All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] [driver][cfb] Make the software cursor non-destructive
@ 2011-11-08  8:59 Gabe Black
  2011-11-08 13:43 ` Mike Frysinger
  2011-11-08 21:47 ` [U-Boot] [PATCH v2] " Gabe Black
  0 siblings, 2 replies; 11+ messages in thread
From: Gabe Black @ 2011-11-08  8:59 UTC (permalink / raw)
  To: u-boot

When printing the string "\r\n" to the framebuffer console, the first
character of the current line was being replaced with a space. The "boot"
prompt would become the "oot" prompt. This change makes the cursor
non-destructive so that no matter where it goes on its way to where it's
supposed to be, the end result is that the cursor is where it's supposed to
be with the other text preserved intact.

Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
 drivers/video/cfb_console.c |   92 ++++++++++++++++++++++---------------------
 1 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 561883a..06de04e 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -221,8 +221,7 @@
 /*
  * Cursor definition:
  * CONFIG_CONSOLE_CURSOR:  Uses a timer function (see drivers/input/i8042.c)
- *			   to let the cursor blink. Uses the macros
- *			   CURSOR_OFF and CURSOR_ON.
+ *			   to let the cursor blink.
  * CONFIG_VIDEO_SW_CURSOR: Draws a cursor after the last character. No
  *			   blinking is provided. Uses the macros CURSOR_SET
  *			   and CURSOR_OFF.
@@ -248,9 +247,9 @@
 #endif
 void console_cursor(int state);
 
-#define CURSOR_ON  console_cursor(1)
+#define CURSOR_ON console_cursor(1)
 #define CURSOR_OFF console_cursor(0)
-#define CURSOR_SET
+#define CURSOR_SET video_set_cursor()
 #ifndef CONFIG_I8042_KBD
 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
 #endif
@@ -265,9 +264,9 @@ void console_cursor(int state);
 #error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
 	or CONFIG_VIDEO_HW_CURSOR can be defined
 #endif
-#define CURSOR_ON
-#define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
-				 console_row * VIDEO_FONT_HEIGHT, ' ')
+void	console_cursor (int state);
+#define CURSOR_ON console_cursor(1)
+#define CURSOR_OFF console_cursor(0)
 #define CURSOR_SET video_set_cursor()
 #endif /* CONFIG_VIDEO_SW_CURSOR */
 
@@ -374,6 +373,10 @@ static void *video_console_address;	/* console buffer start address */
 
 static int video_logo_height = VIDEO_LOGO_HEIGHT;
 
+static int cursor_state = 0;
+static int old_col = 0;
+static int old_row = 0;
+
 static int console_col;		/* cursor col */
 static int console_row;		/* cursor row */
 
@@ -433,6 +436,22 @@ static const int video_font_draw_table32[16][4] = {
 };
 
 
