Minimal changes to support multi-display HWC
authorJesse Hall <jessehall@google.com>
Tue, 31 Jul 2012 21:34:08 +0000 (14:34 -0700)
committerJamie Gennis <jgennis@google.com>
Tue, 7 Aug 2012 19:29:18 +0000 (12:29 -0700)
Change-Id: I8d95065f70c18356672cb3f3e5151d38408d09c0

libhwc/hwc.cpp

index a13c05dfcb7256ce15de6013fedc33b67e0180ef..229031bf83e0f4dc221b10de21ef3e6490be9c88 100644 (file)
@@ -430,12 +430,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;
@@ -457,19 +458,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;
         }
 
@@ -480,13 +481,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
@@ -518,8 +519,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;
 
@@ -583,14 +584,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;
 
@@ -889,24 +890,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]];
             }
         }
 
@@ -935,11 +936,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);
@@ -961,7 +962,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);
@@ -998,8 +999,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;
@@ -1116,7 +1117,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;