160-media-atmel-atmel-isc-specialize-max-width-and-max-h.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. From b51819e17260af2ecc152b7dcd61e63bcaa35edf Mon Sep 17 00:00:00 2001
  2. From: Eugen Hristev <[email protected]>
  3. Date: Tue, 13 Apr 2021 12:57:02 +0200
  4. Subject: [PATCH 160/247] media: atmel: atmel-isc: specialize max width and max
  5. height
  6. Move the max width and max height constants to the product specific driver
  7. and have them in the device struct.
  8. Signed-off-by: Eugen Hristev <[email protected]>
  9. Signed-off-by: Hans Verkuil <[email protected]>
  10. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  11. ---
  12. drivers/media/platform/atmel/atmel-isc-base.c | 28 +++++++++----------
  13. drivers/media/platform/atmel/atmel-isc.h | 9 ++++--
  14. .../media/platform/atmel/atmel-sama5d2-isc.c | 7 +++--
  15. 3 files changed, 25 insertions(+), 19 deletions(-)
  16. diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
  17. index 02f1d1c6b06e..ed0048e79f3b 100644
  18. --- a/drivers/media/platform/atmel/atmel-isc-base.c
  19. +++ b/drivers/media/platform/atmel/atmel-isc-base.c
  20. @@ -1216,8 +1216,8 @@ static void isc_try_fse(struct isc_device *isc,
  21. * just use the maximum ISC can receive.
  22. */
  23. if (ret) {
  24. - pad_cfg->try_crop.width = ISC_MAX_SUPPORT_WIDTH;
  25. - pad_cfg->try_crop.height = ISC_MAX_SUPPORT_HEIGHT;
  26. + pad_cfg->try_crop.width = isc->max_width;
  27. + pad_cfg->try_crop.height = isc->max_height;
  28. } else {
  29. pad_cfg->try_crop.width = fse.max_width;
  30. pad_cfg->try_crop.height = fse.max_height;
  31. @@ -1294,10 +1294,10 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
  32. isc->try_config.sd_format = sd_fmt;
  33. /* Limit to Atmel ISC hardware capabilities */
  34. - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  35. - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  36. - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  37. - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  38. + if (pixfmt->width > isc->max_width)
  39. + pixfmt->width = isc->max_width;
  40. + if (pixfmt->height > isc->max_height)
  41. + pixfmt->height = isc->max_height;
  42. /*
  43. * The mbus format is the one the subdev outputs.
  44. @@ -1339,10 +1339,10 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
  45. v4l2_fill_pix_format(pixfmt, &format.format);
  46. /* Limit to Atmel ISC hardware capabilities */
  47. - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  48. - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  49. - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  50. - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  51. + if (pixfmt->width > isc->max_width)
  52. + pixfmt->width = isc->max_width;
  53. + if (pixfmt->height > isc->max_height)
  54. + pixfmt->height = isc->max_height;
  55. pixfmt->field = V4L2_FIELD_NONE;
  56. pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
  57. @@ -1380,10 +1380,10 @@ static int isc_set_fmt(struct isc_device *isc, struct v4l2_format *f)
  58. return ret;
  59. /* Limit to Atmel ISC hardware capabilities */
  60. - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  61. - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  62. - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  63. - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  64. + if (f->fmt.pix.width > isc->max_width)
  65. + f->fmt.pix.width = isc->max_width;
  66. + if (f->fmt.pix.height > isc->max_height)
  67. + f->fmt.pix.height = isc->max_height;
  68. isc->fmt = *f;
  69. diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
  70. index bb43d3a93052..f208fb691ac9 100644
  71. --- a/drivers/media/platform/atmel/atmel-isc.h
  72. +++ b/drivers/media/platform/atmel/atmel-isc.h
  73. @@ -10,9 +10,6 @@
  74. */
  75. #ifndef _ATMEL_ISC_H_
  76. -#define ISC_MAX_SUPPORT_WIDTH 2592
  77. -#define ISC_MAX_SUPPORT_HEIGHT 1944
  78. -
  79. #define ISC_CLK_MAX_DIV 255
  80. enum isc_clk_id {
  81. @@ -190,6 +187,9 @@ struct isc_ctrls {
  82. * @gamma_table: pointer to the table with gamma values, has
  83. * gamma_max sets of GAMMA_ENTRIES entries each
  84. * @gamma_max: maximum number of sets of inside the gamma_table
  85. + *
  86. + * @max_width: maximum frame width, dependent on the internal RAM
  87. + * @max_height: maximum frame height, dependent on the internal RAM
  88. */
  89. struct isc_device {
  90. struct regmap *regmap;
  91. @@ -253,6 +253,9 @@ struct isc_device {
  92. /* pointer to the defined gamma table */
  93. const u32 (*gamma_table)[GAMMA_ENTRIES];
  94. u32 gamma_max;
  95. +
  96. + u32 max_width;
  97. + u32 max_height;
  98. };
  99. extern struct isc_format formats_list[];
  100. diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  101. index cba6e6c8810b..39fc8d4f9bdc 100644
  102. --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  103. +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  104. @@ -49,8 +49,8 @@
  105. #include "atmel-isc-regs.h"
  106. #include "atmel-isc.h"
  107. -#define ISC_MAX_SUPPORT_WIDTH 2592
  108. -#define ISC_MAX_SUPPORT_HEIGHT 1944
  109. +#define ISC_SAMA5D2_MAX_SUPPORT_WIDTH 2592
  110. +#define ISC_SAMA5D2_MAX_SUPPORT_HEIGHT 1944
  111. #define ISC_CLK_MAX_DIV 255
  112. @@ -216,6 +216,9 @@ static int atmel_isc_probe(struct platform_device *pdev)
  113. isc->gamma_table = isc_sama5d2_gamma_table;
  114. isc->gamma_max = 2;
  115. + isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
  116. + isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
  117. +
  118. ret = isc_pipeline_init(isc);
  119. if (ret)
  120. return ret;
  121. --
  122. 2.32.0