[{"id":584,"web_url":"https://patchwork.libcamera.org/comment/584/","msgid":"<20190125110716.GE2934@pendragon.ideasonboard.com>","date":"2019-01-25T11:07:16","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: uvcvideo:\n\tcreate a V4L2Device for the default video entity","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Wed, Jan 23, 2019 at 04:03:51PM +0100, Niklas Söderlund wrote:\n> Add a V4L2Device for the default video entity in the media graph. The\n> UVC pipeline needs to search for the entity marked with the\n> MEDIA_ENT_FL_DEFAULT flag as the entity names in the media graph varies\n> depending on which device is used.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/pipeline/uvcvideo.cpp | 26 +++++++++++++++++++++++++-\n>  1 file changed, 25 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index b56ee9881239abdc..f853105f50a958a3 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -12,6 +12,7 @@\n>  #include \"log.h\"\n>  #include \"media_device.h\"\n>  #include \"pipeline_handler.h\"\n> +#include \"v4l2_device.h\"\n>  \n>  namespace libcamera {\n>  \n> @@ -31,15 +32,21 @@ public:\n>  \n>  private:\n>  \tMediaDevice *dev_;\n> +\tV4L2Device *v4l2dev_;\n\nNitpicking, how about renaming dev_ to media_ and naming v4l2dev_\neither v4l2_ or video_ ?\n\n>  };\n>  \n>  PipelineHandlerUVC::PipelineHandlerUVC()\n> -\t: dev_(nullptr)\n> +\t: dev_(nullptr), v4l2dev_(nullptr)\n>  {\n>  }\n>  \n>  PipelineHandlerUVC::~PipelineHandlerUVC()\n>  {\n> +\tif (v4l2dev_) {\n> +\t\tv4l2dev_->close();\n> +\t\tdelete v4l2dev_;\n\nDoesn't the V4L2Device destructor close the device already ?\n\n> +\t}\n> +\n>  \tif (dev_)\n>  \t\tdev_->release();\n>  }\n> @@ -83,6 +90,23 @@ bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumera\n>  \n>  \tdev_->acquire();\n>  \n> +\tfor (MediaEntity *entity : dev_->entities()) {\n> +\t\tif (!(entity->flags() & MEDIA_ENT_FL_DEFAULT))\n> +\t\t\tcontinue;\n> +\n> +\t\tv4l2dev_ = new V4L2Device(*entity);\n> +\n> +\t\tif (v4l2dev_->open())\n> +\t\t\tdelete v4l2dev_;\n\nThe PipelineHandlerUVC destructor will delete v4l2dev_, there's no need\nto do it manually here.\n\nApart from this,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\t\tbreak;\n> +\t}\n> +\n> +\tif (!v4l2dev_) {\n> +\t\tdev_->release();\n> +\t\treturn false;\n> +\t}\n> +\n>  \tstd::shared_ptr<Camera> camera = Camera::create(this, dev_->model());\n>  \tregisterCamera(manager, std::move(camera));\n>","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 A4D5D60B1D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 12:07:17 +0100 (CET)","from pendragon.ideasonboard.com (unknown\n\t[IPv6:2a02:a03f:4499:2700:1060:1d4c:d6a:8e80])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 35A7A325;\n\tFri, 25 Jan 2019 12:07:17 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548414437;\n\tbh=d6C/3BzpiT7brR6WcUmCs8NlahjH8pcu39imNV9U5zo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ibiWjs/EzFGQ0hLLp3uhQrFk/tXgVXFJcG7gK9UJe6KWo46J3iD2K0u/JX+tN+QfN\n\tXcx+4SDSlaSSADu9O4N/51rmrievHXgyH3oSq+OjGyyGI7pSURDq3XQuz0n5t1ILlE\n\tp9II2qkUXNqMdkMqF8KNMffttCLxQOBEZnDXnxcg=","Date":"Fri, 25 Jan 2019 13:07:16 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190125110716.GE2934@pendragon.ideasonboard.com>","References":"<20190123150351.8307-1-niklas.soderlund@ragnatech.se>\n\t<20190123150351.8307-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190123150351.8307-3-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: uvcvideo:\n\tcreate a V4L2Device for the default video entity","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, 25 Jan 2019 11:07:17 -0000"}}]