+static void video_invertchar (int xx, int yy)
+{
+	int firstx = xx * VIDEO_PIXEL_SIZE;
+	int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE;
+	int firsty = yy * VIDEO_LINE_LEN;
+	int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN;
+	int x, y;
+	for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) {
+		for (x = firstx; x < lastx; x++) {
+			u8 *dest = (u8 *)(video_fb_address) + x + y;
+			*dest = ~*dest;
+		}
+	}
+}
+
+
 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
 {
 	u8 *cdat, *dest, *dest0;
@@ -608,27 +627,15 @@ static void video_putchar(int xx, int yy, unsigned char c)
 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
 static void video_set_cursor(void)
 {
-	/* swap drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
-	/* draw cursor */
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
-	/* restore drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
+	if (cursor_state)
+		console_cursor(0);
+	console_cursor(1);
 }
-#endif
 
-#ifdef CONFIG_CONSOLE_CURSOR
+
+
 void console_cursor(int state)
 {
-	static int last_state = 0;
-
 #ifdef CONFIG_CONSOLE_TIME
 	struct rtc_time tm;
 	char info[16];
@@ -650,17 +657,20 @@ void console_cursor(int state)
 	}
 #endif
 
-	if (state && (last_state != state)) {
-		video_set_cursor();
-	}
-
-	if (!state && (last_state != state)) {
-		/* clear cursor */
-		video_putchar(console_col * VIDEO_FONT_WIDTH,
-			      console_row * VIDEO_FONT_HEIGHT, ' ');
+	if (cursor_state != state) {
+		if (cursor_state) {
+			/* turn off the cursor */
+			video_invertchar(old_col * VIDEO_FONT_WIDTH,
+			                 old_row * VIDEO_FONT_HEIGHT);
+		} else {
+			/* turn off the cursor and record where it is */
+			video_invertchar(console_col * VIDEO_FONT_WIDTH,
+				         console_row * VIDEO_FONT_HEIGHT);
+			old_col = console_col;
+			old_row = console_row;
+		}
+		cursor_state = state;
 	}
-
-	last_state = state;
 }
 #endif
 
@@ -727,19 +737,11 @@ static void console_back(void)
 		if (console_row < 0)
 			console_row = 0;
 	}
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
+	CURSOR_SET;
 }
 
 static void console_newline(void)
 {
-	/* Check if last character in the line was just drawn. If so, cursor was
-	   overwriten and need not to be cleared. Cursor clearing without this
-	   check causes overwriting the 1st character of the line if line lenght
-	   is >= CONSOLE_COLS
-	 */
-	if (console_col < CONSOLE_COLS)
-		CURSOR_OFF;
 	console_row++;
 	console_col = 0;
 
@@ -755,7 +757,6 @@ static void console_newline(void)
 
 static void console_cr(void)
 {
-	CURSOR_OFF;
 	console_col = 0;
 }
 
@@ -763,6 +764,8 @@ void video_putc(const char c)
 {
 	static int nl = 1;
 
+	CURSOR_OFF;
+
 	switch (c) {
 	case 13:		/* back to first column */
 		console_cr();
@@ -775,7 +778,6 @@ void video_putc(const char c)
 		break;
 
 	case 9:		/* tab 8 */
-		CURSOR_OFF;
 		console_col |= 0x0008;
 		console_col &= ~0x0007;
 
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH] [driver][cfb] Make the software cursor non-destructive
  2011-11-08  8:59 [U-Boot] [PATCH] [driver][cfb] Make the software cursor non-destructive Gabe Black
@ 2011-11-08 13:43 ` Mike Frysinger
  2011-11-08 21:47 ` [U-Boot] [PATCH v2] " Gabe Black
  1 sibling, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2011-11-08 13:43 UTC (permalink / raw)
  To: u-boot

On Tuesday 08 November 2011 03:59:29 Gabe Black wrote:
> When printing the string "\r\n" to the framebuffer console, the first
> character of the current line was being replaced with a space. The "boot"
> prompt would become the "oot" prompt. This change makes the cursor
> non-destructive so that no matter where it goes on its way to where it's
> supposed to be, the end result is that the cursor is where it's supposed to
> be with the other text preserved intact.

"preserved intact" ... word for word verbose redundant ? ;)

> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
>
>  /*
>   * Cursor definition:
>   * CONFIG_CONSOLE_CURSOR:  Uses a timer function (see
> drivers/input/i8042.c) 
> - *			   to let the cursor blink. Uses the macros
> - *			   CURSOR_OFF and CURSOR_ON.
> + *			   to let the cursor blink.

is this intentional ?  seems like the existing doc strings are fine ...

> @@ -248,9 +247,9 @@
> 
> -#define CURSOR_ON  console_cursor(1)
> +#define CURSOR_ON console_cursor(1)

unrelated whitespace change

> -#define CURSOR_ON
> -#define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
> -				 console_row * VIDEO_FONT_HEIGHT, ' ')
> +void	console_cursor (int state);
> +#define CURSOR_ON console_cursor(1)
> +#define CURSOR_OFF console_cursor(0)
>  #define CURSOR_SET video_set_cursor()

so now the CONFIG_CONSOLE_CURSOR and CONFIG_VIDEO_SW_CURSOR code paths wrt 
CURSOR_* definitions are the same.  seems like they should be unified.

> +static void video_invertchar (int xx, int yy)

no space before that "("

the rest looks fine to me, but let's CC the video maintainer ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111108/1281fd0e/attachment.pgp 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v2] [driver][cfb] Make the software cursor non-destructive
  2011-11-08  8:59 [U-Boot] [PATCH] [driver][cfb] Make the software cursor non-destructive Gabe Black
  2011-11-08 13:43 ` Mike Frysinger
@ 2011-11-08 21:47 ` Gabe Black
  2011-11-09 22:31   ` Mike Frysinger
  2011-11-30 23:50   ` [U-Boot] [PATCH v3] video: cfb_console: " Anatolij Gustschin
  1 sibling, 2 replies; 11+ messages in thread
From: Gabe Black @ 2011-11-08 21:47 UTC (permalink / raw)
  To: u-boot

When printing the string "\r\n" to the framebuffer console, the first
character of the current line was being replaced with a space. The "boot"
prompt would become the "oot" prompt. This change makes the cursor
non-destructive so that no matter where it goes on its way to where it's
supposed to be, the end result is that the cursor is where it's supposed to
be with the other text preserved.

Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
Changes in v2:
- Tidy up commit message wording.
- Undo change to documenting comment.
- Undo minor whitespace tweak.
- Consolidate CONFIG_CONSOLE_CURSOR and CONFIG_VIDEO_SW_CURSOR.
- Get rid of a space between video_invertchar and its (.

 drivers/video/cfb_console.c |  107 ++++++++++++++++++++----------------------
 1 files changed, 51 insertions(+), 56 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 561883a..fe80866 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -241,8 +241,9 @@
 #define CURSOR_SET
 #endif
 
-#ifdef	CONFIG_CONSOLE_CURSOR
-#ifdef	CURSOR_ON
+#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
+#if defined(CURSOR_ON) || \
+	(defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
 #error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
 	or CONFIG_VIDEO_HW_CURSOR can be defined
 #endif
@@ -250,27 +251,18 @@ void console_cursor(int state);
 
 #define CURSOR_ON  console_cursor(1)
 #define CURSOR_OFF console_cursor(0)
-#define CURSOR_SET
+#define CURSOR_SET video_set_cursor()
+#endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */
+
+#ifdef	CONFIG_CONSOLE_CURSOR
+#ifndef	CONFIG_CONSOLE_TIME
+#error	CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
+#endif
 #ifndef CONFIG_I8042_KBD
 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
 #endif
-#else
-#ifdef	CONFIG_CONSOLE_TIME
-#error	CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
-#endif
 #endif /* CONFIG_CONSOLE_CURSOR */
 
-#ifdef	CONFIG_VIDEO_SW_CURSOR
-#ifdef	CURSOR_ON
-#error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
-	or CONFIG_VIDEO_HW_CURSOR can be defined
-#endif
-#define CURSOR_ON
-#define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
-				 console_row * VIDEO_FONT_HEIGHT, ' ')
-#define CURSOR_SET video_set_cursor()
-#endif /* CONFIG_VIDEO_SW_CURSOR */
-
 
 #ifdef CONFIG_VIDEO_HW_CURSOR
 #ifdef	CURSOR_ON
