From patchwork Mon Oct 8 21:42:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 190141 X-Patchwork-Delegate: twarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7023A2C01FD for ; Tue, 9 Oct 2012 08:46:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC9F3281C3; Mon, 8 Oct 2012 23:46:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hA7teKIimUW4; Mon, 8 Oct 2012 23:46:50 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BF1C28189; Mon, 8 Oct 2012 23:44:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AAB32281B8 for ; Mon, 8 Oct 2012 23:44:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8aq-YWcB+U2z for ; Mon, 8 Oct 2012 23:44:18 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wg0-f74.google.com (mail-wg0-f74.google.com [74.125.82.74]) by theia.denx.de (Postfix) with ESMTPS id 613D12819D for ; Mon, 8 Oct 2012 23:44:11 +0200 (CEST) Received: by mail-wg0-f74.google.com with SMTP id dt11so287034wgb.3 for ; Mon, 08 Oct 2012 14:44:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/2LGeRqdNjeVVJ7d3E3fCVkh5OAY70TN2yPhvo29elk=; b=BDxem9mx86SIaYvgwgxRhxIUEsltHfP0yXmyzXLhMKh1E7CQEcZ+lWvVM/W0aNuKsI 4mue5e8nPRQ14a77dCEyT8hKa1BTBThEKWBzKGExT0L7sq0In3lParwhhQasLM0+XgX7 NlzVRBL2wJpWtqw0taJDvujDITaqiyrRuFZ7mTZ4uF3VByZM5HRuHtI56pGjkYiW7BM2 BZnR4Wu3z8Ax1nVIIlSn/72Lv3nBUAJlJE6kzCEfx0dV3KsUhhpddFvIs65d9tKYih2S 5zcNwnEJMcEDLDo45OBv5WZsdXBL/zAJ2wK6VCS7EbCwERCfLacd99iqUvRDcPbwadAA FLpA== Received: by 10.216.217.4 with SMTP id h4mr389038wep.7.1349732651367; Mon, 08 Oct 2012 14:44:11 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id k11si1284148wiv.0.2012.10.08.14.44.11 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 08 Oct 2012 14:44:11 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id B6381200057; Mon, 8 Oct 2012 14:44:10 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 1CBA516252E; Mon, 8 Oct 2012 14:44:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 8 Oct 2012 14:42:31 -0700 Message-Id: <1349732556-30700-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1349732556-30700-1-git-send-email-sjg@chromium.org> References: <1349732556-30700-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQkne0rXs9aWkbPVrLr3s9X1TQkuKOIHg9CMlurE+npl0fCnNzl0fU0+fRg7isHOKtFrO+6flknYvFMsFys/8uVejEWxD2lZx0IiOl0cQ2L7a/dzTXR9NR7kaQQ6mDL0YWna1jhDmI7Jl1O24lxecW/lHSWZiRFjHPj/ZxPWPJ7I8znPDFCC1aviMbsx/7k9gyeVzsA9 Cc: Tom Warren Subject: [U-Boot] [PATCH v5 11/16] lcd: Add support for flushing LCD fb from dcache after update X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This provides an option for the LCD to flush the dcache after each update (puts, scroll or clear). Signed-off-by: Simon Glass --- Changes in v4: - Use lcd_puts() for echoing user input so lcd cached data is flushed Changes in v3: - Put the LCD cache flush logic back into lcd_puts() Changes in v2: - Put the LCD cache flush logic into lcd_putc() instead of lcd_puts() common/lcd.c | 46 +++++++++++++++++++++++++++++++++++++++------- common/main.c | 12 ++++++++++-- include/lcd.h | 8 ++++++++ 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index 37b0393..74fa3f9 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -94,6 +94,9 @@ static void lcd_setbgcolor(int color); char lcd_is_enabled = 0; +static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ + + #ifdef NOT_USED_SO_FAR static void lcd_getcolreg(ushort regno, ushort *red, ushort *green, ushort *blue); @@ -102,6 +105,28 @@ static int lcd_getfgcolor(void); /************************************************************************/ +/* Flush LCD activity to the caches */ +void lcd_sync(void) +{ + /* + * flush_dcache_range() is declared in common.h but it seems that some + * architectures do not actually implement it. Is there a way to find + * out whether it exists? For now, ARM is safe. + */ +#ifdef CONFIG_ARM + int line_length; + + if (lcd_flush_dcache) + flush_dcache_range((u32)lcd_base, + (u32)(lcd_base + lcd_get_size(&line_length))); +#endif +} + +void lcd_set_flush_dcache(int flush) +{ + lcd_flush_dcache = (flush != 0); +} + /*----------------------------------------------------------------------*/ static void console_scrollup(void) @@ -111,6 +136,7 @@ static void console_scrollup(void) /* Clear the last one */ memset(CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE); + lcd_sync(); } /*----------------------------------------------------------------------*/ @@ -140,6 +166,8 @@ static inline void console_newline(void) /* Scroll everything up */ console_scrollup(); --console_row; + } else { + lcd_sync(); } } @@ -195,6 +223,7 @@ void lcd_puts(const char *s) while (*s) { lcd_putc(*s++); } + lcd_sync(); } /*----------------------------------------------------------------------*/ @@ -362,13 +391,6 @@ int drv_lcd_init (void) } /*----------------------------------------------------------------------*/ -static -int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) -{ - lcd_clear(); - return 0; -} - void lcd_clear(void) { #if LCD_BPP == LCD_MONOCHROME @@ -410,6 +432,14 @@ void lcd_clear(void) console_col = 0; console_row = 0; + lcd_sync(); +} + +static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + lcd_clear(); + return 0; } U_BOOT_CMD( @@ -621,6 +651,7 @@ void bitmap_plot(int x, int y) } WATCHDOG_RESET(); + lcd_sync(); } #else static inline void bitmap_plot(int x, int y) {} @@ -842,6 +873,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) break; }; + lcd_sync(); return 0; } #endif diff --git a/common/main.c b/common/main.c index 81984ac..d3356e1 100644 --- a/common/main.c +++ b/common/main.c @@ -1040,8 +1040,16 @@ int readline_into_buffer(const char *const prompt, char *buffer, int timeout) puts (tab_seq+(col&07)); col += 8 - (col&07); } else { - ++col; /* echo input */ - putc (c); + char buf[2]; + + /* + * Echo input using puts() to force am + * LCD flush if we are using an LCD + */ + ++col; + buf[0] = c; + buf[1] = '\0'; + puts(buf); } *p++ = c; ++n; diff --git a/include/lcd.h b/include/lcd.h index 6a600ee..8f84741 100644 --- a/include/lcd.h +++ b/include/lcd.h @@ -57,6 +57,14 @@ extern void lcd_initcolregs (void); extern struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp); extern int bmp_display(ulong addr, int x, int y); +/** + * Set whether we need to flush the dcache when changing the LCD image. This + * defaults to off. + * + * @param flush non-zero to flush cache after update, 0 to skip + */ +void lcd_set_flush_dcache(int flush); + #if defined CONFIG_MPC823 /* * LCD controller stucture for MPC823 CPU