• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HI_GBM_H
17 #define HI_GBM_H
18 #include <stdint.h>
19 
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif
23 
24 struct gbm_device;
25 struct gbm_bo;
26 
27 enum gbm_bo_flags {
28     /* *
29      * Buffer is going to be presented to the screen using an API such as KMS
30      */
31     GBM_BO_USE_SCANOUT = (1 << 0),
32     /* *
33      * Buffer is going to be used as cursor
34      */
35     GBM_BO_USE_CURSOR = (1 << 1),
36     /* *
37      * Deprecated
38      */
39     GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR,
40     /* *
41      * Buffer is to be used for rendering - for example it is going to be used
42      * as the storage for a color buffer
43      */
44     GBM_BO_USE_RENDERING = (1 << 2),
45     /* *
46      * Deprecated
47      */
48     GBM_BO_USE_WRITE = (1 << 3),
49     /* *
50      * Buffer is guaranteed to be laid out linearly in memory. That is, the
51      * buffer is laid out as an array with 'height' blocks, each block with
52      * length 'stride'. Each stride is in the same order as the rows of the
53      * buffer. This is intended to be used with buffers that will be accessed
54      * via dma-buf mmap().
55      */
56     GBM_BO_USE_LINEAR = (1 << 4),
57     /* *
58      * The buffer will be used as a texture that will be sampled from.
59      */
60     GBM_BO_USE_TEXTURING = (1 << 5),
61     /* *
62      * The buffer will be written to by a camera subsystem.
63      */
64     GBM_BO_USE_CAMERA_WRITE = (1 << 6),
65     /* *
66      * The buffer will be read from by a camera subsystem.
67      */
68     GBM_BO_USE_CAMERA_READ = (1 << 7),
69     /* *
70      * Buffer inaccessible to unprivileged users.
71      */
72     GBM_BO_USE_PROTECTED = (1 << 8),
73     /* *
74      * These flags specify the frequency of software access. These flags do not
75      * guarantee the buffer is linear, but do guarantee gbm_bo_map(..) will
76      * present a linear view.
77      */
78     GBM_BO_USE_SW_READ_OFTEN = (1 << 9),
79     GBM_BO_USE_SW_READ_RARELY = (1 << 10),
80     GBM_BO_USE_SW_WRITE_OFTEN = (1 << 11),
81     GBM_BO_USE_SW_WRITE_RARELY = (1 << 12),
82     /* *
83      * The buffer will be written by a video decode accelerator.
84      */
85     GBM_BO_USE_HW_VIDEO_DECODER = (1 << 13),
86 };
87 
88 struct gbm_device *hdi_gbm_create_device(int fd);
89 void hdi_gbm_device_destroy(struct gbm_device *gbm);
90 struct gbm_bo *hdi_gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height,
91                                  uint32_t format, uint32_t usage);
92 uint32_t hdi_gbm_bo_get_stride(struct gbm_bo *bo);
93 uint32_t hdi_gbm_bo_get_width(struct gbm_bo *bo);
94 uint32_t hdi_gbm_bo_get_height(struct gbm_bo *bo);
95 void hdi_gbm_bo_destroy(struct gbm_bo *bo);
96 int hdi_gbm_bo_get_fd(struct gbm_bo *bo);
97 
98 #if defined(__cplusplus)
99 }
100 #endif
101 #endif // HI_GBM_H