qdutils: Retrieve MDP revision and pipes information from driver.
Userspace can retrieve MDP revision number and number of different
types of MDP pipes (RGB,VG,DMA) information from driver. Add target
specific flag as previous MDP versions do not provide this support.
- Make use of this information while maintaining PipeBook.
- Move PipeBook related functions from overlay utils to PipeBook.
Change-Id: I46578bb27e515c4b9525d90b6619c11d7749914f
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index 5341c90..d22aedb 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -37,12 +37,7 @@
using namespace utils;
Overlay::Overlay() {
- int numPipes = 0;
- int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
- if (mdpVersion > qdutils::MDP_V3_1) numPipes = 4;
- if (mdpVersion >= qdutils::MDSS_V5) numPipes = 8;
-
- PipeBook::NUM_PIPES = numPipes;
+ PipeBook::NUM_PIPES = qdutils::MDPVersion::getInstance().getTotalPipes();
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
mPipeBook[i].init();
}
@@ -74,8 +69,8 @@
//fds
if(mPipeBook[i].valid()) {
char str[32];
- sprintf(str, "Unset pipe=%s dpy=%d; ", getDestStr((eDest)i),
- mPipeBook[i].mDisplay);
+ sprintf(str, "Unset pipe=%s dpy=%d; ",
+ PipeBook::getDestStr((eDest)i), mPipeBook[i].mDisplay);
strncat(mDumpStr, str, strlen(str));
}
mPipeBook[i].destroy();
@@ -90,7 +85,7 @@
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
//Match requested pipe type
- if(type == OV_MDP_PIPE_ANY || type == getPipeType((eDest)i)) {
+ if(type == OV_MDP_PIPE_ANY || type == PipeBook::getPipeType((eDest)i)) {
//If the pipe is not allocated to any display or used by the
//requesting display already in previous round.
if((mPipeBook[i].mDisplay == PipeBook::DPY_UNUSED ||
@@ -111,7 +106,8 @@
if(not mPipeBook[index].valid()) {
mPipeBook[index].mPipe = new GenericPipe(dpy);
char str[32];
- snprintf(str, 32, "Set pipe=%s dpy=%d; ", getDestStr(dest), dpy);
+ snprintf(str, 32, "Set pipe=%s dpy=%d; ",
+ PipeBook::getDestStr(dest), dpy);
strncat(mDumpStr, str, strlen(str));
}
} else {
@@ -183,13 +179,13 @@
validate(index);
PipeArgs newArgs(args);
- if(dest == OV_VG0 || dest == OV_VG1) {
+ if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
} else {
clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
}
- if(dest == OV_DMA0 || dest == OV_DMA1) {
+ if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_DMA) {
setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
} else {
clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
@@ -205,10 +201,68 @@
return sInstance;
}
-void Overlay::initOverlay() {
- if(utils::initOverlay() == -1) {
- ALOGE("%s failed", __FUNCTION__);
+// Clears any VG pipes allocated to the fb devices
+// Generates a LUT for pipe types.
+int Overlay::initOverlay() {
+ int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
+ int numPipesXType[OV_MDP_PIPE_ANY] = {0};
+ numPipesXType[OV_MDP_PIPE_RGB] =
+ qdutils::MDPVersion::getInstance().getRGBPipes();
+ numPipesXType[OV_MDP_PIPE_VG] =
+ qdutils::MDPVersion::getInstance().getVGPipes();
+ numPipesXType[OV_MDP_PIPE_DMA] =
+ qdutils::MDPVersion::getInstance().getDMAPipes();
+
+ int index = 0;
+ for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types
+ for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num
+ PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X;
+ index++;
+ }
}
+
+ if (mdpVersion < qdutils::MDSS_V5) {
+ msmfb_mixer_info_req req;
+ mdp_mixer_info *minfo = NULL;
+ char name[64];
+ int fd = -1;
+ for(int i = 0; i < NUM_FB_DEVICES; i++) {
+ snprintf(name, 64, FB_DEVICE_TEMPLATE, i);
+ ALOGD("initoverlay:: opening the device:: %s", name);
+ fd = ::open(name, O_RDWR, 0);
+ if(fd < 0) {
+ ALOGE("cannot open framebuffer(%d)", i);
+ return -1;
+ }
+ //Get the mixer configuration */
+ req.mixer_num = i;
+ if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
+ ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
+ close(fd);
+ return -1;
+ }
+ minfo = req.info;
+ for (int j = 0; j < req.cnt; j++) {
+ ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum,
+ minfo->z_order);
+ // except the RGB base layer with z_order of -1, clear any
+ // other pipes connected to mixer.
+ if((minfo->z_order) != -1) {
+ int index = minfo->pndx;
+ ALOGD("Unset overlay with index: %d at mixer %d", index, i);
+ if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
+ ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
+ close(fd);
+ return -1;
+ }
+ }
+ minfo++;
+ }
+ close(fd);
+ fd = -1;
+ }
+ }
+ return 0;
}
void Overlay::dump() const {
@@ -254,5 +308,7 @@
int Overlay::PipeBook::sPipeUsageBitmap = 0;
int Overlay::PipeBook::sLastUsageBitmap = 0;
int Overlay::PipeBook::sAllocatedBitmap = 0;
+utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] =
+ {utils::OV_MDP_PIPE_ANY};
}; // namespace overlay