[{"id":1541,"web_url":"https://patchwork.libcamera.org/comment/1541/","msgid":"<9c2185fa-78d8-f9b3-878c-27eb1a81c691@ideasonboard.com>","date":"2019-04-30T10:37:25","subject":"Re: [libcamera-devel] [PATCH 03/11] libcamera: media_device: Only\n\tread device information in populate()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Niklas,\n\nOn 29/04/2019 20:17, 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\nThis seems reasonable to me.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/media_device.cpp | 51 +++++++++++++++-------------------\n>  1 file changed, 22 insertions(+), 29 deletions(-)\n> \n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index 4b3b8f1fa3e6aaad..416a0d0c207ea72d 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -126,18 +126,11 @@ bool MediaDevice::acquire()\n>   */\n>  \n>  /**\n> - * \\brief Open a media device and retrieve device information\n> - *\n> - * Before populating the media graph or performing any operation that interact\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> - *\n> - * If the device is already open the function returns -EBUSY.\n> + * \\brief Open the media device\n>   *\n>   * \\return 0 on success or a negative error code otherwise\n> + * \\retval -EBUSY Media device already open\n> + * \\sa close()\n>   */\n>  int MediaDevice::open()\n>  {\n> @@ -156,20 +149,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> @@ -196,12 +175,13 @@ void MediaDevice::close()\n>  }\n>  \n>  /**\n> - * \\brief Populate the media graph with media objects\n> + * \\brief Populate the MediaDevice with device information and media objects\n>   *\n> - * This function enumerates all media objects in the media device graph and\n> - * creates their MediaObject representations. All entities, pads and links are\n> - * stored as MediaEntity, MediaPad and MediaLink respectively, with cross-\n> - * references between objects. Interfaces are not processed.\n> + * This function retrieves the media device information and enumerates all\n> + * media objects in the media device graph and creates their MediaObject\n> + * representations. All entities, pads and links are stored as MediaEntity,\n> + * MediaPad and MediaLink respectively, with cross-references between objects.\n> + * Interfaces are not processed.\n>   *\n>   * Entities are stored in a separate list in the MediaDevice to ease lookup,\n>   * while pads are accessible from the entity they belong to and links from the\n> @@ -225,6 +205,19 @@ 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 \" << strerror(-ret);\n> +\t\tgoto done;\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 */\n>","headers":{"Return-Path":"<kieran.bingham@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 E894E600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Apr 2019 12:37:28 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E52831D;\n\tTue, 30 Apr 2019 12:37:28 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556620648;\n\tbh=KE5PpQiNlrHkzpOYkQaBIhyzT8S+VRFNOlriNO5lvBs=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=dUebZKny7rwlFPXVp6COmdxnUluvR3XI46p5HJqy/dAXlw6FdxZLRD5SOydD2krpb\n\tod+/66edBmXTQYzjn8Q81UH8RvPWq86fWyI2jV2+W5QS+o8d6BUaq8NX+1I3Gz3OGn\n\tgM/oW3TtpnCBMTMnAV5whipJDjiljt37wGE7wXOI=","Reply-To":"kieran.bingham@ideasonboard.com","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190429191729.29697-1-niklas.soderlund@ragnatech.se>\n\t<20190429191729.29697-4-niklas.soderlund@ragnatech.se>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49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1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<9c2185fa-78d8-f9b3-878c-27eb1a81c691@ideasonboard.com>","Date":"Tue, 30 Apr 2019 11:37:25 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.1","MIME-Version":"1.0","In-Reply-To":"<20190429191729.29697-4-niklas.soderlund@ragnatech.se>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 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, 30 Apr 2019 10:37:29 -0000"}}]