qcom/display: clean up overlay channels during initialization
- Add an interface to class Overlay to clean up the overlay channels. This interface will query the framebuffer device, and will free(UNSET) them if they are in use - hwcomposer hal will call this API during initialization (cherry picked from commit 0d03b1b823bbf36f7adb16bb4344fc46d8748c6a) Conflicts: libhwcomposer/hwcomposer.cpp Change-Id: I4a4bedfdc409913ef31c1d5f5a869db730528096
This commit is contained in:
parent
08f2e32737
commit
4c082b642a
@ -1449,16 +1449,21 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
|
||||
{
|
||||
int status = -EINVAL;
|
||||
if (!strcmp(name, HWC_HARDWARE_COMPOSER)) {
|
||||
private_hwc_module_t* hwcModule = reinterpret_cast<private_hwc_module_t*>
|
||||
private_hwc_module_t* hwcModule = reinterpret_cast<private_hwc_module_t*>
|
||||
(const_cast<hw_module_t*>(module));
|
||||
|
||||
hwc_module_initialize(hwcModule);
|
||||
hwc_module_initialize(hwcModule);
|
||||
struct hwc_context_t *dev;
|
||||
dev = (hwc_context_t*)malloc(sizeof(*dev));
|
||||
|
||||
/* initialize our state here */
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
#ifdef USE_OVERLAY
|
||||
dev->mOverlayLibObject = new overlay::Overlay();
|
||||
if(overlay::initOverlay() == -1)
|
||||
LOGE("overlay::initOverlay() ERROR!!");
|
||||
#else
|
||||
dev->mOverlayLibObject = NULL;
|
||||
#endif
|
||||
#ifdef COMPOSITION_BYPASS
|
||||
for(int i = 0; i < MAX_BYPASS_LAYERS; i++) {
|
||||
dev->mOvUI[i] = new overlay::OverlayUI();
|
||||
|
@ -372,6 +372,50 @@ unsigned int overlay::getOverlayConfig (unsigned int format3D, bool poll,
|
||||
return curState;
|
||||
}
|
||||
|
||||
/* clears any VG pipes allocated to the fb devices */
|
||||
int overlay::initOverlay() {
|
||||
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);
|
||||
LOGD("initoverlay:: opening the device:: %s", name);
|
||||
fd = open(name, O_RDWR, 0);
|
||||
if(fd < 0) {
|
||||
LOGE("cannot open framebuffer(%d)", i);
|
||||
return -1;
|
||||
}
|
||||
//Get the mixer configuration */
|
||||
req.mixer_num = i;
|
||||
if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
|
||||
LOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
minfo = req.info;
|
||||
for (int j = 0; j < req.cnt; j++) {
|
||||
LOGD("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;
|
||||
LOGD("Unset overlay with index: %d at mixer %d", index, i);
|
||||
if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
|
||||
LOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
minfo++;
|
||||
}
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Overlay::Overlay() : mChannelUP(false), mHDMIConnected(false),
|
||||
mS3DFormat(0), mCroppedSrcWidth(0),
|
||||
mCroppedSrcHeight(0), mState(-1) {
|
||||
@ -1114,10 +1158,8 @@ bool OverlayControlChannel::openDevices(int fbnum) {
|
||||
if (fbnum < 0)
|
||||
return false;
|
||||
|
||||
char const * const device_template =
|
||||
"/dev/graphics/fb%u";
|
||||
char dev_name[64];
|
||||
snprintf(dev_name, 64, device_template, fbnum);
|
||||
snprintf(dev_name, 64, FB_DEVICE_TEMPLATE, fbnum);
|
||||
mFD = open(dev_name, O_RDWR, 0);
|
||||
if (mFD < 0) {
|
||||
reportError("Cant open framebuffer ");
|
||||
@ -1754,10 +1796,8 @@ bool OverlayDataChannel::startDataChannel(
|
||||
bool OverlayDataChannel::openDevices(int fbnum, bool uichannel, int num_buffers) {
|
||||
if (fbnum < 0)
|
||||
return false;
|
||||
char const * const device_template =
|
||||
"/dev/graphics/fb%u";
|
||||
char dev_name[64];
|
||||
snprintf(dev_name, 64, device_template, fbnum);
|
||||
snprintf(dev_name, 64, FB_DEVICE_TEMPLATE, fbnum);
|
||||
|
||||
mFD = open(dev_name, O_RDWR, 0);
|
||||
if (mFD < 0) {
|
||||
|
@ -56,6 +56,7 @@
|
||||
#define VG0_PIPE 0
|
||||
#define VG1_PIPE 1
|
||||
#define NUM_CHANNELS 2
|
||||
#define NUM_FB_DEVICES 3
|
||||
#define FRAMEBUFFER_0 0
|
||||
#define FRAMEBUFFER_1 1
|
||||
#define FRAMEBUFFER_2 2
|
||||
@ -139,6 +140,9 @@ struct overlay_buffer_info {
|
||||
|
||||
using android::Mutex;
|
||||
namespace overlay {
|
||||
|
||||
#define FB_DEVICE_TEMPLATE "/dev/graphics/fb%u"
|
||||
|
||||
//Utility Class to query the framebuffer info
|
||||
class FrameBufferInfo {
|
||||
int mFBWidth;
|
||||
@ -214,6 +218,8 @@ int get_size(int format, int w, int h);
|
||||
int get_rot_output_format(int format);
|
||||
int get_mdp_orientation(int value);
|
||||
void normalize_crop(uint32_t& xy, uint32_t& wh);
|
||||
//Initializes the overlay - cleans up any existing overlay pipes
|
||||
int initOverlay();
|
||||
|
||||
/* Print values being sent to driver in case of ioctl failures
|
||||
These logs are enabled only if DEBUG_OVERLAY is true */
|
||||
|
@ -94,10 +94,8 @@ status_t Display::openDisplay(int fbnum) {
|
||||
return NO_ERROR;
|
||||
|
||||
status_t ret = NO_INIT;
|
||||
char const * const device_template =
|
||||
"/dev/graphics/fb%u";
|
||||
char dev_name[64];
|
||||
snprintf(dev_name, 64, device_template, fbnum);
|
||||
snprintf(dev_name, 64, FB_DEVICE_TEMPLATE, fbnum);
|
||||
|
||||
mFD = open(dev_name, O_RDWR, 0);
|
||||
if (mFD < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user