aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2017-03-10 09:15:19 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-17 02:10:49 -0400
commit1d3b2af213902059d9f4b35eb15b53f8062dc3b3 (patch)
treef887a0ffced8b09515f52e84aaca5774b6dee40d
parentac201479cc695cb0140e425b9ca8ab2ecdcd2f0d (diff)
auxdisplay: charlcd: Add support for displays with more than two lines
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/auxdisplay/charlcd.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index b3a84e90a268..cfeb049a01ef 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -159,15 +159,19 @@ EXPORT_SYMBOL_GPL(charlcd_poke);
159static void charlcd_gotoxy(struct charlcd *lcd) 159static void charlcd_gotoxy(struct charlcd *lcd)
160{ 160{
161 struct charlcd_priv *priv = to_priv(lcd); 161 struct charlcd_priv *priv = to_priv(lcd);
162 unsigned int addr;
162 163
163 lcd->ops->write_cmd(lcd, 164 /*
164 LCD_CMD_SET_DDRAM_ADDR | (priv->addr.y ? lcd->hwidth : 0) | 165 * we force the cursor to stay at the end of the
165 /* 166 * line if it wants to go farther
166 * we force the cursor to stay at the end of the 167 */
167 * line if it wants to go farther 168 addr = priv->addr.x < lcd->bwidth ? priv->addr.x & (lcd->hwidth - 1)
168 */ 169 : lcd->bwidth - 1;
169 ((priv->addr.x < lcd->bwidth) ? priv->addr.x & (lcd->hwidth - 1) 170 if (priv->addr.y & 1)
170 : lcd->bwidth - 1)); 171 addr += lcd->hwidth;
172 if (priv->addr.y & 2)
173 addr += lcd->bwidth;
174 lcd->ops->write_cmd(lcd, LCD_CMD_SET_DDRAM_ADDR | addr);
171} 175}
172 176
173static void charlcd_home(struct charlcd *lcd) 177static void charlcd_home(struct charlcd *lcd)
@@ -203,7 +207,7 @@ static void charlcd_clear_fast(struct charlcd *lcd)
203 if (lcd->ops->clear_fast) 207 if (lcd->ops->clear_fast)
204 lcd->ops->clear_fast(lcd); 208 lcd->ops->clear_fast(lcd);
205 else 209 else
206 for (pos = 0; pos < lcd->height * lcd->hwidth; pos++) 210 for (pos = 0; pos < min(2, lcd->height) * lcd->hwidth; pos++)
207 lcd->ops->write_data(lcd, ' '); 211 lcd->ops->write_data(lcd, ' ');
208 212
209 charlcd_home(lcd); 213 charlcd_home(lcd);