YUYV format camera VI capture also use UYVY

Hi,

When I test a YUYV firmware camera module, and dtsi config pixel_phase = “yuyv”, I found the YUV data’s Y datas and UV datas are reverse, same as use UYVY to capture, because when I use YVYV to check the image color is wrong, and when I use UYVY to check the image color, it’s right. Please help me to check if is an known issue. Thanks!

There’s no way to check. You can just modify the correct color setting in your device tree.

Here’s the VI reg setting. You can confirm this REG is set to correct.

Yes, I have modify the correct color setting in my device tree pixel_phase = “yuyv”,

									dynamic_pixel_bit_depth = "16";
									csi_pixel_bit_depth = "16";
									mode_type = "yuv";
									pixel_phase = "yuyv";

and v4l2 capture set like this:

int main(int argc, char *argv[]) {
    if (argc < 6) {
        fprintf(stderr, "Usage: %s <device> <width> <height> <pixelformat> <frames>\n", argv[0]);
        fprintf(stderr, "Example: %s /dev/video0 640 480 YUYV 100\n", argv[0]);
        return -1;
    }

    const char *device = argv[1];  // 设备节点路径
    int width = atoi(argv[2]);     // 宽度
    int height = atoi(argv[3]);    // 高度
    const char *pixelformat = argv[4];  // 像素格式
    int frames = atoi(argv[5]);    // 捕获的帧数

    int fd;
    FILE *output_file;
    struct v4l2_format fmt = {0};
    struct v4l2_requestbuffers req = {0};
    struct v4l2_buffer buf;
    void *buffers[1];

    sensor_emb_data_t sensor_emb_data;
    isp_emb_data_t isp_emb_data;

    // 打开设备
    fd = open(device, O_RDWR);
    if (fd == -1) {
        errno_exit("open");
    }

    // 设置视频格式
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    fmt.fmt.pix.width = width;
    fmt.fmt.pix.height = height;
    fmt.fmt.pix.pixelformat = v4l2_fourcc(pixelformat[0], pixelformat[1], pixelformat[2], pixelformat[3]);
    fmt.fmt.pix.field = V4L2_FIELD_NONE;

    if (xioctl(fd, VIDIOC_S_FMT, &fmt) == -1) {
        errno_exit("VIDIOC_S_FMT");
    }

and I execute “./v4l2_capture /dev/video0 2592 1948 YUYV 100” to test,

the kern.log is

1970-01-08T06:51:07.490622+08:00 tegra-ubuntu-pos kernel: [RCE] VM0 deactivating.VM0 activating.VI ch[35] frame configuration: 2592x1948 
1970-01-08T06:51:07.490633+08:00 tegra-ubuntu-pos kernel: [RCE]     left skip pixels=0 top skip lines=0
1970-01-08T06:51:07.490635+08:00 tegra-ubuntu-pos kernel: [RCE]     right crop pixels=2592 bottom crop lines=1948
1970-01-08T06:51:07.490636+08:00 tegra-ubuntu-pos kernel: [RCE]     pixel format=VI_PIXFMT_FORMAT_T_Y8_U8__Y8_V8 fmt=16
1970-01-08T06:51:07.490637+08:00 tegra-ubuntu-pos kernel: [RCE] ===== NVCSI Stream Configuration =====
1970-01-08T06:51:07.490639+08:00 tegra-ubuntu-pos kernel: [RCE] stream_id: PP 0, csi_port: PORT A
1970-01-08T06:51:07.490640+08:00 tegra-ubuntu-pos kernel: [RCE] Brick: PHY 0, Mode: C-PHY
1970-01-08T06:51:07.490641+08:00 tegra-ubuntu-pos kernel: [RCE] Partition: CIL A, LP bypass: Disabled, Lanes: 2
1970-01-08T06:51:07.490643+08:00 tegra-ubuntu-pos kernel: [RCE] Clock information:
1970-01-08T06:51:07.490646+08:00 tegra-ubuntu-pos kernel: [RCE] CIL rate: 270000000 Hz
1970-01-08T06:51:07.490647+08:00 tegra-ubuntu-pos kernel: [RCE] MIPI symbol rate: 1312500 kHz
1970-01-08T06:51:07.490648+08:00 tegra-ubuntu-pos kernel: [RCE] Physical rate: 3000000 Kbps
1970-01-08T06:51:07.490649+08:00 tegra-ubuntu-pos kernel: [RCE] T_HS settle: autoconfigured, T_CLK settle: autoconfigured
1970-01-08T06:51:07.490650+08:00 tegra-ubuntu-pos kernel: ======================================

but the dump yuv image use YUYV to preview is wrong color, and use UYVY to preview is correct.

Do you on Jetson Thor?

Could you verify on Orin or Xavier?

I have tested on Jetson Thor and Orin, it’s same issue.

Hi,
It you have same issue on Orin, it should be something wrong in the camera sensor driver. Please check if the sensor is correctly set to YUYV.

Capturing frame data in YUYV on Orin is supposed to work well.

Hi,

I have ensure the sensor is correctly set to YUYV with ofilm factory. Which parameters of camera sensor driver need to config?

Could you provide the frame dump attached here.

FYI, resolution is 2592x1944 + head 4 line embedded data.

yuv_image.zip (10.9 MB)

Could you capture the test pattern for checking.

Thanks

How to config test pattern? Please supply the method.

The sensor should able to support output test pattern by REG config.

The sensor output YUYV and UYVY is correct, you can refer the attached that we checked.

That’s confuse! Then what’s wrong?

Config device tree pixel_phase = “yuyv”, VI receive is wrong.

Hi,
If you configure device tree to YUYV, our VI should expect frame data in YUYV. It should be the camera sensor not outputting in YUYV. Would suggest check this further.

This is the oflim camera factory test result, the camera sensor is outputting in YUYV.

Hi,
Attached yuv_image.zip incudes UYVY_format.yuv and YUYV_format.yuv. Both can be viewed correctly on YUV viewer by setting view format to UYVY. Please check why you configure the camera sensor to output YUYV and it outputs UYVY instead.