Patchwork [U-Boot,06/14] cfb_console: Add function console_clear and console_clear_line

login
register
mail settings
Submitter Pali Rohár
Date Jan. 24, 2012, 2:28 p.m.
Message ID <1327415291-13260-7-git-send-email-pali.rohar@gmail.com>
Download mbox | patch
Permalink /patch/137563/
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Comments

Pali Rohár - Jan. 24, 2012, 2:28 p.m.
* console_clear - clear full console framebuffer output
 * console_clear_line - clear part of specified line (or full)

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
Changes since original version:
   - Fixed commit message

 drivers/video/cfb_console.c |   64 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 12 deletions(-)
Marek Vasut - Jan. 25, 2012, 6:08 p.m.
>  * console_clear - clear full console framebuffer output
>  * console_clear_line - clear part of specified line (or full)
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> ---
> Changes since original version:
>    - Fixed commit message
> 
>  drivers/video/cfb_console.c |   64
> +++++++++++++++++++++++++++++++++++-------- 1 files changed, 52
> insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
> index 9092399..b74d6d0 100644
> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
> @@ -683,6 +683,57 @@ static void memcpyl(int *d, int *s, int c)
>  }
>  #endif
> 
> +static void console_clear(void)

Do you use this function AT ALL?

> +{
> +#ifdef VIDEO_HW_RECTFILL
> +	video_hw_rectfill(VIDEO_PIXEL_SIZE,	/* bytes per pixel */
> +			  0,			/* dest pos x */
> +			  video_logo_height,	/* dest pos y */
> +			  VIDEO_VISIBLE_COLS,	/* frame width */
> +			  VIDEO_VISIBLE_ROWS,	/* frame height */
> +			  bgx			/* fill color */
> +	);
> +#else
> +	memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE, bgx);
> +#endif
> +}
> +
> +static void console_clear_line(int line, int begin, int end)
> +{
> +#ifdef VIDEO_HW_RECTFILL
> +	video_hw_rectfill(VIDEO_PIXEL_SIZE,		/* bytes per pixel */
> +			  /* FIXME: correct? */
> +			  VIDEO_FONT_WIDTH * begin,	/* dest pos x */
> +			  /* FIXME: correct? */
> +			  video_logo_height +
> +			  CONSOLE_ROW_SIZE * line,	/* dest pos y */
> +			  /* FIXME: correct? */
> +			  VIDEO_FONT_WIDTH * (end - begin), /* frame width */
> +			  VIDEO_FONT_HEIGHT,		/* frame height */
> +			  bgx				/* fill color */
> +		);
> +#else
> +	int i;
> +	if (begin == 0 && end == CONSOLE_COLS)
> +		memsetl(CONSOLE_ROW_FIRST +
> +			CONSOLE_ROW_SIZE * line,	/* offset of row */
> +			CONSOLE_ROW_SIZE >> 2,		/* length of row */
> +			bgx				/* fill color */
> +		);
> +	else
> +		for (i = 0; i < VIDEO_FONT_HEIGHT; ++i)
> +			memsetl(CONSOLE_ROW_FIRST +
> +				CONSOLE_ROW_SIZE * line + /* offset of row */
> +				VIDEO_FONT_WIDTH *
> +				VIDEO_PIXEL_SIZE * begin + /* offset of col */
> +				i * VIDEO_LINE_LEN, /* col offset of i line */
> +				(VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE *
> +				(end - begin + 1)) >> 2, /* length to end */
> +				bgx			/* fill color */
> +				);
> +#endif
> +}
> +
>  static void console_scrollup(void)
>  {
>  	/* copy up rows ignoring the first one */
> @@ -705,18 +756,7 @@ static void console_scrollup(void)
>  #endif
> 
>  	/* clear the last one */
> -#ifdef VIDEO_HW_RECTFILL
> -	video_hw_rectfill(VIDEO_PIXEL_SIZE,	/* bytes per pixel */
> -			  0,			/* dest pos x */
> -			  VIDEO_VISIBLE_ROWS
> -			  - VIDEO_FONT_HEIGHT,	/* dest pos y */
> -			  VIDEO_VISIBLE_COLS,	/* frame width */
> -			  VIDEO_FONT_HEIGHT,	/* frame height */
> -			  CONSOLE_BG_COL	/* fill color */
> -		);
> -#else
> -	memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
> -#endif
> +	console_clear_line(CONSOLE_ROWS-1, 0, CONSOLE_COLS);
>  }
> 
>  static void console_back(void)
Pali Rohár - Jan. 25, 2012, 7:31 p.m.
On Wednesday 25 January 2012 19:08:31 Marek Vasut wrote:
> > 
> > +static void console_clear(void)
> 
> Do you use this function AT ALL?
> 

