From 1e841e934de0c359715fc0406e90ce8e26beaebc Mon Sep 17 00:00:00 2001
From: lhelontra <lhe.lontra@gmail.com>
Date: Wed, 28 Jun 2017 12:04:56 -0300
Subject: [PATCH] vfe sets valid input when open device

---
 drivers/media/video/sunxi-vfe/vfe.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/media/video/sunxi-vfe/vfe.c b/drivers/media/video/sunxi-vfe/vfe.c
index 1d5189249..e56dc7908 100755
--- a/drivers/media/video/sunxi-vfe/vfe.c
+++ b/drivers/media/video/sunxi-vfe/vfe.c
@@ -2047,10 +2047,12 @@ static enum v4l2_mbus_pixelcode *try_fmt_internal(struct vfe_dev *dev,struct v4l
 
   f->fmt.pix.width = ccm_fmt.width;
   f->fmt.pix.height = ccm_fmt.height;
+  f->fmt.pix.sizeimage = ccm_fmt.height * f->fmt.pix.bytesperline;
 
   vfe_dbg(0,"bus pixel code = %x at %s\n",*bus_pix_code,__func__);
   vfe_dbg(0,"pix->width = %d at %s\n",f->fmt.pix.width,__func__);
   vfe_dbg(0,"pix->height = %d at %s\n",f->fmt.pix.height,__func__);
+  vfe_dbg(0,"pix->sizeimage = %d at %s\n",f->fmt.pix.sizeimage,__func__);
 
   return bus_pix_code;
 }
@@ -4074,6 +4076,17 @@ static int vfe_open(struct file *file)
 	{
 		vfe_print("vfe_open ok\n");
 		vfe_opened_num ++;
+        if (dev->input == -1) 
+        {
+            int i;
+            for (i = 0; i < dev->dev_qty; i++) 
+            {
+                if (!dev->device_valid_flag[i]) break;
+            }
+            if (i > 0) i -= 1;
+            ret = internal_s_input(dev , i);
+            if (!ret) vfe_dbg(0, "vfe set a valid input %d\n", i);
+        }
 	}
 	return ret;
 }
-- 
2.11.0