@@ -374,6 +366,10 @@ static void *video_console_address;	/* console buffer start address */
 
 static int video_logo_height = VIDEO_LOGO_HEIGHT;
 
+static int cursor_state = 0;
+static int old_col = 0;
+static int old_row = 0;
+
 static int console_col;		/* cursor col */
 static int console_row;		/* cursor row */
 
@@ -433,6 +429,22 @@ static const int video_font_draw_table32[16][4] = {
 };
 
 
+static void video_invertchar(int xx, int yy)
+{
+	int firstx = xx * VIDEO_PIXEL_SIZE;
+	int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE;
+	int firsty = yy * VIDEO_LINE_LEN;
+	int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN;
+	int x, y;
+	for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) {
+		for (x = firstx; x < lastx; x++) {
+			u8 *dest = (u8 *)(video_fb_address) + x + y;
+			*dest = ~*dest;
+		}
+	}
+}
+
+
 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
 {
 	u8 *cdat, *dest, *dest0;
@@ -608,27 +620,15 @@ static void video_putchar(int xx, int yy, unsigned char c)
 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
 static void video_set_cursor(void)
 {
-	/* swap drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
-	/* draw cursor */
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
-	/* restore drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
+	if (cursor_state)
+		console_cursor(0);
+	console_cursor(1);
 }
-#endif
 
-#ifdef CONFIG_CONSOLE_CURSOR
+
+
 void console_cursor(int state)
 {
-	static int last_state = 0;
-
 #ifdef CONFIG_CONSOLE_TIME
 	struct rtc_time tm;
 	char info[16];
@@ -650,17 +650,20 @@ void console_cursor(int state)
 	}
 #endif
 
-	if (state && (last_state != state)) {
-		video_set_cursor();
-	}
-
-	if (!state && (last_state != state)) {
-		/* clear cursor */
-		video_putchar(console_col * VIDEO_FONT_WIDTH,
-			      console_row * VIDEO_FONT_HEIGHT, ' ');
+	if (cursor_state != state) {
+		if (cursor_state) {
+			/* turn off the cursor */
+			video_invertchar(old_col * VIDEO_FONT_WIDTH,
+			                 old_row * VIDEO_FONT_HEIGHT);
+		} else {
+			/* turn off the cursor and record where it is */
+			video_invertchar(console_col * VIDEO_FONT_WIDTH,
+				         console_row * VIDEO_FONT_HEIGHT);
+			old_col = console_col;
+			old_row = console_row;
+		}
+		cursor_state = state;
 	}
-
-	last_state = state;
 }
 #endif
 
@@ -727,19 +730,11 @@ static void console_back(void)
 		if (console_row < 0)
 			console_row = 0;
 	}
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
+	CURSOR_SET;
 }
 
 static void console_newline(void)
 {
-	/* Check if last character in the line was just drawn. If so, cursor was
-	   overwriten and need not to be cleared. Cursor clearing without this
-	   check causes overwriting the 1st character of the line if line lenght
-	   is >= CONSOLE_COLS
-	 */
-	if (console_col < CONSOLE_COLS)
-		CURSOR_OFF;
 	console_row++;
 	console_col = 0;
 
@@ -755,7 +750,6 @@ static void console_newline(void)
 
 static void console_cr(void)
 {
-	CURSOR_OFF;
 	console_col = 0;
 }
 
@@ -763,6 +757,8 @@ void video_putc(const char c)
 {
 	static int nl = 1;
 
+	CURSOR_OFF;
+
 	switch (c) {
 	case 13:		/* back to first column */
 		console_cr();
@@ -775,7 +771,6 @@ void video_putc(const char c)
 		break;
 
 	case 9:		/* tab 8 */
-		CURSOR_OFF;
 		console_col |= 0x0008;
 		console_col &= ~0x0007;
 
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v2] [driver][cfb] Make the software cursor non-destructive
  2011-11-08 21:47 ` [U-Boot] [PATCH v2] " Gabe Black
@ 2011-11-09 22:31   ` Mike Frysinger
  2011-11-30  9:55     ` Gabe Black
  2011-11-30 23:50   ` [U-Boot] [PATCH v3] video: cfb_console: " Anatolij Gustschin
  1 sibling, 1 reply; 11+ messages in thread
From: Mike Frysinger @ 2011-11-09 22:31 UTC (permalink / raw)
  To: u-boot

i don't know the video code all that well, but i don't see anything wrong with 
this patch ...

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111109/9295545e/attachment.pgp 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v2] [driver][cfb] Make the software cursor non-destructive
  2011-11-09 22:31   ` Mike Frysinger
@ 2011-11-30  9:55     ` Gabe Black
  2011-11-30 10:04       ` Anatolij Gustschin
  0 siblings, 1 reply; 11+ messages in thread
From: Gabe Black @ 2011-11-30  9:55 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 9, 2011 at 5:31 PM, Mike Frysinger <vapier@gentoo.org> wrote:

> i don't know the video code all that well, but i don't see anything wrong
> with
> this patch ...
>
> Acked-by: Mike Frysinger <vapier@gentoo.org>
> -mike
>

Bump.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v2] [driver][cfb] Make the software cursor non-destructive
  2011-11-30  9:55     ` Gabe Black
@ 2011-11-30 10:04       ` Anatolij Gustschin
  0 siblings, 0 replies; 11+ messages in thread
From: Anatolij Gustschin @ 2011-11-30 10:04 UTC (permalink / raw)
  To: u-boot

Hi,

On Wed, 30 Nov 2011 04:55:52 -0500
Gabe Black <gabeblack@google.com> wrote:

> On Wed, Nov 9, 2011 at 5:31 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> 
> > i don't know the video code all that well, but i don't see anything wrong
> > with
> > this patch ...
> >
> > Acked-by: Mike Frysinger <vapier@gentoo.org>
> > -mike
> >
> 
> Bump.

This patch is on my TODO list. I'll look at it later today.

Thanks,
Anatolij

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v3] video: cfb_console: Make the software cursor non-destructive
  2011-11-08 21:47 ` [U-Boot] [PATCH v2] " Gabe Black
  2011-11-09 22:31   ` Mike Frysinger
@ 2011-11-30 23:50   ` Anatolij Gustschin
  2011-12-05 21:07     ` Anatolij Gustschin
  1 sibling, 1 reply; 11+ messages in thread
From: Anatolij Gustschin @ 2011-11-30 23:50 UTC (permalink / raw)
  To: u-boot

From: Gabe Black <gabeblack@chromium.org>

When printing the string "\r\n" to the framebuffer console, the first
character of the current line was being replaced with a space. The "boot"
prompt would become the "oot" prompt. This change makes the cursor
non-destructive so that no matter where it goes on its way to where it's
supposed to be, the end result is that the cursor is where it's supposed to
be with the other text preserved.

Signed-off-by: Gabe Black <gabeblack@chromium.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Changes in v3:
- fixed checkpatch errors
- slightly modified subject line
- fixed cursor position if video logo is used

Changes in v2:
- Tidy up commit message wording.
- Undo change to documenting comment.
- Undo minor whitespace tweak.
- Consolidate CONFIG_CONSOLE_CURSOR and CONFIG_VIDEO_SW_CURSOR.
- Get rid of a space between video_invertchar and its (.

 drivers/video/cfb_console.c |  109 +++++++++++++++++++++----------------------
 1 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 480df64..9be6166 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -242,8 +242,9 @@
 #define CURSOR_SET
 #endif
 
-#ifdef	CONFIG_CONSOLE_CURSOR
-#ifdef	CURSOR_ON
+#if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
+#if defined(CURSOR_ON) || \
+	(defined(CONFIG_CONSOLE_CURSOR) && defined(CONFIG_VIDEO_SW_CURSOR))
 #error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
 	or CONFIG_VIDEO_HW_CURSOR can be defined
 #endif
@@ -251,27 +252,18 @@ void console_cursor(int state);
 
 #define CURSOR_ON  console_cursor(1)
 #define CURSOR_OFF console_cursor(0)
-#define CURSOR_SET
+#define CURSOR_SET video_set_cursor()
+#endif /* CONFIG_CONSOLE_CURSOR || CONFIG_VIDEO_SW_CURSOR */
+
+#ifdef	CONFIG_CONSOLE_CURSOR
+#ifndef	CONFIG_CONSOLE_TIME
+#error	CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
+#endif
 #ifndef CONFIG_I8042_KBD
 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
 #endif
-#else
-#ifdef	CONFIG_CONSOLE_TIME
-#error	CONFIG_CONSOLE_CURSOR must be defined for CONFIG_CONSOLE_TIME
-#endif
 #endif /* CONFIG_CONSOLE_CURSOR */
 
-#ifdef	CONFIG_VIDEO_SW_CURSOR
-#ifdef	CURSOR_ON
-#error	only one of CONFIG_CONSOLE_CURSOR, CONFIG_VIDEO_SW_CURSOR, \
-	or CONFIG_VIDEO_HW_CURSOR can be defined
-#endif
-#define CURSOR_ON
-#define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
-				 console_row * VIDEO_FONT_HEIGHT, ' ')
-#define CURSOR_SET video_set_cursor()
-#endif /* CONFIG_VIDEO_SW_CURSOR */
-
 
 #ifdef CONFIG_VIDEO_HW_CURSOR
 #ifdef	CURSOR_ON
@@ -376,6 +368,10 @@ static void *video_console_address;	/* console buffer start address */
 
 static int video_logo_height = VIDEO_LOGO_HEIGHT;
 
+static int cursor_state;
+static int old_col;
+static int old_row;
+
 static int console_col;		/* cursor col */
 static int console_row;		/* cursor row */
 
@@ -435,6 +431,22 @@ static const int video_font_draw_table32[16][4] = {
 };
 
 
+static void video_invertchar(int xx, int yy)
+{
+	int firstx = xx * VIDEO_PIXEL_SIZE;
+	int lastx = (xx + VIDEO_FONT_WIDTH) * VIDEO_PIXEL_SIZE;
+	int firsty = yy * VIDEO_LINE_LEN;
+	int lasty = (yy + VIDEO_FONT_HEIGHT) * VIDEO_LINE_LEN;
+	int x, y;
+	for (y = firsty; y < lasty; y += VIDEO_LINE_LEN) {
+		for (x = firstx; x < lastx; x++) {
+			u8 *dest = (u8 *)(video_fb_address) + x + y;
+			*dest = ~*dest;
+		}
+	}
+}
+
+
 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
 {
 	u8 *cdat, *dest, *dest0;
@@ -610,27 +622,15 @@ static void video_putchar(int xx, int yy, unsigned char c)
 #if defined(CONFIG_CONSOLE_CURSOR) || defined(CONFIG_VIDEO_SW_CURSOR)
 static void video_set_cursor(void)
 {
-	/* swap drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
-	/* draw cursor */
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
-	/* restore drawing colors */
-	eorx = fgx;
-	fgx = bgx;
-	bgx = eorx;
-	eorx = fgx ^ bgx;
+	if (cursor_state)
+		console_cursor(0);
+	console_cursor(1);
 }
-#endif
 
-#ifdef CONFIG_CONSOLE_CURSOR
+
+
 void console_cursor(int state)
 {
-	static int last_state = 0;
-
 #ifdef CONFIG_CONSOLE_TIME
 	struct rtc_time tm;
 	char info[16];
@@ -652,17 +652,22 @@ void console_cursor(int state)
 	}
 #endif
 
-	if (state && (last_state != state)) {
-		video_set_cursor();
-	}
-
-	if (!state && (last_state != state)) {
-		/* clear cursor */
-		video_putchar(console_col * VIDEO_FONT_WIDTH,
-			      console_row * VIDEO_FONT_HEIGHT, ' ');
+	if (cursor_state != state) {
+		if (cursor_state) {
+			/* turn off the cursor */
+			video_invertchar(old_col * VIDEO_FONT_WIDTH,
+					 old_row * VIDEO_FONT_HEIGHT +
+					 video_logo_height);
+		} else {
+			/* turn off the cursor and record where it is */
+			video_invertchar(console_col * VIDEO_FONT_WIDTH,
+					 console_row * VIDEO_FONT_HEIGHT +
+					 video_logo_height);
+			old_col = console_col;
+			old_row = console_row;
+		}
+		cursor_state = state;
 	}
-
-	last_state = state;
 }
 #endif
 
@@ -729,19 +734,11 @@ static void console_back(void)
 		if (console_row < 0)
 			console_row = 0;
 	}
-	video_putchar(console_col * VIDEO_FONT_WIDTH,
-		      console_row * VIDEO_FONT_HEIGHT, ' ');
+	CURSOR_SET;
 }
 
 static void console_newline(void)
 {
-	/* Check if last character in the line was just drawn. If so, cursor was
-	   overwriten and need not to be cleared. Cursor clearing without this
-	   check causes overwriting the 1st character of the line if line lenght
-	   is >= CONSOLE_COLS
-	 */
-	if (console_col < CONSOLE_COLS)
-		CURSOR_OFF;
 	console_row++;
 	console_col = 0;
 
@@ -757,7 +754,6 @@ static void console_newline(void)
 
 static void console_cr(void)
 {
-	CURSOR_OFF;
 	console_col = 0;
 }
 
@@ -765,6 +761,8 @@ void video_putc(const char c)
 {
 	static int nl = 1;
 
+	CURSOR_OFF;
+
 	switch (c) {
 	case 13:		/* back to first column */
 		console_cr();
@@ -777,7 +775,6 @@ void video_putc(const char c)
 		break;
 
 	case 9:		/* tab 8 */
-		CURSOR_OFF;
 		console_col |= 0x0008;
 		console_col &= ~0x0007;
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v3] video: cfb_console: Make the software cursor non-destructive
  2011-11-30 23:50   ` [U-Boot] [PATCH v3] video: cfb_console: " Anatolij Gustschin
@ 2011-12-05 21:07     ` Anatolij Gustschin
  2012-03-18 18:38       ` Wolfgang Denk
  0 siblings, 1 reply; 11+ messages in thread
From: Anatolij Gustschin @ 2011-12-05 21:07 UTC (permalink / raw)
  To: u-boot

On Thu,  1 Dec 2011 00:50:50 +0100
Anatolij Gustschin <agust@denx.de> wrote:

> From: Gabe Black <gabeblack@chromium.org>
> 
> When printing the string "\r\n" to the framebuffer console, the first
> character of the current line was being replaced with a space. The "boot"
> prompt would become the "oot" prompt. This change makes the cursor
> non-destructive so that no matter where it goes on its way to where it's
> supposed to be, the end result is that the cursor is where it's supposed to
> be with the other text preserved.
> 
> Signed-off-by: Gabe Black <gabeblack@chromium.org>
> Acked-by: Mike Frysinger <vapier@gentoo.org>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> Changes in v3:
> - fixed checkpatch errors
> - slightly modified subject line
> - fixed cursor position if video logo is used
> 
> Changes in v2:
> - Tidy up commit message wording.
> - Undo change to documenting comment.
> - Undo minor whitespace tweak.
> - Consolidate CONFIG_CONSOLE_CURSOR and CONFIG_VIDEO_SW_CURSOR.
> - Get rid of a space between video_invertchar and its (.
> 
>  drivers/video/cfb_console.c |  109 +++++++++++++++++++++----------------------
>  1 files changed, 53 insertions(+), 56 deletions(-)

Applied to u-boot-video/master. Thanks!

Anatolij

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v3] video: cfb_console: Make the software cursor non-destructive
  2011-12-05 21:07     ` Anatolij Gustschin
@ 2012-03-18 18:38       ` Wolfgang Denk
  2012-03-18 19:01         ` Anatolij Gustschin
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Denk @ 2012-03-18 18:38 UTC (permalink / raw)
  To: u-boot

Dear Anatolij Gustschin,

In message <20111205220742.18ed6e2f@wker> you wrote:
> On Thu,  1 Dec 2011 00:50:50 +0100
> Anatolij Gustschin <agust@denx.de> wrote:
> 
> > From: Gabe Black <gabeblack@chromium.org>
> > 
> > When printing the string "\r\n" to the framebuffer console, the first
> > character of the current line was being replaced with a space. The "boot"
> > prompt would become the "oot" prompt. This change makes the cursor
> > non-destructive so that no matter where it goes on its way to where it's
> > supposed to be, the end result is that the cursor is where it's supposed to
> > be with the other text preserved.
> > 
> > Signed-off-by: Gabe Black <gabeblack@chromium.org>
> > Acked-by: Mike Frysinger <vapier@gentoo.org>
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > ---
> > Changes in v3:
> > - fixed checkpatch errors
> > - slightly modified subject line
> > - fixed cursor position if video logo is used
> > 
> > Changes in v2:
> > - Tidy up commit message wording.
> > - Undo change to documenting comment.
> > - Undo minor whitespace tweak.
> > - Consolidate CONFIG_CONSOLE_CURSOR and CONFIG_VIDEO_SW_CURSOR.
> > - Get rid of a space between video_invertchar and its (.
> > 
> >  drivers/video/cfb_console.c |  109 +++++++++++++++++++++----------------------
> >  1 files changed, 53 insertions(+), 56 deletions(-)
> 
> Applied to u-boot-video/master. Thanks!

It appears this has not made it into mainline yet.

Is it still queued in your repo?  Do you intend to send a pull request
any time soon?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Why is an average signature file longer than an average Perl script??

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v3] video: cfb_console: Make the software cursor non-destructive
  2012-03-18 18:38       ` Wolfgang Denk
@ 2012-03-18 19:01         ` Anatolij Gustschin
  2012-03-18 19:31           ` Wolfgang Denk
  0 siblings, 1 reply; 11+ messages in thread
From: Anatolij Gustschin @ 2012-03-18 19:01 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang,

On Sun, 18 Mar 2012 19:38:57 +0100
Wolfgang Denk <wd@denx.de> wrote:
...
> > >  drivers/video/cfb_console.c |  109 +++++++++++++++++++++----------------------
> > >  1 files changed, 53 insertions(+), 56 deletions(-)
> > 
> > Applied to u-boot-video/master. Thanks!
> 
> It appears this has not made it into mainline yet.
> 
> Is it still queued in your repo?  Do you intend to send a pull request
> any time soon?

This patch was included in my last pull request and is already in
mainline [1]. Unfortunately it caused some issues on N900 as reported
by Pali Roh?r. He already tested my another testing patch for fixing
these issues and I'm working on a final patch for mainline and intend
to submit this final patch for inclusion into upcoming release. 

Best regards,
Anatolij

[1] http://git.denx.de/?p=u-boot.git;a=commit;h=03d31fcf4c37d90a00e66f06b38742960139f090

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH v3] video: cfb_console: Make the software cursor non-destructive
  2012-03-18 19:01         ` Anatolij Gustschin
@ 2012-03-18 19:31           ` Wolfgang Denk
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfgang Denk @ 2012-03-18 19:31 UTC (permalink / raw)
  To: u-boot

