video: Update truetype console to support copy buffer
Update the implementation to keep a track of what it changes in the frame buffer and then tell the copy buffer about it. Use the special vidconsole_memmove() helper so that memmove() operations are also reflected in the copy buffer. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Anatolij Gustschin <agust@denx.de> Tested-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
		
							parent
							
								
									68f3fc767c
								
							
						
					
					
						commit
						3ad740ac66
					
				| 
						 | 
					@ -127,9 +127,9 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 | 
						struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 | 
				
			||||||
	struct console_tt_priv *priv = dev_get_priv(dev);
 | 
						struct console_tt_priv *priv = dev_get_priv(dev);
 | 
				
			||||||
	void *line;
 | 
						void *end, *line;
 | 
				
			||||||
	int pixels = priv->font_size * vid_priv->line_length;
 | 
						int pixels = priv->font_size * vid_priv->line_length;
 | 
				
			||||||
	int i;
 | 
						int i, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	line = vid_priv->fb + row * priv->font_size * vid_priv->line_length;
 | 
						line = vid_priv->fb + row * priv->font_size * vid_priv->line_length;
 | 
				
			||||||
	switch (vid_priv->bpix) {
 | 
						switch (vid_priv->bpix) {
 | 
				
			||||||
| 
						 | 
					@ -139,6 +139,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (i = 0; i < pixels; i++)
 | 
							for (i = 0; i < pixels; i++)
 | 
				
			||||||
			*dst++ = clr;
 | 
								*dst++ = clr;
 | 
				
			||||||
 | 
							end = dst;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -148,6 +149,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (i = 0; i < pixels; i++)
 | 
							for (i = 0; i < pixels; i++)
 | 
				
			||||||
			*dst++ = clr;
 | 
								*dst++ = clr;
 | 
				
			||||||
 | 
							end = dst;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -157,12 +159,16 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (i = 0; i < pixels; i++)
 | 
							for (i = 0; i < pixels; i++)
 | 
				
			||||||
			*dst++ = clr;
 | 
								*dst++ = clr;
 | 
				
			||||||
 | 
							end = dst;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return -ENOSYS;
 | 
							return -ENOSYS;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ret = vidconsole_sync_copy(dev, line, end);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -174,11 +180,14 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
 | 
				
			||||||
	struct console_tt_priv *priv = dev_get_priv(dev);
 | 
						struct console_tt_priv *priv = dev_get_priv(dev);
 | 
				
			||||||
	void *dst;
 | 
						void *dst;
 | 
				
			||||||
	void *src;
 | 
						void *src;
 | 
				
			||||||
	int i, diff;
 | 
						int i, diff, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dst = vid_priv->fb + rowdst * priv->font_size * vid_priv->line_length;
 | 
						dst = vid_priv->fb + rowdst * priv->font_size * vid_priv->line_length;
 | 
				
			||||||
	src = vid_priv->fb + rowsrc * priv->font_size * vid_priv->line_length;
 | 
						src = vid_priv->fb + rowsrc * priv->font_size * vid_priv->line_length;
 | 
				
			||||||
	memmove(dst, src, priv->font_size * vid_priv->line_length * count);
 | 
						ret = vidconsole_memmove(dev, dst, src, priv->font_size *
 | 
				
			||||||
 | 
									 vid_priv->line_length * count);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Scroll up our position history */
 | 
						/* Scroll up our position history */
 | 
				
			||||||
	diff = (rowsrc - rowdst) * priv->font_size;
 | 
						diff = (rowsrc - rowdst) * priv->font_size;
 | 
				
			||||||
| 
						 | 
					@ -203,8 +212,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 | 
				
			||||||
	struct pos_info *pos;
 | 
						struct pos_info *pos;
 | 
				
			||||||
	u8 *bits, *data;
 | 
						u8 *bits, *data;
 | 
				
			||||||
	int advance;
 | 
						int advance;
 | 
				
			||||||
	void *line;
 | 
						void *start, *end, *line;
 | 
				
			||||||
	int row;
 | 
						int row, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* First get some basic metrics about this character */
 | 
						/* First get some basic metrics about this character */
 | 
				
			||||||
	stbtt_GetCodepointHMetrics(font, ch, &advance, &lsb);
 | 
						stbtt_GetCodepointHMetrics(font, ch, &advance, &lsb);
 | 
				
			||||||
| 
						 | 
					@ -253,11 +262,12 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Figure out where to write the character in the frame buffer */
 | 
						/* Figure out where to write the character in the frame buffer */
 | 
				
			||||||
	bits = data;
 | 
						bits = data;
 | 
				
			||||||
	line = vid_priv->fb + y * vid_priv->line_length +
 | 
						start = vid_priv->fb + y * vid_priv->line_length +
 | 
				
			||||||
		VID_TO_PIXEL(x) * VNBYTES(vid_priv->bpix);
 | 
							VID_TO_PIXEL(x) * VNBYTES(vid_priv->bpix);
 | 
				
			||||||
	linenum = priv->baseline + yoff;
 | 
						linenum = priv->baseline + yoff;
 | 
				
			||||||
	if (linenum > 0)
 | 
						if (linenum > 0)
 | 
				
			||||||
		line += linenum * vid_priv->line_length;
 | 
							start += linenum * vid_priv->line_length;
 | 
				
			||||||
 | 
						line = start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Write a row at a time, converting the 8bpp image into the colour
 | 
						 * Write a row at a time, converting the 8bpp image into the colour
 | 
				
			||||||
| 
						 | 
					@ -286,6 +296,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 | 
				
			||||||
					*dst++ &= out;
 | 
										*dst++ &= out;
 | 
				
			||||||
				bits++;
 | 
									bits++;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								end = dst;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -307,6 +318,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 | 
				
			||||||
					*dst++ &= out;
 | 
										*dst++ &= out;
 | 
				
			||||||
				bits++;
 | 
									bits++;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								end = dst;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -317,6 +329,9 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		line += vid_priv->line_length;
 | 
							line += vid_priv->line_length;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ret = vidconsole_sync_copy(dev, start, line);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
	free(data);
 | 
						free(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return width_frac;
 | 
						return width_frac;
 | 
				
			||||||
| 
						 | 
					@ -340,12 +355,13 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 | 
				
			||||||
				  int xend, int yend, int clr)
 | 
									  int xend, int yend, int clr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 | 
						struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 | 
				
			||||||
	void *line;
 | 
						void *start, *line;
 | 
				
			||||||
	int pixels = xend - xstart;
 | 
						int pixels = xend - xstart;
 | 
				
			||||||
	int row, i;
 | 
						int row, i, ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	line = vid_priv->fb + ystart * vid_priv->line_length;
 | 
						start = vid_priv->fb + ystart * vid_priv->line_length;
 | 
				
			||||||
	line += xstart * VNBYTES(vid_priv->bpix);
 | 
						start += xstart * VNBYTES(vid_priv->bpix);
 | 
				
			||||||
 | 
						line = start;
 | 
				
			||||||
	for (row = ystart; row < yend; row++) {
 | 
						for (row = ystart; row < yend; row++) {
 | 
				
			||||||
		switch (vid_priv->bpix) {
 | 
							switch (vid_priv->bpix) {
 | 
				
			||||||
#ifdef CONFIG_VIDEO_BPP8
 | 
					#ifdef CONFIG_VIDEO_BPP8
 | 
				
			||||||
| 
						 | 
					@ -380,6 +396,9 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		line += vid_priv->line_length;
 | 
							line += vid_priv->line_length;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						ret = vidconsole_sync_copy(dev, start, line);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue