[PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats

Louis Chauvet posted 8 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats
Posted by Louis Chauvet 6 months, 2 weeks ago
The formats XRGB8888 and ARGB8888 were already supported.
Add the support for:
- XBGR8888
- RGBX8888
- BGRX8888
- ABGR8888
- RGBA8888
- BGRA8888

Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
 drivers/gpu/drm/vkms/vkms_formats.c | 19 +++++++++++++++++--
 drivers/gpu/drm/vkms/vkms_plane.c   |  7 ++++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
index a9c624081dac..f5c52c3d10a3 100644
--- a/drivers/gpu/drm/vkms/vkms_formats.c
+++ b/drivers/gpu/drm/vkms/vkms_formats.c
@@ -432,9 +432,14 @@ static void R4_read_line(const struct vkms_plane_state *plane, int x_start,
 
 
 READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0])
+READ_LINE_ARGB8888(XBGR8888_read_line, px, 0xFF, px[0], px[1], px[2])
+READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1])
+READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3])
 
 READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0])
 READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2])
+READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1])
+READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3])
 
 READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0])
 READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0])
@@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format)
 	switch (format) {
 	case DRM_FORMAT_ARGB8888:
 		return &ARGB8888_read_line;
-	case DRM_FORMAT_XRGB8888:
-		return &XRGB8888_read_line;
 	case DRM_FORMAT_ABGR8888:
 		return &ABGR8888_read_line;
+	case DRM_FORMAT_BGRA8888:
+		return &BGRA8888_read_line;
+	case DRM_FORMAT_RGBA8888:
+		return &RGBA8888_read_line;
+	case DRM_FORMAT_XRGB8888:
+		return &XRGB8888_read_line;
+	case DRM_FORMAT_XBGR8888:
+		return &XBGR8888_read_line;
+	case DRM_FORMAT_RGBX8888:
+		return &RGBX8888_read_line;
+	case DRM_FORMAT_BGRX8888:
+		return &BGRX8888_read_line;
 	case DRM_FORMAT_ARGB16161616:
 		return &ARGB16161616_read_line;
 	case DRM_FORMAT_XRGB16161616:
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index e3fdd161d0f0..b7f498944c50 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -14,8 +14,13 @@
 
 static const u32 vkms_formats[] = {
 	DRM_FORMAT_ARGB8888,
-	DRM_FORMAT_XRGB8888,
 	DRM_FORMAT_ABGR8888,
+	DRM_FORMAT_BGRA8888,
+	DRM_FORMAT_RGBA8888,
+	DRM_FORMAT_XRGB8888,
+	DRM_FORMAT_XBGR8888,
+	DRM_FORMAT_RGBX8888,
+	DRM_FORMAT_BGRX8888,
 	DRM_FORMAT_XRGB16161616,
 	DRM_FORMAT_ARGB16161616,
 	DRM_FORMAT_RGB565,

-- 
2.49.0
Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats
Posted by Maíra Canal 6 months, 1 week ago
Hi Louis,

On 5/30/25 11:05, Louis Chauvet wrote:
> The formats XRGB8888 and ARGB8888 were already supported.
> Add the support for:
> - XBGR8888
> - RGBX8888
> - BGRX8888
> - ABGR8888
> - RGBA8888
> - BGRA8888
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---

[...]

> +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1])
> +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3])

How did you test those two formats? I noticed that IGT (kms_plane tests)
doesn't test them.

Best Regards,
- Maíra

>   
>   READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0])
>   READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2])
> +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1])
> +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3])
>   
>   READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0])
>   READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0])
> @@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format)
>   	switch (format) {
>   	case DRM_FORMAT_ARGB8888:
>   		return &ARGB8888_read_line;
> -	case DRM_FORMAT_XRGB8888:
> -		return &XRGB8888_read_line;
>   	case DRM_FORMAT_ABGR8888:
>   		return &ABGR8888_read_line;
> +	case DRM_FORMAT_BGRA8888:
> +		return &BGRA8888_read_line;
> +	case DRM_FORMAT_RGBA8888:
> +		return &RGBA8888_read_line;
> +	case DRM_FORMAT_XRGB8888:
> +		return &XRGB8888_read_line;
> +	case DRM_FORMAT_XBGR8888:
> +		return &XBGR8888_read_line;
> +	case DRM_FORMAT_RGBX8888:
> +		return &RGBX8888_read_line;
> +	case DRM_FORMAT_BGRX8888:
> +		return &BGRX8888_read_line;
>   	case DRM_FORMAT_ARGB16161616:
>   		return &ARGB16161616_read_line;
>   	case DRM_FORMAT_XRGB16161616:
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index e3fdd161d0f0..b7f498944c50 100644
> --- a/drivers/gpu/drm/vkms/vkms_plane.c
> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
> @@ -14,8 +14,13 @@
>   
>   static const u32 vkms_formats[] = {
>   	DRM_FORMAT_ARGB8888,
> -	DRM_FORMAT_XRGB8888,
>   	DRM_FORMAT_ABGR8888,
> +	DRM_FORMAT_BGRA8888,
> +	DRM_FORMAT_RGBA8888,
> +	DRM_FORMAT_XRGB8888,
> +	DRM_FORMAT_XBGR8888,
> +	DRM_FORMAT_RGBX8888,
> +	DRM_FORMAT_BGRX8888,
>   	DRM_FORMAT_XRGB16161616,
>   	DRM_FORMAT_ARGB16161616,
>   	DRM_FORMAT_RGB565,
> 

Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats
Posted by Louis Chauvet 6 months ago

Le 11/06/2025 à 21:55, Maíra Canal a écrit :
> Hi Louis,
> 
> On 5/30/25 11:05, Louis Chauvet wrote:
>> The formats XRGB8888 and ARGB8888 were already supported.
>> Add the support for:
>> - XBGR8888
>> - RGBX8888
>> - BGRX8888
>> - ABGR8888
>> - RGBA8888
>> - BGRA8888
>>
>> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
>> ---
> 
> [...]
> 
>> +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1])
>> +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3])
> 
> How did you test those two formats? I noticed that IGT (kms_plane tests)
> doesn't test them.

