From patchwork Tue May 21 19:27:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1243 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C19A560C40 for ; Tue, 21 May 2019 21:28:02 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2EFFB52C for ; Tue, 21 May 2019 21:28:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558466882; bh=lRlXpq7hg9dWMO+aDJaC4cWVhZYF17ImOcKYL8qSC5g=; h=From:To:Subject:Date:From; b=LPl4XMzFZ6nhmQxfX9Clw66JQDJucPLhKPJa9hQo9/Yp8zqdhsuROoRh3qFkHJk+/ 4Nx3lXJHLzru18PcadgHeRU8vEcJYQZkjF7DUvaBdvAEn5DqeXEu2tVi4XE8vC4hpk lvigC+px4D4hOyT4ILHekC0027Wm7hLIZlB9fm80= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 21 May 2019 22:27:34 +0300 Message-Id: <20190521192740.28112-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 0/6] Rework camera configuration to introduce negotiation of parameters X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 May 2019 19:28:03 -0000 Hello, Camera are currently configured in two steps, first by retrieving a configuration for a set of stream usages with streamConfiguration(), and then by configuring the camera with configureStreams(). The camera configuration can be changed by the application between those two steps, but there is no way for applications to find out what changes are compatible with the camera, as the configureStreams() method either accepts the configuration as-is, or rejects it completely without any additional feedback. This leaves applications with no other option than shooting in the dark. This patch series reworks the camera configuration API to fix this problems, and introduces a new concept: configuration negotiation through validation. The first 5 patches refactor the camera configuration API by renaming the confusing streamConfiguration() and configureStreams() methods to generateConfiguration() and configure() (1/6), replacing stream usages with plain stream roles (2/6, with a regression in the features exposed by libcamera, but this gets fixed in the same series), and further refactoring the APIs (3/6 and 4/6) and the pipeline handlers (5/6). Patch 6/6 introduces configuration negotiation. The core idea is to introduce a new validate() method for the CameraConfiguration class that validates and possibly updates the configuration to the closest supported configuration. Applications can then create a configuration (possibly from scratch, or using Camera::generateConfiguration() with a set of stream roles), modify it, and then call validate() to request a configuration update from libcamera. If the configuration is updated, the application can then inspect it, decide to use the updated version, or try again, until a configuration acceptable for both libcamera and the application is found. The validate() operation is implemented with the help of the pipeline handlers that need to provide a subclass of CameraConfiguration. This puts more burden on the pipeline handlers, but is offset by the fact that the pipeline handler configure() method doesn't need to perform validation anymore as the configuration is validated prior to configure(). Compared to v1, the most notable changes are - Dropped patch 01/12 that has already been merged - Added a CameraConfiguration::at() method and use it on config pointers - Dropped patches 08/12 to 12/12, a new version will be posted by Niklas Changes compared to v2 are detailed in each individual patch. Laurent Pinchart (6): libcamera: camera: Rename configureStreams() and streamConfiguration() libcamera: Use stream roles directly instead of StreamUsage libcamera: Refactor the camera configuration storage and API libcamera: camera: Return a pointer from generateConfiguration() libcamera: pipeline: Move camera data classes to the top level scope libcamera: camera: Add a validation API to the CameraConfiguration class include/libcamera/camera.h | 55 ++-- include/libcamera/stream.h | 56 ++-- src/cam/main.cpp | 74 +++-- src/libcamera/camera.cpp | 351 ++++++++++++----------- src/libcamera/include/pipeline_handler.h | 10 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 349 +++++++++++++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 207 +++++++++---- src/libcamera/pipeline/uvcvideo.cpp | 127 +++++--- src/libcamera/pipeline/vimc.cpp | 142 ++++++--- src/libcamera/pipeline_handler.cpp | 50 ++-- src/libcamera/stream.cpp | 116 +++----- src/qcam/main_window.cpp | 10 +- src/qcam/main_window.h | 4 +- test/camera/capture.cpp | 29 +- test/camera/configuration_default.cpp | 14 +- test/camera/configuration_set.cpp | 35 ++- test/camera/statemachine.cpp | 32 ++- 17 files changed, 1007 insertions(+), 654 deletions(-)