mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	"open list:BAREBOX" <barebox@lists.infradead.org>
Subject: Re: [PATCH 5/5] fbconsole: actually store rows/cols
Date: Thu, 26 Sep 2024 07:39:41 +0200	[thread overview]
Message-ID: <5979bc0b-16e5-4ef6-abdf-59f53460b729@pengutronix.de> (raw)
In-Reply-To: <20240925-graphics-v1-5-f1fe5d2cceec@pengutronix.de>

On 25.09.24 16:34, Sascha Hauer wrote:
> struct fbc_priv has rows and cols fields, but they do not actually
> store the rows and columns, but instead the actual values minus one.
> Change this to make the code better understandable.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  drivers/video/fbconsole.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
> index d3615bc07f..01a091d07a 100644
> --- a/drivers/video/fbconsole.c
> +++ b/drivers/video/fbconsole.c
> @@ -200,7 +200,7 @@ static void printchar(struct fbc_priv *priv, int c)
>  		if (priv->x > 0) {
>  			priv->x--;
>  		} else if (priv->y > 0) {
> -			priv->x = priv->cols;
> +			priv->x = priv->cols - 1;
>  			priv->y--;
>  		}
>  		break;
> @@ -226,26 +226,26 @@ static void printchar(struct fbc_priv *priv, int c)
>  				priv->font->width, priv->font->height);
>  
>  		priv->x++;
> -		if (priv->x > priv->cols) {
> +		if (priv->x >= priv->cols) {
>  			priv->y++;
>  			priv->x = 0;
>  		}
>  	}
>  
> -	if (priv->y > priv->rows) {
> +	if (priv->y >= priv->rows) {
>  		void *buf;
>  		void *adr;
>  		u32 line_length = priv->fb->line_length;
>  		int line_height = line_length * priv->font->height;
>  		int width = priv->fb->xres - priv->margin.left - priv->margin.right;
> -		int height = (priv->rows + 1) * priv->font->height;
> +		int height = priv->rows * priv->font->height;
>  
>  		buf = gui_screen_render_buffer(priv->sc);
>  		adr = buf + priv->margin.top * line_length;
>  
>  		if (!priv->margin.left && !priv->margin.right) {
> -			memcpy(adr, adr + line_height, line_height * priv->rows);
> -			memset(adr + line_height * priv->rows, 0, line_height);
> +			memcpy(adr, adr + line_height, line_height * (priv->rows - 1));
> +			memset(adr + line_height * (priv->rows - 1), 0, line_height);
>  		} else {
>  			int bpp = priv->fb->bits_per_pixel >> 3;
>  			int y;
> @@ -264,7 +264,7 @@ static void printchar(struct fbc_priv *priv, int c)
>  
>  		gu_screen_blit_area(priv->sc, priv->margin.left, priv->margin.top,
>  				width, height);
> -		priv->y = priv->rows;
> +		priv->y = priv->rows - 1;
>  	}
>  
>  	show_cursor(priv, priv->x, priv->y);
> @@ -364,10 +364,10 @@ static void fbc_parse_csi(struct fbc_priv *priv)
>  		show_cursor(priv, priv->x, priv->y);
>  
>  		pos = simple_strtoul(priv->csi, &end, 10);
> -		priv->y = clamp(pos - 1, 0, (int) priv->rows);
> +		priv->y = clamp(pos - 1, 0, (int) priv->rows - 1);
>  
>  		pos = simple_strtoul(end + 1, NULL, 10);
> -		priv->x = clamp(pos - 1, 0, (int) priv->cols);
> +		priv->x = clamp(pos - 1, 0, (int) priv->cols - 1);
>  
>  		show_cursor(priv, priv->x, priv->y);
>  	case 'K':
> @@ -469,8 +469,8 @@ static int setup_font(struct fbc_priv *priv)
>  
>  	priv->font = font;
>  
> -	priv->rows = height / priv->font->height - 1;
> -	priv->cols = width / priv->font->width - 1;
> +	priv->rows = height / priv->font->height;
> +	priv->cols = width / priv->font->width;
>  
>  	return 0;
>  }
> @@ -495,7 +495,7 @@ static int fbc_open(struct console_device *cdev)
>  	priv->state = LIT;
>  
>  	dev_info(priv->cdev.dev, "framebuffer console %dx%d activated\n",
> -		priv->cols + 1, priv->rows + 1);
> +		priv->cols, priv->rows);
>  
>  	priv->active = true;
>  
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2024-09-26  5:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:34 [PATCH 0/5] graphics updates Sascha Hauer
2024-09-25 14:34 ` [PATCH 1/5] graphic_utils: Clip to screen boundaries Sascha Hauer
2024-09-26  5:26   ` Ahmad Fatoum
2024-09-25 14:34 ` [PATCH 2/5] commands: splash: honour line_length Sascha Hauer
2024-09-26  5:31   ` Ahmad Fatoum
2024-09-26  6:48     ` Sascha Hauer
2024-09-25 14:34 ` [PATCH 3/5] gui: fix alpha blend Sascha Hauer
2024-09-26  5:33   ` Ahmad Fatoum
2024-09-25 14:34 ` [PATCH 4/5] fbconsole: make background pixels transparent Sascha Hauer
2024-09-26  5:38   ` Ahmad Fatoum
2024-09-26  7:02     ` Sascha Hauer
2024-09-25 14:34 ` [PATCH 5/5] fbconsole: actually store rows/cols Sascha Hauer
2024-09-26  5:39   ` Ahmad Fatoum [this message]
2024-09-27 10:38 ` [PATCH 0/5] graphics updates Sascha Hauer

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=5979bc0b-16e5-4ef6-abdf-59f53460b729@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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