MM-Camera架构-ProcessCaptureRequest 流程分析

image

文章目录

  • processCaptureRequest\_3\_4
    • 1.1 mDevice
    • 1.2 mDevice->ops->process\_capture\_request
    • 1.3 hardware to vendor
  • mct\_shimlayer\_process\_event
    • 2.1 mct\_shimlayer\_handle\_parm
    • 2.2 mct\_shimlayer\_reg\_buffer

processCaptureRequest_3_4

sdm660的摄像头走camera hal 3.4接口,每个预览帧,都是由camera service发起,通过camera HAL的CameraDeviceSession::processCaptureRequest_3_4接口,通知hal,请求一个预览帧。

hardware/interfaces/camera/device/3.4/default/CameraDeviceSession.cpp

Return<void> CameraDeviceSession::processCaptureRequest_3_4(const hidl_vec<V3_4::CaptureRequest>& requests,const hidl_vec<V3_2::BufferCache>& cachesToRemove,ICameraDeviceSession::processCaptureRequest_3_4_cb _hidl_cb)  {for (size_t i = 0; i < requests.size(); i++, numRequestProcessed++) {s = processOneCaptureRequest_3_4(requests[i]);}...
}Status CameraDeviceSession::processOneCaptureRequest_3_4(const V3_4::CaptureRequest& request)  {...//@ 1.1 - 1.2status_t ret = mDevice->ops->process_capture_request(mDevice, &halRequest);...
}

1.1 mDevice

mDevicecamera_device_t或者camera3_device_t定义。camera1camera3代表的是CAMERA DEVICE API VERSION,camera3canera1完全不一样。这里mDevicecamera3_device_t定义。

camera3_device_t:是 camera HAL 核心结构体之一,是对 venor camera HAL 实现的抽象,APP 通过 Framework对底层Camera设备(物理设备和逻辑虚拟设备)的操作都是通过对 camera3_device_t 实例对象来进行的。
camera3_device_t:主要用来表示Camera设备,其中定义了Camera3_device_ops操作集合,用来实现正常获取图像数据以及控制Camera的功能。

typedef struct camera3_device {hw_device_t common;camera3_device_ops_t *ops;void *priv;
} camera3_device_t;

HAL3的核心接口都是在camera3_device_ops中被定义。
camera3_device_ops结构体定义了一系列的函数指针,用来指向平台厂商实际的实现方法。

typedef struct camera3_device_ops {/*initialize何时被调用:在camera_modul_t中的open方法之后,其他camera3_device_ops方法之前被调用。主要作用:将上层实现的回调方法注册到HAL中,并根据需要在该方法中加入自定义的一些初始化操作。返回时间:在5ms内返回,最长不能超过10ms。*/int (*initialize)(const struct camera3_device *,const camera3_callback_ops_t *callback_ops);/*configure_streams何时被调用:在Initialize方法完成之后,在调用process_capture_request方法之前被调用主要作用:重设当前正在运行的Pipeline以及设执行的输入输出流,其中它回见stream_list中的新的数据流替换之前配置的数据流。返回时间:500ms内返回,最长不能超过1000ms*/int (*configure_streams)(const struct camera3_device *,camera3_stream_configuration_t *stream_list);int (*register_stream_buffers)(const struct camera3_device *,const camera3_stream_buffer_set_t *buffer_set);const camera_metadata_t* (*construct_default_request_settings)(const struct camera3_device *,int type);/*process_capture_request主要作用:下发单次新的capture request到HAL中,上层必须保证该方法的调用都是在一个线程中完成,而且该方法是异步的,其结果是通过HAL调用另一个接口process_capture_result()来返回结果给上层,在使用过程中,通过in-flight机制,保证短时间内下发足够多的requst,从而满足帧率要求。*/int (*process_capture_request)(const struct camera3_device *,camera3_capture_request_t *request);void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,vendor_tag_query_ops_t* ops);void (*dump)(const struct camera3_device *, int fd);int (*flush)(const struct camera3_device *);void (*signal_stream_flush)(const struct camera3_device*,uint32_t num_streams,const camera3_stream_t* const* streams);int (*is_reconfiguration_required)(const struct camera3_device*,const camera_metadata_t* old_session_params,const camera_metadata_t* new_session_params);/* reserved for future use */void *reserved[6];
} camera3_device_ops_t;

