diff options
Diffstat (limited to 'drivers/auxdisplay/hd44780_common.c')
-rw-r--r-- | drivers/auxdisplay/hd44780_common.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index 1dfcb2cdbc70..f86eb2f27cee 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -5,6 +5,9 @@ #include "charlcd.h" #include "hd44780_common.h" +/* LCD commands */ +#define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */ + int hd44780_common_print(struct charlcd *lcd, int c) { struct hd44780_common *hdc = lcd->drvdata; @@ -18,6 +21,26 @@ int hd44780_common_print(struct charlcd *lcd, int c) } EXPORT_SYMBOL_GPL(hd44780_common_print); +int hd44780_common_gotoxy(struct charlcd *lcd) +{ + struct hd44780_common *hdc = lcd->drvdata; + unsigned int addr; + + /* + * we force the cursor to stay at the end of the + * line if it wants to go farther + */ + addr = lcd->addr.x < hdc->bwidth ? lcd->addr.x & (hdc->hwidth - 1) + : hdc->bwidth - 1; + if (lcd->addr.y & 1) + addr += hdc->hwidth; + if (lcd->addr.y & 2) + addr += hdc->bwidth; + hdc->write_cmd(hdc, LCD_CMD_SET_DDRAM_ADDR | addr); + return 0; +} +EXPORT_SYMBOL_GPL(hd44780_common_gotoxy); + struct hd44780_common *hd44780_common_alloc(void) { struct hd44780_common *hd; |