Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3249594pxk; Mon, 5 Oct 2020 05:15:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQowV8Jbz5ZYbcKQfX6mO5UWrSy2xs1suqXQbaI6jMonA1zBsbnlzsStxnaBYkfB6r1zu1 X-Received: by 2002:a17:906:b353:: with SMTP id cd19mr14970117ejb.140.1601900152060; Mon, 05 Oct 2020 05:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601900152; cv=none; d=google.com; s=arc-20160816; b=Sj+zQ31k72DJ7P2sVbvX8Lsxkd9hFCfvDa6O8vO0n1DsH1ljvO20bC4gpOP9f+3Red 08YrBjQE7xfB6fRrCsQTj8mKmF/+F2CTS5OipxDShasFejyjR2hVAUkwKLcZjFBKt94W yISHd6RKIzSnjBt26/ROShEKQRVyRD4UFMMV4O4mbcOD1oy4C1AHOJktA5gZqLbHHEnk iE/0dNPQRnm8uZguhogaQ3CeWWQ4Ab9GBeL62LWDGXIeVVjiLYcp2WXGnsM9gUVXKmzj TEDOETiPeq11PhqLGdycM3eoUgQLbT3kwdNKL/ny6y+1duZrHiq6epU7yKWP8gkqjoEE jiPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EdYG8JWjXn0sr+mPYKcN3RcvMZGZF+2XKNxRGZMDGbw=; b=kukQ6XJVNdGqiOBCt04+uBw36Lb+1EWjZ37iboP4Golv878hMCDD8YE72ErD/iHdPD fxG/hYaGnZj4pKN8r7Qqe7vV9tUtxQPtwe4bq/O7W3hpf/1s7afGqw/tTUx/t1mk1TTN I7qluxqX9SULA82A9hugjZ9xtLLD7tJ657TRXWb4tZ84Fi+9J3VeMi6DweKp6EbTL+So R9eRsAKmTHQAKiUrirwL0A8+NNjWGfXUU8SgMKNwa/M1F+FfS6OYYFhni5hXpAZursFG FpGSAjGSQWgaLzwzd9aH86aP7d19yruLxyE+NPgLRX2J1AjVv3FBnw7THgBgtiyVaGH3 201g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si7804707eju.615.2020.10.05.05.15.29; Mon, 05 Oct 2020 05:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgJEMNp (ORCPT + 99 others); Mon, 5 Oct 2020 08:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbgJEMMf (ORCPT ); Mon, 5 Oct 2020 08:12:35 -0400 Received: from smtp2-2.goneo.de (smtp2.goneo.de [IPv6:2001:1640:5::8:33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25523C0613A8 for ; Mon, 5 Oct 2020 05:12:35 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 09D05241509; Mon, 5 Oct 2020 14:12:34 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.985 X-Spam-Level: X-Spam-Status: No, score=-2.985 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.085, BAYES_00=-1.9] autolearn=ham Received: from smtp2.goneo.de ([127.0.0.1]) by localhost (smtp2.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uXHPxAisGvoE; Mon, 5 Oct 2020 14:12:32 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 5618B241CB7; Mon, 5 Oct 2020 14:12:32 +0200 (CEST) From: poeschel@lemonage.de To: Miguel Ojeda Sandonis , Willy Tarreau , Ksenija Stanojevic , linux-kernel@vger.kernel.org (open list) Cc: Lars Poeschel , Willy Tarreau Subject: [PATCH v3 21/32] auxdisplay: Implement hd44780_common_fontsize Date: Mon, 5 Oct 2020 14:11:49 +0200 Message-Id: <20201005121200.3427363-22-poeschel@lemonage.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201005121200.3427363-1-poeschel@lemonage.de> References: <20201005121200.3427363-1-poeschel@lemonage.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars Poeschel 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 Signed-off-by: Lars Poeschel --- 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