From b786c1e851d5e56ae7aa37bd77279a71afa0a4d0 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Mon, 27 Apr 2015 15:34:32 +0900 Subject: [PATCH] CHROMIUM: [media] rk3288-vpu: Use macros for frame size limits As a prerequisite for reusing those values in new code, this patch creates appropriate macros for them and updates current code to use them. BUG=chromium:485409 TEST=vda/veatests, Chrome with crrev.com/1097913002. Signed-off-by: Tomasz Figa Reviewed-on: https://chromium-review.googlesource.com/269865 Reviewed-by: Pawel Osciak Trybot-Ready: Pawel Osciak Change-Id: I95b1afbeff91aeb71d1748bf05895e769385f76e Signed-off-by: Jeffy Chen Signed-off-by: Yakir Yang --- drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c | 11 +++++++++-- drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c | 12 +++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c index e3c54146c53e..bb28e55c56c1 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c @@ -38,6 +38,11 @@ #define DEF_SRC_FMT_DEC V4L2_PIX_FMT_H264_SLICE #define DEF_DST_FMT_DEC V4L2_PIX_FMT_NV12 +#define RK3288_DEC_MIN_WIDTH 48U +#define RK3288_DEC_MAX_WIDTH 3840U +#define RK3288_DEC_MIN_HEIGHT 48U +#define RK3288_DEC_MAX_HEIGHT 2160U + #define RK3288_H264_MAX_SLICES_PER_FRAME 16 static struct rk3288_vpu_fmt formats[] = { @@ -289,8 +294,10 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) } /* Limit to hardware min/max. */ - pix_fmt_mp->width = clamp(pix_fmt_mp->width, 48U, 3840U); - pix_fmt_mp->height = clamp(pix_fmt_mp->height, 48U, 2160U); + pix_fmt_mp->width = clamp(pix_fmt_mp->width, + RK3288_DEC_MIN_WIDTH, RK3288_DEC_MAX_WIDTH); + pix_fmt_mp->height = clamp(pix_fmt_mp->height, + RK3288_DEC_MIN_HEIGHT, RK3288_DEC_MAX_HEIGHT); /* Round up to macroblocks. */ pix_fmt_mp->width = round_up(pix_fmt_mp->width, MB_DIM); diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c index cee6a5ebbb49..d288e04511cb 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c @@ -44,6 +44,11 @@ #define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12 #define DEF_DST_FMT_ENC V4L2_PIX_FMT_VP8 +#define RK3288_ENC_MIN_WIDTH 96U +#define RK3288_ENC_MAX_WIDTH 1920U +#define RK3288_ENC_MIN_HEIGHT 96U +#define RK3288_ENC_MAX_HEIGHT 1088U + #define V4L2_CID_PRIVATE_RK3288_HEADER (V4L2_CID_CUSTOM_BASE + 0) #define V4L2_CID_PRIVATE_RK3288_REG_PARAMS (V4L2_CID_CUSTOM_BASE + 1) #define V4L2_CID_PRIVATE_RK3288_HW_PARAMS (V4L2_CID_CUSTOM_BASE + 2) @@ -481,9 +486,10 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) } /* Limit to hardware min/max. */ - pix_fmt_mp->width = clamp(pix_fmt_mp->width, 96U, 1920U); - pix_fmt_mp->height = clamp(pix_fmt_mp->height, 96U, 1088U); - + pix_fmt_mp->width = clamp(pix_fmt_mp->width, + RK3288_ENC_MIN_WIDTH, RK3288_ENC_MAX_WIDTH); + pix_fmt_mp->height = clamp(pix_fmt_mp->height, + RK3288_ENC_MIN_HEIGHT, RK3288_ENC_MAX_HEIGHT); /* Round up to macroblocks. */ pix_fmt_mp->width = round_up(pix_fmt_mp->width, MB_DIM); pix_fmt_mp->height = round_up(pix_fmt_mp->height, MB_DIM); -- 2.34.1