Dear Anatolij Gustschin,

In message <20120318200142.5b4d5dba@wker> you wrote:
> 
> This patch was included in my last pull request and is already in
> mainline [1]. Unfortunately it caused some issues on N900 as reported

Strange.  I don;t know how I missed it.  Thanks.

> by Pali Roh?r. He already tested my another testing patch for fixing
> these issues and I'm working on a final patch for mainline and intend
> to submit this final patch for inclusion into upcoming release. 

Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A UNIX saleslady, Lenore,
Enjoys work, but she likes the beach more.
        She found a good way
        To combine work and play:
She sells C shells by the seashore.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-03-18 19:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  8:59 [U-Boot] [PATCH] [driver][cfb] Make the software cursor non-destructive Gabe Black
2011-11-08 13:43 ` Mike Frysinger
2011-11-08 21:47 ` [U-Boot] [PATCH v2] " Gabe Black
2011-11-09 22:31   ` Mike Frysinger
2011-11-30  9:55     ` Gabe Black
2011-11-30 10:04       ` Anatolij Gustschin
2011-11-30 23:50   ` [U-Boot] [PATCH v3] video: cfb_console: " Anatolij Gustschin
2011-12-05 21:07     ` Anatolij Gustschin
2012-03-18 18:38       ` Wolfgang Denk
2012-03-18 19:01         ` Anatolij Gustschin
2012-03-18 19:31           ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.