diff options
author | Michael Tretter <m.tretter@pengutronix.de> | 2023-10-13 14:00:28 +0300 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2023-12-07 10:56:14 +0300 |
commit | 60faf2b82b52ffc3f75ad7ddc28691ce3c367d82 (patch) | |
tree | e960361d31a4d5ab8d16e7537f57cf838a93ee3e /drivers/media/platform | |
parent | ec9ef8dda2a24ce1c13904f0d46867c0aa6b4ee7 (diff) | |
download | linux-60faf2b82b52ffc3f75ad7ddc28691ce3c367d82.tar.xz |
media: rockchip: rga: use clamp() to clamp size to limits
The try_fmt should limit the width and height to the know limits of the
RGA. Use the clamp() helper instead of open coding the clamping.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r-- | drivers/media/platform/rockchip/rga/rga.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c index ea566c11734a..792084918798 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -482,15 +482,10 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f) f->fmt.pix.field = V4L2_FIELD_NONE; - if (f->fmt.pix.width > MAX_WIDTH) - f->fmt.pix.width = MAX_WIDTH; - if (f->fmt.pix.height > MAX_HEIGHT) - f->fmt.pix.height = MAX_HEIGHT; - - if (f->fmt.pix.width < MIN_WIDTH) - f->fmt.pix.width = MIN_WIDTH; - if (f->fmt.pix.height < MIN_HEIGHT) - f->fmt.pix.height = MIN_HEIGHT; + f->fmt.pix.width = clamp(f->fmt.pix.width, + (u32)MIN_WIDTH, (u32)MAX_WIDTH); + f->fmt.pix.height = clamp(f->fmt.pix.height, + (u32)MIN_HEIGHT, (u32)MAX_HEIGHT); if (fmt->hw_format >= RGA_COLOR_FMT_YUV422SP) f->fmt.pix.bytesperline = f->fmt.pix.width; |