From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jocelyn Falempe <jfalempe@redhat.com>,
Francesco Valla <francesco@valla.it>,
Javier Martinez Canillas <javierm@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888
Date: Mon, 06 Oct 2025 12:05:00 +0300 [thread overview]
Message-ID: <1793a882aba06d4b770799633b4443439d978679@intel.com> (raw)
In-Reply-To: <b026d815-dd6e-48a6-8efa-4631ed7cca9c@redhat.com>
On Mon, 06 Oct 2025, Jocelyn Falempe <jfalempe@redhat.com> wrote:
> On 10/6/25 08:48, Jani Nikula wrote:
>> On Sun, 05 Oct 2025, Francesco Valla <francesco@valla.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@valla.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
next prev parent reply other threads:[~2025-10-06 9:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-05 20:21 [PATCH 0/3] drm/draw: add check API to avoid spurious WARN Francesco Valla
2025-10-05 20:21 ` [PATCH 1/3] drm/draw: add drm_draw_can_convert_from_xrgb8888 Francesco Valla
2025-10-06 6:48 ` Jani Nikula
2025-10-06 8:06 ` Jocelyn Falempe
2025-10-06 9:05 ` Jani Nikula [this message]
2025-10-06 21:38 ` Francesco Valla
2025-10-05 20:21 ` [PATCH 2/3] drm/log: avoid WARN when searching for usable format Francesco Valla
2025-10-05 20:21 ` [PATCH 3/3] drm/log: avoid WARN when checking format support Francesco Valla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1793a882aba06d4b770799633b4443439d978679@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=francesco@valla.it \
--cc=javierm@redhat.com \
--cc=jfalempe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome