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>
This commit is contained in:
parent
887dbdb439
commit
a18c9f0490
6 changed files with 46 additions and 14 deletions
|
@ -38,7 +38,7 @@ public:
|
||||||
const std::string &id() const { return id_; }
|
const std::string &id() const { return id_; }
|
||||||
const MediaEntity *entity() const { return entity_; }
|
const MediaEntity *entity() const { return entity_; }
|
||||||
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
const std::vector<unsigned int> &mbusCodes() const { return mbusCodes_; }
|
||||||
const std::vector<Size> &sizes() const { return sizes_; }
|
const std::vector<Size> sizes(unsigned int mbusCode) const;
|
||||||
Size resolution() const;
|
Size resolution() const;
|
||||||
const std::vector<int32_t> &testPatternModes() const
|
const std::vector<int32_t> &testPatternModes() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -472,14 +472,27 @@ int CameraSensor::initProperties()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn CameraSensor::sizes()
|
* \brief Retrieve the supported frame sizes for a media bus code
|
||||||
* \brief Retrieve the frame sizes supported by the camera sensor
|
* \param[in] mbusCode The media bus code for which sizes are requested
|
||||||
*
|
*
|
||||||
* The reported sizes span all media bus codes supported by the camera sensor.
|
* \return The supported frame sizes for \a mbusCode sorted in increasing order
|
||||||
* Not all sizes may be supported by all media bus codes.
|
|
||||||
*
|
|
||||||
* \return The supported frame sizes sorted in increasing order
|
|
||||||
*/
|
*/
|
||||||
|
const std::vector<Size> CameraSensor::sizes(unsigned int mbusCode) const
|
||||||
|
{
|
||||||
|
std::vector<Size> sizes;
|
||||||
|
|
||||||
|
const auto &format = formats_.find(mbusCode);
|
||||||
|
if (format == formats_.end())
|
||||||
|
return sizes;
|
||||||
|
|
||||||
|
const std::vector<SizeRange> &ranges = format->second;
|
||||||
|
std::transform(ranges.begin(), ranges.end(), std::back_inserter(sizes),
|
||||||
|
[](const SizeRange &range) { return range.max; });
|
||||||
|
|
||||||
|
std::sort(sizes.begin(), sizes.end());
|
||||||
|
|
||||||
|
return sizes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the camera sensor resolution
|
* \brief Retrieve the camera sensor resolution
|
||||||
|
|
|
@ -62,16 +62,35 @@ std::vector<PixelFormat> CIO2Device::formats() const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retrieve the list of supported size ranges
|
* \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_)
|
if (!sensor_)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
std::vector<SizeRange> sizes;
|
std::vector<SizeRange> sizes;
|
||||||
for (const Size &size : sensor_->sizes())
|
for (const auto &iter : mbusCodesToPixelFormat) {
|
||||||
sizes.emplace_back(size, size);
|
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;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
CIO2Device();
|
CIO2Device();
|
||||||
|
|
||||||
std::vector<PixelFormat> formats() const;
|
std::vector<PixelFormat> formats() const;
|
||||||
std::vector<SizeRange> sizes() const;
|
std::vector<SizeRange> sizes(const PixelFormat &format) const;
|
||||||
|
|
||||||
int init(const MediaDevice *media, unsigned int index);
|
int init(const MediaDevice *media, unsigned int index);
|
||||||
int configure(const Size &size, V4L2DeviceFormat *outputFormat);
|
int configure(const Size &size, V4L2DeviceFormat *outputFormat);
|
||||||
|
|
|
@ -457,7 +457,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
|
||||||
bufferCount = cio2Config.bufferCount;
|
bufferCount = cio2Config.bufferCount;
|
||||||
|
|
||||||
for (const PixelFormat &format : data->cio2_.formats())
|
for (const PixelFormat &format : data->cio2_.formats())
|
||||||
streamFormats[format] = data->cio2_.sizes();
|
streamFormats[format] = data->cio2_.sizes(format);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ protected:
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Size> &sizes = sensor_->sizes();
|
const std::vector<Size> &sizes = sensor_->sizes(*iter);
|
||||||
auto iter2 = std::find(sizes.begin(), sizes.end(),
|
auto iter2 = std::find(sizes.begin(), sizes.end(),
|
||||||
Size(4096, 2160));
|
Size(4096, 2160));
|
||||||
if (iter2 == sizes.end()) {
|
if (iter2 == sizes.end()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue