• MTK Camera自定义Vendor Tag


    (1)Vendor Tag Structure

    Google用一个 VendorTagSection 来描述一个 VendorTag,sectionName必须以供应商名称命名,例
    如"com.mediatek.control.capture"。注意必须以 com 等开头,否则 CTS 测试会 Failed。

    //hardware/interfaces/camera/common/1.0/types.hal
    
    struct VendorTagSection {
        string sectionName; // Section name; must be namespaced within vendor's name
        vec<VendorTag> tags; // List of tags in this section
    };
    
    /**
     * A single vendor-unique metadata tag.
     * The full name of the tag is .
     */
    struct VendorTag {
        uint32_t tagId; // Tag identifier, must be >= TagBoundaryId::VENDOR
        string tagName; // Name of tag, not including section name
        CameraMetadataType tagType;
    };
    
    enum CameraMetadataType : uint32_t {
        // Unsigned 8-bit integer (uint8_t)
        BYTE = 0,
        // Signed 32-bit integer (int32_t)
        INT32 = 1,
        // 32-bit float (float)
        FLOAT = 2,
        // Signed 64-bit integer (int64_t)
        INT64 = 3,
        // 64-bit float (double)
        DOUBLE = 4,
        // A 64-bit fraction (camera_metadata_rational_t)
        RATIONAL = 5
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    在这里插入图片描述
    (2)How to add vendor tag

    涉及的代码路径如下:

    /vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag.h
    /vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag_info.inl
    
    /vendor/mediatek/proprietary/hardware/mtkcam/utils/metadata/vendortag/VendorTagTable.h
    
    • 1
    • 2
    • 3
    • 4

    添加 request 阶段的 control vendor tag(Eg:com.mediatek.control.capture.flipmode)

    (A)在 mtk_metadata_tag.h 中的 mtk_camera_metadata_section 中定义 vendor tag 所属的 section
    ID,需要定义在 MTK_VENDOR_TAG_SECTION 之后,如MTK_CONTROL_CAPTURE。

    //vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag.h
    
    typedef enum mtk_camera_metadata_section {
    	//...
    
    	//vendor tag
        MTK_VENDOR_TAG_SECTION          = 0x8000,
        MTK_FACE_FEATURE                = 0,
        MTK_NR_FEATURE                  = 1,
        MTK_STEREO_FEATURE              = 2,
        MTK_HDR_FEATURE                 = 3,
        MTK_MFNR_FEATURE                = 4,
        MTK_CSHOT_FEATURE               = 5,
        MTK_3A_FEATURE                  = 6,
        MTK_EIS_FEATURE                 = 7,
        MTK_STREAMING_FEATURE           = 8,
        MTK_VSDOF_FEATURE               = 9,
        MTK_MULTI_CAM_FEATURE           = 10,
        MTK_CONTROL_CAPTURE             = 11,	//MTK_CONTROL_CAPTURE
        MTK_BGSERVICE_FEATURE           = 12,
        MTK_CONFIGURE_SETTING           = 13,
        MTK_FLASH_FEATURE               = 14,
        MTK_SMVR_FEATURE                = 15,
        MTK_SINGLEHW_SETTING            = 16,
        MTK_ABF_FEATURE                 = 17,
        MTK_TRACKINGAF_FEATURE          = 18,
        MTK_AOVSERVICE_FEATURE          = 19,
        MTK_MDPTZ_FEATURE               = 20,
    
    	//...
    } mtk_camera_metadata_section_t;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31

    (B) 在 mtk_metadata_tag.h 中的 mtk_camera_metadata_section_start 中定义 vendor tag 所属的
    section 的起始 ID,如MTK_CONTROL_CAPTURE_START。

    //vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag.h
    
    typedef enum mtk_camera_metadata_section_start {
    	//...
    
    	MTK_STREAMING_FEATURE_START                 = (MTK_STREAMING_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
        MTK_VSDOF_FEATURE_START                     = (MTK_VSDOF_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
        MTK_MULTI_CAM_FEATURE_START                 = (MTK_MULTI_CAM_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
        MTK_CONTROL_CAPTURE_START                   = (MTK_CONTROL_CAPTURE + MTK_VENDOR_TAG_SECTION) << 16,	//MTK_CONTROL_CAPTURE_START
        MTK_BGSERVICE_FEATURE_START                 = (MTK_BGSERVICE_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
        MTK_CONFIGURE_SETTING_START                 = (MTK_CONFIGURE_SETTING + MTK_VENDOR_TAG_SECTION) << 16,
        MTK_FLASH_FEATURE_START                     = (MTK_FLASH_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
    
    	//...
    } mtk_camera_metadata_section_start_t;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    (C)在 mtk_metadata_tag.h 中的 mtk_camera_metadata_tag 中定义 vendor tag 的 ID,如MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE。

    如果需要再定义一个可以与 MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE 归为同一个Section的Tag,则可以忽略第 1、2 步,直接在后面添加 vendor tag,如MTK_CONTROL_CAPTURE_POSTVIEW_SIZE,MTK_CONTROL_CAPTURE_ZSL_MODE等,最后在加上一个End tag(MTK_CONTROL_CAPTURE_END)。

    //vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag.h
    
    typedef enum mtk_camera_metadata_tag {
    	//...
    
    	 MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_SUPPORT  = MTK_CONTROL_CAPTURE_START,
        MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_TRIGGER,
        MTK_CONTROL_CAPTURE_NEXT_READY,
        MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE,	//MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE
        MTK_CONTROL_CAPTURE_AVAILABLE_POSTVIEW_MODES,
        MTK_CONTROL_CAPTURE_POSTVIEW_SIZE,	//MTK_CONTROL_CAPTURE_POSTVIEW_SIZE
        MTK_CONTROL_CAPTURE_REMOSAIC_EN,
        MTK_CONTROL_CAPTURE_SEAMLESS_REMOSAIC_EN,
        MTK_CONTROL_CAPTURE_AVAILABLE_ZSL_MODES, 
        MTK_CONTROL_CAPTURE_DEFAULT_ZSL_MODE,
        MTK_CONTROL_CAPTURE_ZSL_MODE,	//MTK_CONTROL_CAPTURE_ZSL_MODE
    
    	//...
    	MTK_CONTROL_CAPTURE_END,
    }mtk_camera_metadata_tag_t
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    (D)在 mtk_metadata_tag_info.inl 文件中定义vendor tag的类型与 tag name。如下所示,tag name 是 flipmode,value类型是MINT32。

    //vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag_info.inl
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_SUPPORT,
                    MINT32,     "early.notification.support")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_TRIGGER,
                    MINT32,     "early.notification.trigger")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_NEXT_READY,
                    MINT32,     "next.ready")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE,		//MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE
                    MINT32,     "flipmode")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_POSTVIEW_SIZE,
                    MSize,      "postviewsize")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_AVAILABLE_ZSL_MODES,
                    MUINT8,     "availableZslModes")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_DEFAULT_ZSL_MODE,
                    MUINT8,     "defaultZslMode")
    
    _IMP_TAG_INFO_( MTK_CONTROL_CAPTURE_ZSL_MODE,
                    MUINT8,     "zslMode")
    
    //...
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    (E)在 VendorTagTable.h 文件中定义 section name 以及这一 SECTION 包含的 vendor tag。
    如下所示,section name 是"com.mediatek.control.capture",包含了从 MTK_CONTROL_CAPTURE_START至MTK_CONTROL_CAPTURE_END间的vendor tag。

    //vendor/mediatek/proprietary/hardware/mtkcam/utils/metadata/vendortag/VendorTagTable.h
    
    static auto& _ControlCapture_()
    {
        static const std::map<uint32_t, VendorTag_t>
        sInst = {
    			_TAG_(MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_SUPPORT,
                "early.notification.support",    TYPE_INT32),
            _TAG_(MTK_CONTROL_CAPTURE_EARLY_NOTIFICATION_TRIGGER,
                "early.notification.trigger",    TYPE_INT32),
            _TAG_(MTK_CONTROL_CAPTURE_NEXT_READY,
                "next.ready",    TYPE_INT32),
            _TAG_(MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE,		//MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE
                "flipmode",     TYPE_INT32),
            _TAG_(MTK_CONTROL_CAPTURE_AVAILABLE_POSTVIEW_MODES,
                "availablepostviewmodes",    TYPE_INT32),
            _TAG_(MTK_CONTROL_CAPTURE_POSTVIEW_SIZE,
                "postviewsize",    TYPE_INT32),
    		_TAG_(MTK_CONTROL_CAPTURE_AVAILABLE_ZSL_MODES,
                "available.zsl.modes",    TYPE_BYTE),
            _TAG_(MTK_CONTROL_CAPTURE_DEFAULT_ZSL_MODE,
                "default.zsl.mode",    TYPE_BYTE),
            _TAG_(MTK_CONTROL_CAPTURE_ZSL_MODE,
                "zsl.mode",    TYPE_BYTE),
    
    		//...
        };
        return sInst;
    }
    
    static auto& getGlobalSections()
    {
    		static std::vector<VendorTagSection_t>
       		sMTKSections = {
       		
       					_SECTION_( "com.mediatek.control.capture",
                        MTK_CONTROL_CAPTURE_START,
                        MTK_CONTROL_CAPTURE_END,
                        _ControlCapture_() ),
    
    					//...
       		}
    		return sGlobalSections;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44

    然后,通过_ControlCapture_将section name 与 tag name绑定起来,一个完整的vendor tag ID 是 MTK_CONTROL_CAPTURE_JPEG_FLIP_MODE,value 类型是 MINT32,即:

    name = section name + tag name = com.mediatek.control.capture + flipmode

    (3)App当中如何使用Vendor Tag

    (A)水印WaterMark

    CaptureRequest.Key<int[]> mWaterMarkValue =  new CaptureRequest.Key<int[]>("com.mediatek.control.capture.hctHalWatermakr", int[].class);
    
    private static final int[] HAL_WATERMARK_VALUE = new int[]{0};
    
    if(Config.HalWaterMarkSupport()){
                if(WATERMARK_ON.equals(mWaterMark.getValue())){
                    HAL_WATERMARK_VALUE[0] = 1;
                }else{
                    HAL_WATERMARK_VALUE[0] = 0;
                }
                captureBuilder.set(mWaterMarkValue, HAL_WATERMARK_VALUE);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    (B)Mirror效果

    private static final String FLIP_KEY_MODE_REQUEST = "com.mediatek.control.capture.flipmode";
    private CaptureRequest.Key<int[]> mKeyFlipMode;
    
    List<CaptureRequest.Key<?>> requestKeyList = cs.getAvailableCaptureRequestKeys();
            for (CaptureRequest.Key<?> requestKey : requestKeyList) {
            		if (requestKey.getName().equals(FLIP_KEY_MODE_REQUEST)){
                    		mKeyFlipMode = (CaptureRequest.Key<int[]>) requestKey;
    				}
            }
    
    if (value != null && captureBuilder != null) {
                int[] mode = new int[1];
                mode[0] = Integer.parseInt(value);
                captureBuilder.set(mKeyFlipMode, mode);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
  • 相关阅读:
    Flink1.15源码解析--启动脚本----start-cluster.sh
    数字信号处理-2-三角函数与谱
    tars 常用类用法总结一
    通信流程:https【SSL/TLS】,git仓库【https/SSH】,蓝牙【面对面快传/AirDrop】
    mac 环境docker占用空间清除
    PHICOMM(斐讯)N1盒子 - recovery模式救砖卡登录页LOGO卡1%卡4%卡26%
    如何注册一个 DA 为 10 的高价值老域名
    java计算机毕业设计海康物流MyBatis+系统+LW文档+源码+调试部署
    【概率论与数理统计】
    【项目】 基于BOOST的站内搜索引擎
  • 原文地址:https://blog.csdn.net/dongxianfei/article/details/126058896