]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/st7571-i2c: add support for inverted pixel format
authorMarcus Folkesson <marcus.folkesson@gmail.com>
Mon, 21 Jul 2025 10:43:34 +0000 (12:43 +0200)
committerJavier Martinez Canillas <javierm@redhat.com>
Mon, 1 Sep 2025 13:26:44 +0000 (15:26 +0200)
Depending on which display that is connected to the controller, an
"1" means either a black or a white pixel.

The supported formats (R1/R2/XRGB8888) expects the pixels
to map against (4bit):
    00 => Black
    01 => Dark Gray
    10 => Light Gray
    11 => White

If this is not what the display map against, make it possible to invert
the pixels.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20250721-st7571-format-v2-4-159f4134098c@gmail.com
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
drivers/gpu/drm/sitronix/st7571-i2c.c

index 6f814294342855f0b9b4dea9c9625281422f75d8..807bea62d96e3c37dfeba827dab6470873438fd9 100644 (file)
@@ -151,6 +151,7 @@ struct st7571_device {
        bool ignore_nak;
 
        bool grayscale;
+       bool inverted;
        u32 height_mm;
        u32 width_mm;
        u32 startline;
@@ -792,6 +793,7 @@ static int st7567_parse_dt(struct st7571_device *st7567)
 
        of_property_read_u32(np, "width-mm", &st7567->width_mm);
        of_property_read_u32(np, "height-mm", &st7567->height_mm);
+       st7567->inverted = of_property_read_bool(np, "sitronix,inverted");
 
        st7567->pformat = &st7571_monochrome;
        st7567->bpp = 1;
@@ -819,6 +821,7 @@ static int st7571_parse_dt(struct st7571_device *st7571)
        of_property_read_u32(np, "width-mm", &st7571->width_mm);
        of_property_read_u32(np, "height-mm", &st7571->height_mm);
        st7571->grayscale = of_property_read_bool(np, "sitronix,grayscale");
+       st7571->inverted = of_property_read_bool(np, "sitronix,inverted");
 
        if (st7571->grayscale) {
                st7571->pformat = &st7571_grayscale;
@@ -873,7 +876,7 @@ static int st7567_lcd_init(struct st7571_device *st7567)
                ST7571_SET_POWER(0x6),  /* Power Control, VC: ON, VR: ON, VF: OFF */
                ST7571_SET_POWER(0x7),  /* Power Control, VC: ON, VR: ON, VF: ON */
 
-               ST7571_SET_REVERSE(0),
+               ST7571_SET_REVERSE(st7567->inverted ? 1 : 0),
                ST7571_SET_ENTIRE_DISPLAY_ON(0),
        };
 
@@ -917,7 +920,7 @@ static int st7571_lcd_init(struct st7571_device *st7571)
                ST7571_SET_COLOR_MODE(st7571->pformat->mode),
                ST7571_COMMAND_SET_NORMAL,
 
-               ST7571_SET_REVERSE(0),
+               ST7571_SET_REVERSE(st7571->inverted ? 1 : 0),
                ST7571_SET_ENTIRE_DISPLAY_ON(0),
        };