How to load a camera module in kernel space
2014-09-25 19:42
253 查看
Loading sensor structure from kernel space, it is more familiar than loading from user space, first, we define the sensor’s related information in corresponding dtsi file, notice that “compatible” segment
is important, see the following sample,
qcom,camera@26 {
compatible = "qcom,imx214_R";
reg = <0x26>;
qcom,slave-id = <0x34 0x0016 0x0214>;
qcom,csiphy-sd-index = <1>;
qcom,csid-sd-index = <1>;
qcom,mount-angle = <90>;
qcom,sensor-name = "imx214_R";
qcom,actuator-src = <&actuator0>;
The section define a lot of fields, like i2c address, sensor-name, etc.
Turn to imx214_R.c, “imx214_R_platform_probe” function will be triggered by openfirmware function because the driver’s “compatible” field is the same as definition in the dtsi file. Then “msm_sensor_platform_probe”
function in msm_sensor.c will be called.
match = of_match_device(imx214_R_dt_match, &pdev->dev);
rc = msm_sensor_platform_probe(pdev, match->data);
Here we can get all the parameters through “msm_sensor_get_dt_data” function.
if (pdev->dev.of_node) {
rc = msm_sensor_get_dt_data(pdev->dev.of_node, s_ctrl);
assign function pointer for later use, so that user space can get all information it need through “msm_sensor_config” function.
if (!s_ctrl->func_tbl)
s_ctrl->func_tbl = &msm_sensor_func_tbl;
Power up sensor,
rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
then initialize all the components of “s_ctrl”, finally create V4L2 node for user space.
How to modify for other sensor, for instance, changing one sensor to ov13850?
Modify dtsi file firstly,
//compatible = "qcom,imx214_R";
compatible = "qcom,ov13850";
// qcom,sensor-name = "imx214_R";
qcom,sensor-name = "ov13850"
Open imx214_R.c, change dt_match name to “ov13850”,
static const struct of_device_id imx214_R_dt_match[] = {
//{.compatible = "qcom,imx214_R", .data = &imx214_R_s_ctrl},
{.compatible = "qcom,ov13850", .data = &imx214_R_s_ctrl},
Open imx214_R_lib.c, modify function name from “imx214_R_open_lib” to “ov13850_open_lib”
//void* imx214_R_open_lib(void) {
void* ov13850_open_lib(void) {
return &sensor_lib_ptr;
}
Modify some dual camera related codes, see below,
In “msm_sensor_power_down” function,
if(!strcmp(s_ctrl->sensordata->sensor_name,"imx214_R")||!strcmp(s_ctrl->sensordata->sensor_name,"ov13850"))
{
camera_power_flag = (camera_power_flag&(~CAMERA0_UP))& CAMERA_FLAG_MASK ;
printk("[YLMJ]power_downimx214_R camera_power_flag is %d\n ",camera_power_flag);
}
In “msm_sensor_power_up” function,
if(!strcmp(sensor_name,"imx214_R")||!strcmp(s_ctrl->sensordata->sensor_name,"ov13850"))
{
camera_power_flag = (camera_power_flag&CAMERA_FLAG_MASK)|CAMERA0_UP;
printk("[YLMJ]imx214_R camera_power_flag is %d\n ",camera_power_flag);
}
After compiling imx214_R_lib.c, manually change the library name from “libmmcamera_imx214_R.so” to “libmmcamera_ov13850.so” and push it to “/system/vendor/lib” directory through ADB. Remember that it’s just
a test for understanding the camera work flow, if you want to modify completely, please take more effort to modify the whole code, including but not limited to sensor register/make file/ android.mk/ other names.
is important, see the following sample,
qcom,camera@26 {
compatible = "qcom,imx214_R";
reg = <0x26>;
qcom,slave-id = <0x34 0x0016 0x0214>;
qcom,csiphy-sd-index = <1>;
qcom,csid-sd-index = <1>;
qcom,mount-angle = <90>;
qcom,sensor-name = "imx214_R";
qcom,actuator-src = <&actuator0>;
The section define a lot of fields, like i2c address, sensor-name, etc.
Turn to imx214_R.c, “imx214_R_platform_probe” function will be triggered by openfirmware function because the driver’s “compatible” field is the same as definition in the dtsi file. Then “msm_sensor_platform_probe”
function in msm_sensor.c will be called.
match = of_match_device(imx214_R_dt_match, &pdev->dev);
rc = msm_sensor_platform_probe(pdev, match->data);
Here we can get all the parameters through “msm_sensor_get_dt_data” function.
if (pdev->dev.of_node) {
rc = msm_sensor_get_dt_data(pdev->dev.of_node, s_ctrl);
assign function pointer for later use, so that user space can get all information it need through “msm_sensor_config” function.
if (!s_ctrl->func_tbl)
s_ctrl->func_tbl = &msm_sensor_func_tbl;
Power up sensor,
rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
then initialize all the components of “s_ctrl”, finally create V4L2 node for user space.
How to modify for other sensor, for instance, changing one sensor to ov13850?
Modify dtsi file firstly,
//compatible = "qcom,imx214_R";
compatible = "qcom,ov13850";
// qcom,sensor-name = "imx214_R";
qcom,sensor-name = "ov13850"
Open imx214_R.c, change dt_match name to “ov13850”,
static const struct of_device_id imx214_R_dt_match[] = {
//{.compatible = "qcom,imx214_R", .data = &imx214_R_s_ctrl},
{.compatible = "qcom,ov13850", .data = &imx214_R_s_ctrl},
Open imx214_R_lib.c, modify function name from “imx214_R_open_lib” to “ov13850_open_lib”
//void* imx214_R_open_lib(void) {
void* ov13850_open_lib(void) {
return &sensor_lib_ptr;
}
Modify some dual camera related codes, see below,
In “msm_sensor_power_down” function,
if(!strcmp(s_ctrl->sensordata->sensor_name,"imx214_R")||!strcmp(s_ctrl->sensordata->sensor_name,"ov13850"))
{
camera_power_flag = (camera_power_flag&(~CAMERA0_UP))& CAMERA_FLAG_MASK ;
printk("[YLMJ]power_downimx214_R camera_power_flag is %d\n ",camera_power_flag);
}
In “msm_sensor_power_up” function,
if(!strcmp(sensor_name,"imx214_R")||!strcmp(s_ctrl->sensordata->sensor_name,"ov13850"))
{
camera_power_flag = (camera_power_flag&CAMERA_FLAG_MASK)|CAMERA0_UP;
printk("[YLMJ]imx214_R camera_power_flag is %d\n ",camera_power_flag);
}
After compiling imx214_R_lib.c, manually change the library name from “libmmcamera_imx214_R.so” to “libmmcamera_ov13850.so” and push it to “/system/vendor/lib” directory through ADB. Remember that it’s just
a test for understanding the camera work flow, if you want to modify completely, please take more effort to modify the whole code, including but not limited to sensor register/make file/ android.mk/ other names.
相关文章推荐
- How to Install Nvidia Kernel Module Cuda and Pyrit in Kali Linux
- How to build parport related driver upon parport module in the kernel
- How to convert from the color camera space to the depth camera space in Kinect For Windows
- How to unload a kernel module in use
- how to access file in kernel space
- [Yii Framework] How to embed the css and images in a module
- fedora 14 安装VM tools 问题:Even if the module were to compile successfully, it would not load into the running kernel.
- How To Load .NET Assemblies In A PowerShell Session
- how to get the space size of some tables in one database?
- How to create new module in npm
- How to load helpers in model class
- How to burn Linux Kernel into nor flash and rootfs in USB stick at Mindspeed c1k
- How to fix Failed to load JavaHL Library in Eclipse
- how to install your kernel code in FC6
- Step by Step tutorial howto compile kernel in Debian 5.0 (Lenny)
- How to using DeepLoad in netTiers?
- How to use virtual path providers to dynamically load and compile content from virtual paths in
- (极力推荐)BW:How to load and generate a custom hierarchy in SAP Business Warehouse (SAP BW) without using flat files
- How to load the specified mscordacwks.dll for managed debugging when multiple .NET runtime are loaded in one process
- How to Install Older Kernel in Ubuntu