From patchwork Tue Oct 30 23:40:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 195663 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 011ED2C009A for ; Wed, 31 Oct 2012 10:40:52 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DAC694A2E4; Wed, 31 Oct 2012 00:40:50 +0100 (CET) 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 OvunvvAHofz4; Wed, 31 Oct 2012 00:40:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E1AD4A2EA; Wed, 31 Oct 2012 00:40:48 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 624C84A2EA for ; Wed, 31 Oct 2012 00:40:46 +0100 (CET) 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 O85HdcW0+Uet for ; Wed, 31 Oct 2012 00:40:44 +0100 (CET) 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-gh0-f202.google.com (mail-gh0-f202.google.com [209.85.160.202]) by theia.denx.de (Postfix) with ESMTPS id 923EC4A2E4 for ; Wed, 31 Oct 2012 00:40:42 +0100 (CET) Received: by mail-gh0-f202.google.com with SMTP id z15so97420ghb.3 for ; Tue, 30 Oct 2012 16:40:40 -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:x-gm-message-state; bh=tyBdRZklHsTZvwoP+5YgkwCR4v6FrS34/9LAD3flLmM=; b=Xr9WVtvs4EeM8fNg1Of7WgveS6J4gd0pBMC0y2hT7IdV9eHSLPzGapKMClNszuuWzI kLau+ez8irjoNzFNPAn5yQTqLyEJA1Uf1EnpB3yUTvTqwB6dUYTt+c+z432PLZy4UCPr iqMoGMtP7sNUTOIiaSsnuCEb5XgsdjSWWwC4VXHRswgoYTEzSVVUj7TZiR0XiO+krfm4 S8OgGA2rVWKwIKw81OclZDSARXsCn+mMrO1Oday7Mat4DGrcpcvqljUWxj9Dc9FoI5PH LPIGx1pBubb6c7T75yBtvjRcb4VbMEexShu18sNrWjcwWpxY9Qbke+92cL5IM5sjrRky em9A== Received: by 10.236.175.7 with SMTP id y7mr24967368yhl.14.1351640440675; Tue, 30 Oct 2012 16:40:40 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id l1si42400anm.0.2012.10.30.16.40.40 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 30 Oct 2012 16:40:40 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 6E4A81E0048; Tue, 30 Oct 2012 16:40:40 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 20208160C95; Tue, 30 Oct 2012 16:40:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 30 Oct 2012 16:40:18 -0700 Message-Id: <1351640423-15928-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQmrIXZmSzeTV9+OBn5Dh1R6KuYOvwdpED1+dRrIwaUL0XSLvWPIjfyGlDA5VaDEKKNAoaV5yMt+7aorikcpo8P2psKU0JPQqUl6lgS5qGKL/Et6G2cxmVYOVgCXIlu6L8bVnnGnci8GAVkHbVIIoo4dGnRj9UE4fZHJo90bdUhsNINllFP6P0K5R6PhF0dKdTlUvX8I Cc: Tom Warren Subject: [U-Boot] [PATCH v8 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 v8: - Don't enable cache routines if CONFIG_SYS_DCACHE_OFF is defined 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..d2a3e91 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. + */ +#if defined(CONFIG_ARM) && !defined(CONFIG_SYS_DCACHE_OFF) + 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 9507cec..62dbcc5 100644 --- a/common/main.c +++ b/common/main.c @@ -1041,8 +1041,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