drmatt
Posts: 37
Joined: Sat Sep 07, 2019 3:47 am

matching csi2 camera with i2c device

Tue Jun 15, 2021 4:06 am

This question concerns user-space operation of mipi csi2 cameras, as in raspiraw. For a given cm4 carrier board with two csi2 ports, is there any way to automatically determine which port goes with which i2c bus / device? In other words, we probe i2c-0 and find camera #1, and we probe i2c-10 and find camera #2, but which one receives its frame data using camera_num=0 and which one using camera_num=1?

And a loosely related question: is there a way to swap the assignment of i2c-0 and i2c-10 when using dtparam=i2c_vc=on in /boot/config.txt?

cleverca22
Posts: 3915
Joined: Sat Aug 18, 2012 2:33 pm

Re: matching csi2 camera with i2c device

Tue Jun 15, 2021 4:19 am

i think ideally, that would be handled with device-tree

you would use a DT overlay to describe that pairing to linux and the unicam driver, and then it all works without userland having to know how its wired up

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11464
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: matching csi2 camera with i2c device

Tue Jun 15, 2021 8:32 am

drmatt wrote:
Tue Jun 15, 2021 4:06 am
This question concerns user-space operation of mipi csi2 cameras, as in raspiraw. For a given cm4 carrier board with two csi2 ports, is there any way to automatically determine which port goes with which i2c bus / device? In other words, we probe i2c-0 and find camera #1, and we probe i2c-10 and find camera #2, but which one receives its frame data using camera_num=0 and which one using camera_num=1?
No because it could be wired up either way. The two data paths are totally independent, so whatever is controlling them must be told.
drmatt wrote:And a loosely related question: is there a way to swap the assignment of i2c-0 and i2c-10 when using dtparam=i2c_vc=on in /boot/config.txt?
Only by disabling the mux and dropping back to just i2c-0 on the pins of your choice.
Do NOT use dtparam=i2c_vc=on, but replace it with dtoverlay=i2c0,pins_44_45 and i2c-0 will be on 44&45. This will be incompatible with most of the camera driver overlays, so do not mix and match.

You could reassign the aliases, but don't that to be supported in the main kernel/firmware as it'll just cause confusion.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

drmatt
Posts: 37
Joined: Sat Sep 07, 2019 3:47 am

Re: matching csi2 camera with i2c device

Wed Jun 16, 2021 9:32 pm

This all makes sense. We'll try a couple of options - many thanks!

Return to “Camera board”