From: Javier Martinez Canillas <javierm@redhat.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Linux Fbdev development list" <linux-fbdev@vger.kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Daniel Vetter" <daniel.vetter@ffwll.ch>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Sam Ravnborg" <sam@ravnborg.org>,
"DRI Development" <dri-devel@lists.freedesktop.org>,
"Maxime Ripard" <maxime@cerno.tech>,
"Noralf Trønnes" <noralf@tronnes.org>,
"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 v6 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()
Date: Wed, 9 Mar 2022 13:03:05 +0100 [thread overview]
Message-ID: <809430bb-4ffb-3bd4-7062-ec8b78245387@redhat.com> (raw)
In-Reply-To: <CAMuHMdWZHBVwaLDi-B=PrVOfcHxGLxwgDBisvexE94x72qvdJg@mail.gmail.com>
Hello Geert,
Thanks a lot for your feedback.
On 3/8/22 17:13, Geert Uytterhoeven wrote:
[snip]
>> +
>> +static void drm_fb_gray8_to_mono_reversed_line(u8 *dst, const u8 *src, unsigned int pixels,
>
> "pixels" is not the number of pixels to process, but the number of
> bytes in the monochrome destination buffer.
>
Right, that parameter name is misleading / incorrect indeed. Probably
should be changed by dst_pitch or dst_stride.
>> + unsigned int start_offset, unsigned int end_len)
>> +{
>> + unsigned int xb, i;
>> +
>> + for (xb = 0; xb < pixels; xb++) {
>> + unsigned int start = 0, end = 8;
>> + u8 byte = 0x00;
>> +
>> + if (xb == 0 && start_offset)
>> + start = start_offset;
>> +
>> + if (xb == pixels - 1 && end_len)
>> + end = end_len;
>> +
>> + for (i = start; i < end; i++) {
>> + unsigned int x = xb * 8 + i;
>> +
>> + byte >>= 1;
>> + if (src[x] >> 7)
>> + byte |= BIT(7);
>> + }
>> + *dst++ = byte;
>> + }
>
> The above is IMHO very hard to read.
> I think it can be made simpler by passing the total number of pixels
> to process instead of "pixels" (which is bytes) and "end_len".
>
Agreed that's hard to read. I think is better if you propose a patch
with your idea to make it simpler.
[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)
>> +{
>> + unsigned int linepixels = drm_rect_width(clip);
>> + unsigned int lines = clip->y2 - clip->y1;
>
> drm_rect_height(clip)?
>
Yes, unsure why didn't use it since used drm_rect_width() for the width.
>> + unsigned int cpp = fb->format->cpp[0];
>> + unsigned int len_src32 = linepixels * cpp;
>> + struct drm_device *dev = fb->dev;
>> + unsigned int start_offset, end_len;
>> + unsigned int y;
>> + u8 *mono = dst, *gray8;
>> + u32 *src32;
>> +
>> + if (drm_WARN_ON(dev, fb->format->format != DRM_FORMAT_XRGB8888))
>> + return;
>> +
>> + /*
>> + * The reversed mono destination buffer contains 1 bit per pixel
>> + * and destination scanlines have to be in multiple of 8 pixels.
>> + */
>> + if (!dst_pitch)
>> + dst_pitch = DIV_ROUND_UP(linepixels, 8);
>
> This is not correct when clip->x1 is not a multiple of 8 pixels.
> Should be:
>
> DIV_ROUND_UP(linepixels + clip->x1 % 8, 8);
>
Agreed.
>> +
>> + drm_WARN_ONCE(dev, dst_pitch % 8 != 0, "dst_pitch is not a multiple of 8\n");
>
> This triggers for me: dst_pitch = 1.
> Which is perfectly fine, when flashing an 8-pixel wide cursor ;-)
>
Indeed. I think we should just drop that warn.
Do you want me to post patches for all these or would you do it
when simplifying the drm_fb_gray8_to_mono_reversed_line() logic ?
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
next prev parent reply other threads:[~2022-03-09 12:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 13:37 [PATCH v6 0/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-14 13:37 ` [PATCH v6 1/6] drm/format-helper: Add drm_fb_xrgb8888_to_gray8_line() Javier Martinez Canillas
2022-02-16 9:16 ` Maxime Ripard
2022-02-14 13:37 ` [PATCH v6 2/6] drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed() Javier Martinez Canillas
2022-02-16 9:16 ` Maxime Ripard
2022-03-08 16:13 ` Geert Uytterhoeven
2022-03-09 12:03 ` Javier Martinez Canillas [this message]
2022-02-14 13:37 ` [PATCH v6 3/6] drm: Add driver for Solomon SSD130x OLED displays Javier Martinez Canillas
2022-02-16 9:16 ` Maxime Ripard
2022-03-08 16:30 ` Geert Uytterhoeven
2022-03-09 12:14 ` Javier Martinez Canillas
2022-03-09 12:56 ` Geert Uytterhoeven
2022-03-09 13:43 ` Javier Martinez Canillas
2022-03-09 20:04 ` Geert Uytterhoeven
2022-03-09 20:13 ` Javier Martinez Canillas
2022-02-14 13:37 ` [PATCH v6 4/6] drm/solomon: Add SSD130x OLED displays I2C support Javier Martinez Canillas
2022-02-16 9:17 ` Maxime Ripard
2022-02-14 13:39 ` [PATCH v6 5/6] MAINTAINERS: Add entry for Solomon SSD130x OLED displays DRM driver Javier Martinez Canillas
2022-02-16 9:17 ` Maxime Ripard
2022-02-14 13:39 ` [PATCH v6 6/6] dt-bindings: display: ssd1307fb: Add myself as binding co-maintainer Javier Martinez Canillas
2022-02-16 9:17 ` Maxime Ripard
2022-02-16 12:34 ` [PATCH v6 0/6] drm: Add driver for Solomon SSD130x OLED displays 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=809430bb-4ffb-3bd4-7062-ec8b78245387@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