[{"id":993,"web_url":"https://patchwork.libcamera.org/comment/993/","msgid":"<20190301125800.GH26239@pendragon.ideasonboard.com>","date":"2019-03-01T12:58:00","subject":"Re: [libcamera-devel] [PATCH v6 4/5] libcamera: v4l2_device: Add\n\tsupport for META_CAPTURE devices","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Fri, Mar 01, 2019 at 12:51:38PM +0100, Jacopo Mondi wrote:\n> Add support for devices that provide video meta-data to v4l2_device.cpp\n> and re-arrange bufferType handling in open() method.\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/include/v4l2_device.h | 26 ++++++++++-\n>  src/libcamera/v4l2_device.cpp       | 70 +++++++++++++++++++++--------\n>  2 files changed, 76 insertions(+), 20 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 622c9722c992..5c379fac66dc 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -51,13 +51,37 @@ struct V4L2Capability final : v4l2_capability {\n>  \tbool isCapture() const\n>  \t{\n>  \t\treturn device_caps() & (V4L2_CAP_VIDEO_CAPTURE |\n> -\t\t\t\t\tV4L2_CAP_VIDEO_CAPTURE_MPLANE);\n> +\t\t\t\t\tV4L2_CAP_VIDEO_CAPTURE_MPLANE |\n> +\t\t\t\t\tV4L2_CAP_META_CAPTURE);\n>  \t}\n>  \tbool isOutput() const\n>  \t{\n>  \t\treturn device_caps() & (V4L2_CAP_VIDEO_OUTPUT |\n>  \t\t\t\t\tV4L2_CAP_VIDEO_OUTPUT_MPLANE);\n>  \t}\n> +\tbool isVideo() const\n> +\t{\n> +\t\treturn device_caps() & (V4L2_CAP_VIDEO_CAPTURE |\n> +\t\t\t\t\tV4L2_CAP_VIDEO_CAPTURE_MPLANE |\n> +\t\t\t\t\tV4L2_CAP_VIDEO_OUTPUT |\n> +\t\t\t\t\tV4L2_CAP_VIDEO_OUTPUT_MPLANE);\n> +\t}\n> +\tbool isMeta() const\n> +\t{\n> +\t\treturn device_caps() & V4L2_CAP_META_CAPTURE;\n> +\t}\n> +\tbool isVideoCapture() const\n> +\t{\n> +\t\treturn isVideo() && isCapture();\n> +\t}\n> +\tbool isVideoOutput() const\n> +\t{\n> +\t\treturn isVideo() && isOutput();\n> +\t}\n> +\tbool isMetaCapture() const\n> +\t{\n> +\t\treturn isMeta() && isCapture();\n> +\t}\n>  \tbool hasStreaming() const\n>  \t{\n>  \t\treturn device_caps() & V4L2_CAP_STREAMING;\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 4c670185bb7c..b19cf9f78029 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -69,14 +69,47 @@ LOG_DEFINE_CATEGORY(V4L2)\n>  \n>  /**\n>   * \\fn bool V4L2Capability::isCapture()\n> - * \\brief Identify if the device is capable of capturing video\n> - * \\return True if the device can capture video frames\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> - * \\brief Identify if the device is capable of outputting video\n> - * \\return True if the device can output video frames\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> + * \\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> + * \\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> + *\n> + * \\return True if the device can capture or output image meta-data\n> + */\n> +\n> +/**\n> + * \\fn bool 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> + * \\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> + * \\brief Identify if the device captures image meta-data\n> + * \\return True if the device can capture image meta-data\n>   */\n>  \n>  /**\n> @@ -280,33 +313,32 @@ int V4L2Device::open()\n>  \t\t<< \"Opened device \" << caps_.bus_info() << \": \"\n>  \t\t<< caps_.driver() << \": \" << caps_.card();\n>  \n> -\tif (!caps_.isCapture() && !caps_.isOutput()) {\n> -\t\tLOG(V4L2, Debug) << \"Device is not a supported type\";\n> -\t\treturn -EINVAL;\n> -\t}\n> -\n>  \tif (!caps_.hasStreaming()) {\n>  \t\tLOG(V4L2, Error) << \"Device does not support streaming I/O\";\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> -\tif (caps_.isCapture())\n> +\t/*\n> +\t * Set buffer type and wait for read notifications on CAPTURE devices\n> +\t * (POLLIN), and write notifications for OUTPUT devices (POLLOUT).\n> +\t */\n> +\tif (caps_.isVideoCapture()) {\n> +\t\tfdEvent_ = new EventNotifier(fd_, EventNotifier::Read);\n>  \t\tbufferType_ = caps_.isMultiplanar()\n>  \t\t\t    ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE\n>  \t\t\t    : V4L2_BUF_TYPE_VIDEO_CAPTURE;\n> -\telse\n> +\t} else if (caps_.isVideoOutput()) {\n> +\t\tfdEvent_ = new EventNotifier(fd_, EventNotifier::Write);\n>  \t\tbufferType_ = caps_.isMultiplanar()\n>  \t\t\t    ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE\n>  \t\t\t    : V4L2_BUF_TYPE_VIDEO_OUTPUT;\n> -\n> -\t/*\n> -\t *  We wait for Read notifications on CAPTURE devices (POLLIN), and\n> -\t *  Write notifications for OUTPUT devices (POLLOUT).\n> -\t */\n> -\tif (caps_.isCapture())\n> +\t} else if (caps_.isMetaCapture()) {\n>  \t\tfdEvent_ = new EventNotifier(fd_, EventNotifier::Read);\n> -\telse\n> -\t\tfdEvent_ = new EventNotifier(fd_, EventNotifier::Write);\n> +\t\tbufferType_ = V4L2_BUF_TYPE_META_CAPTURE;\n> +\t} else {\n> +\t\tLOG(V4L2, Debug) << \"Device is not a supported type\";\n> +\t\treturn -EINVAL;\n> +\t}\n>  \n>  \tfdEvent_->activated.connect(this, &V4L2Device::bufferAvailable);\n>  \tfdEvent_->setEnabled(false);","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D681610BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Mar 2019 13:58:06 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EC82A49;\n\tFri,  1 Mar 2019 13:58:05 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551445086;\n\tbh=vnj1imiVyJWBO0LYqOy70xZbICWgOMCdlrJgaPoPdNg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YqYhTEycZ1TR/NXTr7/8hdgHH2him8WmymVMKejCg3GsulVmQWW1Lr4/zjKNIV3yc\n\tSAaDMThAbC8fHF2PjEroWxyDA7Vct8LcEjJcGp0kPhncAV/7NDIzHkiVQocGMzdtP7\n\towVPA1JvJ8finafT90OF8IXOTx3AED+bljAZgULA=","Date":"Fri, 1 Mar 2019 14:58:00 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190301125800.GH26239@pendragon.ideasonboard.com>","References":"<20190301115139.11060-1-jacopo@jmondi.org>\n\t<20190301115139.11060-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190301115139.11060-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v6 4/5] libcamera: v4l2_device: Add\n\tsupport for META_CAPTURE devices","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 12:58:06 -0000"}}]