Tool/software: Linux
Hello everyone,
we are using the i2c subdev(ov490) driver for reference to developed our driver on am5718 custom board. We have lots of try to direct read write the i2c register of sensor but we are failed so now we have added the below api in ov490 driver. Note: we have enable "CONFIG_VIDEO_ADV_DEBUG" macro using menuconfig.
static int ar1335_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
u16 val = 0;
int ret;
struct i2c_client *client = cli;
printk("%d - %s() \n", __LINE__, __FUNCTION__ );
ret=AR1335_reg_read_test(client, reg->reg & 0xff, &val);
reg->val = val;
reg->size = 1;
return ret;
}
static int ar1335_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg)
{
struct i2c_client *client = cli;
printk("%d - %s() \n", __LINE__, __FUNCTION__ );
ar1335_write_reg(client, AR1335_16BIT, reg->reg & 0xff, reg->val & 0xff);
return 0;
}
static const struct v4l2_subdev_core_ops AR1335_core_ops = {
.log_status = v4l2_ctrl_subdev_log_status,
.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
.g_register = ar1335_g_register,
.s_register = ar1335_s_register,
};
We have used the below sample application to check the ar1335_g_register ioctl call.
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include <string.h>
#include <stdio.h>
int main()
{
int ret=0;
int fd = open("/dev/video0", O_RDWR);
printf("FD:- %d\n",fd);
struct v4l2_dbg_register cap;
memset(&cap, 0, sizeof(cap));
ret=ioctl(fd, VIDIOC_DBG_G_REGISTER, &cap);
printf("ret: %d \n",ret);
}
Please help us to solve the above issue