I work with two different image sensors on a orin nx, sony imx565 and sony imx567. For both, images captured using v4l2 contain garbled pixels at the right end of the lines, replacing the true pixels sent by the sensor. The problem does not appear when capturing using e.g. nvargus_raw, but pure v4l2 must work too.
For the imx565 sensor (4128 x 3008), the noise begins at column 4096. For the imx567 (2472 x 2064) it is less clear where noise begins, but it seems to be at column 2416.
The sensors and the driver produce 12 bit pixels (MEDIA_BUS_FMT_Y12_1X12), but I need only 8, so I have added the following entry to vi5_video_formats :
Raw dumps of RG12 mode show no problem. All pixels in the raw dump get the value I have put in the pattern generator. But if I ask to get the same image in GREY8 mode using the conversion provided by the VI, the last pixels are replaced by some sort of noise. It is certainly a bug in the RAW12 to RAW8 conversion provided by the vi5 driver (or hardware).
I understand that converting RAW12 to T_R16 replicates the most significant nibble of the RAW12 value into the least significant nibble of the T_R16 value. That happens above when trying T_R16 for 8 bits GREY, and that happens correctly for the four 12-bit Bayer variants : RG12, BA12, GB12 and BG12 :
My test pattern emits RAW12 0xe81 pixels. They are correctly transformed into T_R8 0xe8 pixels by throwing away the LSB’s (the four bits of the nibble with value 1) for the biggest part of the image
Knowing that 4128 is 1020 hex, one sees that the first line (from 0 to 1020) is correctly transformed, but in the second line the pixels between 2020 and 2040 are replaced by 0 values. The same thing happens for every pair of following lines : the first one is correct (e.g. from 2040 to 3060), but the next one is corrupted at the end (3060 to 4060 is correct, 4060 to 4080 is corrupted)
with a imx567 sensor programmed with the mode 3 of the pattern generator.
One image (the good one) is obtained on a jetson nano running jetpack-4.6.
The other image (the bad one) is obtained on a orin nx running jetpack-5.1.1.
For comparison and proof that the sensor and the physical transmission are good on the orin, I have added an image created by the following command :
For me it is clearly a bug either in the vi5 driver (but on the orin-nx we have vi6) or in the hardware itself. Could you report it to your upper level ?
And with the imx567 sensor (line width = 2472, not 4128), the problem arises also with the simple conversion of my solid 0xe81 image to T_R16, but is more difficult to describe. Maybe the distance between a power of 2 and the width of the line amplifies the problem. 4128 = 4096 + 32, but 2472 = 2048 + 424. Do you need examples of garbled RAW12 to T_R16 conversion with line width = 2472 ?
I need to process on a Orin NX with Jetpack-5.1.1 in GREY8 form, images coming from RAW12 sensors. Therefore my driver produces always MEDIA_BUS_FMT_Y12_1X12, and I have added the following entriy to vi5_video_formats
to camera_common_color_fmts. This works perfectly with TX1’s TX2’s and TX1 Nano.
But, from what I’ve seen, with the ORIN NX and jetpack-5.1.1, there are bugs in the conversion from MIPI RAW12 to Nvidia T_R8 and T_R16 in memory formats. T_R16 format was added after your suggestion. The bug has different results depending on the T_R8 or T_R16 conversion and depends also on the width of the image. The bug seems to be a replacement of block of pixels by pixels with value 0x00 (black). This happens often at end of lines, but also in the lines in the images with the vertical columns (103).
Evidence images are provided. These are images coming from two different sensors (IMX565 4128x3008 and IMX567 2472x2064), with 3 different patterns generated by the sensors, and processed by 3 different capture commands. Here are the capture commands :
The argus images are provided to show that the image coming from the sensor is not garbled. The sensor is programmed identically in all cases. The intermediate .pgm files are also provided for closer inspection.
I would be happy to test patches that you would provide.