libcamera: ipu3: Configure ImgU with the computed parameters

Instrument the ImgUDevice::configureInput() function to use the provided
pipe configuration parameters to configure the IF, BDS and GDC
rectangles.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2020-07-08 14:30:54 +02:00
parent 4ecbd0ea5a
commit 15df621fb9
4 changed files with 36 additions and 22 deletions

View file

View file

@ -431,11 +431,11 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe)
/** /**
* \brief Configure the ImgU unit input * \brief Configure the ImgU unit input
* \param[in] size The ImgU input frame size * \param[in] config The ImgU pipe configuration parameters
* \param[in] inputFormat The format to be applied to ImgU input * \param[in] inputFormat The format to be applied to ImgU input
* \return 0 on success or a negative error code otherwise * \return 0 on success or a negative error code otherwise
*/ */
int ImgUDevice::configureInput(const Size &size, int ImgUDevice::configureInput(const PipeConfig &pipeConfig,
V4L2DeviceFormat *inputFormat) V4L2DeviceFormat *inputFormat)
{ {
/* Configure the ImgU input video device with the requested sizes. */ /* Configure the ImgU input video device with the requested sizes. */
@ -455,27 +455,27 @@ int ImgUDevice::configureInput(const Size &size,
* to configure the crop/compose rectangles, contradicting the * to configure the crop/compose rectangles, contradicting the
* V4L2 specification. * V4L2 specification.
*/ */
Rectangle rect{ 0, 0, inputFormat->size }; Rectangle iif{ 0, 0, pipeConfig.iif };
ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect); ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &iif);
if (ret)
return ret;
LOG(IPU3, Debug) << "ImgU IF rectangle = " << iif.toString();
Rectangle bds{ 0, 0, pipeConfig.bds };
ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &bds);
if (ret)
return ret;
LOG(IPU3, Debug) << "ImgU BDS rectangle = " << bds.toString();
V4L2SubdeviceFormat gdcFormat = {};
gdcFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
gdcFormat.size = pipeConfig.gdc;
ret = imgu_->setFormat(PAD_INPUT, &gdcFormat);
if (ret) if (ret)
return ret; return ret;
ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect); LOG(IPU3, Debug) << "ImgU GDC format = " << gdcFormat.toString();
if (ret)
return ret;
LOG(IPU3, Debug) << "ImgU input feeder and BDS rectangle = "
<< rect.toString();
V4L2SubdeviceFormat imguFormat = {};
imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
imguFormat.size = size;
ret = imgu_->setFormat(PAD_INPUT, &imguFormat);
if (ret)
return ret;
LOG(IPU3, Debug) << "ImgU GDC format = " << imguFormat.toString();
return 0; return 0;
} }

View file

@ -45,7 +45,7 @@ public:
PipeConfig calculatePipeConfig(Pipe *pipe); PipeConfig calculatePipeConfig(Pipe *pipe);
int configureInput(const Size &size, V4L2DeviceFormat *inputFormat); int configureInput(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputFormat);
int configureOutput(const StreamConfiguration &cfg, int configureOutput(const StreamConfiguration &cfg,
V4L2DeviceFormat *outputFormat) V4L2DeviceFormat *outputFormat)

View file

@ -67,6 +67,7 @@ public:
Status validate() override; Status validate() override;
const StreamConfiguration &cio2Format() const { return cio2Configuration_; }; const StreamConfiguration &cio2Format() const { return cio2Configuration_; };
const ImgUDevice::PipeConfig imguConfig() const { return pipeConfig_; }
private: private:
/* /*
@ -462,7 +463,20 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
if (ret) if (ret)
return ret; return ret;
ret = imgu->configureInput(sensorSize, &cio2Format); /*
* If the ImgU gets configured with proper IF, BDS and GDC sizes, it
* is then expected that frames are dequeued from its main output
* otherwise the system stalls.
*
* If no ImgU configuration has been computed, it means only a RAW
* stream has been requested: return here to skip the ImgU configuration
* part.
*/
ImgUDevice::PipeConfig imguConfig = config->imguConfig();
if (imguConfig.isNull())
return 0;
ret = imgu->configureInput(imguConfig, &cio2Format);
if (ret) if (ret)
return ret; return ret;