minigbm: Refactored minigbm on top a private API
We would like to reuse the same set of drivers for ChromeOS (with
a minigbm frontend) and Android (with a gralloc frontend). Since
we don't want to pollute the gbm API with gralloc formats and usages,
we can refactor minigbm on top a private API that will be a superset
of gbm and gralloc. This change redirects gbm calls to the
private API.
TEST=Ran graphics_Gbm on minnie and cyan, and checked if Chrome boots.
BUG=chromium:616275
CQ-DEPEND=CL:367791
Change-Id: I50d10f9d6c7ea936b0d76c5299a58d948939fdf9
Reviewed-on: https://chromium-review.googlesource.com/367780
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/drv_priv.h b/drv_priv.h
new file mode 100644
index 0000000..d49c9da
--- /dev/null
+++ b/drv_priv.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef DRV_PRIV_H
+#define DRV_PRIV_H
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "drv.h"
+
+struct bo
+{
+ struct driver *drv;
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
+ uint32_t tiling;
+ size_t num_planes;
+ union bo_handle handles[DRV_MAX_PLANES];
+ uint32_t offsets[DRV_MAX_PLANES];
+ uint32_t sizes[DRV_MAX_PLANES];
+ uint32_t strides[DRV_MAX_PLANES];
+ uint64_t format_modifiers[DRV_MAX_PLANES];
+ void *priv;
+};
+
+struct driver {
+ int fd;
+ struct backend *backend;
+ void *priv;
+};
+
+struct backend
+{
+ char *name;
+ int (*init)(struct driver *drv);
+ void (*close)(struct driver *drv);
+ int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height,
+ drv_format_t format, uint32_t flags);
+ int (*bo_destroy)(struct bo *bo);
+ struct format_supported {
+ drv_format_t format;
+ uint64_t usage;
+ }
+ format_list[18];
+};
+
+#endif