{"id":1188,"url":"https://patchwork.libcamera.org/api/patches/1188/?format=json","web_url":"https://patchwork.libcamera.org/patch/1188/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190511091907.10050-4-niklas.soderlund@ragnatech.se>","date":"2019-05-11T09:18:59","name":"[libcamera-devel,v3,03/11] libcamera: media_device: Only read device information in populate()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e36e28ae0e4fe98bf4839cad0c559b78d8b00d38","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1188/mbox/","series":[{"id":303,"url":"https://patchwork.libcamera.org/api/series/303/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=303","date":"2019-05-11T09:18:56","name":"libcamerea: Add support for exclusive access to cameras between processes","version":3,"mbox":"https://patchwork.libcamera.org/series/303/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1188/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1188/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B53F960E6E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 11 May 2019 11:19:47 +0200 (CEST)","from localhost.localdomain (unknown [185.224.57.161])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid ea5c7a7b-73cd-11e9-8e2f-005056917f90;\n\tSat, 11 May 2019 11:19:46 +0200 (CEST)"],"X-Halon-ID":"ea5c7a7b-73cd-11e9-8e2f-005056917f90","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 11 May 2019 11:18:59 +0200","Message-Id":"<20190511091907.10050-4-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190511091907.10050-1-niklas.soderlund@ragnatech.se>","References":"<20190511091907.10050-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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":"Sat, 11 May 2019 09:19:48 -0000"},"content":"There is no reason to reread the MEDIA_IOC_DEVICE_INFO information every\ntime the media device is opened. Move it populate() where it will be\nread once together the other information about the media device.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/media_device.cpp | 51 +++++++++++++++-------------------\n 1 file changed, 22 insertions(+), 29 deletions(-)","diff":"diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex c39775164fab7487..eef348e35eb6a97f 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","prefixes":["libcamera-devel","v3","03/11"]}