OSDN Git Service

minigbm: allow for multiple {format, modifier} pairs in combination list
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 1 Dec 2016 21:36:04 +0000 (13:36 -0800)
committerchrome-bot <chrome-bot@chromium.org>
Wed, 7 Dec 2016 03:55:08 +0000 (19:55 -0800)
With CL:405019, drv_insert_supported_combination appended flags if the
{format, modifier} pair was already in the list. This would result
in the BO_USE_RENDERING flag being in the same supported combination
as BO_USE_LINEAR, even though the arrays in the drivers try to separate
these cases. Initially, add all the combinations specified by
the drivers. When querying KMS, add a helper function that modifies
existing combinations if they already exist.

BUG=b:31942635,
TEST=graphics_Gbm, Chrome boots on minnie
CQ-DEPEND=CL:414584

Change-Id: I64326be2078ae745fca2c819e8344797aef3c667
Reviewed-on: https://chromium-review.googlesource.com/415442
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
helpers.c
helpers.h

index cc66fc6..75c982f 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -276,44 +276,59 @@ uint32_t drv_log_base2(uint32_t value)
        return ret;
 }
 
+/* Inserts a combination into list -- caller should have lock on driver. */
 void drv_insert_supported_combination(struct driver *drv, uint32_t format,
                                      uint64_t usage, uint64_t modifier)
 {
-       int found = 0;
        struct combination_list_element *elem;
 
-       pthread_mutex_lock(&drv->driver_lock);
-
-       list_for_each_entry(struct combination_list_element,
-                           elem, &drv->backend->combinations, link) {
-               if (elem->combination.format == format &&
-                   elem->combination.modifier == modifier) {
-                       elem->combination.usage |= usage;
-                       found = 1;
-               }
-       }
-
-       if (found)
-               goto out;
-
        elem = calloc(1, sizeof(*elem));
        elem->combination.format = format;
        elem->combination.modifier = modifier;
        elem->combination.usage = usage;
        LIST_ADD(&elem->link, &drv->backend->combinations);
-
-out:
-       pthread_mutex_unlock(&drv->driver_lock);
 }
 
 void drv_insert_combinations(struct driver *drv, struct supported_combination *combos,
                             uint32_t size)
 {
        unsigned int i;
+
+       pthread_mutex_lock(&drv->driver_lock);
+
        for (i = 0; i < size; i++)
                drv_insert_supported_combination(drv, combos[i].format,
                                                 combos[i].usage,
                                                 combos[i].modifier);
+
+       pthread_mutex_unlock(&drv->driver_lock);
+}
+
+void drv_modify_supported_combination(struct driver *drv, uint32_t format,
+                                     uint64_t usage, uint64_t modifier)
+{
+       /*
+        * Attempts to add the specified usage to an existing {format, modifier}
+        * pair. If the pair is not present, a new combination is created.
+        */
+       int found = 0;
+
+       pthread_mutex_lock(&drv->driver_lock);
+
+       list_for_each_entry(struct combination_list_element,
+                           elem, &drv->backend->combinations, link) {
+               if (elem->combination.format == format &&
+                   elem->combination.modifier == modifier) {
+                       elem->combination.usage |= usage;
+                       found = 1;
+               }
+       }
+
+
+       if (!found)
+               drv_insert_supported_combination(drv, format, usage, modifier);
+
+       pthread_mutex_unlock(&drv->driver_lock);
 }
 
 int drv_add_kms_flags(struct driver *drv)
@@ -332,12 +347,10 @@ int drv_add_kms_flags(struct driver *drv)
         * combination here. Note that the kernel disregards the alpha component
         * of ARGB unless it's an overlay plane.
         */
-       drv_insert_supported_combination(drv, DRM_FORMAT_XRGB8888,
-                                        DRV_BO_USE_SCANOUT,
-                                        0);
-       drv_insert_supported_combination(drv, DRM_FORMAT_ARGB8888,
-                                        DRV_BO_USE_SCANOUT,
-                                        0);
+       drv_modify_supported_combination(drv, DRM_FORMAT_XRGB8888,
+                                        DRV_BO_USE_SCANOUT, 0);
+       drv_modify_supported_combination(drv, DRM_FORMAT_ARGB8888,
+                                        DRV_BO_USE_SCANOUT, 0);
 
        /*
         * The ability to return universal planes is only complete on
@@ -389,7 +402,7 @@ int drv_add_kms_flags(struct driver *drv)
                }
 
                for (j = 0; j < plane->count_formats; j++)
-                       drv_insert_supported_combination(drv, plane->formats[j],
+                       drv_modify_supported_combination(drv, plane->formats[j],
                                                         usage, 0);
 
                drmModeFreeObjectProperties(props);
index aa549b0..5b72bac 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -29,5 +29,7 @@ void drv_insert_supported_combination(struct driver *drv, uint32_t format,
 void drv_insert_combinations(struct driver *drv,
                             struct supported_combination *combos,
                             uint32_t size);
+void drv_modify_supported_combination(struct driver *drv, uint32_t format,
+                                     uint64_t usage, uint64_t modifier);
 int drv_add_kms_flags(struct driver *drv);
 #endif