From patchwork Mon May 30 14:27:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16118 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F1E4DC3275 for ; Mon, 30 May 2022 14:27:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 951AB6564C; Mon, 30 May 2022 16:27:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653920873; bh=nImSIZ5uytByW9XxCoN6/Shcks/45bpyiqqgaYQ2cEE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sRRmP3Vhi4a5274RMh8fr3NfvNB2tDI3nfhaj8tEOtuIfWir825BOzQpNuVoBizt4 fkqqBR93XWg5TbfMx22OPZx/mV752y7qHyPBJItk7KRfKknmZbBKvYqWA5unAklWcA x69HXc5ITf/EAyUkYjrJ+2XU7AUaRF7Z4KhtiYYEI+YUqhTA18VJMCSwMO/P+LtaJQ N1knvVRUT6HV4odfn0Q19skw2gJlrOE1zF37AqeYnDlx9QK5sUcmkXEyoj38jUjMk7 tr6vGnfAGEj4pkmLsSFgE0+1jhzXn9bSeD9G63NhfEl+Mnpp+MAA3VhkVAStzRCDn2 PR04vwQwxMg5A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D93F465641 for ; Mon, 30 May 2022 16:27:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gNfQ1dDu"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 511E7145B; Mon, 30 May 2022 16:27:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653920864; bh=nImSIZ5uytByW9XxCoN6/Shcks/45bpyiqqgaYQ2cEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNfQ1dDumnu8RcJZQYZ16P2wPLcPxFW8FFC8iXM61kpDaLHz3Jk5olIo1ceF3RCoD rAYaDo/bYNmVleWZI2wDb21+fQfjzHcWEMLWW2O1LVx2OnnGErxQ3Y1XGH2ZRyg370 5HEEgk3+DekvjwNBH2lsAboI3Xfd+k+8bZkbuj+I= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Mon, 30 May 2022 17:27:17 +0300 Message-Id: <20220530142722.57618-12-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220530142722.57618-1-tomi.valkeinen@ideasonboard.com> References: <20220530142722.57618-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 11/16] py: merge read_event() and get_ready_requests() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We always call CameraManager.read_event() and CameraManager.get_ready_requests(), so to simplify the use merge the read_event() into the get_ready_requests(). This has the side effect that get_ready_requests() will now block if there is no event ready. If we ever need to call get_ready_requests() in a polling manner we will need a new function which behaves differently. However, afaics the only sensible way to manage the event loop is to use select/poll on the eventfd and then call get_ready_requests() once, which is the use case what the current merged function supports. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- src/py/cam/cam.py | 2 -- src/py/libcamera/py_main.cpp | 7 ++----- test/py/unittests.py | 4 ---- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index bf8529d9..2ae89fa8 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -243,8 +243,6 @@ class CaptureState: # Called from renderer when there is a libcamera event def event_handler(self): try: - self.cm.read_event() - reqs = self.cm.get_ready_requests() for req in reqs: diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index fcf009f0..505cc3dc 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -213,15 +213,12 @@ PYBIND11_MODULE(_libcamera, m) return gEventfd; }) - .def("read_event", [](CameraManager &) { + .def("get_ready_requests", [](CameraManager &) { uint8_t buf[8]; - int ret = read(gEventfd, buf, 8); - if (ret != 8) + if (read(gEventfd, buf, 8) != 8) throw std::system_error(errno, std::generic_category()); - }) - .def("get_ready_requests", [](CameraManager &) { std::vector v; { diff --git a/test/py/unittests.py b/test/py/unittests.py index 33b35a0a..9adc4337 100755 --- a/test/py/unittests.py +++ b/test/py/unittests.py @@ -210,8 +210,6 @@ class SimpleCaptureMethods(CameraTesterBase): reqs = [] while True: - cm.read_event() - ready_reqs = cm.get_ready_requests() reqs += ready_reqs @@ -283,8 +281,6 @@ class SimpleCaptureMethods(CameraTesterBase): while running: events = sel.select() for key, _ in events: - cm.read_event() - ready_reqs = cm.get_ready_requests() reqs += ready_reqs