display: Enable vsync
* Use the vsync uevents from the kernel to start
surfaceflinger composition.
* This patch also does some code cleanup
- Move copybit specific functions to copybit files.
- Cleanup verbose logging.
Change-Id: I36936e4b0a082cfb0347d8ee7d2bc936e01808e6
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 7826a5f..c0bca9d 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -20,8 +20,12 @@
#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <EGL/egl.h>
+#include <overlay.h>
+#include <fb_priv.h>
#include "hwc_utils.h"
+#include "hwc_qbuf.h"
#include "hwc_video.h"
#include "hwc_uimirror.h"
#include "hwc_copybit.h"
@@ -93,6 +97,47 @@
return 0;
}
+static int hwc_eventControl(struct hwc_composer_device* dev,
+ int event, int enabled)
+{
+ int ret = 0;
+ hwc_context_t* ctx = (hwc_context_t*)(dev);
+ private_module_t* m = reinterpret_cast<private_module_t*>(
+ ctx->mFbDev->common.module);
+ switch(event) {
+ case HWC_EVENT_VSYNC:
+ if(ioctl(m->framebuffer->fd, MSMFB_OVERLAY_VSYNC_CTRL, &enabled) < 0)
+ ret = -errno;
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ return ret;
+}
+
+static int hwc_query(struct hwc_composer_device* dev,
+ int param, int* value)
+{
+ hwc_context_t* ctx = (hwc_context_t*)(dev);
+ private_module_t* m = reinterpret_cast<private_module_t*>(
+ ctx->mFbDev->common.module);
+
+ switch (param) {
+ case HWC_BACKGROUND_LAYER_SUPPORTED:
+ // Not supported for now
+ value[0] = 0;
+ break;
+ case HWC_VSYNC_PERIOD:
+ value[0] = 1000000000.0 / m->fps;
+ ALOGI("fps: %d", value[0]);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+
+}
+
static int hwc_set(hwc_composer_device_t *dev,
hwc_display_t dpy,
hwc_surface_t sur,
@@ -119,7 +164,7 @@
static int hwc_device_close(struct hw_device_t *dev)
{
if(!dev) {
- ALOGE("hwc_device_close null device pointer");
+ ALOGE("%s: NULL device pointer", __FUNCTION__);
return -1;
}
closeContext((hwc_context_t*)dev);
@@ -137,14 +182,25 @@
struct hwc_context_t *dev;
dev = (hwc_context_t*)malloc(sizeof(*dev));
memset(dev, 0, sizeof(*dev));
+
+ //Initialize hwc context
initContext(dev);
+
+ //Setup HWC methods
+ hwc_methods_t *methods;
+ methods = (hwc_methods_t *)malloc(sizeof(*methods));
+ memset(methods, 0, sizeof(*methods));
+ methods->eventControl = hwc_eventControl;
+
dev->device.common.tag = HARDWARE_DEVICE_TAG;
- dev->device.common.version = 0;
+ dev->device.common.version = HWC_DEVICE_API_VERSION_0_3;
dev->device.common.module = const_cast<hw_module_t*>(module);
dev->device.common.close = hwc_device_close;
dev->device.prepare = hwc_prepare;
dev->device.set = hwc_set;
dev->device.registerProcs = hwc_registerProcs;
+ dev->device.query = hwc_query;
+ dev->device.methods = methods;
*device = &dev->device.common;
status = 0;
}