Camera main() function is in server.c, which will be compiled as mm-qcamera-daemon and locate in “/system/bin/” directory.
/* 2. after open node, initialize modules */
if(server_process_module_init() == FALSE)
goto module_init_fail;
“server_process_module_init” which is defined in server_process.c, will call init_mod,
temp = modules_list[i].init_mod(modules_list[i].name);
“modules_list[]” definition,
static mct_module_init_name_t modules_list[] = {
{"sensor", module_sensor_init, module_sensor_deinit},
Then jump to module_sensor.c, “module_sensor_init” call “sensor_init_probe” as below,
/* module_sensor_probe_sensors */
ret = sensor_init_probe(module_ctrl);
I’ve mentioned “sensor_init_probe” previously and it will construct one of the two sensors which is called “imx214”. But what about another “imx214_R”? the function will call “module_sensor_find_sensor_subdev” and find it with difference style.
/* Fill all detected sensors */
module_sensor_find_sensor_subdev(module_ctrl);
In “module_sensor_find_sensor_subdev” function, we can see such code,
cfg.cfgtype = CFG_GET_SENSOR_INFO;
rc = ioctl(sd_fd, VIDIOC_MSM_SENSOR_CFG, &cfg);
jump to msm_sensor.c through ioctl system call, we find the destination, “msm_sensor_config” function.
switch (cdata->cfgtype) {
case CFG_GET_SENSOR_INFO:
memcpy(cdata->cfg.sensor_info.sensor_name,
s_ctrl->sensordata->sensor_name,
sizeof(cdata->cfg.sensor_info.sensor_name));
It is very important because the other camera’s name will return to user space which name is “imx214_R”, we must remember this name so that we can know how and why imx214_R library still be loaded in somewhere.
Come back to “module_sensor_init” function, after call “module_sensor_find_sensor_subdev”, it will continuously call “port_sensor_create” function,
/* Create ports based on CID info */
ret = mct_list_traverse(module_ctrl->sensor_bundle, port_sensor_create,
s_module);
jump to port_sensor.c, we can find that “port_sensor_create” will load given library by sensor’s name,
sensor_lib_params = s_bundle->sensor_lib_params;
rc = sensor_load_library(s_bundle->sensor_info->sensor_name,
Two back cameras are loaded by two difference method, it is funny, isn’t it?