发布网友 发布时间:2022-05-12 19:10
共1个回答
热心网友 时间:2023-10-19 03:05
camera模块驱动是一个字符驱动,驱动是挂载在总线上,一般在 Linux 总线驱动模型中,我们只需要关心总线、设备、驱动这三个实体。总线会充当红娘对加载于其上的设备与驱动进行配对,对于 Camera 模块也不例外,下面从总线、设备、驱动的角度来分析 Camera 模块驱动的注册、匹配与加载过程。
MTK的image_sensor注册的是一个platform类型总线驱动,首先要进行板极设备的初始化的工作,代码在:mediatek/platform/mt6572/kernel/core/mt_devs.c,里面会对platform总线注册的device进行注册:
[cpp] view plain copy
#if 1 ///defined(CONFIG_VIDEO_CAPTURE_DRIVERS)
retval = platform_device_register(&sensor_dev);
if (retval != 0){
return retval;
}
#endif
static struct platform_device sensor_dev = {
.name = "image_sensor",
.id = -1,
};
image_sensor的platform类型驱动的device的name为 "image_sensor",而在linux中,所有的总线的driver与device都是通过name来与进行匹配的,platform总线也不例外,所以可以通过grep命令来查找camera注册的总线中driver的注册路径为:mediatek/custom/common/kernel/imgsensor/src/kd_sensorlist.c,代码为:
[cpp] view plain copy
static struct platform_driver g_stCAMERA_HW_Driver = {
.probe = CAMERA_HW_probe,
.remove = CAMERA_HW_remove,
.suspend = CAMERA_HW_suspend,
.resume = CAMERA_HW_resume,
.driver = {
.name = "image_sensor",
.owner = THIS_MODULE,
}
};