Camera API2/HAL3的核心为per-frame control,为了达成这个目标产生了metadata的机制.metadata一共分为三类;
Control(request):
当APK query出static metadata后,可以从中作总结想要的控制
Dynamic(result):
当Hal层收到control metadata后,设定进ISP最终产生对应的结果
Static(charateristics):
描述此logcial device的规格与提供的功能
Camera static metadata再camerahalserver进程驱动就会进行加载,再onEnumerateDevicesLocked中会去分别加载相关的static_metadata;主要就是分为两类
auto CameraDeviceManagerImpl::
onEnumerateDevicesLocked() -> android::status_t{
...
sizet const deviceNum = pHalDeviceList->searchDevices();//加载sensor&3A相关的 static metadata
pMetadataProvider = IMetadataProvider::create(instance);//加载其他的static metadata
}
vendor/mediatek/proprietary/hardware/mtkcam/utils/LogicalCam/HalLogicalDeviceList.cpp searchDevices
vendor/mediatek/proprietary/hardware/mtkcam/utils/LogicalCam/HalLogicalDeviceList.cpp createDeviceMap
vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/common/v1_1/HalSensorList.cpp searchSensors
HalSensorList::EnumInfo const*
HalSensorList::
addAndInitSensorEnumInof_Locked(
IMGSENSOR_SENSOR_IDX eSensorDev,
MUINT eSensorType,
char *szSensorDrvName){
...
buildStaticInfo(rEnumInfo,rEnumInfo.mMetadata);
...
}
最终会通过addSensorMetadata()->buildStaticInfo()从camera metadata配置文件加载sensor与3A相关的static metadata或者自动生成特定的static metadata。在Android Q中首先会通过impBuildStaticInfo_v1这一路进行加载,然后回调用impBuildStaticInfo兼容Android P,加载自动生成的metadata,最后调用impBuildStaticInfo_v1_overwrite,加载需要强制复写的metadata,如下
MBOOL
HalSensorList::
buildStaticInfo(Info const& rInfo, IMetadata& rMetadata) const
{
if( !impBuildStaticInfo_v1(rInfo, rMetadata) ) //加载Android Q架构的metadata
if( !impBuildStaticInfo(rInfo, rMetadata)) //兼容加载Android P架构的metadata
//Sensor manual add tag_list //加载自动产生的metadata
IMetadata::IEntry entryA(MTK_MULTI_CAM_FEAUTRE_SENSOR_MANULA_UPDATED);
entryA.push_back((MINT64)MTK_SENSOR_INFO_ACTIVE_ARRAT_REGION, Type2Type<MUINT64>());
impBuildStaticInfo_v1_overwrite(rInfo, rMetadata);//提供强制修改metadata的接口
}
Android Q的加载类型主要有
static
char const*const
kCommonStaticMetadataNames[] = {
// MODULE
"CAMERA",
"CONTROL_AE",
"CONTROL_AF",
"CONTROL_AWB",
"TUNNING",
"FLASHLIGHT",
"SENSOR",
"LENS",
// // PROJECT
// "AVAILABLE_KEYS",
// "FEATURE",
// "MULTICAM",
// "REQUEST",
// "SCALER",
// "VENDOR",
NULL
};
static
char const* const
kPlatformStaticMetadataNames[] =
{
"MODULE",
"LENS",
// "MOD_OVERWRITE"
// "PROJECT",
// // "PRO_OVERWRITE"
NULL
};
impBuildStaticInfo()兼容Android P架构,加载的是Android P类型的metadata,主要类型是
static
char const* const
kStaticMetadataTypeNames[] =
{
"LENS",
"SENSOR",
"TUNNING_3A",
"FLASHLIGHT",
"SCALER",
"FEATURE",
"CAMERA",
"REQUEST",
NULL
};
impBuildStaticInfo_v1_overwrite提供强制修改metadata的接口,加载的类型是[MOD_OVERWRITE]
static
char const* const
kPlatformOverwriteStaticMetadataNames[] =
{
// "MODULE"
// "LENS",
"MOD_OVERWRITE",
// "PROJECT",
// // "PRO_OVERWRITE"
NULL
};
以impBuildStaticInfo为例,介绍加载类型是如何对应上配置中的metadata
static
MBOOL
impBuildStaticInfo(
Info const& rInfo,
IMetadata& rMetadata ){
...
String8 const s8Symbol_Sensor = String8::format("%s_DEVICE_%s_%s", PREFIX_FUNCTION_STATIC_METADATA,
pTypeName, rInfo.getSensorDrvName().string());
status = impConstructStaticMetadata_by_SymbolName(s8Symbol_sensor, rInfo, rMetadata);
String8 const s8Symbol_Common = String8::format("%s_DEVICE_%s_%s", PREFIX_FUNCTION_STATIC_METADATA,
pTypeName, "COMMON");
status = impConstructStaticMetadata_by_SymbolName(s8Symbol_Common , rInfo, rMetadata);
}
上面部分使用类型等参数从camera metadata配置文件中找到对应文件中的函数指针进行加载,
String8::format("%s_DEVICE_%s_%s", PREFIX_FUNCTION_STATIC_METADATA, pTypeName, rInfo.getSensorDrvName().string());
以LENS类型为例,pTypeName = “LENS”, rInfo.getSensorDevName表示sensorName,
对应的函数指针即
STATIC_METADATA2_BEGIN(DEVICE,LENS,SENSOR_DRVNAME_IMX135_MIPI_RAW),
对应加载的配置文件即
config_static_metadata.lens.imx135mipiraw.h
HalSensorList.cpp加载sensor与3A的metadata,主要就是通过impConstructStaticMetadata_by_SymbolName函数去open对应的so库,这里是"libcam.halsensor.so"
MBOOL
impConstructStaticMetadata_by_SymbolName(
String8 const& s8Symbol,
Info const& rInfo,
IMetadata& rMetadata){
...
Sting8 const s8LibPath = String8::format("libcam.halsensor.so");
void *handle = ::dlopen(s8LibPath.string(), RTLD_GLOBAL);
}
metadata文件的命令主要有三种,
“config_request_metadata_*.h”、" config_static_metadata_ *. h"、“config_static_metadata. * .h”;
libcam.halsensor.so默认会加载libcam.halsensor.custom.a这个static lib,而这个static lib加载的则是"config_static_metadata.*.h"类型的文件;类似
config_static_metadata.lens.imx135mipiraw.h
config_static_metadata.project.camera.imx135mipiraw.h
config_static_metadata.project.flashlight.imx135mipiraw.h
config_static_metadata.sensor.imx135mipiraw.h等
vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/mtxxx/custom/Android.mk
#define my-all-config.sensor-metadata-under
$(patsubst ./%,%, \
$(shell find $(1) -maxdepth 4 \( -name "config_static_metadata.*.h") \) -and -not -name ".*") \
)
#endef
上述说到除了生成libcam.halsensor.custom.a类型的metadata,还剩下"config_request_metadata_* .h"、" config_static_metadata_ * . h"两类;其他类型的主要是指" config_static_ metadata_ * . h"
status_t
MetadataProvider::
onCreate()
{
...
status = (mVersion==0)?
constructStaticMetadata(pMetadataConverter, mpStaticCharacteristics, mpHALMetadata):
constructStaticMetadata_v1(pMetadataConverter, mpStaticCharacteristics, mpHALMetadata);
}
constructStaticMetadata是Android P的加载流程,Android Q开始默认走的是constructStaticMetadata_v1这一路函数,同加载Sensor与3A metadata一样,这类同样会调用到impConstructStaticMetadata_v1进行配置文件中的static metadata记载,再updata(mtkMetadata)中会自动生成特定的metadata;
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/metadataprovider/constructStaticMetadata.cpp
impConstrucStaticMetadata_by_SymbolName会去加载so库,constructStaticMetadata.cpp加载的默认路径的so,这里加载的时libmtkcam_metastore.so;
status_t
MetadataProvider::
impConstructStaticMetadata_by_SymbolName(
String8 const& s8Symbol,
IMetadata &metadata){
typedef status_t (*PFN_T)(
IMetadata & metadata,
Info const& info);
PFN_T pfn = (PFN_T)::dlsym(RTKD_DEFAULT, s8Symbol.string());
}
libmtkcam_metastore.so加载了libmtkcam_metastore.static.custom.a,默认会加载"config_static_metadata_*.h"类型,类似
config_static_metadata_feature.h
config_static_metadata_request_commonType.h
config_static_metadata_scaler.h
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/metadataprovider/custom/Android.mk
#define my-all-config.metadata-under
$(patsubst ./%,%, \
$(shell if [ 0d $(1) ]; then find $(1) -maxdepth 4 \( name 'config_static_metadata_*.h' \) -and -not -name '.*'; fi) \
)
impConstructStaticMetadata_v1()也保留了向前兼容Android P版本的metadata配置,在metadata配置中可以直接按Android P的结构进行配置,这部分加载的类型主要是
static
char const*const
kCommonStaticMetadataNames[] =
{
// // MODULE
// "CAMERA",
// "CONTROL_AE",
// "CONTROL_AF",
// "CONTROL_AWB",
// "TUNNING",
// "FLASHLIGHT",
// "SENSOR",
// "LENS",
// PROJECT
"AVAILABLE_KEYS",
"AVAILABLE_KEYS_VENDOR",
"AVAILABLE_KEYS_CUSTOM",
"FEAUTRE",
"MULTICAM",
"REQUEST",
"SCALER",
"VENDOR",
"CUSTOM",
NULL
};
static
char const*const
kPlatformStaticMetadataNames[] =
{
// "MODULE",
// "LENS",
// // "MOD_OVERWRITE"
"PROJECT",
// "PRO_OVERWRITE"
NULL
};
加载的是可选的平台相关的配置,对应的加载类型是
static
char const* const
kPlatformOptionalStaticMetadataNames[] =
{
"AVAILABLE_KEYS",
"VENDOR",
"CUSTOM",
NULL
};
如上,最后还剩下"config_request_metadata_* .h"类型的static metadata ;
当APK调用CameraDevice.createCaptureRequest(eg:CameraDevice.TEMPLATE_PREVIEW),会触发RequestTempalte的加载过程,通过HIDL接口调用到CameraDevice3SessionImpl.cpp中的constructDefaultRequestSettings()方法并创建TemplateRequest实例
vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/device/CameraDevice3SessionImpl.cpp
Return<void>
ThisNamespace::
constructDefaultRequestSettings(RequestTemplate type, constructDefaultRequestSettings_cb_hidl_cb)
{
ITemplateRequest* obj = NSTemplateRequestManager::valueFor(getInstanceId());
if (obj == nullptr){
obj = ITemplateRequest::getInstance(getInstanceID());
NSTemplateRequestManager::add(getInstanceId(),obj);
}
CameraMetadata metadata;
{
camera_metadata const* p_camera_metadata = obj->getData(static_cast<int>(type));
}
}
在ITemplateRequest的getIstance方法中会进行Template.onCreate()的创建动作,紧着调用constructRequsetMetadata加载TempalteRequest还是与之前一样,impConstructRequestMetadata()加载的时配置文件中的TemplateRequest信息,updata()是自动生成的TemplateRequest信息
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/templateRequest/TemplateRequest.cpp
TemplateRequest::
constuctRequestMetadata(
int const requestType,
camera_metadata*& rpMetadata,
IMetadata& rMtkMetadata){
MY_LOGD("constructRequestMetadata");
//-----(1)-----//
if( OK != (status = impConstructRequestMetadata(rMtkMetadata, rquestType)) ){
MY_LOGE("Unable evaluate the size for camera staic info -status[%s(%d)]\n",::strerror(-status), -status);
return status;
}
//-----(2)-----/
//overwrite
updateData(rMtkMetadata);
}
RequestTemplate类型:
CAMERA3_TEMPLATE_PREVIEW
CAMERA3_TEMPLATE_STILL_CAPTURE
CAMERA3_TEMPLATE_VIDEO_RECORD
CAMERA3_TEMPLATE_VIDEO_SNAPSHOT
CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG
impConstructRequestMetadata加载的是默认的搜索路径的so们这里加载的是libmtkcam_metastore.so,这个动态库会加载libmtkcam_metastore.requset.custom.a,它会从metadata配置中加载名为"config_request_metadata_*.h"类型的文件,主要是
config_request_metadata_.h
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/templateRequest/custom/Android.mk
#define my-all-config.metadata-under
$(patsubst ./%,%, \
$(shell if [ 0d $(1) ]; then find $(1) -maxdepth 4 \( name 'config_request_metadata_*.h' \) -and -not -name '.*'; fi) \
)
Android Q上通过COMMON_HIERARCHY这个宏开关控制走Android Q的Flow,在Andorid Q架构上PLATFORM目录与PROJECT目录一般不妨REQUEST TEMPLATE数据
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/templateRequest/custom/TempalteRequest.cpp
#ifdef COMMON_HIERARCHY
//
int32_t result = 0;
{
String8 const s8Symbol_Common = String8::format("%s_COMMON_%s", PREFIX_FUNCTION_REQUEST_METADATA, "COMMON");
status = impConstructRequestMetadata_by_SymbolName(s8Symbol_Common, metadata, requestType);
if( !status ) result|=COMMON_COMMON;
String8 const s8Symbol_Sensor = String8::format("%s_COMMON_%s", PREFIX_FUNCTION_REQUEST_METADATA, nInfo.getSensorDrvName());
status = impConstructRequestMetadata_by_SymbolName(s8Symbol_Sensor , metadata, requestType);
if( !status ) result|=COMMON_SENSOR;
}
//
{
String8 const s8Symbol_Common = String8::format("%s_DEVICE_%s", PREFIX_FUNCTION_REQUEST_METADATA, "DEFAULT");
status = impConstructRequestMetadata_by_SymbolName(s8Symbol_Common, metadata, requestType);
if( !status ) result|=PLATFORM_COMMON;
String8 const s8Symbol_Sensor = String8::format("%s_DEVICE_%s", PREFIX_FUNCTION_REQUEST_METADATA, nInfo.getSensorDrvName());
status = impConstructRequestMetadata_by_SymbolName(s8Symbol_Sensor , metadata, requestType);
if( !status ) result|=PLATFORM_SENSOR;
}
//
{
String8 const s8Symbol_Sensor = String8::format("%s_PROJECT_%s", PREFIX_FUNCTION_REQUEST_METADATA, nInfo.getSensorDrvName());
status = impConstructRequestMetadata_by_SymbolName(s8Symbol_Sensor , metadata, requestType);
if( !status ) result|=PROJECT_SENSOR;
}
META_LOGD("%s: load status(0x%x)", "TemplateRequest", result);
(O - > Android 8 P - > Andorid 9 Q - > Android 10, R - > Android 11)
Android Q版本加载的metadata配置文件路径如下图:
Android 会先加载COMMON,再加载PLATFORM目录下的metadata,再加载PROJECT目录。Project目前很少用到;后面加载的会覆盖前面加载的metadata或者前面加载的metadata基础上追加
Path | Priority | |
---|---|---|
PROJECT | CUSTOM\$(PROJECT)\hal\imgsensor_metadata\common [PROJECT_COMMON] CUSTOM\$(PROJECT)\hal\imgsensor_metadata\imx_mipi_raw [PROJECT_SENSOR] |
High |
PLATFORM | CUSTOM\$(PROJECT)\hal\imgsensor_metadata\common [PALTFORM_COMMON] CUSTOM\$(PROJECT)\hal\imgsensor_metadata\imx_mipi_raw [PALTFORM_SENSOR] |
Mid |
PROJECT | CUSTOM\$(PROJECT)\hal\imgsensor_metadata\common [COMMON_COMMON] CUSTOM\$(PROJECT)\hal\imgsensor_metadata\imx_mipi_raw [COMMON_SENSOR] |
Low |
在同级目录下的加载顺序则为先COMMON目录,紧接着是PLATFORM目录,最后是PROJECT目录,对于某些tag,并不希望直接覆盖前面已经加载的tag对应的Metadata,那么则需要使用APPEND_METADATA_BEGIN/APPEND_METADATA_END接口。如在PLATFORM_SENSOR目录下希望增加MTK_REQUSET_AVAILABLE_REQUEST_KEYS中的key,如果直接使用CONFIG_METADATA_BEGIN/CONFIG_METADATA_END接口,就会直接覆盖COMMON_COMMOM中的config_static_metadata_availableKey.h加载的所有MTK_REQUEST_AVAILABLE_REQUEST_KEYS,最终可能只剩下PLATFORM_SENSOR中增加的这一个。
该目录结构如下图,主要配置TemplateRequest,以及所有平添通用的3A或者metadta配置,该文件夹会最先被加载
vendor/mediatek/proprietary/custom/common/hal/imgsensor_metadata/common/
config_request_metadata_.h
config_static_metadata.ae.h
config_static_metadata.af.h
config_static_metadata.awb.h
config_static_metadata.camera.h
config_static_metadata.flashlight.h
config_static_metadata.tunning.h
config_static_metadata_availableKeys.h
config_static_metadata_custom.h
config_static_metadata_feature.h
config_static_metadata_multicam.h
config_static_metadata_request.h
config_static_metadata_scaler.h
config_static_metadata_vendor.h
//config_request_metadata_.h:配置 Template Request, android.*/com.mediatek.*
config_static_metadata.ae.h:配置CONTROL_AE类型的Metadata,第一个参数COMMON和最后一个参数COMMON表示
位于COMMON-COMMON目录下(后面都参考此规则),第二个参数表示类型;
android.control.ae*
STATIC_METADATA_BEGIN(COMMON, CONTROL_AE, COMMON)
//--------------------------------------------
//android.control.ae*
//--------------------------------------------
android.control.af*
STATIC_METADATA_BEGIN(COMMON, CONTROL_AF, COMMON)
//--------------------------------------------
//android.control.af*
//--------------------------------------------
该目录结构如下,主要配置的是特定sensor相关的信息,所有平台都通用的camera sensor属性
vendor/mediatek/proprietary/custom/common/hal/imgsensor_metadata/sensor/imx_mipi_raw
config_static_metadata.sensor.imxmipiraw.h
该目录下的文件结构如下所示,以DEVICE开头的都是Android P的Metadata加载方式,只有按照Android Q的方式没有加载到数据时才会使用
vendor/mediatek/proprietary/custom/mt6761/hal/imgsensor_metadata/common/
config_static_metadata.lens.h
config_static_metadata.project.flashlight.h
config_static_metadata.sensor.h
config_static_metadata.tunning_3a.h
config_static_metadata_common.h
config_static_metadata_feature.h
config_static_metadata_project.h
config_static_metadata_request_commonType.h
config_static_metadata_scaler.h
config_static_metadata_project.h 配置PROJECT类型的Metadata,位于PLAFTOFMR目录下目前存放了
PLATFORM通用的stream configuration
STATIC_METADATA2_BEGIN(PLATFORM, PROJECT, DEFAULT)
//--------------------------------------------
//android.requset
文件结构如下,该目录配置的时Platform中Camera Sensor特有的camera metadata配置
size=4>vendor/mediatek/proprietary/custom/mt6761/hal/imgsensor_metadata/imx_mipi_raw/
config_static_metadata.lens.imxmipiraw.h
config_static_metadata.module.imxmipiraw.h
config_static_metadata_availableKeys.h
config_static_metadata_custom.h
config_static_metadata_project.h
config_static_metadata_vendor.h
config_static_metadata_availableKeys.h 配置的是AVAILABLE_KEYS类型的Metadata,可以在这里添加自定义的Vendor Tag(sensor 特有的)
STATIC_METADATA2_BEGIN(PLATFORM, AVAILABLE_KEYS, SENSOR_DRVNAME_IMX_MIPI_RAW)
//--------------------------------------------
//android.requset
config_static_metadata_custom.h 配置的是CUSTOMER类型的Metadata,可以在这里添加自定义的Metadata(sensor特有的): com.xxx.*
STATIC_METADATA2_BEGIN(PLATFORM, CUSTOM, SENSOR_DRVNAME_IMX_MIPI_RAW)
//--------------------------------------------
//com.xxx.*
config_static_metadata_project.h 配置的是PROJECT类型的Metadata,可以在这里添加Stream Configuration
STATIC_METADATA2_BEGIN(PLATFORM, PROJECT, SENSOR_DRVNAME_IMX_MIPI_RAW)
//--------------------------------------------
//android.requset
config_static_metadata_vendor.h 配置的是VENDOR类型的Metadata,目前用于MTK 的Vendor Tag
HAL_PIXEL_FORMAT_BLOB表示Picture-size,必须是16 align,最大必须填到跟sensor的szie小于3%的差距,宽高比位标准4:3或16:9
HAL_PIXEL_FORMAT_YCbCr_420_888用于preview、video size,只要配置了YCbCr_420_888 output,同时需要配置相同的BLOB size,HAL_PIXEL_FORMAT_YCbCr_420_888的input config用于支持yuv-reporcessing
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED则是用于private-reporcessing,仅用于input配置,不需要output,反而回引起问题
HAL_PIXEL_FORMAT_RAW16 只需要填一組output config, size同sensor size,支持拍raw图
若是有支援reprocessing, 则需要定义如下
CONFIG_METADATA_BEGIN(MTK_REPROCESS_MAX_CAPTURE_STALL)
CONFIG_ENTRY_VALUE(2 , MINT32)
CONFIG_METADATA_END()
CONFIG_ENTRY_VALUE(HAL_PIXEL_FORMAT_YCbCr_420_888, MINT64)
CONFIG_ENTRY_VALUE(4608, MINT64)
CONFIG_ENTRY_VALUE(3456, MINT64)
CONFIG_ENTRY_VALUE(MTK_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, MINT64)
CONFIG_ENTRY_VALUE(66666666, MINT64)
CONFIG_ENTRY_VALUE(0, MINT64) //CTS testStreamConfigurationMap
min frame duration 表示size streaming出的情況下, frame 与 frame之间的最短duration
stall duration 表示size因为后处理所要付出的额外时间 (例如jpeg的encode)
min frame duration 影响rrzo的大小,影响p1的出图规则(正常rrzo要小于picture size)(p1→p2 p2a 将raw图转yuv)
mtkcam3/pipeline/policy/config/mtkcam-P1HwSettingPolicy configP1HwSetting minDuration
mtkcam3/pipeline/policy/FeatureSettingPolicy.cpp evaluateCaptureSetting needCaptureNode
mtkcam3/pipeline/policy/requset/P2NodeDecisionPolicy.cpp decideStreamOut
sensor imgo im2go输出的都是raw图;preview只出im2go;capture两个都出(imgo 纯raw图)
P1Node负责输出raw图;P2CaptureNode主要负责拍照的frame的处理;P2StreamingNode主要负责录像预览的数据处理;
JpegNode的输入时main YUV、Thumbnail YUV及metadata,输出是Jpeg及App metadata
首先得确保再ProjectConfig.mk中 MTK_SLOW_MOTION_VIDEO_SUPPORT = yes
config_static_metadata_availablekeys.h
APPEND_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_RESULT_KEYS)//new hidden
//APPEND_ENTRY_VALUE(MTK_SMVR_FEATURE_SMVR_RESULT, MINT32)
APPEND_METADATA_END()
//==========================================================================
APPEND_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS)//new hidden
APPEND_ENTRY_VALUE(MTK_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS, MINT32)
APPEND_METADATA_END()
config_static_metadata_project.h
CONFIG_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_CAPABILITIES)//new
CONFIG_ENTRY_VALUE(MTK_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO, MUINT8)
CONFIG_METADATA_END()
//==========================================================================
CONFIG_METADATA_BEGIN(MTK_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS)//new hidden
CONFIG_ENTRY_VALUE(1920, MINT32) // width
CONFIG_ENTRY_VALUE(1080, MINT32) // height
CONFIG_ENTRY_VALUE( 30, MINT32) // fps_min
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_max
CONFIG_ENTRY_VALUE( 4, MINT32) // batch_size_max
CONFIG_ENTRY_VALUE(1920, MINT32) // width
CONFIG_ENTRY_VALUE(1080, MINT32) // height
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_min
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_max
CONFIG_ENTRY_VALUE( 4, MINT32) // batch_size_max
CONFIG_ENTRY_VALUE(1280, MINT32) // width
CONFIG_ENTRY_VALUE( 720, MINT32) // height
CONFIG_ENTRY_VALUE( 30, MINT32) // fps_min
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_max
CONFIG_ENTRY_VALUE( 4, MINT32) // batch_size_max
CONFIG_ENTRY_VALUE(1280, MINT32) // width
CONFIG_ENTRY_VALUE( 720, MINT32) // height
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_min
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_max
CONFIG_ENTRY_VALUE( 4, MINT32) // batch_size_max
CONFIG_METADATA_END()
以上是google AOSP 120fps的配置,MTK提供SMVR功能,SMVR与google AOSP不能同时配置,会导致慢动作crash,项目中有遇到前摄VTS测不过,使用原生接口有问题,后来就改成了MTK SMVR Batch Mode
SMVR(Slow Motion Video Record),MTK支持三种模式
(1) constrained high speed recording
原生支持120fps,但仅能使用与Camera2 API,并且提供了 HD 和 FHD的分辨率
(2) continuos mode with batch-frames buffer
持续模式意味着,能一直录制知道用户停止,或达到内存上限,提供了240fps 和 HD resolution
(3)burst mode with dram-buffering
(3)是(2)的一个转变,提供更好帧率的录制同时减少了录制时间,提供480fps 和 HD resolution
config_static_metadata_availablekeys.h
APPEND_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_RESULT_KEYS)//new hidden
APPEND_ENTRY_VALUE(MTK_SMVR_FEATURE_SMVR_RESULT, MINT32)
APPEND_METADATA_END()
config_static_metadata_vendor.h
CONFIG_METADATA_BEGIN(MTK_SMVR_FEATURE_AVAILABLE_SMVR_MODES)// new hidden
CONFIG_ENTRY_VALUE(1280, MINT32) // width
CONFIG_ENTRY_VALUE( 720, MINT32) // height
CONFIG_ENTRY_VALUE( 120, MINT32) // fps_max
CONFIG_ENTRY_VALUE( 4, MINT32) // p2-custom-batch-num
CONFIG_METADATA_END()
没有慢动作选项或者效果需要注意media_profiles.xml中各sensor_id的支持能力,例如
<EncoderProfile quality="highspeed720p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="17000000"
width="1280"
height="720"
frameRate="240" />
<Audio codec="aac"
bitRate="256000"
sampleRate="48000"
channels="2" />
</EncoderProfile>
无论是characteristic类型的,还是config阶段的session key 或者是 requset 阶段的control key都是需要进行如下定义的
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_BGSERVICE_FEATURE = 12,
MTK_CONFIGURE_SETTING = 13,
MTK_FLASH_FEATURE = 14,
MTK_SMVR_FEATURE = 15,
MTK_SINGLEHW_SETTING = 16,
MTK_ABF_FEATURE = 17,
MTK_CUSTOM_FEATURE = 18, //客制化
MTK_VENDOR_SECTION_COUNT,
} mtk_camera_metadata_section_t;
//客制化feature段起始地址
typedef enum mtk_camera_metadata_section_start {
...
...
MTK_SINGLEHW_SETTING_START = (MTK_SINGLEHW_SETTING + MTK_VENDOR_TAG_SECTION) << 16,
MTK_ABF_FEATURE_START = (MTK_ABF_FEATURE + MTK_VENDOR_TAG_SECTION) << 16,
MTK_CUSTOM_FEATURE_START = (MTK_CUSTOM_FEATURE + MTK_VENDOR_TAG_SECTION) << 16, //客制化
}
//客制化获取的metadata变量
typedef enum mtk_camera_metadata_tag{
...
...
MTK_CUSTOM_FEATURE_SENSOR_INFO_NAME = MTK_CUSTOM_FEATURE_START, //客制化
MTK_CUSTOM_FEATURE_END,
...
}mtk_camera_metadata_tag_t;
vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/client/mtk_metadata_tag_info.inl
_IMP_SECTION_INFO_(MTK_CUSTOM_FEATURE, "mtk.custom")
_IMP_TAG_INFO_( MTK_CUSTOM_FEATURE,
MUINT8, "mtk.custom")
...
vendor/mediatek/proprietary/hardware/mtkcam/include/mtkcam/utils/metadata/vendortag/VendorTagTable.h
static auto& _MTKCustomFeature_()
{
static const std::map<uint32_t, VendorTag_t>
sInst = {
_TAG_(MTK_CUSTOM_FEATURE,
"mtk.custom", TYPE_BYTE),
};
//
return sInst;
}
static auto& getGlobalSections()
{
static std::vector<VendorTagSection_t>
sMTKSections = {
_SECTION_( "com.mediatek.facefeature",
MTK_FACE_FEATURE_START,
MTK_FACE_FEATURE_END,
_FaceFeature_() ),
...
...
_SECTION_( "mtk.custom",
MTK_CUSTOM_FEATURE_START,
MTK_CUSTOM_FEATURE_END,
_MTKCustomFeature_() ),
};
...
}
vendor/mediatek/proprietary/cutom/mtxxx/hal/imgsensor_metadata/xxx_mipi_raw/config_static_metadata_availablekeys.h
APPEND_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_REQUEST_KEYS)
APPEND_ENTRY_VALUE(MTK_CUSTOM_FEATURE, MINT32)
APPEND_METADATA_END()
CONFIG_METADATA_BEGIN(MTK_CUSTOM_FEATURE)
CONFIG_ENTRY_VALUE(1, MINT32)
CONFIG_METADATA_END()
vendor/mediatek/proprietary/cutom/mtxxx/hal/imgsensor_metadata/xxx_mipi_raw/config_static_metadata_availablekeys.h
APPEND_METADATA_BEGIN(MTK_REQUEST_AVAILABLE_SESSION_KEYS)
APPEND_ENTRY_VALUE(MTK_CUSTOM_FEATURE, MIN32)
APPEND_METADATA_END()
或者在constructStaticMetadata.cpp去动态更新
vendor/mediatek/proprietary/hardware/mtkcam/utils/metastore/metadataprovider/constructStaticMetadata.cpp
void
MetadataProvider::
updataData(IMetadata &rMetadata)
{
updataStreamConfiguration(rMetadata);
updataRecommendedStreamConfiguration(rMetadata);
updataAfRegions(rMetadata);
...
{
IMetadata::IEntry availCharactsEntry = rMetadata.entryFor(MTK_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS);
availCharactsEntry.push_back(MTK_HDR_FEATURE_AVAILABLE_HDR_MODES_PHOTO, Type2Type<MINT32 >());
availCharactsEntry.push_back(MTK_HDR_FEATURE_AVAILABLE_HDR_MODES_VIDEO, Type2Type<MINT32 >());
availCharactsEntry.push_back(MTK_HDR_FEATURE_AVAILABLE_MSTREAM_HDR_MODES, Type2Type<MINT32 >());
rMetadata.updata(availCharactsEntry.tag(), availCharactsEntry);
}
...
IMetadata::IEntry customFeature = rMetadata.entryFor(MTK_REQUEST_AVAILABLE_SESSION_KEYS);
customFeature.push_back(MTK_CUSTOM_FEATURE, Type2Type< MINT32 >());
rMetadata.updata(customFeature.tag(), customFeature);
//session key pParsedAppConfiguration结构体
auto const& pParsedAppCfg = pPipelineUserConfiguration->pParsedAppConfiguration;
IMetadata::getEntry<MUINT8>(&pParsedAppCfg->sessionParams, MTK_CUSTOM_FEATURE, value);
//RequestPtr pRequest;
IMetadata* pAppMeta = pRequest->mIMetadataApp->acquire();
IMetadata* pHalMeta = pRequest->mIMetadataHal->acquire();
IMetadata* IMetaDynamic = pRequest->mIMetadataDynamic->acquire();
IMetadata::setEntry<MINT32>(pHalMeta, MTK_3A_ISP_BYPASS_LCE, 0);//Bypass isp module