ath25: switch default kernel to 5.15
[openwrt/staging/wigyori.git] / target / linux / at91 / patches-5.10 / 159-media-atmel-atmel-isc-add-checks-for-limiting-frame-.patch
1 From de8fa25cdf3726c83ac0d7b3b1e28bcb6334aadd Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:01 +0200
4 Subject: [PATCH 159/247] media: atmel: atmel-isc: add checks for limiting
5 frame sizes
6
7 When calling the subdev, certain subdev drivers will overwrite the
8 frame size and adding sizes which are beyond the ISC's capabilities.
9 Thus we need to ensure the frame size is cropped to the maximum caps.
10
11 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
12 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
14 ---
15 drivers/media/platform/atmel/atmel-isc-base.c | 12 ++++++++++++
16 1 file changed, 12 insertions(+)
17
18 --- a/drivers/media/platform/atmel/atmel-isc-base.c
19 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
20 @@ -1338,6 +1338,12 @@ static int isc_try_fmt(struct isc_device
21
22 v4l2_fill_pix_format(pixfmt, &format.format);
23
24 + /* Limit to Atmel ISC hardware capabilities */
25 + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
26 + pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
27 + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
28 + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
29 +
30 pixfmt->field = V4L2_FIELD_NONE;
31 pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
32 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
33 @@ -1373,6 +1379,12 @@ static int isc_set_fmt(struct isc_device
34 if (ret < 0)
35 return ret;
36
37 + /* Limit to Atmel ISC hardware capabilities */
38 + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
39 + pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
40 + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
41 + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
42 +
43 isc->fmt = *f;
44
45 if (isc->try_config.sd_format && isc->config.sd_format &&