I2C Control of SOC-Camera via V4L API on TK1

Is there a way to map read and write registers on a MIPI camera using ioctl commands using the Video4Linux API.

Hi ayodeji
Did you want to access the sensor REG via i2c bus? I don’t see the V4L2 API support that what you want. There is some tools like i2cget, i2cdump. Or you can implement a debug sysfs for your purpose.

Hello Shane,

I was thinking I could somehow map certain register reads and writes to ioctl commands. What I don’t know is if I can then make the ioctl commands callable via the V4L2 API. Correct me if I’m wrong but I think the soc-camera driver is built on Video4Linux so I thought there might be a way to make this work. Thanks!

As my understand there’s a V4L2 API for your request.

if you enable “CONFIG_VIDEO_ADV_DEBUG”, then you can access sensor register through VIDIOC_DBG_S_REGISTER/VIDIOC_DBG_G_REGISTER V4L2 IOCtl.

Also, you need to connect read / write functions in your sensor code like below

static struct v4l2_subdev_core_ops mysensor_ops = {
    .g_chip_ident	= mysensor_g_chip_ident,
    .init		= mysensor_init,
.....
#ifdef CONFIG_VIDEO_ADV_DEBUG
    .g_register		= mysensor_g_register,
    .s_register		= mysensor_s_register,
#endif

Thank you Jack71! It seems the TX1 has sensor_s_ctrl & sensor_volatile_g_ctrl functions that can be used. Do you know if the is available on the TK1?

ayodeji
TK1 is v4l2 soc_camera system. You can reference to some driver locate …/kernel/drivers/media/i2c/soc_camera/
I saw they support v4l2_subdev_core_ops suppose you can implement the g_register/s_register to your v4l2 sensor driver.