1 /* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (C) 2022 Roman Stratiienko (r.stratiienko@gmail.com) 5 * SPDX-License-Identifier: MIT 6 */ 7 8 #ifndef U_GRALLOC_H 9 #define U_GRALLOC_H 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 #include <cutils/native_handle.h> 16 17 #include <stdbool.h> 18 19 #include "util/macros.h" 20 #include "GL/internal/dri_interface.h" 21 22 struct u_gralloc; 23 24 /* Both Vulkan and EGL API exposes HAL format / pixel stride which is required 25 * by the fallback implementation. 26 */ 27 struct u_gralloc_buffer_handle { 28 const native_handle_t *handle; 29 int hal_format; 30 int pixel_stride; 31 }; 32 33 struct u_gralloc_buffer_basic_info { 34 uint32_t drm_fourcc; 35 uint64_t modifier; 36 37 int num_planes; 38 int fds[4]; 39 int offsets[4]; 40 int strides[4]; 41 }; 42 43 struct u_gralloc_buffer_color_info { 44 enum __DRIYUVColorSpace yuv_color_space; 45 enum __DRISampleRange sample_range; 46 enum __DRIChromaSiting horizontal_siting; 47 enum __DRIChromaSiting vertical_siting; 48 }; 49 50 enum u_gralloc_type { 51 U_GRALLOC_TYPE_AUTO, 52 #ifdef USE_IMAPPER4_METADATA_API 53 U_GRALLOC_TYPE_GRALLOC4, 54 #endif 55 U_GRALLOC_TYPE_CROS, 56 U_GRALLOC_TYPE_FALLBACK, 57 U_GRALLOC_TYPE_COUNT, 58 }; 59 60 struct u_gralloc *u_gralloc_create(enum u_gralloc_type type); 61 62 void u_gralloc_destroy(struct u_gralloc **gralloc NONNULL); 63 64 int u_gralloc_get_buffer_basic_info( 65 struct u_gralloc *gralloc NONNULL, 66 struct u_gralloc_buffer_handle *hnd NONNULL, 67 struct u_gralloc_buffer_basic_info *out NONNULL); 68 69 int u_gralloc_get_buffer_color_info( 70 struct u_gralloc *gralloc NONNULL, 71 struct u_gralloc_buffer_handle *hnd NONNULL, 72 struct u_gralloc_buffer_color_info *out NONNULL); 73 74 int u_gralloc_get_front_rendering_usage(struct u_gralloc *gralloc NONNULL, 75 uint64_t *out_usage NONNULL); 76 77 #ifdef __cplusplus 78 } 79 #endif 80 81 #endif /* U_GRALLOC_H */ 82