1.2 mDevice->ops->process_capture_request

继续mDevice->ops->process_capture_request
hardware/qcom/camera/QCamera2/HAL3/QCamera3HWI.h中camera3_device_ops_t定义了mCameraOps:

static camera3_device_ops_t mCameraOps;

camera3_device_ops_t QCamera3HardwareInterface::mCameraOps = {.initialize                         = QCamera3HardwareInterface::initialize,.configure_streams                  = QCamera3HardwareInterface::configure_streams,.register_stream_buffers            = NULL,.construct_default_request_settings = QCamera3HardwareInterface::construct_default_request_settings,.process_capture_request            = QCamera3HardwareInterface::process_capture_request,.get_metadata_vendor_tag_ops        = NULL,.dump                               = QCamera3HardwareInterface::dump,.flush                              = QCamera3HardwareInterface::flush,.reserved                           = {0},
};

hardware/qcom/camera/QCamera2/HAL3/QCamera3HWI.cpp

int QCamera3HardwareInterface::process_capture_request(const struct camera3_device *device,camera3_capture_request_t *request)
{LOGE("sundpmy_ process_capture_request E");...QCamera3HardwareInterface *hw =reinterpret_cast<QCamera3HardwareInterface *>(device->priv);int rc = hw->orchestrateRequest(request);LOGE("sundpmy_ process_capture_request X");return rc;
}int32_t QCamera3HardwareInterface::orchestrateRequest(camera3_capture_request_t *request)
{int32_t ret = NO_ERROR;...ret = processCaptureRequest(request, internallyRequestedStreams);...
}

1.3 hardware to vendor

QCamera2Factory构造的时候调用get_num_of_cameras_to_expose,一直到用到mm_camera_load_shim_lib。

 QCamera2Factory::QCamera2Factory(){mHalDescriptors = NULL;mCallbacks = NULL;mNumOfCameras = get_num_of_cameras();mNumOfCameras_expose = get_num_of_cameras_to_expose();get_num_of_cameras_to_expose()---> get_num_of_cameras()--->mm_camera_load_shim_lib() 
}

mm_camera_load_shim_lib里面dlopen:libmmcamera2_mct_shimlayer.so。dlsym获取入口函数:mct_shimlayer_process_module_init

#define SHIMLAYER_LIB "/system/vendor/lib/libmmcamera2_mct_shimlayer.so"int32_t mm_camera_load_shim_lib()
{const char* error = NULL;void *qdaemon_lib = NULL;LOGD("E");qdaemon_lib = dlopen(SHIMLAYER_LIB, RTLD_NOW);if (!qdaemon_lib) {error = dlerror();LOGE("dlopen failed with error %s", error ? error : "");return -1;}*(void **)&mm_camera_shim_module_init =dlsym(qdaemon_lib, "mct_shimlayer_process_module_init");if (!mm_camera_shim_module_init) {error = dlerror();LOGE("dlsym failed with error code %s", error ? error: "");dlclose(qdaemon_lib);return -1;}return mm_camera_shim_module_init(&g_cam_ctrl.cam_shim_ops);
}

mct_shimlayer_process_module_init给shim_ops_tbl赋值: @vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/mct_shim_layer/mct_shim_layer.c

int mct_shimlayer_process_module_init(mm_camera_shim_ops_t*shim_ops_tbl)
{...shim_ops_tbl->mm_camera_shim_open_session = mct_shimlayer_start_session;shim_ops_tbl->mm_camera_shim_close_session = mct_shimlayer_stop_session;shim_ops_tbl->mm_camera_shim_send_cmd = mct_shimlayer_process_event;...
}

mm_camera_shim_send_cmd的调用:

