[PORT FROM R2] atomisp: ensure vf res not larger than main res
authorTao Jing <jing.tao@intel.com>
Sat, 31 Dec 2011 07:23:22 +0000 (15:23 +0800)
committerbuildbot <buildbot@intel.com>
Thu, 19 Jan 2012 11:58:09 +0000 (03:58 -0800)
BZ: 20531

There is no protection when Vf resolution is configured larger
then the Main resolution

Add the restration rule here:
1: if config vf res after main res, and res larger than main res
- restrain vf res to be equal with main res
2: if config vf res before main res, and main res small than vf res
- enlarge main res to be equal with vf res

Change-Id: I71cc1dd0eac916bc713e9d56f57f1e3b26f09b1d
Orig-Change-Id: I71e54c3be4308bbcf578a854b4d00c8e7e10de3a
Signed-off-by: Tao Jing <jing.tao@intel.com>
Reviewed-on: http://android.intel.com:8080/30257
Reviewed-by: Cohen, David A <david.a.cohen@intel.com>
Reviewed-by: Koskinen, Ilkka <ilkka.koskinen@intel.com>
Tested-by: Koski, Anttu <anttu.koski@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Reviewed-on: http://android.intel.com:8080/32445
Reviewed-by: Lampila, KalleX <kallex.lampila@intel.com>
Tested-by: Lampila, KalleX <kallex.lampila@intel.com>
drivers/media/video/atomisp/atomisp_cmd.c

index 051c92a..fef295a 100644 (file)
@@ -3230,6 +3230,28 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
 
        sh_format = format_bridge->sh_fmt;
        if (!pipe->is_main) {
+               /*
+                * Check whether VF resolution configured larger
+                * than Main Resolution. If so, Force VF resolution
+                * to be the same as Main resolution
+                */
+               if (isp->isp_subdev.video_out_mo.format &&
+                   isp->isp_subdev.video_out_mo.format->out.width &&
+                   isp->isp_subdev.video_out_mo.format->out.height) {
+                       if (isp->isp_subdev.video_out_mo.format->out.width <
+                           width ||
+                           isp->isp_subdev.video_out_mo.format->out.height <
+                           height) {
+                               v4l2_warn(&atomisp_dev, "VF Resolution config "
+                                         "larger then Main Resolution. Force "
+                                         "to be equal with Main Resolution.");
+                               width = isp->isp_subdev.video_out_mo.format
+                                   ->out.width;
+                               height = isp->isp_subdev.video_out_mo.format
+                                   ->out.height;
+                       }
+               }
+
                switch (isp->sw_contex.run_mode) {
                case CI_MODE_VIDEO:
                        sh_css_video_configure_viewfinder(
@@ -3244,6 +3266,27 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
                }
                goto done;
        }
+       /*
+        * Check whether Main resolution configured smaller
+        * than Vf Resolution. If so, Force Main resolution
+        * to be the same as Main resolution
+        */
+       if (isp->isp_subdev.video_out_vf.format &&
+           isp->isp_subdev.video_out_vf.format->out.width &&
+           isp->isp_subdev.video_out_vf.format->out.height) {
+               if (isp->isp_subdev.video_out_vf.format->out.width >
+                   width ||
+                   isp->isp_subdev.video_out_vf.format->out.height >
+                   height) {
+                       v4l2_warn(&atomisp_dev, "Main Resolution config "
+                                 "smaller then Vf Resolution. Force "
+                                 "to be equal with Vf Resolution.");
+                       width = isp->isp_subdev.video_out_vf.format
+                           ->out.width;
+                       height = isp->isp_subdev.video_out_vf .format
+                           ->out.height;
+               }
+       }
 
        /* V4L2_BUF_TYPE_PRIVATE will set offline processing */
        if (f->type == V4L2_BUF_TYPE_PRIVATE)