高通camera流程注释


当前使用设备的参数表     SD

static struct msm_sensor_ctrl_t   ov5640_s_ctrl  = {
     .msm_sensor_reg = &ov5640_regs,
     .msm_sensor_v4l2_ctrl_info =   ov5640_v4l2_ctrl_info,
    .num_v4l2_ctrl = ARRAY_SIZE(ov5640_v4l2_ctrl_info),
     .sensor_i2c_client = &ov5640_sensor_i2c_client,
     .sensor_i2c_addr =  0x78 - 2,//original 0x78, sub offset to avoid i2c conflicts
     .sensor_output_reg_addr = &ov5640_reg_addr,
     .sensor_id_info = &ov5640_id_info,
     .sensor_exp_gain_info = &ov5640_exp_gain_info,
     .cam_mode = MSM_SENSOR_MODE_INVALID,
     .csic_params = &ov5640_csi_params_array[0],
     .msm_sensor_mutex = &ov5640_mut,
     .sensor_i2c_driver = &ov5640_i2c_driver,
     .sensor_v4l2_subdev_info = ov5640_subdev_info,
     .sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov5640_subdev_info),
     .sensor_v4l2_subdev_ops = &ov5640_subdev_ops,
     .func_tbl = &ov5640_func_tbl,
     .clk_rate = MSM_SENSOR_MCLK_24HZ,
};


ov5640v4l2:
static struct v4l2_subdev_core_ops ov5640_subdev_core_ops = {
     .s_ctrl =   msm_sensor_v4l2_s_ctrl,                        //参数选择
     .queryctrl =   msm_sensor_v4l2_query_ctrl,             //参数min和max选择
     .ioctl = msm_sensor_subdev_ioctl,
     .s_power = msm_sensor_power,
};


int32_t   msm_sensor_v4l2_query_ctrl(
     struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
{
     int rc = -1, i = 0;
     struct msm_sensor_ctrl_t *s_ctrl =
          (struct msm_sensor_ctrl_t *) sd->dev_priv;

     CDBG("%s\n", __func__);
     CDBG("%s id: %d\n", __func__, qctrl->id);

     if (s_ctrl->msm_sensor_v4l2_ctrl_info == NULL)
          return rc;

     for (i = 0; i < s_ctrl->num_v4l2_ctrl; i++) {
          if (s_ctrl->msm_sensor_v4l2_ctrl_info[i].ctrl_id == qctrl->id) {
                qctrl->minimum =
                    s_ctrl->msm_sensor_v4l2_ctrl_info[i].min;
                          //参数min和max选择
               qctrl->maximum =
                    s_ctrl->msm_sensor_v4l2_ctrl_info[i].max;
                         //参数min和max选择
               qctrl->flags = 1;
               rc = 0;
               break;
          }
     }

     return rc;
}




msm_sensor:
int32_t  msm_sensor_v4l2_s_ctrl (struct v4l2_subdev * sd ,struct v4l2_control * ctrl )  //  sd 是subdev的意思是 s_ctrl中的成员
{                                                                                                                       //   ctrl是上层传下的设置的参数
     int rc = -1, i = 0;
     struct msm_sensor_ctrl_t * s_ctrl  = get_sctrl( sd );
     struct msm_sensor_v4l2_ctrl_info_t * v4l2_ctrl  =
           s_ctrl->msm_sensor_v4l2_ctrl_info ;

     CDBG("%s\n", __func__);
     CDBG("%d\n", ctrl->id);
     if (v4l2_ctrl == NULL)
          return rc;
     for (i = 0; i <  s_ctrl->num_v4l2_ctrl ; i++) {        // 曝光 对比度 iso 饱和度 等
          if ( v4l2_ctrl [i].ctrl_id ==  ctrl->id ) {                 //如果是需要调的选项
               if ( v4l2_ctrl [i].s_v4l2_ctrl != NULL) {
                    CDBG("\n calling msm_sensor_s_ctrl_by_enum\n");
                    rc =  v4l2_ctrl [i].s_v4l2_ctrl( s_ctrl, &s_ctrl->msm_sensor_v4l2_ctrl_info[i], ctrl->value);  //调用参数table的函数
               }
               break;
          }
     }

     return rc;
}

ov5640v4l2:
struct msm_sensor_v4l2_ctrl_info_t ov5640_v4l2_ctrl_info[] = {
     {
        .ctrl_id = V4L2_CID_EXPOSURE,
        .min = 0,
        .max = 0,
        .step = 0,       
        .s_v4l2_ctrl = ov5640_set_exposure_msm_sensor_s_ctrl,
    },
     {
        .ctrl_id = V4L2_CID_AUTO_WHITE_BALANCE,
        .min = CAMERA_WB_AUTO,
        .max = CAMERA_WB_CLOUDY_DAYLIGHT,
        .step = 1,       
          .enum_cfg_settings = &ov5640_wb_enum_confs,
        .s_v4l2_ctrl = ov5640_msm_sensor_s_ctrl_by_enum,
    },
     {
        .ctrl_id = MSM_V4L2_PID_BEST_SHOT,
        .min = 0,
        .max = 0,
        .step = 0,       
        .s_v4l2_ctrl = OV5640_set_scene_mode,
    },
    {
        .ctrl_id = V4L2_CID_FOCUS_AUTO,
        .min = 0,
        .max = 0,
        .step = 0,
        .s_v4l2_ctrl = ov5640_set_auto_focus_msm_sensor_s_ctrl,
    },
     {
          .ctrl_id = V4L2_CID_SPECIAL_EFFECT,
          .min = CAMERA_EFFECT_OFF,
          .max = CAMERA_EFFECT_SEPIA,
          .step = 1,
          .enum_cfg_settings = &ov5640_special_effect_enum_confs,
          .s_v4l2_ctrl = ov5640_effect_msm_sensor_s_ctrl_by_enum,
     },

你可能感兴趣的:(高通camera)