[{"id":594,"web_url":"https://patchwork.libcamera.org/comment/594/","msgid":"<20190125144956.GD4320@pendragon.ideasonboard.com>","date":"2019-01-25T14:49:56","subject":"Re: [libcamera-devel] [PATCH v2 3/3] 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 Fri, Jan 25, 2019 at 03:39: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 | 20 +++++++++++++++++++-\n>  1 file changed, 19 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 1a445edfa8df777c..e3a475704c080e90 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -11,6 +11,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> @@ -26,15 +27,20 @@ public:\n>  \n>  private:\n>  \tstd::shared_ptr<MediaDevice> media_;\n> +\n\nI wouldn't have added a blank line, but it's up to you :-)\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\tV4L2Device *video_;\n>  };\n>  \n>  PipelineHandlerUVC::PipelineHandlerUVC(CameraManager *manager)\n> -\t: PipelineHandler(manager), media_(nullptr)\n> +\t: PipelineHandler(manager), media_(nullptr), video_(nullptr)\n>  {\n>  }\n>  \n>  PipelineHandlerUVC::~PipelineHandlerUVC()\n>  {\n> +\tif (video_)\n> +\t\tdelete video_;\n> +\n>  \tif (media_)\n>  \t\tmedia_->release();\n>  }\n> @@ -50,6 +56,18 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>  \n>  \tmedia_->acquire();\n>  \n> +\tfor (MediaEntity *entity : media_->entities()) {\n> +\t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n> +\t\t\tvideo_ = new V4L2Device(*entity);\n> +\t\t\tbreak;\n> +\t\t}\n> +\t}\n> +\n> +\tif (!video_ || video_->open()) {\n> +\t\tmedia_->release();\n> +\t\treturn false;\n> +\t}\n> +\n>  \tstd::shared_ptr<Camera> camera = Camera::create(this, media_->model());\n>  \tregisterCamera(std::move(camera));\n>  \thotplugMediaDevice(media_.get());","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 F102560B1D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 15:49:56 +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 94C64325;\n\tFri, 25 Jan 2019 15:49:56 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548427796;\n\tbh=JHJfDADsbJbo9mLMT7b9BwR3O/QiNF1uWmqfTXINl+Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=T9jp/nZDgkEaetzbS87ZlhbdBB9OOMVOalVQId/cS17VJpzXWYaXgAu4Giwz7KuWm\n\t0eTNPhi5e1pitxsEY3thSFEgvBqKM138lLZVyAlQtKeRaPvWr+i5rBtCPZ9COcxHzq\n\t+Ym9HwlSINY1ye5Jh5UQO/njhW9un/naj9FSQMTQ=","Date":"Fri, 25 Jan 2019 16:49:56 +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":"<20190125144956.GD4320@pendragon.ideasonboard.com>","References":"<20190125143951.27992-1-niklas.soderlund@ragnatech.se>\n\t<20190125143951.27992-4-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":"<20190125143951.27992-4-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 3/3] 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 14:49:57 -0000"}}]