From: Tomasz Figa Date: Mon, 23 Mar 2015 06:16:32 +0000 (+0900) Subject: CHROMIUM: [media] rk3288-vpu: Fix image size clamping X-Git-Tag: firefly_0821_release~2312 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b0ac756a6c36b001ad0c0360d62071945a9b56f1;p=firefly-linux-kernel-4.4.55.git CHROMIUM: [media] rk3288-vpu: Fix image size clamping 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 Reviewed-on: https://chromium-review.googlesource.com/261851 Reviewed-by: Pawel Osciak Change-Id: I0c51e5a9ad235716ee447e052455b97ed0c295de Signed-off-by: Jeffy Chen Signed-off-by: Yakir Yang --- diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c index cc0f9b3f0601..62fde2772353 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c @@ -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) { diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c index 3336143f13a5..bf00ae0d7d76 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c @@ -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) {