gralloc: list supported metadata types
Add function to get the metadata types supported by IMapper. In future releases, we will add more standard types but upgrading devices may not support those types. This function will allow the framework to identify which metadata types the device supports. Bug: 141632767 Test: VtsHalGraphicsMapperV4_0TargetTest Change-Id: I760cf054d2b6f08a52ad70f4ae60a39a63500939
This commit is contained in:
parent
88d87faec9
commit
0001a5d5ba
2 changed files with 108 additions and 0 deletions
|
@ -515,5 +515,43 @@ interface IMapper {
|
|||
MetadataType metadataType)
|
||||
generates (Error error,
|
||||
vec<uint8_t> metadata);
|
||||
|
||||
struct MetadataTypeDescription {
|
||||
MetadataType metadataType;
|
||||
/**
|
||||
* description should contain a string representation of the MetadataType.
|
||||
*
|
||||
* For example: "MyExampleMetadataType is a 64-bit timestamp in nanoseconds
|
||||
* that indicates when a buffer is decoded. It is set by the media HAL after
|
||||
* a buffer is decoded. It is used by the display HAL for hardware
|
||||
* synchronization".
|
||||
*
|
||||
* This field is required for any non-StandardMetadataTypes.
|
||||
*/
|
||||
string description;
|
||||
/**
|
||||
* isGettable represents if the MetadataType can be get.
|
||||
*/
|
||||
bool isGettable;
|
||||
/**
|
||||
* isSettable represents if the MetadataType can be set.
|
||||
*/
|
||||
bool isSettable;
|
||||
};
|
||||
|
||||
/**
|
||||
* Lists all the MetadataTypes supported by IMapper as well as a description
|
||||
* of each supported MetadataType. For StandardMetadataTypes, the description
|
||||
* string can be left empty.
|
||||
*
|
||||
* @return error Error status of the call, which may be
|
||||
* - `NONE` upon success.
|
||||
* - `NO_RESOURCES` if the get cannot be fullfilled due to unavailability of
|
||||
* resources.
|
||||
* @return descriptions Vector of MetadataTypeDescriptions that represent the
|
||||
* MetadataTypes supported by the device.
|
||||
*/
|
||||
listSupportedMetadataTypes()
|
||||
generates (Error error, vec<MetadataTypeDescription> descriptions);
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ using aidl::android::hardware::graphics::common::Dataspace;
|
|||
using aidl::android::hardware::graphics::common::ExtendableType;
|
||||
using aidl::android::hardware::graphics::common::PlaneLayout;
|
||||
using aidl::android::hardware::graphics::common::PlaneLayoutComponent;
|
||||
using aidl::android::hardware::graphics::common::StandardMetadataType;
|
||||
|
||||
using DecodeFunction = std::function<void(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
const hidl_vec<uint8_t>& vec)>;
|
||||
|
@ -162,6 +163,27 @@ class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
|
||||
std::unique_ptr<Gralloc> mGralloc;
|
||||
IMapper::BufferDescriptorInfo mDummyDescriptorInfo{};
|
||||
static const std::set<StandardMetadataType> sRequiredMetadataTypes;
|
||||
};
|
||||
|
||||
const std::set<StandardMetadataType> GraphicsMapperHidlTest::sRequiredMetadataTypes{
|
||||
StandardMetadataType::BUFFER_ID,
|
||||
StandardMetadataType::NAME,
|
||||
StandardMetadataType::WIDTH,
|
||||
StandardMetadataType::HEIGHT,
|
||||
StandardMetadataType::LAYER_COUNT,
|
||||
StandardMetadataType::PIXEL_FORMAT_REQUESTED,
|
||||
StandardMetadataType::PIXEL_FORMAT_FOURCC,
|
||||
StandardMetadataType::PIXEL_FORMAT_MODIFIER,
|
||||
StandardMetadataType::USAGE,
|
||||
StandardMetadataType::ALLOCATION_SIZE,
|
||||
StandardMetadataType::PROTECTED_CONTENT,
|
||||
StandardMetadataType::COMPRESSION,
|
||||
StandardMetadataType::INTERLACED,
|
||||
StandardMetadataType::CHROMA_SITING,
|
||||
StandardMetadataType::PLANE_LAYOUTS,
|
||||
StandardMetadataType::DATASPACE,
|
||||
StandardMetadataType::BLEND_MODE,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1591,6 +1613,54 @@ TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUnsupportedStandardMet
|
|||
ASSERT_EQ(0, vec.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::listSupportedMetadataTypes()
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, ListSupportedMetadataTypes) {
|
||||
hidl_vec<IMapper::MetadataTypeDescription> descriptions;
|
||||
mGralloc->getMapper()->listSupportedMetadataTypes(
|
||||
[&](const auto& tmpError, const auto& tmpDescriptions) {
|
||||
ASSERT_EQ(Error::NONE, tmpError);
|
||||
descriptions = tmpDescriptions;
|
||||
});
|
||||
|
||||
std::set<StandardMetadataType> foundMetadataTypes;
|
||||
|
||||
std::set<StandardMetadataType> notSettableMetadataTypes{
|
||||
StandardMetadataType::BUFFER_ID, StandardMetadataType::NAME,
|
||||
StandardMetadataType::WIDTH, StandardMetadataType::HEIGHT,
|
||||
StandardMetadataType::LAYER_COUNT, StandardMetadataType::PIXEL_FORMAT_REQUESTED,
|
||||
StandardMetadataType::USAGE};
|
||||
|
||||
ASSERT_LE(sRequiredMetadataTypes.size(), descriptions.size());
|
||||
|
||||
for (const auto& description : descriptions) {
|
||||
const auto& metadataType = description.metadataType;
|
||||
|
||||
if (!gralloc4::isStandardMetadataType(metadataType)) {
|
||||
EXPECT_GT(0, description.description.size());
|
||||
continue;
|
||||
}
|
||||
|
||||
StandardMetadataType type = gralloc4::getStandardMetadataTypeValue(metadataType);
|
||||
|
||||
if (sRequiredMetadataTypes.find(type) == sRequiredMetadataTypes.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT_EQ(foundMetadataTypes.find(type), foundMetadataTypes.end());
|
||||
foundMetadataTypes.insert(type);
|
||||
|
||||
ASSERT_TRUE(description.isGettable);
|
||||
|
||||
if (notSettableMetadataTypes.find(type) != notSettableMetadataTypes.end()) {
|
||||
ASSERT_FALSE(description.isSettable);
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(sRequiredMetadataTypes, foundMetadataTypes);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace vts
|
||||
} // namespace V4_0
|
||||
|
|
Loading…
Reference in a new issue