overlay: Support for returning pipe based on capability
Add support for returning pipes based on capabilities.
getPipe() API takes in pipe specifications like format class,
scaling, display, mixer, fb and decides what pipe to return.
The nextPipe() API is now just a private helper.
Change-Id: I0ab809662c0ad6297e19a44f39264ee929944d13
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 1222dcf..992c043 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -393,37 +393,6 @@
return true;
}
-ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type,
- int mixer) {
- overlay::Overlay& ov = *ctx->mOverlay;
- ovutils::eDest mdp_pipe = ovutils::OV_INVALID;
-
- switch(type) {
- case MDPCOMP_OV_DMA:
- mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer);
- if(mdp_pipe != ovutils::OV_INVALID) {
- return mdp_pipe;
- }
- case MDPCOMP_OV_ANY:
- case MDPCOMP_OV_RGB:
- mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer);
- if(mdp_pipe != ovutils::OV_INVALID) {
- return mdp_pipe;
- }
-
- if(type == MDPCOMP_OV_RGB) {
- //Requested only for RGB pipe
- break;
- }
- case MDPCOMP_OV_VG:
- return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer);
- default:
- ALOGE("%s: Invalid pipe type",__FUNCTION__);
- return ovutils::OV_INVALID;
- };
- return ovutils::OV_INVALID;
-}
-
bool MDPComp::isFrameDoable(hwc_context_t *ctx) {
bool ret = true;
@@ -1342,18 +1311,23 @@
info.pipeInfo = new MdpYUVPipeInfo;
info.rot = NULL;
MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo;
- ePipeType type = MDPCOMP_OV_VG;
pipe_info.lIndex = ovutils::OV_INVALID;
pipe_info.rIndex = ovutils::OV_INVALID;
- pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT);
+ Overlay::PipeSpecs pipeSpecs;
+ pipeSpecs.formatClass = Overlay::FORMAT_YUV;
+ pipeSpecs.needsScaling = true;
+ pipeSpecs.dpy = mDpy;
+ pipeSpecs.fb = false;
+
+ pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.lIndex == ovutils::OV_INVALID){
bRet = false;
ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed",
__FUNCTION__);
}
- pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT);
+ pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.rIndex == ovutils::OV_INVALID){
bRet = false;
ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed",
@@ -1423,28 +1397,20 @@
info.pipeInfo = new MdpPipeInfoNonSplit;
info.rot = NULL;
MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo;
- ePipeType type = MDPCOMP_OV_ANY;
- if(isYuvBuffer(hnd)) {
- type = MDPCOMP_OV_VG;
- } else if(qdutils::MDPVersion::getInstance().is8x26() &&
- (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024)) {
- if(qhwc::needsScaling(layer))
- type = MDPCOMP_OV_RGB;
- } else if(!qhwc::needsScaling(layer)
- && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
- && ctx->mMDP.version >= qdutils::MDSS_V5) {
- type = MDPCOMP_OV_DMA;
- } else if(qhwc::needsScaling(layer) &&
- !(ctx->listStats[mDpy].yuvCount) &&
- ! qdutils::MDPVersion::getInstance().isRGBScalarSupported()){
- type = MDPCOMP_OV_VG;
- }
+ Overlay::PipeSpecs pipeSpecs;
+ pipeSpecs.formatClass = isYuvBuffer(hnd) ?
+ Overlay::FORMAT_YUV : Overlay::FORMAT_RGB;
+ pipeSpecs.needsScaling = qhwc::needsScaling(layer) or
+ (qdutils::MDPVersion::getInstance().is8x26() and
+ ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024);
+ pipeSpecs.dpy = mDpy;
+ pipeSpecs.fb = false;
- pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT);
+ pipe_info.index = ctx->mOverlay->getPipe(pipeSpecs);
+
if(pipe_info.index == ovutils::OV_INVALID) {
- ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d",
- __FUNCTION__, (int) type);
+ ALOGD_IF(isDebug(), "%s: Unable to get pipe", __FUNCTION__);
return false;
}
}
@@ -1607,22 +1573,31 @@
}
bool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer,
- MdpPipeInfoSplit& pipe_info,
- ePipeType type) {
- const int lSplit = getLeftSplit(ctx, mDpy);
+ MdpPipeInfoSplit& pipe_info) {
+ const int lSplit = getLeftSplit(ctx, mDpy);
+ private_handle_t *hnd = (private_handle_t *)layer->handle;
hwc_rect_t dst = layer->displayFrame;
pipe_info.lIndex = ovutils::OV_INVALID;
pipe_info.rIndex = ovutils::OV_INVALID;
+ Overlay::PipeSpecs pipeSpecs;
+ pipeSpecs.formatClass = isYuvBuffer(hnd) ?
+ Overlay::FORMAT_YUV : Overlay::FORMAT_RGB;
+ pipeSpecs.needsScaling = qhwc::needsScalingWithSplit(ctx, layer, mDpy);
+ pipeSpecs.dpy = mDpy;
+ pipeSpecs.mixer = Overlay::MIXER_LEFT;
+ pipeSpecs.fb = false;
+
if (dst.left < lSplit) {
- pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT);
+ pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.lIndex == ovutils::OV_INVALID)
return false;
}
if(dst.right > lSplit) {
- pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT);
+ pipeSpecs.mixer = Overlay::MIXER_RIGHT;
+ pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.rIndex == ovutils::OV_INVALID)
return false;
}
@@ -1652,19 +1627,10 @@
info.pipeInfo = new MdpPipeInfoSplit;
info.rot = NULL;
MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo;
- ePipeType type = MDPCOMP_OV_ANY;
- if(isYuvBuffer(hnd)) {
- type = MDPCOMP_OV_VG;
- } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy)
- && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
- && ctx->mMDP.version >= qdutils::MDSS_V5) {
- type = MDPCOMP_OV_DMA;
- }
-
- if(!acquireMDPPipes(ctx, layer, pipe_info, type)) {
- ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d",
- __FUNCTION__, (int) type);
+ if(!acquireMDPPipes(ctx, layer, pipe_info)) {
+ ALOGD_IF(isDebug(), "%s: Unable to get pipe for type",
+ __FUNCTION__);
return false;
}
}
@@ -1848,7 +1814,7 @@
//================MDPCompSrcSplit==============================================
bool MDPCompSrcSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer,
- MdpPipeInfoSplit& pipe_info, ePipeType type) {
+ MdpPipeInfoSplit& pipe_info) {
private_handle_t *hnd = (private_handle_t *)layer->handle;
hwc_rect_t dst = layer->displayFrame;
hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf);
@@ -1859,32 +1825,25 @@
//should have a higher priority than the right one. Pipe priorities are
//starting with VG0, VG1 ... , RGB0 ..., DMA1
+ Overlay::PipeSpecs pipeSpecs;
+ pipeSpecs.formatClass = isYuvBuffer(hnd) ?
+ Overlay::FORMAT_YUV : Overlay::FORMAT_RGB;
+ pipeSpecs.needsScaling = qhwc::needsScaling(layer);
+ pipeSpecs.dpy = mDpy;
+ pipeSpecs.fb = false;
+
//1 pipe by default for a layer
- pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT);
+ pipe_info.lIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.lIndex == ovutils::OV_INVALID) {
- if(isYuvBuffer(hnd)) {
- return false;
- }
- pipe_info.lIndex = getMdpPipe(ctx, MDPCOMP_OV_ANY,
- Overlay::MIXER_DEFAULT);
- if(pipe_info.lIndex == ovutils::OV_INVALID) {
- return false;
- }
+ return false;
}
//If layer's crop width or dest width > 2048, use 2 pipes
if((dst.right - dst.left) > qdutils::MAX_DISPLAY_DIM or
(crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) {
- pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT);
+ pipe_info.rIndex = ctx->mOverlay->getPipe(pipeSpecs);
if(pipe_info.rIndex == ovutils::OV_INVALID) {
- if(isYuvBuffer(hnd)) {
- return false;
- }
- pipe_info.rIndex = getMdpPipe(ctx, MDPCOMP_OV_ANY,
- Overlay::MIXER_DEFAULT);
- if(pipe_info.rIndex == ovutils::OV_INVALID) {
- return false;
- }
+ return false;
}
// Return values