minigbm/i915: Implement bo_create_with_modifiers

This implements the bo_create_with_modifiers driver functions, which
enables the gbm_bo_create_with_modifiers() entry point. This will
allow ozone to allocate with the modifiers it queries from KMS.

BUG=chromium:763760
TEST=Allocates Y-tiled scanout on SKL+

Change-Id: Id770e571a51aef4d753b30e12cd67d935c5228b7
Reviewed-on: https://chromium-review.googlesource.com/729279
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
diff --git a/helpers.c b/helpers.c
index 07044da..bdae73d 100644
--- a/helpers.c
+++ b/helpers.c
@@ -605,3 +605,23 @@
 	free(items);
 	return 0;
 }
+
+/*
+ * Pick the best modifier from modifiers, according to the ordering
+ * given by modifier_order.
+ */
+uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
+			   const uint64_t *modifier_order, uint32_t order_count)
+{
+	uint32_t i, j;
+
+	for (i = 0; i < order_count; i++) {
+		for (j = 0; j < count; j++) {
+			if (modifiers[j] == modifier_order[i]) {
+				return modifiers[j];
+			}
+		}
+	}
+
+	return DRM_FORMAT_MOD_LINEAR;
+}