From: Louis Chauvet <louis.chauvet@bootlin.com>
To: "Maíra Canal" <mairacanal@riseup.net>
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>,
Melissa Wen <melissa.srw@gmail.com>,
Haneen Mohammed <hamohammed.sa@gmail.com>,
Daniel Vetter <daniel@ffwll.ch>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
dri-devel@lists.freedesktop.org, arthurgrillo@riseup.net,
linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com,
miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com,
seanpaul@google.com, nicolejadeyee@google.com
Subject: Re: [PATCH v2 2/3] drm/vkms: Add a macro for write_line functions
Date: Mon, 28 Oct 2024 10:50:36 +0100 [thread overview]
Message-ID: <Zx9ebKnJF6_vL4i9@fedora> (raw)
In-Reply-To: <2af1f9b4-0bc8-4585-ba13-d3b97e25845f@riseup.net>
On 26/10/24 - 12:08, Maíra Canal wrote:
> Hi Louis,
>
> On 14/08/24 05:42, Louis Chauvet wrote:
> > As stated in [2], the write_line functions are very similar and force code
>
> Where is [2]?
>
> > duplication. This patch add a macro to avoid code repetition.
> >
> > Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> > ---
> > drivers/gpu/drm/vkms/vkms_formats.c | 107 ++++++++++--------------------------
> > 1 file changed, 30 insertions(+), 77 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
> > index d1309f6d307f..a25cdf656d8a 100644
> > --- a/drivers/gpu/drm/vkms/vkms_formats.c
> > +++ b/drivers/gpu/drm/vkms/vkms_formats.c
> > @@ -654,6 +654,31 @@ static void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pi
> > *pixel = cpu_to_le16(r << 11 | g << 5 | b);
> > }
> > +/**
> > + * WRITE_LINE() - Generic generator for write_line functions
> > + *
> > + * This generator can only be used for format with only one plane and block_w == block_h == 1
> > + *
> > + * @function_name: Name to use for the generated function
> > + * @conversion_function: Fonction to use for the conversion from argb_u16 to the required format.
>
> s/Fonction/Function
>
> > + */
> > +#define WRITE_LINE(function_name, conversion_function) \
> > +static void function_name(struct vkms_writeback_job *wb, \
> > + struct pixel_argb_u16 *src_pixels, int count, int x_start, \
> > + int y_start) \
> > +{ \
> > + u8 *dst_pixels; \
> > + \
> > + packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels); \
> > + \
> > + while (count) { \
> > + (conversion_function)(dst_pixels, src_pixels); \
> > + dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0]; \
> > + src_pixels += 1; \
> > + count--; \
>
> Just a nit: What do you think about this loop?
>
> for (; count > 0; src_pixels++, count--)
>
> It doesn't really matter what option you pick.
I take this version, a bit shorter and not less explicit, thanks!
Thanks,
Louis Chauvet
> Best Regards,
> - Maíra
>
> > + } \
> > +}
> > +
> > /*
> > * The following functions are write_line function for each pixel format supported by VKMS.
> > *
> > @@ -667,85 +692,13 @@ static void argb_u16_to_RGB565(u8 *out_pixel, const struct pixel_argb_u16 *in_pi
> > * [1]: https://lore.kernel.org/dri-devel/d258c8dc-78e9-4509-9037-a98f7f33b3a3@riseup.net/
> > */
> > -static void ARGB8888_write_line(struct vkms_writeback_job *wb,
> > - struct pixel_argb_u16 *src_pixels, int count, int x_start,
> > - int y_start)
> > -{
> > - u8 *dst_pixels;
> > +WRITE_LINE(ARGB8888_write_line, argb_u16_to_ARGB8888)
> > +WRITE_LINE(XRGB8888_write_line, argb_u16_to_XRGB8888)
> > - packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels);
> > +WRITE_LINE(ARGB16161616_write_line, argb_u16_to_ARGB16161616)
> > +WRITE_LINE(XRGB16161616_write_line, argb_u16_to_XRGB16161616)
> > - while (count) {
> > - argb_u16_to_ARGB8888(dst_pixels, src_pixels);
> > - dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0];
> > - src_pixels += 1;
> > - count--;
> > - }
> > -}
> > -
> > -static void XRGB8888_write_line(struct vkms_writeback_job *wb,
> > - struct pixel_argb_u16 *src_pixels, int count, int x_start,
> > - int y_start)
> > -{
> > - u8 *dst_pixels;
> > -
> > - packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels);
> > -
> > - while (count) {
> > - argb_u16_to_XRGB8888(dst_pixels, src_pixels);
> > - dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0];
> > - src_pixels += 1;
> > - count--;
> > - }
> > -}
> > -
> > -static void ARGB16161616_write_line(struct vkms_writeback_job *wb,
> > - struct pixel_argb_u16 *src_pixels, int count, int x_start,
> > - int y_start)
> > -{
> > - u8 *dst_pixels;
> > -
> > - packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels);
> > -
> > - while (count) {
> > - argb_u16_to_ARGB16161616(dst_pixels, src_pixels);
> > - dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0];
> > - src_pixels += 1;
> > - count--;
> > - }
> > -}
> > -
> > -static void XRGB16161616_write_line(struct vkms_writeback_job *wb,
> > - struct pixel_argb_u16 *src_pixels, int count, int x_start,
> > - int y_start)
> > -{
> > - u8 *dst_pixels;
> > -
> > - packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels);
> > -
> > - while (count) {
> > - argb_u16_to_XRGB16161616(dst_pixels, src_pixels);
> > - dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0];
> > - src_pixels += 1;
> > - count--;
> > - }
> > -}
> > -
> > -static void RGB565_write_line(struct vkms_writeback_job *wb,
> > - struct pixel_argb_u16 *src_pixels, int count, int x_start,
> > - int y_start)
> > -{
> > - u8 *dst_pixels;
> > -
> > - packed_pixels_addr_1x1(&wb->wb_frame_info, x_start, y_start, 0, &dst_pixels);
> > -
> > - while (count) {
> > - argb_u16_to_RGB565(dst_pixels, src_pixels);
> > - dst_pixels += wb->wb_frame_info.fb->format->char_per_block[0];
> > - src_pixels += 1;
> > - count--;
> > - }
> > -}
> > +WRITE_LINE(RGB565_write_line, argb_u16_to_RGB565)
> > /**
> > * get_pixel_read_function() - Retrieve the correct read_line function for a specific
> >
next prev parent reply other threads:[~2024-10-28 9:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 8:42 [PATCH v2 0/3] drm/vkms: Reimplement line-per-line pixel conversion for writeback Louis Chauvet
2024-08-14 8:42 ` [PATCH v2 1/3] drm/vkms: Re-introduce line-by-line algorithm " Louis Chauvet
2024-10-26 15:05 ` Maíra Canal
2024-10-28 9:50 ` Louis Chauvet
2024-08-14 8:42 ` [PATCH v2 2/3] drm/vkms: Add a macro for write_line functions Louis Chauvet
2024-10-26 15:08 ` Maíra Canal
2024-10-28 9:50 ` Louis Chauvet [this message]
2024-08-14 8:42 ` [PATCH v2 3/3] drm/vkms: Add support for XRGB2101010 Louis Chauvet
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=Zx9ebKnJF6_vL4i9@fedora \
--to=louis.chauvet@bootlin.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=jeremie.dautheribes@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=melissa.srw@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=nicolejadeyee@google.com \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=seanpaul@google.com \
--cc=thomas.petazzoni@bootlin.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.