0002-Revert-libcamera-rkisp1-Eliminate-hard-coded-resizer.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From 6e24360d3fc91cbeecb4f5cf432cd194bc098618 Mon Sep 17 00:00:00 2001
  2. From: Quentin Schulz <quentin.schulz@cherry.de>
  3. Date: Thu, 3 Apr 2025 20:09:00 +0200
  4. Subject: [PATCH] Revert "libcamera: rkisp1: Eliminate hard-coded resizer
  5. limits"
  6. This reverts commit e85c7ddd38ce8456ab01c2a73baf9e788f6a462e.
  7. Linux kernel predating 6.4 (specifically commit 7cfb35d3a800 ("media:
  8. rkisp1: Implement ENUM_FRAMESIZES") do not have the ioctl in rkisp1
  9. driver required to dynamically query the resizer limits.
  10. Because of that, maxResolution and minResolution are both {0, 0}
  11. (default value for Size objects) which means filterSensorResolution()
  12. will create an entry for the sensor in sensorSizesMap_ but because the
  13. sensor resolution cannot fit inside the min and max resolution of the
  14. rkisp1, no size is put into this entry in sensorSizesMap_.
  15. On the next call to filterSensorResolution(),
  16. sensorSizesMap_.find(sensor) will return the entry but when attempting
  17. to call back() on iter->second, it'll trigger an assert because the size
  18. array is empty.
  19. Linux kernel 6.1 is supported until December 2027, so it seems premature
  20. to get rid of those hard-coded resizer limits before this happens.
  21. Let's restore the hard-coded resizer limits as fallbacks, actual limits
  22. are still queried from the driver on recent enough kernels.
  23. Fixes: 761545407c76 ("pipeline: rkisp1: Filter out sensor sizes not supported by the pipeline")
  24. Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
  25. Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
  26. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  27. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  28. Upstream: https://git.libcamera.org/libcamera/libcamera.git/commit/?id=6e24360d3fc91cbeecb4f5cf432cd194bc098618
  29. Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
  30. ---
  31. src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 21 +++++++++++++------
  32. src/libcamera/pipeline/rkisp1/rkisp1_path.h | 3 ++-
  33. 2 files changed, 17 insertions(+), 7 deletions(-)
  34. diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
  35. index eee5b09e..64018dc5 100644
  36. --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
  37. +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
  38. @@ -54,8 +54,11 @@ const std::map<PixelFormat, uint32_t> formatToMediaBus = {
  39. } /* namespace */
  40. -RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats)
  41. - : name_(name), running_(false), formats_(formats), link_(nullptr)
  42. +RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
  43. + const Size &minResolution, const Size &maxResolution)
  44. + : name_(name), running_(false), formats_(formats),
  45. + minResolution_(minResolution), maxResolution_(maxResolution),
  46. + link_(nullptr)
  47. {
  48. }
  49. @@ -517,10 +520,12 @@ void RkISP1Path::stop()
  50. }
  51. /*
  52. - * \todo Remove the hardcoded formats once all users will have migrated to a
  53. - * recent enough kernel.
  54. + * \todo Remove the hardcoded resolutions and formats once kernels older than
  55. + * v6.4 will stop receiving LTS support (scheduled for December 2027 for v6.1).
  56. */
  57. namespace {
  58. +constexpr Size RKISP1_RSZ_MP_SRC_MIN{ 32, 16 };
  59. +constexpr Size RKISP1_RSZ_MP_SRC_MAX{ 4416, 3312 };
  60. constexpr std::array<PixelFormat, 18> RKISP1_RSZ_MP_FORMATS{
  61. formats::YUYV,
  62. formats::NV16,
  63. @@ -542,6 +547,8 @@ constexpr std::array<PixelFormat, 18> RKISP1_RSZ_MP_FORMATS{
  64. formats::SRGGB12,
  65. };
  66. +constexpr Size RKISP1_RSZ_SP_SRC_MIN{ 32, 16 };
  67. +constexpr Size RKISP1_RSZ_SP_SRC_MAX{ 1920, 1920 };
  68. constexpr std::array<PixelFormat, 8> RKISP1_RSZ_SP_FORMATS{
  69. formats::YUYV,
  70. formats::NV16,
  71. @@ -555,12 +562,14 @@ constexpr std::array<PixelFormat, 8> RKISP1_RSZ_SP_FORMATS{
  72. } /* namespace */
  73. RkISP1MainPath::RkISP1MainPath()
  74. - : RkISP1Path("main", RKISP1_RSZ_MP_FORMATS)
  75. + : RkISP1Path("main", RKISP1_RSZ_MP_FORMATS,
  76. + RKISP1_RSZ_MP_SRC_MIN, RKISP1_RSZ_MP_SRC_MAX)
  77. {
  78. }
  79. RkISP1SelfPath::RkISP1SelfPath()
  80. - : RkISP1Path("self", RKISP1_RSZ_SP_FORMATS)
  81. + : RkISP1Path("self", RKISP1_RSZ_SP_FORMATS,
  82. + RKISP1_RSZ_SP_SRC_MIN, RKISP1_RSZ_SP_SRC_MAX)
  83. {
  84. }
  85. diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
  86. index 2a1ef0ab..430181d3 100644
  87. --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h
  88. +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
  89. @@ -34,7 +34,8 @@ struct V4L2SubdeviceFormat;
  90. class RkISP1Path
  91. {
  92. public:
  93. - RkISP1Path(const char *name, const Span<const PixelFormat> &formats);
  94. + RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
  95. + const Size &minResolution, const Size &maxResolution);
  96. bool init(MediaDevice *media);