summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-30 21:16:28 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-30 22:18:42 +0300
commita2dddf7c26df3307b9d4554c25387a00687a6234 (patch)
treebe4004bb072d39d471ee790069e3f74d1cd5bbe0 /src/libcamera/pipeline
parentbaad55d00975f8931d51c333def20472457dc943 (diff)
libcamera: Use the Size class through libcamera
Several of our structures include width and height fields that model a size while we have a Size class for that purpose. Use the Size class through libcamera, and give it a toString() method like other geometry and format classes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/pipeline')
-rw-r--r--src/libcamera/pipeline/ipu3/ipu3.cpp39
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp16
-rw-r--r--src/libcamera/pipeline/uvcvideo.cpp9
-rw-r--r--src/libcamera/pipeline/vimc.cpp9
4 files changed, 28 insertions, 45 deletions
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index fbb37498..3aa47548 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -262,8 +262,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,
*
* \todo Clarify ImgU alignment requirements.
*/
- streamConfig.width = 2560;
- streamConfig.height = 1920;
+ streamConfig.size = { 2560, 1920 };
break;
@@ -295,8 +294,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,
res.width);
unsigned int height = std::min(usage.size().height,
res.height);
- streamConfig.width = width & ~7;
- streamConfig.height = height & ~3;
+ streamConfig.size = { width & ~7, height & ~3 };
break;
}
@@ -347,15 +345,15 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
* \todo: Consider the BDS scaling factor requirements: "the
* downscaling factor must be an integer value multiple of 1/32"
*/
- if (cfg.width % 8 || cfg.height % 4) {
+ if (cfg.size.width % 8 || cfg.size.height % 4) {
LOG(IPU3, Error)
<< "Invalid stream size: bad alignment";
return -EINVAL;
}
const Size &resolution = cio2->sensor_->resolution();
- if (cfg.width > resolution.width ||
- cfg.height > resolution.height) {
+ if (cfg.size.width > resolution.width ||
+ cfg.size.height > resolution.height) {
LOG(IPU3, Error)
<< "Invalid stream size: larger than sensor resolution";
return -EINVAL;
@@ -365,10 +363,10 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
* Collect the maximum width and height: IPU3 can downscale
* only.
*/
- if (cfg.width > sensorSize.width)
- sensorSize.width = cfg.width;
- if (cfg.height > sensorSize.height)
- sensorSize.height = cfg.height;
+ if (cfg.size.width > sensorSize.width)
+ sensorSize.width = cfg.size.width;
+ if (cfg.size.height > sensorSize.height)
+ sensorSize.height = cfg.size.height;
stream->active_ = true;
}
@@ -427,8 +425,7 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
* \todo Revise this when we'll actually use the stat node.
*/
StreamConfiguration statConfig = {};
- statConfig.width = cio2Format.width;
- statConfig.height = cio2Format.height;
+ statConfig.size = cio2Format.size;
ret = imgu->configureOutput(&imgu->stat_, statConfig);
if (ret)
@@ -932,8 +929,8 @@ int ImgUDevice::configureInput(const Size &size,
Rectangle rect = {
.x = 0,
.y = 0,
- .w = inputFormat->width,
- .h = inputFormat->height,
+ .w = inputFormat->size.width,
+ .h = inputFormat->size.height,
};
ret = imgu_->setCrop(PAD_INPUT, &rect);
if (ret)
@@ -947,9 +944,8 @@ int ImgUDevice::configureInput(const Size &size,
<< rect.toString();
V4L2SubdeviceFormat imguFormat = {};
- imguFormat.width = size.width;
- imguFormat.height = size.height;
imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
+ imguFormat.size = size;
ret = imgu_->setFormat(PAD_INPUT, &imguFormat);
if (ret)
@@ -973,9 +969,8 @@ int ImgUDevice::configureOutput(ImgUOutput *output,
unsigned int pad = output->pad;
V4L2SubdeviceFormat imguFormat = {};
- imguFormat.width = config.width;
- imguFormat.height = config.height;
imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
+ imguFormat.size = config.size;
int ret = imgu_->setFormat(pad, &imguFormat);
if (ret)
@@ -986,9 +981,8 @@ int ImgUDevice::configureOutput(ImgUOutput *output,
return 0;
V4L2DeviceFormat outputFormat = {};
- outputFormat.width = config.width;
- outputFormat.height = config.height;
outputFormat.fourcc = V4L2_PIX_FMT_NV12;
+ outputFormat.size = config.size;
outputFormat.planesCount = 2;
ret = dev->setFormat(&outputFormat);
@@ -1288,9 +1282,8 @@ int CIO2Device::configure(const Size &size,
if (ret)
return ret;
- outputFormat->width = sensorFormat.width;
- outputFormat->height = sensorFormat.height;
outputFormat->fourcc = mediaBusToFormat(sensorFormat.mbus_code);
+ outputFormat->size = sensorFormat.size;
outputFormat->planesCount = 1;
ret = output_->setFormat(outputFormat);
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 9a63a68b..7acf8515 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -116,10 +116,8 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera,
CameraConfiguration configs;
StreamConfiguration config{};
- const Size &resolution = data->sensor_->resolution();
- config.width = resolution.width;
- config.height = resolution.height;
config.pixelFormat = V4L2_PIX_FMT_NV12;
+ config.size = data->sensor_->resolution();
config.bufferCount = RKISP1_BUFFER_COUNT;
configs[&data->stream_] = config;
@@ -137,8 +135,8 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,
/* Verify the configuration. */
const Size &resolution = sensor->resolution();
- if (cfg.width > resolution.width ||
- cfg.height > resolution.height) {
+ if (cfg.size.width > resolution.width ||
+ cfg.size.height > resolution.height) {
LOG(RkISP1, Error)
<< "Invalid stream size: larger than sensor resolution";
return -EINVAL;
@@ -193,7 +191,7 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,
MEDIA_BUS_FMT_SGBRG8_1X8,
MEDIA_BUS_FMT_SGRBG8_1X8,
MEDIA_BUS_FMT_SRGGB8_1X8 },
- Size(cfg.width, cfg.height));
+ cfg.size);
LOG(RkISP1, Debug) << "Configuring sensor with " << format.toString();
@@ -216,17 +214,15 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,
return ret;
V4L2DeviceFormat outputFormat = {};
- outputFormat.width = cfg.width;
- outputFormat.height = cfg.height;
outputFormat.fourcc = cfg.pixelFormat;
+ outputFormat.size = cfg.size;
outputFormat.planesCount = 2;
ret = video_->setFormat(&outputFormat);
if (ret)
return ret;
- if (outputFormat.width != cfg.width ||
- outputFormat.height != cfg.height ||
+ if (outputFormat.size != cfg.size ||
outputFormat.fourcc != cfg.pixelFormat) {
LOG(RkISP1, Error)
<< "Unable to configure capture in " << cfg.toString();
diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
index fd1d6df1..358e247b 100644
--- a/src/libcamera/pipeline/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo.cpp
@@ -92,9 +92,8 @@ PipelineHandlerUVC::streamConfiguration(Camera *camera,
CameraConfiguration configs;
StreamConfiguration config{};
- config.width = 640;
- config.height = 480;
config.pixelFormat = V4L2_PIX_FMT_YUYV;
+ config.size = { 640, 480 };
config.bufferCount = 4;
configs[&data->stream_] = config;
@@ -110,16 +109,14 @@ int PipelineHandlerUVC::configureStreams(Camera *camera,
int ret;
V4L2DeviceFormat format = {};
- format.width = cfg->width;
- format.height = cfg->height;
format.fourcc = cfg->pixelFormat;
+ format.size = cfg->size;
ret = data->video_->setFormat(&format);
if (ret)
return ret;
- if (format.width != cfg->width ||
- format.height != cfg->height ||
+ if (format.size != cfg->size ||
format.fourcc != cfg->pixelFormat)
return -EINVAL;
diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
index f9514066..83fa9cf4 100644
--- a/src/libcamera/pipeline/vimc.cpp
+++ b/src/libcamera/pipeline/vimc.cpp
@@ -92,9 +92,8 @@ PipelineHandlerVimc::streamConfiguration(Camera *camera,
CameraConfiguration configs;
StreamConfiguration config{};
- config.width = 640;
- config.height = 480;
config.pixelFormat = V4L2_PIX_FMT_RGB24;
+ config.size = { 640, 480 };
config.bufferCount = 4;
configs[&data->stream_] = config;
@@ -110,16 +109,14 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,
int ret;
V4L2DeviceFormat format = {};
- format.width = cfg->width;
- format.height = cfg->height;
format.fourcc = cfg->pixelFormat;
+ format.size = cfg->size;
ret = data->video_->setFormat(&format);
if (ret)
return ret;
- if (format.width != cfg->width ||
- format.height != cfg->height ||
+ if (format.size != cfg->size ||
format.fourcc != cfg->pixelFormat)
return -EINVAL;