[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201005121200.3427363-22-poeschel@lemonage.de>
Date: Mon, 5 Oct 2020 14:11:49 +0200
From: poeschel@...onage.de
To: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@...il.com>,
Willy Tarreau <willy@...roxy.com>,
Ksenija Stanojevic <ksenija.stanojevic@...il.com>,
linux-kernel@...r.kernel.org (open list)
Cc: Lars Poeschel <poeschel@...onage.de>, Willy Tarreau <w@....eu>
Subject: [PATCH v3 21/32] auxdisplay: Implement hd44780_common_fontsize
From: Lars Poeschel <poeschel@...onage.de>
This implements hd44780_common_fontsize to switch between two fontsizes.
The hd44780 drivers can just set this function to their ops structure
and charlcd uses it through this ops function pointer.
Reviewed-by: Willy Tarreau <w@....eu>
Signed-off-by: Lars Poeschel <poeschel@...onage.de>
---
drivers/auxdisplay/charlcd.c | 6 ++++++
drivers/auxdisplay/charlcd.h | 6 ++++++
drivers/auxdisplay/hd44780.c | 2 ++
drivers/auxdisplay/hd44780_common.c | 25 +++++++++++++++++++++++++
drivers/auxdisplay/hd44780_common.h | 1 +
drivers/auxdisplay/panel.c | 3 +++
6 files changed, 43 insertions(+)
diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index c04aaa4d66a5..f4400a2c1ba5 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -281,10 +281,16 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
break;
case 'f': /* Small Font */
priv->flags &= ~LCD_FLAG_F;
+ if (priv->flags != oldflags)
+ lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_SMALL);
+
processed = 1;
break;
case 'F': /* Large Font */
priv->flags |= LCD_FLAG_F;
+ if (priv->flags != oldflags)
+ lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_LARGE);
+
processed = 1;
break;
case 'n': /* One Line */
diff --git a/drivers/auxdisplay/charlcd.h b/drivers/auxdisplay/charlcd.h
index d9d907db2724..ff223ed59bd9 100644
--- a/drivers/auxdisplay/charlcd.h
+++ b/drivers/auxdisplay/charlcd.h
@@ -26,6 +26,11 @@ enum charlcd_shift_dir {
CHARLCD_SHIFT_RIGHT,
};
+enum charlcd_fontsize {
+ CHARLCD_FONTSIZE_SMALL,
+ CHARLCD_FONTSIZE_LARGE,
+};
+
struct charlcd {
const struct charlcd_ops *ops;
const unsigned char *char_conv; /* Optional */
@@ -77,6 +82,7 @@ struct charlcd_ops {
int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
+ int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
};
void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
index a8d6e5483a92..2b5f8984fcd4 100644
--- a/drivers/auxdisplay/hd44780.c
+++ b/drivers/auxdisplay/hd44780.c
@@ -136,6 +136,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = {
.display = hd44780_common_display,
.cursor = hd44780_common_cursor,
.blink = hd44780_common_blink,
+ .fontsize = hd44780_common_fontsize,
};
/* Send a command to the LCD panel in 4 bit GPIO mode */
@@ -189,6 +190,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = {
.display = hd44780_common_display,
.cursor = hd44780_common_cursor,
.blink = hd44780_common_blink,
+ .fontsize = hd44780_common_fontsize,
};
static int hd44780_probe(struct platform_device *pdev)
diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c
index 5c028f157fc8..112285f8f414 100644
--- a/drivers/auxdisplay/hd44780_common.c
+++ b/drivers/auxdisplay/hd44780_common.c
@@ -250,6 +250,31 @@ int hd44780_common_blink(struct charlcd *lcd, enum charlcd_onoff on)
}
EXPORT_SYMBOL_GPL(hd44780_common_blink);
+static void hd44780_common_set_function(struct hd44780_common *hdc)
+{
+ hdc->write_cmd(hdc,
+ LCD_CMD_FUNCTION_SET |
+ ((hdc->ifwidth == 8) ? LCD_CMD_DATA_LEN_8BITS : 0) |
+ ((hdc->hd44780_common_flags & LCD_FLAG_F) ?
+ LCD_CMD_FONT_5X10_DOTS : 0) |
+ ((hdc->hd44780_common_flags & LCD_FLAG_N) ?
+ LCD_CMD_TWO_LINES : 0));
+}
+
+int hd44780_common_fontsize(struct charlcd *lcd, enum charlcd_fontsize size)
+{
+ struct hd44780_common *hdc = lcd->drvdata;
+
+ if (size == CHARLCD_FONTSIZE_LARGE)
+ hdc->hd44780_common_flags |= LCD_FLAG_F;
+ else
+ hdc->hd44780_common_flags &= ~LCD_FLAG_F;
+
+ hd44780_common_set_function(hdc);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(hd44780_common_fontsize);
+
struct hd44780_common *hd44780_common_alloc(void)
{
struct hd44780_common *hd;
diff --git a/drivers/auxdisplay/hd44780_common.h b/drivers/auxdisplay/hd44780_common.h
index b46171f21a05..65d513efcc43 100644
--- a/drivers/auxdisplay/hd44780_common.h
+++ b/drivers/auxdisplay/hd44780_common.h
@@ -27,5 +27,6 @@ int hd44780_common_shift_display(struct charlcd *lcd,
int hd44780_common_display(struct charlcd *lcd, enum charlcd_onoff on);
int hd44780_common_cursor(struct charlcd *lcd, enum charlcd_onoff on);
int hd44780_common_blink(struct charlcd *lcd, enum charlcd_onoff on);
+int hd44780_common_fontsize(struct charlcd *lcd, enum charlcd_fontsize size);
struct hd44780_common *hd44780_common_alloc(void);
diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
index 2d2f59360e1a..6e13806af497 100644
--- a/drivers/auxdisplay/panel.c
+++ b/drivers/auxdisplay/panel.c
@@ -884,6 +884,7 @@ static const struct charlcd_ops charlcd_serial_ops = {
.display = hd44780_common_display,
.cursor = hd44780_common_cursor,
.blink = hd44780_common_blink,
+ .fontsize = hd44780_common_fontsize,
};
static const struct charlcd_ops charlcd_parallel_ops = {
@@ -898,6 +899,7 @@ static const struct charlcd_ops charlcd_parallel_ops = {
.display = hd44780_common_display,
.cursor = hd44780_common_cursor,
.blink = hd44780_common_blink,
+ .fontsize = hd44780_common_fontsize,
};
static const struct charlcd_ops charlcd_tilcd_ops = {
@@ -912,6 +914,7 @@ static const struct charlcd_ops charlcd_tilcd_ops = {
.display = hd44780_common_display,
.cursor = hd44780_common_cursor,
.blink = hd44780_common_blink,
+ .fontsize = hd44780_common_fontsize,
};
/* initialize the LCD driver */
--
2.28.0
Powered by blists - more mailing lists