From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/9] drm/color-mgmt: Prepare for RGB332 palettes
Date: Fri, 11 Jul 2025 14:30:53 +0200 [thread overview]
Message-ID: <635a8207-c52b-4a02-9135-738d12d517a7@suse.de> (raw)
In-Reply-To: <87ple6ex00.fsf@minerva.mail-host-address-is-not-set>
Hi
Am 11.07.25 um 14:24 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
>
>> Add helper drm_crtc_fill_palette_332(), which fills palettes with
>> RGB332 color data. Each color in RGB332 format serves as an index
>> into an 8-bit palette that stores the corresponding component-based
>> colors.
>>
>> Vesadrm will use the new helper to emulate RGB formats on top of
>> framebuffers in C8 format.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>> drivers/gpu/drm/drm_color_mgmt.c | 32 ++++++++++++++++++++++++++++++++
>> include/drm/drm_color_mgmt.h | 1 +
>> 2 files changed, 33 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
>> index 37a3270bc3c2..7ef214848313 100644
>> --- a/drivers/gpu/drm/drm_color_mgmt.c
>> +++ b/drivers/gpu/drm/drm_color_mgmt.c
>> @@ -817,6 +817,38 @@ void drm_crtc_load_palette_8(struct drm_crtc *crtc, const struct drm_color_lut *
>> }
>> EXPORT_SYMBOL(drm_crtc_load_palette_8);
>>
>> +static void fill_palette_332(struct drm_crtc *crtc, u16 r, u16 g, u16 b,
>> + drm_crtc_set_lut_func set_palette)
>> +{
>> + unsigned int i = (r << 5) | (g << 2) | b;
>> +
>> + r = (r << 13) | (r << 10) | (r << 7) | (r << 4) | (r << 1) | (r >> 2);
>> + g = (g << 13) | (g << 10) | (g << 7) | (g << 4) | (g << 1) | (g >> 2);
>> + b = (b << 14) | (b << 12) | (b << 10) | (b << 8) | (b << 6) | (b << 4) | (b << 2) | b;
>> +
>> + set_palette(crtc, i, r, g, b);
>> +}
> I think this helper can benefit of having a kernel-doc or some code
> comments, e.g:
>
> /* Calculate the 8-bit palette index from the color components */
> unsigned int i = (r << 5) | (g << 2) | b;
>
> /* Expand R (3-bit) G (3-bit) and B (2-bit) values to 16-bit depth colors */
> r = (r << 13) | (r << 10) | (r << 7) | (r << 4) | (r << 1) | (r >> 2);
> g = (g << 13) | (g << 10) | (g << 7) | (g << 4) | (g << 1) | (g >> 2);
> b = (b << 14) | (b << 12) | (b << 10) | (b << 8) | (b << 6) | (b << 4) | (b << 2) | b;
>
> /* Call the drivers' specific callback to program the hardware LUT */
> set_palette(crtc, i, r, g, b);
>
> It might be evident to you, but I don't think it will be for others looking
> at the code later.
>
> The code itself looks good to me, if I understood it correctly :)
Thanks for reviewing. Commenting this code makes sense. I just looked
again at the r-g-b for loop and the limits are incorrect. Needs to by
3-3-2 instead of 8-8-4. IDK how that happened, as the screenshot from
the test looks correct.
https://imgur.com/a/vesadrm-day4-z2XQ4wA
Anyway that is another fix here.
Best regards
Thomas
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
next prev parent reply other threads:[~2025-07-11 12:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 14:23 [PATCH 0/9] drm/vesadrm: Support 8-bit palettes Thomas Zimmermann
2025-06-17 14:23 ` [PATCH 1/9] video: pixel_format: Add compare helpers Thomas Zimmermann
2025-07-11 11:55 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 2/9] video: screen_info: Add pixel-format helper for linear framebuffers Thomas Zimmermann
2025-07-11 11:58 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 3/9] drm/sysfb: Find screen_info format with helpers Thomas Zimmermann
2025-07-11 12:08 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 4/9] drm/sysfb: Blit to CRTC destination format Thomas Zimmermann
2025-07-11 12:10 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 5/9] drm/color-mgmt: Prepare for RGB332 palettes Thomas Zimmermann
2025-07-11 12:24 ` Javier Martinez Canillas
2025-07-11 12:30 ` Thomas Zimmermann [this message]
2025-07-14 7:13 ` Thomas Zimmermann
2025-06-17 14:23 ` [PATCH 6/9] drm/format-helper: Add XRGB8888-to-RGB332 to drm_fb_blit() Thomas Zimmermann
2025-07-11 12:25 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 7/9] drm/vesadrm: Rename vesadrm_set_gamma_lut() to vesadrm_set_color_lut() Thomas Zimmermann
2025-07-11 12:25 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 8/9] drm/vesadrm: Prepare color management for palette-based framebuffers Thomas Zimmermann
2025-07-11 12:26 ` Javier Martinez Canillas
2025-06-17 14:23 ` [PATCH 9/9] drm/vesadrm: Support DRM_FORMAT_C8 Thomas Zimmermann
2025-07-11 12:33 ` Javier Martinez Canillas
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=635a8207-c52b-4a02-9135-738d12d517a7@suse.de \
--to=tzimmermann@suse.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).