(1)源码
//vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/common/v1/HalSensorList.buildStaticInfo.cpp
MBOOL
HalSensorList::
buildStaticInfo(Info const& rInfo, IMetadata& rMetadata) const
{
SensorStaticInfo *pSensorStaticInfo = &sensorStaticInfo[rInfo.getDeviceId()];
MUINT8 u8Para = 0;
if (!impBuildStaticInfo(rInfo, rMetadata))
{
MY_LOGE(
"Fail to build static info for %s index:%d type:%d",
rInfo.getSensorDrvName().string(), rInfo.getDeviceId(), rInfo.getSensorType()
);
//return MFALSE;
}
lbLoadDone:
/*METEDATA Ref //system/media/camera/docs/docs.html*/
//using full size
{
IMetadata::IEntry entryA(MTK_SENSOR_INFO_ACTIVE_ARRAY_REGION);
MRect region1(MPoint(pSensorStaticInfo->SensorGrabStartX_CAP,pSensorStaticInfo->SensorGrabStartY_CAP), MSize(pSensorStaticInfo->captureWidth,pSensorStaticInfo->captureHeight));
entryA.push_back(region1, Type2Type<MRect>());
rMetadata.update(MTK_SENSOR_INFO_ACTIVE_ARRAY_REGION, entryA);
MY_LOGD("MTK_SENSOR_INFO_ACTIVE_ARRAY_REGION(%d, %d, %d, %d)", pSensorStaticInfo->SensorGrabStartX_CAP, pSensorStaticInfo->SensorGrabStartY_CAP,
pSensorStaticInfo->captureWidth, pSensorStaticInfo->captureHeight);
}
//using full size(No correction)
{
IMetadata::IEntry entryA(MTK_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE);
entryA.push_back(pSensorStaticInfo->SensorGrabStartX_CAP, Type2Type<MINT32>());
entryA.push_back(pSensorStaticInfo->SensorGrabStartY_CAP, Type2Type<MINT32>());
entryA.push_back(pSensorStaticInfo->captureWidth, Type2Type<MINT32>());
entryA.push_back(pSensorStaticInfo->captureHeight, Type2Type<MINT32>());
rMetadata.update(MTK_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, entryA);
MY_LOGD("MTK_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE(%d, %d, %d, %d)", pSensorStaticInfo->SensorGrabStartX_CAP, pSensorStaticInfo->SensorGrabStartY_CAP,
pSensorStaticInfo->captureWidth, pSensorStaticInfo->captureHeight);
}
//Pixel arry
{
SensorDrv *const pSensorDrv = SensorDrv::get();
MUINT32 scenario = MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG; /*capture mode*/
SensorCropWinInfo rSensorCropInfo;
::memset(&rSensorCropInfo, 0, sizeof(SensorCropWinInfo));
pSensorDrv->sendCommand((IMGSENSOR_SENSOR_IDX) rInfo.getDeviceId(),
CMD_SENSOR_GET_SENSOR_CROP_WIN_INFO,
(MUINTPTR)&scenario,
(MUINTPTR)&rSensorCropInfo,
0);
//(1)这里可以更新sensor pixel array size
IMetadata::IEntry entryA(MTK_SENSOR_INFO_PIXEL_ARRAY_SIZE);
+ if(rSensorCropInfo.full_w == 1600 && rSensorCropInfo.full_h == 1200){
+ rSensorCropInfo.full_w = 1640;
+ rSensorCropInfo.full_h = 1230;
+ }
MSize Size1(rSensorCropInfo.full_w, rSensorCropInfo.full_h);
entryA.push_back(Size1, Type2Type<MSize>());
rMetadata.update(MTK_SENSOR_INFO_PIXEL_ARRAY_SIZE, entryA);
}
//Color filter
{
IMetadata::IEntry entryA(MTK_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT);
switch(pSensorStaticInfo->sensorFormatOrder) {
case SENSOR_FORMAT_ORDER_RAW_B:
u8Para = 0x3;//BGGR
break;
case SENSOR_FORMAT_ORDER_RAW_Gb:
u8Para = 0x2;//GBRG
break;
case SENSOR_FORMAT_ORDER_RAW_Gr:
u8Para = 0x1;//GRBG
break;
case SENSOR_FORMAT_ORDER_RAW_R:
u8Para = 0x0;//RGGB
break;
default:
u8Para = 0x4;//BGR not bayer
break;
}
entryA.push_back(u8Para, Type2Type<MUINT8>());
rMetadata.update(MTK_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, entryA);
}
//Orientation
{
//(2)更新MTK_SENSOR_INFO_ORIENTATION
IMetadata::IEntry entryA(MTK_SENSOR_INFO_ORIENTATION);
entryA.push_back((MINT32)pSensorStaticInfo->orientationAngle, Type2Type<MINT32>());
rMetadata.update(MTK_SENSOR_INFO_ORIENTATION, entryA);
// IMetadata::IEntry entryB(MTK_SENSOR_INFO_WANTED_ORIENTATION);
// entryB.push_back((MINT32)pSensorStaticInfo->orientationAngle, Type2Type<MINT32>());
// rMetadata.update(MTK_SENSOR_INFO_WANTED_ORIENTATION, entryB);
}
//AOSP Orientation & Facing
{
//(3)更新MTK_SENSOR_ORIENTATION
IMetadata::IEntry entryA(MTK_SENSOR_ORIENTATION);
entryA.push_back((MINT32)pSensorStaticInfo->orientationAngle, Type2Type<MINT32>());
rMetadata.update(MTK_SENSOR_ORIENTATION, entryA);
//(4)更新MTK_LENS_FACING信息
IMetadata::IEntry entryB(MTK_LENS_FACING);
if ( pSensorStaticInfo->facingDirection==0 )
entryB.push_back(MTK_LENS_FACING_BACK, Type2Type<MUINT8>());
else
entryB.push_back(MTK_LENS_FACING_FRONT, Type2Type<MUINT8>());
rMetadata.update(MTK_LENS_FACING, entryB);
}
//Sensor manual add tag list
{
IMetadata::IEntry entryA(MTK_MULTI_CAM_FEATURE_SENSOR_MANUAL_UPDATED);
entryA.push_back((MINT64)MTK_SENSOR_INFO_ACTIVE_ARRAY_REGION, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_INFO_PIXEL_ARRAY_SIZE, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_INFO_ORIENTATION, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_INFO_WANTED_ORIENTATION, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_SENSOR_ORIENTATION, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_LENS_FACING, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_CONTROL_AF_AVAILABLE_MODES, Type2Type<MINT64>());
entryA.push_back((MINT64)MTK_CONTROL_MAX_REGIONS, Type2Type<MINT64>());
rMetadata.update(MTK_MULTI_CAM_FEATURE_SENSOR_MANUAL_UPDATED, entryA);
}
rMetadata.sort();
return MTRUE;
}
以上信息可以在运行的过程中来更新Metadata的值,比如可以参考这篇文章的使用CTS测试中testAvailableStreamConfigs[1]项。