UPSTREAM: video: Allow driver to specify the line length

At present line_length is always calculated in video_post_probe(). But
some hardware may use a different line length, e.g. with a 1366-wide
display.

Allow the driver to set this value if needed.

BUG=chromium:903818
TEST=build and boot on careena; see that display is good now
Reviewed-by: Anatolij Gustschin <agust@denx.de>
Change-Id: I66e1cffc055e84d40c47ac1ed701127bcb4f57cc
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1366597
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c
index 29113f7..b4dabea 100644
--- a/drivers/pci/pci_rom.c
+++ b/drivers/pci/pci_rom.c
@@ -331,6 +331,7 @@
 		return -ENXIO;
 	uc_priv->xsize = vesa->x_resolution;
 	uc_priv->ysize = vesa->y_resolution;
+	uc_priv->line_length = vesa->bytes_per_scanline;
 	switch (vesa->bits_per_pixel) {
 	case 32:
 	case 24:
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index dd08737..804576b 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -213,7 +213,9 @@
 
 	/* Set up the line and display size */
 	priv->fb = map_sysmem(plat->base, plat->size);
-	priv->line_length = priv->xsize * VNBYTES(priv->bpix);
+	if (!priv->line_length)
+		priv->line_length = priv->xsize * VNBYTES(priv->bpix);
+
 	priv->fb_size = priv->line_length * priv->ysize;
 
 	/* Set up colors  */
diff --git a/include/video.h b/include/video.h
index ddc2eeb..dce8c55 100644
--- a/include/video.h
+++ b/include/video.h
@@ -61,7 +61,9 @@
  * @font_size:	Font size in pixels (0 to use a default value)
  * @fb:		Frame buffer
  * @fb_size:	Frame buffer size
- * @line_length:	Length of each frame buffer line, in bytes
+ * @line_length:	Length of each frame buffer line, in bytes. This can be
+ *		set by the driver, but if not, the uclass will set it after
+ *		probing
  * @colour_fg:	Foreground colour (pixel value)
  * @colour_bg:	Background colour (pixel value)
  * @flush_dcache:	true to enable flushing of the data cache after