-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Describe the bug
I'm trying to use RGB24 format with TC358743 instead of UYVY, and noticed that it produces BGR sequence in the raw data instead of RGB. I used the blue fullscreen image as an HDMI source and made a stream dump that confirms this, getting something like [255, 0, 0]
for first 3 bytes.
If you have a top secret datasheet under Toshiba NDA, you can check pages 36/261 and 37/261. This confirms that UYVY is implemented correctly, but RGB has the reverse sequence. Apparently, this bug went unnoticed because everyone was using UYVY. I need RGB to output the image in DRM and encode in M2M at the same time.
Steps to reproduce the behaviour
Use any capture software with TC358743 in RGB24 format and dump the raw image.
Device (s)
Raspberry Pi CM4, Raspberry Pi CM4 Lite
System
- Arch Linux ARM, but it doesn't matter
version c14213886ae1e31951022b74ce776ce7ee7023ee (clean) (release) (start)
Linux pikvm 6.6.21-4-rpi #1 SMP Wed Mar 13 20:36:42 UTC 2024 armv7l GNU/Linux
- Apparently, the problem is relevant for any version of kernel.
Logs
No response
Additional context
I found this bug when encoding JPEG in M2M and using libjpeg. It's the same with M2M H.264. Interestingly, because of the endianness, DRM_FORMAT_RGB888 is actually BGR, so the rendering of the TC* chip output in DRM was correct colors, while the encoding was not.
I don't know if it is possible to fix this with little blood without loss of performance, given that it looks like you need to use the reverse order to put bytes in memory after receiving from CSI. This is not a big problem and I can make a userspace workaround for this, but it would probably be better to fix it upstream if the fix is not complex or fatal to performance.