xref: /aosp_15_r20/external/minigbm/cros_gralloc/gralloc4/CrosGralloc4Utils.h (revision d95af8df99a05bcb8679a54dc3ab8e5cd312b38e)
1*d95af8dfSAndroid Build Coastguard Worker /*
2*d95af8dfSAndroid Build Coastguard Worker  * Copyright 2020 The Chromium OS Authors. All rights reserved.
3*d95af8dfSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
4*d95af8dfSAndroid Build Coastguard Worker  * found in the LICENSE file.
5*d95af8dfSAndroid Build Coastguard Worker  */
6*d95af8dfSAndroid Build Coastguard Worker 
7*d95af8dfSAndroid Build Coastguard Worker #include <string>
8*d95af8dfSAndroid Build Coastguard Worker #include <vector>
9*d95af8dfSAndroid Build Coastguard Worker 
10*d95af8dfSAndroid Build Coastguard Worker #include <aidl/android/hardware/graphics/common/PlaneLayout.h>
11*d95af8dfSAndroid Build Coastguard Worker #include <android/hardware/graphics/common/1.2/types.h>
12*d95af8dfSAndroid Build Coastguard Worker #include <android/hardware/graphics/mapper/4.0/IMapper.h>
13*d95af8dfSAndroid Build Coastguard Worker #include <hidl/HidlSupport.h>
14*d95af8dfSAndroid Build Coastguard Worker 
15*d95af8dfSAndroid Build Coastguard Worker struct cros_gralloc_buffer_descriptor;
16*d95af8dfSAndroid Build Coastguard Worker 
17*d95af8dfSAndroid Build Coastguard Worker std::string getPixelFormatString(android::hardware::graphics::common::V1_2::PixelFormat format);
18*d95af8dfSAndroid Build Coastguard Worker 
19*d95af8dfSAndroid Build Coastguard Worker std::string getUsageString(
20*d95af8dfSAndroid Build Coastguard Worker         android::hardware::hidl_bitfield<android::hardware::graphics::common::V1_2::BufferUsage>
21*d95af8dfSAndroid Build Coastguard Worker                 usage);
22*d95af8dfSAndroid Build Coastguard Worker 
23*d95af8dfSAndroid Build Coastguard Worker int convertToDrmFormat(android::hardware::graphics::common::V1_2::PixelFormat format,
24*d95af8dfSAndroid Build Coastguard Worker                        uint32_t* outDrmFormat);
25*d95af8dfSAndroid Build Coastguard Worker 
26*d95af8dfSAndroid Build Coastguard Worker int convertToBufferUsage(uint64_t grallocUsage, uint64_t* outBufferUsage);
27*d95af8dfSAndroid Build Coastguard Worker 
28*d95af8dfSAndroid Build Coastguard Worker int convertToCrosDescriptor(
29*d95af8dfSAndroid Build Coastguard Worker         const android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo& descriptor,
30*d95af8dfSAndroid Build Coastguard Worker         struct cros_gralloc_buffer_descriptor* outCrosDescriptor);
31*d95af8dfSAndroid Build Coastguard Worker 
32*d95af8dfSAndroid Build Coastguard Worker int convertToMapUsage(uint64_t grallocUsage, uint32_t* outMapUsage);
33*d95af8dfSAndroid Build Coastguard Worker 
34*d95af8dfSAndroid Build Coastguard Worker int convertToFenceFd(const android::hardware::hidl_handle& fence_handle, int* out_fence_fd);
35*d95af8dfSAndroid Build Coastguard Worker 
36*d95af8dfSAndroid Build Coastguard Worker android::hardware::hidl_handle convertToFenceHandle(int fence_fd, char* native_handle_storage);
37*d95af8dfSAndroid Build Coastguard Worker 
38*d95af8dfSAndroid Build Coastguard Worker int getPlaneLayouts(
39*d95af8dfSAndroid Build Coastguard Worker         uint32_t drm_format,
40*d95af8dfSAndroid Build Coastguard Worker         std::vector<aidl::android::hardware::graphics::common::PlaneLayout>* out_layouts);
41