mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javierm@redhat.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Linux Fbdev development list" <linux-fbdev@vger.kernel.org>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Maxime Ripard" <maxime@cerno.tech>,
	"DRI Development" <dri-devel@lists.freedesktop.org>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@linux.ie>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>
Subject: Re: [PATCH v5 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
Date: Mon, 14 Feb 2022 09:57:21 +0100	[thread overview]
Message-ID: <e50211b1-08fa-de09-8948-664493423c33@redhat.com> (raw)
In-Reply-To: <CAMuHMdUeqXs2PeV9s8+edPpOGodRT=it3g+fOTB7DuTuW2J9ZA@mail.gmail.com>

Hello Geert,

Thanks for your feedback.

On 2/12/22 16:54, Geert Uytterhoeven wrote:

[snip]

>> +
>> +               for (i = start; i < end; i++) {
>> +                       unsigned int x = xb * 8 + i;
>> +
>> +                       byte >>= 1;
>> +                       if (src[x] >> 7)
>> +                               byte |= BIT(7);
>> +               }
> 
>     x = xb * 8;
>     for (i = start; i < end; i++) {
>             byte >>= 1;
>             byte |= src[x + i] & BIT(7);
>     }
> 

I think the original version from Noralf is easier to read and understand.

It makes explicit that the bit is set if the grayscale value is >= 128.

[snip]

>> +void drm_fb_xrgb8888_to_mono_reversed(void *dst, unsigned int dst_pitch, const void *vaddr,
>> +                                     const struct drm_framebuffer *fb, const struct drm_rect *clip)
>> +{

[snip]

>> +       u8 *mono = dst, *gray8;
>> +       u32 *src32;

[snip]

>> +        *
>> +        * Allocate a buffer to be used for both copying from the cma
>> +        * memory and to store the intermediate grayscale line pixels.
>> +        */
>> +       src32 = kmalloc(len_src32 + linepixels, GFP_KERNEL);
>> +       if (!src32)
>> +               return;
>> +
>> +       gray8 = (u8 *)src32 + len_src32;
> 
> The cast can be removed if src32 is changed to "void *".
> For symmetry, gray8 and mono can be changed to "void *", too.
>

Yes, but these being "u32 *" and "u8 *" also express that the source buffer
contains 32-bit XRGB8888 pixels, the intermediate buffer a 8-bit grayscale
pixel format and the destination buffer a 8-bit packed reversed monochrome.

Using "void *" for these would make that less clear when reading the code IMO.

Best regards,
-- 
Javier Martinez Canillas
Linux Engineering
Red Hat


  reply	other threads:[~2022-02-14  8:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 14:33 [PATCH v5 0/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-11 14:33 ` [PATCH v5 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() Javier Martinez Canillas
2022-02-11 15:58   ` Andy Shevchenko
2022-02-11 14:33 ` [PATCH v5 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed() Javier Martinez Canillas
2022-02-11 16:04   ` Andy Shevchenko
2022-02-12 15:54   ` Geert Uytterhoeven
2022-02-14  8:57     ` Javier Martinez Canillas [this message]
2022-02-11 14:33 ` [PATCH v5 3/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-11 16:13   ` Andy Shevchenko
2022-02-11 19:19     ` Javier Martinez Canillas
2022-02-12 11:59       ` Javier Martinez Canillas
2022-02-11 14:33 ` [PATCH v5 4/6] drm/solomon: Add SSD130x OLED displays I2C support Javier Martinez Canillas
2022-02-11 14:35 ` [PATCH v5 5/6] MAINTAINERS: Add entry for Solomon SSD130x OLED displays DRM driver Javier Martinez Canillas
2022-02-11 14:36 ` [PATCH v5 6/6] dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer 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=e50211b1-08fa-de09-8948-664493423c33@redhat.com \
    --to=javierm@redhat.com \
    --cc=airlied@linux.ie \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime@cerno.tech \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    --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

all inboxes | Powered by JetHome®