From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] video: cfb_console: flush dcache for frame buffer in DRAM
Date: Mon, 30 Apr 2012 04:25:50 +0200 [thread overview]
Message-ID: <201204300425.51019.marex@denx.de> (raw)
In-Reply-To: <1335625447-24189-1-git-send-email-agust@denx.de>
Dear Anatolij Gustschin,
> Data cache flushing is required for frame buffer in RAM to fix the
> distorted console text output. Currently this text distortion is
> observed with cfb on beageboard and N900 when running with data
> cache enabled.
beagleboard ;-)
>
> Reported-by: Pali Roh?r <pali.rohar@gmail.com>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> drivers/video/cfb_console.c | 35 +++++++++++++++++++++++++++++++++++
> 1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
> index 904caf7..dd7ccb7 100644
> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
> @@ -360,6 +360,8 @@ void console_cursor(int state);
> extern void video_get_info_str(int line_number, char *info);
> #endif
>
> +DECLARE_GLOBAL_DATA_PTR;
> +
> /* Locals */
> static GraphicDevice *pGD; /* Pointer to Graphic array */
>
> @@ -377,6 +379,8 @@ static int console_row; /* cursor row */
>
> static u32 eorx, fgx, bgx; /* color pats */
>
> +static int cfb_do_flush_cache;
> +
> static const int video_font_draw_table8[] = {
> 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff,
> 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff,
> @@ -553,6 +557,8 @@ static void video_drawchars(int xx, int yy, unsigned
> char *s, int count) SWAP32((video_font_draw_table32
> [bits & 15][3] & eorx) ^ bgx);
> }
> + if (cfb_do_flush_cache)
> + flush_cache((ulong)dest0, 32);
flush_dcache_range() ?
> dest0 += VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE;
> s++;
> }
> @@ -621,6 +627,8 @@ static void video_invertchar(int xx, int yy)
> for (x = firstx; x < lastx; x++) {
> u8 *dest = (u8 *)(video_fb_address) + x + y;
> *dest = ~*dest;
> + if (cfb_do_flush_cache)
> + flush_cache((ulong)dest, 4);
DTTO
> }
> }
> }
> @@ -717,6 +725,8 @@ static void console_scrollup(void)
> #else
> memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
> #endif
> + if (cfb_do_flush_cache)
> + flush_cache((ulong)CONSOLE_ROW_FIRST, CONSOLE_SIZE);
> }
>
> static void console_back(void)
> @@ -1651,6 +1661,29 @@ static void *video_logo(void)
> }
> #endif
>
> +static int cfb_fb_is_in_dram(void)
> +{
> + bd_t *bd = gd->bd;
> + ulong start, end;
> + int i;
> +
> + for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
> +#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(COFNIG_NDS32)
> || \ +defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
> + start = bd->bi_dram[i].start;
> + end = bd->bi_dram[i].start + bd->bi_dram[i].size - 1;
> +#else
> + start = bd->bi_memstart;
> + end = bd->bi_memsize;
> +#endif
> +
> + if ((ulong)video_fb_address >= start &&
> + (ulong)video_fb_address < end)
> + return 1;
> + }
> + return 0;
> +}
Can't you have SRAM cached too? ;-)
> +
> static int video_init(void)
> {
> unsigned char color8;
> @@ -1664,6 +1697,8 @@ static int video_init(void)
> video_init_hw_cursor(VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
> #endif
>
> + cfb_do_flush_cache = cfb_fb_is_in_dram() && dcache_status();
> +
> /* Init drawing pats */
> switch (VIDEO_DATA_FORMAT) {
> case GDF__8BIT_INDEX:
next prev parent reply other threads:[~2012-04-30 2:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-28 15:04 [U-Boot] [PATCH] video: cfb_console: flush dcache for frame buffer in DRAM Anatolij Gustschin
2012-04-28 15:58 ` Pali Rohár
2012-04-28 18:16 ` Mike Frysinger
2012-04-30 15:32 ` Anatolij Gustschin
2012-05-01 4:14 ` Mike Frysinger
2012-04-30 2:25 ` Marek Vasut [this message]
2012-04-30 5:56 ` Simon Glass
2012-04-30 16:26 ` Anatolij Gustschin
2012-04-30 15:19 ` Anatolij Gustschin
2012-04-30 15:21 ` Marek Vasut
2012-04-30 15:27 ` Anatolij Gustschin
2012-04-30 15:57 ` Marek Vasut
2012-06-05 7:28 ` Anatolij Gustschin
2012-07-19 13:26 ` Mike Frysinger
2012-07-19 15:49 ` Marek Vasut
2012-07-19 16:51 ` Mike Frysinger
-- strict thread matches above, loose matches on Subject: below --
2012-09-18 2:49 Eric Nelson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201204300425.51019.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox