blob: 9b1f81de6da865fb040c826c70acf3609ced61bd [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 Sankaran53b05f22014-08-05 11:27:03 -0700311static status_t setPartialUpdatePref(hwc_context_t *ctx, uint32_t enable) {
312 ALOGD("%s: enable: %d", __FUNCTION__, enable);
313 if(qhwc::MDPComp::setPartialUpdatePref(ctx, (bool)enable) < 0)
314 return NO_INIT;
315 return NO_ERROR;
316}
317
Naseer Ahmed78951b22014-12-10 18:19:21 -0500318static void toggleScreenUpdate(hwc_context_t* ctx, uint32_t on) {
319 ALOGD("%s: toggle update: %d", __FUNCTION__, on);
Naseer Ahmed78951b22014-12-10 18:19:21 -0500320 if (on == 0) {
Raj Kamal58b31a02014-12-16 15:53:53 +0530321 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500322 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = true;
323 ctx->mOverlay->configBegin();
324 ctx->mOverlay->configDone();
325 ctx->mRotMgr->clear();
326 if(!Overlay::displayCommit(ctx->dpyAttr[0].fd)) {
327 ALOGE("%s: Display commit failed", __FUNCTION__);
328 }
Raj Kamal58b31a02014-12-16 15:53:53 +0530329 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500330 } else {
Raj Kamal58b31a02014-12-16 15:53:53 +0530331 ctx->mDrawLock.lock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500332 ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isPause = false;
Raj Kamal58b31a02014-12-16 15:53:53 +0530333 ctx->mDrawLock.unlock();
Naseer Ahmed78951b22014-12-10 18:19:21 -0500334 ctx->proc->invalidate(ctx->proc);
335 }
336}
337
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500338static void setS3DMode(hwc_context_t* ctx, int mode) {
339 if (ctx->mHDMIDisplay) {
340 if(ctx->mHDMIDisplay->isS3DModeSupported(mode)) {
341 ALOGD("%s: Force S3D mode to %d", __FUNCTION__, mode);
342 Locker::Autolock _sl(ctx->mDrawLock);
343 ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].s3dModeForced = true;
344 setup3DMode(ctx, HWC_DISPLAY_EXTERNAL, mode);
345 } else {
346 ALOGD("%s: mode %d is not supported", __FUNCTION__, mode);
347 }
348 } else {
349 ALOGE("%s: No HDMI Display detected", __FUNCTION__);
350 }
351}
352
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800353static status_t setActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
354 Parcel *outParcel) {
355 uint32_t index = inParcel->readInt32();
356 int dpy = inParcel->readInt32();
357 //Currently only primary supported
358 if(dpy > HWC_DISPLAY_PRIMARY) {
359 return BAD_VALUE;
360 }
361
362 Configs *configs = Configs::getInstance();
363 if(configs == NULL) {
364 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
365 return INVALID_OPERATION;
366 }
367
368 if(configs->getActiveConfig() == index) {
369 ALOGI("%s(): Config %u is already set", __FUNCTION__, index);
370 return ALREADY_EXISTS;
371 }
372
373 ctx->mDrawLock.lock();
374 //Updates the necessary sysfs nodes and reads split info again which is
375 //needed to reinitialize composition resources.
376 if(configs->setActiveConfig(index) == false) {
377 ALOGE("%s(): Failed to set config %u", __FUNCTION__, index);
378 ctx->mDrawLock.unlock();
379 return UNKNOWN_ERROR;
380 }
381
382 qdutils::DisplayAttributes attr = configs->getAttributes(index);
383
384 ctx->dpyAttr[dpy].xres = attr.xres;
385 ctx->dpyAttr[dpy].yres = attr.yres;
386
387 ctx->dpyAttr[dpy].fbScaling = ((ctx->dpyAttr[dpy].xres !=
388 ctx->dpyAttr[dpy].xresFB) || (ctx->dpyAttr[dpy].yres !=
389 ctx->dpyAttr[dpy].yresFB));
390
391 destroyCompositionResources(ctx, dpy);
392 initCompositionResources(ctx, dpy);
393 ctx->dpyAttr[dpy].configSwitched = true;
394 ctx->mDrawLock.unlock();
395 ctx->proc->invalidate(ctx->proc);
396 return NO_ERROR;
397}
398
399static status_t getActiveConfig(hwc_context_t* ctx, const Parcel *inParcel,
400 Parcel *outParcel) {
401 Locker::Autolock _sl(ctx->mDrawLock);
402 int dpy = inParcel->readInt32();
403 //Currently only primary supported
404 if(dpy > HWC_DISPLAY_PRIMARY) {
405 return BAD_VALUE;
406 }
407
408 Configs *configs = Configs::getInstance();
409 if(configs == NULL) {
410 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
411 return INVALID_OPERATION;
412 }
413
414 outParcel->writeInt32(configs->getActiveConfig());
415 return NO_ERROR;
416}
417
418static status_t getConfigCount(hwc_context_t* ctx, const Parcel *inParcel,
419 Parcel *outParcel) {
420 Locker::Autolock _sl(ctx->mDrawLock);
421 int dpy = inParcel->readInt32();
422 //Currently only primary supported
423 if(dpy > HWC_DISPLAY_PRIMARY) {
424 return BAD_VALUE;
425 }
426
427 Configs *configs = Configs::getInstance();
428 if(configs == NULL) {
429 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
430 return INVALID_OPERATION;
431 }
432
433 outParcel->writeInt32(configs->getConfigCount());
434 return NO_ERROR;
435}
436
437static status_t getDisplayAttributesForConfig(hwc_context_t* ctx,
438 const Parcel *inParcel, Parcel *outParcel) {
439 Locker::Autolock _sl(ctx->mDrawLock);
440 uint32_t index = inParcel->readInt32();
441 int dpy = inParcel->readInt32();
442 //Currently only primary supported
443 if(dpy > HWC_DISPLAY_PRIMARY) {
444 return BAD_VALUE;
445 }
446
447 Configs *configs = Configs::getInstance();
448 if(configs == NULL) {
449 ALOGE("%s(): Unable to acquire a Configs instance", __FUNCTION__);
450 return INVALID_OPERATION;
451 }
452
453 //xres, yres are used from the Config class, we assume for now that the
454 //other params are the same. This might change in the future.
455 outParcel->writeInt32(ctx->dpyAttr[dpy].vsync_period);
456
457 qdutils::DisplayAttributes attr = configs->getAttributes(index);
458 outParcel->writeInt32(attr.xres);
459 outParcel->writeInt32(attr.yres);
460
461 outParcel->writeFloat(ctx->dpyAttr[dpy].xdpi);
462 outParcel->writeFloat(ctx->dpyAttr[dpy].ydpi);
463 outParcel->writeInt32(ctx->mMDP.panel);
464
465 return NO_ERROR;
466}
467
Naseer Ahmed4957c522013-11-12 18:07:15 -0500468status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel,
469 Parcel* outParcel) {
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800470 status_t ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500471
Naseer Ahmed4957c522013-11-12 18:07:15 -0500472 switch(command) {
473 case IQService::SECURING:
474 securing(mHwcContext, inParcel->readInt32());
475 break;
476 case IQService::UNSECURING:
477 unsecuring(mHwcContext, inParcel->readInt32());
478 break;
479 case IQService::SCREEN_REFRESH:
480 return screenRefresh(mHwcContext);
481 break;
482 case IQService::EXTERNAL_ORIENTATION:
483 setExtOrientation(mHwcContext, inParcel->readInt32());
484 break;
485 case IQService::BUFFER_MIRRORMODE:
486 setBufferMirrorMode(mHwcContext, inParcel->readInt32());
487 break;
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800488 case IQService::GET_DISPLAY_VISIBLE_REGION:
489 ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(),
490 outParcel);
491 break;
Naseer Ahmed78c952e2013-11-25 18:12:23 -0500492 case IQService::CHECK_EXTERNAL_STATUS:
493 isExternalConnected(mHwcContext, outParcel);
494 break;
495 case IQService::GET_DISPLAY_ATTRIBUTES:
496 getDisplayAttributes(mHwcContext, inParcel, outParcel);
497 break;
498 case IQService::SET_HSIC_DATA:
Arun Kumar K.R2aa44c62014-01-21 23:08:28 -0800499 setHSIC(inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530500 break;
Arun Kumar K.R33888f52014-10-09 15:56:33 -0700501 case IQService::SET_SECONDARY_DISPLAY_STATUS:
502 setSecondaryDisplayStatus(mHwcContext, inParcel);
Raj kamal59fea562014-04-01 16:52:19 +0530503 break;
Ramkumar Radhakrishnan0a021a82014-05-19 19:53:56 -0700504 case IQService::SET_VIEW_FRAME:
505 setViewFrame(mHwcContext, inParcel);
506 break;
Naseer Ahmed35a268c2014-06-24 19:07:13 -0400507 case IQService::DYNAMIC_DEBUG:
508 toggleDynamicDebug(mHwcContext, inParcel);
509 break;
Saurabh Shah59562ff2014-09-30 16:13:12 -0700510 case IQService::SET_IDLE_TIMEOUT:
511 setIdleTimeout(mHwcContext, inParcel);
512 break;
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700513 case IQService::SET_MAX_PIPES_PER_MIXER:
514 setMaxPipesPerMixer(mHwcContext, inParcel);
Jeykumar Sankaran85ddc0c2014-12-17 14:39:26 -0800515 break;
Jeykumar Sankaran53b05f22014-08-05 11:27:03 -0700516 case IQService::SET_PARTIAL_UPDATE:
517 ret = setPartialUpdatePref(mHwcContext, inParcel->readInt32());
Jeykumar Sankaranbe93e272014-06-19 18:15:57 -0700518 break;
Saurabh Shahcd018352014-11-11 13:54:19 -0800519 case IQService::TOGGLE_BWC:
520 toggleBWC(mHwcContext, inParcel);
521 break;
Raj Kamal0d53fc62014-11-25 17:36:36 +0530522 case IQService::CONFIGURE_DYN_REFRESH_RATE:
523 configureDynRefreshRate(mHwcContext, inParcel);
524 break;
Naseer Ahmed78951b22014-12-10 18:19:21 -0500525 case IQService::TOGGLE_SCREEN_UPDATE:
526 toggleScreenUpdate(mHwcContext, inParcel->readInt32());
527 break;
Naseer Ahmed6bbd0a12015-01-23 11:57:10 -0500528 case IQService::SET_S3D_MODE:
529 setS3DMode(mHwcContext, inParcel->readInt32());
530 break;
Saurabh Shah90c55cf2015-02-10 15:37:39 -0800531 case IQService::SET_ACTIVE_CONFIG:
532 ret = setActiveConfig(mHwcContext, inParcel, outParcel);
533 break;
534 case IQService::GET_ACTIVE_CONFIG:
535 ret = getActiveConfig(mHwcContext, inParcel, outParcel);
536 break;
537 case IQService::GET_CONFIG_COUNT:
538 ret = getConfigCount(mHwcContext, inParcel, outParcel);
539 break;
540 case IQService::GET_DISPLAY_ATTRIBUTES_FOR_CONFIG:
541 ret = getDisplayAttributesForConfig(mHwcContext, inParcel,
542 outParcel);
543 break;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500544 default:
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800545 ret = NO_ERROR;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500546 }
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800547 return ret;
Naseer Ahmed4957c522013-11-12 18:07:15 -0500548}
549
Saurabh Shah86c17292013-02-08 15:24:13 -0800550}