blob: f18ad3666eed8780560ad197d4c3d8008da54403 [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>
Zohaib Alam83ea46d2015-03-23 15:44:19 -040040#include <hwc_qdcm.h>
Saurabh Shah86c17292013-02-08 15:24:13 -080041
42#define QCLIENT_DEBUG 0
43
44using namespace android;
45using namespace qService;
Arun Kumar K.Rc62935a2013-12-03 16:47:47 -080046using namespace qhwc;
Saurabh Shah24eec8a2014-08-22 15:07:25 -070047using namespace overlay;
Saurabh Shahcd018352014-11-11 13:54:19 -080048using namespace qdutils;
Zohaib Alam83ea46d2015-03-23 15:44:19 -040049using namespace qQdcm;
Saurabh Shah86c17292013-02-08 15:24:13 -080050
51namespace qClient {
52
53// ----------------------------------------------------------------------------
Saurabh Shah7128e502013-02-20 13:24:48 -080054QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx),
55 mMPDeathNotifier(new MPDeathNotifier(ctx))
Saurabh Shah86c17292013-02-08 15:24:13 -080056{
57 ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked");
58}
59
60QClient::~QClient()
61{
62 ALOGD_IF(QCLIENT_DEBUG,"QClient Destructor invoked");
63}
64
Naseer Ahmed4957c522013-11-12 18:07:15 -050065static void securing(hwc_context_t *ctx, uint32_t startEnd) {
Saurabh Shahc2125772013-03-15 16:49:50 -070066 //The only way to make this class in this process subscribe to media
67 //player's death.
68 IMediaDeathNotifier::getMediaPlayerService();
69
Raj Kamal58b31a02014-12-16 15:53:53 +053070 ctx->mDrawLock.lock();
Naseer Ahmed4957c522013-11-12 18:07:15 -050071 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080072 //We're done securing
73 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050074 ctx->mSecureMode = true;
Raj Kamal58b31a02014-12-16 15:53:53 +053075 ctx->mDrawLock.unlock();
76
Naseer Ahmed4957c522013-11-12 18:07:15 -050077 if(ctx->proc)
78 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080079}
80
Naseer Ahmed4957c522013-11-12 18:07:15 -050081static void unsecuring(hwc_context_t *ctx, uint32_t startEnd) {
Raj Kamal58b31a02014-12-16 15:53:53 +053082 ctx->mDrawLock.lock();
Naseer Ahmed4957c522013-11-12 18:07:15 -050083 ctx->mSecuring = startEnd;
Saurabh Shah86c17292013-02-08 15:24:13 -080084 //We're done unsecuring
85 if(startEnd == IQService::END)
Naseer Ahmed4957c522013-11-12 18:07:15 -050086 ctx->mSecureMode = false;
Raj Kamal58b31a02014-12-16 15:53:53 +053087 ctx->mDrawLock.unlock();
88
Naseer Ahmed4957c522013-11-12 18:07:15 -050089 if(ctx->proc)
90 ctx->proc->invalidate(ctx->proc);
Saurabh Shah86c17292013-02-08 15:24:13 -080091}
92
Saurabh Shah7128e502013-02-20 13:24:48 -080093void QClient::MPDeathNotifier::died() {
Raj Kamal58b31a02014-12-16 15:53:53 +053094 mHwcContext->mDrawLock.lock();
Saurabh Shah7128e502013-02-20 13:24:48 -080095 ALOGD_IF(QCLIENT_DEBUG, "Media Player died");
96 mHwcContext->mSecuring = false;
97 mHwcContext->mSecureMode = false;
Raj Kamal58b31a02014-12-16 15:53:53 +053098 mHwcContext->mDrawLock.unlock();
Saurabh Shah7128e502013-02-20 13:24:48 -080099 if(mHwcContext->proc)
100 mHwcContext->proc->invalidate(mHwcContext->proc);
101}
102
Naseer Ahmed4957c522013-11-12 18:07:15 -0500103static android::status_t screenRefresh(hwc_context_t *ctx) {
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800104 status_t result = NO_INIT;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500105 if(ctx->proc) {
106 ctx->proc->invalidate(ctx->proc);
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800107 result = NO_ERROR;
108 }
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -0800109 return result;
110}
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700111
Naseer Ahmed4957c522013-11-12 18:07:15 -0500112static void setExtOrientation(hwc_context_t *ctx, uint32_t orientation) {
113 ctx->mExtOrientation = orientation;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700114}
115
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500116static void isExternalConnected(hwc_context_t* ctx, Parcel* outParcel) {
117 int connected;
118 connected = ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected ? 1 : 0;
119 outParcel->writeInt32(connected);
120}
121
122static void getDisplayAttributes(hwc_context_t* ctx, const Parcel* inParcel,
123 Parcel* outParcel) {
124 int dpy = inParcel->readInt32();
125 outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period);
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800126 outParcel->writeInt32(ctx->dpyAttr[dpy].xres);
127 outParcel->writeInt32(ctx->dpyAttr[dpy].yres);
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500128 outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi);
129 outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi);
130 //XXX: Need to check what to return for HDMI
131 outParcel->writeInt32(ctx->mMDP.panel);
132}
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800133static void setHSIC(const Parcel* inParcel) {
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500134 int dpy = inParcel->readInt32();
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800135 ALOGD_IF(0, "In %s: dpy = %d", __FUNCTION__, dpy);
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500136 HSICData_t hsic_data;
137 hsic_data.hue = inParcel->readInt32();
138 hsic_data.saturation = inParcel->readFloat();
139 hsic_data.intensity = inParcel->readInt32();
140 hsic_data.contrast = inParcel->readFloat();
141 //XXX: Actually set the HSIC data through ABL lib
142}
143
144
Naseer Ahmed4957c522013-11-12 18:07:15 -0500145static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) {
146 ctx->mBufferMirrorMode = enable;
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700147}
148
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800149static status_t getDisplayVisibleRegion(hwc_context_t* ctx, int dpy,
150 Parcel* outParcel) {
151 // Get the info only if the dpy is valid
152 if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
153 Locker::Autolock _sl(ctx->mDrawLock);
154 if(dpy && (ctx->mExtOrientation || ctx->mBufferMirrorMode)) {
155 // Return the destRect on external, if external orienation
156 // is enabled
157 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.left);
158 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.top);
159 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.right);
160 outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.bottom);
161 } else {
162 outParcel->writeInt32(ctx->mViewFrame[dpy].left);
163 outParcel->writeInt32(ctx->mViewFrame[dpy].top);
164 outParcel->writeInt32(ctx->mViewFrame[dpy].right);
165 outParcel->writeInt32(ctx->mViewFrame[dpy].bottom);
166 }
167 return NO_ERROR;
168 } else {
169 ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy);
170 return BAD_VALUE;
171 }
172}
173
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700174// USed for setting the secondary(hdmi/wfd) status
175static void setSecondaryDisplayStatus(hwc_context_t *ctx,
176 const Parcel* inParcel) {
177 uint32_t dpy = inParcel->readInt32();
178 uint32_t status = inParcel->readInt32();
179 ALOGD_IF(QCLIENT_DEBUG, "%s: dpy = %d status = %s", __FUNCTION__,
180 dpy, getExternalDisplayState(status));
181
182 if(dpy > HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
Raj Kamal0d53fc62014-11-25 17:36:36 +0530183 if(dpy == HWC_DISPLAY_VIRTUAL && status == qdutils::EXTERNAL_OFFLINE) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700184 ctx->mWfdSyncLock.lock();
185 ctx->mWfdSyncLock.signal();
186 ctx->mWfdSyncLock.unlock();
Raj Kamal0d53fc62014-11-25 17:36:36 +0530187 } else if(status == qdutils::EXTERNAL_PAUSE) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700188 handle_pause(ctx, dpy);
Raj Kamal0d53fc62014-11-25 17:36:36 +0530189 } else if(status == qdutils::EXTERNAL_RESUME) {
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700190 handle_resume(ctx, dpy);
191 }
Arun Kumar K.Rc62935a2013-12-03 16:47:47 -0800192 } else {
Ramakant Singh8595cca2014-11-06 16:17:08 +0530193 ALOGE("%s: Invalid dpy %d", __FUNCTION__, dpy);
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700194 return;
Raj kamal59fea562014-04-01 16:52:19 +0530195 }
196}
197
Ramkumar Radhakrishnan0a021a82014-05-19 19:53:56 -0700198
199static status_t setViewFrame(hwc_context_t* ctx, const Parcel* inParcel) {
200 int dpy = inParcel->readInt32();
201 if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) {
202 Locker::Autolock _sl(ctx->mDrawLock);
203 ctx->mViewFrame[dpy].left = inParcel->readInt32();
204 ctx->mViewFrame[dpy].top = inParcel->readInt32();
205 ctx->mViewFrame[dpy].right = inParcel->readInt32();
206 ctx->mViewFrame[dpy].bottom = inParcel->readInt32();
207 ALOGD_IF(QCLIENT_DEBUG, "%s: mViewFrame[%d] = [%d %d %d %d]",
208 __FUNCTION__, dpy,
209 ctx->mViewFrame[dpy].left, ctx->mViewFrame[dpy].top,
210 ctx->mViewFrame[dpy].right, ctx->mViewFrame[dpy].bottom);
211 return NO_ERROR;
212 } else {
213 ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy);
214 return BAD_VALUE;
215 }
216}
217
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400218static void toggleDynamicDebug(hwc_context_t* ctx, const Parcel* inParcel) {
219 int debug_type = inParcel->readInt32();
220 bool enable = !!inParcel->readInt32();
221 ALOGD("%s: debug_type: %d enable:%d",
222 __FUNCTION__, debug_type, enable);
223 Locker::Autolock _sl(ctx->mDrawLock);
224 switch (debug_type) {
225 //break is ignored for DEBUG_ALL to toggle all of them at once
226 case IQService::DEBUG_ALL:
227 case IQService::DEBUG_MDPCOMP:
228 qhwc::MDPComp::dynamicDebug(enable);
229 if (debug_type != IQService::DEBUG_ALL)
230 break;
231 case IQService::DEBUG_VSYNC:
232 ctx->vstate.debug = enable;
233 if (debug_type != IQService::DEBUG_ALL)
234 break;
Tatenda Chipeperekwa06af9cb2014-08-26 14:51:05 -0700235 case IQService::DEBUG_VD:
Manoj Kumar AVM9591a5e2014-08-21 22:50:21 -0700236 HWCVirtualVDS::dynamicDebug(enable);
Tatenda Chipeperekwa06af9cb2014-08-26 14:51:05 -0700237 if (debug_type != IQService::DEBUG_ALL)
238 break;
Saurabh Shah24eec8a2014-08-22 15:07:25 -0700239 case IQService::DEBUG_PIPE_LIFECYCLE:
240 Overlay::debugPipeLifecycle(enable);
241 if (debug_type != IQService::DEBUG_ALL)
242 break;
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400243 }
244}
245
Saurabh Shah59562ff2014-09-30 16:13:12 -0700246static void setIdleTimeout(hwc_context_t* ctx, const Parcel* inParcel) {
247 uint32_t timeout = (uint32_t)inParcel->readInt32();
248 ALOGD("%s :%u ms", __FUNCTION__, timeout);
249 Locker::Autolock _sl(ctx->mDrawLock);
250 MDPComp::setIdleTimeout(timeout);
251}
252
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700253static void setMaxPipesPerMixer(hwc_context_t* ctx, const Parcel* inParcel) {
254 uint32_t value = (uint32_t)inParcel->readInt32();
255 ALOGD("%s : setting MaxPipesPerMixer: %d ", __FUNCTION__, value);
256 Locker::Autolock _sl(ctx->mDrawLock);
257 MDPComp::setMaxPipesPerMixer(value);
258}
259
Saurabh Shahcd018352014-11-11 13:54:19 -0800260static void toggleBWC(hwc_context_t* ctx, const Parcel* inParcel) {
261 uint32_t enable = (uint32_t)inParcel->readInt32();
262 if(MDPVersion::getInstance().supportsBWC()) {
263 Locker::Autolock _sl(ctx->mDrawLock);
264 ctx->mBWCEnabled = (bool) enable;
265 ALOGI("%s: Set BWC to %d", __FUNCTION__, enable);
266 } else {
267 ALOGI("%s: Target doesn't support BWC", __FUNCTION__);
268 }
269}
270
Raj Kamal0d53fc62014-11-25 17:36:36 +0530271static void configureDynRefreshRate(hwc_context_t* ctx,
272 const Parcel* inParcel) {
273 uint32_t op = (uint32_t)inParcel->readInt32();
274 uint32_t refresh_rate = (uint32_t)inParcel->readInt32();
275 MDPVersion& mdpHw = MDPVersion::getInstance();
276 uint32_t dpy = HWC_DISPLAY_PRIMARY;
277
278 if(mdpHw.isDynFpsSupported()) {
279 Locker::Autolock _sl(ctx->mDrawLock);
280
281 switch (op) {
282 case DISABLE_METADATA_DYN_REFRESH_RATE:
283 ctx->mUseMetaDataRefreshRate = false;
284 setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate);
285 break;
286 case ENABLE_METADATA_DYN_REFRESH_RATE:
287 ctx->mUseMetaDataRefreshRate = true;
288 setRefreshRate(ctx, dpy, ctx->dpyAttr[dpy].refreshRate);
289 break;
290 case SET_BINDER_DYN_REFRESH_RATE:
291 if(ctx->mUseMetaDataRefreshRate)
292 ALOGW("%s: Ignoring binder request to change refresh-rate",
293 __FUNCTION__);
294 else {
295 uint32_t rate = roundOff(refresh_rate);
296 if((rate >= mdpHw.getMinFpsSupported() &&
297 rate <= mdpHw.getMaxFpsSupported())) {
298 setRefreshRate(ctx, dpy, rate);
299 } else {
300 ALOGE("%s: Requested refresh-rate should be between \
301 (%d) and (%d). Given (%d)", __FUNCTION__,
302 mdpHw.getMinFpsSupported(),
303 mdpHw.getMaxFpsSupported(), rate);
304 }
305 }
306 break;
307 default:
308 ALOGE("%s: Invalid op %d",__FUNCTION__,op);
309 }
310 }
311}
312
Jeykumar Sankaran14d41a82015-03-11 14:13:43 -0700313static status_t setPartialUpdateState(hwc_context_t *ctx, uint32_t state) {
314 ALOGD("%s: state: %d", __FUNCTION__, state);
315 switch(state) {
316 case IQService::PREF_PARTIAL_UPDATE:
317 if(qhwc::MDPComp::setPartialUpdatePref(ctx, true) < 0)
318 return NO_INIT;
319 return NO_ERROR;
320 case IQService::PREF_POST_PROCESSING:
321 if(qhwc::MDPComp::setPartialUpdatePref(ctx, false) < 0)
322 return NO_INIT;
323 qhwc::MDPComp::enablePartialUpdate(false);
324 return NO_ERROR;
325 case IQService::ENABLE_PARTIAL_UPDATE:
326 qhwc::MDPComp::enablePartialUpdate(true);
327 return NO_ERROR;
328 default:
329 ALOGE("%s: Invalid state", __FUNCTION__);
330 return NO_ERROR;
331 };
Jeykumar Sankaran53b05f22014-08-05 11:27:03 -0700332}
333
Naseer Ahmed78951b22014-12-10 18:19:21 -0500334static void toggleScreenUpdate(hwc_context_t* ctx, uint32_t on) {
335 ALOGD("%s: toggle update: %d", __FUNCTION__, on);
Naseer Ahmed78951b22014-12-10 18:19:21 -0500336 if (on == 0) {
Raj Kamal58b31a02014-12-16 15:53:53 +0530337 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500338 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = true;
339 ctx->mOverlay->configBegin();
340 ctx->mOverlay->configDone();
341 ctx->mRotMgr->clear();
342 if(!Overlay::displayCommit(ctx->dpyAttr[0].fd)) {
343 ALOGE("%s: Display commit failed", __FUNCTION__);
344 }
Raj Kamal58b31a02014-12-16 15:53:53 +0530345 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500346 } else {
Raj Kamal58b31a02014-12-16 15:53:53 +0530347 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500348 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = false;
Raj Kamal58b31a02014-12-16 15:53:53 +0530349 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500350 ctx->proc->invalidate(ctx->proc);
351 }
352}
353
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500354static void setS3DMode(hwc_context_t* ctx, int mode) {
355 if (ctx->mHDMIDisplay) {
356 if(ctx->mHDMIDisplay->isS3DModeSupported(mode)) {
357 ALOGD("%s: Force S3D mode to %d", __FUNCTION__, mode);
358 Locker::Autolock _sl(ctx->mDrawLock);
359 ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].s3dModeForced = true;
360 setup3DMode(ctx, HWC_DISPLAY_EXTERNAL, mode);
361 } else {
362 ALOGD("%s: mode %d is not supported", __FUNCTION__, mode);
363 }
364 } else {
365 ALOGE("%s: No HDMI Display detected", __FUNCTION__);
366 }
367}
368
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800369static status_t setActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
370 Parcel *outParcel) {
371 uint32_t index = inParcel->readInt32();
372 int dpy = inParcel->readInt32();
373 //Currently only primary supported
374 if(dpy > HWC_DISPLAY_PRIMARY) {
375 return BAD_VALUE;
376 }
377
378 Configs *configs = Configs::getInstance();
379 if(configs == NULL) {
380 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
381 return INVALID_OPERATION;
382 }
383
384 if(configs->getActiveConfig() == index) {
385 ALOGI("%s(): Config %u is already set", __FUNCTION__, index);
386 return ALREADY_EXISTS;
387 }
388
389 ctx->mDrawLock.lock();
390 //Updates the necessary sysfs nodes and reads split info again which is
391 //needed to reinitialize composition resources.
392 if(configs->setActiveConfig(index) == false) {
393 ALOGE("%s(): Failed to set config %u", __FUNCTION__, index);
394 ctx->mDrawLock.unlock();
395 return UNKNOWN_ERROR;
396 }
397
398 qdutils::DisplayAttributes attr = configs->getAttributes(index);
399
400 ctx->dpyAttr[dpy].xres = attr.xres;
401 ctx->dpyAttr[dpy].yres = attr.yres;
402
403 ctx->dpyAttr[dpy].fbScaling = ((ctx->dpyAttr[dpy].xres !=
404 ctx->dpyAttr[dpy].xresFB) || (ctx->dpyAttr[dpy].yres !=
405 ctx->dpyAttr[dpy].yresFB));
406
407 destroyCompositionResources(ctx, dpy);
408 initCompositionResources(ctx, dpy);
409 ctx->dpyAttr[dpy].configSwitched = true;
410 ctx->mDrawLock.unlock();
411 ctx->proc->invalidate(ctx->proc);
412 return NO_ERROR;
413}
414
415static status_t getActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
416 Parcel *outParcel) {
417 Locker::Autolock _sl(ctx->mDrawLock);
418 int dpy = inParcel->readInt32();
419 //Currently only primary supported
420 if(dpy > HWC_DISPLAY_PRIMARY) {
421 return BAD_VALUE;
422 }
423
424 Configs *configs = Configs::getInstance();
425 if(configs == NULL) {
426 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
427 return INVALID_OPERATION;
428 }
429
430 outParcel->writeInt32(configs->getActiveConfig());
431 return NO_ERROR;
432}
433
434static status_t getConfigCount(hwc_context_t* ctx, const Parcel *inParcel,
435 Parcel *outParcel) {
436 Locker::Autolock _sl(ctx->mDrawLock);
437 int dpy = inParcel->readInt32();
438 //Currently only primary supported
439 if(dpy > HWC_DISPLAY_PRIMARY) {
440 return BAD_VALUE;
441 }
442
443 Configs *configs = Configs::getInstance();
444 if(configs == NULL) {
445 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
446 return INVALID_OPERATION;
447 }
448
449 outParcel->writeInt32(configs->getConfigCount());
450 return NO_ERROR;
451}
452
453static status_t getDisplayAttributesForConfig(hwc_context_t* ctx,
454 const Parcel *inParcel, Parcel *outParcel) {
455 Locker::Autolock _sl(ctx->mDrawLock);
456 uint32_t index = inParcel->readInt32();
457 int dpy = inParcel->readInt32();
458 //Currently only primary supported
459 if(dpy > HWC_DISPLAY_PRIMARY) {
460 return BAD_VALUE;
461 }
462
463 Configs *configs = Configs::getInstance();
464 if(configs == NULL) {
465 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
466 return INVALID_OPERATION;
467 }
468
469 //xres, yres are used from the Config class, we assume for now that the
470 //other params are the same. This might change in the future.
471 outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period);
472
473 qdutils::DisplayAttributes attr = configs->getAttributes(index);
474 outParcel->writeInt32(attr.xres);
475 outParcel->writeInt32(attr.yres);
476
477 outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi);
478 outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi);
479 outParcel->writeInt32(ctx->mMDP.panel);
480
481 return NO_ERROR;
482}
483
Naseer Ahmed4957c522013-11-12 18:07:15 -0500484status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel,
485 Parcel* outParcel) {
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800486 status_t ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500487
Naseer Ahmed4957c522013-11-12 18:07:15 -0500488 switch(command) {
489 case IQService::SECURING:
490 securing(mHwcContext, inParcel->readInt32());
491 break;
492 case IQService::UNSECURING:
493 unsecuring(mHwcContext, inParcel->readInt32());
494 break;
495 case IQService::SCREEN_REFRESH:
496 return screenRefresh(mHwcContext);
497 break;
498 case IQService::EXTERNAL_ORIENTATION:
499 setExtOrientation(mHwcContext, inParcel->readInt32());
500 break;
501 case IQService::BUFFER_MIRRORMODE:
502 setBufferMirrorMode(mHwcContext, inParcel->readInt32());
503 break;
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800504 case IQService::GET_DISPLAY_VISIBLE_REGION:
505 ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(),
506 outParcel);
507 break;
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500508 case IQService::CHECK_EXTERNAL_STATUS:
509 isExternalConnected(mHwcContext, outParcel);
510 break;
511 case IQService::GET_DISPLAY_ATTRIBUTES:
512 getDisplayAttributes(mHwcContext, inParcel, outParcel);
513 break;
514 case IQService::SET_HSIC_DATA:
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800515 setHSIC(inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530516 break;
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700517 case IQService::SET_SECONDARY_DISPLAY_STATUS:
518 setSecondaryDisplayStatus(mHwcContext, inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530519 break;
Ramkumar Radhakrishnan0a021a82014-05-19 19:53:56 -0700520 case IQService::SET_VIEW_FRAME:
521 setViewFrame(mHwcContext, inParcel);
522 break;
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400523 case IQService::DYNAMIC_DEBUG:
524 toggleDynamicDebug(mHwcContext, inParcel);
525 break;
Saurabh Shah59562ff2014-09-30 16:13:12 -0700526 case IQService::SET_IDLE_TIMEOUT:
527 setIdleTimeout(mHwcContext, inParcel);
528 break;
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700529 case IQService::SET_MAX_PIPES_PER_MIXER:
530 setMaxPipesPerMixer(mHwcContext, inParcel);
Jeykumar Sankaran85ddc0c2014-12-17 14:39:26 -0800531 break;
Jeykumar Sankaran53b05f22014-08-05 11:27:03 -0700532 case IQService::SET_PARTIAL_UPDATE:
Jeykumar Sankaran14d41a82015-03-11 14:13:43 -0700533 ret = setPartialUpdateState(mHwcContext, inParcel->readInt32());
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700534 break;
Saurabh Shahcd018352014-11-11 13:54:19 -0800535 case IQService::TOGGLE_BWC:
536 toggleBWC(mHwcContext, inParcel);
537 break;
Raj Kamal0d53fc62014-11-25 17:36:36 +0530538 case IQService::CONFIGURE_DYN_REFRESH_RATE:
539 configureDynRefreshRate(mHwcContext, inParcel);
540 break;
Naseer Ahmed78951b22014-12-10 18:19:21 -0500541 case IQService::TOGGLE_SCREEN_UPDATE:
542 toggleScreenUpdate(mHwcContext, inParcel->readInt32());
543 break;
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500544 case IQService::SET_S3D_MODE:
545 setS3DMode(mHwcContext, inParcel->readInt32());
546 break;
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800547 case IQService::SET_ACTIVE_CONFIG:
548 ret = setActiveConfig(mHwcContext, inParcel, outParcel);
549 break;
550 case IQService::GET_ACTIVE_CONFIG:
551 ret = getActiveConfig(mHwcContext, inParcel, outParcel);
552 break;
553 case IQService::GET_CONFIG_COUNT:
554 ret = getConfigCount(mHwcContext, inParcel, outParcel);
555 break;
556 case IQService::GET_DISPLAY_ATTRIBUTES_FOR_CONFIG:
557 ret = getDisplayAttributesForConfig(mHwcContext, inParcel,
558 outParcel);
Zohaib Alam83ea46d2015-03-23 15:44:19 -0400559 case IQService::QDCM_SVC_CMDS:
560 qdcmCmdsHandler(mHwcContext, inParcel, outParcel);
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800561 break;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500562 default:
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800563 ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500564 }
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800565 return ret;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500566}
567
Saurabh Shah86c17292013-02-08 15:24:13 -0800568}