summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_subdevice.cpp
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/v4l2_subdevice.cpp
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/v4l2_subdevice.cpp')
-rw-r--r--src/libcamera/v4l2_subdevice.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 6fc866a6..fceee331 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -65,13 +65,8 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)
*/
/**
- * \var V4L2SubdeviceFormat::width
- * \brief The image width in pixels
- */
-
-/**
- * \var V4L2SubdeviceFormat::height
- * \brief The image height in pixels
+ * \var V4L2SubdeviceFormat::size
+ * \brief The image size in pixels
*/
/**
@@ -83,8 +78,7 @@ const std::string V4L2SubdeviceFormat::toString() const
std::stringstream ss;
ss.fill(0);
- ss << width << "x" << height << "-0x" << std::hex
- << std::setw(4) << mbus_code;
+ ss << size.toString() << "-0x" << std::hex << std::setw(4) << mbus_code;
return ss.str();
}
@@ -265,8 +259,8 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format)
return ret;
}
- format->width = subdevFmt.format.width;
- format->height = subdevFmt.format.height;
+ format->size.width = subdevFmt.format.width;
+ format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
return 0;
@@ -288,8 +282,8 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)
struct v4l2_subdev_format subdevFmt = {};
subdevFmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
subdevFmt.pad = pad;
- subdevFmt.format.width = format->width;
- subdevFmt.format.height = format->height;
+ subdevFmt.format.width = format->size.width;
+ subdevFmt.format.height = format->size.height;
subdevFmt.format.code = format->mbus_code;
int ret = ioctl(fd_, VIDIOC_SUBDEV_S_FMT, &subdevFmt);
@@ -301,8 +295,8 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format)
return ret;
}
- format->width = subdevFmt.format.width;
- format->height = subdevFmt.format.height;
+ format->size.width = subdevFmt.format.width;
+ format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
return 0;