summaryrefslogtreecommitdiff
path: root/drv.c
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2017-03-01 20:14:39 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-03-16 11:25:47 -0700
commit6b41fb55deae7d8ae00c33f7ce849d6fd6525d77 (patch)
tree92d9f413a88e3cb3c330da5aaaecaeb541593cf3 /drv.c
parent4d22b4e285f02adfc65d6ae1d6469a0e13ee12ba (diff)
minigbm: rework flag API
We've been back and forth on the semantics of the flag API many times, and the current situation is confusing. Change the drivers so every combination defines a distinct type of buffer. That means if the same format is in the combination list three times, the tiling or format modifiers of one of those combinations must be different from the other two. Let's add a priority variable in struct supported_combination that breaks ties. For example, if a consumer specifies BO_USE_TEXTURE, we of course can texture from both linear and tiled buffers, but because a tiled buffer's priority is greater, it will be chosen. If a consumer specifies BO_USE_TEXTURE | BO_USE_SW_WRITE_OFTEN, the tiled combination won't have the BO_USE_SW_WRITE_OFTEN flag and the linear combination will be chosen. We expect drivers to modify the combinations after querying KMS. This is clunky using linked lists, so get rid of list.h and use arrays. BUG=chromium:616275 TEST=all the following compiles: emerge-cyan minigbm/arc-cros-gralloc emerge-oak minigbm/arc-cros-gralloc emerge-veyron_minnie-cheets minigbm/arc-cros-gralloc emerge-peach_pi minigbm emerge-nyan_big minigbm emerge-jadeite minigbm Tested with gbmtest on cyan, checked if Chrome boots Change-Id: Ib3fccf6f0cb86c8ded45924297df3c06f8e49271 Reviewed-on: https://chromium-review.googlesource.com/448252 Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Diffstat (limited to 'drv.c')
-rw-r--r--drv.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/drv.c b/drv.c
index 8836065..4d6d981 100644
--- a/drv.c
+++ b/drv.c
@@ -131,12 +131,20 @@ struct driver *drv_create(int fd)
if (!drv->map_table)
goto free_buffer_table;
- LIST_INITHEAD(&drv->backend->combinations);
+ /* Start with a power of 2 number of allocations. */
+ drv->backend->combos.allocations = 2;
+ drv->backend->combos.size = 0;
+ drv->backend->combos.data = calloc(drv->backend->combos.allocations,
+ sizeof(struct combination));
+ if (!drv->backend->combos.data)
+ goto free_map_table;
if (drv->backend->init) {
ret = drv->backend->init(drv);
- if (ret)
+ if (ret) {
+ free(drv->backend->combos.data);
goto free_map_table;
+ }
}
return drv;
@@ -162,11 +170,7 @@ void drv_destroy(struct driver *drv)
drmHashDestroy(drv->buffer_table);
drmHashDestroy(drv->map_table);
- list_for_each_entry_safe(struct combination_list_element, elem,
- &drv->backend->combinations, link) {
- LIST_DEL(&elem->link);
- free(elem);
- }
+ free(drv->backend->combos.data);
pthread_mutex_unlock(&drv->driver_lock);
pthread_mutex_destroy(&drv->driver_lock);
@@ -185,22 +189,25 @@ drv_get_name(struct driver *drv)
return drv->backend->name;
}
-int drv_is_combination_supported(struct driver *drv, uint32_t format,
- uint64_t usage, uint64_t modifier)
+struct combination *drv_get_combination(struct driver *drv, uint32_t format,
+ uint64_t usage)
{
+ struct combination *curr, *best;
if (format == DRM_FORMAT_NONE || usage == BO_USE_NONE)
return 0;
- list_for_each_entry(struct combination_list_element, elem,
- &drv->backend->combinations, link) {
- if (format == elem->combination.format &&
- usage == (elem->combination.usage & usage) &&
- modifier == elem->combination.modifier)
- return 1;
+ best = NULL;
+ uint32_t i;
+ for (i = 0; i < drv->backend->combos.size; i++) {
+ curr = &drv->backend->combos.data[i];
+ if ((format == curr->format) && usage == (curr->usage & usage))
+ if (!best ||
+ best->metadata.priority < curr->metadata.priority)
+ best = curr;
}
- return 0;
+ return best;
}
struct bo *drv_bo_new(struct driver *drv, uint32_t width, uint32_t height,