diff options
author | Umang Jain <umang.jain@ideasonboard.com> | 2021-08-10 13:28:51 +0530 |
---|---|---|
committer | Umang Jain <umang.jain@ideasonboard.com> | 2021-08-31 12:26:54 +0530 |
commit | a18c9f04906d8a6bc3f2887687fee344b2316cab (patch) | |
tree | 95bdb3a9fd71af233bbfd80e7805f05520700949 /src/libcamera/pipeline/ipu3/cio2.cpp | |
parent | 887dbdb43978ecae4407d1a916075757bbaaa51d (diff) |
libcamera: camera_sensor: Transform CameraSensor::sizes()
In CameraSensor, the mbusCodes() and sizes() accessor functions
retrieves all the supported media bus codes and the supported sizes
respectively. However, this is quite limiting since the caller
probably isn't in a position to match which range of sizes are
supported for a particular mbusCode.
Hence, the caller is most likely interested to know about the sizes
supported for a particular media bus code. This patch transforms the
existing CameraSensor::sizes() to CameraSensor::sizes(mbuscode) to
achieve that goal.
The patch also transforms existing CIO2Device::sizes() in IPU3 pipeline
handler to CIO2Device::sizes(PixelFormat) on a similar principle. The
function is then plumbed to CameraSensor::sizes(mbusCode) to enumerate
the per-format sizes as required in
PipelineHandlerIPU3::generateConfiguration().
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/ipu3/cio2.cpp')
-rw-r--r-- | src/libcamera/pipeline/ipu3/cio2.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 1bcd580e..07025b09 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -62,16 +62,35 @@ std::vector<PixelFormat> CIO2Device::formats() const /** * \brief Retrieve the list of supported size ranges - * \return The list of supported SizeRange + * \param[in] format The pixel format + * + * Retrieve the list of supported sizes for a particular \a format by matching + * the sensor produced media bus codes formats supported by the CIO2 unit. + * + * \return A list of supported sizes for the \a format or an empty list + * otherwise */ -std::vector<SizeRange> CIO2Device::sizes() const +std::vector<SizeRange> CIO2Device::sizes(const PixelFormat &format) const { + int mbusCode = -1; + if (!sensor_) return {}; std::vector<SizeRange> sizes; - for (const Size &size : sensor_->sizes()) - sizes.emplace_back(size, size); + for (const auto &iter : mbusCodesToPixelFormat) { + if (iter.second != format) + continue; + + mbusCode = iter.first; + break; + } + + if (mbusCode == -1) + return {}; + + for (const Size &sz : sensor_->sizes(mbusCode)) + sizes.emplace_back(sz); return sizes; } |