VIDIOC_ENUM_FMT don't match device tree and driver

Hi, I’m developing a driver for a CSI-2 camera.

I currently have 2 modes in my device tree, uyvy(640x480) and grey(1280x480). In my mode_tbls.h file, I also have 2 formats and each one is mapped to a sensor_mode, 0 for uyvy and 1 for grey.

My problem is, when I check for the supported format with v4l2-ctl -d0 --list-formats-ext,
it gives me this.

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'GREY'
    Name        : 8-bit Greyscale
            Size: Discrete 640x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)
            Size: Discrete 1280x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)
    Index       : 1
    Type        : Video Capture
    Pixel Format: 'UYVY'
    Name        : UYVY 4:2:2
            Size: Discrete 640x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)
            Size: Discrete 1280x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)

This is not what I would expect, I would expect something like this. I only want 1280x 480 for grey and only 640x480 for uyvy. Also, the index are inverted. 0 should be uyvy

    Index       : 0
    Type        : Video Capture
    Pixel Format: 'UYVY'
    Name        : UYVY 4:2:2
            Size: Discrete 640x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)
    Index       : 1
    Type        : Video Capture
    Pixel Format: 'GREY'
    Name        : 8-bit Greyscale
            Size: Discrete 1280x480
                    Interval: Discrete 0.033s (30.000 fps)
                    Interval: Discrete 0.017s (60.000 fps)

Any suggestions ?

ps. I have no problem to grab.

hello alexandre.caron,

could you please check the driver implementation,
may I also know what’s the mode definition in camera_common_frmfmt ?
thanks

Hi,

Here the content of camera_common_frmfmt

static const int camera_yuy = {
30,60,
};

static const int camera_y16 = {
30,60,
};

static const struct camera_common_frmfmt camera_frmfmt[2] =
{
{{640, 480}, camera_yuy, 2, 0, camera_MODE_640X480_yuy},
{{1280, 480}, camera_y16, 2, 0, camera_MODE_640X480_y16},
};

And here is the dtsi

           mode0 { /* camera_MODE_640x480_UYVY */
                mclk_khz = "";
                num_lanes = "1";
                tegra_sinterface = "serial_a";
                phy_mode = "DPHY";
                discontinuous_clk = "no";
                dpcm_enable = "false";
                cil_settletime = "0";
                active_w = "640";
                active_h = "480";
                mode_type = "yuv";
                csi_pixel_bit_depth = "16";
                pixel_phase = "uyvy";
                readout_orientation = "0";
                line_length = "640";
                inherent_gain = "1";
                pix_clk_hz = "400000000";

                gain_factor = "1";
                framerate_factor = "1";
                exposure_factor = "1000000";
                min_gain_val = "1";    /* Min Raw gain */
                max_gain_val = "1"; /* Max Raw gain */
                step_gain_val = "1";
                default_gain = "1"; /* 1.00x */
                min_hdr_ratio = "1";
                max_hdr_ratio = "1";
                min_framerate = "30";
                max_framerate = "60";
                step_framerate = "30";
                default_framerate = "30"; /* 60.0 fps */
                min_exp_time = "1"; /* us */
                max_exp_time = "200000"; /* us */
                step_exp_time = "1";
                default_exp_time = "14040"; /* us */
                embedded_metadata_height = "0";
            };       

            mode1 { /* camera_MODE_640x480_Y16 */
                mclk_khz = "";
                num_lanes = "1";
                tegra_sinterface = "serial_a";
                phy_mode = "DPHY";
                discontinuous_clk = "no";
                dpcm_enable = "false";
                cil_settletime = "0";
                active_w = "1280";
                active_h = "480";
                mode_type = "grey";
                csi_pixel_bit_depth = "8";
                pixel_phase = "";
                readout_orientation = "0";
                line_length = "1280";
                inherent_gain = "1";
                pix_clk_hz = "400000000";

                gain_factor = "1";
                framerate_factor = "1";
                exposure_factor = "1000000";
                min_gain_val = "1";    /* Min Raw gain */
                max_gain_val = "1"; /* Max Raw gain */
                step_gain_val = "1";
                default_gain = "1"; /* 1.00x */
                min_hdr_ratio = "1";
                max_hdr_ratio = "1";
                min_framerate = "30";
                max_framerate = "60";
                step_framerate = "30";
                default_framerate = "30"; /* 30.0 fps */
                min_exp_time = "1"; /* us */
                max_exp_time = "200000"; /* us */
                step_exp_time = "1";
                default_exp_time = "14040"; /* us */
                embedded_metadata_height = "0";
            };

hello alexandre.caron,

it should be v4l layer issue, I also see unexpected formats with --list-formats-ext.
this is not harmful since your use-case works normally.