From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Thomas Zimmermann <tzimmermann@suse.de>,
Maxime Ripard <mripard@kernel.org>,
Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc()
Date: Wed, 12 Jul 2023 12:24:16 +0200 [thread overview]
Message-ID: <CAMuHMdWbQ8VAVPdLLpgV97=uY85-PfKWMmzyXpFZ6d=iJ2JOAQ@mail.gmail.com> (raw)
In-Reply-To: <20230609170941.1150941-6-javierm@redhat.com>
Hi Javier,
Thanks for your patch!
On Fri, Jun 9, 2023 at 7:09 PM Javier Martinez Canillas
<javierm@redhat.com> wrote:
> The driver only supports OLED controllers that have a native DRM_FORMAT_C1
DRM_FORMAT_R1 (colormap is fixed to white-on-black).
> pixel format and that is why it has harcoded a division of the width by 8.
hardcoded.
> But the driver might be extended to support devices that have a different
> pixel format. So it's better to use the struct drm_format_info helpers to
> compute the size of the buffer, used to store the pixels in native format.
>
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> --- a/drivers/gpu/drm/solomon/ssd130x.c
> +++ b/drivers/gpu/drm/solomon/ssd130x.c
> @@ -150,9 +150,16 @@ static int ssd130x_buf_alloc(struct ssd130x_device *ssd130x)
> {
> unsigned int page_height = ssd130x->device_info->page_height;
> unsigned int pages = DIV_ROUND_UP(ssd130x->height, page_height);
> + const struct drm_format_info *fi;
> + unsigned int pitch;
>
> - ssd130x->buffer = kcalloc(DIV_ROUND_UP(ssd130x->width, 8),
> - ssd130x->height, GFP_KERNEL);
> + fi = drm_format_info(DRM_FORMAT_C1);
DRM_FORMAT_R1.
> + if (!fi)
> + return -EINVAL;
> +
> + pitch = drm_format_info_min_pitch(fi, 0, ssd130x->width);
> +
> + ssd130x->buffer = kcalloc(pitch, ssd130x->height, GFP_KERNEL);
> if (!ssd130x->buffer)
> return -ENOMEM;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2023-07-12 10:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 17:09 [PATCH v2 0/5] drm/ssd130x: A few enhancements and cleanups Javier Martinez Canillas
2023-06-09 17:09 ` [PATCH v2 1/5] drm/ssd130x: Make default width and height to be controller dependent Javier Martinez Canillas
2023-06-09 17:09 ` [PATCH v2 2/5] dt-bindings: display: ssd1307fb: Remove default width and height values Javier Martinez Canillas
2023-06-10 15:10 ` Conor Dooley
2023-06-10 17:51 ` Javier Martinez Canillas
2023-06-10 18:14 ` Conor Dooley
2023-06-10 23:18 ` Javier Martinez Canillas
2023-06-12 7:47 ` Thomas Zimmermann
2023-06-12 17:44 ` Conor Dooley
2023-06-12 18:30 ` Javier Martinez Canillas
2023-06-09 17:09 ` [PATCH v2 3/5] drm/ssd130x: Set the page height value in the device info data Javier Martinez Canillas
2023-06-09 17:09 ` [PATCH v2 4/5] drm/ssd130x: Don't allocate buffers on each plane update Javier Martinez Canillas
2023-07-13 12:44 ` Geert Uytterhoeven
2023-07-13 13:15 ` Javier Martinez Canillas
2023-07-13 13:25 ` Geert Uytterhoeven
2023-07-13 14:12 ` Javier Martinez Canillas
2023-07-13 14:53 ` Geert Uytterhoeven
2023-07-13 16:34 ` Javier Martinez Canillas
2023-06-09 17:09 ` [PATCH v2 5/5] drm/ssd130x: Remove hardcoded bits-per-pixel in ssd130x_buf_alloc() Javier Martinez Canillas
2023-07-12 10:24 ` Geert Uytterhoeven [this message]
2023-06-15 21:53 ` [PATCH v2 0/5] drm/ssd130x: A few enhancements and cleanups 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='CAMuHMdWbQ8VAVPdLLpgV97=uY85-PfKWMmzyXpFZ6d=iJ2JOAQ@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).