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