Yes, in patch which add ANSI terminal support to cfb_console.
Marek Vasut - Jan. 25, 2012, 8:54 p.m.
> On Wednesday 25 January 2012 19:08:31 Marek Vasut wrote:
> > > +static void console_clear(void)
> > 
> > Do you use this function AT ALL?
> 
> Yes, in patch which add ANSI terminal support to cfb_console.

Why do you even need the support for ANSI terminal in the first place?

Patch

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 9092399..b74d6d0 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -683,6 +683,57 @@  static void memcpyl(int *d, int *s, int c)
 }
 #endif
 
+static void console_clear(void)
+{
+#ifdef VIDEO_HW_RECTFILL
+	video_hw_rectfill(VIDEO_PIXEL_SIZE,	/* bytes per pixel */
+			  0,			/* dest pos x */
+			  video_logo_height,	/* dest pos y */
+			  VIDEO_VISIBLE_COLS,	/* frame width */
+			  VIDEO_VISIBLE_ROWS,	/* frame height */
+			  bgx			/* fill color */
+	);
+#else
+	memsetl(CONSOLE_ROW_FIRST, CONSOLE_SIZE, bgx);
+#endif
+}
+
+static void console_clear_line(int line, int begin, int end)
+{
+#ifdef VIDEO_HW_RECTFILL
+	video_hw_rectfill(VIDEO_PIXEL_SIZE,		/* bytes per pixel */
+			  /* FIXME: correct? */
+			  VIDEO_FONT_WIDTH * begin,	/* dest pos x */
+			  /* FIXME: correct? */
+			  video_logo_height +
+			  CONSOLE_ROW_SIZE * line,	/* dest pos y */
+			  /* FIXME: correct? */
+			  VIDEO_FONT_WIDTH * (end - begin), /* frame width */
+			  VIDEO_FONT_HEIGHT,		/* frame height */
+			  bgx				/* fill color */
+		);
+#else
+	int i;
+	if (begin == 0 && end == CONSOLE_COLS)
+		memsetl(CONSOLE_ROW_FIRST +
+			CONSOLE_ROW_SIZE * line,	/* offset of row */
+			CONSOLE_ROW_SIZE >> 2,		/* length of row */
+			bgx				/* fill color */
+		);
+	else
+		for (i = 0; i < VIDEO_FONT_HEIGHT; ++i)
+			memsetl(CONSOLE_ROW_FIRST +
+				CONSOLE_ROW_SIZE * line + /* offset of row */
+				VIDEO_FONT_WIDTH *
+				VIDEO_PIXEL_SIZE * begin + /* offset of col */
+				i * VIDEO_LINE_LEN, /* col offset of i line */
+				(VIDEO_FONT_WIDTH * VIDEO_PIXEL_SIZE *
+				(end - begin + 1)) >> 2, /* length to end */
+				bgx			/* fill color */
+				);
+#endif
+}
+
 static void console_scrollup(void)
 {
 	/* copy up rows ignoring the first one */
@@ -705,18 +756,7 @@  static void console_scrollup(void)
 #endif
 
 	/* clear the last one */
-#ifdef VIDEO_HW_RECTFILL
-	video_hw_rectfill(VIDEO_PIXEL_SIZE,	/* bytes per pixel */
-			  0,			/* dest pos x */
-			  VIDEO_VISIBLE_ROWS
-			  - VIDEO_FONT_HEIGHT,	/* dest pos y */
-			  VIDEO_VISIBLE_COLS,	/* frame width */
-			  VIDEO_FONT_HEIGHT,	/* frame height */
-			  CONSOLE_BG_COL	/* fill color */
-		);
-#else
-	memsetl(CONSOLE_ROW_LAST, CONSOLE_ROW_SIZE >> 2, CONSOLE_BG_COL);
-#endif
+	console_clear_line(CONSOLE_ROWS-1, 0, CONSOLE_COLS);
 }
 
 static void console_back(void)