Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3249622pxk; Mon, 5 Oct 2020 05:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoG0uFezd2nsFlCM6uXRNFnh5Eye+xJSBJ7fnm9mX5vYfIX4PilhPnvYr3HJciu0NHoseA X-Received: by 2002:a17:906:a387:: with SMTP id k7mr11025336ejz.167.1601900153842; Mon, 05 Oct 2020 05:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601900153; cv=none; d=google.com; s=arc-20160816; b=nj/e1/iyCysQzyWpYygpwC/1aT5PoIqa3ZeCYnY6IFUhMy8EFD61rhkydLOyvL5c9I U72RdF8ISmI3i2Xoy0aCLqQFpwM54MABLYjY+bffB8EwGkSelpegxnWfzz85vYKjOG46 bKhghg3cJS1s1/acV63TwjeG8e9/uku5IHGF367JS3E9O9hVEkS4SYtKIKYCUx9JMUtp mhnvpXTTnSbntj6bInmfHtRKJtTpG6b/QuS97+4oaq25N+BXHOSvApCbDK4d67BnOtKe cm5MBEiN2aV2nbLqKEvYuyoyYBrES/CNML5aGOjU8g8Ab5nLbdR2lztrSLrzwrlEEsSb oTIg== 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=O6UujgNvPeAHRIwK0tO9uaT9mf6EGQvpsE8OoLY/NI0=; b=eQoYDcOTDqTEu0qqh4Qd50Pnl01mCMDl4pe2ToPV8F92M82rx4vSFga1/EbahJ8Ycg 5gaKeVYcZWIdYYu5M/YJexRwEkVM60pFUm+IfvyHXKuHxGZ9tGztOlm6XMmonxRSWxdI XqudbbrZabLp8srme5sqdsAaCgeOYhACnolU2iMIohv5K1I3N8PIn/WN0XfXjd0Zoxco yC7LzTKOa0djHyM6iyxsx7YlHrrYToCspKEj27Ux/NQTYwDGI8mADozvttnGme6yPvhN JnNzGW7+3i3qGzkZMqoKohfH2GkBZoipq7CCnAl4x4IrZkD0U3N43cdo9hDiyjNRIM02 sJLA== 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 gz18si6308446ejb.408.2020.10.05.05.15.31; Mon, 05 Oct 2020 05:15:53 -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 S1726686AbgJEMNg (ORCPT + 99 others); Mon, 5 Oct 2020 08:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbgJEMMg (ORCPT ); Mon, 5 Oct 2020 08:12:36 -0400 Received: from smtp2-2.goneo.de (smtp2.goneo.de [IPv6:2001:1640:5::8:33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF954C0613A9 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 BDB48241B22; 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 Co4xvcpT5IXO; Mon, 5 Oct 2020 14:12:33 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 2AD1023FEC4; Mon, 5 Oct 2020 14:12:33 +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 22/32] auxdisplay: Implement hd44780_common_lines Date: Mon, 5 Oct 2020 14:11:50 +0200 Message-Id: <20201005121200.3427363-23-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_lines to switch the display between one and two lines mode. The hd44780 drivers use this function by adding it to their ops structure and charlcd now calls through its ops function pointer. Reviewed-by: Willy Tarreau Signed-off-by: Lars Poeschel --- drivers/auxdisplay/charlcd.c | 6 ++++++ drivers/auxdisplay/charlcd.h | 7 +++++++ drivers/auxdisplay/hd44780.c | 2 ++ drivers/auxdisplay/hd44780_common.c | 14 ++++++++++++++ drivers/auxdisplay/hd44780_common.h | 1 + drivers/auxdisplay/panel.c | 3 +++ 6 files changed, 33 insertions(+) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index f4400a2c1ba5..d672e4c371e1 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -295,10 +295,16 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) break; case 'n': /* One Line */ priv->flags &= ~LCD_FLAG_N; + if (priv->flags != oldflags) + lcd->ops->lines(lcd, CHARLCD_LINES_1); + processed = 1; break; case 'N': /* Two Lines */ priv->flags |= LCD_FLAG_N; + if (priv->flags != oldflags) + lcd->ops->lines(lcd, CHARLCD_LINES_2); + processed = 1; break; case 'l': /* Shift Cursor Left */ diff --git a/drivers/auxdisplay/charlcd.h b/drivers/auxdisplay/charlcd.h index ff223ed59bd9..5b0717c7482b 100644 --- a/drivers/auxdisplay/charlcd.h +++ b/drivers/auxdisplay/charlcd.h @@ -31,6 +31,11 @@ enum charlcd_fontsize { CHARLCD_FONTSIZE_LARGE, }; +enum charlcd_lines { + CHARLCD_LINES_1, + CHARLCD_LINES_2, +}; + struct charlcd { const struct charlcd_ops *ops; const unsigned char *char_conv; /* Optional */ @@ -68,6 +73,7 @@ struct charlcd { * @display: Turn display on or off. * @cursor: Turn cursor on or off. * @blink: Turn cursor blink on or off. + * @lines: One or two lines. */ struct charlcd_ops { void (*clear_fast)(struct charlcd *lcd); @@ -83,6 +89,7 @@ struct charlcd_ops { 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); + int (*lines)(struct charlcd *lcd, enum charlcd_lines lines); }; void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on); diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index 2b5f8984fcd4..7b7b28d72198 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -137,6 +137,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = { .cursor = hd44780_common_cursor, .blink = hd44780_common_blink, .fontsize = hd44780_common_fontsize, + .lines = hd44780_common_lines, }; /* Send a command to the LCD panel in 4 bit GPIO mode */ @@ -191,6 +192,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = { .cursor = hd44780_common_cursor, .blink = hd44780_common_blink, .fontsize = hd44780_common_fontsize, + .lines = hd44780_common_lines, }; static int hd44780_probe(struct platform_device *pdev) diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index 112285f8f414..2df2410f3874 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -275,6 +275,20 @@ int hd44780_common_fontsize(struct charlcd *lcd, enum charlcd_fontsize size) } EXPORT_SYMBOL_GPL(hd44780_common_fontsize); +int hd44780_common_lines(struct charlcd *lcd, enum charlcd_lines lines) +{ + struct hd44780_common *hdc = lcd->drvdata; + + if (lines == CHARLCD_LINES_2) + hdc->hd44780_common_flags |= LCD_FLAG_N; + else + hdc->hd44780_common_flags &= ~LCD_FLAG_N; + + hd44780_common_set_function(hdc); + return 0; +} +EXPORT_SYMBOL_GPL(hd44780_common_lines); + 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 65d513efcc43..419065bfaea2 100644 --- a/drivers/auxdisplay/hd44780_common.h +++ b/drivers/auxdisplay/hd44780_common.h @@ -28,5 +28,6 @@ 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); +int hd44780_common_lines(struct charlcd *lcd, enum charlcd_lines lines); struct hd44780_common *hd44780_common_alloc(void); diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index 6e13806af497..3d33d7cc979c 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -885,6 +885,7 @@ static const struct charlcd_ops charlcd_serial_ops = { .cursor = hd44780_common_cursor, .blink = hd44780_common_blink, .fontsize = hd44780_common_fontsize, + .lines = hd44780_common_lines, }; static const struct charlcd_ops charlcd_parallel_ops = { @@ -900,6 +901,7 @@ static const struct charlcd_ops charlcd_parallel_ops = { .cursor = hd44780_common_cursor, .blink = hd44780_common_blink, .fontsize = hd44780_common_fontsize, + .lines = hd44780_common_lines, }; static const struct charlcd_ops charlcd_tilcd_ops = { @@ -915,6 +917,7 @@ static const struct charlcd_ops charlcd_tilcd_ops = { .cursor = hd44780_common_cursor, .blink = hd44780_common_blink, .fontsize = hd44780_common_fontsize, + .lines = hd44780_common_lines, }; /* initialize the LCD driver */ -- 2.28.0