OSDN Git Service

cros_gralloc: Fix logging statement format specifier am: b26e66e866
[android-x86/external-minigbm.git] / cros_gralloc / gralloc3 / CrosGralloc3Mapper.h
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 <android/hardware/graphics/mapper/3.0/IMapper.h>
8
9 #include <optional>
10
11 #include "cros_gralloc/cros_gralloc_driver.h"
12 #include "cros_gralloc/cros_gralloc_handle.h"
13
14 class CrosGralloc3Mapper : public android::hardware::graphics::mapper::V3_0::IMapper {
15   public:
16     CrosGralloc3Mapper();
17
18     android::hardware::Return<void> createDescriptor(const BufferDescriptorInfo& description,
19                                                      createDescriptor_cb hidlCb) override;
20
21     android::hardware::Return<void> importBuffer(const android::hardware::hidl_handle& rawHandle,
22                                                  importBuffer_cb hidlCb) override;
23
24     android::hardware::Return<android::hardware::graphics::mapper::V3_0::Error> freeBuffer(
25             void* rawHandle) override;
26
27     android::hardware::Return<android::hardware::graphics::mapper::V3_0::Error> validateBufferSize(
28             void* rawHandle, const BufferDescriptorInfo& descriptor, uint32_t stride) override;
29
30     android::hardware::Return<void> getTransportSize(void* rawHandle,
31                                                      getTransportSize_cb hidlCb) override;
32
33     android::hardware::Return<void> lock(void* rawHandle, uint64_t cpuUsage,
34                                          const Rect& accessRegion,
35                                          const android::hardware::hidl_handle& acquireFence,
36                                          lock_cb hidlCb) override;
37
38     android::hardware::Return<void> lockYCbCr(void* rawHandle, uint64_t cpuUsage,
39                                               const Rect& accessRegion,
40                                               const android::hardware::hidl_handle& acquireFence,
41                                               lockYCbCr_cb _hidl_cb) override;
42
43     android::hardware::Return<void> unlock(void* rawHandle, unlock_cb hidlCb) override;
44
45     android::hardware::Return<void> isSupported(const BufferDescriptorInfo& descriptor,
46                                                 isSupported_cb hidlCb) override;
47
48   private:
49     int getResolvedDrmFormat(android::hardware::graphics::common::V1_2::PixelFormat pixelFormat,
50                              uint64_t bufferUsage, uint32_t* outDrmFormat);
51
52     struct LockResult {
53         android::hardware::graphics::mapper::V3_0::Error error;
54
55         uint8_t* mapped[DRV_MAX_PLANES];
56     };
57     LockResult lockInternal(cros_gralloc_handle_t crosHandle, uint64_t cpuUsage,
58                             const Rect& accessRegion,
59                             const android::hardware::hidl_handle& acquireFence);
60
61     std::unique_ptr<cros_gralloc_driver> mDriver;
62 };
63
64 extern "C" android::hardware::graphics::mapper::V3_0::IMapper* HIDL_FETCH_IMapper(const char* name);