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>
diff --git a/helpers.h b/helpers.h
index 64e8489..e265b42 100644
--- a/helpers.h
+++ b/helpers.h
@@ -25,12 +25,14 @@
 void drv_decrement_reference_count(struct driver *drv, struct bo *bo,
 				   size_t plane);
 uint32_t drv_log_base2(uint32_t value);
-void drv_insert_supported_combination(struct driver *drv, uint32_t format,
-			              uint64_t usage, uint64_t modifier);
-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);
+int drv_add_combination(struct driver *drv, uint32_t format,
+			struct format_metadata *metadata, uint64_t usage);
+int drv_add_combinations(struct driver *drv, const uint32_t *formats,
+			 uint32_t num_formats, struct format_metadata *metadata,
+			 uint64_t usage);
+void drv_modify_combination(struct driver *drv, uint32_t format,
+			    struct format_metadata *metadata, uint64_t usage);
+struct kms_item *drv_query_kms(struct driver *drv, uint32_t *num_items);
+int drv_add_linear_combinations(struct driver *drv, const uint32_t *formats,
+				uint32_t num_formats);
 #endif