liboverlay: Always use rotator for UI mirroring on HDMI

- Use rotator buffer for UI mirroring on HDMI
- Avoid ioctl calls on getPosition

CRs-fixed: 278858
Change-Id: Id390e2b85fe939d8388ed17f5f9c7fcd30499755
This commit is contained in:
Arun Kumar K.R 2011-03-31 20:27:26 -07:00 committed by Govind Surti
parent e825316b00
commit ed35d42ee4
5 changed files with 25 additions and 19 deletions

View File

@ -163,6 +163,7 @@ static void *disp_loop(void *ptr)
pthread_mutex_lock(&m->overlayLock);
m->orientation = neworientation;
m->currentOffset = offset;
m->hdmiStateChanged = true;
pthread_cond_signal(&(m->overlayPost));
pthread_mutex_unlock(&m->overlayLock);
#endif
@ -210,7 +211,9 @@ static void *hdmi_ui_loop(void *ptr)
ptr);
while (1) {
pthread_mutex_lock(&m->overlayLock);
pthread_cond_wait(&(m->overlayPost), &(m->overlayLock));
while(!(m->hdmiStateChanged))
pthread_cond_wait(&(m->overlayPost), &(m->overlayLock));
m->hdmiStateChanged = false;
if (m->exitHDMIUILoop) {
pthread_mutex_unlock(&m->overlayLock);
return NULL;
@ -226,7 +229,7 @@ static void *hdmi_ui_loop(void *ptr)
if (!pTemp->isChannelUP()) {
int alignedW = ALIGN(m->info.xres, 32);
if (pTemp->startChannel(alignedW, m->info.yres,
m->fbFormat, 1, false, true)) {
m->fbFormat, 1, false, true, 0, VG0_PIPE, true)) {
pTemp->setFd(m->framebuffer->fd);
pTemp->setCrop(0, 0, m->info.xres, m->info.yres);
} else
@ -312,11 +315,10 @@ static void *hdmi_ui_loop(void *ptr)
break;
}
}
int currentOrientation = 0;
pTemp->getOrientation(currentOrientation);
if(rot != currentOrientation) {
if(rot != m->currentOrientation) {
pTemp->setParameter(OVERLAY_TRANSFORM,
rot);
m->currentOrientation = rot;
}
EVEN_OUT(asX);
EVEN_OUT(asY);
@ -348,6 +350,7 @@ static int fb_videoOverlayStarted(struct framebuffer_device_t* dev, int started)
pthread_mutex_lock(&m->overlayLock);
Overlay* pTemp = m->pobjOverlay;
if(started != m->videoOverlay) {
m->hdmiStateChanged = true;
if (started && pTemp) {
pTemp->closeChannel();
m->videoOverlay = true;
@ -371,6 +374,7 @@ static int fb_enableHDMIOutput(struct framebuffer_device_t* dev, int enable)
if (!enable && pTemp)
pTemp->closeChannel();
m->enableHDMIOutput = enable;
m->hdmiStateChanged = true;
pthread_cond_signal(&(m->overlayPost));
pthread_mutex_unlock(&m->overlayLock);
return 0;
@ -809,6 +813,7 @@ int mapFrameBufferLocked(struct private_module_t* module)
module->pobjOverlay = new Overlay();
module->currentOffset = 0;
module->exitHDMIUILoop = false;
module->hdmiStateChanged = false;
pthread_t hdmiUIThread;
pthread_create(&hdmiUIThread, NULL, &hdmi_ui_loop, (void *) module);
#endif

View File

@ -235,6 +235,8 @@ struct private_module_t {
bool exitHDMIUILoop;
float actionsafeWidthRatio;
float actionsafeHeightRatio;
int currentOrientation;
bool hdmiStateChanged;
pthread_mutex_t overlayLock;
pthread_cond_t overlayPost;
#endif

View File

@ -173,7 +173,7 @@ public:
mHandle.pobjControlChannel[index] = new OverlayControlChannel();
}
bool ret = mHandle.pobjControlChannel[index]->startControlChannel(
mHandle.w, mHandle.h, mHandle.format, fbnum, norot,
mHandle.w, mHandle.h, mHandle.format, fbnum, norot, false,
format3D, zorder, true);
if (ret) {
if (!(mHandle.pobjControlChannel[index]->

View File

@ -164,7 +164,7 @@ bool Overlay::startChannel(int w, int h, int format, int fbnum,
if (format3D)
zorder = channel;
mChannelUP = objOvCtrlChannel[channel].startControlChannel(w, h, format, fbnum,
norot, format3D, zorder, ignoreFB);
norot, uichannel, format3D, zorder, ignoreFB);
if (!mChannelUP) {
LOGE("startChannel for fb%d failed", fbnum);
return mChannelUP;
@ -295,7 +295,6 @@ bool Overlay::setSource(uint32_t w, uint32_t h, int format, int orientation,
int stateChanged = 0;
int hw_format = get_mdp_format(colorFormat);
bool uichannel = isRGBType(hw_format);
int s3dChanged =0, hdmiChanged = 0;
if (format3D != mS3DFormat)
@ -322,7 +321,7 @@ bool Overlay::setSource(uint32_t w, uint32_t h, int format, int orientation,
}
} else {
return startChannel(w, h, colorFormat, 0, !orientation,
uichannel, 0, VG0_PIPE, ignoreFB, num_buffers);
false, 0, VG0_PIPE, ignoreFB, num_buffers);
}
}
else
@ -646,6 +645,8 @@ bool OverlayControlChannel::startOVRotatorSessions(int w, int h,
mRotInfo.src_rect.y = 0;
mRotInfo.rotations = 0;
mRotInfo.enable = 0;
if(mUIChannel)
mRotInfo.enable = 1;
mRotInfo.session_id = 0;
int result = ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo);
if (result) {
@ -676,9 +677,11 @@ bool OverlayControlChannel::startOVRotatorSessions(int w, int h,
bool OverlayControlChannel::startControlChannel(int w, int h,
int format, int fbnum, bool norot,
bool uichannel,
unsigned int format3D, int zorder,
bool ignoreFB) {
mNoRot = norot;
mUIChannel = uichannel;
fb_fix_screeninfo finfo;
fb_var_screeninfo vinfo;
int hw_format;
@ -940,7 +943,9 @@ bool OverlayControlChannel::setParameter(int param, int value, bool fetch) {
else {
if(mRotInfo.src.format == MDP_Y_CRCB_H2V2_TILE)
mOVInfo.src.format = MDP_Y_CRCB_H2V2_TILE;
mRotInfo.enable = 0;
mRotInfo.enable = 0;
if(mUIChannel)
mRotInfo.enable = 1;
}
if (ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo)) {
reportError("setParameter, rotator start failed");
@ -965,15 +970,7 @@ bool OverlayControlChannel::getPosition(int& x, int& y,
uint32_t& w, uint32_t& h) {
if (!isChannelUP())
return false;
mdp_overlay ov;
ov.id = mOVInfo.id;
if (ioctl(mFD, MSMFB_OVERLAY_GET, &ov)) {
reportError("getPosition, overlay GET failed");
return false;
}
mOVInfo = ov;
//mOVInfo has the current Overlay Position
x = mOVInfo.dst_rect.x;
y = mOVInfo.dst_rect.y;
w = mOVInfo.dst_rect.w;

View File

@ -96,6 +96,7 @@ class OverlayControlChannel {
int mSize;
int mOrientation;
unsigned int mFormat3D;
bool mUIChannel;
mdp_overlay mOVInfo;
msm_rotator_img_info mRotInfo;
bool openDevices(int fbnum = -1);
@ -109,6 +110,7 @@ public:
~OverlayControlChannel();
bool startControlChannel(int w, int h, int format,
int fbnum, bool norot = false,
bool uichannel = false,
unsigned int format3D = 0, int zorder = 0,
bool ignoreFB = false);
bool closeControlChannel();