Message ID | 20230706185100.84322-1-hugo@hugovil.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2791488vqx; Thu, 6 Jul 2023 12:38:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlGSykbGXj86dfiqVes2MxlIO1oX9HYgHhixVAzU8oVGky4CzzEPAEBVRD61qhiHiZS9gwFz X-Received: by 2002:a17:90a:b904:b0:263:848:762e with SMTP id p4-20020a17090ab90400b002630848762emr2004666pjr.40.1688672316673; Thu, 06 Jul 2023 12:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688672316; cv=none; d=google.com; s=arc-20160816; b=dQy+JQ3k7C6Q0v0uArxpCr3/pXDreUoH72a+rp2S7UvAygqPeijimMQ7Yqdvt41XZt DdIXlEV5qLtPIy92yp9C+zZw/NgAietZZ5anfrzLAB3ozhj+m/a8gA0XbbdLY1Q7wMo1 kz1EURArZCylZUc6XuyKeUn0y3APotnbkeiFntm95Y/vZCNbnirkjCFa5+C7kaMKNAXf 0VYEUHf5UXgJ0fj8GjzEbiGTFUrFTPQDZ0lNa0WT4gL/eKfFVICBzfkukWRrbxYvuj7P oyvu+KLd2lpsvkl/J3XeLvS49IBXNI0OkrGUOZikdjA82jYmVit1Zi0HQNKKPn5Kl4xE Cc8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :message-id:date:cc:to:from:dkim-signature; bh=rI+8S7w+5wae4yvhZ4wNULs/xtvCq38AsDvZDV1s+XA=; fh=jx556IfQxnA+SVkPjFOTiN2gTXycDTv+SzzEMOSWlIA=; b=U3I6CqNqIt7ZIIn+X67OI7iuXv1+ZlHkwoioCyJlrl+HcZVz8viXK2HDKFRb34Es0f aNMNUNiwFYe3mBe7Qv/v/W6223tqUY/Km+hPIBd3SlMM+Pw9/DRaIuLo10FbFyrlQQLD xva4/ksJICSqFIZRId4MxM3Uqle9YYvELvfEvTLuzbTl7z2yeebQKw4PgV2wDOKTtReX KbPlSeyHSaJ10YCmhBb9oigKi4bWxh8LA0+XYqcTyiqnBbG26iuxZe7xTusEYaHGv8Vg QBp/3NZwui/5ctyAIjfRsURF0HZV3/6FRKXHq8lOzGx5fgJTfU9G1cN5gqjtNHX1cu4h rGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=R69MOA17; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ml20-20020a17090b361400b0025546028cbesi322728pjb.31.2023.07.06.12.38.21; Thu, 06 Jul 2023 12:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@hugovil.com header.s=x header.b=R69MOA17; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbjGFSvL (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Thu, 6 Jul 2023 14:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjGFSvK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 6 Jul 2023 14:51:10 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CA75B2 for <linux-kernel@vger.kernel.org>; Thu, 6 Jul 2023 11:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=rI+8S7w+5wae4yvhZ4wNULs/xtvCq38AsDvZDV1s+XA=; b=R 69MOA17vuBfB1Penjn6uVmOGkl7d8gMlbQlfxbeXLHuT6j5rTfCGiksUJxFZu5vgHUCtyhB6fIT5p sXhGLR+vvpiqKmjLEPcXyNUGz5KrX8NOHzBhUUqzrx6eGO+EuD+9YwIgJ+BAy/Q0I8ExLHVdP5iHS scK0kkBM8tzJk26M=; Received: from modemcable061.19-161-184.mc.videotron.ca ([184.161.19.61]:39080 helo=localhost.localdomain) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from <hugo@hugovil.com>) id 1qHU4E-0002oN-Iu; Thu, 06 Jul 2023 14:51:03 -0400 From: Hugo Villeneuve <hugo@hugovil.com> To: Miguel Ojeda <ojeda@kernel.org> Cc: hugo@hugovil.com, Hugo Villeneuve <hvilleneuve@dimonoff.com>, linux-kernel@vger.kernel.org Date: Thu, 6 Jul 2023 14:50:59 -0400 Message-Id: <20230706185100.84322-1-hugo@hugovil.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 184.161.19.61 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH] auxdisplay: hd44780: move cursor home after clear display command X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770701263304429975?= X-GMAIL-MSGID: =?utf-8?q?1770701263304429975?= |
Series |
auxdisplay: hd44780: move cursor home after clear display command
|
|
Commit Message
Hugo Villeneuve
July 6, 2023, 6:50 p.m. UTC
From: Hugo Villeneuve <hvilleneuve@dimonoff.com> The "clear display" command on the NewHaven NHD-0220DZW-AG5 display does NOT change the DDRAM address to 00h (home position) like the standard Hitachi HD44780 controller. As a consequence, the starting position of the initial string LCD_INIT_TEXT is not guaranteed to be at 0,0 depending on where the cursor was before the clear display command. Extract of CLEAR_DISPLAY command from datasheets of: Hitachi HD44780: ... It then sets DDRAM address 0 into the address counter... NewHaven NHD-0220DZW-AG5 datasheet: ... This instruction does not change the DDRAM Address Move the cursor home after sending clear display command to support non-standard LCDs. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> --- drivers/auxdisplay/hd44780_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) base-commit: c17414a273b81fe4e34e11d69fc30cc8b1431614
Comments
On Thu, Jul 6, 2023 at 8:51 PM Hugo Villeneuve <hugo@hugovil.com> wrote: > > The "clear display" command on the NewHaven NHD-0220DZW-AG5 display > does NOT change the DDRAM address to 00h (home position) like the > standard Hitachi HD44780 controller. As a consequence, the starting > position of the initial string LCD_INIT_TEXT is not guaranteed to be > at 0,0 depending on where the cursor was before the clear display > command. > > Extract of CLEAR_DISPLAY command from datasheets of: > > Hitachi HD44780: > ... It then sets DDRAM address 0 into the address counter... > > NewHaven NHD-0220DZW-AG5 datasheet: > ... This instruction does not change the DDRAM Address > > Move the cursor home after sending clear display command to support > non-standard LCDs. > > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Thanks! Sounds good to me, as long the extra command does not introduce some issue with the actual HD44780 -- can we double-check the HD44780 still works as expected? Cc'ing Lars and Geert since they may be able to give it a quick test. > + /* > + * Some LCDs (ex: NewHaven) do not reset the DDRAM address when > + * executing the CLEAR_DISPLAY command. Explicitely move cursor > + * to home position to account for these non-standard LCDs: > + */ > + return hd44780_common_home(lcd); Few nits: - Explicitely -> Explicitly. - Isn't the command `DISPLAY_CLEAR` instead of `CLEAR_DISPLAY`? (at least the identifier above is `LCD_CMD_DISPLAY_CLEAR`). - `:` -> `.`. What about something like: The Hitachi HD44780 controller (and compatible ones) reset the DDRAM address when executing the `DISPLAY_CLEAR` command, thus the following call is not required. However, other controllers do not (e.g. NewHaven NHD-0220DZW-AG5), thus move the cursor to home unconditionally to support both. Cheers, Miguel
On Thu, 6 Jul 2023 21:33:05 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > On Thu, Jul 6, 2023 at 8:51 PM Hugo Villeneuve <hugo@hugovil.com> wrote: > > > > The "clear display" command on the NewHaven NHD-0220DZW-AG5 display > > does NOT change the DDRAM address to 00h (home position) like the > > standard Hitachi HD44780 controller. As a consequence, the starting > > position of the initial string LCD_INIT_TEXT is not guaranteed to be > > at 0,0 depending on where the cursor was before the clear display > > command. > > > > Extract of CLEAR_DISPLAY command from datasheets of: > > > > Hitachi HD44780: > > ... It then sets DDRAM address 0 into the address counter... > > > > NewHaven NHD-0220DZW-AG5 datasheet: > > ... This instruction does not change the DDRAM Address > > > > Move the cursor home after sending clear display command to support > > non-standard LCDs. > > > > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> > > Thanks! Sounds good to me, as long the extra command does not > introduce some issue with the actual HD44780 -- can we double-check > the HD44780 still works as expected? > > Cc'ing Lars and Geert since they may be able to give it a quick test. Hi Miguel, I do not have a standard Hitachi controller to test it on, so lets wait for feedback from Lars and Geert or others. > > + /* > > + * Some LCDs (ex: NewHaven) do not reset the DDRAM address when > > + * executing the CLEAR_DISPLAY command. Explicitely move cursor > > + * to home position to account for these non-standard LCDs: > > + */ > > + return hd44780_common_home(lcd); > > Few nits: > > - Explicitely -> Explicitly. > - Isn't the command `DISPLAY_CLEAR` instead of `CLEAR_DISPLAY`? (at > least the identifier above is `LCD_CMD_DISPLAY_CLEAR`). Yes, I have also modified the commit log message to be consistent with the code. > - `:` -> `.`. > What about something like: > > The Hitachi HD44780 controller (and compatible ones) reset the > DDRAM address when executing the `DISPLAY_CLEAR` command, thus the > following call is not required. However, other controllers do not > (e.g. NewHaven NHD-0220DZW-AG5), thus move the cursor to home > unconditionally to support both. Ok, changed comments to that. Thank you, Hugo.
Am 2023-07-06 21:49, schrieb Hugo Villeneuve: > On Thu, 6 Jul 2023 21:33:05 +0200 > Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > >> On Thu, Jul 6, 2023 at 8:51 PM Hugo Villeneuve <hugo@hugovil.com> >> wrote: >> > >> > The "clear display" command on the NewHaven NHD-0220DZW-AG5 display >> > does NOT change the DDRAM address to 00h (home position) like the >> > standard Hitachi HD44780 controller. As a consequence, the starting >> > position of the initial string LCD_INIT_TEXT is not guaranteed to be >> > at 0,0 depending on where the cursor was before the clear display >> > command. >> > >> > Extract of CLEAR_DISPLAY command from datasheets of: >> > >> > Hitachi HD44780: >> > ... It then sets DDRAM address 0 into the address counter... >> > >> > NewHaven NHD-0220DZW-AG5 datasheet: >> > ... This instruction does not change the DDRAM Address >> > >> > Move the cursor home after sending clear display command to support >> > non-standard LCDs. >> > >> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> >> >> Thanks! Sounds good to me, as long the extra command does not >> introduce some issue with the actual HD44780 -- can we double-check >> the HD44780 still works as expected? >> >> Cc'ing Lars and Geert since they may be able to give it a quick test. > > Hi Miguel, > I do not have a standard Hitachi controller to test it on, so lets wait > for feedback from Lars and Geert or others. Sorry guys, I do not have access to the relevant hardware anymore. I am CC'ing Christian, who has the relevant hardware and maybe he can help testing the patch. Christian is on vacation up until mid august, so we have to wait a bit more for someone able to test this. BTW: The displays I did the work back then on were for sure not genuine Hitachi ones either. I do not see, that the little patch should do any harm. Regards, Lars
poeschel@lemonage.de writes: > Am 2023-07-06 21:49, schrieb Hugo Villeneuve: >> On Thu, 6 Jul 2023 21:33:05 +0200 >> Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: >> >>> On Thu, Jul 6, 2023 at 8:51 PM Hugo Villeneuve <hugo@hugovil.com> wrote: >>> > >>> > The "clear display" command on the NewHaven NHD-0220DZW-AG5 display >>> > does NOT change the DDRAM address to 00h (home position) like the >>> > standard Hitachi HD44780 controller. As a consequence, the starting >>> > position of the initial string LCD_INIT_TEXT is not guaranteed to be >>> > at 0,0 depending on where the cursor was before the clear display >>> > command. >>> > >>> > Extract of CLEAR_DISPLAY command from datasheets of: >>> > >>> > Hitachi HD44780: >>> > ... It then sets DDRAM address 0 into the address counter... >>> > >>> > NewHaven NHD-0220DZW-AG5 datasheet: >>> > ... This instruction does not change the DDRAM Address >>> > >>> > Move the cursor home after sending clear display command to support >>> > non-standard LCDs. >>> > >>> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> >>> Thanks! Sounds good to me, as long the extra command does not >>> introduce some issue with the actual HD44780 -- can we double-check >>> the HD44780 still works as expected? >>> Cc'ing Lars and Geert since they may be able to give it a quick test. >> Hi Miguel, >> I do not have a standard Hitachi controller to test it on, so lets wait >> for feedback from Lars and Geert or others. > > Sorry guys, > I do not have access to the relevant hardware anymore. I am CC'ing Christian, > who has the relevant hardware and maybe he can help testing the patch. > Christian is on vacation up until mid august, so we have to wait a bit more > for someone able to test this. > > BTW: The displays I did the work back then on were for sure not genuine > Hitachi ones either. > I do not see, that the little patch should do any harm. > > Regards, > Lars I was actually hooking up a 16x2 HD44780 on my BeagleBone Black last night before I came across this patch, so I was able to test this. It works fine for me. I tested with: $ printf '\f' > /dev/lcd $ printf 'Hello\nWorld!\n' > /dev/lcd $ printf '\x1b[LR' > /dev/lcd $ printf '\x1b[LR' > /dev/lcd $ printf '\x1b[LR' > /dev/lcd $ printf '\f' > /dev/lcd $ printf 'Goodbye\nWorld!\n' > /dev/lcd As expected, "Goodbye World!" was correctly placed left-aligned on the display, split over both lines. Let me know if there is something else you would like me to do to test this! Tested-by: David Reaver <me@davidreaver.com>
On Sat, Jul 22, 2023 at 4:54 PM David Reaver <me@davidreaver.com> wrote: > > I was actually hooking up a 16x2 HD44780 on my BeagleBone Black last > night before I came across this patch, so I was able to test this. It > works fine for me. I tested with: > > $ printf '\f' > /dev/lcd > $ printf 'Hello\nWorld!\n' > /dev/lcd > $ printf '\x1b[LR' > /dev/lcd > $ printf '\x1b[LR' > /dev/lcd > $ printf '\x1b[LR' > /dev/lcd > $ printf '\f' > /dev/lcd > $ printf 'Goodbye\nWorld!\n' > /dev/lcd > > As expected, "Goodbye World!" was correctly placed left-aligned on the > display, split over both lines. Let me know if there is something else > you would like me to do to test this! > > Tested-by: David Reaver <me@davidreaver.com> Thanks a lot, that is very helpful! I will wait a while in case Christian or somebody else wants to test it, and send it for 6.6. Cheers, Miguel
On Sat, 22 Jul 2023 18:04:03 +0200 Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote: > On Sat, Jul 22, 2023 at 4:54 PM David Reaver <me@davidreaver.com> wrote: > > > > I was actually hooking up a 16x2 HD44780 on my BeagleBone Black last > > night before I came across this patch, so I was able to test this. It > > works fine for me. I tested with: > > > > $ printf '\f' > /dev/lcd > > $ printf 'Hello\nWorld!\n' > /dev/lcd > > $ printf '\x1b[LR' > /dev/lcd > > $ printf '\x1b[LR' > /dev/lcd > > $ printf '\x1b[LR' > /dev/lcd > > $ printf '\f' > /dev/lcd > > $ printf 'Goodbye\nWorld!\n' > /dev/lcd > > > > As expected, "Goodbye World!" was correctly placed left-aligned on the > > display, split over both lines. Let me know if there is something else > > you would like me to do to test this! > > > > Tested-by: David Reaver <me@davidreaver.com> > > Thanks a lot, that is very helpful! > > I will wait a while in case Christian or somebody else wants to test > it, and send it for 6.6. Hi Miguel, in the meantime, I will send V2 of the patch with the changes you suggested for the commit message and the comments. Hugo.
diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index 3934c2eebf33..70c818945a74 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -82,7 +82,13 @@ int hd44780_common_clear_display(struct charlcd *lcd) hdc->write_cmd(hdc, LCD_CMD_DISPLAY_CLEAR); /* datasheet says to wait 1,64 milliseconds */ long_sleep(2); - return 0; + + /* + * Some LCDs (ex: NewHaven) do not reset the DDRAM address when + * executing the CLEAR_DISPLAY command. Explicitely move cursor + * to home position to account for these non-standard LCDs: + */ + return hd44780_common_home(lcd); } EXPORT_SYMBOL_GPL(hd44780_common_clear_display);