Minimal changes to support multi-display HWC
authorJesse Hall <jessehall@google.com>
Thu, 26 Jul 2012 05:16:17 +0000 (22:16 -0700)
committerJesse Hall <jessehall@google.com>
Tue, 31 Jul 2012 04:37:30 +0000 (21:37 -0700)
Change-Id: I05e56d287a658f1174104b81e1b5ee0b33944555

libhwc/hwc.cpp

index a2d67e7c42116934ea28681ae79bd8832acc6344..7dd204b67203d6e0d485b8487fdc6c94bb151b67 100644 (file)
@@ -412,12 +412,13 @@ inline hwc_rect intersection(const hwc_rect &r1, const hwc_rect &r2)
     return i;
 }
 
-static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* list)
+static int exynos5_prepare(hwc_composer_device_1_t *dev,
+        size_t numDisplays, hwc_display_contents_1_t** displays)
 {
-    if (!list)
+    if (!numDisplays || !displays)
         return 0;
 
-    ALOGV("preparing %u layers", list->numHwLayers);
+    ALOGV("preparing %u layers", displays[0]->numHwLayers);
 
     exynos5_hwc_composer_device_1_t *pdev =
             (exynos5_hwc_composer_device_1_t *)dev;
@@ -439,19 +440,19 @@ static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* lis
     size_t first_fb = 0, last_fb = 0;
 
     // find unsupported overlays
-    for (size_t i = 0; i < list->numHwLayers; i++) {
-        hwc_layer_1_t &layer = list->hwLayers[i];
+    for (size_t i = 0; i < displays[0]->numHwLayers; i++) {
+        hwc_layer_1_t &layer = displays[0]->hwLayers[i];
 
         if (layer.compositionType == HWC_BACKGROUND && !force_fb) {
             ALOGV("\tlayer %u: background supported", i);
-            dump_layer(&list->hwLayers[i]);
+            dump_layer(&displays[0]->hwLayers[i]);
             continue;
         }
 
-        if (exynos5_supports_overlay(list->hwLayers[i], i) && !force_fb) {
+        if (exynos5_supports_overlay(displays[0]->hwLayers[i], i) && !force_fb) {
             ALOGV("\tlayer %u: overlay supported", i);
             layer.compositionType = HWC_OVERLAY;
-            dump_layer(&list->hwLayers[i]);
+            dump_layer(&displays[0]->hwLayers[i]);
             continue;
         }
 
@@ -462,13 +463,13 @@ static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* lis
         last_fb = i;
         layer.compositionType = HWC_FRAMEBUFFER;
 
-        dump_layer(&list->hwLayers[i]);
+        dump_layer(&displays[0]->hwLayers[i]);
     }
 
     // can't composite overlays sandwiched between framebuffers
     if (fb_needed)
         for (size_t i = first_fb; i < last_fb; i++)
-            list->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
+            displays[0]->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
 
     // Incrementally try to add our supported layers to hardware windows.
     // If adding a layer would violate a hardware constraint, force it
@@ -500,8 +501,8 @@ static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* lis
 
         changed = false;
 
-        for (size_t i = 0; i < list->numHwLayers; i++) {
-            hwc_layer_1_t &layer = list->hwLayers[i];
+        for (size_t i = 0; i < displays[0]->numHwLayers; i++) {
+            hwc_layer_1_t &layer = displays[0]->hwLayers[i];
             if (layer.flags & HWC_SKIP_LAYER)
                 continue;
 
@@ -565,14 +566,14 @@ static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* lis
 
         if (changed)
             for (size_t i = first_fb; i < last_fb; i++)
-                list->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
+                displays[0]->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
     } while(changed);
 
     unsigned int nextWindow = 0;
     int nextGsc = 0;
 
-    for (size_t i = 0; i < list->numHwLayers; i++) {
-        hwc_layer_1_t &layer = list->hwLayers[i];
+    for (size_t i = 0; i < displays[0]->numHwLayers; i++) {
+        hwc_layer_1_t &layer = displays[0]->hwLayers[i];
         if (layer.flags & HWC_SKIP_LAYER)
             continue;
 
@@ -869,24 +870,24 @@ static void exynos5_post_callback(void *data, private_handle_t *fb)
     pthread_mutex_unlock(&pdata->completion_lock);
 }
 
-static int exynos5_set(struct hwc_composer_device_1 *dev, hwc_display_t dpy,
-        hwc_surface_t sur, hwc_layer_list_1_t* list)
+static int exynos5_set(struct hwc_composer_device_1 *dev,
+        size_t numDisplays, hwc_display_contents_1_t** displays)
 {
     exynos5_hwc_composer_device_1_t *pdev =
             (exynos5_hwc_composer_device_1_t *)dev;
 
-    if (!dpy || !sur)
+    if (!numDisplays || !displays || !displays[0] || !displays[0]->dpy || !displays[0]->sur)
         return 0;
 
     hwc_callback_queue_t *queue = NULL;
     pthread_mutex_t *lock = NULL;
     exynos5_hwc_post_data_t *data = NULL;
 
-    if (list) {
+    if (displays[0]->numHwLayers) {
         for (size_t i = 0; i < NUM_HW_WINDOWS; i++) {
             if (pdev->bufs.overlay_map[i] != -1) {
                 pdev->bufs.overlays[i] =
-                    list->hwLayers[pdev->bufs.overlay_map[i]];
+                    displays[0]->hwLayers[pdev->bufs.overlay_map[i]];
             }
         }
 
@@ -915,11 +916,11 @@ static int exynos5_set(struct hwc_composer_device_1 *dev, hwc_display_t dpy,
             queue->push_front(entry);
             pthread_mutex_unlock(lock);
 
-            EGLBoolean success = eglSwapBuffers((EGLDisplay)dpy,
-                    (EGLSurface)sur);
+            EGLBoolean success = eglSwapBuffers((EGLDisplay)displays[0]->dpy,
+                    (EGLSurface)displays[0]->sur);
             if (!success) {
                 ALOGE("HWC_EGL_ERROR");
-                if (list) {
+                if (displays[0]) {
                     pthread_mutex_lock(lock);
                     queue->removeAt(0);
                     pthread_mutex_unlock(lock);
@@ -941,7 +942,7 @@ static int exynos5_set(struct hwc_composer_device_1 *dev, hwc_display_t dpy,
             int dup_fd = dup(data->fence);
             if (dup_fd < 0)
                 ALOGW("release fence dup failed: %s", strerror(errno));
-            list->hwLayers[pdev->bufs.overlay_map[i]].releaseFenceFd = dup_fd;
+            displays[0]->hwLayers[pdev->bufs.overlay_map[i]].releaseFenceFd = dup_fd;
         }
     }
     close(data->fence);
@@ -978,8 +979,8 @@ static int exynos5_query(struct hwc_composer_device_1* dev, int what, int *value
     return 0;
 }
 
-static int exynos5_eventControl(struct hwc_composer_device_1 *dev, int event,
-        int enabled)
+static int exynos5_eventControl(struct hwc_composer_device_1 *dev, int dpy,
+        int event, int enabled)
 {
     struct exynos5_hwc_composer_device_1_t *pdev =
             (struct exynos5_hwc_composer_device_1_t *)dev;
@@ -1096,7 +1097,7 @@ static void *hwc_vsync_thread(void *data)
     return NULL;
 }
 
-static int exynos5_blank(struct hwc_composer_device_1 *dev, int blank)
+static int exynos5_blank(struct hwc_composer_device_1 *dev, int dpy, int blank)
 {
     struct exynos5_hwc_composer_device_1_t *pdev =
             (struct exynos5_hwc_composer_device_1_t *)dev;