While BGR565 read is currently supported, the format code is missing support for BGR565 write.
Implement argb_u16_to_BGR565(), add it to get_pixel_write_function() and advertise BGR565 support in vkms_wb_formats. Signed-off-by: Matheus Alves de Almeida <[email protected]> --- drivers/gpu/drm/vkms/vkms_formats.c | 12 ++++++++++++ drivers/gpu/drm/vkms/vkms_writeback.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 6d7853e87..b44900761 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -672,6 +672,16 @@ static void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pi *pixel = cpu_to_le16(r << 11 | g << 5 | b); } +static void argb_u16_to_BGR565(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel) +{ + __le16 *pixel = (__le16 *)out_pixel; + u16 r, g, b; + + argb_u16_to_channels(&r, &g, &b, NULL, 5, 6, 5, 0, in_pixel); + + *pixel = cpu_to_le16(b << 11 | g << 5 | r); +} + /** * vkms_writeback_row() - Generic loop for all supported writeback format. It is executed just * after the blending to write a line in the writeback buffer. @@ -972,6 +982,8 @@ pixel_write_t get_pixel_write_function(u32 format) return &argb_u16_to_XRGB16161616; case DRM_FORMAT_RGB565: return &argb_u16_to_RGB565; + case DRM_FORMAT_BGR565: + return &argb_u16_to_BGR565; default: /* * This is a bug in vkms_writeback_atomic_check. All the supported diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index ecf29a2c0..f64b90908 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -21,7 +21,8 @@ static const u32 vkms_wb_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_ARGB16161616, - DRM_FORMAT_RGB565 + DRM_FORMAT_RGB565, + DRM_FORMAT_BGR565 }; static const struct drm_connector_funcs vkms_wb_connector_funcs = { -- 2.43.0
