Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1574860

[PATCH 11/13] auxdisplay: charlcd: Add support for displays with more than two lines

From Geert Uytterhoeven <geert@linux-m68k.org>
Newsgroups linux.kernel
Subject [PATCH 11/13] auxdisplay: charlcd: Add support for displays with more than two lines
Date 2017-02-06 15:50 +0100
Message-ID <t7SMb-6cu-35@gated-at.bofh.it> (permalink)
References <t7SCt-68H-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On displays with more than two lines, the additional lines are stored in
the buffers used for the first two lines, but beyond the visible parts.
Adjust the DDRAM address calculation to cater for this.

When clearing the display, avoid writing more spaces than the actual
size of the physical buffer.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/auxdisplay/charlcd.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 6d27d9363c9baaf2..6aea90086e3695c5 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -159,15 +159,19 @@ void charlcd_poke(struct charlcd *lcd)
 static void charlcd_gotoxy(struct charlcd *lcd)
 {
 	struct charlcd_priv *priv = to_priv(lcd);
+	unsigned int addr;
 
-	lcd->ops->write_cmd(lcd,
-		LCD_CMD_SET_DDRAM_ADDR | (priv->addr.y ? lcd->hwidth : 0) |
-		/*
-		 * we force the cursor to stay at the end of the
-		 * line if it wants to go farther
-		 */
-		((priv->addr.x < lcd->bwidth) ? priv->addr.x & (lcd->hwidth - 1)
-					      : lcd->bwidth - 1));
+	/*
+	 * we force the cursor to stay at the end of the
+	 * line if it wants to go farther
+	 */
+	addr = priv->addr.x < lcd->bwidth ? priv->addr.x & (lcd->hwidth - 1)
+					  : lcd->bwidth - 1;
+	if (priv->addr.y & 1)
+		addr += lcd->hwidth;
+	if (priv->addr.y & 2)
+		addr += lcd->bwidth;
+	lcd->ops->write_cmd(lcd, LCD_CMD_SET_DDRAM_ADDR | addr);
 }
 
 static void charlcd_home(struct charlcd *lcd)
@@ -203,7 +207,7 @@ static void charlcd_clear_fast(struct charlcd *lcd)
 	if (lcd->ops->clear_fast)
 		lcd->ops->clear_fast(lcd);
 	else
-		for (pos = 0; pos < lcd->height * lcd->hwidth; pos++)
+		for (pos = 0; pos < min(2, lcd->height) * lcd->hwidth; pos++)
 			lcd->ops->write_data(lcd, ' ');
 
 	charlcd_home(lcd);
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/13] Add HD44780 Character LCD support Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 03/13] misc: panel: Remove unused LCD_FLAG_S and LCD_FLAG_ID Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 05/13] misc: panel: Move all suboptions into a big if section Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 04/13] misc: panel: Remove reference to misc device support Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 06/13] misc: panel: Remove always-true check from panel_detach() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 11/13] auxdisplay: charlcd: Add support for displays with more than two lines Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  [PATCH 02/13] misc: panel: Remove PANEL_VERSION Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 15:50 +0100
  Re: [PATCH 09/13] auxdisplay: charlcd: Extract character LCD core  from misc/panel Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-06 16:20 +0100
  Re: [PATCH 09/13] auxdisplay: charlcd: Extract character LCD core  from misc/panel Arnd Bergmann <arnd@arndb.de> - 2017-02-06 16:20 +0100
  Re: [PATCH 00/13] Add HD44780 Character LCD support Willy TARREAU <wtarreau@haproxy.com> - 2017-02-06 16:50 +0100
  Re: [PATCH 09/13] auxdisplay: charlcd: Extract character LCD core  from misc/panel Geert Uytterhoeven <geert@linux-m68k.org> - 2017-02-08 13:30 +0100
  Re: [PATCH 00/13] Add HD44780 Character LCD support Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-10 15:40 +0100

csiph-web