Skip to contentSkip to conversation

drm/vkms: Add DRM_FORMAT_XBGR8888 support to writeback

PATCH In review Karthik Sarvan 2 participants 2 messages Nov 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vkms: Add DRM_FORMAT_XBGR8888 support to writeback

VKMS planes already support reading DRM_FORMAT_XBGR8888, but writeback cannot write it yet. In the 8888 format family, writeback only supports ARGB8888, XRGB8888, and ABGR8888.

Add a pixel write function for XBGR8888 and include it in the supported writeback formats list so compositors and tests can capture frames in this format.

---
 drivers/gpu/drm/vkms/vkms_formats.c   | 10 ++++++++++
 drivers/gpu/drm/vkms/vkms_writeback.c |  1 +
 2 files changed, 11 insertions(+)
drivers/gpu/drm/vkms/vkms_formats.c +10 -0
index 7f1f29b589e8..a89aef97cede 100644
@@ -611,6 +611,14 @@ static void argb_u16_to_XRGB8888(u8 *out_pixel, const struct pixel_argb_u16 *in_
 	out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257);
 }
 
+static void argb_u16_to_XBGR8888(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
+{
+	out_pixel[3] = 0xff;
+	out_pixel[2] = DIV_ROUND_CLOSEST(in_pixel->b, 257);
+	out_pixel[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257);
+	out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->r, 257);
+}
+
 static void argb_u16_to_ABGR8888(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
 {
 	out_pixel[3] = DIV_ROUND_CLOSEST(in_pixel->a, 257);
@@ -977,6 +985,8 @@ pixel_write_t get_pixel_write_function(u32 format)
 		return &argb_u16_to_ARGB8888;
 	case DRM_FORMAT_XRGB8888:
 		return &argb_u16_to_XRGB8888;
+	case DRM_FORMAT_XBGR8888:
+		return &argb_u16_to_XBGR8888;
 	case DRM_FORMAT_ABGR8888:
 		return &argb_u16_to_ABGR8888;
 	case DRM_FORMAT_ARGB16161616:
drivers/gpu/drm/vkms/vkms_writeback.c +1 -0
index 858df1f89f66..3407b5914694 100644
@@ -18,6 +18,7 @@
 static const u32 vkms_wb_formats[] = {
 	DRM_FORMAT_ARGB8888,
 	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_XBGR8888,
 	DRM_FORMAT_ABGR8888,
 	DRM_FORMAT_XRGB16161616,
 	DRM_FORMAT_ARGB16161616,
Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 57 lines · Karthik Sarvan

VKMS planes already support reading DRM_FORMAT_XBGR8888, but writeback cannot write it yet. In the 8888 format family, writeback only supports ARGB8888, XRGB8888, and ABGR8888.

Add a pixel write function for XBGR8888 and include it in the supported writeback formats list so compositors and tests can capture frames in this format.

---
 drivers/gpu/drm/vkms/vkms_formats.c   | 10 ++++++++++
 drivers/gpu/drm/vkms/vkms_writeback.c |  1 +
 2 files changed, 11 insertions(+)
drivers/gpu/drm/vkms/vkms_formats.c +10 -0
index 7f1f29b589e8..a89aef97cede 100644
@@ -611,6 +611,14 @@ static void argb_u16_to_XRGB8888(u8 *out_pixel, const struct pixel_argb_u16 *in_
 	out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257);
 }
 
+static void argb_u16_to_XBGR8888(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
+{
+	out_pixel[3] = 0xff;
+	out_pixel[2] = DIV_ROUND_CLOSEST(in_pixel->b, 257);
+	out_pixel[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257);
+	out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->r, 257);
+}
+
 static void argb_u16_to_ABGR8888(u8 *out_pixel, const struct pixel_argb_u16 *in_pixel)
 {
 	out_pixel[3] = DIV_ROUND_CLOSEST(in_pixel->a, 257);
@@ -977,6 +985,8 @@ pixel_write_t get_pixel_write_function(u32 format)
 		return &argb_u16_to_ARGB8888;
 	case DRM_FORMAT_XRGB8888:
 		return &argb_u16_to_XRGB8888;
+	case DRM_FORMAT_XBGR8888:
+		return &argb_u16_to_XBGR8888;
 	case DRM_FORMAT_ABGR8888:
 		return &argb_u16_to_ABGR8888;
 	case DRM_FORMAT_ARGB16161616:
drivers/gpu/drm/vkms/vkms_writeback.c +1 -0
index 858df1f89f66..3407b5914694 100644
@@ -18,6 +18,7 @@
 static const u32 vkms_wb_formats[] = {
 	DRM_FORMAT_ARGB8888,
 	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_XBGR8888,
 	DRM_FORMAT_ABGR8888,
 	DRM_FORMAT_XRGB16161616,
 	DRM_FORMAT_ARGB16161616,
Signature · 1 line
2.56.0