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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. --- a/drivers/media/platform/atmel/atmel-isc-base.c
  17. +++ b/drivers/media/platform/atmel/atmel-isc-base.c
  18. @@ -1216,8 +1216,8 @@ static void isc_try_fse(struct isc_devic
  19. * just use the maximum ISC can receive.
  20. */
  21. if (ret) {
  22. - pad_cfg->try_crop.width = ISC_MAX_SUPPORT_WIDTH;
  23. - pad_cfg->try_crop.height = ISC_MAX_SUPPORT_HEIGHT;
  24. + pad_cfg->try_crop.width = isc->max_width;
  25. + pad_cfg->try_crop.height = isc->max_height;
  26. } else {
  27. pad_cfg->try_crop.width = fse.max_width;
  28. pad_cfg->try_crop.height = fse.max_height;
  29. @@ -1294,10 +1294,10 @@ static int isc_try_fmt(struct isc_device
  30. isc->try_config.sd_format = sd_fmt;
  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. + if (pixfmt->width > isc->max_width)
  37. + pixfmt->width = isc->max_width;
  38. + if (pixfmt->height > isc->max_height)
  39. + pixfmt->height = isc->max_height;
  40. /*
  41. * The mbus format is the one the subdev outputs.
  42. @@ -1339,10 +1339,10 @@ static int isc_try_fmt(struct isc_device
  43. v4l2_fill_pix_format(pixfmt, &format.format);
  44. /* Limit to Atmel ISC hardware capabilities */
  45. - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  46. - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  47. - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  48. - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  49. + if (pixfmt->width > isc->max_width)
  50. + pixfmt->width = isc->max_width;
  51. + if (pixfmt->height > isc->max_height)
  52. + pixfmt->height = isc->max_height;
  53. pixfmt->field = V4L2_FIELD_NONE;
  54. pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
  55. @@ -1380,10 +1380,10 @@ static int isc_set_fmt(struct isc_device
  56. return ret;
  57. /* Limit to Atmel ISC hardware capabilities */
  58. - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
  59. - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
  60. - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
  61. - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
  62. + if (f->fmt.pix.width > isc->max_width)
  63. + f->fmt.pix.width = isc->max_width;
  64. + if (f->fmt.pix.height > isc->max_height)
  65. + f->fmt.pix.height = isc->max_height;
  66. isc->fmt = *f;
  67. --- a/drivers/media/platform/atmel/atmel-isc.h
  68. +++ b/drivers/media/platform/atmel/atmel-isc.h
  69. @@ -10,9 +10,6 @@
  70. */
  71. #ifndef _ATMEL_ISC_H_
  72. -#define ISC_MAX_SUPPORT_WIDTH 2592
  73. -#define ISC_MAX_SUPPORT_HEIGHT 1944
  74. -
  75. #define ISC_CLK_MAX_DIV 255
  76. enum isc_clk_id {
  77. @@ -190,6 +187,9 @@ struct isc_ctrls {
  78. * @gamma_table: pointer to the table with gamma values, has
  79. * gamma_max sets of GAMMA_ENTRIES entries each
  80. * @gamma_max: maximum number of sets of inside the gamma_table
  81. + *
  82. + * @max_width: maximum frame width, dependent on the internal RAM
  83. + * @max_height: maximum frame height, dependent on the internal RAM
  84. */
  85. struct isc_device {
  86. struct regmap *regmap;
  87. @@ -253,6 +253,9 @@ struct isc_device {
  88. /* pointer to the defined gamma table */
  89. const u32 (*gamma_table)[GAMMA_ENTRIES];
  90. u32 gamma_max;
  91. +
  92. + u32 max_width;
  93. + u32 max_height;
  94. };
  95. extern struct isc_format formats_list[];
  96. --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  97. +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
  98. @@ -49,8 +49,8 @@
  99. #include "atmel-isc-regs.h"
  100. #include "atmel-isc.h"
  101. -#define ISC_MAX_SUPPORT_WIDTH 2592
  102. -#define ISC_MAX_SUPPORT_HEIGHT 1944
  103. +#define ISC_SAMA5D2_MAX_SUPPORT_WIDTH 2592
  104. +#define ISC_SAMA5D2_MAX_SUPPORT_HEIGHT 1944
  105. #define ISC_CLK_MAX_DIV 255
  106. @@ -216,6 +216,9 @@ static int atmel_isc_probe(struct platfo
  107. isc->gamma_table = isc_sama5d2_gamma_table;
  108. isc->gamma_max = 2;
  109. + isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
  110. + isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
  111. +
  112. ret = isc_pipeline_init(isc);
  113. if (ret)
  114. return ret;