libgralloc: Add API's to synchronize framebuffer update.
This change introduces API's in gralloc to allow clients to synchronize with framebuffer posts. CRs-fixed: 348953 (cherry picked from commit f81de75b1adb78018c0bd54b7f27901ba467defd) Conflicts: libgralloc/framebuffer.cpp libqcomui/qcom_ui.h Change-Id: I98b6a2b3243f520138cb5d1c76493cdfa3af60b6
This commit is contained in:
parent
ac786968e3
commit
5875b20445
@ -168,6 +168,12 @@ static void *disp_loop(void *ptr)
|
||||
LOGE("ERROR FBIOPUT_VSCREENINFO failed; frame not displayed");
|
||||
}
|
||||
|
||||
//Signal so that we can close channels if we need to
|
||||
pthread_mutex_lock(&m->bufferPostLock);
|
||||
m->bufferPostDone = true;
|
||||
pthread_cond_signal(&m->bufferPostCond);
|
||||
pthread_mutex_unlock(&m->bufferPostLock);
|
||||
|
||||
CALC_FPS();
|
||||
|
||||
if (cur_buf == -1) {
|
||||
@ -401,6 +407,31 @@ static int fb_orientationChanged(struct framebuffer_device_t* dev, int orientati
|
||||
}
|
||||
#endif
|
||||
|
||||
//Wait until framebuffer content is displayed.
|
||||
////This is called in the context of threadLoop.
|
||||
////Display loop wakes this up after display.
|
||||
static int fb_waitForBufferPost(struct framebuffer_device_t* dev)
|
||||
{
|
||||
private_module_t* m = reinterpret_cast<private_module_t*>(
|
||||
dev->common.module);
|
||||
pthread_mutex_lock(&m->bufferPostLock);
|
||||
while(m->bufferPostDone == false) {
|
||||
pthread_cond_wait(&(m->bufferPostCond), &(m->bufferPostLock));
|
||||
}
|
||||
pthread_mutex_unlock(&m->bufferPostLock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fb_resetBufferPostStatus(struct framebuffer_device_t* dev)
|
||||
{
|
||||
private_module_t* m = reinterpret_cast<private_module_t*>(
|
||||
dev->common.module);
|
||||
pthread_mutex_lock(&m->bufferPostLock);
|
||||
m->bufferPostDone = false;
|
||||
pthread_mutex_unlock(&m->bufferPostLock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* fb_perform - used to add custom event and handle them in fb HAL
|
||||
* Used for external display related functions as of now
|
||||
*/
|
||||
@ -420,6 +451,12 @@ static int fb_perform(struct framebuffer_device_t* dev, int event, int value)
|
||||
fb_orientationChanged(dev, value);
|
||||
break;
|
||||
#endif
|
||||
case EVENT_RESET_POSTBUFFER:
|
||||
fb_resetBufferPostStatus(dev);
|
||||
break;
|
||||
case EVENT_WAIT_POSTBUFFER:
|
||||
fb_waitForBufferPost(dev);
|
||||
break;
|
||||
default:
|
||||
LOGE("In %s: UNKNOWN Event = %d!!!", __FUNCTION__, event);
|
||||
break;
|
||||
@ -427,7 +464,6 @@ static int fb_perform(struct framebuffer_device_t* dev, int event, int value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
|
||||
{
|
||||
if (private_handle_t::validate(buffer) < 0)
|
||||
@ -816,6 +852,9 @@ int mapFrameBufferLocked(struct private_module_t* module)
|
||||
module->hdmiMirroringState = HDMI_NO_MIRRORING;
|
||||
module->trueMirrorSupport = false;
|
||||
#endif
|
||||
pthread_mutex_init(&(module->bufferPostLock), NULL);
|
||||
pthread_cond_init(&(module->bufferPostCond), NULL);
|
||||
module->bufferPostDone = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -298,7 +298,8 @@ struct private_module_t {
|
||||
PRIV_MIN_SWAP_INTERVAL = 0,
|
||||
PRIV_MAX_SWAP_INTERVAL = 1,
|
||||
};
|
||||
#if defined(__cplusplus) && defined(HDMI_DUAL_DISPLAY)
|
||||
#if defined(__cplusplus)
|
||||
#if defined(HDMI_DUAL_DISPLAY)
|
||||
Overlay* pobjOverlay;
|
||||
int orientation;
|
||||
int videoOverlay; // VIDEO_OVERLAY - 2D or 3D
|
||||
@ -313,6 +314,10 @@ struct private_module_t {
|
||||
hdmi_mirroring_state hdmiMirroringState;
|
||||
pthread_mutex_t overlayLock;
|
||||
pthread_cond_t overlayPost;
|
||||
#endif
|
||||
pthread_mutex_t bufferPostLock;
|
||||
pthread_cond_t bufferPostCond;
|
||||
bool bufferPostDone;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -111,9 +111,16 @@ enum external_display_type {
|
||||
connect, disconnect, orientation, video started etc.,
|
||||
*/
|
||||
enum {
|
||||
EVENT_EXTERNAL_DISPLAY, // External display on/off Event
|
||||
EVENT_VIDEO_OVERLAY, // Video Overlay start/stop Event
|
||||
EVENT_ORIENTATION_CHANGE, // Orientation Change Event
|
||||
EVENT_EXTERNAL_DISPLAY, // External display on/off Event
|
||||
EVENT_VIDEO_OVERLAY, // Video Overlay start/stop Event
|
||||
EVENT_ORIENTATION_CHANGE, // Orientation Change Event
|
||||
EVENT_OVERLAY_STATE_CHANGE, // Overlay State Change Event
|
||||
EVENT_OPEN_SECURE_START, // Start of secure session setup config by stagefright
|
||||
EVENT_OPEN_SECURE_END, // End of secure session setup config by stagefright
|
||||
EVENT_CLOSE_SECURE_START, // Start of secure session teardown config
|
||||
EVENT_CLOSE_SECURE_END, // End of secure session teardown config
|
||||
EVENT_RESET_POSTBUFFER, // Reset post framebuffer mutex
|
||||
EVENT_WAIT_POSTBUFFER, // Wait until post framebuffer returns
|
||||
};
|
||||
|
||||
// Video information sent to framebuffer HAl
|
||||
|
Loading…
Reference in New Issue
Block a user