diff options
author | codeworkx <codeworkx@cyanogenmod.org> | 2012-12-01 13:02:41 +0100 |
---|---|---|
committer | codeworkx <codeworkx@cyanogenmod.org> | 2012-12-01 13:05:32 +0100 |
commit | 53cacd86d64639e7f0d722c49b45caacf96b8594 (patch) | |
tree | 3b1867332d8d61e1139e0aab02acb219b5f321f6 | |
parent | 707e301de8b52780a7f0e88e6f25ac919c23671f (diff) | |
download | hardware_ti_omap4xxx-53cacd86d64639e7f0d722c49b45caacf96b8594.zip hardware_ti_omap4xxx-53cacd86d64639e7f0d722c49b45caacf96b8594.tar.gz hardware_ti_omap4xxx-53cacd86d64639e7f0d722c49b45caacf96b8594.tar.bz2 |
hwc: support vsync notification via sysfs
Change-Id: Ie2172b5fb2e8595136f6ccb28abd9f8ce89a526f
-rw-r--r-- | hwc/Android.mk | 5 | ||||
-rw-r--r-- | hwc/hwc.c | 49 |
2 files changed, 54 insertions, 0 deletions
diff --git a/hwc/Android.mk b/hwc/Android.mk index c6a2eae..11a7b13 100644 --- a/hwc/Android.mk +++ b/hwc/Android.mk @@ -16,6 +16,11 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := hwcomposer.omap4 LOCAL_CFLAGS := -DLOG_TAG=\"ti_hwc\" LOCAL_C_INCLUDES += external/libpng external/zlib + +ifeq ($(BOARD_USE_SYSFS_VSYNC_NOTIFICATION),true) +LOCAL_CFLAGS += -DSYSFS_VSYNC_NOTIFICATION +endif + # LOG_NDEBUG=0 means verbose logging enabled # LOCAL_CFLAGS += -DLOG_NDEBUG=0 include $(BUILD_SHARED_LIBRARY) @@ -26,6 +26,10 @@ #include <sys/mman.h> #include <sys/resource.h> +#ifdef SYSFS_VSYNC_NOTIFICATION +#include <sys/prctl.h> +#endif + #include <cutils/properties.h> #include <cutils/log.h> #include <cutils/native_handle.h> @@ -124,6 +128,9 @@ struct omap4_hwc_device { hwc_composer_device_1_t base; hwc_procs_t *procs; pthread_t hdmi_thread; +#ifdef SYSFS_VSYNC_NOTIFICATION + pthread_t vsync_thread; +#endif pthread_mutex_t lock; IMG_framebuffer_device_public_t *fb_dev; @@ -1837,6 +1844,38 @@ static void handle_uevents(omap4_hwc_device_t *hwc_dev, const char *buff, int le } } +#ifdef SYSFS_VSYNC_NOTIFICATION +static void *omap4_hwc_vsync_sysfs_loop(void *data) +{ + omap4_hwc_device_t *hwc_dev = data; + static char buf[4096]; + int vsync_timestamp_fd; + fd_set exceptfds; + int res; + int64_t timestamp = 0; + + vsync_timestamp_fd = open("/sys/devices/platform/omapfb/vsync_time", O_RDONLY); + char thread_name[64] = "hwcVsyncThread"; + prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); + setpriority(PRIO_PROCESS, 0, -20); + memset(buf, 0, sizeof(buf)); + + ALOGD("Using sysfs mechanism for VSYNC notification"); + + FD_ZERO(&exceptfds); + FD_SET(vsync_timestamp_fd, &exceptfds); + do { + ssize_t len = read(vsync_timestamp_fd, buf, sizeof(buf)); + timestamp = strtoull(buf, NULL, 0); + hwc_dev->procs->vsync(hwc_dev->procs, 0, timestamp); + select(vsync_timestamp_fd + 1, NULL, NULL, &exceptfds, NULL); + lseek(vsync_timestamp_fd, 0, SEEK_SET); + } while (1); + + return NULL; +} +#endif + static void *omap4_hwc_hdmi_thread(void *data) { omap4_hwc_device_t *hwc_dev = data; @@ -2068,6 +2107,16 @@ static int omap4_hwc_device_open(const hw_module_t* module, const char* name, err = -errno; goto done; } + +#ifdef SYSFS_VSYNC_NOTIFICATION + if (pthread_create(&hwc_dev->vsync_thread, NULL, omap4_hwc_vsync_sysfs_loop, hwc_dev)) + { + ALOGE("pthread_create() failed : %s", errno); + err = -errno; + goto done; + } +#endif + if (pthread_create(&hwc_dev->hdmi_thread, NULL, omap4_hwc_hdmi_thread, hwc_dev)) { ALOGE("failed to create HDMI listening thread (%d): %m", errno); |