blob: 34de2e60e937d0843daae08940fdafc02ee1f12c [file] [log] [blame]
Saurabh Shah86c17292013-02-08 15:24:13 -08001/*
Arun Kumar K.Rc62935a2013-12-03 16:47:47 -08002 * Copyright (c) 2013-14, The Linux Foundation. All rights reserved.
Saurabh Shah86c17292013-02-08 15:24:13 -08003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR CLIENTS; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <hwc_qclient.h>
31#include <IQService.h>
32#include <hwc_utils.h>
Zohaib Alam1bb65612013-09-28 03:38:20 -040033#include <mdp_version.h>
Naseer Ahmed35a268c2014-06-24 19:07:13 -040034#include <hwc_mdpcomp.h>
Tatenda Chipeperekwa06af9cb2014-08-26 14:51:05 -070035#include <hwc_virtual.h>
Saurabh Shah24eec8a2014-08-22 15:07:25 -070036#include <overlay.h>
Raj Kamal0d53fc62014-11-25 17:36:36 +053037#include <display_config.h>
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -050038#include <hdmi.h>
39#include <video/msm_hdmi_modes.h>
Saurabh Shah86c17292013-02-08 15:24:13 -080040
41#define QCLIENT_DEBUG 0
42
43using namespace android;
44using namespace qService;
Arun Kumar K.Rc62935a2013-12-03 16:47:47 -080045using namespace qhwc;
Saurabh Shah24eec8a2014-08-22 15:07:25 -070046using namespace overlay;
Saurabh Shahcd018352014-11-11 13:54:19 -080047using namespace qdutils;
Saurabh Shah86c17292013-02-08 15:24:13 -080048
49namespace qClient {
50
51// ----------------------------------------------------------------------------
Saurabh Shah7128e502013-02-20 13:24:48 -080052QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx),
53 mMPDeathNotifier(new MPDeathNotifier(ctx))
Saurabh Shah86c17292013-02-08 15:24:13 -080054{
55 ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked");
56}
57
58QClient::~QClient()
59{
60 ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked");
61}
62
Naseer Ahmed4957c522013-11-12 18:07:15 -050063static void securing(hwc_context_t *ctx, uint32_t startEnd) {
Saurabh Shahc2125772013-03-15 16:49:50 -070064 //The only way to make this class in this process subscribe to media
65 //player's death.
66 IMediaDeathNotifier::getMediaPlayerService();
67
Raj Kamal58b31a02014-12-16 15:53:53 +053068 ctx->mDrawLock.lock();
Naseer Ahmed4957c522013-11-12 18:07:15 -050069 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080070 //We're done securing
71 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050072 ctx->mSecureMode = true;
Raj Kamal58b31a02014-12-16 15:53:53 +053073 ctx->mDrawLock.unlock();
74
Naseer Ahmed4957c522013-11-12 18:07:15 -050075 if(ctx->proc)
76 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080077}
78
Naseer Ahmed4957c522013-11-12 18:07:15 -050079static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) {
Raj Kamal58b31a02014-12-16 15:53:53 +053080 ctx->mDrawLock.lock();
Naseer Ahmed4957c522013-11-12 18:07:15 -050081 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080082 //We're done unsecuring
83 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050084 ctx->mSecureMode = false;
Raj Kamal58b31a02014-12-16 15:53:53 +053085 ctx->mDrawLock.unlock();
86
Naseer Ahmed4957c522013-11-12 18:07:15 -050087 if(ctx->proc)
88 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080089}
90
Saurabh Shah7128e502013-02-20 13:24:48 -080091void QClient::MPDeathNotifier::died() {
Raj Kamal58b31a02014-12-16 15:53:53 +053092 mHwcContext->mDrawLock.lock();
Saurabh Shah7128e502013-02-20 13:24:48 -080093 ALOGD_IF(QCLIENT_DEBUG, "Media Player died");
94 mHwcContext->mSecuring = false;
95 mHwcContext->mSecureMode = false;
Raj Kamal58b31a02014-12-16 15:53:53 +053096 mHwcContext->mDrawLock.unlock();
Saurabh Shah7128e502013-02-20 13:24:48 -080097 if(mHwcContext->proc)
98 mHwcContext->proc->invalidate(mHwcContext->proc);
99}
100
Naseer Ahmed4957c522013-11-12 18:07:15 -0500101static android::status_t screenRefresh(hwc_context_t *ctx) {
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800102 status_t result = NO_INIT;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500103 if(ctx->proc) {
104 ctx->proc->invalidate(ctx->proc);
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800105 result = NO_ERROR;
106 }
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800107 return result;
108}
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700109
Naseer Ahmed4957c522013-11-12 18:07:15 -0500110static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) {
111 ctx->mExtOrientation = orientation;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700112}
113
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500114static void isExternalConnected(hwc_context_t* ctx, Parcel* outParcel) {
115 int connected;
116 connected = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected ? 1 : 0;
117 outParcel->writeInt32(connected);
118}
119
120static void getDisplayAttributes(hwc_context_t* ctx, const Parcel* inParcel,
121 Parcel* outParcel) {
122 int dpy = inParcel->readInt32();
123 outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period);
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800124 outParcel->writeInt32(ctx->dpyAttr[dpy].xres);
125 outParcel->writeInt32(ctx->dpyAttr[dpy].yres);
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500126 outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi);
127 outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi);
128 //XXX: Need to check what to return for HDMI
129 outParcel->writeInt32(ctx->mMDP.panel);
130}
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800131static void setHSIC(const Parcel* inParcel) {
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500132 int dpy = inParcel->readInt32();
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800133 ALOGD_IF(0, "In %s: dpy = %d", __FUNCTION__, dpy);
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500134 HSICData_t hsic_data;
135 hsic_data.hue = inParcel->readInt32();
136 hsic_data.saturation = inParcel->readFloat();
137 hsic_data.intensity = inParcel->readInt32();
138 hsic_data.contrast = inParcel->readFloat();
139 //XXX: Actually set the HSIC data through ABL lib
140}
141
142
Naseer Ahmed4957c522013-11-12 18:07:15 -0500143static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) {
144 ctx->mBufferMirrorMode = enable;
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700145}
146
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800147static status_t getDisplayVisibleRegion(hwc_context_t* ctx, int dpy,
148 Parcel* outParcel) {
149 // Get the info only if the dpy is valid
150 if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
151 Locker::Autolock _sl(ctx->mDrawLock);
152 if(dpy && (ctx->mExtOrientation || ctx->mBufferMirrorMode)) {
153 // Return the destRect on external, if external orienation
154 // is enabled
155 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.left);
156 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.top);
157 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.right);
158 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.bottom);
159 } else {
160 outParcel->writeInt32(ctx->mViewFrame[dpy].left);
161 outParcel->writeInt32(ctx->mViewFrame[dpy].top);
162 outParcel->writeInt32(ctx->mViewFrame[dpy].right);
163 outParcel->writeInt32(ctx->mViewFrame[dpy].bottom);
164 }
165 return NO_ERROR;
166 } else {
167 ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy);
168 return BAD_VALUE;
169 }
170}
171
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700172// USed for setting the secondary(hdmi/wfd) status
173static void setSecondaryDisplayStatus(hwc_context_t *ctx,
174 const Parcel* inParcel) {
175 uint32_t dpy = inParcel->readInt32();
176 uint32_t status = inParcel->readInt32();
177 ALOGD_IF(QCLIENT_DEBUG, "%s: dpy = %d status = %s", __FUNCTION__,
178 dpy, getExternalDisplayState(status));
179
180 if(dpy > HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
Raj Kamal0d53fc62014-11-25 17:36:36 +0530181 if(dpy == HWC_DISPLAY_VIRTUAL && status == qdutils::EXTERNAL_OFFLINE) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700182 ctx->mWfdSyncLock.lock();
183 ctx->mWfdSyncLock.signal();
184 ctx->mWfdSyncLock.unlock();
Raj Kamal0d53fc62014-11-25 17:36:36 +0530185 } else if(status == qdutils::EXTERNAL_PAUSE) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700186 handle_pause(ctx, dpy);
Raj Kamal0d53fc62014-11-25 17:36:36 +0530187 } else if(status == qdutils::EXTERNAL_RESUME) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700188 handle_resume(ctx, dpy);
189 }
Arun Kumar K.Rc62935a2013-12-03 16:47:47 -0800190 } else {
Ramakant Singh8595cca2014-11-06 16:17:08 +0530191 ALOGE("%s: Invalid dpy %d", __FUNCTION__, dpy);
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700192 return;
Raj kamal59fea562014-04-01 16:52:19 +0530193 }
194}
195
Ramkumar Radhakrishnan0a021a82014-05-19 19:53:56 -0700196
197static status_t setViewFrame(hwc_context_t* ctx, const Parcel* inParcel) {
198 int dpy = inParcel->readInt32();
199 if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
200 Locker::Autolock _sl(ctx->mDrawLock);
201 ctx->mViewFrame[dpy].left = inParcel->readInt32();
202 ctx->mViewFrame[dpy].top = inParcel->readInt32();
203 ctx->mViewFrame[dpy].right = inParcel->readInt32();
204 ctx->mViewFrame[dpy].bottom = inParcel->readInt32();
205 ALOGD_IF(QCLIENT_DEBUG, "%s: mViewFrame[%d] = [%d %d %d %d]",
206 __FUNCTION__, dpy,
207 ctx->mViewFrame[dpy].left, ctx->mViewFrame[dpy].top,
208 ctx->mViewFrame[dpy].right, ctx->mViewFrame[dpy].bottom);
209 return NO_ERROR;
210 } else {
211 ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy);
212 return BAD_VALUE;
213 }
214}
215
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400216static void toggleDynamicDebug(hwc_context_t* ctx, const Parcel* inParcel) {
217 int debug_type = inParcel->readInt32();
218 bool enable = !!inParcel->readInt32();
219 ALOGD("%s: debug_type: %d enable:%d",
220 __FUNCTION__, debug_type, enable);
221 Locker::Autolock _sl(ctx->mDrawLock);
222 switch (debug_type) {
223 //break is ignored for DEBUG_ALL to toggle all of them at once
224 case IQService::DEBUG_ALL:
225 case IQService::DEBUG_MDPCOMP:
226 qhwc::MDPComp::dynamicDebug(enable);
227 if (debug_type != IQService::DEBUG_ALL)
228 break;
229 case IQService::DEBUG_VSYNC:
230 ctx->vstate.debug = enable;
231 if (debug_type != IQService::DEBUG_ALL)
232 break;
Tatenda Chipeperekwa06af9cb2014-08-26 14:51:05 -0700233 case IQService::DEBUG_VD:
Manoj Kumar AVM9591a5e2014-08-21 22:50:21 -0700234 HWCVirtualVDS::dynamicDebug(enable);
Tatenda Chipeperekwa06af9cb2014-08-26 14:51:05 -0700235 if (debug_type != IQService::DEBUG_ALL)
236 break;
Saurabh Shah24eec8a2014-08-22 15:07:25 -0700237 case IQService::DEBUG_PIPE_LIFECYCLE:
238 Overlay::debugPipeLifecycle(enable);
239 if (debug_type != IQService::DEBUG_ALL)
240 break;
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400241 }
242}
243
Saurabh Shah59562ff2014-09-30 16:13:12 -0700244static void setIdleTimeout(hwc_context_t* ctx, const Parcel* inParcel) {
245 uint32_t timeout = (uint32_t)inParcel->readInt32();
246 ALOGD("%s :%u ms", __FUNCTION__, timeout);
247 Locker::Autolock _sl(ctx->mDrawLock);
248 MDPComp::setIdleTimeout(timeout);
249}
250
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700251static void setMaxPipesPerMixer(hwc_context_t* ctx, const Parcel* inParcel) {
252 uint32_t value = (uint32_t)inParcel->readInt32();
253 ALOGD("%s : setting MaxPipesPerMixer: %d ", __FUNCTION__, value);
254 Locker::Autolock _sl(ctx->mDrawLock);
255 MDPComp::setMaxPipesPerMixer(value);
256}
257
Saurabh Shahcd018352014-11-11 13:54:19 -0800258static void toggleBWC(hwc_context_t* ctx, const Parcel* inParcel) {
259 uint32_t enable = (uint32_t)inParcel->readInt32();
260 if(MDPVersion::getInstance().supportsBWC()) {
261 Locker::Autolock _sl(ctx->mDrawLock);
262 ctx->mBWCEnabled = (bool) enable;
263 ALOGI("%s: Set BWC to %d", __FUNCTION__, enable);
264 } else {
265 ALOGI("%s: Target doesn't support BWC", __FUNCTION__);
266 }
267}
268
Raj Kamal0d53fc62014-11-25 17:36:36 +0530269static void configureDynRefreshRate(hwc_context_t* ctx,
270 const Parcel* inParcel) {
271 uint32_t op = (uint32_t)inParcel->readInt32();
272 uint32_t refresh_rate = (uint32_t)inParcel->readInt32();
273 MDPVersion& mdpHw = MDPVersion::getInstance();
274 uint32_t dpy = HWC_DISPLAY_PRIMARY;
275
276 if(mdpHw.isDynFpsSupported()) {
277 Locker::Autolock _sl(ctx->mDrawLock);
278
279 switch (op) {
280 case DISABLE_METADATA_DYN_REFRESH_RATE:
281 ctx->mUseMetaDataRefreshRate = false;
282 setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate);
283 break;
284 case ENABLE_METADATA_DYN_REFRESH_RATE:
285 ctx->mUseMetaDataRefreshRate = true;
286 setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate);
287 break;
288 case SET_BINDER_DYN_REFRESH_RATE:
289 if(ctx->mUseMetaDataRefreshRate)
290 ALOGW("%s: Ignoring binder request to change refresh-rate",
291 __FUNCTION__);
292 else {
293 uint32_t rate = roundOff(refresh_rate);
294 if((rate >= mdpHw.getMinFpsSupported() &&
295 rate <= mdpHw.getMaxFpsSupported())) {
296 setRefreshRate(ctx, dpy, rate);
297 } else {
298 ALOGE("%s: Requested refresh-rate should be between \
299 (%d) and (%d). Given (%d)", __FUNCTION__,
300 mdpHw.getMinFpsSupported(),
301 mdpHw.getMaxFpsSupported(), rate);
302 }
303 }
304 break;
305 default:
306 ALOGE("%s: Invalid op %d",__FUNCTION__,op);
307 }
308 }
309}
310
Jeykumar Sankaran14d41a82015-03-11 14:13:43 -0700311static status_t setPartialUpdateState(hwc_context_t *ctx, uint32_t state) {
312 ALOGD("%s: state: %d", __FUNCTION__, state);
313 switch(state) {
314 case IQService::PREF_PARTIAL_UPDATE:
315 if(qhwc::MDPComp::setPartialUpdatePref(ctx, true) < 0)
316 return NO_INIT;
317 return NO_ERROR;
318 case IQService::PREF_POST_PROCESSING:
319 if(qhwc::MDPComp::setPartialUpdatePref(ctx, false) < 0)
320 return NO_INIT;
321 qhwc::MDPComp::enablePartialUpdate(false);
322 return NO_ERROR;
323 case IQService::ENABLE_PARTIAL_UPDATE:
324 qhwc::MDPComp::enablePartialUpdate(true);
325 return NO_ERROR;
326 default:
327 ALOGE("%s: Invalid state", __FUNCTION__);
328 return NO_ERROR;
329 };
Jeykumar Sankaran53b05f22014-08-05 11:27:03 -0700330}
331
Naseer Ahmed78951b22014-12-10 18:19:21 -0500332static void toggleScreenUpdate(hwc_context_t* ctx, uint32_t on) {
333 ALOGD("%s: toggle update: %d", __FUNCTION__, on);
Naseer Ahmed78951b22014-12-10 18:19:21 -0500334 if (on == 0) {
Raj Kamal58b31a02014-12-16 15:53:53 +0530335 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500336 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = true;
337 ctx->mOverlay->configBegin();
338 ctx->mOverlay->configDone();
339 ctx->mRotMgr->clear();
340 if(!Overlay::displayCommit(ctx->dpyAttr[0].fd)) {
341 ALOGE("%s: Display commit failed", __FUNCTION__);
342 }
Raj Kamal58b31a02014-12-16 15:53:53 +0530343 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500344 } else {
Raj Kamal58b31a02014-12-16 15:53:53 +0530345 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500346 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = false;
Raj Kamal58b31a02014-12-16 15:53:53 +0530347 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500348 ctx->proc->invalidate(ctx->proc);
349 }
350}
351
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500352static void setS3DMode(hwc_context_t* ctx, int mode) {
353 if (ctx->mHDMIDisplay) {
354 if(ctx->mHDMIDisplay->isS3DModeSupported(mode)) {
355 ALOGD("%s: Force S3D mode to %d", __FUNCTION__, mode);
356 Locker::Autolock _sl(ctx->mDrawLock);
357 ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].s3dModeForced = true;
358 setup3DMode(ctx, HWC_DISPLAY_EXTERNAL, mode);
359 } else {
360 ALOGD("%s: mode %d is not supported", __FUNCTION__, mode);
361 }
362 } else {
363 ALOGE("%s: No HDMI Display detected", __FUNCTION__);
364 }
365}
366
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800367static status_t setActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
368 Parcel *outParcel) {
369 uint32_t index = inParcel->readInt32();
370 int dpy = inParcel->readInt32();
371 //Currently only primary supported
372 if(dpy > HWC_DISPLAY_PRIMARY) {
373 return BAD_VALUE;
374 }
375
376 Configs *configs = Configs::getInstance();
377 if(configs == NULL) {
378 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
379 return INVALID_OPERATION;
380 }
381
382 if(configs->getActiveConfig() == index) {
383 ALOGI("%s(): Config %u is already set", __FUNCTION__, index);
384 return ALREADY_EXISTS;
385 }
386
387 ctx->mDrawLock.lock();
388 //Updates the necessary sysfs nodes and reads split info again which is
389 //needed to reinitialize composition resources.
390 if(configs->setActiveConfig(index) == false) {
391 ALOGE("%s(): Failed to set config %u", __FUNCTION__, index);
392 ctx->mDrawLock.unlock();
393 return UNKNOWN_ERROR;
394 }
395
396 qdutils::DisplayAttributes attr = configs->getAttributes(index);
397
398 ctx->dpyAttr[dpy].xres = attr.xres;
399 ctx->dpyAttr[dpy].yres = attr.yres;
400
401 ctx->dpyAttr[dpy].fbScaling = ((ctx->dpyAttr[dpy].xres !=
402 ctx->dpyAttr[dpy].xresFB) || (ctx->dpyAttr[dpy].yres !=
403 ctx->dpyAttr[dpy].yresFB));
404
405 destroyCompositionResources(ctx, dpy);
406 initCompositionResources(ctx, dpy);
407 ctx->dpyAttr[dpy].configSwitched = true;
408 ctx->mDrawLock.unlock();
409 ctx->proc->invalidate(ctx->proc);
410 return NO_ERROR;
411}
412
413static status_t getActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
414 Parcel *outParcel) {
415 Locker::Autolock _sl(ctx->mDrawLock);
416 int dpy = inParcel->readInt32();
417 //Currently only primary supported
418 if(dpy > HWC_DISPLAY_PRIMARY) {
419 return BAD_VALUE;
420 }
421
422 Configs *configs = Configs::getInstance();
423 if(configs == NULL) {
424 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
425 return INVALID_OPERATION;
426 }
427
428 outParcel->writeInt32(configs->getActiveConfig());
429 return NO_ERROR;
430}
431
432static status_t getConfigCount(hwc_context_t* ctx, const Parcel *inParcel,
433 Parcel *outParcel) {
434 Locker::Autolock _sl(ctx->mDrawLock);
435 int dpy = inParcel->readInt32();
436 //Currently only primary supported
437 if(dpy > HWC_DISPLAY_PRIMARY) {
438 return BAD_VALUE;
439 }
440
441 Configs *configs = Configs::getInstance();
442 if(configs == NULL) {
443 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
444 return INVALID_OPERATION;
445 }
446
447 outParcel->writeInt32(configs->getConfigCount());
448 return NO_ERROR;
449}
450
451static status_t getDisplayAttributesForConfig(hwc_context_t* ctx,
452 const Parcel *inParcel, Parcel *outParcel) {
453 Locker::Autolock _sl(ctx->mDrawLock);
454 uint32_t index = inParcel->readInt32();
455 int dpy = inParcel->readInt32();
456 //Currently only primary supported
457 if(dpy > HWC_DISPLAY_PRIMARY) {
458 return BAD_VALUE;
459 }
460
461 Configs *configs = Configs::getInstance();
462 if(configs == NULL) {
463 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
464 return INVALID_OPERATION;
465 }
466
467 //xres, yres are used from the Config class, we assume for now that the
468 //other params are the same. This might change in the future.
469 outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period);
470
471 qdutils::DisplayAttributes attr = configs->getAttributes(index);
472 outParcel->writeInt32(attr.xres);
473 outParcel->writeInt32(attr.yres);
474
475 outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi);
476 outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi);
477 outParcel->writeInt32(ctx->mMDP.panel);
478
479 return NO_ERROR;
480}
481
Naseer Ahmed4957c522013-11-12 18:07:15 -0500482status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel,
483 Parcel* outParcel) {
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800484 status_t ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500485
Naseer Ahmed4957c522013-11-12 18:07:15 -0500486 switch(command) {
487 case IQService::SECURING:
488 securing(mHwcContext, inParcel->readInt32());
489 break;
490 case IQService::UNSECURING:
491 unsecuring(mHwcContext, inParcel->readInt32());
492 break;
493 case IQService::SCREEN_REFRESH:
494 return screenRefresh(mHwcContext);
495 break;
496 case IQService::EXTERNAL_ORIENTATION:
497 setExtOrientation(mHwcContext, inParcel->readInt32());
498 break;
499 case IQService::BUFFER_MIRRORMODE:
500 setBufferMirrorMode(mHwcContext, inParcel->readInt32());
501 break;
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800502 case IQService::GET_DISPLAY_VISIBLE_REGION:
503 ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(),
504 outParcel);
505 break;
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500506 case IQService::CHECK_EXTERNAL_STATUS:
507 isExternalConnected(mHwcContext, outParcel);
508 break;
509 case IQService::GET_DISPLAY_ATTRIBUTES:
510 getDisplayAttributes(mHwcContext, inParcel, outParcel);
511 break;
512 case IQService::SET_HSIC_DATA:
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800513 setHSIC(inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530514 break;
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700515 case IQService::SET_SECONDARY_DISPLAY_STATUS:
516 setSecondaryDisplayStatus(mHwcContext, inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530517 break;
Ramkumar Radhakrishnan0a021a82014-05-19 19:53:56 -0700518 case IQService::SET_VIEW_FRAME:
519 setViewFrame(mHwcContext, inParcel);
520 break;
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400521 case IQService::DYNAMIC_DEBUG:
522 toggleDynamicDebug(mHwcContext, inParcel);
523 break;
Saurabh Shah59562ff2014-09-30 16:13:12 -0700524 case IQService::SET_IDLE_TIMEOUT:
525 setIdleTimeout(mHwcContext, inParcel);
526 break;
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700527 case IQService::SET_MAX_PIPES_PER_MIXER:
528 setMaxPipesPerMixer(mHwcContext, inParcel);
Jeykumar Sankaran85ddc0c2014-12-17 14:39:26 -0800529 break;
Jeykumar Sankaran53b05f22014-08-05 11:27:03 -0700530 case IQService::SET_PARTIAL_UPDATE:
Jeykumar Sankaran14d41a82015-03-11 14:13:43 -0700531 ret = setPartialUpdateState(mHwcContext, inParcel->readInt32());
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700532 break;
Saurabh Shahcd018352014-11-11 13:54:19 -0800533 case IQService::TOGGLE_BWC:
534 toggleBWC(mHwcContext, inParcel);
535 break;
Raj Kamal0d53fc62014-11-25 17:36:36 +0530536 case IQService::CONFIGURE_DYN_REFRESH_RATE:
537 configureDynRefreshRate(mHwcContext, inParcel);
538 break;
Naseer Ahmed78951b22014-12-10 18:19:21 -0500539 case IQService::TOGGLE_SCREEN_UPDATE:
540 toggleScreenUpdate(mHwcContext, inParcel->readInt32());
541 break;
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500542 case IQService::SET_S3D_MODE:
543 setS3DMode(mHwcContext, inParcel->readInt32());
544 break;
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800545 case IQService::SET_ACTIVE_CONFIG:
546 ret = setActiveConfig(mHwcContext, inParcel, outParcel);
547 break;
548 case IQService::GET_ACTIVE_CONFIG:
549 ret = getActiveConfig(mHwcContext, inParcel, outParcel);
550 break;
551 case IQService::GET_CONFIG_COUNT:
552 ret = getConfigCount(mHwcContext, inParcel, outParcel);
553 break;
554 case IQService::GET_DISPLAY_ATTRIBUTES_FOR_CONFIG:
555 ret = getDisplayAttributesForConfig(mHwcContext, inParcel,
556 outParcel);
557 break;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500558 default:
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800559 ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500560 }
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800561 return ret;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500562}
563
Saurabh Shah86c17292013-02-08 15:24:13 -0800564}