CHROMIUM: [media] rk3288-vpu: Fix image size clamping
authorTomasz Figa <tfiga@chromium.org>
Mon, 23 Mar 2015 06:16:32 +0000 (15:16 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:54:03 +0000 (19:54 +0800)
Current code always assumed the maximum supported resolution to be
1920x1088, and minimum 8x4 however the real limits are 48x48 and 3840x2160
for decoder and 96x96 and 1920x1088 for encoder. This patch modifies the
driver to use correct limits and also fixes incorrect log message.

BUG=chrome-os-partner:38232,chromium:464920
TEST=Screen sharing of a window bigger than 1920x1088 to Jerry

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/261851
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Change-Id: I0c51e5a9ad235716ee447e052455b97ed0c295de
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c
drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c

index cc0f9b3f060187384a3e9e75914ee407cb1ecb7f..62fde27723539ad2a26063f948bbe4ed5c691e33 100644 (file)
@@ -289,8 +289,8 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                }
 
                /* Limit to hardware min/max. */
-               v4l_bound_align_image(&pix_fmt_mp->width, 8, 1920, 0,
-                                     &pix_fmt_mp->height, 4, 1088, 0, 0);
+               pix_fmt_mp->width = clamp(pix_fmt_mp->width, 48U, 3840U);
+               pix_fmt_mp->height = clamp(pix_fmt_mp->height, 48U, 2160U);
 
                /* Round up to macroblocks. */
                pix_fmt_mp->width = round_up(pix_fmt_mp->width, MB_DIM);
@@ -377,7 +377,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 
                vpu_debug(0, "CAPTURE codec mode: %d\n", fmt->codec_mode);
                vpu_debug(0, "fmt - w: %d, h: %d, mb - w: %d, h: %d\n",
-                         pix_fmt_mp->width, pix_fmt_mp->width,
+                         pix_fmt_mp->width, pix_fmt_mp->height,
                          mb_width, mb_height);
 
                for (i = 0; i < fmt->num_planes; ++i) {
index 3336143f13a5c7cdf9dc0b9794a607af6e3c2c51..bf00ae0d7d7610105bac3df598874de53dc9be87 100644 (file)
@@ -481,8 +481,8 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
                }
 
                /* Limit to hardware min/max. */
-               v4l_bound_align_image(&pix_fmt_mp->width, 8, 1920, 0,
-                                     &pix_fmt_mp->height, 4, 1080, 0, 0);
+               pix_fmt_mp->width = clamp(pix_fmt_mp->width, 96U, 1920U);
+               pix_fmt_mp->height = clamp(pix_fmt_mp->height, 96U, 1088U);
 
                /* Round up to macroblocks. */
                pix_fmt_mp->width = round_up(pix_fmt_mp->width, MB_DIM);
@@ -559,7 +559,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 
                vpu_debug(0, "OUTPUT codec mode: %d\n", fmt->codec_mode);
                vpu_debug(0, "fmt - w: %d, h: %d, mb - w: %d, h: %d\n",
-                         pix_fmt_mp->width, pix_fmt_mp->width,
+                         pix_fmt_mp->width, pix_fmt_mp->height,
                          mb_width, mb_height);
 
                for (i = 0; i < fmt->num_planes; ++i) {