Skip to contentSkip to conversation

Staging: fbtft: Fix wrong check in fbtft_write_wmem16_bus8()

PATCH In review Nicolas Saenz Julienne 3 participants 7 messages Jul 15, 2019 – Jul 25, 2019 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: fbtft: Fix wrong check in fbtft_write_wmem16_bus8()

We actually want to set the gpio pin if it's avilable, not the other way around.

Fixes c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface")
---
 drivers/staging/fbtft/fbtft-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-bus.c +1 -1
index 2ea814d0dca5..63c65dd67b17 100644
@@ -135,7 +135,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
 	remain = len / 2;
 	vmem16 = (u16 *)(par->info->screen_buffer + offset);
 
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 1);
 
 	/* non buffered write */
Signature · 1 line
2.22.0
#2 lore raw

Re: [PATCH] Staging: fbtft: Fix wrong check in,fbtft_write_wmem16_bus8()

In reply to a message not in the archive

Coincidentially, I've worked on the exact same issue this weekend. I can confirm this change is necessary, and with this and the other two patches from Phil Reid the driver works again. The same mistake occurred in several other locations, though. I'll send a patch fixing all of them.

I've tested this on a ili9486-based display connected to a raspberry pi 3b+.

Regards, Jan

Quoted 25 lines · On Mon, 15 Jul 2019 Nicolas Saenz Julienne wrote:

We actually want to set the gpio pin if it's avilable, not the other way around.

Fixes c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor

interface")

---
 drivers/staging/fbtft/fbtft-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-bus.c +1 -1
index 2ea814d0dca5..63c65dd67b17 100644
@@ -135,7 +135,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par,
 size_t offset, size_t len)
        remain = len / 2;
        vmem16 = (u16 *)(par->info->screen_buffer + offset);
 -      if (!par->gpio.dc)
+       if (par->gpio.dc)
                gpiod_set_value(par->gpio.dc, 1);
        /* non buffered write */
--

2.22.0

#3 lore raw

PATCH 1/1 Staging: fbtft: Fix GPIO handling

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") breaks GPIO handling. In several places, checks to only set a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486 display connected to a raspberry pi via SPI.

Fixes commit c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor interface")
---
 drivers/staging/fbtft/fb_bd663474.c  | 2 +-
 drivers/staging/fbtft/fb_ili9163.c   | 2 +-
 drivers/staging/fbtft/fb_ili9325.c   | 2 +-
 drivers/staging/fbtft/fb_s6d1121.c   | 2 +-
 drivers/staging/fbtft/fb_ssd1289.c   | 2 +-
 drivers/staging/fbtft/fb_ssd1331.c   | 4 ++--
 drivers/staging/fbtft/fb_upd161704.c | 2 +-
 drivers/staging/fbtft/fbtft-bus.c    | 2 +-
 drivers/staging/fbtft/fbtft-core.c   | 4 ++--
 9 files changed, 11 insertions(+), 11 deletions(-)
drivers/staging/fbtft/fb_bd663474.c +1 -1
index b6c6d66e4eb1..e2c7646588f8 100644
@@ -24,7 +24,7 @@
 
 static int init_display(struct fbtft_par *par)
 {
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	par->fbtftops.reset(par);
drivers/staging/fbtft/fb_ili9163.c +1 -1
index d609a2b67db9..fd32376700e2 100644
@@ -77,7 +77,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */
drivers/staging/fbtft/fb_ili9325.c +1 -1
index b090e7ab6fdd..85e54a10ed72 100644
@@ -85,7 +85,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	bt &= 0x07;
drivers/staging/fbtft/fb_s6d1121.c +1 -1
index b3d0701880fe..5a129b1352cc 100644
@@ -29,7 +29,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	/* Initialization sequence from Lib_UTFT */
drivers/staging/fbtft/fb_ssd1289.c +1 -1
index bbf75f795234..88a5b6925901 100644
@@ -28,7 +28,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	write_reg(par, 0x00, 0x0001);
drivers/staging/fbtft/fb_ssd1331.c +2 -2
index 4cfe9f8535d0..37622c9462aa 100644
@@ -81,7 +81,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 	va_start(args, len);
 
 	*buf = (u8)va_arg(args, unsigned int);
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 0);
 	ret = par->fbtftops.write(par, par->buf, sizeof(u8));
 	if (ret < 0) {
@@ -104,7 +104,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 			return;
 		}
 	}
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 1);
 	va_end(args);
 }
drivers/staging/fbtft/fb_upd161704.c +1 -1
index 564a38e34440..c77832ae5e5b 100644
@@ -26,7 +26,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	/* Initialization sequence from Lib_UTFT */
drivers/staging/fbtft/fbtft-bus.c +1 -1
index 2ea814d0dca5..63c65dd67b17 100644
@@ -135,7 +135,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
 	remain = len / 2;
 	vmem16 = (u16 *)(par->info->screen_buffer + offset);
 
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 1);
 
 	/* non buffered write */
drivers/staging/fbtft/fbtft-core.c +2 -2
index bc750250ccd6..5127de922f6a 100644
@@ -916,7 +916,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
 		return -EINVAL;
 
 	par->fbtftops.reset(par);
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	while (p) {
@@ -1007,7 +1007,7 @@ int fbtft_init_display(struct fbtft_par *par)
 	}
 
 	par->fbtftops.reset(par);
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	i = 0;
Signature · 1 line
2.21.0
author Reviewed-by on v1 1/1
#4 lore raw

