From bfe9dad37f72757d887ae184d70823fafbf5c71c Mon Sep 17 00:00:00 2001
From: Guillaume La Roque <glaroque@baylibre.com>
Date: Mon, 20 Jan 2025 16:38:24 +0100
Subject: [PATCH] v4l2: remove all decoder/encoder not supported

Actually HAL register support of VP8/VP9 and some secure codec but we
don't support it actually.

Remove declaration of decoder/encoder for unsupported codec and remove
all variable and check link to this codec.

Fix VTS test :
VtsHalMediaC2V1_0TargetMasterTest/PerInstance/Codec2MasterHalTest#ListComponents/0_default
VtsHalMediaC2V1_0TargetMasterTest/PerInstance/Codec2MasterHalTest#ListComponents/1_software
VtsHalMediaC2V1_0TargetComponentTest

Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
---
 v4l2/V4L2ComponentCommon.cpp                  | 30 +++++--------------
 v4l2/V4L2ComponentStore.cpp                   | 13 --------
 .../v4l2_codec2/v4l2/V4L2ComponentCommon.h    |  8 -----
 3 files changed, 7 insertions(+), 44 deletions(-)

diff --git a/v4l2/V4L2ComponentCommon.cpp b/v4l2/V4L2ComponentCommon.cpp
index 9520341..305e70c 100644
--- a/v4l2/V4L2ComponentCommon.cpp
+++ b/v4l2/V4L2ComponentCommon.cpp
@@ -13,39 +13,29 @@
 namespace android {
 
 const std::string V4L2ComponentName::kH264Encoder = "c2.v4l2.avc.encoder";
-const std::string V4L2ComponentName::kVP8Encoder = "c2.v4l2.vp8.encoder";
-const std::string V4L2ComponentName::kVP9Encoder = "c2.v4l2.vp9.encoder";
 
 const std::string V4L2ComponentName::kH264Decoder = "c2.v4l2.avc.decoder";
-const std::string V4L2ComponentName::kVP8Decoder = "c2.v4l2.vp8.decoder";
-const std::string V4L2ComponentName::kVP9Decoder = "c2.v4l2.vp9.decoder";
 const std::string V4L2ComponentName::kHEVCDecoder = "c2.v4l2.hevc.decoder";
-const std::string V4L2ComponentName::kH264SecureDecoder = "c2.v4l2.avc.decoder.secure";
-const std::string V4L2ComponentName::kVP8SecureDecoder = "c2.v4l2.vp8.decoder.secure";
-const std::string V4L2ComponentName::kVP9SecureDecoder = "c2.v4l2.vp9.decoder.secure";
-const std::string V4L2ComponentName::kHEVCSecureDecoder = "c2.v4l2.hevc.decoder.secure";
 
 // static
 bool V4L2ComponentName::isValid(const std::string& name) {
-    return name == kH264Encoder || name == kVP8Encoder || name == kVP9Encoder ||
-           name == kH264Decoder || name == kVP8Decoder || name == kVP9Decoder ||
-           name == kHEVCDecoder || name == kH264SecureDecoder || name == kVP8SecureDecoder ||
-           name == kVP9SecureDecoder || name == kHEVCSecureDecoder;
+    return name == kH264Encoder ||
+           name == kH264Decoder ||
+           name == kHEVCDecoder ;
 }
 
 // static
 bool V4L2ComponentName::isEncoder(const std::string& name) {
     ALOG_ASSERT(isValid(name));
 
-    return name == kH264Encoder || name == kVP8Encoder || name == kVP9Encoder;
+    return name == kH264Encoder;
 }
 
 // static
 bool V4L2ComponentName::isDecoder(const std::string& name) {
     ALOG_ASSERT(isValid(name));
     static const std::set<std::string> kValidDecoders = {
-            kH264Decoder, kH264SecureDecoder, kVP8Decoder,  kVP8SecureDecoder,
-            kVP9Decoder,  kVP9SecureDecoder,  kHEVCDecoder, kHEVCSecureDecoder,
+            kH264Decoder,  kHEVCDecoder,
     };
 
     return kValidDecoders.find(name) != kValidDecoders.end();
@@ -55,16 +45,10 @@ bool V4L2ComponentName::isDecoder(const std::string& name) {
 std::optional<VideoCodec> V4L2ComponentName::getCodec(const std::string& name) {
     ALOG_ASSERT(isValid(name));
     static const std::map<std::string, VideoCodec> kNameToCodecs = {
-            {kH264Decoder, VideoCodec::H264}, {kH264SecureDecoder, VideoCodec::H264},
+            {kH264Decoder, VideoCodec::H264},
             {kH264Encoder, VideoCodec::H264},
 
-            {kVP8Decoder, VideoCodec::VP8},   {kVP8SecureDecoder, VideoCodec::VP8},
-            {kVP8Encoder, VideoCodec::VP8},
-
-            {kVP9Decoder, VideoCodec::VP9},   {kVP9SecureDecoder, VideoCodec::VP9},
-            {kVP9Encoder, VideoCodec::VP9},
-
-            {kHEVCDecoder, VideoCodec::HEVC}, {kHEVCSecureDecoder, VideoCodec::HEVC},
+            {kHEVCDecoder, VideoCodec::HEVC},
     };
 
     auto iter = kNameToCodecs.find(name);
diff --git a/v4l2/V4L2ComponentStore.cpp b/v4l2/V4L2ComponentStore.cpp
index 927a4c0..a189622 100644
--- a/v4l2/V4L2ComponentStore.cpp
+++ b/v4l2/V4L2ComponentStore.cpp
@@ -38,25 +38,12 @@ std::shared_ptr<C2ComponentStore> V4L2ComponentStore::Create() {
 
     builder.encoder(V4L2ComponentName::kH264Encoder, VideoCodec::H264,
                     &V4L2ComponentFactory::create);
-    builder.encoder(V4L2ComponentName::kVP8Encoder, VideoCodec::VP8, &V4L2ComponentFactory::create);
-    builder.encoder(V4L2ComponentName::kVP9Encoder, VideoCodec::VP9, &V4L2ComponentFactory::create);
 
     builder.decoder(V4L2ComponentName::kH264Decoder, VideoCodec::H264,
                     &V4L2ComponentFactory::create);
-    builder.decoder(V4L2ComponentName::kVP8Decoder, VideoCodec::VP8, &V4L2ComponentFactory::create);
-    builder.decoder(V4L2ComponentName::kVP9Decoder, VideoCodec::VP9, &V4L2ComponentFactory::create);
     builder.decoder(V4L2ComponentName::kHEVCDecoder, VideoCodec::HEVC,
                     &V4L2ComponentFactory::create);
 
-    builder.decoder(V4L2ComponentName::kH264SecureDecoder, VideoCodec::H264,
-                    &V4L2ComponentFactory::create);
-    builder.decoder(V4L2ComponentName::kVP8SecureDecoder, VideoCodec::VP8,
-                    &V4L2ComponentFactory::create);
-    builder.decoder(V4L2ComponentName::kVP9SecureDecoder, VideoCodec::VP9,
-                    &V4L2ComponentFactory::create);
-    builder.decoder(V4L2ComponentName::kHEVCSecureDecoder, VideoCodec::HEVC,
-                    &V4L2ComponentFactory::create);
-
     store = std::shared_ptr<C2ComponentStore>(std::move(builder).build());
     platformStore = store;
     return store;
diff --git a/v4l2/include/v4l2_codec2/v4l2/V4L2ComponentCommon.h b/v4l2/include/v4l2_codec2/v4l2/V4L2ComponentCommon.h
index 7a9e36a..c06e30f 100644
--- a/v4l2/include/v4l2_codec2/v4l2/V4L2ComponentCommon.h
+++ b/v4l2/include/v4l2_codec2/v4l2/V4L2ComponentCommon.h
@@ -14,17 +14,9 @@ namespace android {
 // Defines the names of all supported components.
 struct V4L2ComponentName {
     static const std::string kH264Encoder;
-    static const std::string kVP8Encoder;
-    static const std::string kVP9Encoder;
 
     static const std::string kH264Decoder;
-    static const std::string kVP8Decoder;
-    static const std::string kVP9Decoder;
     static const std::string kHEVCDecoder;
-    static const std::string kH264SecureDecoder;
-    static const std::string kVP8SecureDecoder;
-    static const std::string kVP9SecureDecoder;
-    static const std::string kHEVCSecureDecoder;
 
     // Return true if |name| is a valid component name.
     static bool isValid(const std::string& name);
-- 
GitLab