以问答的形式来理解摄像头框架流程
问:aw_camera.xml中配置的多个摄像头在哪里匹配?
答:sensor.c(vendor)通过iotcl到底层在msm_sensor_driver_probe去获取dtsi中配置的g_sctrl
kernel\msm-3.18\drivers\media\platform\msm\camera_v2\sensor\msm_sensor_init.c
msm_sensor_init_subdev_do_ioctl -> msm_sensor_init_subdev_ioctl -> msm_sensor_driver_cmd -> msm_sensor_driver_probe
问:g_sctrl里面的值什么时候赋值?
答:通过平台driver进来解析dts时复制
kernel\msm-3.18\drivers\media\platform\msm\camera_v2\sensor\msm_sensor_driver.c
msm_sensor_driver_platform_probe -> msm_sensor_driver_parse -> msm_sensor_driver_get_dt_data
问:g_sctrl里面的sensor_i2c_client内容关于i2c通讯部分哪里来的?
答:camera_v2\sensor\cci\msm_cci.c中通过platform_driver_register获取i2c相关的配置,msm_sensor_driver_platform_probe里面会对g_sctrl里面的内容都填充
msm_sensor_driver_platform_probe -> msm_sensor_driver_parse -> msm_sensor_init_default_params -> s_ctrl->sensor_i2c_client->i2c_func_tbl =
&msm_sensor_cci_func_tbl;
问:/dev/media*和/dev/video*和/dev/v4l-subdev*在哪里注册的?
答:kernel\msm-3.18\drivers\media\platform\msm\camera_v2\msm.c代码里注册的*0,匹配msm8937-camera.dtsi里面的qcom,msm-cam
驱动里面注册:msm_probe -> media_device_register(/dev/media*)
->video_register_device -> __video_register_device(里面注册了主设备号81的设备和/sys/class/video4linux/video* v4l-subdev*)
kernel\msm-3.18\drivers\media\platform\msm\camera_v2\sensor\msm_sensor_driver.c里面调用camera_init_v4l2注册了真正的摄像头:
msm_sensor_driver_probe -> msm_sensor_driver_create_v4l_subdev -> camera_init_v4l2 -> media_device_register
问:如何解决 mmm libs提示'sensor_lib.h' file not found 或者ALOGE未定义
答:1.#include
2. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../../../../../mm-camerasdk/sensor/includes/
问:摄像头的两个相关服务代码分别在哪
答:
server:cameraserver
frameworks\av\camera\cameraserver\main_cameraserver.cpp
server:mm-qcamera-daemon
vendor\qcom\proprietary\mm-camera\mm-camera2\server-imaging\server.c
main -> server_process_module_sensor_init -> module_sensor_init(module_sensor.c)-> sensor_init_probe(sensor_init.c) -> sensor_init_xml_probe -> sensor_probe -> sensor_load_library ->
问:为什么mm-qcamera-daemon是32位的应用程序,编译取决哪里?
答:Android.mk加了下面这句所以编译出来是32位的应用程序
LOCAL_32_BIT_ONLY := true
问:vendor\qcom\proprietary\mm-camera\mm-camera2\media-controller\modules\sensors\sensor\module\sensor.c中调用的ioctrl对应驱动程序的哪里?
答:kernel\msm-3.18\drivers\media\platform\msm\camera_v2\sensor\msm_sensor.c
msm_sensor_subdev_fops_ioctl -> msm_sensor_subdev_do_ioctl -> msm_sensor_subdev_ioctll -> msm_sensor_config32
kernel\msm-3.18\drivers\media\platform\msm\camera_v2\sensor\msm_sensor_driver.c msm_sensor_driver_create_i2c_v4l_subdev中有设置了compat_ioctl32:
问:配置的xml在哪里解析
答:
\vendor\qcom\proprietary\mm-camera\mm-camera2\media-controller\modules\sensors\chromatix\module\chromatix_manager.c
addLib -> addLib_getSymbol -> load_chromatix (chromatix_sub_module.c)