lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1793a882aba06d4b770799633b4443439d978679@intel.com>
Date: Mon, 06 Oct 2025 12:05:00 +0300
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Jocelyn Falempe <jfalempe@...hat.com>, Francesco Valla
 <francesco@...la.it>, Javier Martinez Canillas <javierm@...hat.com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
 <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David
 Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888

On Mon, 06 Oct 2025, Jocelyn Falempe <jfalempe@...hat.com> wrote:
> On 10/6/25 08:48, Jani Nikula wrote:
>> On Sun, 05 Oct 2025, Francesco Valla <francesco@...la.it> wrote:
>>> Add drm_draw_can_convert_from_xrgb8888() function that can be used to
>>> determine if a XRGB8888 color can be converted to the specified format.
>>>
>>> Signed-off-by: Francesco Valla <francesco@...la.it>
>>> ---
>>>   drivers/gpu/drm/drm_draw.c          | 84 +++++++++++++++++++++++++++----------
>>>   drivers/gpu/drm/drm_draw_internal.h |  2 +
>>>   2 files changed, 63 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_draw.c b/drivers/gpu/drm/drm_draw.c
>>> index 9dc0408fbbeadbe8282a2d6b210e0bfb0672967f..2641026a103d3b28cab9f5d378604b0604520fe4 100644
>>> --- a/drivers/gpu/drm/drm_draw.c
>>> +++ b/drivers/gpu/drm/drm_draw.c
>>> @@ -15,45 +15,83 @@
>>>   #include "drm_draw_internal.h"
>>>   #include "drm_format_internal.h"
>>>   
>>> -/**
>>> - * drm_draw_color_from_xrgb8888 - convert one pixel from xrgb8888 to the desired format
>>> - * @color: input color, in xrgb8888 format
>>> - * @format: output format
>>> - *
>>> - * Returns:
>>> - * Color in the format specified, casted to u32.
>>> - * Or 0 if the format is not supported.
>>> - */
>>> -u32 drm_draw_color_from_xrgb8888(u32 color, u32 format)
>>> +static int __drm_draw_color_from_xrgb8888(u32 color, u32 format, u32 *out_color)
>> 
>> Is there any reason to change the return value of this function and
>> return the result via out_color? It already returns 0 if the format is
>> not supported. If there's a reason, it needs to be in the commit
>> message.
>
> I think the problem is that 0, is also a valid color.

Right, of course.

> Maybe it would be better to split it into 2 functions, and duplicate the 
> switch case.
>
> ie:
>
> u32 drm_draw_color_from_xrgb8888(u32 color, u32 format)
> {
> 	switch(format) {
> 	case DRM_FORMAT_RGB565:
> 		return drm_pixel_xrgb8888_to_rgb565(color);
>
> ....
>
>
> bool drm_draw_can_convert_from_xrgb8888(u32 format)
> {
>
> 	switch(format) {
> 	case DRM_FORMAT_RGB565:
> 		return true;
>
> ....
> 	default:
> 		return false;
>
>
> I didn't do it this way, because there is a risk to add a format to only 
> one of the switch. But after more thinking, that would be simpler overall.

The duplication is a bit annoying, but it might be simpler. Dunno.

BR,
Jani.




>
> Best regards,

-- 
Jani Nikula, Intel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