libcamera: mali-c55: Limit ISP input size
The Mali-C55 ISP has a minimum input size limit of 640x480. Filter out resolutions smaller than this when selecting the sensor format. While at it, rename 'maxYuvSize' to a more appropriate 'minSensorSize'. Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
This commit is contained in:
parent
a10fcffcca
commit
0caaf7498d
1 changed files with 23 additions and 15 deletions
|
@ -79,6 +79,7 @@ const std::map<libcamera::PixelFormat, unsigned int> maliC55FmtToCode = {
|
||||||
{ formats::SGRBG16, MEDIA_BUS_FMT_SGRBG16_1X16 },
|
{ formats::SGRBG16, MEDIA_BUS_FMT_SGRBG16_1X16 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr Size kMaliC55MinInputSize = { 640, 480 };
|
||||||
constexpr Size kMaliC55MinSize = { 128, 128 };
|
constexpr Size kMaliC55MinSize = { 128, 128 };
|
||||||
constexpr Size kMaliC55MaxSize = { 8192, 8192 };
|
constexpr Size kMaliC55MaxSize = { 8192, 8192 };
|
||||||
constexpr unsigned int kMaliC55ISPInternalFormat = MEDIA_BUS_FMT_RGB121212_1X36;
|
constexpr unsigned int kMaliC55ISPInternalFormat = MEDIA_BUS_FMT_RGB121212_1X36;
|
||||||
|
@ -264,13 +265,16 @@ PixelFormat MaliC55CameraData::adjustRawFormat(const PixelFormat &rawFmt) const
|
||||||
return rawFmt;
|
return rawFmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size MaliC55CameraData::adjustRawSizes(const PixelFormat &rawFmt, const Size &rawSize) const
|
Size MaliC55CameraData::adjustRawSizes(const PixelFormat &rawFmt, const Size &size) const
|
||||||
{
|
{
|
||||||
/* Just make sure the format is supported. */
|
/* Just make sure the format is supported. */
|
||||||
auto it = maliC55FmtToCode.find(rawFmt);
|
auto it = maliC55FmtToCode.find(rawFmt);
|
||||||
if (it == maliC55FmtToCode.end())
|
if (it == maliC55FmtToCode.end())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
/* Expand the RAW size to the minimum ISP input size. */
|
||||||
|
Size rawSize = size.expandedTo(kMaliC55MinInputSize);
|
||||||
|
|
||||||
/* Check if the size is natively supported. */
|
/* Check if the size is natively supported. */
|
||||||
unsigned int rawCode = it->second;
|
unsigned int rawCode = it->second;
|
||||||
const auto rawSizes = sizes(rawCode);
|
const auto rawSizes = sizes(rawCode);
|
||||||
|
@ -281,14 +285,14 @@ Size MaliC55CameraData::adjustRawSizes(const PixelFormat &rawFmt, const Size &ra
|
||||||
/* Or adjust it to the closest supported size. */
|
/* Or adjust it to the closest supported size. */
|
||||||
uint16_t distance = std::numeric_limits<uint16_t>::max();
|
uint16_t distance = std::numeric_limits<uint16_t>::max();
|
||||||
Size bestSize;
|
Size bestSize;
|
||||||
for (const Size &size : rawSizes) {
|
for (const Size &sz : rawSizes) {
|
||||||
uint16_t dist = std::abs(static_cast<int>(rawSize.width) -
|
uint16_t dist = std::abs(static_cast<int>(rawSize.width) -
|
||||||
static_cast<int>(size.width)) +
|
static_cast<int>(sz.width)) +
|
||||||
std::abs(static_cast<int>(rawSize.height) -
|
std::abs(static_cast<int>(rawSize.height) -
|
||||||
static_cast<int>(size.height));
|
static_cast<int>(sz.height));
|
||||||
if (dist < distance) {
|
if (dist < distance) {
|
||||||
dist = distance;
|
dist = distance;
|
||||||
bestSize = size;
|
bestSize = sz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,8 +379,13 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()
|
||||||
frPipeAvailable = false;
|
frPipeAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust processed streams. */
|
/*
|
||||||
Size maxYuvSize;
|
* Adjust processed streams.
|
||||||
|
*
|
||||||
|
* Compute the minimum sensor size to be later used to select the
|
||||||
|
* sensor configuration.
|
||||||
|
*/
|
||||||
|
Size minSensorSize = kMaliC55MinInputSize;
|
||||||
for (StreamConfiguration &config : config_) {
|
for (StreamConfiguration &config : config_) {
|
||||||
if (isFormatRaw(config.pixelFormat))
|
if (isFormatRaw(config.pixelFormat))
|
||||||
continue;
|
continue;
|
||||||
|
@ -398,8 +407,8 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()
|
||||||
status = Adjusted;
|
status = Adjusted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxYuvSize < size)
|
if (minSensorSize < size)
|
||||||
maxYuvSize = size;
|
minSensorSize = size;
|
||||||
|
|
||||||
if (frPipeAvailable) {
|
if (frPipeAvailable) {
|
||||||
config.setStream(const_cast<Stream *>(&data_->frStream_));
|
config.setStream(const_cast<Stream *>(&data_->frStream_));
|
||||||
|
@ -415,7 +424,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()
|
||||||
if (rawConfig) {
|
if (rawConfig) {
|
||||||
const auto it = maliC55FmtToCode.find(rawConfig->pixelFormat);
|
const auto it = maliC55FmtToCode.find(rawConfig->pixelFormat);
|
||||||
sensorFormat_.code = it->second;
|
sensorFormat_.code = it->second;
|
||||||
sensorFormat_.size = rawConfig->size;
|
sensorFormat_.size = rawConfig->size.expandedTo(minSensorSize);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -429,14 +438,13 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()
|
||||||
const auto sizes = data_->sizes(it->second);
|
const auto sizes = data_->sizes(it->second);
|
||||||
Size bestSize;
|
Size bestSize;
|
||||||
for (const auto &size : sizes) {
|
for (const auto &size : sizes) {
|
||||||
/* Skip sensor sizes that are smaller than the max YUV size. */
|
if (minSensorSize.width > size.width ||
|
||||||
if (maxYuvSize.width > size.width ||
|
minSensorSize.height > size.height)
|
||||||
maxYuvSize.height > size.height)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint16_t dist = std::abs(static_cast<int>(maxYuvSize.width) -
|
uint16_t dist = std::abs(static_cast<int>(minSensorSize.width) -
|
||||||
static_cast<int>(size.width)) +
|
static_cast<int>(size.width)) +
|
||||||
std::abs(static_cast<int>(maxYuvSize.height) -
|
std::abs(static_cast<int>(minSensorSize.height) -
|
||||||
static_cast<int>(size.height));
|
static_cast<int>(size.height));
|
||||||
if (dist < distance) {
|
if (dist < distance) {
|
||||||
dist = distance;
|
dist = distance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue