libcamera: pipeline: simple: Add stride support

Report the stride when configuring the camera. The stride is retrieved
from the capture device first, and overridden by the converter if used.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart
2020-05-19 19:46:15 +03:00
parent 09eeec1520
commit 5331051c35
3 changed files with 13 additions and 9 deletions
+8 -5
View File
@@ -12,6 +12,7 @@
#include <libcamera/buffer.h>
#include <libcamera/geometry.h>
#include <libcamera/signal.h>
#include <libcamera/stream.h>
#include "libcamera/internal/log.h"
#include "libcamera/internal/media_device.h"
@@ -93,14 +94,14 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
}
int SimpleConverter::configure(PixelFormat inputFormat,
PixelFormat outputFormat, const Size &size)
StreamConfiguration *cfg)
{
V4L2DeviceFormat format;
int ret;
V4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);
format.fourcc = videoFormat;
format.size = size;
format.size = cfg->size;
ret = m2m_->output()->setFormat(&format);
if (ret < 0) {
@@ -109,7 +110,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,
return ret;
}
if (format.fourcc != videoFormat || format.size != size) {
if (format.fourcc != videoFormat || format.size != cfg->size) {
LOG(SimplePipeline, Error)
<< "Input format not supported";
return -EINVAL;
@@ -119,7 +120,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,
* Set the pixel format on the output, the size is identical to the
* input as we don't support scaling.
*/
videoFormat = m2m_->capture()->toV4L2PixelFormat(outputFormat);
videoFormat = m2m_->capture()->toV4L2PixelFormat(cfg->pixelFormat);
format.fourcc = videoFormat;
ret = m2m_->capture()->setFormat(&format);
@@ -129,12 +130,14 @@ int SimpleConverter::configure(PixelFormat inputFormat,
return ret;
}
if (format.fourcc != videoFormat || format.size != size) {
if (format.fourcc != videoFormat || format.size != cfg->size) {
LOG(SimplePipeline, Error)
<< "Output format not supported";
return -EINVAL;
}
cfg->stride = format.planes[0].bpl;
return 0;
}
+2 -2
View File
@@ -20,6 +20,7 @@ namespace libcamera {
class FrameBuffer;
class MediaDevice;
struct Size;
struct StreamConfiguration;
class V4L2M2MDevice;
class SimpleConverter
@@ -33,8 +34,7 @@ public:
std::vector<PixelFormat> formats(PixelFormat input);
int configure(PixelFormat inputFormat, PixelFormat outputFormat,
const Size &size);
int configure(PixelFormat inputFormat, StreamConfiguration *cfg);
int exportBuffers(unsigned int count,
std::vector<std::unique_ptr<FrameBuffer>> *buffers);
+3 -2
View File
@@ -549,12 +549,13 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
return -EINVAL;
}
cfg.stride = captureFormat.planes[0].bpl;
/* Configure the converter if required. */
useConverter_ = config->needConversion();
if (useConverter_) {
int ret = converter_->configure(pipeConfig.pixelFormat,
cfg.pixelFormat, cfg.size);
int ret = converter_->configure(pipeConfig.pixelFormat, &cfg);
if (ret < 0) {
LOG(SimplePipeline, Error)
<< "Unable to configure converter";