summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorEugen Hristev <eugen.hristev@microchip.com>2021-04-13 12:57:01 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-06-08 12:19:05 +0200
commit5122e8d15a0703b6d8bf6cb703536d29f8aa74cf (patch)
tree61c2b2e8625b2928155899879b7ef6c89b15eace /drivers/media
parentd5475b3c901a007e74544e7704a1c2107dbcc115 (diff)
downloadlinux-5122e8d15a0703b6d8bf6cb703536d29f8aa74cf.tar.gz
linux-5122e8d15a0703b6d8bf6cb703536d29f8aa74cf.tar.bz2
linux-5122e8d15a0703b6d8bf6cb703536d29f8aa74cf.zip
media: atmel: atmel-isc: add checks for limiting frame sizes
When calling the subdev, certain subdev drivers will overwrite the frame size and adding sizes which are beyond the ISC's capabilities. Thus we need to ensure the frame size is cropped to the maximum caps. Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/atmel/atmel-isc-base.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
index d987a8891bd9..02f1d1c6b06e 100644
--- a/drivers/media/platform/atmel/atmel-isc-base.c
+++ b/drivers/media/platform/atmel/atmel-isc-base.c
@@ -1338,6 +1338,12 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
v4l2_fill_pix_format(pixfmt, &format.format);
+ /* Limit to Atmel ISC hardware capabilities */
+ if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
+ pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
+ if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
+ pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
+
pixfmt->field = V4L2_FIELD_NONE;
pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
@@ -1373,6 +1379,12 @@ static int isc_set_fmt(struct isc_device *isc, struct v4l2_format *f)
if (ret < 0)
return ret;
+ /* Limit to Atmel ISC hardware capabilities */
+ if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
+ pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
+ if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
+ pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
+
isc->fmt = *f;
if (isc->try_config.sd_format && isc->config.sd_format &&