159-media-atmel-atmel-isc-add-checks-for-limiting-frame-.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From de8fa25cdf3726c83ac0d7b3b1e28bcb6334aadd Mon Sep 17 00:00:00 2001
  2. From: Eugen Hristev <[email protected]>
  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. When calling the subdev, certain subdev drivers will overwrite the
  7. frame size and adding sizes which are beyond the ISC's capabilities.
  8. Thus we need to ensure the frame size is cropped to the maximum caps.
  9. Signed-off-by: Eugen Hristev <[email protected]>
  10. Signed-off-by: Hans Verkuil <[email protected]>
  11. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  12. ---
  13. drivers/media/platform/atmel/atmel-isc-base.c | 12 ++++++++++++
  14. 1 file changed, 12 insertions(+)
  15. --- a/drivers/media/platform/atmel/atmel-isc-base.c
  16. +++ b/drivers/media/platform/atmel/atmel-isc-base.c
  17. @@ -1338,6 +1338,12 @@ static int isc_try_fmt(struct isc_device
  18. v4l2_fill_pix_format(pixfmt, &format.format);
  19. + /* Limit to Atmel ISC hardware capabilities */
  20. + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  21. + pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  22. + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  23. + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  24. +
  25. pixfmt->field = V4L2_FIELD_NONE;
  26. pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
  27. pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
  28. @@ -1373,6 +1379,12 @@ static int isc_set_fmt(struct isc_device
  29. if (ret < 0)
  30. return ret;
  31. + /* Limit to Atmel ISC hardware capabilities */
  32. + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  33. + pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  34. + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  35. + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  36. +
  37. isc->fmt = *f;
  38. if (isc->try_config.sd_format && isc->config.sd_format &&