Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3249752pxk; Mon, 5 Oct 2020 05:16:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjahTsnR9Dz3ppT/dsgmVZQo8RKEeI4M3zFStArgxN1TzB1nchG3S0N4TGVpCqaXK5cne3 X-Received: by 2002:a17:906:d0c6:: with SMTP id bq6mr4826277ejb.16.1601900165950; Mon, 05 Oct 2020 05:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601900165; cv=none; d=google.com; s=arc-20160816; b=SXN1USfLHgSsNrvSM7o3CXNLJ1jPiLDNd/L/kyTRJ1KrFSmZlq9XkwtDE0sn5igQ0K VBiJ6lF+agYyBuLz1b4niadqcvqU+S3HCh+Lg/Ec7qq7Z2obqcmddeN6GRn79e47Xw8O Gi4UTl8iNq9O3AVoFFoSjXdT7zGmUhN32VkJXhAML/nTyIs+NSSvmpDeDHqZHbeNL9nN dAyVmJNqJA4A5jl9Nf6/SxWcgKg5259CbrACxq6DapOLIAvdOb7FXxTqMNcQyOafkgHo bcR+WCeMiurFOJaBUmOvpz54AN6suNMFQ/W/7TNEkaMpSuQCMZXLGCi+nMvjBZ/9ZLCF CFrQ== 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=1j+peqdYEy7MmtaMLqok/HlV4bmdL0XACsClr6+2KKs=; b=QEeFMv+t9Vp827y0WFbtI7laxj43sjW7xr9rULer1l2SQcZq8otAqDWdOPeixuaLY1 pKSTLXyJKibigDAJZiXoH2svexrprihw7T3IO8aLAFnBTwHXtSYLv7GOUT2OysSWp5fV gGM5ZdJCJBt/fSozc778XTUOoQKjgQucFelVyO75Jf8ZiFL7bzIxcp3xNu/a/g9kzrXb RPZkwX78ioDQapIuPhnIP+PRQUP6hWwkDKe8eiws0TlXr3jO5Sx/UGKNYlOb1kMlFtvH AuvfOmjSdpgymwa7mL0QZK3tzDir5rIFhkuicmpzHWzRJgSnpRGMtTWmjUfGjy18Z6Kc UHPg== 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 cc17si7535378edb.261.2020.10.05.05.15.43; Mon, 05 Oct 2020 05:16:05 -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 S1726740AbgJEMN5 (ORCPT + 99 others); Mon, 5 Oct 2020 08:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgJEMMc (ORCPT ); Mon, 5 Oct 2020 08:12:32 -0400 Received: from smtp2-2.goneo.de (smtp2.goneo.de [IPv6:2001:1640:5::8:33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58D75C0613CE for ; Mon, 5 Oct 2020 05:12:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.goneo.de (Postfix) with ESMTP id 3CAF5241C33; Mon, 5 Oct 2020 14:12:31 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.987 X-Spam-Level: X-Spam-Status: No, score=-2.987 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.087, 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 oNt9OH7VdKCo; Mon, 5 Oct 2020 14:12:29 +0200 (CEST) Received: from lem-wkst-02.lemonage.de. (hq.lemonage.de [87.138.178.34]) by smtp2.goneo.de (Postfix) with ESMTPA id 67BBD241B45; Mon, 5 Oct 2020 14:12:29 +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 17/32] auxdisplay: Implement a hd44780_common_display Date: Mon, 5 Oct 2020 14:11:45 +0200 Message-Id: <20201005121200.3427363-18-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 Implement a hd44780_common_display function to turn the whole display on or off. The hd44780 drivers can use this and charlcd uses this through its ops function pointer. Reviewed-by: Willy Tarreau Signed-off-by: Lars Poeschel --- drivers/auxdisplay/charlcd.c | 6 ++++++ drivers/auxdisplay/charlcd.h | 2 ++ drivers/auxdisplay/hd44780.c | 2 ++ drivers/auxdisplay/hd44780_common.c | 26 ++++++++++++++++++++++++++ drivers/auxdisplay/hd44780_common.h | 1 + drivers/auxdisplay/panel.c | 3 +++ 6 files changed, 40 insertions(+) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index e48287197732..9bd3c0f2c470 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -232,10 +232,16 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) switch (*esc) { case 'D': /* Display ON */ priv->flags |= LCD_FLAG_D; + if (priv->flags != oldflags) + lcd->ops->display(lcd, CHARLCD_ON); + processed = 1; break; case 'd': /* Display OFF */ priv->flags &= ~LCD_FLAG_D; + if (priv->flags != oldflags) + lcd->ops->display(lcd, CHARLCD_OFF); + processed = 1; break; case 'C': /* Cursor ON */ diff --git a/drivers/auxdisplay/charlcd.h b/drivers/auxdisplay/charlcd.h index 6fd4a77f5794..ec739a25195e 100644 --- a/drivers/auxdisplay/charlcd.h +++ b/drivers/auxdisplay/charlcd.h @@ -60,6 +60,7 @@ struct charlcd { * @init_display: Initialize the display. * @shift_cursor: Shift cursor left or right one position. * @shift_display: Shift whole display content left or right. + * @display: Turn display on or off. */ struct charlcd_ops { void (*clear_fast)(struct charlcd *lcd); @@ -71,6 +72,7 @@ struct charlcd_ops { int (*init_display)(struct charlcd *lcd); int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir); int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir); + int (*display)(struct charlcd *lcd, enum charlcd_onoff on); }; void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on); diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index a3b18bbc2e4a..0f76b812fa20 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c @@ -133,6 +133,7 @@ static const struct charlcd_ops hd44780_ops_gpio8 = { .init_display = hd44780_common_init_display, .shift_cursor = hd44780_common_shift_cursor, .shift_display = hd44780_common_shift_display, + .display = hd44780_common_display, }; /* Send a command to the LCD panel in 4 bit GPIO mode */ @@ -183,6 +184,7 @@ static const struct charlcd_ops hd44780_ops_gpio4 = { .init_display = hd44780_common_init_display, .shift_cursor = hd44780_common_shift_cursor, .shift_display = hd44780_common_shift_display, + .display = hd44780_common_display, }; static int hd44780_probe(struct platform_device *pdev) diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index 972c74a22294..07fd03555e99 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -196,6 +196,32 @@ int hd44780_common_shift_display(struct charlcd *lcd, } EXPORT_SYMBOL_GPL(hd44780_common_shift_display); +static void hd44780_common_set_mode(struct hd44780_common *hdc) +{ + hdc->write_cmd(hdc, + LCD_CMD_DISPLAY_CTRL | + ((hdc->hd44780_common_flags & LCD_FLAG_D) ? + LCD_CMD_DISPLAY_ON : 0) | + ((hdc->hd44780_common_flags & LCD_FLAG_C) ? + LCD_CMD_CURSOR_ON : 0) | + ((hdc->hd44780_common_flags & LCD_FLAG_B) ? + LCD_CMD_BLINK_ON : 0)); +} + +int hd44780_common_display(struct charlcd *lcd, enum charlcd_onoff on) +{ + struct hd44780_common *hdc = lcd->drvdata; + + if (on == CHARLCD_ON) + hdc->hd44780_common_flags |= LCD_FLAG_D; + else + hdc->hd44780_common_flags &= ~LCD_FLAG_D; + + hd44780_common_set_mode(hdc); + return 0; +} +EXPORT_SYMBOL_GPL(hd44780_common_display); + 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 7badb96cb8a9..1550fa77b956 100644 --- a/drivers/auxdisplay/hd44780_common.h +++ b/drivers/auxdisplay/hd44780_common.h @@ -24,5 +24,6 @@ int hd44780_common_shift_cursor(struct charlcd *lcd, enum charlcd_shift_dir dir); int hd44780_common_shift_display(struct charlcd *lcd, enum charlcd_shift_dir dir); +int hd44780_common_display(struct charlcd *lcd, enum charlcd_onoff on); struct hd44780_common *hd44780_common_alloc(void); diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index 7ebbfb338518..9cb895c74cfb 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -881,6 +881,7 @@ static const struct charlcd_ops charlcd_serial_ops = { .init_display = hd44780_common_init_display, .shift_cursor = hd44780_common_shift_cursor, .shift_display = hd44780_common_shift_display, + .display = hd44780_common_display, }; static const struct charlcd_ops charlcd_parallel_ops = { @@ -892,6 +893,7 @@ static const struct charlcd_ops charlcd_parallel_ops = { .init_display = hd44780_common_init_display, .shift_cursor = hd44780_common_shift_cursor, .shift_display = hd44780_common_shift_display, + .display = hd44780_common_display, }; static const struct charlcd_ops charlcd_tilcd_ops = { @@ -903,6 +905,7 @@ static const struct charlcd_ops charlcd_tilcd_ops = { .init_display = hd44780_common_init_display, .shift_cursor = hd44780_common_shift_cursor, .shift_display = hd44780_common_shift_display, + .display = hd44780_common_display, }; /* initialize the LCD driver */ -- 2.28.0