Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3205814pxk; Mon, 21 Sep 2020 07:51:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMX+VvLzQ8MMhEkgVNkJ76fuEN/efgL+YOpIV0fhra0GZZCkO1NDX8ZzcNclSgyE/i5tx6 X-Received: by 2002:a17:906:3bd8:: with SMTP id v24mr51935981ejf.509.1600699900898; Mon, 21 Sep 2020 07:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600699900; cv=none; d=google.com; s=arc-20160816; b=j271qhdGLEGxSxbJ/v0JheWxFiDW47Gb+pMe8vZXjGfXxlU1UpHBxK6XJ0/EIiuDvK oqx7ZsoIjgqOUslFMxWonJVWtbqcANDXV1wsT8bSAab/H0Ttl4diEihS5SFDnnOI84Yp fJCK5G0GpWyxaIhCRYh7ArreOrlau/AV/UOfzgW1NMFkmSKejcbcWbf28wLx5vnKFmwJ ujo8EZ6Kpu4nM+Qy5k2GpPAMUr5YSO/j+ZJLtkgNXkGaz9TYePaJDPGS3PkeLI6J5GIf +iMj0IIFlaM0zLUGCeJsgzdrpfYxQdssGyEAAgI+fZ8mqrVsILIsqfK8UtKpkpyV4Aas AdMg== 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=SIlv0/x+jpNDPu4rozx8k+16++mQ9FoM+jWcers/J5w=; b=RjYc+VGhcyyOzLaQlFw4j2cit23/RNDOlMOo1WQMk6f37HleFi8cWSsiarxASENL5C QsZj47uFDrNybALZQFCm5Bjfdl31x7SikSNFpvEddL+X4fhy+Qu9rtvW1SlE6qrlaBba HMArwP3UoQvy0AgrnJGMCrGsaCa56hk2BteodEuCO++scU6suh+0hRVvlyAEeuN1WWKO 4/rTZOpORNilt8RNuS18K0NZ7IU6ioZgtpkqyJXpstKayOkuV7I6V2jlohioH2B1Q8Gf wEIp4tg5vc0FqMNs5mbVBkERsJ/KzBWljS6/aL0Vj7AXiO10KPHkIs/p1LvmnZd1RDlN c4Aw== 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 p9si8422868ejy.150.2020.09.21.07.51.17; Mon, 21 Sep 2020 07:51:40 -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 S1727156AbgIUOtT (ORCPT + 99 others); Mon, 21 Sep 2020 10:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbgIUOsJ (ORCPT ); Mon, 21 Sep 2020 10:48:09 -0400 Received: from smtp1.goneo.de (smtp1.goneo.de [IPv6:2001:1640:5::8:30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00904C0613D1 for ; Mon, 21 Sep 2020 07:48:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.goneo.de (Postfix) with ESMTP id D00BD23F16C; Mon, 21 Sep 2020 16:48:07 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.999 X-Spam-Level: X-Spam-Status: No, score=-2.999 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.099, BAYES_00=-1.9] autolearn=ham Received: from smtp1.goneo.de ([127.0.0.1]) by localhost (smtp1.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hn6MgJseOVhL; Mon, 21 Sep 2020 16:48:05 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp1.goneo.de (Postfix) with ESMTPA id 8DA7723F160; Mon, 21 Sep 2020 16:48:05 +0200 (CEST) From: poeschel@lemonage.de To: Miguel Ojeda Sandonis , Willy Tarreau , Ksenija Stanojevic , linux-kernel@vger.kernel.org (open list) Cc: Lars Poeschel Subject: [PATCH v2 21/32] auxdisplay: Implement hd44780_common_fontsize Date: Mon, 21 Sep 2020 16:46:33 +0200 Message-Id: <20200921144645.2061313-22-poeschel@lemonage.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921144645.2061313-1-poeschel@lemonage.de> References: <20191016082430.5955-1-poeschel@lemonage.de> <20200921144645.2061313-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. 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 ecd2c2118318..f2f58ae1a285 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -249,6 +249,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