hwcomposer : Use sysfs to read vysnc information
* Read sysfs entries to get vsync timestamp from kernel.
* External display continues to use uevents for hotplug events
* A new thread, vsyncThread is created to read and send vsync
timestamps to HAL.
* Disable H/W VSYNC for MDP 5.x targets until kernel changes are
complete.
* Synchronization is needed to make sure read() is not called
by hwcVsyncThread when VSYNC is disabled.
Change-Id: Iab0a94a3cfce9142b8867859f2a7d9bcaecb0996
Acked-by: Neti Ravi Kumar <ravineti@codeaurora.org>
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index 3df0e25..ef43f62 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -21,6 +21,7 @@
#include <hardware_legacy/uevent.h>
#include <utils/Log.h>
#include <sys/resource.h>
+#include <sys/prctl.h>
#include <string.h>
#include <stdlib.h>
#include "hwc_utils.h"
@@ -28,8 +29,6 @@
namespace qhwc {
-const char* MSMFB_DEVICE_FB0 = "change@/devices/virtual/graphics/fb0";
-const char* MSMFB_DEVICE_FB1 = "change@/devices/virtual/graphics/fb1";
const char* MSMFB_HDMI_NODE = "fb1";
static void handle_uevent(hwc_context_t* ctx, const char* udata, int len)
@@ -38,65 +37,38 @@
char* hdmi;
int64_t timestamp = 0;
const char *str = udata;
- int display = HWC_DISPLAY_PRIMARY;
if(!strcasestr(str, "@/devices/virtual/graphics/fb")) {
ALOGD_IF(UEVENT_DEBUG, "%s: Not Ext Disp Event ", __FUNCTION__);
return;
}
-
- //Check if its primary vsync
- vsync = !strncmp(str, MSMFB_DEVICE_FB0, strlen(MSMFB_DEVICE_FB0));
- //If not primary vsync, see if its an external vsync
- if(isExternalActive(ctx) && !vsync) {
- vsync = !strncmp(str, MSMFB_DEVICE_FB1, strlen(MSMFB_DEVICE_FB1));
- display = HWC_DISPLAY_EXTERNAL;
- }
-
hdmi = strcasestr(str, MSMFB_HDMI_NODE);
-
- if(vsync) {
- str += strlen(str) + 1;
- while(*str) {
- if (!strncmp(str, "VSYNC=", strlen("VSYNC="))) {
- timestamp = strtoull(str + strlen("VSYNC="), NULL, 0);
- //XXX: Handle vsync from multiple displays
- ctx->proc->vsync(ctx->proc, display, timestamp);
- }
- str += strlen(str) + 1;
- if(str - udata >= len)
- break;
- }
- return;
- }
-
- if(hdmi) {
- // parse HDMI events
- // The event will be of the form:
- // change@/devices/virtual/graphics/fb1 ACTION=change
- // DEVPATH=/devices/virtual/graphics/fb1
- // SUBSYSTEM=graphics HDCP_STATE=FAIL MAJOR=29
- // for now just parsing onlin/offline info is enough
+ // parse HDMI events
+ // The event will be of the form:
+ // change@/devices/virtual/graphics/fb1 ACTION=change
+ // DEVPATH=/devices/virtual/graphics/fb1
+ // SUBSYSTEM=graphics HDCP_STATE=FAIL MAJOR=29
+ // for now just parsing onlin/offline info is enough
+ if (hdmi) {
str = udata;
int connected = 0;
if(!(strncmp(str,"online@",strlen("online@")))) {
connected = 1;
- ctx->mExtDisplay->setExternalDisplay(connected);
+ ctx->mExtDisplay->setExternalDisplay(connected);;
} else if(!(strncmp(str,"offline@",strlen("offline@")))) {
connected = 0;
- ctx->mExtDisplay->setExternalDisplay(connected);
+ ctx->mExtDisplay->setExternalDisplay(connected);;
}
}
-
}
static void *uevent_loop(void *param)
{
int len = 0;
- static char udata[4096];
- memset(udata, 0, sizeof(udata));
+ static char udata[PAGE_SIZE];
hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param);
-
+ char thread_name[64] = "hwcUeventThread";
+ prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
uevent_init();