drivers/staging/fbtft/fb_ili9341.c | 3 +++ drivers/staging/fbtft/fbtft-core.c | 2 ++ drivers/staging/fbtft/fbtft.h | 3 +++ 3 files changed, 8 insertions(+)
Add devicetree parameter to enable or disable the invert feature of the
ili9341 display
Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org>
---
drivers/staging/fbtft/fb_ili9341.c | 3 +++
drivers/staging/fbtft/fbtft-core.c | 2 ++
drivers/staging/fbtft/fbtft.h | 3 +++
3 files changed, 8 insertions(+)
diff --git a/drivers/staging/fbtft/fb_ili9341.c b/drivers/staging/fbtft/fb_ili9341.c
index 47e72b87d76d996111aaadcf5e56dfdfc1c331ab..a184f57df12b5ad6612a2e83b664a8911c7c79be 100644
--- a/drivers/staging/fbtft/fb_ili9341.c
+++ b/drivers/staging/fbtft/fb_ili9341.c
@@ -103,6 +103,9 @@ static int set_var(struct fbtft_par *par)
break;
}
+ if (par->invert)
+ write_reg(par, 0x21);
+
return 0;
}
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index da9c64152a606dc4a176f5a37fa59f6a7d3a2af3..4e827e9899e32313f2e4a9bf12ff49283a63fed3 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -641,6 +641,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
par->buf = buf;
spin_lock_init(&par->dirty_lock);
par->bgr = pdata->bgr;
+ par->invert = pdata->invert;
par->startbyte = pdata->startbyte;
par->init_sequence = init_sequence;
par->gamma.curves = gamma_curves;
@@ -1107,6 +1108,7 @@ static struct fbtft_platform_data *fbtft_properties_read(struct device *dev)
pdata->display.bpp = fbtft_property_value(dev, "bpp");
pdata->display.debug = fbtft_property_value(dev, "debug");
pdata->rotate = fbtft_property_value(dev, "rotate");
+ pdata->invert = device_property_read_bool(dev, "invert");
pdata->bgr = device_property_read_bool(dev, "bgr");
pdata->fps = fbtft_property_value(dev, "fps");
pdata->txbuflen = fbtft_property_value(dev, "txbuflen");
diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index 317be17b95c1672404fc6aecda24d0a1f563685d..71c9c35e7548de314088ac3aeb160d6c6aaf75c9 100644
--- a/drivers/staging/fbtft/fbtft.h
+++ b/drivers/staging/fbtft/fbtft.h
@@ -125,6 +125,7 @@ struct fbtft_display {
* @display: Display properties
* @gpios: Pointer to an array of pinname to gpio mappings
* @rotate: Display rotation angle
+ * @invert: Invert display colors
* @bgr: LCD Controller BGR bit
* @fps: Frames per second (this will go away, use @fps in @fbtft_display)
* @txbuflen: Size of transmit buffer
@@ -135,6 +136,7 @@ struct fbtft_display {
struct fbtft_platform_data {
struct fbtft_display display;
unsigned int rotate;
+ bool invert;
bool bgr;
unsigned int fps;
int txbuflen;
@@ -229,6 +231,7 @@ struct fbtft_par {
bool first_update_done;
ktime_t update_time;
bool bgr;
+ bool invert;
void *extra;
bool polarity;
};
---
base-commit: 914873bc7df913db988284876c16257e6ab772c6
change-id: 20250528-ili9341-invert-dtb-07a5656e6dfd
Best regards,
--
Bram Vlerick <bram.vlerick@openpixelsystems.org>
On Wed, May 28, 2025 at 05:42:30PM +0200, Bram Vlerick wrote: > Add devicetree parameter to enable or disable the invert feature of the > ili9341 display Can't/shouldn't this be done by userspace application? Why would someone want to invert the color by default. Also, this driver is built on top of the deprecated framebuffer, it will never get out of staging/. For new feature, you probably want to send it to drivers/gpu/drm/panel/panel-ilitek-ili9341.c instead. > Signed-off-by: Bram Vlerick <bram.vlerick@openpixelsystems.org> > --- > drivers/staging/fbtft/fb_ili9341.c | 3 +++ > drivers/staging/fbtft/fbtft-core.c | 2 ++ > drivers/staging/fbtft/fbtft.h | 3 +++ > 3 files changed, 8 insertions(+) > > diff --git a/drivers/staging/fbtft/fb_ili9341.c b/drivers/staging/fbtft/fb_ili9341.c > index 47e72b87d76d996111aaadcf5e56dfdfc1c331ab..a184f57df12b5ad6612a2e83b664a8911c7c79be 100644 > --- a/drivers/staging/fbtft/fb_ili9341.c > +++ b/drivers/staging/fbtft/fb_ili9341.c > @@ -103,6 +103,9 @@ static int set_var(struct fbtft_par *par) > break; > } > > + if (par->invert) > + write_reg(par, 0x21); Use MIPI_DCS_ENTER_INVERT_MODE instead of the magic number. Best regards, Nam
On Wed, May 28, 2025 at 05:42:30PM +0200, Bram Vlerick wrote: > Add devicetree parameter to enable or disable the invert feature of the > ili9341 display > This commit message is so unclear. The parameter doesn't let you --and this is a direct quote. LOL-- "disable the invert feature". It would be better to say "Add devicetree parameter to invert the display on a ili9341 device." regards, dan carpenter
© 2016 - 2026 Red Hat, Inc.