Re: [PATCH] Staging: fbtft: Fix GPIO handling

Quoted 10 lines · Jan Sebastian Götte

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") breaks GPIO handling. In several places, checks to only set a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486 display connected to a raspberry pi via SPI.

Fixes commit c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor

interface")

Thanks Jan, this version is indeed more complete.

Regards,
Nicolas

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

#5 lore raw

PATCH v2 1/1 Staging: fbtft: Fix GPIO handling

In reply to Jan Sebastian Götte

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") breaks GPIO handling. In several places, checks to only set a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486 display connected to a raspberry pi via SPI.

Fixes commit c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor interface")
---
 drivers/staging/fbtft/fb_bd663474.c  | 2 +-
 drivers/staging/fbtft/fb_ili9163.c   | 2 +-
 drivers/staging/fbtft/fb_ili9325.c   | 2 +-
 drivers/staging/fbtft/fb_s6d1121.c   | 2 +-
 drivers/staging/fbtft/fb_ssd1289.c   | 2 +-
 drivers/staging/fbtft/fb_ssd1331.c   | 4 ++--
 drivers/staging/fbtft/fb_upd161704.c | 2 +-
 drivers/staging/fbtft/fbtft-bus.c    | 2 +-
 drivers/staging/fbtft/fbtft-core.c   | 4 ++--
 9 files changed, 11 insertions(+), 11 deletions(-)
drivers/staging/fbtft/fb_bd663474.c +1 -1
index b6c6d66e4eb1..e2c7646588f8 100644
@@ -24,7 +24,7 @@
 
 static int init_display(struct fbtft_par *par)
 {
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	par->fbtftops.reset(par);
drivers/staging/fbtft/fb_ili9163.c +1 -1
index d609a2b67db9..fd32376700e2 100644
@@ -77,7 +77,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */
drivers/staging/fbtft/fb_ili9325.c +1 -1
index b090e7ab6fdd..85e54a10ed72 100644
@@ -85,7 +85,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	bt &= 0x07;
drivers/staging/fbtft/fb_s6d1121.c +1 -1
index b3d0701880fe..5a129b1352cc 100644
@@ -29,7 +29,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	/* Initialization sequence from Lib_UTFT */
drivers/staging/fbtft/fb_ssd1289.c +1 -1
index bbf75f795234..88a5b6925901 100644
@@ -28,7 +28,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	write_reg(par, 0x00, 0x0001);
drivers/staging/fbtft/fb_ssd1331.c +2 -2
index 4cfe9f8535d0..37622c9462aa 100644
@@ -81,7 +81,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 	va_start(args, len);
 
 	*buf = (u8)va_arg(args, unsigned int);
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 0);
 	ret = par->fbtftops.write(par, par->buf, sizeof(u8));
 	if (ret < 0) {
@@ -104,7 +104,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 			return;
 		}
 	}
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 1);
 	va_end(args);
 }
drivers/staging/fbtft/fb_upd161704.c +1 -1
index 564a38e34440..c77832ae5e5b 100644
@@ -26,7 +26,7 @@ static int init_display(struct fbtft_par *par)
 {
 	par->fbtftops.reset(par);
 
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	/* Initialization sequence from Lib_UTFT */
drivers/staging/fbtft/fbtft-bus.c +1 -1
index 2ea814d0dca5..63c65dd67b17 100644
@@ -135,7 +135,7 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
 	remain = len / 2;
 	vmem16 = (u16 *)(par->info->screen_buffer + offset);
 
-	if (!par->gpio.dc)
+	if (par->gpio.dc)
 		gpiod_set_value(par->gpio.dc, 1);
 
 	/* non buffered write */
drivers/staging/fbtft/fbtft-core.c +2 -2
index bc750250ccd6..5127de922f6a 100644
@@ -916,7 +916,7 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
 		return -EINVAL;
 
 	par->fbtftops.reset(par);
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	while (p) {
@@ -1007,7 +1007,7 @@ int fbtft_init_display(struct fbtft_par *par)
 	}
 
 	par->fbtftops.reset(par);
-	if (!par->gpio.cs)
+	if (par->gpio.cs)
 		gpiod_set_value(par->gpio.cs, 0);  /* Activate chip */
 
 	i = 0;
Signature · 1 line
2.21.0
maintainer
#6 lore raw

Re: [PATCH v2] Staging: fbtft: Fix GPIO handling

Quoted 11 lines · Jan Sebastian Götte

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") breaks GPIO handling. In several places, checks to only set a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486 display connected to a raspberry pi via SPI.

Fixes commit c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor interface")

---

Can this go on top of Phil's patches? Or does it replace it?

I can't figure out what to do here, sorry.

thanks,

greg k-h

#7 lore raw

Re: [PATCH v2] Staging: fbtft: Fix GPIO handling

Quoted 7 lines · Greg KH
Quoted 6 lines · Jan Sebastian Götte

Commit c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") breaks GPIO handling. In several places, checks to only set a GPIO if it was configured ended up backwards.
I have tested this fix. The fixed driver works with a ili9486 display connected to a raspberry pi via SPI.

Quoted 8 lines
Quoted 6 lines
Fixes commit c440eee1a7a1d ("Staging: fbtft: Switch to the gpio descriptor

interface")

---

Can this go on top of Phil's patches? Or does it replace it?

This is needed on top of Phil patches.

Regards,
Nicolas

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel