高通camera如何匹配I2C总线

1、dts配置

cci: qcom,cci@1b0c000 {

compatible = "qcom,cci";

...

pinctrl-names = "cci_default","cci_suspend";

pinctrl-0= <&cci0_default>;

pinctrl-1= <&cci0_sleep>;

gpios =<&msm_gpio 29 0>,//CAM_I2C_SCL

<&msm_gpio 30 0>;//CAM_I2C_SDA

...

};

2、kernel代码

代码:kernel/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c

static int msm_cci_probe(structplatform_device *pdev)

{

...

v4l2_subdev_init(&new_cci_dev->msm_sd.sd,&msm_cci_subdev_ops);//绑定操作集合

g_cci_subdev =&new_cci_dev->msm_sd.sd; //对外接口

...

}

static struct v4l2_subdev_core_opsmsm_cci_subdev_core_ops = {

.g_chip_ident =&msm_cci_subdev_g_chip_ident,

.ioctl = &msm_cci_subdev_ioctl,//控制接口函数

.interrupt_service_routine =msm_cci_irq_routine,

};

static const struct v4l2_subdev_opsmsm_cci_subdev_ops = {

.core = &msm_cci_subdev_core_ops,

};

static long msm_cci_subdev_ioctl(structv4l2_subdev *sd, unsigned int cmd, void *arg)

{

int32_t rc = 0;

CDBG("%s line %d\n",__func__, __LINE__);

switch (cmd) {

case VIDIOC_MSM_CCI_CFG:

rc = msm_cci_config(sd,arg);//具体的参数配置

break;

case MSM_SD_SHUTDOWN: {

struct msm_camera_cci_ctrlctrl_cmd;

ctrl_cmd.cmd = MSM_CCI_RELEASE;

rc = msm_cci_config(sd,&ctrl_cmd);

break;

}

default:

rc = -ENOIOCTLCMD;

}

CDBG("%s line %d rc %d\n",__func__, __LINE__, rc);

return rc;

}

static int32_t msm_cci_config(structv4l2_subdev *sd, struct msm_camera_cci_ctrl*cci_ctrl)

{

int32_t rc = 0;

CDBG("%s line %d cmd %d\n",__func__, __LINE__, cci_ctrl->cmd);

switch (cci_ctrl->cmd) {

case MSM_CCI_INIT:

rc =msm_cci_init(sd, cci_ctrl); //完成iic初始化

break;

case MSM_CCI_RELEASE:

rc = msm_cci_release(sd);

break;

case MSM_CCI_I2C_READ:

rc =msm_cci_i2c_read_bytes(sd, cci_ctrl); //iic

break;

case MSM_CCI_I2C_WRITE:

rc =msm_cci_i2c_write(sd, cci_ctrl); //iic

break;

case MSM_CCI_GPIO_WRITE:

break;

default:

rc = -ENOIOCTLCMD;

}

CDBG("%s line %d rc %d\n",__func__, __LINE__, rc);

cci_ctrl->status = rc;

return rc;

}

struct v4l2_subdev*msm_cci_get_subdev(void)

{

return g_cci_subdev;

}

注:kernel/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h中会声明struct v4l2_subdev*msm_cci_get_subdev(void);以提供对外接口,当camera相关模块probe时会通过此接口得到g_cci_subdev。

你可能感兴趣的:(驱动开发)