@@ -214,10 +214,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
bitDepth = bayerFormat.bitDepth;
}
- V4L2SubdeviceFormat sensorFormat =
- data_->findBestFormat(rawStreams.empty() ? outStreams[0].cfg->size
- : rawStreams[0].cfg->size,
- bitDepth);
+ sensorFormat_ = data_->findBestFormat(rawStreams.empty() ? outStreams[0].cfg->size
+ : rawStreams[0].cfg->size,
+ bitDepth);
status = data_->platformValidate(rawStreams, outStreams);
if (status == Invalid)
@@ -232,7 +231,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
bitDepth = info.isValid() ? info.bitsPerPixel : defaultRawBitDepth;
BayerFormat::Packing packing = BayerFormat::fromPixelFormat(cfg.pixelFormat).packing;
- rawFormat = PipelineHandlerBase::toV4L2DeviceFormat(raw.dev, sensorFormat, packing);
+ rawFormat = PipelineHandlerBase::toV4L2DeviceFormat(raw.dev, sensorFormat_, packing);
int ret = raw.dev->tryFormat(&rawFormat);
if (ret)
@@ -452,8 +451,6 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)
stream->clearFlags(StreamFlag::External);
std::vector<CameraData::StreamParams> rawStreams, ispStreams;
- std::optional<BayerFormat::Packing> packing;
- unsigned int bitDepth = defaultRawBitDepth;
for (unsigned i = 0; i < config->size(); i++) {
StreamConfiguration *cfg = &config->at(i);
@@ -471,32 +468,23 @@ int PipelineHandlerBase::configure(Camera *camera, CameraConfiguration *config)
std::sort(ispStreams.begin(), ispStreams.end(),
[](auto &l, auto &r) { return l.cfg->size > r.cfg->size; });
- /*
- * Calculate the best sensor mode we can use based on the user's request,
- * and apply it to the sensor with the cached tranform, if any.
- *
- * If we have been given a RAW stream, use that size for setting up the sensor.
- */
- if (!rawStreams.empty()) {
- BayerFormat bayerFormat = BayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);
- /* Replace the user requested packing/bit-depth. */
- packing = bayerFormat.packing;
- bitDepth = bayerFormat.bitDepth;
- }
-
- V4L2SubdeviceFormat sensorFormat =
- data->findBestFormat(rawStreams.empty() ? ispStreams[0].cfg->size
- : rawStreams[0].cfg->size,
- bitDepth);
+ /* Apply the format on the sensor with any cached transform. */
+ const RPiCameraConfiguration *rpiConfig =
+ static_cast<const RPiCameraConfiguration *>(config);
+ V4L2SubdeviceFormat sensorFormat = rpiConfig->sensorFormat_;
- /* Apply any cached transform. */
- const RPiCameraConfiguration *rpiConfig = static_cast<const RPiCameraConfiguration *>(config);
-
- /* Then apply the format on the sensor. */
ret = data->sensor_->setFormat(&sensorFormat, rpiConfig->combinedTransform_);
if (ret)
return ret;
+ /* Use the user requested packing/bit-depth. */
+ std::optional<BayerFormat::Packing> packing;
+ if (!rawStreams.empty()) {
+ BayerFormat bayerFormat =
+ BayerFormat::fromPixelFormat(rawStreams[0].cfg->pixelFormat);
+ packing = bayerFormat.packing;
+ }
+
/*
* Platform specific internal stream configuration. This also assigns
* external streams which get configured below.
@@ -262,6 +262,8 @@ public:
/* Cache the combinedTransform_ that will be applied to the sensor */
Transform combinedTransform_;
+ /* The sensor format computed in validate() */
+ V4L2SubdeviceFormat sensorFormat_;
private:
const CameraData *data_;