From 8e7a62fc9746c03b03f7c3721c3d56a83c5ee318 Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Fri, 6 Dec 2013 18:55:41 -0800 Subject: [PATCH] hwc: Add binder interface to get the visibleRegion - This binder interface can be used by clients to know the active visible region for a display(pri/ext/virt) - When external orientation is used, return the destFrame of the FrameBuffer layer, as its the viewFrame Change-Id: I7cfd149c76c16b9a3031103c89b1932d44bcbecd --- libhwcomposer/hwc_fbupdate.cpp | 2 ++ libhwcomposer/hwc_qclient.cpp | 34 ++++++++++++++++++++++++++++++++-- libhwcomposer/hwc_utils.h | 2 ++ libqdutils/display_config.cpp | 22 ++++++++++++++++++++++ libqdutils/display_config.h | 4 ++++ libqservice/IQService.h | 1 + 6 files changed, 63 insertions(+), 2 deletions(-) diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp index 0ca5ad94..d601f8ff 100644 --- a/libhwcomposer/hwc_fbupdate.cpp +++ b/libhwcomposer/hwc_fbupdate.cpp @@ -176,6 +176,8 @@ bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *lis } calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame, transform, orient); + //Store the displayFrame, will be used in getDisplayViewFrame + ctx->dpyAttr[mDpy].mDstRect = displayFrame; setMdpFlags(layer, mdpFlags, 0, transform); // For External use rotator if there is a rotation value set ret = preRotateExtDisplay(ctx, layer, info, diff --git a/libhwcomposer/hwc_qclient.cpp b/libhwcomposer/hwc_qclient.cpp index a3f6b5b4..50e94c9b 100644 --- a/libhwcomposer/hwc_qclient.cpp +++ b/libhwcomposer/hwc_qclient.cpp @@ -140,8 +140,34 @@ static void setBufferMirrorMode(hwc_context_t *ctx, uint32_t enable) { ctx->mBufferMirrorMode = enable; } +static status_t getDisplayVisibleRegion(hwc_context_t* ctx, int dpy, + Parcel* outParcel) { + // Get the info only if the dpy is valid + if(dpy >= HWC_DISPLAY_PRIMARY && dpy <= HWC_DISPLAY_VIRTUAL) { + Locker::Autolock _sl(ctx->mDrawLock); + if(dpy && (ctx->mExtOrientation || ctx->mBufferMirrorMode)) { + // Return the destRect on external, if external orienation + // is enabled + outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.left); + outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.top); + outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.right); + outParcel->writeInt32(ctx->dpyAttr[dpy].mDstRect.bottom); + } else { + outParcel->writeInt32(ctx->mViewFrame[dpy].left); + outParcel->writeInt32(ctx->mViewFrame[dpy].top); + outParcel->writeInt32(ctx->mViewFrame[dpy].right); + outParcel->writeInt32(ctx->mViewFrame[dpy].bottom); + } + return NO_ERROR; + } else { + ALOGE("In %s: invalid dpy index %d", __FUNCTION__, dpy); + return BAD_VALUE; + } +} + status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, Parcel* outParcel) { + status_t ret = NO_ERROR; if (command > IQService::VPU_COMMAND_LIST_START && command < IQService::VPU_COMMAND_LIST_END) { @@ -164,6 +190,10 @@ status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, case IQService::BUFFER_MIRRORMODE: setBufferMirrorMode(mHwcContext, inParcel->readInt32()); break; + case IQService::GET_DISPLAY_VISIBLE_REGION: + ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(), + outParcel); + break; case IQService::CHECK_EXTERNAL_STATUS: isExternalConnected(mHwcContext, outParcel); break; @@ -174,9 +204,9 @@ status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, setHSIC(mHwcContext, inParcel); break; default: - return NO_ERROR; + ret = NO_ERROR; } - return NO_ERROR; + return ret; } diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h index 872b3062..cd84f736 100644 --- a/libhwcomposer/hwc_utils.h +++ b/libhwcomposer/hwc_utils.h @@ -87,6 +87,8 @@ struct DisplayAttributes { bool isConfiguring; // External Display is in MDP Downscale mode indicator bool mDownScaleMode; + // Ext dst Rect + hwc_rect_t mDstRect; }; struct ListStats { diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp index eaf53849..45b02110 100644 --- a/libqdutils/display_config.cpp +++ b/libqdutils/display_config.cpp @@ -91,4 +91,26 @@ int setHSIC(int dpy, const HSICData_t& hsic_data) { ALOGE("%s: Failed to get external status err=%d", __FUNCTION__, err); return err; } + +int getDisplayVisibleRegion(int dpy, hwc_rect_t &rect) { + status_t err = FAILED_TRANSACTION; + sp binder = getBinder(); + Parcel inParcel, outParcel; + inParcel.writeInt32(dpy); + if(binder != NULL) { + err = binder->dispatch(IQService::GET_DISPLAY_VISIBLE_REGION, + &inParcel, &outParcel); + } + if(!err) { + rect.left = outParcel.readInt32(); + rect.top = outParcel.readInt32(); + rect.right = outParcel.readInt32(); + rect.bottom = outParcel.readInt32(); + } else { + ALOGE("%s: Failed to getVisibleRegion for dpy =%d: err = %d", + __FUNCTION__, dpy, err); + } + return err; +} + }; //namespace diff --git a/libqdutils/display_config.h b/libqdutils/display_config.h index c7d8ce91..29edbef3 100644 --- a/libqdutils/display_config.h +++ b/libqdutils/display_config.h @@ -29,6 +29,7 @@ #include #include #include +#include // This header is for clients to use to set/get global display configuration // The functions in this header run in the client process and wherever necessary @@ -69,4 +70,7 @@ int getDisplayAttributes(int dpy, DisplayAttributes_t& dpyattr); // Returns 0 on success, negative values on errors int setHSIC(int dpy, const HSICData_t& hsic_data); +// get the active visible region for the display +// Returns 0 on success, negative values on errors +int getDisplayVisibleRegion(int dpy, hwc_rect_t &rect); }; //namespace diff --git a/libqservice/IQService.h b/libqservice/IQService.h index d6e525a1..f8e58ab5 100644 --- a/libqservice/IQService.h +++ b/libqservice/IQService.h @@ -48,6 +48,7 @@ public: CHECK_EXTERNAL_STATUS, // Check status of external display GET_DISPLAY_ATTRIBUTES, // Get display attributes SET_HSIC_DATA, // Set HSIC on dspp + GET_DISPLAY_VISIBLE_REGION, // Get the visibleRegion for dpy VPU_COMMAND_LIST_START = 100, //Reserved block for VPU commands VPU_COMMAND_LIST_END = 200, COMMAND_LIST_END = 400,