mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fbconsole: move font variable into struct font_desc
@ 2015-11-08  3:16 Du Huanpeng
  2015-11-09  6:28 ` Sascha Hauer
  2015-11-09  8:21 ` Du Huanpeng
  0 siblings, 2 replies; 3+ messages in thread
From: Du Huanpeng @ 2015-11-08  3:16 UTC (permalink / raw)
  To: barebox; +Cc: Du Huanpeng

replace font related variables with a struct pointer,
font_desc.

Signed-off-by: Du Huanpeng <u74147@gmail.com>
---
 drivers/video/fbconsole.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index b10503e..60f3c48 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -22,8 +22,8 @@ struct fbc_priv {
 	struct param_d *par_font;
 	int par_font_val;
 
-	int font_width, font_height;
-	const u8 *fontdata;
+	const struct font_desc *font;
+
 	unsigned int cols, rows;
 	unsigned int x, y; /* cursor position */
 
@@ -97,7 +97,7 @@ static void drawchar(struct fbc_priv *priv, int x, int y, char c)
 
 	buf = gui_screen_render_buffer(priv->sc);
 
-	inbuf = &priv->fontdata[c * priv->font_height];
+	inbuf = &priv->font->data[c * priv->font->height];
 
 	line_length = priv->fb->line_length;
 
@@ -113,13 +113,13 @@ static void drawchar(struct fbc_priv *priv, int x, int y, char c)
 	rgb = &colors[bgcolor];
 	bgcolor = gu_rgb_to_pixel(priv->fb, rgb->r, rgb->g, rgb->b, 0xff);
 
-	for (i = 0; i < priv->font_height; i++) {
+	for (i = 0; i < priv->font->height; i++) {
 		uint8_t t = inbuf[i];
 		int j;
 
-		adr = buf + line_length * (y * priv->font_height + i) + x * priv->font_width * bpp;
+		adr = buf + line_length * (y * priv->font->height + i) + x * priv->font->width * bpp;
 
-		for (j = 0; j < priv->font_width; j++) {
+		for (j = 0; j < priv->font->width; j++) {
 			if (t & 0x80)
 				gu_set_pixel(priv->fb, adr, color);
 			else
@@ -137,10 +137,10 @@ static void video_invertchar(struct fbc_priv *priv, int x, int y)
 
 	buf = gui_screen_render_buffer(priv->sc);
 
-	gu_invert_area(priv->fb, buf, x * priv->font_width, y * priv->font_height,
-			priv->font_width, priv->font_height);
-	gu_screen_blit_area(priv->sc, x * priv->font_width, y * priv->font_height,
-			priv->font_width, priv->font_height);
+	gu_invert_area(priv->fb, buf, x * priv->font->width, y * priv->font->height,
+			priv->font->width, priv->font->height);
+	gu_screen_blit_area(priv->sc, x * priv->font->width, y * priv->font->height,
+			priv->font->width, priv->font->height);
 }
 
 static void printchar(struct fbc_priv *priv, int c)
@@ -174,9 +174,9 @@ static void printchar(struct fbc_priv *priv, int c)
 	default:
 		drawchar(priv, priv->x, priv->y, c);
 
-		gu_screen_blit_area(priv->sc, priv->x * priv->font_width,
-				priv->y * priv->font_height,
-				priv->font_width, priv->font_height);
+		gu_screen_blit_area(priv->sc, priv->x * priv->font->width,
+				priv->y * priv->font->height,
+				priv->font->width, priv->font->height);
 
 		priv->x++;
 		if (priv->x > priv->cols) {
@@ -188,7 +188,7 @@ static void printchar(struct fbc_priv *priv, int c)
 	if (priv->y > priv->rows) {
 		void *buf;
 		u32 line_length = priv->fb->line_length;
-		int line_height = line_length * priv->font_height;
+		int line_height = line_length * priv->font->height;
 
 		buf = gui_screen_render_buffer(priv->sc);
 
@@ -355,12 +355,10 @@ static int setup_font(struct fbc_priv *priv)
 		return -ENOENT;
 	}
 
-	priv->font_width = font->width;
-	priv->font_height = font->height;
-	priv->fontdata = font->data;
+	priv->font = font;
 
-	priv->rows = fb->yres / priv->font_height - 1;
-	priv->cols = fb->xres / priv->font_width - 1;
+	priv->rows = fb->yres / priv->font->height - 1;
+	priv->cols = fb->xres / priv->font->width - 1;
 
 	return 0;
 }
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] fbconsole: move font variable into struct font_desc
  2015-11-08  3:16 [PATCH] fbconsole: move font variable into struct font_desc Du Huanpeng
@ 2015-11-09  6:28 ` Sascha Hauer
  2015-11-09  8:21 ` Du Huanpeng
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-11-09  6:28 UTC (permalink / raw)
  To: Du Huanpeng; +Cc: barebox

On Sat, Nov 07, 2015 at 07:16:16PM -0800, Du Huanpeng wrote:
> replace font related variables with a struct pointer,
> font_desc.
> 
> Signed-off-by: Du Huanpeng <u74147@gmail.com>
> ---
>  drivers/video/fbconsole.c | 36 +++++++++++++++++-------------------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
> index b10503e..60f3c48 100644
> --- a/drivers/video/fbconsole.c
> +++ b/drivers/video/fbconsole.c
> @@ -22,8 +22,8 @@ struct fbc_priv {
>  	struct param_d *par_font;
>  	int par_font_val;
>  
> -	int font_width, font_height;
> -	const u8 *fontdata;
> +	const struct font_desc *font;
> +
>  	unsigned int cols, rows;
>  	unsigned int x, y; /* cursor position */
>  
> @@ -97,7 +97,7 @@ static void drawchar(struct fbc_priv *priv, int x, int y, char c)
>  
>  	buf = gui_screen_render_buffer(priv->sc);
>  
> -	inbuf = &priv->fontdata[c * priv->font_height];
> +	inbuf = &priv->font->data[c * priv->font->height];

I replaced this with:

	inbuf = priv->font->data + c * priv->font->height;

Otherwise we get:

drivers/video/fbconsole.c:100:27: warning: dereferencing 'void *' pointer

but otherwise: Applied, thanks

Sascha


-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] fbconsole: move font variable into struct font_desc
  2015-11-08  3:16 [PATCH] fbconsole: move font variable into struct font_desc Du Huanpeng
  2015-11-09  6:28 ` Sascha Hauer
@ 2015-11-09  8:21 ` Du Huanpeng
  1 sibling, 0 replies; 3+ messages in thread
From: Du Huanpeng @ 2015-11-09  8:21 UTC (permalink / raw)
  To: barebox

On Sat, Nov 07, 2015 at 07:16:16PM -0800, Du Huanpeng wrote:
thanks!
because my next patch will change this line to:

+	int index;
+	if (font->index == NULL) {
+		index  = font->width + 7;
+		index /= 8;
+		index *= font->height;
+		index *= ch;

so, I didn't fix this warning.

- - -
Du Huanpeng


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-11-09  8:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-08  3:16 [PATCH] fbconsole: move font variable into struct font_desc Du Huanpeng
2015-11-09  6:28 ` Sascha Hauer
2015-11-09  8:21 ` Du Huanpeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox