Android Camera硬件抽象层(HAL,Hardware Abstraction Layer)主要用于把底层camera driver的实现接口进行封装,再经过算法处理,提供接口给framework连接起来。
在安卓上实现camera的功能会有这么几个流程实现,open、config、request、result、close
负责AppStreamMgr的回调
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.CallbackHandler.cpp
负责AppStreamMgr的Frame处理
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.FrameHandler.cpp
负责AppStreamMgr的Batch处理
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.BatchHandler.cpp
负责AppStreamMgr的处理请求
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.RequestHandler.cpp
负责AppStreamMgr的结果返回
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.ResultHandler.cpp
负责AppStreamMgr的Config处理
alps/vendor/mediatek/proprietary/hardware/mtkcam3/main/hal/device/3.x/app/AppStreamMgr.ConfigHandler.cpp
7、pipelineModulelmpl调用创建线程来进行open和powerOn。
在给配流过程中有两次配流
IPipelineModelSessionFactory::
createPipelineModelSession(
CreationParams const& params __unused
){
// (1) convert to UserConfiguration
auto pUserConfiguration = convertToUserConfiguration(
*params.pPipelineStaticInfo,
*params.pUserConfigurationParams
);
// (2) pipeline policy
auto pSettingPolicy = IPipelineSettingPolicyFactory::createPipelineSettingPolicy(
IPipelineSettingPolicyFactory::CreationParams{
.pPipelineStaticInfo = params.pPipelineStaticInfo,
.pPipelineUserConfiguration = pUserConfiguration,
});
// (3) pipeline session
auto pSession = decidePipelineModelSession(params, pUserConfiguration, pSettingPolicy);
}
Config stream 1st (pipelingsettingPolicy)
sessionCfgParams.pPipelineStaticInfo = mPipelineStaticInfo;
sessionCfgParams.pUserConfigurationParams = params;
sessionCfgParams.pPipelineModelCallback = mCallback.promote();
Config stream 2nd
mPolicyTable->fConfigPipelineNodesNeed
mPolicyTable->fConfigPipelineTopology
mPolicyTable->fConfigSensorSetting
mPolicyTable->fConfigP1HwSetting
mPolicyTable->fConfigP1DmaNeed
mPolicyTable->fConfigStreamInfo_P1
mPolicyTable->fConfigStreamInfo_NonP1
第二次配流主要配置pipelineModuleSession和构建pipelineContext,构建pipelineContext需要配streaming、node、pipeline。
构建pipelineContext:
Config streaming:网上代码乱码。。
Config node:configContextLocked_Nodes(…)
{
for(size_t i = 0; i < pPipelineNodesNeed->needP1Node.size(); i++) {
if (pPipelineNodesNeed->needP1Node[i]) {
configContextLocked_P1Node(pContext,
pOldPipelineContext,
pStreamingFeatureSetting,
pPipelineNodesNeed,
&(*pParsedStreamInfo_P1)[i],
pParsedStreamInfo_NonP1,
&(*pSensorSetting)[i],
&(*pvP1HwSetting)[i],
i,
batchSize,
useP1NodeCount > 1,
bMultiCam_CamSvPath,
pCommon,
isReConfig);
}
}
if( pPipelineNodesNeed->needP2StreamNode ) {
bool hasMonoSensor = false;
for(auto const v : pPipelineStaticInfo->sensorRawType) {
if(SENSOR_RAW_MONO == v) {
hasMonoSensor = true;
break;
}
}
configContextLocked_P2SNode(pContext,
pStreamingFeatureSetting,
pParsedStreamInfo_P1,
pParsedStreamInfo_NonP1,
batchSize,
useP1NodeCount,
hasMonoSensor,
pCommon);
}
if( pPipelineNodesNeed->needP2CaptureNode ) {
configContextLocked_P2CNode(pContext,
pCaptureFeatureSetting,
pParsedStreamInfo_P1,
pParsedStreamInfo_NonP1,
useP1NodeCount,
pCommon);
}
if( pPipelineNodesNeed->needFDNode ) {
configContextLocked_FdNode(pContext,
pParsedStreamInfo_P1,
pParsedStreamInfo_NonP1,
useP1NodeCount,
pCommon);
}
if( pPipelineNodesNeed->needJpegNode ) {
configContextLocked_JpegNode(pContext,
pParsedStreamInfo_NonP1,
useP1NodeCount,
pCommon);
}
if( pPipelineNodesNeed->needRaw16Node ) {
configContextLocked_Raw16Node(pContext,
pParsedStreamInfo_P1,
pParsedStreamInfo_NonP1,
useP1NodeCount,
pCommon);
}
if( pPipelineNodesNeed->needPDENode ) {
configContextLocked_PDENode(pContext,
pParsedStreamInfo_P1,
pParsedStreamInfo_NonP1,
useP1NodeCount,
pCommon);
}
}
配置pipeline
mpPipelineConfig->setRootNode(rootNodes);
mpPipelineConfig->setNodeEdges(edges);
Request阶段
Camera3deviceSession通过submitRequest将request发给appStreamMgr进行校验和格式转化为hal request和pipeline request,然后camera3deviceSession把转化结果送给pipelineModule处理。
1、Camera3deviceSession接到request,将request通过submitRequest先提交给appstreamMgr再提交给pipelineModule。
pAppStreamManager->submitRequest(requests, appRequests);
pPipelineModel->submitRequest(vPipelineRequests, numRequestProcessed);
2、PipelineModelSessionBase里面解析request并通过submitOneRequest(reqs[i])提交处理。
PipelineModelSessionBase::
submitRequest(
std::vector
uint32_t& numRequestProcessed
){
解析
for (size_t i = 0; i < requests.size(); i++) {
auto r = std::make_shared();
parseAppRequest(r.get(), requests[i].get() );//构造AppRequest对象
reqs.emplace_back®;
}
逐个提交
for (size_t i = 0; i < reqs.size(); i++, numRequestProcessed++) {
submitOneRequest(reqs[i]);
}
}
3、进行处理流程
在处理前会构建freamqueue,建立这个request的I/O buffer、Topological、sub frame、dummy frame、feature set等信息;
android::sp pPipelineFrame;
buildPipelineFrame(pPipelineFrame,params);
PipelineContext流程