From 95beff230b807509caf11c737de84ee2b30ddb2a Mon Sep 17 00:00:00 2001 From: Sasha McIntosh Date: Wed, 9 Apr 2025 17:18:41 -0400 Subject: [PATCH] drm_hwcomposer: Implement setContentType in hwc3 Internal ContentType and ContentType.aidl both match the HDMI 1.4 specification exactly. Change-Id: If345a794a10c967b7fdb513f9056de39c7260678 Signed-off-by: Sasha McIntosh --- compositor/DisplayInfo.h | 5 +++-- hwc3/ComposerClient.cpp | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/compositor/DisplayInfo.h b/compositor/DisplayInfo.h index 04a4a7b..d7aef8f 100644 --- a/compositor/DisplayInfo.h +++ b/compositor/DisplayInfo.h @@ -73,9 +73,10 @@ enum PanelOrientation { }; /* - * Content type to be used for HDMI infoframes. + * Content type to be used for HDMI infoframes. Values match the HDMI 1.4 + * specification. */ -enum class ContentType { kNoData, kGraphics, kPhoto, kCinema, kGame }; +enum class ContentType : int32_t { kNoData, kGraphics, kPhoto, kCinema, kGame }; struct QueuedConfigTiming { // In order for the new config to be applied, the client must send a new frame diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp index b48b475..6bf336c 100644 --- a/hwc3/ComposerClient.cpp +++ b/hwc3/ComposerClient.cpp @@ -1361,10 +1361,19 @@ ndk::ScopedAStatus ComposerClient::setContentType(int64_t display_id, return ToBinderStatus(hwc3::Error::kBadDisplay); } - if (type == ContentType::NONE) { - return ndk::ScopedAStatus::ok(); + // ContentType.aidl and ::ContentType enum both match the HDMI 1.4 specification + // exactly. Static cast is safe. + switch (type) { + case ContentType::NONE: + case ContentType::GRAPHICS: + case ContentType::PHOTO: + case ContentType::CINEMA: + case ContentType::GAME: + display->SetContentType(static_cast<::ContentType>(type)); + return ndk::ScopedAStatus::ok(); + default: + return ToBinderStatus(hwc3::Error::kBadParameter); } - return ToBinderStatus(hwc3::Error::kUnsupported); } ndk::ScopedAStatus ComposerClient::setDisplayedContentSamplingEnabled(