1 #pragma once 2 3 #include <aidl/android/hardware/graphics/common/StandardMetadataType.h> 4 #include <gralloctypes/Gralloc4.h> 5 6 #include <cstdint> 7 #include <limits> 8 9 namespace pixel::graphics { 10 11 constexpr const char* kGralloc4StandardMetadataTypeName = GRALLOC4_STANDARD_METADATA_TYPE; 12 constexpr const char* kPixelMetadataTypeName = "android.hardware.graphics.common.PixelMetadataType"; 13 14 using StandardMetadataType = aidl::android::hardware::graphics::common::StandardMetadataType; 15 16 #define MapMetadataType(f) f = static_cast<uint64_t>(StandardMetadataType::f) 17 18 // This seemingly clashes with MetadataType in Mapper, but this enum represents just the "value" 19 // member of that struct. MetadataType comprises of a metadata name and value. Name is just there to 20 // identify what kind of metadata it is. So, for all StandardMetadataType, clients need to use 21 // kGralloc4StandardMetadataType and for pixel specific metadata, clients should use 22 // kPixelMetadataType. 23 enum class MetadataType : int64_t { 24 MapMetadataType(INVALID), 25 MapMetadataType(BUFFER_ID), 26 MapMetadataType(NAME), 27 MapMetadataType(WIDTH), 28 MapMetadataType(HEIGHT), 29 MapMetadataType(LAYER_COUNT), 30 MapMetadataType(PIXEL_FORMAT_REQUESTED), 31 MapMetadataType(PIXEL_FORMAT_FOURCC), 32 MapMetadataType(PIXEL_FORMAT_MODIFIER), 33 MapMetadataType(USAGE), 34 MapMetadataType(ALLOCATION_SIZE), 35 MapMetadataType(PROTECTED_CONTENT), 36 MapMetadataType(COMPRESSION), 37 MapMetadataType(INTERLACED), 38 MapMetadataType(CHROMA_SITING), 39 MapMetadataType(PLANE_LAYOUTS), 40 MapMetadataType(CROP), 41 MapMetadataType(DATASPACE), 42 MapMetadataType(BLEND_MODE), 43 MapMetadataType(SMPTE2086), 44 MapMetadataType(CTA861_3), 45 MapMetadataType(SMPTE2094_40), 46 MapMetadataType(SMPTE2094_10), 47 MapMetadataType(STRIDE), 48 49 // Pixel specific metadata 50 // Make sure to use kPixelMetadataType as the name when using these metadata. 51 52 // TODO: These metadata queries returns a pointer inside metadata for now. Need to change that 53 // so we are returning proper data only. 54 // Returns: void* 55 VIDEO_HDR = std::numeric_limits<int64_t>::max() - (1 << 16), 56 57 // TODO(b/289448426#comment2): ROIINFO is probably not being used. Remove this after 58 // confirmation. 59 // Returns: void* 60 VIDEO_ROI, 61 62 // This metadata just refers to the same fd contained in buffer handle and not a clone. 63 // So the client should not attempt to close these fds. 64 // Returns: std::vector<int> 65 PLANE_DMA_BUFS, 66 67 // PLANE_LAYOUTS from gralloc reply with the actual offset of the plane from the start of the 68 // header if any. But some IPs require the offset starting from the body of a plane. 69 // Returns: std::vector<CompressedPlaneLayout> 70 COMPRESSED_PLANE_LAYOUTS, 71 72 // Ideally drivers should be using fourcc to identify an allocation, but some of the drivers 73 // depend upon the format too much that updating them will require longer time. 74 // Returns: ::pixel::graphics::Format 75 PIXEL_FORMAT_ALLOCATED, 76 77 // Returns: ::pixel::graphics::FormatType 78 FORMAT_TYPE, 79 80 // This is a experimental feature 81 VIDEO_GMV, 82 }; 83 84 struct VideoGMV { 85 int x; 86 int y; 87 }; 88 89 #undef MapMetadataType 90 91 // There is no backward compatibility guarantees, all dependencies must be built together. 92 struct CompressedPlaneLayout { 93 uint64_t header_offset_in_bytes; 94 uint64_t header_size_in_bytes; 95 uint64_t body_offset_in_bytes; 96 uint64_t body_size_in_bytes; 97 98 bool operator==(const CompressedPlaneLayout& other) const { 99 return header_offset_in_bytes == other.header_offset_in_bytes && 100 header_size_in_bytes == other.header_size_in_bytes && 101 body_offset_in_bytes == other.body_offset_in_bytes && 102 body_size_in_bytes == other.body_size_in_bytes; 103 } 104 105 bool operator!=(const CompressedPlaneLayout& other) const { return !(*this == other); } 106 }; 107 108 } // namespace pixel::graphics 109