Skip to content

Commit 39d80ce

Browse files
committed
drm/vkms: Add support for RGB565 formats
The format RGB565 was already supported. Add the support for: - BGR565 Reviewed-by: Maíra Canal <mcanal@igalia.com> Acked-by: Daniel Stone <daniels@collabora.com> Link: https://lore.kernel.org/r/20250703-b4-new-color-formats-v7-4-15fd8fd2e15c@bootlin.com Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
1 parent bac5c59 commit 39d80ce

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/gpu/drm/vkms/vkms_formats.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ static struct pixel_argb_u16 argb_u16_from_grayu16(u16 gray)
259259
return argb_u16_from_u16161616(0xFFFF, gray, gray, gray);
260260
}
261261

262+
static struct pixel_argb_u16 argb_u16_from_BGR565(const __le16 *pixel)
263+
{
264+
struct pixel_argb_u16 out_pixel;
265+
266+
out_pixel = argb_u16_from_RGB565(pixel);
267+
swap(out_pixel.r, out_pixel.b);
268+
269+
return out_pixel;
270+
}
271+
262272
VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_2,
263273
const struct conversion_matrix *matrix)
264274
{
@@ -451,6 +461,7 @@ READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[
451461
READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2])
452462

453463
READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px)
464+
READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px)
454465

455466
READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px)
456467

@@ -675,6 +686,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format)
675686
return &XBGR16161616_read_line;
676687
case DRM_FORMAT_RGB565:
677688
return &RGB565_read_line;
689+
case DRM_FORMAT_BGR565:
690+
return &BGR565_read_line;
678691
case DRM_FORMAT_NV12:
679692
case DRM_FORMAT_NV16:
680693
case DRM_FORMAT_NV24:

drivers/gpu/drm/vkms/vkms_plane.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static const u32 vkms_formats[] = {
2424
DRM_FORMAT_ARGB16161616,
2525
DRM_FORMAT_ABGR16161616,
2626
DRM_FORMAT_RGB565,
27+
DRM_FORMAT_BGR565,
2728
DRM_FORMAT_NV12,
2829
DRM_FORMAT_NV16,
2930
DRM_FORMAT_NV24,

0 commit comments

Comments
 (0)