From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937731AbdCJOPh (ORCPT ); Fri, 10 Mar 2017 09:15:37 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:48090 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933214AbdCJOPd (ORCPT ); Fri, 10 Mar 2017 09:15:33 -0500 From: Geert Uytterhoeven To: Miguel Ojeda Sandonis , Greg Kroah-Hartman , Willy Tarreau , Ksenija Stanojevic , Arnd Bergmann Cc: Rob Herring , Mark Rutland , Akira Tsukamoto , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 3/5] auxdisplay: charlcd: Add support for displays with more than two lines Date: Fri, 10 Mar 2017 15:15:19 +0100 Message-Id: <1489155321-25666-4-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489155321-25666-1-git-send-email-geert@linux-m68k.org> References: <1489155321-25666-1-git-send-email-geert@linux-m68k.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On displays with more than two lines, the additional lines are stored in the buffers used for the first two lines, but beyond the visible parts. Adjust the DDRAM address calculation to cater for this. When clearing the display, avoid writing more spaces than the actual size of the physical buffer. Signed-off-by: Geert Uytterhoeven --- v2: - No changes. --- drivers/auxdisplay/charlcd.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c index b3a84e90a268478c..cfeb049a01ef8442 100644 --- a/drivers/auxdisplay/charlcd.c +++ b/drivers/auxdisplay/charlcd.c @@ -159,15 +159,19 @@ EXPORT_SYMBOL_GPL(charlcd_poke); static void charlcd_gotoxy(struct charlcd *lcd) { struct charlcd_priv *priv = to_priv(lcd); + unsigned int addr; - lcd->ops->write_cmd(lcd, - LCD_CMD_SET_DDRAM_ADDR | (priv->addr.y ? lcd->hwidth : 0) | - /* - * we force the cursor to stay at the end of the - * line if it wants to go farther - */ - ((priv->addr.x < lcd->bwidth) ? priv->addr.x & (lcd->hwidth - 1) - : lcd->bwidth - 1)); + /* + * we force the cursor to stay at the end of the + * line if it wants to go farther + */ + addr = priv->addr.x < lcd->bwidth ? priv->addr.x & (lcd->hwidth - 1) + : lcd->bwidth - 1; + if (priv->addr.y & 1) + addr += lcd->hwidth; + if (priv->addr.y & 2) + addr += lcd->bwidth; + lcd->ops->write_cmd(lcd, LCD_CMD_SET_DDRAM_ADDR | addr); } static void charlcd_home(struct charlcd *lcd) @@ -203,7 +207,7 @@ static void charlcd_clear_fast(struct charlcd *lcd) if (lcd->ops->clear_fast) lcd->ops->clear_fast(lcd); else - for (pos = 0; pos < lcd->height * lcd->hwidth; pos++) + for (pos = 0; pos < min(2, lcd->height) * lcd->hwidth; pos++) lcd->ops->write_data(lcd, ' '); charlcd_home(lcd); -- 2.7.4