int32_t mm_camera_module_send_cmd(cam_shim_packet_t *event)
{int32_t rc = -1;if(g_cam_ctrl.cam_shim_ops.mm_camera_shim_send_cmd) {rc = g_cam_ctrl.cam_shim_ops.mm_camera_shim_send_cmd(event);}return rc;
}

mm_camera_module_send_cmd是个包装函数:
mm_camera_module_send_cmd被调用的地方比较多,打印log看一下:

D mm-camera: <CPP   >< HIGH> 1485: cpp_hardware_process_frame: [CPP_BUF:] stream_status:0xe7f1608c, iden:0x40002, cur_frame_id:17
E QCamera : <MCI><ERROR> mm_stream_unmap_buf: 2327: sundp_mc func:mm_stream_unmap_buf line:2327 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_stream_map_buf: 2168: sundp_mc func:mm_stream_map_buf line:2168 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_camera_util_s_ctrl: 2111: sundp_mc func:mm_camera_util_s_ctrl line:2111 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =0
D mm-camera: <CPP   >< HIGH> 1485: cpp_hardware_process_frame: [CPP_BUF:] stream_status:0xe7f1608c, iden:0x40002, cur_frame_id:18
E QCamera : <MCI><ERROR> mm_stream_unmap_buf: 2327: sundp_mc func:mm_stream_unmap_buf line:2327 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_stream_map_buf: 2168: sundp_mc func:mm_stream_map_buf line:2168 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_camera_util_s_ctrl: 2111: sundp_mc func:mm_camera_util_s_ctrl line:2111 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =0
D mm-camera: <CPP   >< HIGH> 1485: cpp_hardware_process_frame: [CPP_BUF:] stream_status:0xe7f1608c, iden:0x40002, cur_frame_id:19
E QCamera : <MCI><ERROR> mm_stream_unmap_buf: 2327: sundp_mc func:mm_stream_unmap_buf line:2327 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_stream_map_buf: 2168: sundp_mc func:mm_stream_map_buf line:2168 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_camera_util_s_ctrl: 2111: sundp_mc func:mm_camera_util_s_ctrl line:2111 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =0
D mm-camera: <CPP   >< HIGH> 1485: cpp_hardware_process_frame: [CPP_BUF:] stream_status:0xe7f1608c, iden:0x40002, cur_frame_id:20
E QCamera : <MCI><ERROR> mm_stream_unmap_buf: 2327: sundp_mc func:mm_stream_unmap_buf line:2327 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_stream_map_buf: 2168: sundp_mc func:mm_stream_map_buf line:2168 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =2
E QCamera : <MCI><ERROR> mm_camera_util_s_ctrl: 2111: sundp_mc func:mm_camera_util_s_ctrl line:2111 here
E mm-camera: <SHIM  ><ERROR> 481: mct_shimlayer_process_event: sundp_mct Received event from HAL type =0
D mm-camera: <CPP   >< HIGH> 1485: cpp_hardware_process_frame: [CPP_BUF:] stream_status:0xe7f1608c, iden:0x40002, cur_frame_id:21

以上log,可以看出每一帧,每次captureRequest,mm_camera_module_send_cmd会被调用三次。func:mm_stream_map_buf,func:mm_camera_util_s_ctrl,以及每一帧结束后的func:mm_stream_unmap_buf。


mct_shimlayer_process_event

从cameraservice层到qcom的hal层,到了shimlayer。 vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/mct_shim_layer/mct_shim_layer.c
从日志看,每次captureRequest,mct_shimlayer_process_event会被调用两次,cmd_type分别是CAM_SHIM_REG_BUF和CAM_SHIM_SET_PARM。

