[{"id":1417,"web_url":"https://patchwork.libcamera.org/comment/1417/","msgid":"<20190416224641.GO4822@pendragon.ideasonboard.com>","date":"2019-04-16T22:46:41","subject":"Re: [libcamera-devel] [RFC 03/11] libcamera: media_device: Only\n\tread device information in populate()","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 Sun, Apr 14, 2019 at 03:34:58AM +0200, Niklas Söderlund wrote:\n> There is no reason to reread the MEDIA_IOC_DEVICE_INFO information every\n> time the media device is opened. Move it populate() where it will be\n> read once together the other information about the media device.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/media_device.cpp | 31 ++++++++++++++-----------------\n>  1 file changed, 14 insertions(+), 17 deletions(-)\n> \n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index ecb00a1d5abffe80..54706bb73a7591d5 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -131,9 +131,6 @@ bool MediaDevice::acquire()\n>   * with the device node associated with the media device, the device node must\n>   * be opened.\n>   *\n> - * This function also retrieves media device information from the device node,\n> - * which can be queried through driver().\n\nThis should go to the documentation of the populate() function (in a\nmodified form to integrate nicely with it).\n\n> - *\n>   * If the device is already open the function returns -EBUSY.\n>   *\n>   * \\return 0 on success or a negative error code otherwise\n> @@ -155,20 +152,6 @@ int MediaDevice::open()\n>  \t}\n>  \tfd_ = ret;\n>  \n> -\tstruct media_device_info info = { };\n> -\tret = ioctl(fd_, MEDIA_IOC_DEVICE_INFO, &info);\n> -\tif (ret) {\n> -\t\tret = -errno;\n> -\t\tLOG(MediaDevice, Error)\n> -\t\t\t<< \"Failed to get media device info \"\n> -\t\t\t<< \": \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\n> -\tdriver_ = info.driver;\n> -\tmodel_ = info.model;\n> -\tversion_ = info.media_version;\n> -\n>  \treturn 0;\n>  }\n>  \n> @@ -224,6 +207,20 @@ int MediaDevice::populate()\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> +\tstruct media_device_info info = {};\n> +\tret = ioctl(fd_, MEDIA_IOC_DEVICE_INFO, &info);\n> +\tif (ret) {\n> +\t\tret = -errno;\n> +\t\tLOG(MediaDevice, Error)\n> +\t\t\t<< \"Failed to get media device info \"\n\nWhile at it you could merge the \": \" wit the previous line (and remove\nthe space after \"info\").\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\t<< \": \" << strerror(-ret);\n> +\t\tgoto err_out;\n> +\t}\n> +\n> +\tdriver_ = info.driver;\n> +\tmodel_ = info.model;\n> +\tversion_ = info.media_version;\n> +\n>  \t/*\n>  \t * Keep calling G_TOPOLOGY until the version number stays stable.\n>  \t */","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 9C10760004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 00:46:50 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1225AE2;\n\tWed, 17 Apr 2019 00:46:50 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555454810;\n\tbh=b8RA4sP93IwLokXThivk0OrjFxQy9zz/qfyRGks1QxY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=M9tZVxKMnlbMs6wkn2AsFlB8srHqIy5GAVTL4ldzoKS/LIwL2RwIZ8dSpS/T8+F38\n\tWldpbtB3OPtd0jHfmTzJ4cWn0cIa/FYL7vb+sOZhEey0Dwab5sb7kwWiE5mqRPz/tF\n\trgJoX1IQFeaO/cuFQ/LI4EGtSTLAia6NZJwiwkUI=","Date":"Wed, 17 Apr 2019 01:46:41 +0300","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":"<20190416224641.GO4822@pendragon.ideasonboard.com>","References":"<20190414013506.10515-1-niklas.soderlund@ragnatech.se>\n\t<20190414013506.10515-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":"<20190414013506.10515-4-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [RFC 03/11] libcamera: media_device: Only\n\tread device information in populate()","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":"Tue, 16 Apr 2019 22:46:50 -0000"}}]