WIP: video: implement quick-n-dirty framebuffer console
RFC 1/1 WIP: video: implement quick-n-dirty framebuffer console
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).
fbconsole mini-HOWTO
====================
1. compile sandbox barebox with
CONFIG_VIDEO=y
CONFIG_FBCONSOLE=y
CONFIG_DRIVER_VIDEO_SDL=y
2. run barebox
3. test fbconsole
fbconsole0.active=o
TODO:
* no visible cursor;
* FIXME: /dev/fb0 is hardcoded;
* FIXME: drop blanckchar() dirty hack;
* Sascha Hauer: character set should be prerendered for the actual framebuffer format before printing a string.
--- drivers/video/Kconfig | 5 + drivers/video/Makefile | 1 + drivers/video/fbconsole.c | 259 +++ drivers/video/sdl.c | 7 +- include/video_font_data.h | 4627 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 4898 insertions(+), 1 deletion(-) create mode 100644 drivers/video/fbconsole.c create mode 100644 include/video_font_data.h
drivers/video/Kconfig +5 -0
@@ -5,6 +5,11 @@ menuconfig VIDEO if VIDEO +config FBCONSOLE + bool + select IMAGE_RENDERER + prompt "framebuffer console support" + config DRIVER_VIDEO_ATMEL bool "Atmel LCDC framebuffer driver" depends on ARCH_AT91
drivers/video/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_DRIVER_VIDEO_EDID) += edid.o obj-$(CONFIG_OFDEVICE) += of_display_timing.o obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT) += backlight.o obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT_PWM) += backlight-pwm.o +obj-$(CONFIG_FBCONSOLE) += fbconsole.o obj-$(CONFIG_DRIVER_VIDEO_ATMEL) += atmel_lcdfb.o atmel_lcdfb_core.o obj-$(CONFIG_DRIVER_VIDEO_ATMEL_HLCD) += atmel_hlcdfb.o atmel_lcdfb_core.o
drivers/video/fbconsole.c new file +259 -0
259 lines not on this page · raw message
drivers/video/sdl.c +6 -1
@@ -69,8 +69,13 @@ static int sdlfb_probe(struct device_d *dev) dev->priv = fb; ret =register_framebuffer (fb); -if (!ret) +if (!ret) { +extern int register_fbconsole (struct fb_info *fb); + +register_fbconsole (fb); +return 0 ; + } err:kfree (fb->screen_base);
include/video_font_data.h new file +4627 -0
2,709 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Part of the diff is not shown here. View the raw message.
Hi Antony,
Quoted 9 lines · Antony Pavlov
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (
git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).
There's even one in barebox in drivers/serial/efi-stdio.c
Quoted 10 lines
fbconsole mini-HOWTO
====================1. compile sandbox barebox with
CONFIG_VIDEO=y
CONFIG_FBCONSOLE=y
CONFIG_DRIVER_VIDEO_SDL=y
Quoted 5 lines
2. run barebox
3. test fbconsole
fbconsole0.active=o
I gave it a try on real hardware. Works nice.
Quoted 4 lines
TODO:
* no visible cursor;
I couldn't resist and did some hacking on this. The cursor is visible now. Also I implemented more control characters and color support. I'll send an update patch shortly.
Quoted 4 lines
* FIXME:
/dev/fb0is hardcoded;
* FIXME: dropblanckchar()dirty hack;
* Sascha Hauer: character set should be prerendered for the actual framebuffer format before printing a string.
Did I mention that ealier? I don't know if that's a good idea since with color support we would need quite some memory and I'm not sure if that would really speed up things.
I'd really love to have framebuffer console in barebox. I wasn't aware that this would be relatively straight forward to implement though. I'm willing to help working on this job so that we finally have a fbcon.
Maybe one first step is to simply merge the font so that the patches get smaller.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 10 lines · Antony Pavlov
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (
git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).
Here's my WIP state based on your patch. It's probably worth to create a function that takes a bw bitmap and a color and which renders the bitmap to the screen with the given color. Also it might be worth to separate the ANSI/VT100 parser to be able to share it between the EFI console and fbcon.
Sascha
From 59211105b2fdcdf6c1891edfa999d915ceba3bb3 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Thu, 9 Jul 2015 10:01:36 +0200
Subject: [PATCH] fbcon wip
--- drivers/video/fbconsole.c | 172 ++++++++++++++++++++++++++++++++-------------- lib/gui/graphic_utils.c | 21 +++++- 2 files changed, 140 insertions(+), 53 deletions(-)
drivers/video/fbconsole.c +120 -52
@@ -15,6 +15,8 @@ enum state_t { CSI, /* Reading arguments in "CSI Pn ;...*/ }; +u32 get_pixel (struct fb_info *info,u32 color); +struct fbc_priv {struct console_device cdev;struct fb_info *fb;
@@ -25,49 +27,13 @@ struct fbc_priv {unsigned int x, y;/* cursor position */ enum state_t state; -}; - -static struct image *char8x16_img (char *inbuf) -{ -struct image *img =calloc (1 ,sizeof (struct image )); -int i; -uint32_t *p; - -if (!img) -return ERR_PTR (-ENOMEM ); - - img->bits_per_pixel =4 <<3 ; - img->data =calloc (1 ,sizeof (uint32_t ) *VIDEO_FONT_WIDTH *VIDEO_FONT_HEIGHT ); - img->height =VIDEO_FONT_HEIGHT ; - img->width =VIDEO_FONT_WIDTH ; - - p = img->data; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { -uint8_t t = inbuf[i]; -int j; -for (j =0 ; j <VIDEO_FONT_WIDTH ; j++) { -if (t &0x80 ) { - *p =0xffffffff ; - } +u32 color; +bool invert; - p++; - t <<=1 ; - } - } - -return img; -} - -static void init_chars (struct image *chars[],int char_num) -{ -int i; - -for (i =0 ; i < char_num; i++) { - chars[i] =char8x16_img (&video_fontdata[i *VIDEO_FONT_HEIGHT ]); - } -} +int csipos; +u8 csi[20 ]; +};static int fbc_getc (struct console_device *cdev) {
@@ -82,39 +48,66 @@ static int fbc_tstc(struct console_device *cdev)static void drawchar (struct fbc_priv *priv,int x,int y,char c) {void *buf; +int bpp = priv->fb->bits_per_pixel >>3 ; +void *adr; +int i; +char *inbuf; +int line_length; +u32 color, bgcolor; buf =gui_screen_redering_buffer (&priv->sc); -rgba_blend (priv->fb, priv->chars[(int )c], - buf,VIDEO_FONT_HEIGHT ,VIDEO_FONT_WIDTH , -VIDEO_FONT_WIDTH * x,VIDEO_FONT_HEIGHT * y,1 ); + inbuf = &video_fontdata[c *VIDEO_FONT_HEIGHT ]; + + line_length = priv->fb->line_length; + + color = priv->invert ?0xff000000 : priv->color; + bgcolor = priv->invert ? priv->color :0xff000000 ; + +for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { +uint8_t t = inbuf[i]; +int j; + + adr = buf + line_length * (y *VIDEO_FONT_HEIGHT + i) + x *VIDEO_FONT_WIDTH * bpp; + +for (j =0 ; j <VIDEO_FONT_WIDTH ; j++) { +if (t &0x80 ) +set_pixel (priv->fb, adr, color); +else +set_pixel (priv->fb, adr, bgcolor); + + adr += priv->fb->bits_per_pixel >>3 ; + t <<=1 ; + } + } } -/* FIXME */ -static void blankchar (struct fbc_priv *priv,int x,int y) +void invert_area (struct fb_info *info,void *buf,int startx,int starty,int width, +int height); + +static void video_invertchar (struct fbc_priv *priv,int x,int y) {void *buf; buf =gui_screen_redering_buffer (&priv->sc); -rgba_blend (priv->fb, priv->chars[' ' ], - buf,VIDEO_FONT_HEIGHT ,VIDEO_FONT_WIDTH , -VIDEO_FONT_WIDTH * x,VIDEO_FONT_HEIGHT * y,0 ); +invert_area (priv->fb, buf, x *VIDEO_FONT_WIDTH , y *VIDEO_FONT_HEIGHT , +VIDEO_FONT_WIDTH ,VIDEO_FONT_HEIGHT ); }static void printchar (struct fbc_priv *priv,int c) { +video_invertchar (priv, priv->x, priv->y); +switch (c) {case '\007' :/* bell: ignore */ break ;case '\b' :if (priv->x >0 ) { priv->x--; -blankchar (priv, priv->x, priv->y); }else if (priv->y >0 ) { priv->x = priv->cols; priv->y--; -blankchar (priv, priv->x, priv->y); }break ;case '\n' :
@@ -126,6 +119,10 @@ static void printchar(struct fbc_priv *priv, int c) priv->x =0 ;break ; +case '\t' : + priv->x = (priv->x +8 ) & ~0x3 ; +break ; +default :drawchar (priv, priv->x, priv->y, c);screen_blit (&priv->sc);
@@ -150,9 +147,75 @@ static void printchar(struct fbc_priv *priv, int c) priv->y = priv->rows; } +video_invertchar (priv, priv->x, priv->y); +return ; } +static void fbc_parse_csi (struct fbc_priv *priv) +{ +int a, b =-1 ; +char *end; + + a =simple_strtoul (priv->csi, &end,10 ); +if (*end ==';' ) + b =simple_strtoul (end +1 , &end,10 ); + +if (*end =='m' && b ==-1 ) { +switch (a) { +case 0 : + priv->color =0xffffffff ; + priv->invert = false; +break ; +case 7 : + priv->invert = true; +break ; + } +return ; + } + +if (*end =='J' && a ==2 && b ==-1 ) { +void *buf =gui_screen_redering_buffer (&priv->sc); + +memset (buf,0 , priv->fb->line_length * priv->fb->yres); + + priv->x =0 ; + priv->y =0 ; +video_invertchar (priv, priv->x, priv->y); + } + +if (*end =='m' && a ==1 ) { +switch (b) { +case 32 : + priv->color =get_pixel (priv->fb,0xff00ff00 ); +break ; +case 31 : + priv->color =get_pixel (priv->fb,0xffff0000 ); +break ; +case 34 : + priv->color =get_pixel (priv->fb,0xff0000ff ); +break ; +case 36 : + priv->color =get_pixel (priv->fb,0xff54ffff ); +break ; +case 37 : + priv->color =get_pixel (priv->fb,0xffffffff ); +break ; +default : +break ; + } +return ; + } + +if (*end =='H' ) { +video_invertchar (priv, priv->x, priv->y); + priv->x = b -1 ; + priv->y = a -1 ; +video_invertchar (priv, priv->x, priv->y); +return ; + } +} +static void fbc_putc (struct console_device *cdev,char c) { struct fbc_priv *priv = container_of(cdev,
@@ -172,10 +235,14 @@ static void fbc_putc(struct console_device *cdev, char c)switch (c) {case '[' : priv->state =CSI ; + priv->csipos =0 ; +memset (priv->csi,0 ,6 );break ; }break ;case CSI : + priv->csi[priv->csipos++] = c; +switch (c) {case '0' :case '1' :
@@ -191,6 +258,7 @@ static void fbc_putc(struct console_device *cdev, char c)case ':' :break ;default : +fbc_parse_csi (priv); priv->state =LIT ; }break ;
@@ -235,7 +303,7 @@ int register_fbconsole(struct fb_info *fb) priv->fb = fb; priv->x =0 ; priv->y =0 ; -init_chars (priv->chars,VIDEO_FONT_CHARS ); + priv->color =0xff00ff00 ; cdev = &priv->cdev; cdev->dev = &fb->dev;
lib/gui/graphic_utils.c +20 -1
@@ -7,7 +7,7 @@#include <fs.h> #include <malloc.h> -static u32 get_pixel (struct fb_info *info,u32 color) +u32 get_pixel (struct fb_info *info,u32 color) {u32 px;u8 t = (color >>24 ) &0xff ;
@@ -128,6 +128,25 @@ static u8 alpha_mux(int s, int d, int a)return (d * a + s * (255 - a)) >>8 ; } +void invert_area (struct fb_info *info,void *buf,int startx,int starty,int width, +int height) +{ +unsigned char *adr; +int x, y; +int line_length; +int bpp = info->bits_per_pixel >>3 ; + + line_length = info->line_length; + +for (y = starty; y < starty + height; y++) { + adr = buf + line_length * y + startx * bpp; + +for (x =0 ; x < width * bpp; x++) { + *adr++ ^=0xff ; + } + } +} +void set_rgba_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b,u8 a) {u32 px =0x0 ;
Signature · 12 lines
2.1.4 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 51 lines · On Thu, 9 Jul 2015 08:49:20 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 9 lines · Antony Pavlov
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (
git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).There's even one in barebox in
drivers/serial/efi-stdio.cQuoted 10 lines
fbconsole mini-HOWTO
====================1. compile sandbox barebox with
CONFIG_VIDEO=y
CONFIG_FBCONSOLE=y
CONFIG_DRIVER_VIDEO_SDL=yQuoted 5 lines
2. run barebox
3. test fbconsole
fbconsole0.active=o
I gave it a try on real hardware. Works nice.
Quoted 4 lines
TODO:
* no visible cursor;
I couldn't resist and did some hacking on this. The cursor is visible now. Also I implemented more control characters and color support. I'll send an update patch shortly.
Quoted 4 lines
* FIXME:
/dev/fb0is hardcoded;
* FIXME: dropblanckchar()dirty hack;
* Sascha Hauer: character set should be prerendered for the actual framebuffer format before printing a string.Did I mention that ealier? I don't know if that's a good idea since with color support we would need quite some memory and I'm not sure if that would really speed up things.
Quoted 6 lines
I'd really love to have framebuffer console in barebox. I wasn't aware that this would be relatively straight forward to implement though. I'm willing to help working on this job so that we finally have a fbcon.
Maybe one first step is to simply merge the font so that the patches get smaller.
IMHO it is very reasonable to add simple tools and instruction for font modifing. We even can add several fonts and select one of them via Kconfig options as linux kernel does. There are some reasons for that:
* some people prefere another fonts (e.g. Terminus);
* in Russia we need a font with cyrillic letters.
Also I prefere fix original font header file.
Here is an example.
1. original font header file fragment:
+ /* 65 0x41 */
+ 0x00, /* 00000000 */
+ 0x00, /* 00000000 */
+ 0x10, /* 00010000 */
+ 0x38, /* 00111000 */
+ 0x6c, /* 01101100 */
+ 0xc6, /* 11000110 */
+ 0xc6, /* 11000110 */
+ 0xfe, /* 11111110 */
+ 0xc6, /* 11000110 */
+ 0xc6, /* 11000110 */
+ 0xc6, /* 11000110 */
+ 0xc6, /* 11000110 */
+ 0x00, /* 00000000 */
+ 0x00, /* 00000000 */
+ 0x00, /* 00000000 */
+ 0x00, /* 00000000 */
+
2. my version
+ /* 65 0x41 'A' */
+ 0x00, /* ........ */
+ 0x00, /* ........ */
+ 0x10, /* ...#.... */
+ 0x38, /* ..###... */
+ 0x6c, /* .##.##.. */
+ 0xc6, /* ##...##. */
+ 0xc6, /* ##...##. */
+ 0xfe, /* #######. */
+ 0xc6, /* ##...##. */
+ 0xc6, /* ##...##. */
+ 0xc6, /* ##...##. */
+ 0xc6, /* ##...##. */
+ 0x00, /* ........ */
+ 0x00, /* ........ */
+ 0x00, /* ........ */
+ 0x00, /* ........ */
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 12 lines · On Thu, 9 Jul 2015 10:16:39 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 10 lines · Antony Pavlov
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (
git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).
Quoted 5 lines
Here's my WIP state based on your patch. It's probably worth to create a function that takes a bw bitmap and a color and which renders the bitmap to the screen with the given color. Also it might be worth to separate the ANSI/VT100 parser to be able to share it between the EFI console and fbcon.
Thanks!
I'll try you patch as soon as possible.
I have not known about EFI console ANSI/VT100 parser until now. I'll take a look on it too.
Quoted 322 lines
From
59211105b2fdcdf6c1891edfa999d915ceba3bb3Mon Sep 17 00:00:00 2001
From: Sascha Hauer <[email protected]>
Date: Thu, 9 Jul 2015 10:01:36 +0200
Subject: [PATCH] fbcon wipSigned-off-by Sascha Hauer <[email protected]>--- drivers/video/fbconsole.c | 172 ++++++++++++++++++++++++++++++++-------------- lib/gui/graphic_utils.c | 21 +++++- 2 files changed, 140 insertions(+), 53 deletions(-)drivers/video/fbconsole.c +120
-52@@ -15,6 +15,8 @@ enum state_t { CSI, /* Reading arguments in "CSI Pn ;...*/ }; +u32 get_pixel (struct fb_info *info,u32 color); +struct fbc_priv {struct console_device cdev;struct fb_info *fb;@@ -25,49 +27,13 @@ struct fbc_priv {unsigned int x, y;/* cursor position */ enum state_t state; -}; - -static struct image *char8x16_img (char *inbuf) -{ -struct image *img =calloc (1 ,sizeof (struct image )); -int i; -uint32_t *p; - -if (!img) -return ERR_PTR (-ENOMEM ); - - img->bits_per_pixel =4 <<3 ; - img->data =calloc (1 ,sizeof (uint32_t ) *VIDEO_FONT_WIDTH *VIDEO_FONT_HEIGHT ); - img->height =VIDEO_FONT_HEIGHT ; - img->width =VIDEO_FONT_WIDTH ; - - p = img->data; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { -uint8_t t = inbuf[i]; -int j; -for (j =0 ; j <VIDEO_FONT_WIDTH ; j++) { -if (t &0x80 ) { - *p =0xffffffff ; - } +u32 color; +bool invert; - p++; - t <<=1 ; - } - } - -return img; -} - -static void init_chars (struct image *chars[],int char_num) -{ -int i; - -for (i =0 ; i < char_num; i++) { - chars[i] =char8x16_img (&video_fontdata[i *VIDEO_FONT_HEIGHT ]); - } -} +int csipos; +u8 csi[20 ]; +};static int fbc_getc (struct console_device *cdev) {@@ -82,39 +48,66 @@ static int fbc_tstc(struct console_device *cdev)static void drawchar (struct fbc_priv *priv,int x,int y,char c) {void *buf; +int bpp = priv->fb->bits_per_pixel >>3 ; +void *adr; +int i; +char *inbuf; +int line_length; +u32 color, bgcolor; buf =gui_screen_redering_buffer (&priv->sc); -rgba_blend (priv->fb, priv->chars[(int )c], - buf,VIDEO_FONT_HEIGHT ,VIDEO_FONT_WIDTH , -VIDEO_FONT_WIDTH * x,VIDEO_FONT_HEIGHT * y,1 ); + inbuf = &video_fontdata[c *VIDEO_FONT_HEIGHT ]; + + line_length = priv->fb->line_length; + + color = priv->invert ?0xff000000 : priv->color; + bgcolor = priv->invert ? priv->color :0xff000000 ; + +for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { +uint8_t t = inbuf[i]; +int j; + + adr = buf + line_length * (y *VIDEO_FONT_HEIGHT + i) + x *VIDEO_FONT_WIDTH * bpp; + +for (j =0 ; j <VIDEO_FONT_WIDTH ; j++) { +if (t &0x80 ) +set_pixel (priv->fb, adr, color); +else +set_pixel (priv->fb, adr, bgcolor); + + adr += priv->fb->bits_per_pixel >>3 ; + t <<=1 ; + } + } } -/* FIXME */ -static void blankchar (struct fbc_priv *priv,int x,int y) +void invert_area (struct fb_info *info,void *buf,int startx,int starty,int width, +int height); + +static void video_invertchar (struct fbc_priv *priv,int x,int y) {void *buf; buf =gui_screen_redering_buffer (&priv->sc); -rgba_blend (priv->fb, priv->chars[' ' ], - buf,VIDEO_FONT_HEIGHT ,VIDEO_FONT_WIDTH , -VIDEO_FONT_WIDTH * x,VIDEO_FONT_HEIGHT * y,0 ); +invert_area (priv->fb, buf, x *VIDEO_FONT_WIDTH , y *VIDEO_FONT_HEIGHT , +VIDEO_FONT_WIDTH ,VIDEO_FONT_HEIGHT ); }static void printchar (struct fbc_priv *priv,int c) { +video_invertchar (priv, priv->x, priv->y); +switch (c) {case '\007' :/* bell: ignore */ break ;case '\b' :if (priv->x >0 ) { priv->x--; -blankchar (priv, priv->x, priv->y); }else if (priv->y >0 ) { priv->x = priv->cols; priv->y--; -blankchar (priv, priv->x, priv->y); }break ;case '\n' :@@ -126,6 +119,10 @@ static void printchar(struct fbc_priv *priv, int c) priv->x =0 ;break ; +case '\t' : + priv->x = (priv->x +8 ) & ~0x3 ; +break ; +default :drawchar (priv, priv->x, priv->y, c);screen_blit (&priv->sc);@@ -150,9 +147,75 @@ static void printchar(struct fbc_priv *priv, int c) priv->y = priv->rows; } +video_invertchar (priv, priv->x, priv->y); +return ; } +static void fbc_parse_csi (struct fbc_priv *priv) +{ +int a, b =-1 ; +char *end; + + a =simple_strtoul (priv->csi, &end,10 ); +if (*end ==';' ) + b =simple_strtoul (end +1 , &end,10 ); + +if (*end =='m' && b ==-1 ) { +switch (a) { +case 0 : + priv->color =0xffffffff ; + priv->invert = false; +break ; +case 7 : + priv->invert = true; +break ; + } +return ; + } + +if (*end =='J' && a ==2 && b ==-1 ) { +void *buf =gui_screen_redering_buffer (&priv->sc); + +memset (buf,0 , priv->fb->line_length * priv->fb->yres); + + priv->x =0 ; + priv->y =0 ; +video_invertchar (priv, priv->x, priv->y); + } + +if (*end =='m' && a ==1 ) { +switch (b) { +case 32 : + priv->color =get_pixel (priv->fb,0xff00ff00 ); +break ; +case 31 : + priv->color =get_pixel (priv->fb,0xffff0000 ); +break ; +case 34 : + priv->color =get_pixel (priv->fb,0xff0000ff ); +break ; +case 36 : + priv->color =get_pixel (priv->fb,0xff54ffff ); +break ; +case 37 : + priv->color =get_pixel (priv->fb,0xffffffff ); +break ; +default : +break ; + } +return ; + } + +if (*end =='H' ) { +video_invertchar (priv, priv->x, priv->y); + priv->x = b -1 ; + priv->y = a -1 ; +video_invertchar (priv, priv->x, priv->y); +return ; + } +} +static void fbc_putc (struct console_device *cdev,char c) { struct fbc_priv *priv = container_of(cdev,@@ -172,10 +235,14 @@ static void fbc_putc(struct console_device *cdev, char c)switch (c) {case '[' : priv->state =CSI ; + priv->csipos =0 ; +memset (priv->csi,0 ,6 );break ; }break ;case CSI : + priv->csi[priv->csipos++] = c; +switch (c) {case '0' :case '1' :@@ -191,6 +258,7 @@ static void fbc_putc(struct console_device *cdev, char c)case ':' :break ;default : +fbc_parse_csi (priv); priv->state =LIT ; }break ;@@ -235,7 +303,7 @@ int register_fbconsole(struct fb_info *fb) priv->fb = fb; priv->x =0 ; priv->y =0 ; -init_chars (priv->chars,VIDEO_FONT_CHARS ); + priv->color =0xff00ff00 ; cdev = &priv->cdev; cdev->dev = &fb->dev;lib/gui/graphic_utils.c +20
-1@@ -7,7 +7,7 @@#include <fs.h> #include <malloc.h> -static u32 get_pixel (struct fb_info *info,u32 color) +u32 get_pixel (struct fb_info *info,u32 color) {u32 px;u8 t = (color >>24 ) &0xff ;@@ -128,6 +128,25 @@ static u8 alpha_mux(int s, int d, int a)return (d * a + s * (255 - a)) >>8 ; } +void invert_area (struct fb_info *info,void *buf,int startx,int starty,int width, +int height) +{ +unsigned char *adr; +int x, y; +int line_length; +int bpp = info->bits_per_pixel >>3 ; + + line_length = info->line_length; + +for (y = starty; y < starty + height; y++) { + adr = buf + line_length * y + startx * bpp; + +for (x =0 ; x < width * bpp; x++) { + *adr++ ^=0xff ; + } + } +} +void set_rgba_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b,u8 a) {u32 px =0x0 ;Signature · 7 lines
2.1.4 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 61 lines · Antony Pavlov
Quoted 51 lines · On Thu, 9 Jul 2015 08:49:20 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 9 lines · Antony Pavlov
This patch realizes very simple framebuffer console for barebox. Minimal ANSI/VT100 Escape Sequence parser is used to ignore color change commands (based on GNU screen parser).
THere are several ANSI/VT100 parsers:
* GNU screen (
git://git.savannah.gnu.org/screen.git);
* st - simple terminal (http://git.suckless.org/st);
* or even mutt (https://github.com/karelzak/mutt-kz).There's even one in barebox in
drivers/serial/efi-stdio.cQuoted 10 lines
fbconsole mini-HOWTO
====================1. compile sandbox barebox with
CONFIG_VIDEO=y
CONFIG_FBCONSOLE=y
CONFIG_DRIVER_VIDEO_SDL=yQuoted 5 lines
2. run barebox
3. test fbconsole
fbconsole0.active=o
I gave it a try on real hardware. Works nice.
Quoted 4 lines
TODO:
* no visible cursor;
I couldn't resist and did some hacking on this. The cursor is visible now. Also I implemented more control characters and color support. I'll send an update patch shortly.
Quoted 4 lines
* FIXME:
/dev/fb0is hardcoded;
* FIXME: dropblanckchar()dirty hack;
* Sascha Hauer: character set should be prerendered for the actual framebuffer format before printing a string.Did I mention that ealier? I don't know if that's a good idea since with color support we would need quite some memory and I'm not sure if that would really speed up things.
Quoted 6 lines
I'd really love to have framebuffer console in barebox. I wasn't aware that this would be relatively straight forward to implement though. I'm willing to help working on this job so that we finally have a fbcon.
Maybe one first step is to simply merge the font so that the patches get smaller.
Quoted 7 lines
IMHO it is very reasonable to add simple tools and instruction for font modifing. We even can add several fonts and select one of them via
Kconfigoptions as linux kernel does. There are some reasons for that:* some people prefere another fonts (e.g. Terminus);
* in Russia we need a font with cyrillic letters.
Ok. I'm happy to add this later, but if you want to add this from the start, fine aswell.
Quoted 33 lines
Also I prefere fix original font header file.
Here is an example.1. original font header file fragment:
include/video_font_data.h new file +18
-0+/* 65 0x41 */ +0x00 ,/* 00000000 */ +0x00 ,/* 00000000 */ +0x10 ,/* 00010000 */ +0x38 ,/* 00111000 */ +0x6c ,/* 01101100 */ +0xc6 ,/* 11000110 */ +0xc6 ,/* 11000110 */ +0xfe ,/* 11111110 */ +0xc6 ,/* 11000110 */ +0xc6 ,/* 11000110 */ +0xc6 ,/* 11000110 */ +0xc6 ,/* 11000110 */ +0x00 ,/* 00000000 */ +0x00 ,/* 00000000 */ +0x00 ,/* 00000000 */ + 0x00, /* 00000000 */ +2. my version
(quoted diff) +7
-0+ /* 65 0x41 'A' */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x10, /* ...#.... */ + 0x38, /* ..###... */ + 0x6c, /* .##.##.. */ + 0xc6, /* ##...##. */
Review
Quoted 10 lines
(quoted diff) +10
-0+ 0xc6, /* ##...##. */ + 0xfe, /* #######. */ + 0xc6, /* ##...##. */ + 0xc6, /* ##...##. */ + 0xc6, /* ##...##. */ + 0xc6, /* ##...##. */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */ + 0x00, /* ........ */
Yeah, that's much better to read.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox