[{"id":1164,"web_url":"https://patchwork.libcamera.org/comment/1164/","msgid":"<20190401220407.GN4787@pendragon.ideasonboard.com>","date":"2019-04-01T22:04:07","subject":"Re: [libcamera-devel] [PATCH v5 07/19] libcamera: v4l2_subdevice:\n\tCreate device from entity name","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 Tue, Mar 26, 2019 at 09:38:50AM +0100, Jacopo Mondi wrote:\n> Add a static method to V4L2Subdevice class to create a V4L2Subdevice\n> instance from a media entity name.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_subdevice.h |  5 +++++\n>  src/libcamera/v4l2_subdevice.cpp       | 22 ++++++++++++++++++++++\n>  2 files changed, 27 insertions(+)\n> \n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index f42cccabda94..0067109931d1 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -18,6 +18,8 @@\n>  \n>  namespace libcamera {\n>  \n> +class MediaDevice;\n> +\n>  struct V4L2SubdeviceFormat {\n>  \tuint32_t mbus_code;\n>  \tuint32_t width;\n> @@ -29,6 +31,9 @@ struct V4L2SubdeviceFormat {\n>  class V4L2Subdevice : protected Loggable\n>  {\n>  public:\n> +\tstatic V4L2Subdevice *fromEntityName(const MediaDevice *media,\n> +\t\t\t\t\t     const std::string &name);\n> +\nI would move this down, as static methods are usually put after the\nnon-static ones.\n\nI would also rename the name argument to entity (I forgot to mention\nthis for patch 06/19, it applies there too).\n\nI wonder if there would be an advantage in turning this into a\nconstructor for the V4L2Subdevice class, but in any case that could be\ndone later, so, with the above and below issues fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \texplicit V4L2Subdevice(const MediaEntity *entity);\n>  \tV4L2Subdevice(const V4L2Subdevice &) = delete;\n>  \tV4L2Subdevice &operator=(const V4L2Subdevice &) = delete;\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 10925f9fe497..e28857c9aeb1 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -16,6 +16,7 @@\n>  \n>  #include \"geometry.h\"\n>  #include \"log.h\"\n> +#include \"media_device.h\"\n>  #include \"media_object.h\"\n>  #include \"v4l2_subdevice.h\"\n>  \n> @@ -101,6 +102,27 @@ const std::string V4L2SubdeviceFormat::toString() const\n>   * any device left open will be closed, and any resources released.\n>   */\n>  \n> +/**\n> + * \\brief Create a new video subdevice instance from entity with \\a name in\n> + * media device \\a media\n> + * \\param[in] media The media device where the entity is registered\n> + * \\param[in] name The media entity name\n> + *\n> + * Releasing memory of the newly created instance is responsibility of the\n\ns/Releasing memory of the/Deleting the/\ns/is responsibility/is the responsibility/\n\n(applies to 06/19 too)\n\n> + * caller of this function.\n> + *\n> + * \\return A newly created V4L2Subdevice on success, nullptr otherwise\n> + */\n> +V4L2Subdevice *V4L2Subdevice::fromEntityName(const MediaDevice *media,\n> +\t\t\t\t\t     const std::string &name)\n> +{\n> +\tMediaEntity *entity = media->getEntityByName(name);\n> +\tif (!entity)\n> +\t\treturn nullptr;\n> +\n> +\treturn new V4L2Subdevice(entity);\n> +}\n> +\n>  /**\n>   * \\brief Create a V4L2 subdevice from a MediaEntity using its device node\n>   * path","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 88243610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 00:04:18 +0200 (CEST)","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 DD858542;\n\tTue,  2 Apr 2019 00:04:17 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554156258;\n\tbh=AB0caFCNHGZKUBpuKjVWt7RBuIJciNM49srKaFv/1RI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=KLosxFrwZZnbivCkK8FO0rdtwo8xh4GgUfGRw4hY4+wzeWKA+OzKIpudjE86yMdy/\n\ttp1cK4Qpzf+sq0BohUfy3I7Gi7PQQQxpZ5EH2lymZFtUCMy6V6iPW+i4PLM/AAqiQ1\n\tOJOg02j8D7Dgz1og3ohPPo3i6vSBAx8xxOKThpUY=","Date":"Tue, 2 Apr 2019 01:04:07 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190401220407.GN4787@pendragon.ideasonboard.com>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-8-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190326083902.26121-8-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v5 07/19] libcamera: v4l2_subdevice:\n\tCreate device from entity name","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":"Mon, 01 Apr 2019 22:04:18 -0000"}}]