drm/mipi-dbi: Add support for DRM_FORMAT_RGB888
authorNoralf Trønnes <noralf@tronnes.org>
Tue, 4 Jun 2024 13:20:31 +0000 (15:20 +0200)
committerNoralf Trønnes <noralf@tronnes.org>
Fri, 7 Jun 2024 14:09:05 +0000 (16:09 +0200)
commit4aebb79021f3e6c2b6fbb92a7d9c5d1e6ad0324a
treed2b0fa455b8cfc4148b6d5b6cf4de4a300d1c740
parentdf3fb27a74a4eeb1436129024a7e957c2e83a95e
drm/mipi-dbi: Add support for DRM_FORMAT_RGB888

DRM_FORMAT_RGB888 is 24 bits per pixel and it would be natural to send it
on the SPI bus using a 24 bits per word transfer. The problem with this
is that not all SPI controllers support 24 bpw.

Since DRM_FORMAT_RGB888 is stored in memory as little endian and the SPI
bus is big endian we use 8 bpw to always get the same pixel format on the
bus: b8g8r8.

The MIPI DCS specification lists the standard commands that can be sent
over the MIPI DBI interface. The set_address_mode (36h) command has one
bit in the parameter that controls RGB/BGR order. This means that the
controller can be configured to receive the pixel as BGR.

RGB888 is rarely supported on these controllers but RGB666 is very common.
All datasheets I have seen do at least support the pixel format option
where each color is sent as one byte and the 6 MSB's are used.

All this put together means that we can send each pixel as b8g8r8 and an
RGB666 capable controller sees this as b6x2g6x2r6x2.

v4:
- s/emulation_format/pixel_format/ (Dmitry)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240604-panel-mipi-dbi-rgb666-v4-4-d7c2bcb9b78d@tronnes.org
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
drivers/gpu/drm/drm_mipi_dbi.c
include/drm/drm_mipi_dbi.h