-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix rgb565 / bgr565 interchange issue in Zephyr display #79996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rgb565 / bgr565 interchange issue in Zephyr display #79996
Conversation
|
@danieldegrasse : The display format is RGB565, not BGR565. I think there are two mistakes that makes it "works" in practice for NXP display, but make it confused for others, and that impacts the video capture where we forced RGB565 to BGR565 for display.
|
|
Taking the example of RK055HDMIPI4MA01: I did not test on hardware though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zephyr's definition of BGR_565 is unfortunately rather odd- BGR_565 corresponds to what most definitions consider RGB565, and RGB_565 corresponds to BGR_565, but byte swapped.
The only reason I can imagine we did this was that most SPI displays that use 16 bit color would use the RGB_565 format, since the byte swap would result on the data on the SPI MOSI line being in the correct order.
This comment by @zejiang0jason does a good job explaining what is going on here: #71406 (comment)
Another way to check this would be to run samples/drivers/display with this PR, you'll see that the box we expect to be gray is instead cycling through a set of incorrect colors.
|
@danieldegrasse : I did check with both |
|
I will look through Jason's explaination but honestly, I can't understand where and how Zephyr define a RGB565 to become BGR565. If it's an issue with only NXP's displays, it should not be enforced widely in Zephyr. |
|
Oh, just retested. Indeed, with the display sample, the colors are wrong, from top-left to bottom-left the box colors are : R -> B, G -> R, B -> G and the grey box cycling through a set of incorrect colors as you said, sorry for that (I am not too familiar with the display sample, so I didn't check carefully). But for the video capture sample, the color bar pattern are all correct how do we explain that ? |
fc4ecc7 to
a39d1ca
Compare
2ab5de2 to
5affa0b
Compare
5affa0b to
684e39d
Compare
684e39d to
e89e549
Compare
Mention that the RGB565 and BGR565 interchange issue has been fixed in the display sample. Signed-off-by: Phi Bang Nguyen <[email protected]>
e89e549 to
2eb7066
Compare
|
Would it make sense to add a comment into the display header to describe what is the expected orderring for each format ? With this PR merged, the LTDC is now broken since we merged the PR #92483 in the v4.2.0 release cycle in order to have LTDC behaving properly in v4.2.0. So related swap done in the PR #92483 should now be reverted I believe to have it work again. |
|
Yes, it's a good idea.
It should better be done in the same PR I think. I will do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead and get this moved forwards. @josuah I appreciate you creating #92343- I have an st7796s based display, which appears to need updating. I made the change here: danieldegrasse@0bce970. @ngphibang would you prefer I make a PR with that fix, or to just pull that commit into this PR?
|
@ngphibang since this PR got merged yesterday I will prepare and push a PR in order to tackle the two points I raised in my previous comment, that is, adding format description and fixing the LTDC. |
|
@avolmat-st : Sorry for the delay. I am working on it now. |
|
Here is the PR : #93805 |
Propagate zephyrproject-rtos#79996 where RGB_565 and BGR_565 interchange got fixed. It is not necessary to enable the BGR_565 format for the ST7789V display as RGB_565, the default, is correct. Signed-off-by: Josuah Demangeon <[email protected]>
Propagate zephyrproject-rtos#79996 where RGB_565 and BGR_565 interchange got fixed. It is not necessary to enable the BGR_565 format for the ST7789V display as RGB_565, the default, is correct. Signed-off-by: Josuah Demangeon <[email protected]>
Propagate zephyrproject-rtos#79996 where RGB_565 and BGR_565 interchange got fixed. It is not necessary to enable the BGR_565 format for the ST7789V display as RGB_565, the default, is correct. Signed-off-by: Josuah Demangeon <[email protected]>
Propagate zephyrproject-rtos#79996 where RGB_565 and BGR_565 interchange got fixed. It is not necessary to enable the BGR_565 format for the ST7789V display as RGB_565, the default, is correct. Signed-off-by: Josuah Demangeon <[email protected]>
Propagate #79996 where RGB_565 and BGR_565 interchange got fixed. It is not necessary to enable the BGR_565 format for the ST7789V display as RGB_565, the default, is correct. Signed-off-by: Josuah Demangeon <[email protected]>





There is a wrong assumption about the "byte swap" in Zephyr display that makes RGB565 and BGR565 formats are used interchangeably.
This mistake (perhaps) originally comes frome the display samples that leads to the confusion in display drivers, shields, video sample. This PR fixes it.