summaryrefslogtreecommitdiff
path: root/drv.h
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2016-08-05 14:40:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-12 22:44:40 -0700
commit46faf6bf430b8f8805f2acfad546329eebcd50f6 (patch)
treec2ca577f4520b878e99eed244137867a04588c70 /drv.h
parent0fd114250dba56533eee9b7a812bc287b7dbf663 (diff)
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>
Diffstat (limited to 'drv.h')
-rw-r--r--drv.h186
1 files changed, 186 insertions, 0 deletions
diff --git a/drv.h b/drv.h
new file mode 100644
index 0000000..2b523e0
--- /dev/null
+++ b/drv.h
@@ -0,0 +1,186 @@
+/*
+ * 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_H_
+#define DRV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define DRV_MAX_PLANES 4
+
+/* Vendor ids and mod_code fourcc function must match gbm.h */
+#define DRV_FORMAT_MOD_NONE 0
+#define DRV_FORMAT_MOD_VENDOR_INTEL 0x01
+#define DRV_FORMAT_MOD_VENDOR_AMD 0x02
+#define DRV_FORMAT_MOD_VENDOR_NV 0x03
+#define DRV_FORMAT_MOD_VENDOR_SAMSUNG 0x04
+#define DRV_FORMAT_MOD_VENDOR_QCOM 0x05
+
+#define drv_fourcc_mod_code(vendor, val) \
+ ((((__u64)DRV_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL))
+
+/* Use flags */
+#define DRV_BO_USE_NONE 0
+#define DRV_BO_USE_SCANOUT (1ull << 0)
+#define DRV_BO_USE_CURSOR (1ull << 1)
+#define DRV_BO_USE_CURSOR_64X64 DRV_BO_USE_CURSOR
+#define DRV_BO_USE_RENDERING (1ull << 2)
+#define DRV_BO_USE_LINEAR (1ull << 3)
+
+typedef enum {
+ DRV_FORMAT_NONE,
+ DRV_FORMAT_C8,
+ DRV_FORMAT_R8,
+ DRV_FORMAT_RG88,
+ DRV_FORMAT_GR88,
+ DRV_FORMAT_RGB332,
+ DRV_FORMAT_BGR233,
+ DRV_FORMAT_XRGB4444,
+ DRV_FORMAT_XBGR4444,
+ DRV_FORMAT_RGBX4444,
+ DRV_FORMAT_BGRX4444,
+ DRV_FORMAT_ARGB4444,
+ DRV_FORMAT_ABGR4444,
+ DRV_FORMAT_RGBA4444,
+ DRV_FORMAT_BGRA4444,
+ DRV_FORMAT_XRGB1555,
+ DRV_FORMAT_XBGR1555,
+ DRV_FORMAT_RGBX5551,
+ DRV_FORMAT_BGRX5551,
+ DRV_FORMAT_ARGB1555,
+ DRV_FORMAT_ABGR1555,
+ DRV_FORMAT_RGBA5551,
+ DRV_FORMAT_BGRA5551,
+ DRV_FORMAT_RGB565,
+ DRV_FORMAT_BGR565,
+ DRV_FORMAT_RGB888,
+ DRV_FORMAT_BGR888,
+ DRV_FORMAT_XRGB8888,
+ DRV_FORMAT_XBGR8888,
+ DRV_FORMAT_RGBX8888,
+ DRV_FORMAT_BGRX8888,
+ DRV_FORMAT_ARGB8888,
+ DRV_FORMAT_ABGR8888,
+ DRV_FORMAT_RGBA8888,
+ DRV_FORMAT_BGRA8888,
+ DRV_FORMAT_XRGB2101010,
+ DRV_FORMAT_XBGR2101010,
+ DRV_FORMAT_RGBX1010102,
+ DRV_FORMAT_BGRX1010102,
+ DRV_FORMAT_ARGB2101010,
+ DRV_FORMAT_ABGR2101010,
+ DRV_FORMAT_RGBA1010102,
+ DRV_FORMAT_BGRA1010102,
+ DRV_FORMAT_YUYV,
+ DRV_FORMAT_YVYU,
+ DRV_FORMAT_UYVY,
+ DRV_FORMAT_VYUY,
+ DRV_FORMAT_AYUV,
+ DRV_FORMAT_NV12,
+ DRV_FORMAT_NV21,
+ DRV_FORMAT_NV16,
+ DRV_FORMAT_NV61,
+ DRV_FORMAT_YUV410,
+ DRV_FORMAT_YVU410,
+ DRV_FORMAT_YUV411,
+ DRV_FORMAT_YVU411,
+ DRV_FORMAT_YUV420,
+ DRV_FORMAT_YVU420,
+ DRV_FORMAT_YUV422,
+ DRV_FORMAT_YVU422,
+ DRV_FORMAT_YUV444,
+ DRV_FORMAT_YVU444,
+} drv_format_t;
+
+struct driver;
+struct bo;
+
+union bo_handle {
+ void *ptr;
+ int32_t s32;
+ uint32_t u32;
+ int64_t s64;
+ uint64_t u64;
+};
+
+struct drv_import_fd_data {
+ int fd;
+ uint32_t width;
+ uint32_t height;
+ uint32_t stride;
+ drv_format_t format;
+};
+
+struct driver *
+drv_create(int fd);
+
+void
+drv_destroy(struct driver *drv);
+
+int
+drv_get_fd(struct driver *drv);
+
+const char *
+drv_get_name(struct driver *drv);
+
+int
+drv_is_format_supported(struct driver *drv, drv_format_t format,
+ uint64_t usage);
+
+struct bo *
+drv_bo_new(struct driver *drv, uint32_t width, uint32_t height,
+ drv_format_t format);
+
+struct bo *
+drv_bo_create(struct driver *drv, uint32_t width, uint32_t height,
+ drv_format_t format, uint64_t flags);
+
+void
+drv_bo_destroy(struct bo *bo);
+
+struct bo *
+drv_bo_import(struct driver *drv, struct drv_import_fd_data *data);
+
+uint32_t
+drv_bo_get_width(struct bo *bo);
+
+uint32_t
+drv_bo_get_height(struct bo *bo);
+
+uint32_t
+drv_bo_get_stride_or_tiling(struct bo *bo);
+
+size_t
+drv_bo_get_num_planes(struct bo *bo);
+
+union bo_handle
+drv_bo_get_plane_handle(struct bo *bo, size_t plane);
+
+int
+drv_bo_get_plane_fd(struct bo *bo, size_t plane);
+
+uint32_t
+drv_bo_get_plane_offset(struct bo *bo, size_t plane);
+
+uint32_t
+drv_bo_get_plane_size(struct bo *bo, size_t plane);
+
+uint32_t
+drv_bo_get_plane_stride(struct bo *bo, size_t plane);
+
+uint64_t
+drv_bo_get_plane_format_modifier(struct bo *bo, size_t plane);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+