Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

Camera board • Re: Custom camera driver format propagation

$
0
0
Hi guys!

I'm building a v4l2 driver for a custom MIPI camera sensor.
The sensor only supports 1 format but I don't know which one at compile time, I retrieve it by I²C at driver loading.

I could successfully record from my sensor using commands like

Code:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=RGB3 --stream-mmap --stream-count=10
But if i don't specify the format, it is assumed to be 640x480.
That behavior seems to come from the fact that the video0 node (so the unicam driver behind) declares that format :

Code:

$ v4l2-ctl  -d /dev/video0 --allDriver Info:        Driver name      : unicam        Card type        : unicam        Bus info         : platform:fe801000.csi        Driver version   : 6.6.51        Capabilities     : 0xa5a00001                Video Capture                Metadata Capture                Read/Write                Streaming                Extended Pix Format                Device Capabilities        Device Caps      : 0x25200001                Video Capture                Read/Write                Streaming                Extended Pix FormatMedia Driver Info:        Driver name      : unicam        Model            : unicam        Serial           :         Bus info         : platform:fe801000.csi        Media version    : 6.6.51        Hardware revision: 0x00000000 (0)        Driver version   : 6.6.51Interface Info:        ID               : 0x03000005        Type             : V4L VideoEntity Info:        ID               : 0x00000003 (3)        Name             : unicam-image        Function         : V4L2 I/O        Flags            : default        Pad 0x01000004   : 0: Sink          Link 0x02000007: from remote pad 0x1000002 of entity 'mysensor 10-002c' (Camera Sensor): Data, Enabled, ImmutablePriority: 2Video input : 0 (unicam-image: ok)Format Video Capture:        Width/Height      : 640/480        Pixel Format      : 'YUYV' (YUYV 4:2:2)        Field             : None        Bytes per Line    : 1280        Size Image        : 614400        Colorspace        : sRGB        Transfer Function : sRGB        YCbCr/HSV Encoding: ITU-R 601        Quantization      : Limited Range        Flags             :
even though the source pad is successfully configured with the right format :

Code:

$ media-ctl -d /dev/media0 -pMedia controller API version 6.6.51Media device information------------------------driver          unicammodel           unicamserial          bus info        platform:fe801000.csihw revision     0x0driver version  6.6.51Device topology- entity 1: mysensor 10-002c (1 pad, 1 link)            type V4L2 subdev subtype Sensor flags 0            device node name /dev/v4l-subdev0        pad0: Source                [fmt:RGB888_1X24/1920x1080 field:none]                -> "unicam-image":0 [ENABLED,IMMUTABLE]- entity 3: unicam-image (1 pad, 1 link)            type Node subtype V4L flags 1            device node name /dev/video0        pad0: Sink                <- "mysensor 10-002c":0 [ENABLED,IMMUTABLE]
So my question is : Why isn't the source pad format (the format declared by the driver) propagated to the video0 dev node ?
Because that isn't the way that Media Controller is meant to work.
We used to only use the /dev/video0 node rather than Media Controller, and you still can if you choose to do so. However it won't work with libcamera as that has been set up to use Media Controller.

See viewtopic.php?t=322076 for my original intro when Media Controller became enabled by default.
And beyond that, how am I supposed to configure it properly? From what I read, it should be the userspace app job to configure it but that seem weird, especially in my case where only the driver knows the supported format.
Your driver should support the enum_mbus_code pad op and that can be interrogated by userspace. Userspace can then set the pad format through the set_fmt pad op, and also the format on the unicam driver. When starting the pipeline it should validate that everything is consistent.

Statistics: Posted by 6by9 — Mon Jun 30, 2025 2:15 pm



Viewing all articles
Browse latest Browse all 8621

Trending Articles