packet->cmd_type----->
typedef enum {CAM_SHIM_SET_PARM,   /*v4l2 set parameter*/CAM_SHIM_GET_PARM,   /*v4l2 get parameter*/CAM_SHIM_REG_BUF,    /*Reg/unreg buffers with back-end*/CAM_SHIM_BUNDLE_CMD, /*Bundled command for streams*/
} cam_shim_cmd_type;int mct_shimlayer_process_event(cam_shim_packet_t *packet)
{switch (packet->cmd_type) {case CAM_SHIM_SET_PARM:case CAM_SHIM_GET_PARM: {session_id = packet->session_id;parm_event = &packet->cmd_data;@2.1rc = mct_shimlayer_handle_parm(packet->cmd_type, session_id, parm_event);  }break;case CAM_SHIM_REG_BUF: {session_id = packet->session_id;reg_buf = &packet->reg_buf;@2.2rc = mct_shimlayer_reg_buffer(session_id, reg_buf);  }break;......
}

接下来看mct_shimlayer_process_event中的2.1 和 2.2。

2.1 mct_shimlayer_handle_parm

2.2 mct_shimlayer_reg_buffer

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/96984.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

图论第2天----第1020题、第130题

# 图论第2天----第1020题、第130题 文章目录 一、第1020题--飞地的数量二、第130题--被围绕的区域 ​ 又继续开始修行&#xff0c;把图论这块补上&#xff0c;估计要个5-6天时间。 一、第1020题–飞地的数量 ​ 跟前面做的思路差不多&#xff0c;其实有另外一种思路。我这里是…

mysql5.7停止维护时间

mysql5.7将于2023年10月停止官网支持和更新&#xff1b;老项目要准备升级&#xff0c;新项目的mysql必须是mysql8.0&#xff08;2023-10&#xff09; 官方升级咨询地址 oracle官方升级咨询地址https://go.oracle.com/LP116153?elq_mid247718&sh1518132002061316121320310…

数据结构—栈、队列、链表

一、栈 Stack&#xff08;存取O(1)&#xff09; 先进后出&#xff0c;进去123&#xff0c;出来321。 基于数组&#xff1a;最后一位为栈尾&#xff0c;用于取操作。 基于链表&#xff1a;第一位为栈尾&#xff0c;用于取操作。 1.1、数组栈 /*** 基于数组实现的顺序栈&#…

波浪input输入框文字边框动画

一个input输入框的小动画,大家可以按需引入和修改 input的动画表现为,文字提示波浪动画 效果图如下 源码如下 tips: 有不懂的可以在评论区问博主 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name&q…

javascript中依次输出元素并不断循环实现echarts柱图动画效果

循环来遍历数组并输出其中的元素 在JavaScript中&#xff0c;你可以使用循环来遍历数组并输出其中的元素。如果你想要依次输出6个元素并不断循环&#xff0c;可以使用如下的代码&#xff1a; let arr [/* 你的数组 */];for (let i 0; i < arr.length; i) {console.log(a…

机器学习笔记(一)

1.线性回归模型 2. 损失函数 3.梯度下降算法 多元特征的线性回归 当有多个影响因素的时候,公式可以改写为: 当有多个影响因素的时候为了方便计算,可以使用 Numpy下面的点积方法, np.dot(w,x) 最后再加个b 就省略了很多书写步骤,这叫做矢量化 多元回归的梯度下降 左边是一…

[Android] Input事件分发流程之IMS初始化(1)

IMS初始化 一、简介 当用户触摸屏幕或者按键操作&#xff0c;首次触发的是硬件驱动&#xff0c;驱动收到事件后&#xff0c;将该相应事件写入到输入设备节点&#xff0c; 这便产生了最原生态的内核事件。接着&#xff0c;输入系统取出原生态的事件&#xff0c;经过层层封装后…

acwing算法基础之基础算法--高精度除法算法

目录 1 知识点2 模板 1 知识点 大数除以小数&#xff0c;返回商和余数。 2 模板 //A是大数&#xff0c;低位在前 //b是小数 //C是商&#xff0c;低位在前 //r是余数 vector<int> div(vector<int> &A, int b, int &r) {vector<int> C;for (int i …

CSS文本超出显示小数点

目录 1、单行文本溢出 2、多行文本溢出 1、基于高度截断 2、基于行数截断 1、单行文本溢出 如果解决文本溢出显示省略号&#xff0c;需要满足的三个条件&#xff1a; 先强制一行内显示文本 white-space:nowrap;/*默认normal 自动换行*/ 超出的文本隐藏起来。 overflow:…

clickonce 发布的winform 如何CA认证?

要为使用ClickOnce发布的WinForms应用程序启用CA&#xff08;证书颁发机构&#xff09;认证&#xff0c;您可以按照以下步骤进行操作&#xff1a; 1. **获取数字证书**&#xff1a; - 首先&#xff0c;您需要获得一个数字证书&#xff0c;通常从受信任的CA购买。这个数字证…

unity脚本_生命周期函数 c#

帧&#xff1a;fps 即每秒钟跑的游戏帧数 游戏的本质 是一个死循环 每一次循环处理游戏逻辑就会更新一次画面 之所以能看到画面在动 是因为切换画面的速度达到一定时人眼就认为画面时流畅的 一帧就是执行一次循环 人眼舒适放松时可视帧数 24帧/s 游戏卡顿的原因&#xff1a; …

【将文本编码为图像灰度级别】以 ASCII 编码并与灰度级别位混合将文本字符串隐藏到图像像素的最低位中,使其不明显研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

土木硕设计院在职转码上岸

一、个人介绍 双非土木硕&#xff0c;98年&#xff0c;目前在北京&#xff0c;职位为前端开发工程师&#xff0c;设计院在职期间自学转码上岸&#x1f33f; 二、背景 本人于19年开始土木研究生生涯&#xff0c;研二期间去地产实习近半年(碧桂园和世茂&#xff0c;这两家的地产…

跨考408的C语言需要什么水平?

跨考408的C语言需要什么水平? 其实C语言了解一下就可以了&#xff0c;复习之前可以在b站上面随便找个视频看一下&#xff0c;指针部分重点学习一下就 行&#xff0c;C语言主要是数据结构代码部分的基础&#xff0c;对于跨考生来说&#xff0c;先看一下C语言对数据结构的复习有…

MySQL面试题合集

MySQL面经知识整理 文章目录 MySQL面经知识整理一、查询相关1.什么是MySQL的连接查询&#xff0c;左连接&#xff0c;右连接&#xff0c;内外连接2.SQL慢查询优化的方法3.大表查询如何优化 二、索引相关1.在MySQL中,可以通过哪些命令来查看查询是否使用了索引2.MySQL的最左匹配…

跨域请求方案整理实践

项目场景&#xff1a; 调用接口进行手机验证提示,项目需要调用其它域名的接口,导致前端提示跨域问题 问题描述 前端调用其他域名接口时报错提示: index.html#/StatisticalAnalysisOfVacancy:1 Access to XMLHttpRequest at http://xxxxx/CustomerService/template/examineMes…

#力扣:13. 罗马数字转整数@FDDLC

13. 罗马数字转整数 一、Java import java.util.HashMap;class Solution {public int romanToInt(String s) {HashMap<Character, Integer> m new HashMap<>() {{put(I, 1);put(V, 5);put(X, 10);put(L, 50);put(C, 100);put(D, 500);put(M, 1000);}};char[] a …

背包问题学习笔记-分组背包

题意描述&#xff1a; 有 N 组物品和一个容量是 V 的背包。每组物品有若干个&#xff0c;同一组内的物品最多只能选一个。每件物品的体积是 vij&#xff0c;价值是 wij&#xff0c;其中 i 是组号&#xff0c;j 是组内编号。求解将哪些物品装入背包&#xff0c;可使物品总体积不…

UniApp创建项目HelloWorld

浏览器预览效果镇楼 普通项目创建 点击创建完成后&#xff0c;就如下所示 确实和微信小程序开发差不多。只是稍微换了一个名字的概念了&#xff0c;这个就是开发嘛&#xff0c;不要过于纠结概念性东西。开发开发&#xff0c;开了就知道怎么发了&#xff1f; 或许是 反正write就…

基于虚拟阻抗的下垂控制——孤岛双机并联Simulink仿真

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…