video: Let video_sync to return error value
This patch is preparation for follow up one to support cases where synchronization can fail. Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									17da310ac4
								
							
						
					
					
						commit
						9de731f295
					
				|  | @ -89,9 +89,7 @@ static int vidconsole_back(struct udevice *dev) | |||
| 		if (priv->ycur < 0) | ||||
| 			priv->ycur = 0; | ||||
| 	} | ||||
| 	video_sync(dev->parent, false); | ||||
| 
 | ||||
| 	return 0; | ||||
| 	return video_sync(dev->parent, false); | ||||
| } | ||||
| 
 | ||||
| /* Move to a newline, scrolling the display if necessary */ | ||||
|  | @ -101,7 +99,7 @@ static void vidconsole_newline(struct udevice *dev) | |||
| 	struct udevice *vid_dev = dev->parent; | ||||
| 	struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); | ||||
| 	const int rows = CONFIG_CONSOLE_SCROLL_LINES; | ||||
| 	int i; | ||||
| 	int i, ret; | ||||
| 
 | ||||
| 	priv->xcur_frac = priv->xstart_frac; | ||||
| 	priv->ycur += priv->y_charsize; | ||||
|  | @ -116,7 +114,12 @@ static void vidconsole_newline(struct udevice *dev) | |||
| 	} | ||||
| 	priv->last_ch = 0; | ||||
| 
 | ||||
| 	video_sync(dev->parent, false); | ||||
| 	ret = video_sync(dev->parent, false); | ||||
| 	if (ret) { | ||||
| #ifdef DEBUG | ||||
| 		console_puts_select_stderr(true, "[vc err: video_sync]"); | ||||
| #endif | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static const struct vid_rgb colors[VID_COLOR_COUNT] = { | ||||
|  | @ -348,8 +351,15 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) | |||
| 		parsenum(priv->escape_buf + 1, &mode); | ||||
| 
 | ||||
| 		if (mode == 2) { | ||||
| 			int ret; | ||||
| 
 | ||||
| 			video_clear(dev->parent); | ||||
| 			video_sync(dev->parent, false); | ||||
| 			ret = video_sync(dev->parent, false); | ||||
| 			if (ret) { | ||||
| #ifdef DEBUG | ||||
| 				console_puts_select_stderr(true, "[vc err: video_sync]"); | ||||
| #endif | ||||
| 			} | ||||
| 			priv->ycur = 0; | ||||
| 			priv->xcur_frac = priv->xstart_frac; | ||||
| 		} else { | ||||
|  | @ -565,7 +575,12 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) | |||
| 		console_puts_select_stderr(true, "[vc err: putc]"); | ||||
| #endif | ||||
| 	} | ||||
| 	video_sync(dev->parent, false); | ||||
| 	ret = video_sync(dev->parent, false); | ||||
| 	if (ret) { | ||||
| #ifdef DEBUG | ||||
| 		console_puts_select_stderr(true, "[vc err: video_sync]"); | ||||
| #endif | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void vidconsole_puts(struct stdio_dev *sdev, const char *s) | ||||
|  | @ -582,7 +597,12 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) | |||
| 		console_puts_select_stderr(true, str); | ||||
| #endif | ||||
| 	} | ||||
| 	video_sync(dev->parent, false); | ||||
| 	ret = video_sync(dev->parent, false); | ||||
| 	if (ret) { | ||||
| #ifdef DEBUG | ||||
| 		console_puts_select_stderr(true, "[vc err: video_sync]"); | ||||
| #endif | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| /* Set up the number of rows and colours (rotated drivers override this) */ | ||||
|  | @ -691,9 +711,7 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, | |||
| 	for (s = argv[1]; *s; s++) | ||||
| 		vidconsole_put_char(dev, *s); | ||||
| 
 | ||||
| 	video_sync(dev->parent, false); | ||||
| 
 | ||||
| 	return 0; | ||||
| 	return video_sync(dev->parent, false); | ||||
| } | ||||
| 
 | ||||
| U_BOOT_CMD( | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
| #include <video_console.h> | ||||
| #include <asm/cache.h> | ||||
| #include <dm/lists.h> | ||||
| #include <dm/device_compat.h> | ||||
| #include <dm/device-internal.h> | ||||
| #include <dm/uclass-internal.h> | ||||
| #ifdef CONFIG_SANDBOX | ||||
|  | @ -172,7 +173,7 @@ void video_set_default_colors(struct udevice *dev, bool invert) | |||
| } | ||||
| 
 | ||||
| /* Flush video activity to the caches */ | ||||
| void video_sync(struct udevice *vid, bool force) | ||||
| int video_sync(struct udevice *vid, bool force) | ||||
| { | ||||
| 	/*
 | ||||
| 	 * flush_dcache_range() is declared in common.h but it seems that some | ||||
|  | @ -196,17 +197,22 @@ void video_sync(struct udevice *vid, bool force) | |||
| 		last_sync = get_timer(0); | ||||
| 	} | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| void video_sync_all(void) | ||||
| { | ||||
| 	struct udevice *dev; | ||||
| 	int ret; | ||||
| 
 | ||||
| 	for (uclass_find_first_device(UCLASS_VIDEO, &dev); | ||||
| 	     dev; | ||||
| 	     uclass_find_next_device(&dev)) { | ||||
| 		if (device_active(dev)) | ||||
| 			video_sync(dev, true); | ||||
| 		if (device_active(dev)) { | ||||
| 			ret = video_sync(dev, true); | ||||
| 			if (ret) | ||||
| 				dev_dbg(dev, "Video sync failed\n"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -379,8 +379,5 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, | |||
| 	if (ret) | ||||
| 		return log_ret(ret); | ||||
| 
 | ||||
| 	video_sync(dev, false); | ||||
| 
 | ||||
| 	return 0; | ||||
| 	return video_sync(dev, false); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -155,11 +155,13 @@ int video_clear(struct udevice *dev); | |||
|  * @force:	True to force a sync even if there was one recently (this is | ||||
|  *		very expensive on sandbox) | ||||
|  * | ||||
|  * @return: 0 always | ||||
|  * | ||||
|  * Some frame buffers are cached or have a secondary frame buffer. This | ||||
|  * function syncs these up so that the current contents of the U-Boot frame | ||||
|  * buffer are displayed to the user. | ||||
|  */ | ||||
| void video_sync(struct udevice *vid, bool force); | ||||
| int video_sync(struct udevice *vid, bool force); | ||||
| 
 | ||||
| /**
 | ||||
|  * video_sync_all() - Sync all devices' frame buffers with there hardware | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue