From patchwork Wed Jun 29 07:04:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16406 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 9952FBE173 for ; Wed, 29 Jun 2022 07:04:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96F886563B; Wed, 29 Jun 2022 09:04:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656486282; bh=jj3dizpI6ArZZZ7WrJHaft6iRD1TBV/M310eawnjA2M=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=0POIa8kJUfsjJccA22GoSeOXVL943jiaNFH8v42D3AbMIci85YRFmnL6M+K1Q4bC2 woPlJFq1AwUmnjUT1xJcetlQpw7o5hr3ddVog7XUxE2rG2ehs5z9V5bwSxpEAVYwfb PEGoH1hWAfWZ5DUapJ/7ez5/AJT65NnZbm558TqZv3ZfXiD4kujRaM7T6DdwVjDDcW CsGns4Sb3ndAeXnwB8fgv1tvbIMLmQy4yndRAyaT5L7l6GWVwQizRvTND7iczYgGvB MUuESWuvPL4mNLPTcXcaDj/7eo+CN/NlIAhymQN8SB9Vnh9ndov5DCcHVMKxndYRCy fJndQJNf9/y8g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F95F60552 for ; Wed, 29 Jun 2022 09:04:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d/lNJLNy"; dkim-atps=neutral Received: from deskari.lan (91-158-154-79.elisa-laajakaista.fi [91.158.154.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5C7EA4A8; Wed, 29 Jun 2022 09:04:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1656486279; bh=jj3dizpI6ArZZZ7WrJHaft6iRD1TBV/M310eawnjA2M=; h=From:To:Cc:Subject:Date:From; b=d/lNJLNym+5KNkXG6hTeyhaiv4Vjl6fMsYgrkKX/eUMoXC2vWvxhZidj784mE4A8A MPr0ItOVxOmYhgoNtBD2OQp+xXJcMMwwrjL4TbTA1JptE5bz0rVz/2mpAdxoqSPAa+ tOCb9+f0fr7vpkTI8g7VOdWBkuFRoxzP2XA2kopQ= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Wed, 29 Jun 2022 10:04:02 +0300 Message-Id: <20220629070416.17550-1-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 00/14] Python bindings event handling 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" Hi, v2 of the event handling series. Plenty of changes to v1: - (Hopefully) most of the review comments addressed - PyCameraManager no longer inherits CameraManager. This also fixes the camera added/removed events. - 7 new patches - API CHANGE: The eventfd is now always non-blocking. This causes an API change only if you relied on the blocking read. - API CHANGE: many of the methods exposed to Python no longer return an error code, but raise an exception on error. The patches up to and including "py: Switch to non-blocking eventfd" can be considered for merging. The new event handling still needs more thought, I believe. I'm still not sure if we should go with the dispatching method implemented now, or instead returning a list of events which the user needs to process (a bit more like what we have now with the get_ready_requests). I'm also not quite sure how to go with the camera.stop(), but there's an attempt to solve that in this series. Tomi Tomi Valkeinen (14): py: cam.py: Fix multi camera capture without -C py: Add Python logging category py: Move ControlValue helpers to py_helpers.cpp py: cam.py: Remove todo comment py: Create PyCameraManager py: Use UniqueFD py: Set EFD_CLOEXEC on eventfd to avoid fd leaking py: Use libcamera's Mutex classes py: Use exceptions instead of returning error codes py: Switch to non-blocking eventfd py: New event handling py: cam.py: Use new events support py: Discard/Dispatch Request events on camera.stop() py: Add hotplug-monitor.py src/py/cam/cam.py | 57 +-- src/py/examples/hotplug-monitor.py | 38 ++ src/py/examples/simple-cam.py | 20 +- src/py/examples/simple-capture.py | 33 +- src/py/examples/simple-continuous-capture.py | 26 +- src/py/libcamera/meson.build | 2 + src/py/libcamera/py_camera_manager.cpp | 375 +++++++++++++++++++ src/py/libcamera/py_camera_manager.h | 100 +++++ src/py/libcamera/py_helpers.cpp | 97 +++++ src/py/libcamera/py_helpers.h | 13 + src/py/libcamera/py_main.cpp | 347 ++++++++--------- src/py/libcamera/py_main.h | 14 + test/py/unittests.py | 83 ++-- 13 files changed, 904 insertions(+), 301 deletions(-) create mode 100644 src/py/examples/hotplug-monitor.py create mode 100644 src/py/libcamera/py_camera_manager.cpp create mode 100644 src/py/libcamera/py_camera_manager.h create mode 100644 src/py/libcamera/py_helpers.cpp create mode 100644 src/py/libcamera/py_helpers.h create mode 100644 src/py/libcamera/py_main.h