Commit 88645a86 authored by Lars Poeschel's avatar Lars Poeschel Committed by Miguel Ojeda

auxdisplay: add home to charlcd_ops

This adds a home function to the charlcd_ops struct and offer an
implementation for hd44780_common. This implementation is used by our
two hd44780 drivers. This is to make charlcd device independent.
Reviewed-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarLars Poeschel <poeschel@lemonage.de>
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent d3a2fb81
...@@ -144,7 +144,7 @@ static void charlcd_home(struct charlcd *lcd) ...@@ -144,7 +144,7 @@ static void charlcd_home(struct charlcd *lcd)
{ {
lcd->addr.x = 0; lcd->addr.x = 0;
lcd->addr.y = 0; lcd->addr.y = 0;
lcd->ops->gotoxy(lcd); lcd->ops->home(lcd);
} }
static void charlcd_print(struct charlcd *lcd, char c) static void charlcd_print(struct charlcd *lcd, char c)
......
...@@ -41,12 +41,15 @@ struct charlcd { ...@@ -41,12 +41,15 @@ struct charlcd {
* wrap to the next line at the end of a line. * wrap to the next line at the end of a line.
* @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
* previously set in addr.x and addr.y by charlcd. * previously set in addr.x and addr.y by charlcd.
* @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
* charlcd prior to calling this function.
*/ */
struct charlcd_ops { struct charlcd_ops {
void (*clear_fast)(struct charlcd *lcd); void (*clear_fast)(struct charlcd *lcd);
void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on); void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
int (*print)(struct charlcd *lcd, int c); int (*print)(struct charlcd *lcd, int c);
int (*gotoxy)(struct charlcd *lcd); int (*gotoxy)(struct charlcd *lcd);
int (*home)(struct charlcd *lcd);
}; };
struct charlcd *charlcd_alloc(void); struct charlcd *charlcd_alloc(void);
......
...@@ -128,6 +128,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = { ...@@ -128,6 +128,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = {
.backlight = hd44780_backlight, .backlight = hd44780_backlight,
.print = hd44780_common_print, .print = hd44780_common_print,
.gotoxy = hd44780_common_gotoxy, .gotoxy = hd44780_common_gotoxy,
.home = hd44780_common_home,
}; };
/* Send a command to the LCD panel in 4 bit GPIO mode */ /* Send a command to the LCD panel in 4 bit GPIO mode */
...@@ -173,6 +174,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = { ...@@ -173,6 +174,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = {
.backlight = hd44780_backlight, .backlight = hd44780_backlight,
.print = hd44780_common_print, .print = hd44780_common_print,
.gotoxy = hd44780_common_gotoxy, .gotoxy = hd44780_common_gotoxy,
.home = hd44780_common_home,
}; };
static int hd44780_probe(struct platform_device *pdev) static int hd44780_probe(struct platform_device *pdev)
......
...@@ -41,6 +41,14 @@ int hd44780_common_gotoxy(struct charlcd *lcd) ...@@ -41,6 +41,14 @@ int hd44780_common_gotoxy(struct charlcd *lcd)
} }
EXPORT_SYMBOL_GPL(hd44780_common_gotoxy); EXPORT_SYMBOL_GPL(hd44780_common_gotoxy);
int hd44780_common_home(struct charlcd *lcd)
{
lcd->addr.x = 0;
lcd->addr.y = 0;
return hd44780_common_gotoxy(lcd);
}
EXPORT_SYMBOL_GPL(hd44780_common_home);
struct hd44780_common *hd44780_common_alloc(void) struct hd44780_common *hd44780_common_alloc(void)
{ {
struct hd44780_common *hd; struct hd44780_common *hd;
......
...@@ -16,4 +16,5 @@ struct hd44780_common { ...@@ -16,4 +16,5 @@ struct hd44780_common {
int hd44780_common_print(struct charlcd *lcd, int c); int hd44780_common_print(struct charlcd *lcd, int c);
int hd44780_common_gotoxy(struct charlcd *lcd); int hd44780_common_gotoxy(struct charlcd *lcd);
int hd44780_common_home(struct charlcd *lcd);
struct hd44780_common *hd44780_common_alloc(void); struct hd44780_common *hd44780_common_alloc(void);
...@@ -876,18 +876,21 @@ static const struct charlcd_ops charlcd_serial_ops = { ...@@ -876,18 +876,21 @@ static const struct charlcd_ops charlcd_serial_ops = {
.clear_fast = lcd_clear_fast_s, .clear_fast = lcd_clear_fast_s,
.backlight = lcd_backlight, .backlight = lcd_backlight,
.gotoxy = hd44780_common_gotoxy, .gotoxy = hd44780_common_gotoxy,
.home = hd44780_common_home,
}; };
static const struct charlcd_ops charlcd_parallel_ops = { static const struct charlcd_ops charlcd_parallel_ops = {
.clear_fast = lcd_clear_fast_p8, .clear_fast = lcd_clear_fast_p8,
.backlight = lcd_backlight, .backlight = lcd_backlight,
.gotoxy = hd44780_common_gotoxy, .gotoxy = hd44780_common_gotoxy,
.home = hd44780_common_home,
}; };
static const struct charlcd_ops charlcd_tilcd_ops = { static const struct charlcd_ops charlcd_tilcd_ops = {
.clear_fast = lcd_clear_fast_tilcd, .clear_fast = lcd_clear_fast_tilcd,
.backlight = lcd_backlight, .backlight = lcd_backlight,
.gotoxy = hd44780_common_gotoxy, .gotoxy = hd44780_common_gotoxy,
.home = hd44780_common_home,
}; };
/* initialize the LCD driver */ /* initialize the LCD driver */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment