Reading I2C register with regmap_read() but getting constant values

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)

	address = (u16)(val & 0xffff);
	reg.addr = address; /* 16-bit address */
		 "%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;
		 "%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!

How about read some others REG?

Hi, @ShaneCCC!

By other REG, you mean other registers in the same register map? If that’s the case, I did do that (maybe it was a miswriting by my part, but I did test reading a lot of registers from the camera and they mostly matched the value of the datasheet).

Otherwise, if you mean other devices, I don’t have any other in hand (for now) that I know of (unless there are any sort of internal register in TX1 that I could test on).

But in any case, I will continue searching about this and I will post any updates on my findings here.

I mean different offset REG in the same device. Could you write and read back to check it. If no problem that could tell they is no problem for your function and maybe some thing write it back after your write.