pipeline: raspberrypi: Restrict the advertised maximum ISP output resolution

Limit the advertised ISP output sizes available to the sensor resolution in
PipelineHandlerRPi::generateConfiguration(). The user is free to configure a
larger resolution than this, and this will work. However, this stops strange
behavior in applications that use the V4L2 compatability layer to run, and
request the largest possible advertised resolution, which is much larger than
the sensor resolution.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2021-12-08 12:36:37 +00:00 committed by Kieran Bingham
parent 5964420570
commit f16acb275c

View file

@ -530,10 +530,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
unsigned int rawCount = 0; unsigned int rawCount = 0;
unsigned int outCount = 0; unsigned int outCount = 0;
Size sensorSize = data->sensor_->resolution();
for (const StreamRole role : roles) { for (const StreamRole role : roles) {
switch (role) { switch (role) {
case StreamRole::Raw: case StreamRole::Raw:
size = data->sensor_->resolution(); size = sensorSize;
sensorFormat = findBestFormat(data->sensorFormats_, size, defaultRawBitDepth); sensorFormat = findBestFormat(data->sensorFormats_, size, defaultRawBitDepth);
pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code, pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code,
BayerFormat::Packing::CSI2); BayerFormat::Packing::CSI2);
@ -546,7 +547,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
fmts = data->isp_[Isp::Output0].dev()->formats(); fmts = data->isp_[Isp::Output0].dev()->formats();
pixelFormat = formats::NV12; pixelFormat = formats::NV12;
/* Return the largest sensor resolution. */ /* Return the largest sensor resolution. */
size = data->sensor_->resolution(); size = sensorSize;
bufferCount = 1; bufferCount = 1;
outCount++; outCount++;
break; break;
@ -599,11 +600,15 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,
std::forward_as_tuple(format.second.begin(), format.second.end())); std::forward_as_tuple(format.second.begin(), format.second.end()));
} }
} else { } else {
/* Translate the V4L2PixelFormat to PixelFormat. */ /*
* Translate the V4L2PixelFormat to PixelFormat. Note that we
* limit the recommended largest ISP output size to match the
* sensor resolution.
*/
for (const auto &format : fmts) { for (const auto &format : fmts) {
PixelFormat pf = format.first.toPixelFormat(); PixelFormat pf = format.first.toPixelFormat();
if (pf.isValid()) if (pf.isValid())
deviceFormats[pf] = format.second; deviceFormats[pf].emplace_back(sensorSize);
} }
} }