Hi Maíra,

Thanks for your review!

I wrote this a long time ago, so I don't remember. I was probably greedy 
and added all the "trivial" formats I was able to do and missed that 
this format was not tested.

For this revision, I just started kms_plane to check if it was happy 
after the rebase, I did not check the formats one by one.

Do you want me to remove those formats? I think it costs nothing to keep 
them, especially with the new READ_LINE_ARGB8888 macro, but I will 
comply if you think we should only merge tested formats.

Thanks,
Louis Chauvet

> Best Regards,
> - Maíra
> 
>>    
>>    READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0])
>>    READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2])
>> +READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1])
>> +READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3])
>>    
>>    READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0])
>>    READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0])
>> @@ -644,10 +649,20 @@ pixel_read_line_t get_pixel_read_line_function(u32 format)
>>    	switch (format) {
>>    	case DRM_FORMAT_ARGB8888:
>>    		return &ARGB8888_read_line;
>> -	case DRM_FORMAT_XRGB8888:
>> -		return &XRGB8888_read_line;
>>    	case DRM_FORMAT_ABGR8888:
>>    		return &ABGR8888_read_line;
>> +	case DRM_FORMAT_BGRA8888:
>> +		return &BGRA8888_read_line;
>> +	case DRM_FORMAT_RGBA8888:
>> +		return &RGBA8888_read_line;
>> +	case DRM_FORMAT_XRGB8888:
>> +		return &XRGB8888_read_line;
>> +	case DRM_FORMAT_XBGR8888:
>> +		return &XBGR8888_read_line;
>> +	case DRM_FORMAT_RGBX8888:
>> +		return &RGBX8888_read_line;
>> +	case DRM_FORMAT_BGRX8888:
>> +		return &BGRX8888_read_line;
>>    	case DRM_FORMAT_ARGB16161616:
>>    		return &ARGB16161616_read_line;
>>    	case DRM_FORMAT_XRGB16161616:
>> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
>> index e3fdd161d0f0..b7f498944c50 100644
>> --- a/drivers/gpu/drm/vkms/vkms_plane.c
>> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
>> @@ -14,8 +14,13 @@
>>    
>>    static const u32 vkms_formats[] = {
>>    	DRM_FORMAT_ARGB8888,
>> -	DRM_FORMAT_XRGB8888,
>>    	DRM_FORMAT_ABGR8888,
>> +	DRM_FORMAT_BGRA8888,
>> +	DRM_FORMAT_RGBA8888,
>> +	DRM_FORMAT_XRGB8888,
>> +	DRM_FORMAT_XBGR8888,
>> +	DRM_FORMAT_RGBX8888,
>> +	DRM_FORMAT_BGRX8888,
>>    	DRM_FORMAT_XRGB16161616,
>>    	DRM_FORMAT_ARGB16161616,
>>    	DRM_FORMAT_RGB565,
>>
> 

-- 
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Re: [PATCH v4 2/8] drm/vkms: Add support for ARGB8888 formats
Posted by Maíra Canal 5 months, 4 weeks ago
Hi Louis,

On 13/06/25 14:28, Louis Chauvet wrote:
> 
> 
> Le 11/06/2025 à 21:55, Maíra Canal a écrit :
>> Hi Louis,
>>
>> On 5/30/25 11:05, Louis Chauvet wrote:
>>> The formats XRGB8888 and ARGB8888 were already supported.
>>> Add the support for:
>>> - XBGR8888
>>> - RGBX8888
>>> - BGRX8888
>>> - ABGR8888
>>> - RGBA8888
>>> - BGRA8888
>>>
>>> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
>>> ---
>>
>> [...]
>>
>>> +READ_LINE_ARGB8888(RGBX8888_read_line, px, 0xFF, px[3], px[2], px[1])
>>> +READ_LINE_ARGB8888(BGRX8888_read_line, px, 0xFF, px[1], px[2], px[3])
>>
>> How did you test those two formats? I noticed that IGT (kms_plane tests)
>> doesn't test them.
> 
> Hi Maíra,
> 
> Thanks for your review!
> 
> I wrote this a long time ago, so I don't remember. I was probably greedy 
> and added all the "trivial" formats I was able to do and missed that 
> this format was not tested.
> 
> For this revision, I just started kms_plane to check if it was happy 
> after the rebase, I did not check the formats one by one.
> 
> Do you want me to remove those formats? I think it costs nothing to keep 
> them, especially with the new READ_LINE_ARGB8888 macro, but I will 
> comply if you think we should only merge tested formats.

If we don't have a use-case for those formats and we haven't tested
them, I can't see a compelling reason to keep them. Otherwise, we might
keep untested/unused code around that might stale over time.

Best Regards,
- Maíra

> 
> Thanks,
> Louis Chauvet
> 
>> Best Regards,
>> - Maíra
>>