1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2011 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18bf215546Sopenharmony_ci * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19bf215546Sopenharmony_ci * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20bf215546Sopenharmony_ci * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci *
24bf215546Sopenharmony_ci * Authors:
25bf215546Sopenharmony_ci *    Benjamin Franzke <benjaminfranzke@googlemail.com>
26bf215546Sopenharmony_ci */
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#ifndef _GBM_H_
29bf215546Sopenharmony_ci#define _GBM_H_
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#define __GBM__ 1
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#include <stddef.h>
34bf215546Sopenharmony_ci#include <stdint.h>
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#ifdef __cplusplus
37bf215546Sopenharmony_ciextern "C" {
38bf215546Sopenharmony_ci#endif
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci
41bf215546Sopenharmony_ci/**
42bf215546Sopenharmony_ci * \file gbm.h
43bf215546Sopenharmony_ci * \brief Generic Buffer Manager
44bf215546Sopenharmony_ci */
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_cistruct gbm_device;
47bf215546Sopenharmony_cistruct gbm_bo;
48bf215546Sopenharmony_cistruct gbm_surface;
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci/**
51bf215546Sopenharmony_ci * \mainpage The Generic Buffer Manager
52bf215546Sopenharmony_ci *
53bf215546Sopenharmony_ci * This module provides an abstraction that the caller can use to request a
54bf215546Sopenharmony_ci * buffer from the underlying memory management system for the platform.
55bf215546Sopenharmony_ci *
56bf215546Sopenharmony_ci * This allows the creation of portable code whilst still allowing access to
57bf215546Sopenharmony_ci * the underlying memory manager.
58bf215546Sopenharmony_ci */
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci/**
61bf215546Sopenharmony_ci * Abstraction representing the handle to a buffer allocated by the
62bf215546Sopenharmony_ci * manager
63bf215546Sopenharmony_ci */
64bf215546Sopenharmony_ciunion gbm_bo_handle {
65bf215546Sopenharmony_ci   void *ptr;
66bf215546Sopenharmony_ci   int32_t s32;
67bf215546Sopenharmony_ci   uint32_t u32;
68bf215546Sopenharmony_ci   int64_t s64;
69bf215546Sopenharmony_ci   uint64_t u64;
70bf215546Sopenharmony_ci};
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci/** Format of the allocated buffer */
73bf215546Sopenharmony_cienum gbm_bo_format {
74bf215546Sopenharmony_ci   /** RGB with 8 bits per channel in a 32 bit value */
75bf215546Sopenharmony_ci   GBM_BO_FORMAT_XRGB8888,
76bf215546Sopenharmony_ci   /** ARGB with 8 bits per channel in a 32 bit value */
77bf215546Sopenharmony_ci   GBM_BO_FORMAT_ARGB8888
78bf215546Sopenharmony_ci};
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ci/**
82bf215546Sopenharmony_ci * The FourCC format codes are taken from the drm_fourcc.h definition, and
83bf215546Sopenharmony_ci * re-namespaced. New GBM formats must not be added, unless they are
84bf215546Sopenharmony_ci * identical ports from drm_fourcc.
85bf215546Sopenharmony_ci */
86bf215546Sopenharmony_ci#define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
87bf215546Sopenharmony_ci			      ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci#define GBM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci/* color index */
92bf215546Sopenharmony_ci#define GBM_FORMAT_C8		__gbm_fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci/* 8 bpp Red */
95bf215546Sopenharmony_ci#define GBM_FORMAT_R8		__gbm_fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci/* 16 bpp Red */
98bf215546Sopenharmony_ci#define GBM_FORMAT_R16          __gbm_fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_ci/* 16 bpp RG */
101bf215546Sopenharmony_ci#define GBM_FORMAT_GR88		__gbm_fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci/* 32 bpp RG */
104bf215546Sopenharmony_ci#define GBM_FORMAT_RG1616	__gbm_fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */
105bf215546Sopenharmony_ci#define GBM_FORMAT_GR1616	__gbm_fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci/* 8 bpp RGB */
108bf215546Sopenharmony_ci#define GBM_FORMAT_RGB332	__gbm_fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */
109bf215546Sopenharmony_ci#define GBM_FORMAT_BGR233	__gbm_fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ci/* 16 bpp RGB */
112bf215546Sopenharmony_ci#define GBM_FORMAT_XRGB4444	__gbm_fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */
113bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR4444	__gbm_fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */
114bf215546Sopenharmony_ci#define GBM_FORMAT_RGBX4444	__gbm_fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */
115bf215546Sopenharmony_ci#define GBM_FORMAT_BGRX4444	__gbm_fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci#define GBM_FORMAT_ARGB4444	__gbm_fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */
118bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR4444	__gbm_fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */
119bf215546Sopenharmony_ci#define GBM_FORMAT_RGBA4444	__gbm_fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */
120bf215546Sopenharmony_ci#define GBM_FORMAT_BGRA4444	__gbm_fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci#define GBM_FORMAT_XRGB1555	__gbm_fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */
123bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR1555	__gbm_fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */
124bf215546Sopenharmony_ci#define GBM_FORMAT_RGBX5551	__gbm_fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */
125bf215546Sopenharmony_ci#define GBM_FORMAT_BGRX5551	__gbm_fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci#define GBM_FORMAT_ARGB1555	__gbm_fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */
128bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR1555	__gbm_fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */
129bf215546Sopenharmony_ci#define GBM_FORMAT_RGBA5551	__gbm_fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */
130bf215546Sopenharmony_ci#define GBM_FORMAT_BGRA5551	__gbm_fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci#define GBM_FORMAT_RGB565	__gbm_fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */
133bf215546Sopenharmony_ci#define GBM_FORMAT_BGR565	__gbm_fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci/* 24 bpp RGB */
136bf215546Sopenharmony_ci#define GBM_FORMAT_RGB888	__gbm_fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */
137bf215546Sopenharmony_ci#define GBM_FORMAT_BGR888	__gbm_fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci/* 32 bpp RGB */
140bf215546Sopenharmony_ci#define GBM_FORMAT_XRGB8888	__gbm_fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */
141bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR8888	__gbm_fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */
142bf215546Sopenharmony_ci#define GBM_FORMAT_RGBX8888	__gbm_fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */
143bf215546Sopenharmony_ci#define GBM_FORMAT_BGRX8888	__gbm_fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci#define GBM_FORMAT_ARGB8888	__gbm_fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */
146bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR8888	__gbm_fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */
147bf215546Sopenharmony_ci#define GBM_FORMAT_RGBA8888	__gbm_fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */
148bf215546Sopenharmony_ci#define GBM_FORMAT_BGRA8888	__gbm_fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci#define GBM_FORMAT_XRGB2101010	__gbm_fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */
151bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR2101010	__gbm_fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */
152bf215546Sopenharmony_ci#define GBM_FORMAT_RGBX1010102	__gbm_fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */
153bf215546Sopenharmony_ci#define GBM_FORMAT_BGRX1010102	__gbm_fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_ci#define GBM_FORMAT_ARGB2101010	__gbm_fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */
156bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR2101010	__gbm_fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */
157bf215546Sopenharmony_ci#define GBM_FORMAT_RGBA1010102	__gbm_fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */
158bf215546Sopenharmony_ci#define GBM_FORMAT_BGRA1010102	__gbm_fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci/* 64 bpp RGB */
161bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR16161616	__gbm_fourcc_code('X', 'B', '4', '8') /* [63:0] x:B:G:R 16:16:16:16 little endian */
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR16161616	__gbm_fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ci/*
166bf215546Sopenharmony_ci * Floating point 64bpp RGB
167bf215546Sopenharmony_ci * IEEE 754-2008 binary16 half-precision float
168bf215546Sopenharmony_ci * [15:0] sign:exponent:mantissa 1:5:10
169bf215546Sopenharmony_ci */
170bf215546Sopenharmony_ci#define GBM_FORMAT_XBGR16161616F __gbm_fourcc_code('X', 'B', '4', 'H') /* [63:0] x:B:G:R 16:16:16:16 little endian */
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci#define GBM_FORMAT_ABGR16161616F __gbm_fourcc_code('A', 'B', '4', 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci/* packed YCbCr */
175bf215546Sopenharmony_ci#define GBM_FORMAT_YUYV		__gbm_fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
176bf215546Sopenharmony_ci#define GBM_FORMAT_YVYU		__gbm_fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
177bf215546Sopenharmony_ci#define GBM_FORMAT_UYVY		__gbm_fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
178bf215546Sopenharmony_ci#define GBM_FORMAT_VYUY		__gbm_fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
179bf215546Sopenharmony_ci
180bf215546Sopenharmony_ci#define GBM_FORMAT_AYUV		__gbm_fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ci/*
183bf215546Sopenharmony_ci * 2 plane YCbCr
184bf215546Sopenharmony_ci * index 0 = Y plane, [7:0] Y
185bf215546Sopenharmony_ci * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
186bf215546Sopenharmony_ci * or
187bf215546Sopenharmony_ci * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
188bf215546Sopenharmony_ci */
189bf215546Sopenharmony_ci#define GBM_FORMAT_NV12		__gbm_fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */
190bf215546Sopenharmony_ci#define GBM_FORMAT_NV21		__gbm_fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */
191bf215546Sopenharmony_ci#define GBM_FORMAT_NV16		__gbm_fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */
192bf215546Sopenharmony_ci#define GBM_FORMAT_NV61		__gbm_fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci/*
195bf215546Sopenharmony_ci * 3 plane YCbCr
196bf215546Sopenharmony_ci * index 0: Y plane, [7:0] Y
197bf215546Sopenharmony_ci * index 1: Cb plane, [7:0] Cb
198bf215546Sopenharmony_ci * index 2: Cr plane, [7:0] Cr
199bf215546Sopenharmony_ci * or
200bf215546Sopenharmony_ci * index 1: Cr plane, [7:0] Cr
201bf215546Sopenharmony_ci * index 2: Cb plane, [7:0] Cb
202bf215546Sopenharmony_ci */
203bf215546Sopenharmony_ci#define GBM_FORMAT_YUV410	__gbm_fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */
204bf215546Sopenharmony_ci#define GBM_FORMAT_YVU410	__gbm_fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */
205bf215546Sopenharmony_ci#define GBM_FORMAT_YUV411	__gbm_fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */
206bf215546Sopenharmony_ci#define GBM_FORMAT_YVU411	__gbm_fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */
207bf215546Sopenharmony_ci#define GBM_FORMAT_YUV420	__gbm_fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */
208bf215546Sopenharmony_ci#define GBM_FORMAT_YVU420	__gbm_fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */
209bf215546Sopenharmony_ci#define GBM_FORMAT_YUV422	__gbm_fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */
210bf215546Sopenharmony_ci#define GBM_FORMAT_YVU422	__gbm_fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */
211bf215546Sopenharmony_ci#define GBM_FORMAT_YUV444	__gbm_fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */
212bf215546Sopenharmony_ci#define GBM_FORMAT_YVU444	__gbm_fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_cistruct gbm_format_name_desc {
215bf215546Sopenharmony_ci   char name[5];
216bf215546Sopenharmony_ci};
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci/**
219bf215546Sopenharmony_ci * Flags to indicate the intended use for the buffer - these are passed into
220bf215546Sopenharmony_ci * gbm_bo_create(). The caller must set the union of all the flags that are
221bf215546Sopenharmony_ci * appropriate
222bf215546Sopenharmony_ci *
223bf215546Sopenharmony_ci * \sa Use gbm_device_is_format_supported() to check if the combination of format
224bf215546Sopenharmony_ci * and use flags are supported
225bf215546Sopenharmony_ci */
226bf215546Sopenharmony_cienum gbm_bo_flags {
227bf215546Sopenharmony_ci   /**
228bf215546Sopenharmony_ci    * Buffer is going to be presented to the screen using an API such as KMS
229bf215546Sopenharmony_ci    */
230bf215546Sopenharmony_ci   GBM_BO_USE_SCANOUT      = (1 << 0),
231bf215546Sopenharmony_ci   /**
232bf215546Sopenharmony_ci    * Buffer is going to be used as cursor
233bf215546Sopenharmony_ci    */
234bf215546Sopenharmony_ci   GBM_BO_USE_CURSOR       = (1 << 1),
235bf215546Sopenharmony_ci   /**
236bf215546Sopenharmony_ci    * Deprecated
237bf215546Sopenharmony_ci    */
238bf215546Sopenharmony_ci   GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
239bf215546Sopenharmony_ci   /**
240bf215546Sopenharmony_ci    * Buffer is to be used for rendering - for example it is going to be used
241bf215546Sopenharmony_ci    * as the storage for a color buffer
242bf215546Sopenharmony_ci    */
243bf215546Sopenharmony_ci   GBM_BO_USE_RENDERING    = (1 << 2),
244bf215546Sopenharmony_ci   /**
245bf215546Sopenharmony_ci    * Buffer can be used for gbm_bo_write.  This is guaranteed to work
246bf215546Sopenharmony_ci    * with GBM_BO_USE_CURSOR, but may not work for other combinations.
247bf215546Sopenharmony_ci    */
248bf215546Sopenharmony_ci   GBM_BO_USE_WRITE    = (1 << 3),
249bf215546Sopenharmony_ci   /**
250bf215546Sopenharmony_ci    * Buffer is linear, i.e. not tiled.
251bf215546Sopenharmony_ci    */
252bf215546Sopenharmony_ci   GBM_BO_USE_LINEAR = (1 << 4),
253bf215546Sopenharmony_ci   /**
254bf215546Sopenharmony_ci    * Buffer is protected, i.e. encrypted and not readable by CPU or any
255bf215546Sopenharmony_ci    * other non-secure / non-trusted components nor by non-trusted OpenGL,
256bf215546Sopenharmony_ci    * OpenCL, and Vulkan applications.
257bf215546Sopenharmony_ci    */
258bf215546Sopenharmony_ci   GBM_BO_USE_PROTECTED = (1 << 5),
259bf215546Sopenharmony_ci};
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ciint
262bf215546Sopenharmony_cigbm_device_get_fd(struct gbm_device *gbm);
263bf215546Sopenharmony_ci
264bf215546Sopenharmony_ciconst char *
265bf215546Sopenharmony_cigbm_device_get_backend_name(struct gbm_device *gbm);
266bf215546Sopenharmony_ci
267bf215546Sopenharmony_ciint
268bf215546Sopenharmony_cigbm_device_is_format_supported(struct gbm_device *gbm,
269bf215546Sopenharmony_ci                               uint32_t format, uint32_t flags);
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ciint
272bf215546Sopenharmony_cigbm_device_get_format_modifier_plane_count(struct gbm_device *gbm,
273bf215546Sopenharmony_ci                                           uint32_t format,
274bf215546Sopenharmony_ci                                           uint64_t modifier);
275bf215546Sopenharmony_ci
276bf215546Sopenharmony_civoid
277bf215546Sopenharmony_cigbm_device_destroy(struct gbm_device *gbm);
278bf215546Sopenharmony_ci
279bf215546Sopenharmony_cistruct gbm_device *
280bf215546Sopenharmony_cigbm_create_device(int fd);
281bf215546Sopenharmony_ci
282bf215546Sopenharmony_cistruct gbm_bo *
283bf215546Sopenharmony_cigbm_bo_create(struct gbm_device *gbm,
284bf215546Sopenharmony_ci              uint32_t width, uint32_t height,
285bf215546Sopenharmony_ci              uint32_t format, uint32_t flags);
286bf215546Sopenharmony_ci
287bf215546Sopenharmony_cistruct gbm_bo *
288bf215546Sopenharmony_cigbm_bo_create_with_modifiers(struct gbm_device *gbm,
289bf215546Sopenharmony_ci                             uint32_t width, uint32_t height,
290bf215546Sopenharmony_ci                             uint32_t format,
291bf215546Sopenharmony_ci                             const uint64_t *modifiers,
292bf215546Sopenharmony_ci                             const unsigned int count);
293bf215546Sopenharmony_ci
294bf215546Sopenharmony_cistruct gbm_bo *
295bf215546Sopenharmony_cigbm_bo_create_with_modifiers2(struct gbm_device *gbm,
296bf215546Sopenharmony_ci                              uint32_t width, uint32_t height,
297bf215546Sopenharmony_ci                              uint32_t format,
298bf215546Sopenharmony_ci                              const uint64_t *modifiers,
299bf215546Sopenharmony_ci                              const unsigned int count,
300bf215546Sopenharmony_ci                              uint32_t flags);
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ci#define GBM_BO_IMPORT_WL_BUFFER         0x5501
303bf215546Sopenharmony_ci#define GBM_BO_IMPORT_EGL_IMAGE         0x5502
304bf215546Sopenharmony_ci#define GBM_BO_IMPORT_FD                0x5503
305bf215546Sopenharmony_ci#define GBM_BO_IMPORT_FD_MODIFIER       0x5504
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_cistruct gbm_import_fd_data {
308bf215546Sopenharmony_ci   int fd;
309bf215546Sopenharmony_ci   uint32_t width;
310bf215546Sopenharmony_ci   uint32_t height;
311bf215546Sopenharmony_ci   uint32_t stride;
312bf215546Sopenharmony_ci   uint32_t format;
313bf215546Sopenharmony_ci};
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_ci#define GBM_MAX_PLANES 4
316bf215546Sopenharmony_ci
317bf215546Sopenharmony_cistruct gbm_import_fd_modifier_data {
318bf215546Sopenharmony_ci   uint32_t width;
319bf215546Sopenharmony_ci   uint32_t height;
320bf215546Sopenharmony_ci   uint32_t format;
321bf215546Sopenharmony_ci   uint32_t num_fds;
322bf215546Sopenharmony_ci   int fds[GBM_MAX_PLANES];
323bf215546Sopenharmony_ci   int strides[GBM_MAX_PLANES];
324bf215546Sopenharmony_ci   int offsets[GBM_MAX_PLANES];
325bf215546Sopenharmony_ci   uint64_t modifier;
326bf215546Sopenharmony_ci};
327bf215546Sopenharmony_ci
328bf215546Sopenharmony_cistruct gbm_bo *
329bf215546Sopenharmony_cigbm_bo_import(struct gbm_device *gbm, uint32_t type,
330bf215546Sopenharmony_ci              void *buffer, uint32_t flags);
331bf215546Sopenharmony_ci
332bf215546Sopenharmony_ci/**
333bf215546Sopenharmony_ci * Flags to indicate the type of mapping for the buffer - these are
334bf215546Sopenharmony_ci * passed into gbm_bo_map(). The caller must set the union of all the
335bf215546Sopenharmony_ci * flags that are appropriate.
336bf215546Sopenharmony_ci *
337bf215546Sopenharmony_ci * These flags are independent of the GBM_BO_USE_* creation flags. However,
338bf215546Sopenharmony_ci * mapping the buffer may require copying to/from a staging buffer.
339bf215546Sopenharmony_ci *
340bf215546Sopenharmony_ci * See also: pipe_map_flags
341bf215546Sopenharmony_ci */
342bf215546Sopenharmony_cienum gbm_bo_transfer_flags {
343bf215546Sopenharmony_ci   /**
344bf215546Sopenharmony_ci    * Buffer contents read back (or accessed directly) at transfer
345bf215546Sopenharmony_ci    * create time.
346bf215546Sopenharmony_ci    */
347bf215546Sopenharmony_ci   GBM_BO_TRANSFER_READ       = (1 << 0),
348bf215546Sopenharmony_ci   /**
349bf215546Sopenharmony_ci    * Buffer contents will be written back at unmap time
350bf215546Sopenharmony_ci    * (or modified as a result of being accessed directly).
351bf215546Sopenharmony_ci    */
352bf215546Sopenharmony_ci   GBM_BO_TRANSFER_WRITE      = (1 << 1),
353bf215546Sopenharmony_ci   /**
354bf215546Sopenharmony_ci    * Read/modify/write
355bf215546Sopenharmony_ci    */
356bf215546Sopenharmony_ci   GBM_BO_TRANSFER_READ_WRITE = (GBM_BO_TRANSFER_READ | GBM_BO_TRANSFER_WRITE),
357bf215546Sopenharmony_ci};
358bf215546Sopenharmony_ci
359bf215546Sopenharmony_civoid *
360bf215546Sopenharmony_cigbm_bo_map(struct gbm_bo *bo,
361bf215546Sopenharmony_ci           uint32_t x, uint32_t y, uint32_t width, uint32_t height,
362bf215546Sopenharmony_ci           uint32_t flags, uint32_t *stride, void **map_data);
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_civoid
365bf215546Sopenharmony_cigbm_bo_unmap(struct gbm_bo *bo, void *map_data);
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_ciuint32_t
368bf215546Sopenharmony_cigbm_bo_get_width(struct gbm_bo *bo);
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_ciuint32_t
371bf215546Sopenharmony_cigbm_bo_get_height(struct gbm_bo *bo);
372bf215546Sopenharmony_ci
373bf215546Sopenharmony_ciuint32_t
374bf215546Sopenharmony_cigbm_bo_get_stride(struct gbm_bo *bo);
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_ciuint32_t
377bf215546Sopenharmony_cigbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane);
378bf215546Sopenharmony_ci
379bf215546Sopenharmony_ciuint32_t
380bf215546Sopenharmony_cigbm_bo_get_format(struct gbm_bo *bo);
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_ciuint32_t
383bf215546Sopenharmony_cigbm_bo_get_bpp(struct gbm_bo *bo);
384bf215546Sopenharmony_ci
385bf215546Sopenharmony_ciuint32_t
386bf215546Sopenharmony_cigbm_bo_get_offset(struct gbm_bo *bo, int plane);
387bf215546Sopenharmony_ci
388bf215546Sopenharmony_cistruct gbm_device *
389bf215546Sopenharmony_cigbm_bo_get_device(struct gbm_bo *bo);
390bf215546Sopenharmony_ci
391bf215546Sopenharmony_ciunion gbm_bo_handle
392bf215546Sopenharmony_cigbm_bo_get_handle(struct gbm_bo *bo);
393bf215546Sopenharmony_ci
394bf215546Sopenharmony_ciint
395bf215546Sopenharmony_cigbm_bo_get_fd(struct gbm_bo *bo);
396bf215546Sopenharmony_ci
397bf215546Sopenharmony_ciuint64_t
398bf215546Sopenharmony_cigbm_bo_get_modifier(struct gbm_bo *bo);
399bf215546Sopenharmony_ci
400bf215546Sopenharmony_ciint
401bf215546Sopenharmony_cigbm_bo_get_plane_count(struct gbm_bo *bo);
402bf215546Sopenharmony_ci
403bf215546Sopenharmony_ciunion gbm_bo_handle
404bf215546Sopenharmony_cigbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane);
405bf215546Sopenharmony_ci
406bf215546Sopenharmony_ciint
407bf215546Sopenharmony_cigbm_bo_get_fd_for_plane(struct gbm_bo *bo, int plane);
408bf215546Sopenharmony_ci
409bf215546Sopenharmony_ciint
410bf215546Sopenharmony_cigbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
411bf215546Sopenharmony_ci
412bf215546Sopenharmony_civoid
413bf215546Sopenharmony_cigbm_bo_set_user_data(struct gbm_bo *bo, void *data,
414bf215546Sopenharmony_ci		     void (*destroy_user_data)(struct gbm_bo *, void *));
415bf215546Sopenharmony_ci
416bf215546Sopenharmony_civoid *
417bf215546Sopenharmony_cigbm_bo_get_user_data(struct gbm_bo *bo);
418bf215546Sopenharmony_ci
419bf215546Sopenharmony_civoid
420bf215546Sopenharmony_cigbm_bo_destroy(struct gbm_bo *bo);
421bf215546Sopenharmony_ci
422bf215546Sopenharmony_cistruct gbm_surface *
423bf215546Sopenharmony_cigbm_surface_create(struct gbm_device *gbm,
424bf215546Sopenharmony_ci                   uint32_t width, uint32_t height,
425bf215546Sopenharmony_ci		   uint32_t format, uint32_t flags);
426bf215546Sopenharmony_ci
427bf215546Sopenharmony_cistruct gbm_surface *
428bf215546Sopenharmony_cigbm_surface_create_with_modifiers(struct gbm_device *gbm,
429bf215546Sopenharmony_ci                                  uint32_t width, uint32_t height,
430bf215546Sopenharmony_ci                                  uint32_t format,
431bf215546Sopenharmony_ci                                  const uint64_t *modifiers,
432bf215546Sopenharmony_ci                                  const unsigned int count);
433bf215546Sopenharmony_ci
434bf215546Sopenharmony_cistruct gbm_surface *
435bf215546Sopenharmony_cigbm_surface_create_with_modifiers2(struct gbm_device *gbm,
436bf215546Sopenharmony_ci                                   uint32_t width, uint32_t height,
437bf215546Sopenharmony_ci                                   uint32_t format,
438bf215546Sopenharmony_ci                                   const uint64_t *modifiers,
439bf215546Sopenharmony_ci                                   const unsigned int count,
440bf215546Sopenharmony_ci                                   uint32_t flags);
441bf215546Sopenharmony_ci
442bf215546Sopenharmony_cistruct gbm_bo *
443bf215546Sopenharmony_cigbm_surface_lock_front_buffer(struct gbm_surface *surface);
444bf215546Sopenharmony_ci
445bf215546Sopenharmony_civoid
446bf215546Sopenharmony_cigbm_surface_release_buffer(struct gbm_surface *surface, struct gbm_bo *bo);
447bf215546Sopenharmony_ci
448bf215546Sopenharmony_ciint
449bf215546Sopenharmony_cigbm_surface_has_free_buffers(struct gbm_surface *surface);
450bf215546Sopenharmony_ci
451bf215546Sopenharmony_civoid
452bf215546Sopenharmony_cigbm_surface_destroy(struct gbm_surface *surface);
453bf215546Sopenharmony_ci
454bf215546Sopenharmony_cichar *
455bf215546Sopenharmony_cigbm_format_get_name(uint32_t gbm_format, struct gbm_format_name_desc *desc);
456bf215546Sopenharmony_ci
457bf215546Sopenharmony_ci#ifdef __cplusplus
458bf215546Sopenharmony_ci}
459bf215546Sopenharmony_ci#endif
460bf215546Sopenharmony_ci
461bf215546Sopenharmony_ci#endif
462