Merge "display: Add BufferMirrorMode support for External"

This commit is contained in:
Linux Build Service Account
2013-08-21 12:25:21 -07:00
committed by Gerrit - the friendly Code Review server
9 changed files with 95 additions and 16 deletions

View File

@@ -116,6 +116,10 @@ bool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
ovutils::eTransform orient =
static_cast<ovutils::eTransform>(transform);
// use ext orientation if any
int extOrient = ctx->mExtOrientation;
if(ctx->mBufferMirrorMode)
extOrient = getMirrorModeOrientation(ctx);
// Do not use getNonWormholeRegion() function to calculate the
// sourceCrop during animation on external display and
@@ -125,7 +129,7 @@ bool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
sourceCrop = layer->displayFrame;
displayFrame = sourceCrop;
} else if((!mDpy ||
(mDpy && !ctx->mExtOrientation
(mDpy && !extOrient
&& !ctx->dpyAttr[mDpy].mDownScaleMode))
&& (extOnlyLayerIndex == -1)) {
if(!qdutils::MDPVersion::getInstance().is8x26()) {
@@ -134,13 +138,12 @@ bool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
}
}
if(mDpy && !qdutils::MDPVersion::getInstance().is8x26()) {
if(ctx->mExtOrientation || ctx->dpyAttr[mDpy].mDownScaleMode) {
if(extOrient || ctx->dpyAttr[mDpy].mDownScaleMode) {
calcExtDisplayPosition(ctx, mDpy, sourceCrop, displayFrame);
// If there is a external orientation set, use that
if(ctx->mExtOrientation) {
transform = ctx->mExtOrientation;
orient =
static_cast<ovutils::eTransform >(ctx->mExtOrientation);
if(extOrient) {
transform = extOrient;
orient = static_cast<ovutils::eTransform >(extOrient);
}
}
// Calculate the actionsafe dimensions for External(dpy = 1 or 2)
@@ -148,7 +151,7 @@ bool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
}
setMdpFlags(layer, mdpFlags, 0, transform);
// For External use rotator if there is a rotation value set
if(mDpy && (ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)) {
if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
mRot = ctx->mRotMgr->getNext();
if(mRot == NULL) return -1;
//Configure rotator for pre-rotation

View File

@@ -64,6 +64,9 @@ status_t QClient::notifyCallback(uint32_t msg, uint32_t value) {
case IQService::EXTERNAL_ORIENTATION:
setExtOrientation(value);
break;
case IQService::BUFFER_MIRRORMODE:
setBufferMirrorMode(value);
break;
default:
return NO_ERROR;
}
@@ -118,4 +121,8 @@ void QClient::setExtOrientation(uint32_t orientation) {
mHwcContext->mExtOrientation = orientation;
}
void QClient::setBufferMirrorMode(uint32_t enable) {
mHwcContext->mBufferMirrorMode = enable;
}
}

View File

@@ -61,6 +61,7 @@ private:
void unsecuring(uint32_t startEnd);
android::status_t screenRefresh();
void setExtOrientation(uint32_t orientation);
void setBufferMirrorMode(uint32_t enable);
hwc_context_t *mHwcContext;
const android::sp<android::IMediaDeathNotifier> mMPDeathNotifier;

View File

@@ -196,6 +196,8 @@ void initContext(hwc_context_t *ctx)
ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0;
ctx->mPrevTransformVideo = 0;
ctx->mBufferMirrorMode = false;
ALOGI("Initializing Qualcomm Hardware Composer");
ALOGI("MDP version: %d", ctx->mMDP.version);
}
@@ -297,7 +299,11 @@ void getActionSafePosition(hwc_context_t *ctx, int dpy, hwc_rect_t& rect) {
float fbHeight = ctx->dpyAttr[dpy].yres;
// Since external is rotated 90, need to swap width/height
if(ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)
int extOrient = ctx->mExtOrientation;
if(ctx->mBufferMirrorMode)
extOrient = getMirrorModeOrientation(ctx);
if(extOrient & HWC_TRANSFORM_ROT_90)
swap(fbWidth, fbHeight);
float asX = 0;
@@ -496,7 +502,10 @@ void calcExtDisplayPosition(hwc_context_t *ctx, int dpy,
hwc_rect_t& sourceCrop,
hwc_rect_t& displayFrame) {
// Swap width and height when there is a 90deg transform
if(ctx->mExtOrientation & HWC_TRANSFORM_ROT_90) {
int extOrient = ctx->mExtOrientation;
if(ctx->mBufferMirrorMode)
extOrient = getMirrorModeOrientation(ctx);
if(extOrient & HWC_TRANSFORM_ROT_90) {
int dstWidth = ctx->dpyAttr[dpy].xres;
int dstHeight = ctx->dpyAttr[dpy].yres;;
int srcWidth = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres;
@@ -538,7 +547,26 @@ void calcExtDisplayPosition(hwc_context_t *ctx, int dpy,
displayFrame.right *= wRatio;
displayFrame.bottom *= hRatio;
}
}
/* Returns the orientation which needs to be set on External for
* SideSync/Buffer Mirrormode
*/
int getMirrorModeOrientation(hwc_context_t *ctx) {
int extOrientation = 0;
int deviceOrientation = ctx->deviceOrientation;
if(!isPrimaryPortrait(ctx))
deviceOrientation = (deviceOrientation + 1) % 4;
if (deviceOrientation == 0)
extOrientation = HWC_TRANSFORM_ROT_270;
else if (deviceOrientation == 1)//90
extOrientation = 0;
else if (deviceOrientation == 2)//180
extOrientation = HWC_TRANSFORM_ROT_90;
else if (deviceOrientation == 3)//270
extOrientation = HWC_TRANSFORM_FLIP_V | HWC_TRANSFORM_FLIP_H;
return extOrientation;
}
bool needsScaling(hwc_context_t* ctx, hwc_layer_1_t const* layer,
@@ -663,9 +691,10 @@ void setListStats(hwc_context_t *ctx,
ctx->mExtOrientation = atoi(value); */
// Assuming the orientation value is in terms of HAL_TRANSFORM,
// This needs mapping to HAL, if its in different convention
if(ctx->mExtOrientation) {
ALOGD_IF(HWC_UTILS_DEBUG, "%s: ext orientation = %d",
__FUNCTION__, ctx->mExtOrientation);
if(ctx->mExtOrientation || ctx->mBufferMirrorMode) {
ALOGD_IF(HWC_UTILS_DEBUG, "%s: ext orientation = %d"
"BufferMirrorMode = %d", __FUNCTION__,
ctx->mExtOrientation, ctx->mBufferMirrorMode);
if(ctx->mOverlay->isPipeTypeAttached(OV_MDP_PIPE_DMA)) {
ctx->isPaddingRound = true;
}
@@ -1165,12 +1194,15 @@ int configureLowRes(hwc_context_t *ctx, hwc_layer_1_t *layer,
}
}
if(dpy) {
int extOrient = ctx->mExtOrientation;
if(ctx->mBufferMirrorMode)
extOrient = getMirrorModeOrientation(ctx);
// Just need to set the position to portrait as the transformation
// will already be set to required orientation on TV
if(ctx->mExtOrientation || ctx->dpyAttr[dpy].mDownScaleMode) {
getAspectRatioPosition(ctx, dpy, ctx->mExtOrientation, dst, dst);
if(ctx->mExtOrientation) {
transform = ctx->mExtOrientation;
if(extOrient || ctx->dpyAttr[dpy].mDownScaleMode) {
getAspectRatioPosition(ctx, dpy, extOrient, dst, dst);
if(extOrient) {
transform = extOrient;
orient = static_cast<eTransform>(transform);
}
}

View File

@@ -193,6 +193,9 @@ void calcExtDisplayPosition(hwc_context_t *ctx,
int dpy,
hwc_rect_t& sourceCrop,
hwc_rect_t& displayFrame);
// Returns the orientation that needs to be set on external for
// BufferMirrirMode(Sidesync)
int getMirrorModeOrientation(hwc_context_t *ctx);
//Close acquireFenceFds of all layers of incoming list
void closeAcquireFds(hwc_display_contents_1_t* list);
@@ -371,6 +374,11 @@ struct hwc_context_t {
int mExtOrientation;
//Flags the transition of a video session
bool mVideoTransFlag;
//Used for SideSync feature
//which overrides the mExtOrientation
bool mBufferMirrorMode;
qhwc::LayerRotMap *mLayerRotMap[HWC_NUM_DISPLAY_TYPES];
};

View File

@@ -78,6 +78,13 @@ public:
data.writeInt32(orientation);
remote()->transact(EXTERNAL_ORIENTATION, data, &reply);
}
virtual void setBufferMirrorMode(uint32_t enable) {
Parcel data, reply;
data.writeInterfaceToken(IQService::getInterfaceDescriptor());
data.writeInt32(enable);
remote()->transact(BUFFER_MIRRORMODE, data, &reply);
}
};
IMPLEMENT_META_INTERFACE(QService, "android.display.IQService");
@@ -160,6 +167,18 @@ status_t BnQService::onTransact(
setExtOrientation(orientation);
return NO_ERROR;
} break;
case BUFFER_MIRRORMODE: {
CHECK_INTERFACE(IQService, data, reply);
if(callerUid != AID_SYSTEM) {
ALOGE("display.qservice BUFFER_MIRRORMODE access denied: \
pid=%d uid=%d process=%s",callerPid,
callerUid, callingProcName);
return PERMISSION_DENIED;
}
uint32_t enable = data.readInt32();
setBufferMirrorMode(enable);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}

View File

@@ -42,6 +42,7 @@ public:
CONNECT,
SCREEN_REFRESH,
EXTERNAL_ORIENTATION,
BUFFER_MIRRORMODE,
};
enum {
END = 0,
@@ -52,6 +53,7 @@ public:
virtual void connect(const android::sp<qClient::IQClient>& client) = 0;
virtual android::status_t screenRefresh() = 0;
virtual void setExtOrientation(uint32_t orientation) = 0;
virtual void setBufferMirrorMode(uint32_t enable) = 0;
};
// ----------------------------------------------------------------------------

View File

@@ -77,6 +77,12 @@ void QService::setExtOrientation(uint32_t orientation) {
}
}
void QService::setBufferMirrorMode(uint32_t enable) {
if(mClient.get()) {
mClient->notifyCallback(BUFFER_MIRRORMODE, enable);
}
}
void QService::init()
{
if(!sQService) {

View File

@@ -50,6 +50,7 @@ public:
virtual void connect(const android::sp<qClient::IQClient>& client);
virtual android::status_t screenRefresh();
virtual void setExtOrientation(uint32_t orientation);
virtual void setBufferMirrorMode(uint32_t enable);
static void init();
private:
QService();