lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMuHMdUsP5gcTyvqJM4OUFL3VutzDrX-V23uYRfnfgzotD8+rg@mail.gmail.com>
Date: Thu, 24 Apr 2025 10:38:33 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Marcus Folkesson <marcus.folkesson@...il.com>
Cc: David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, 
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>, 
	Thomas Zimmermann <tzimmermann@...e.de>, Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, 
	dri-devel@...ts.freedesktop.org, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Thomas Zimmermann <tzimmrmann@...e.de>, 
	Javier Martinez Canillas <javierm@...hat.com>
Subject: Re: [PATCH v6 2/3] drm/st7571-i2c: add support for Sitronix ST7571
 LCD controller

Hi Marcus,

On Wed, 23 Apr 2025 at 21:04, Marcus Folkesson
<marcus.folkesson@...il.com> wrote:
> Sitronix ST7571 is a 4bit gray scale dot matrix LCD controller.
> The controller has a SPI, I2C and 8bit parallel interface, this
> driver is for the I2C interface only.
>
> Reviewed-by: Thomas Zimmermann <tzimmrmann@...e.de>
> Reviewed-by: Javier Martinez Canillas <javierm@...hat.com>
> Signed-off-by: Marcus Folkesson <marcus.folkesson@...il.com>

Thanks for your patch, which is now commit 4b35f0f41ee29505
("drm/st7571-i2c: add support for Sitronix ST7571 LCD controller")
in drm-misc-next.

> --- /dev/null
> +++ b/drivers/gpu/drm/tiny/st7571-i2c.c

> +static int st7571_fb_update_rect_grayscale(struct drm_framebuffer *fb, struct drm_rect *rect)
> +{
> +       struct st7571_device *st7571 = drm_to_st7571(fb->dev);
> +       u32 format = fb->format->format;
> +       char *row = st7571->row;
> +       int x1;
> +       int x2;
> +
> +       /* Align y to display page boundaries */
> +       rect->y1 = round_down(rect->y1, ST7571_PAGE_HEIGHT);
> +       rect->y2 = min_t(unsigned int, round_up(rect->y2, ST7571_PAGE_HEIGHT), st7571->nlines);
> +
> +       switch (format) {
> +       case DRM_FORMAT_XRGB8888:
> +               /* Threated as monochrome (R1) */
> +               fallthrough;
> +       case DRM_FORMAT_R1:
> +               x1 = rect->x1;
> +               x2 = rect->x2;
> +               break;
> +       case DRM_FORMAT_R2:
> +               x1 = rect->x1 * 2;
> +               x2 = rect->x2 * 2;
> +               break;
> +       }
> +
> +       for (int y = rect->y1; y < rect->y2; y += ST7571_PAGE_HEIGHT) {
> +               for (int x = x1; x < x2; x++)
> +                       row[x] = st7571_transform_xy(st7571->hwbuf, x, y);
> +
> +               st7571_set_position(st7571, rect->x1, y);
> +
> +               /* TODO: Investige why we can't write multiple bytes at once */
> +               for (int x = x1; x < x2; x++) {
> +                       regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, row + x, 1);
> +
> +                       /*
> +                        * As the display supports grayscale, all pixels must be written as two bits
> +                        * even if the format is monochrome.
> +                        *
> +                        * The bit values maps to the following grayscale:
> +                        * 0 0 = White
> +                        * 0 1 = Light gray
> +                        * 1 0 = Dark gray
> +                        * 1 1 = Black

That is not R2, but D2?
include/uapi/drm/drm_fourcc.h:

    /* 2 bpp Red (direct relationship between channel value and brightness) */
    #define DRM_FORMAT_R2             fourcc_code('R', '2', ' ', ' ')
/* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */

    /* 2 bpp Darkness (inverse relationship between channel value and
brightness) */
    #define DRM_FORMAT_D2             fourcc_code('D', '2', ' ', ' ')
/* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */

So the driver actually supports D1 and D2, and XRGB8888 should be
inverted while converting to monochrome (and grayscale, which is not
yet implemented).

> +                        *
> +                        * For monochrome formats, write the same value twice to get
> +                        * either a black or white pixel.
> +                        */
> +                       if (format == DRM_FORMAT_R1 || format == DRM_FORMAT_XRGB8888)
> +                               regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, row + x, 1);
> +               }
> +       }
> +
> +       return 0;
> +}

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