From patchwork Fri Feb 1 15:42:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 473 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B975B60B10 for ; Fri, 1 Feb 2019 16:42:39 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 7B0ED1BF215; Fri, 1 Feb 2019 15:42:39 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:42 +0100 Message-Id: <20190201154248.15006-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/7] libcamera: v4l2_device: Rename format() method to getFormat() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:39 -0000 Rename format() to getFormat() to reflect the v4l2 API names more closely. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/include/v4l2_device.h | 2 +- src/libcamera/v4l2_device.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index f68b2b1..70e3c00 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -86,7 +86,7 @@ public: const char *deviceName() const { return caps_.card(); } const char *busName() const { return caps_.bus_info(); } - int format(V4L2DeviceFormat *fmt); + int getFormat(V4L2DeviceFormat *fmt); int setFormat(V4L2DeviceFormat *fmt); private: diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 5c415d0..26b6ff3 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -282,7 +282,7 @@ void V4L2Device::close() * \brief Retrieve the image format set on the V4L2 device * \return 0 for success, a negative error code otherwise */ -int V4L2Device::format(V4L2DeviceFormat *fmt) +int V4L2Device::getFormat(V4L2DeviceFormat *fmt) { return caps_.isMultiplanar() ? getFormatMultiplane(fmt) : getFormatSingleplane(fmt); From patchwork Fri Feb 1 15:42:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 474 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 39DD660B10 for ; Fri, 1 Feb 2019 16:42:40 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id DD2621BF207; Fri, 1 Feb 2019 15:42:39 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:43 +0100 Message-Id: <20190201154248.15006-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/7] libcamera: v4l2_device: Fix getFormatSingleplane ioclt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:40 -0000 The single plane getFormat() function wrongly used the VIDIOC_S_FMT ioctl. Fix that by using the more opportune VIDIOC_G_FMT one. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 26b6ff3..5ba89b9 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -305,7 +305,7 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *fmt) int ret; v4l2Fmt.type = bufferType_; - ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Fmt); + ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Fmt); if (ret) { ret = -errno; LOG(Error) << "Unable to get format: " << strerror(-ret); From patchwork Fri Feb 1 15:42:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 475 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B962660DBB for ; Fri, 1 Feb 2019 16:42:40 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 63E351BF207; Fri, 1 Feb 2019 15:42:40 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:44 +0100 Message-Id: <20190201154248.15006-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/7] libcamera: v4l2_device: Rename parameters to s/g_fmt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:41 -0000 Rename parameters to get and set format functions to expand 'fmt' to 'format'. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/include/v4l2_device.h | 12 ++-- src/libcamera/v4l2_device.cpp | 96 ++++++++++++++--------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index 70e3c00..e65a540 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -86,15 +86,15 @@ public: const char *deviceName() const { return caps_.card(); } const char *busName() const { return caps_.bus_info(); } - int getFormat(V4L2DeviceFormat *fmt); - int setFormat(V4L2DeviceFormat *fmt); + int getFormat(V4L2DeviceFormat *format); + int setFormat(V4L2DeviceFormat *format); private: - int getFormatSingleplane(V4L2DeviceFormat *fmt); - int setFormatSingleplane(V4L2DeviceFormat *fmt); + int getFormatSingleplane(V4L2DeviceFormat *format); + int setFormatSingleplane(V4L2DeviceFormat *format); - int getFormatMultiplane(V4L2DeviceFormat *fmt); - int setFormatMultiplane(V4L2DeviceFormat *fmt); + int getFormatMultiplane(V4L2DeviceFormat *format); + int setFormatMultiplane(V4L2DeviceFormat *format); std::string deviceNode_; int fd_; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 5ba89b9..8cf566c 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -282,58 +282,58 @@ void V4L2Device::close() * \brief Retrieve the image format set on the V4L2 device * \return 0 for success, a negative error code otherwise */ -int V4L2Device::getFormat(V4L2DeviceFormat *fmt) +int V4L2Device::getFormat(V4L2DeviceFormat *format) { - return caps_.isMultiplanar() ? getFormatMultiplane(fmt) : - getFormatSingleplane(fmt); + return caps_.isMultiplanar() ? getFormatMultiplane(format) : + getFormatSingleplane(format); } /** * \brief Configure an image format on the V4L2 device * \return 0 for success, a negative error code otherwise */ -int V4L2Device::setFormat(V4L2DeviceFormat *fmt) +int V4L2Device::setFormat(V4L2DeviceFormat *format) { - return caps_.isMultiplanar() ? setFormatMultiplane(fmt) : - setFormatSingleplane(fmt); + return caps_.isMultiplanar() ? setFormatMultiplane(format) : + setFormatSingleplane(format); } -int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *fmt) +int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Fmt; - struct v4l2_pix_format *pix = &v4l2Fmt.fmt.pix; + struct v4l2_format v4l2Format; + struct v4l2_pix_format *pix = &v4l2Format.fmt.pix; int ret; - v4l2Fmt.type = bufferType_; - ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Fmt); + v4l2Format.type = bufferType_; + ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format); if (ret) { ret = -errno; LOG(Error) << "Unable to get format: " << strerror(-ret); return ret; } - fmt->width = pix->width; - fmt->height = pix->height; - fmt->fourcc = pix->pixelformat; - fmt->planes = 1; - fmt->planesFmt[0].bpl = pix->bytesperline; - fmt->planesFmt[0].size = pix->sizeimage; + format->width = pix->width; + format->height = pix->height; + format->fourcc = pix->pixelformat; + format->planes = 1; + format->planesFmt[0].bpl = pix->bytesperline; + format->planesFmt[0].size = pix->sizeimage; return 0; } -int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *fmt) +int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Fmt; - struct v4l2_pix_format *pix = &v4l2Fmt.fmt.pix; + struct v4l2_format v4l2Format; + struct v4l2_pix_format *pix = &v4l2Format.fmt.pix; int ret; - v4l2Fmt.type = bufferType_; - pix->width = fmt->width; - pix->height = fmt->height; - pix->pixelformat = fmt->fourcc; + v4l2Format.type = bufferType_; + pix->width = format->width; + pix->height = format->height; + pix->pixelformat = format->fourcc; - ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Fmt); + ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format); if (ret) { ret = -errno; LOG(Error) << "Unable to set format: " << strerror(-ret); @@ -343,51 +343,51 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *fmt) return 0; } -int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *fmt) +int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Fmt; - struct v4l2_pix_format_mplane *pix = &v4l2Fmt.fmt.pix_mp; + struct v4l2_format v4l2Format; + struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp; int ret; - v4l2Fmt.type = bufferType_; - ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Fmt); + v4l2Format.type = bufferType_; + ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format); if (ret) { ret = -errno; LOG(Error) << "Unable to get format: " << strerror(-ret); return ret; } - fmt->width = pix->width; - fmt->height = pix->height; - fmt->fourcc = pix->pixelformat; - fmt->planes = pix->num_planes; + format->width = pix->width; + format->height = pix->height; + format->fourcc = pix->pixelformat; + format->planes = pix->num_planes; - for (unsigned int i = 0; i < fmt->planes; ++i) { - fmt->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline; - fmt->planesFmt[i].size = pix->plane_fmt[i].sizeimage; + for (unsigned int i = 0; i < format->planes; ++i) { + format->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline; + format->planesFmt[i].size = pix->plane_fmt[i].sizeimage; } return 0; } -int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *fmt) +int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Fmt; - struct v4l2_pix_format_mplane *pix = &v4l2Fmt.fmt.pix_mp; + struct v4l2_format v4l2Format; + struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp; int ret; - v4l2Fmt.type = bufferType_; - pix->width = fmt->width; - pix->height = fmt->height; - pix->pixelformat = fmt->fourcc; - pix->num_planes = fmt->planes; + v4l2Format.type = bufferType_; + pix->width = format->width; + pix->height = format->height; + pix->pixelformat = format->fourcc; + pix->num_planes = format->planes; for (unsigned int i = 0; i < pix->num_planes; ++i) { - pix->plane_fmt[i].bytesperline = fmt->planesFmt[i].bpl; - pix->plane_fmt[i].sizeimage = fmt->planesFmt[i].size; + pix->plane_fmt[i].bytesperline = format->planesFmt[i].bpl; + pix->plane_fmt[i].sizeimage = format->planesFmt[i].size; } - ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Fmt); + ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format); if (ret) { ret = -errno; LOG(Error) << "Unable to set format: " << strerror(-ret); From patchwork Fri Feb 1 15:42:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 476 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 20F3660DB5 for ; Fri, 1 Feb 2019 16:42:41 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id D4C531BF219; Fri, 1 Feb 2019 15:42:40 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:45 +0100 Message-Id: <20190201154248.15006-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/7] libcamera: v4l2_device: Rename plane format fields X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:41 -0000 Rename the number of valid plane formats to 'planesCount' and the actual per-plane size information array to 'planes'. Signed-off-by: Jacopo Mondi Acked-by: Laurent Pinchart --- src/libcamera/include/v4l2_device.h | 4 ++-- src/libcamera/v4l2_device.cpp | 29 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h index e65a540..4ff48fb 100644 --- a/src/libcamera/include/v4l2_device.h +++ b/src/libcamera/include/v4l2_device.h @@ -63,8 +63,8 @@ public: struct { uint32_t size; uint32_t bpl; - } planesFmt[3]; - unsigned int planes; + } planes[3]; + unsigned int planesCount; }; class MediaEntity; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 8cf566c..0d4d60f 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -92,7 +92,7 @@ LOG_DEFINE_CATEGORY(V4L2) * * Formats defined as 'single planar' by the V4L2 APIs are represented with * V4L2DeviceFormat instances with a single plane - * (V4L2DeviceFormat::planes = 1). Semi-planar and multiplanar formats use + * (V4L2DeviceFormat::planesCount = 1). Semi-planar and multiplanar formats use * 2 and 3 planes respectively. * * V4L2DeviceFormat defines the exchange format between components that @@ -120,19 +120,18 @@ LOG_DEFINE_CATEGORY(V4L2) */ /** - * \var V4L2DeviceFormat::planesFmt + * \var V4L2DeviceFormat::planes * \brief The per-plane size information * * Images are stored in memory in one or more data planes. Each data plane * has a specific size and line length, which could differ from the image * visible sizes to accommodate line or plane padding data. * - * Only the first V4L2DeviceFormat::planes entries are considered valid. - * + * Only the first \ref planesCount entries are considered valid. */ /** - * \var V4L2DeviceFormat::planes + * \var V4L2DeviceFormat::planesCount * \brief The number of valid data planes */ @@ -315,9 +314,9 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format) format->width = pix->width; format->height = pix->height; format->fourcc = pix->pixelformat; - format->planes = 1; - format->planesFmt[0].bpl = pix->bytesperline; - format->planesFmt[0].size = pix->sizeimage; + format->planesCount = 1; + format->planes[0].bpl = pix->bytesperline; + format->planes[0].size = pix->sizeimage; return 0; } @@ -360,11 +359,11 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format) format->width = pix->width; format->height = pix->height; format->fourcc = pix->pixelformat; - format->planes = pix->num_planes; + format->planesCount = pix->num_planes; - for (unsigned int i = 0; i < format->planes; ++i) { - format->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline; - format->planesFmt[i].size = pix->plane_fmt[i].sizeimage; + for (unsigned int i = 0; i < format->planesCount; ++i) { + format->planes[i].bpl = pix->plane_fmt[i].bytesperline; + format->planes[i].size = pix->plane_fmt[i].sizeimage; } return 0; @@ -380,11 +379,11 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format) pix->width = format->width; pix->height = format->height; pix->pixelformat = format->fourcc; - pix->num_planes = format->planes; + pix->num_planes = format->planesCount; for (unsigned int i = 0; i < pix->num_planes; ++i) { - pix->plane_fmt[i].bytesperline = format->planesFmt[i].bpl; - pix->plane_fmt[i].sizeimage = format->planesFmt[i].size; + pix->plane_fmt[i].bytesperline = format->planes[i].bpl; + pix->plane_fmt[i].sizeimage = format->planes[i].size; } ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format); From patchwork Fri Feb 1 15:42:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 477 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8EB0D60DB5 for ; Fri, 1 Feb 2019 16:42:41 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 3DDA81BF205; Fri, 1 Feb 2019 15:42:41 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:46 +0100 Message-Id: <20190201154248.15006-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/7] libcamera: v4l2_device: Zero-initialize V4L2 format X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:41 -0000 Zero initialize v4l2_format structures used to set and get format on the V4L2 device. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 0d4d60f..b86a629 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -299,7 +299,7 @@ int V4L2Device::setFormat(V4L2DeviceFormat *format) int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Format; + struct v4l2_format v4l2Format = {}; struct v4l2_pix_format *pix = &v4l2Format.fmt.pix; int ret; @@ -323,7 +323,7 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format) int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Format; + struct v4l2_format v4l2Format = {}; struct v4l2_pix_format *pix = &v4l2Format.fmt.pix; int ret; @@ -344,7 +344,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format) int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Format; + struct v4l2_format v4l2Format = {}; struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp; int ret; @@ -371,7 +371,7 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format) int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format) { - struct v4l2_format v4l2Format; + struct v4l2_format v4l2Format = {}; struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp; int ret; From patchwork Fri Feb 1 15:42:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 478 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F282860DB5 for ; Fri, 1 Feb 2019 16:42:41 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id A3DEF1BF20C; Fri, 1 Feb 2019 15:42:41 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:47 +0100 Message-Id: <20190201154248.15006-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/7] libcamera: v4l2_device: Set bytesperline in single plane S_FMT X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:42 -0000 The 'bytesperline' field of 'struct v4l2_pix_format' has to be set for the single planar set format use case. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index b86a629..4d1f76b 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -331,6 +331,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format) pix->width = format->width; pix->height = format->height; pix->pixelformat = format->fourcc; + pix->bytesperline = format->planes[0].bpl; ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format); if (ret) { From patchwork Fri Feb 1 15:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 479 Return-Path: Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BB3660DB5 for ; Fri, 1 Feb 2019 16:42:42 +0100 (CET) X-Originating-IP: 91.183.179.147 Received: from uno.localdomain (unknown [91.183.179.147]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 107D71BF205; Fri, 1 Feb 2019 15:42:41 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Feb 2019 16:42:48 +0100 Message-Id: <20190201154248.15006-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201154248.15006-1-jacopo@jmondi.org> References: <20190201154248.15006-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 7/7] libcamera: v4l2_device: Improve documentation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 15:42:42 -0000 Improve the V4L2DeviceFormat documentation as suggested during patches review. Signed-off-by: Jacopo Mondi --- src/libcamera/v4l2_device.cpp | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 4d1f76b..5ae208f 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -84,48 +84,52 @@ LOG_DEFINE_CATEGORY(V4L2) * \class V4L2DeviceFormat * \brief The V4L2 device image format and sizes * - * Describes the image format and image sizes to be programmed on a V4L2 - * video device. The image format is defined by fourcc code as defined by - * the V4L2 APIs with the V4L2_PIX_FMT_ macros, a visible width and height - * and a variable number of planes (1 to 3) with variable sizes and line - * strides. + * This class describes the image format and image sizes to be programmed + * on a V4L2 video device. The image format is defined by a fourcc code + * as defined by the V4L2 API with the V4L2_PIX_FMT_* macros, a visible + * width and height and one to three planes with configurable line stride + * and a total per-plane size in bytes. * - * Formats defined as 'single planar' by the V4L2 APIs are represented with - * V4L2DeviceFormat instances with a single plane - * (V4L2DeviceFormat::planesCount = 1). Semi-planar and multiplanar formats use - * 2 and 3 planes respectively. + * The V4L2 APIs defines packed, semi-planar and planar image formats. + * Packed formats are stored as a single, contiguous memory area, while + * semi-planar and multi-planar ones use two or three (possibly not contiguous) + * memory regions to store the image components as separate planes. * - * V4L2DeviceFormat defines the exchange format between components that - * receive image configuration requests from applications and a V4L2Device. - * The V4L2Device validates and applies the requested size and format to - * the device driver. + * Packed formats are represented by V4L2DeviceFormat instances with a + * single valid \ref planes array entry (\ref planesCount = 1). + * Non-packed formats allows configuring per plane size and line stride length, + * but only when applied to devices that support the V4L2 multi-planar APIs. + * When a non-packed image format gets applied to a device that only supports + * the V4L2 single-planar APIs, it is not possible to configure per-plane sizes + * as the only valid informations are contained in the first entry of the \ref + * planes array, and apply to the image as a whole. */ /** * \var V4L2DeviceFormat::width - * \brief The image width + * \brief The image width in pixels */ /** * \var V4L2DeviceFormat::height - * \brief The image height + * \brief The image height in pixels */ /** * \var V4L2DeviceFormat::fourcc * \brief The pixel encoding scheme * - * The fourcc code, as defined by the V4L2 APIs with the V4L2_PIX_FMT_ macros, + * The fourcc code, as defined by the V4L2 API with the V4L2_PIX_FMT_* macros, * that identifies the image format pixel encoding scheme. */ /** * \var V4L2DeviceFormat::planes - * \brief The per-plane size information + * \brief The per-plane memory size information * * Images are stored in memory in one or more data planes. Each data plane - * has a specific size and line length, which could differ from the image - * visible sizes to accommodate line or plane padding data. + * has a specific memory size and line length, which could differ from the + * image visible sizes to accommodate line or plane padding data. * * Only the first \ref planesCount entries are considered valid. */