xref: /aosp_15_r20/external/mesa3d/src/util/u_gralloc/u_gralloc_internal.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 2023 Roman Stratiienko ([email protected])
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef U_GRALLOC_INTERNAL_H
9 #define U_GRALLOC_INTERNAL_H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include "u_gralloc.h"
16 
17 struct u_gralloc_ops {
18    int (*get_buffer_basic_info)(struct u_gralloc *gralloc,
19                                 struct u_gralloc_buffer_handle *hnd,
20                                 struct u_gralloc_buffer_basic_info *out);
21    int (*get_buffer_color_info)(struct u_gralloc *gralloc,
22                                 struct u_gralloc_buffer_handle *hnd,
23                                 struct u_gralloc_buffer_color_info *out);
24    int (*get_front_rendering_usage)(struct u_gralloc *gralloc,
25                                     uint64_t *out_usage);
26    int (*destroy)(struct u_gralloc *gralloc);
27 };
28 
29 struct u_gralloc {
30    struct u_gralloc_ops ops;
31    int type;
32 };
33 
34 extern struct u_gralloc *u_gralloc_cros_api_create(void);
35 #ifdef USE_IMAPPER4_METADATA_API
36 extern struct u_gralloc *u_gralloc_imapper_api_create(void);
37 #endif
38 extern struct u_gralloc *u_gralloc_qcom_create(void);
39 extern struct u_gralloc *u_gralloc_libdrm_create(void);
40 extern struct u_gralloc *u_gralloc_fallback_create(void);
41 
42 /* Helpers for legacy grallocs */
43 struct android_ycbcr;
44 
45 bool is_hal_format_yuv(int native);
46 int get_hal_format_bpp(int native);
47 int get_fourcc_from_hal_format(int native);
48 int bufferinfo_from_ycbcr(const struct android_ycbcr *ycbcr,
49                           struct u_gralloc_buffer_handle *hnd,
50                           struct u_gralloc_buffer_basic_info *out);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif /* U_GRALLOC_INTERNAL_H */
57