{"id":694,"url":"https://patchwork.libcamera.org/api/1.1/patches/694/?format=json","web_url":"https://patchwork.libcamera.org/patch/694/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190301115139.11060-6-jacopo@jmondi.org>","date":"2019-03-01T11:51:39","name":"[libcamera-devel,v6,5/5] libcamera: v4l2_device: Cosmetic update","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0281c5165e017d04c923eae3378f3bdebf0eeab1","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/694/mbox/","series":[{"id":200,"url":"https://patchwork.libcamera.org/api/1.1/series/200/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=200","date":"2019-03-01T11:51:34","name":"v4l2_(sub)dev: improvements and tests","version":6,"mbox":"https://patchwork.libcamera.org/series/200/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/694/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/694/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AA2CE61114\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Mar 2019 12:52:47 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2CD14C000D;\n\tFri,  1 Mar 2019 11:52:45 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  1 Mar 2019 12:51:39 +0100","Message-Id":"<20190301115139.11060-6-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190301115139.11060-1-jacopo@jmondi.org>","References":"<20190301115139.11060-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 5/5] libcamera: v4l2_device: Cosmetic\n\tupdate","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 01 Mar 2019 11:52:47 -0000"},"content":"Cosmetic update of V4L2Device class:\n- remove the return type from Doxygen documentation of inline functions\n- re-sort methods implementation to reflect the declaration order in the\nclass definition\n\nCosmetic update, no functional changes intended.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/v4l2_device.cpp | 412 +++++++++++++++++-----------------\n 1 file changed, 206 insertions(+), 206 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex b19cf9f78029..5f2cf4846c65 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -37,56 +37,56 @@ LOG_DEFINE_CATEGORY(V4L2)\n  */\n \n /**\n- * \\fn const char *V4L2Capability::driver()\n+ * \\fn V4L2Capability::driver()\n  * \\brief Retrieve the driver module name\n  * \\return The string containing the name of the driver module\n  */\n \n /**\n- * \\fn const char *V4L2Capability::card()\n+ * \\fn V4L2Capability::card()\n  * \\brief Retrieve the device card name\n  * \\return The string containing the device name\n  */\n \n /**\n- * \\fn const char *V4L2Capability::bus_info()\n+ * \\fn V4L2Capability::bus_info()\n  * \\brief Retrieve the location of the device in the system\n  * \\return The string containing the device location\n  */\n \n /**\n- * \\fn unsigned int V4L2Capability::device_caps()\n+ * \\fn V4L2Capability::device_caps()\n  * \\brief Retrieve the capabilities of the device\n  * \\return The device specific capabilities if V4L2_CAP_DEVICE_CAPS is set or\n  * \t   driver capabilities otherwise\n  */\n \n /**\n- * \\fn bool V4L2Capability::isMultiplanar()\n+ * \\fn V4L2Capability::isMultiplanar()\n  * \\brief Identify if the device implements the V4L2 multiplanar APIs\n  * \\return True if the device supports multiplanar APIs\n  */\n \n /**\n- * \\fn bool V4L2Capability::isCapture()\n+ * \\fn V4L2Capability::isCapture()\n  * \\brief Identify if the device captures data\n  * \\return True if the device can capture data\n  */\n \n /**\n- * \\fn bool V4L2Capability::isOutput()\n+ * \\fn V4L2Capability::isOutput()\n  * \\brief Identify if the device outputs data\n  * \\return True if the device can output data\n  */\n \n /**\n- * \\fn bool V4L2Capability::isVideo()\n+ * \\fn V4L2Capability::isVideo()\n  * \\brief Identify if the device captures or outputs images\n  * \\return True if the device can capture or output images\n  */\n \n /**\n- * \\fn bool V4L2Capability::isMeta()\n+ * \\fn V4L2Capability::isMeta()\n  * \\brief Identify if the device captures or outputs image meta-data\n  *\n  * \\todo Add support for META_CAPTURE introduced in Linux v5.0\n@@ -95,25 +95,25 @@ LOG_DEFINE_CATEGORY(V4L2)\n  */\n \n /**\n- * \\fn bool V4L2Capability::isVideoCapture()\n+ * \\fn V4L2Capability::isVideoCapture()\n  * \\brief Identify if the device captures images\n  * \\return True if the device can capture images\n  */\n \n /**\n- * \\fn bool V4L2Capability::isVideoOutput()\n+ * \\fn V4L2Capability::isVideoOutput()\n  * \\brief Identify if the device outputs images\n  * \\return True if the device can output images\n  */\n \n /**\n- * \\fn bool V4L2Capability::isMetaCapture()\n+ * \\fn V4L2Capability::isMetaCapture()\n  * \\brief Identify if the device captures image meta-data\n  * \\return True if the device can capture image meta-data\n  */\n \n /**\n- * \\fn bool V4L2Capability::hasStreaming()\n+ * \\fn V4L2Capability::hasStreaming()\n  * \\brief Determine if the device can perform Streaming I/O\n  * \\return True if the device provides Streaming I/O IOCTLs\n  */\n@@ -371,19 +371,19 @@ void V4L2Device::close()\n }\n \n /**\n- * \\fn const char *V4L2Device::driverName()\n+ * \\fn V4L2Device::driverName()\n  * \\brief Retrieve the name of the V4L2 device driver\n  * \\return The string containing the driver name\n  */\n \n /**\n- * \\fn const char *V4L2Device::deviceName()\n+ * \\fn V4L2Device::deviceName()\n  * \\brief Retrieve the name of the V4L2 device\n  * \\return The string containing the device name\n  */\n \n /**\n- * \\fn const char *V4L2Device::busName()\n+ * \\fn V4L2Device::busName()\n  * \\brief Retrieve the location of the device in the system\n  * \\return The string containing the device location\n  */\n@@ -394,11 +394,6 @@ void V4L2Device::close()\n  * \\return The video device device node path\n  */\n \n-std::string V4L2Device::logPrefix() const\n-{\n-\treturn deviceNode_;\n-}\n-\n /**\n  * \\brief Retrieve the image format set on the V4L2 device\n  * \\param[out] format The image format applied on the device\n@@ -426,155 +421,6 @@ int V4L2Device::setFormat(V4L2DeviceFormat *format)\n \t\t\t\t       setFormatSingleplane(format);\n }\n \n-int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n-{\n-\tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n-\tint ret;\n-\n-\tv4l2Format.type = bufferType_;\n-\tret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);\n-\tif (ret) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error) << \"Unable to get format: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n-\tformat->planesCount = 1;\n-\tformat->planes[0].bpl = pix->bytesperline;\n-\tformat->planes[0].size = pix->sizeimage;\n-\n-\treturn 0;\n-}\n-\n-int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n-{\n-\tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n-\tint ret;\n-\n-\tv4l2Format.type = bufferType_;\n-\tpix->width = format->width;\n-\tpix->height = format->height;\n-\tpix->pixelformat = format->fourcc;\n-\tpix->bytesperline = format->planes[0].bpl;\n-\tpix->field = V4L2_FIELD_NONE;\n-\n-\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n-\tif (ret) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\t/*\n-\t * Return to caller the format actually applied on the device,\n-\t * which might differ from the requested one.\n-\t */\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n-\tformat->planesCount = 1;\n-\tformat->planes[0].bpl = pix->bytesperline;\n-\tformat->planes[0].size = pix->sizeimage;\n-\n-\treturn 0;\n-}\n-\n-int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)\n-{\n-\tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n-\tint ret;\n-\n-\tv4l2Format.type = bufferType_;\n-\tret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);\n-\tif (ret) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error) << \"Unable to get format: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n-\tformat->planesCount = pix->num_planes;\n-\n-\tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n-\t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n-\t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n-{\n-\tstruct v4l2_format v4l2Format = {};\n-\tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n-\tint ret;\n-\n-\tv4l2Format.type = bufferType_;\n-\tpix->width = format->width;\n-\tpix->height = format->height;\n-\tpix->pixelformat = format->fourcc;\n-\tpix->num_planes = format->planesCount;\n-\tpix->field = V4L2_FIELD_NONE;\n-\n-\tfor (unsigned int i = 0; i < pix->num_planes; ++i) {\n-\t\tpix->plane_fmt[i].bytesperline = format->planes[i].bpl;\n-\t\tpix->plane_fmt[i].sizeimage = format->planes[i].size;\n-\t}\n-\n-\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n-\tif (ret) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\t/*\n-\t * Return to caller the format actually applied on the device,\n-\t * which might differ from the requested one.\n-\t */\n-\tformat->width = pix->width;\n-\tformat->height = pix->height;\n-\tformat->fourcc = pix->pixelformat;\n-\tformat->planesCount = pix->num_planes;\n-\tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n-\t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n-\t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-int V4L2Device::requestBuffers(unsigned int count)\n-{\n-\tstruct v4l2_requestbuffers rb = {};\n-\tint ret;\n-\n-\trb.count = count;\n-\trb.type = bufferType_;\n-\trb.memory = memoryType_;\n-\n-\tret = ioctl(fd_, VIDIOC_REQBUFS, &rb);\n-\tif (ret < 0) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to request \" << count << \" buffers: \"\n-\t\t\t<< strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\tLOG(V4L2, Debug) << rb.count << \" buffers requested.\";\n-\n-\treturn rb.count;\n-}\n-\n /**\n  * \\brief Request buffers to be allocated from the device and stored in the\n  *  buffer pool provided.\n@@ -649,37 +495,6 @@ int V4L2Device::exportBuffers(BufferPool *pool)\n \treturn 0;\n }\n \n-int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,\n-\t\t\t    unsigned int length)\n-{\n-\tstruct v4l2_exportbuffer expbuf = {};\n-\tint ret;\n-\n-\tLOG(V4L2, Debug)\n-\t\t<< \"Buffer \" << buffer->index()\n-\t\t<< \" plane \" << planeIndex\n-\t\t<< \": length=\" << length;\n-\n-\texpbuf.type = bufferType_;\n-\texpbuf.index = buffer->index();\n-\texpbuf.plane = planeIndex;\n-\texpbuf.flags = O_RDWR;\n-\n-\tret = ioctl(fd_, VIDIOC_EXPBUF, &expbuf);\n-\tif (ret < 0) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Failed to export buffer: \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\tbuffer->planes().emplace_back();\n-\tPlane &plane = buffer->planes().back();\n-\tplane.setDmabuf(expbuf.fd, length);\n-\n-\treturn 0;\n-}\n-\n /**\n  * \\brief Import the externally allocated \\a pool of buffers\n  * \\param[in] pool BufferPool of buffers to import\n@@ -790,6 +605,11 @@ int V4L2Device::queueBuffer(Buffer *buffer)\n \treturn 0;\n }\n \n+/**\n+ * \\var V4L2Device::bufferReady\n+ * \\brief A Signal emitted when a buffer completes\n+ */\n+\n /**\n  * \\brief Dequeue the next available buffer from the device\n  *\n@@ -860,11 +680,6 @@ void V4L2Device::bufferAvailable(EventNotifier *notifier)\n \tbuffer->completed.emit(buffer);\n }\n \n-/**\n- * \\var V4L2Device::bufferReady\n- * \\brief A Signal emitted when a buffer completes\n- */\n-\n /**\n  * \\brief Start the video stream\n  *\n@@ -910,4 +725,189 @@ int V4L2Device::streamOff()\n \treturn 0;\n }\n \n+std::string V4L2Device::logPrefix() const\n+{\n+\treturn deviceNode_;\n+}\n+\n+int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to get format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tformat->width = pix->width;\n+\tformat->height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->bytesperline;\n+\tformat->planes[0].size = pix->sizeimage;\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->width = format->width;\n+\tpix->height = format->height;\n+\tpix->pixelformat = format->fourcc;\n+\tpix->bytesperline = format->planes[0].bpl;\n+\tpix->field = V4L2_FIELD_NONE;\n+\n+\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->width = pix->width;\n+\tformat->height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->bytesperline;\n+\tformat->planes[0].size = pix->sizeimage;\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to get format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tformat->width = pix->width;\n+\tformat->height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = pix->num_planes;\n+\n+\tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n+\t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n+\t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->width = format->width;\n+\tpix->height = format->height;\n+\tpix->pixelformat = format->fourcc;\n+\tpix->num_planes = format->planesCount;\n+\tpix->field = V4L2_FIELD_NONE;\n+\n+\tfor (unsigned int i = 0; i < pix->num_planes; ++i) {\n+\t\tpix->plane_fmt[i].bytesperline = format->planes[i].bpl;\n+\t\tpix->plane_fmt[i].sizeimage = format->planes[i].size;\n+\t}\n+\n+\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->width = pix->width;\n+\tformat->height = pix->height;\n+\tformat->fourcc = pix->pixelformat;\n+\tformat->planesCount = pix->num_planes;\n+\tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n+\t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n+\t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int V4L2Device::requestBuffers(unsigned int count)\n+{\n+\tstruct v4l2_requestbuffers rb = {};\n+\tint ret;\n+\n+\trb.count = count;\n+\trb.type = bufferType_;\n+\trb.memory = memoryType_;\n+\n+\tret = ioctl(fd_, VIDIOC_REQBUFS, &rb);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to request \" << count << \" buffers: \"\n+\t\t\t<< strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tLOG(V4L2, Debug) << rb.count << \" buffers requested.\";\n+\n+\treturn rb.count;\n+}\n+\n+int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex,\n+\t\t\t    unsigned int length)\n+{\n+\tstruct v4l2_exportbuffer expbuf = {};\n+\tint ret;\n+\n+\tLOG(V4L2, Debug)\n+\t\t<< \"Buffer \" << buffer->index()\n+\t\t<< \" plane \" << planeIndex\n+\t\t<< \": length=\" << length;\n+\n+\texpbuf.type = bufferType_;\n+\texpbuf.index = buffer->index();\n+\texpbuf.plane = planeIndex;\n+\texpbuf.flags = O_RDWR;\n+\n+\tret = ioctl(fd_, VIDIOC_EXPBUF, &expbuf);\n+\tif (ret < 0) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Failed to export buffer: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tbuffer->planes().emplace_back();\n+\tPlane &plane = buffer->planes().back();\n+\tplane.setDmabuf(expbuf.fd, length);\n+\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v6","5/5"]}