V4L2 - 2 cameras: using one camera activates the other one also

I have a problem with 2 CSI cameras and V4L2 API.

If I use a v4l2-ctl call, I can see in my dmesg prints that for both sensors, the regmap mode is written new.
This could be a problem if one sensor is already streaming and I start the other one I can have artefacts because the regmap mode is newly written while streaming.

Is this intended behaviour?

Best regards,

I don’t think so. It should show the resource busy if the one is streaming.

I narrowed down the problem a little bit.

When I stream sensor 1 and then write to sensor 2 with v4l2-ctl, it can happen that I seem to sometimes lose sensor 1 MIPI CSI data. (The image “jumps” and sometimes the last part is more red (because the bayer pattern seems to be broken after that)

I checked dmesg. You are right, that sensor 1 is not written when writing sensor 2. So this does not seem to be the problem.

I was trying to get the error when using i2cset instead of v4l2-ctl, but I cannot reproduce the problem with that method so it seems to about the amount of i2c request or v4l2 in general.

The problem also appear when starting stream of sensor and also when stopping stream of sensor 2.

Do you have any idea, how this could happen?

best regards,

EDIT: Also using i2cset in a for loop does not produce the problem!

EDIT2: Another thing I noticed but until now did not care too much about: All the register in my mode table are written multiple times, for exaple when setting a mode, but also everytime I call streamon with v4l2 api.
Even when using v4l2-ctl -c only to set one parameter, all the mode registers are written. Why is that?

That’s current call flow.

Thanks for your response.
I still need to come up with a solution. This is a huge problem.

I found out the problem is not with writing i2c.

Because when I use v4l2-ctl to write a parameter. When I write it twice, the i2c write is not called since it is the same value. The error still appears.

So what can it be, that is done when calling one sensor it conflicts with the other? Can you help me out with that? How can I continue debugging?

This also appears when reading with v4l2-ctl.

EDIT: The error does not appear when streaming both cameras, then using v4l2-ctl to read parameter of one of them. So the error happens with something that is done, when the sensor is not streaming,but not when its already streaming.

Can you point me to the code that is run, when streamon is called on camera devices?

The camera kernel driver is located at …/kernel/nvidia/drivers/media/platform/tegra/camera/*