Hi, everyone!
So, this might be a general Linux question but, anyway, here it goes.
I’m currently studying nVidia’s driver implementation for the ov5693 camera and I currently have a working driver for ov5647, basically replicated from ov5693’s code.
Now, I already am able to capture raw images and write to I2C registers (tested through yavta, by calling the V4L2_CID_GAIN ioctl command and, then, checking the effects of gain change in the captured image).
Then I created a simple extended control to be called through ioctl that prints the value of a register (to be read at dmesg).
Here is the code:
static int ov5647_debug_read_reg(struct ov5647 *priv, s32 val)
{
ov5647_reg reg;
int err;
u16 address;
if (!priv->group_hold_prev)
ov5647_set_group_hold(priv);
address = (u16)(val & 0xffff);
reg.addr = address; /* 16-bit address */
dev_info(&priv->i2c_client->dev,
"%s: val: 0x%8X\n", __func__, address);
err = ov5647_read_reg(priv->s_data, reg.addr, &(reg.val));
printk("debug: %s: addr=0x%04X, val=0x%02X\n", __func__, reg.addr, reg.val);
if (err)
goto fail;
return 0;
fail:
dev_info(&priv->i2c_client->dev,
"%s: DEBUG_READ_REG control error\n", __func__);
return err;
}
(here, all ov5647* structs and called functions are identical to nVidia’s implementation for ov5693)
This code does print the (or at least, some) value stored at a given address in the I2C register and most of them happen to match the default value indicated by the sensor datasheet.
But here is my problem. Even though I know I’ve indeed written the value in the I2C register (because of the test I mentioned before), when I read the same register, after writing different values to it, it always shows the same value. I think it’s also relevant to say that values initialized at probe (values defined at *_mode_tbls.h) presents the same issue, that is, when I read values that should be initialized by probe, my debug_read_reg() function usually shows them having either the datasheet’s default or another entirely different value.
It seems to me like I’m somehow reading from a cached version of the register, but I couldn’t really understand either how or why it happens. Either that or I might be misunderstanding how regmap.c works in general.
Do anyone happen to know something about this? Any hints, leads or advices are welcome!