Skip to content

Commit

Permalink
auxdisplay: charlcd: Add support for displays with more than two lines
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Geert Uytterhoeven authored and Greg Kroah-Hartman committed Mar 17, 2017
1 parent ac20147 commit 1d3b2af
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions drivers/auxdisplay/charlcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,19 @@ EXPORT_SYMBOL_GPL(charlcd_poke);
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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1d3b2af

Please sign in to comment.