From patchwork Sun May 19 15:00:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1231 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7320260E4C for ; Sun, 19 May 2019 17:01:07 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E0C99443 for ; Sun, 19 May 2019 17:01:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558278067; bh=7K9A1OogelmTi0nbw2s61KsA8JJ44XjFG43/soeeDls=; h=From:To:Subject:Date:From; b=b8p9upkzyiAYr4Qdh2H+sS7l7HU8cET+0uuY/Hpx8/8c3GSN/qhmyioKcU7GUlNG0 txjA1IBEL3nHAt61j0IYj/PO+UmsS/tkU2whCypAbFrehjIGKt5+BaTxnSsbMgTki9 a4BNV6vIOvkoXNWQjME72vjqmkI2R30ozskq30CI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 19 May 2019 18:00:41 +0300 Message-Id: <20190519150047.12444-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Sun, 19 May 2019 15:01:07 -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 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 | 51 +--- src/cam/main.cpp | 78 ++--- src/libcamera/camera.cpp | 347 +++++++++++----------- src/libcamera/include/pipeline_handler.h | 10 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 351 ++++++++++++++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 210 ++++++++++---- src/libcamera/pipeline/uvcvideo.cpp | 131 ++++++--- src/libcamera/pipeline/vimc.cpp | 147 +++++++--- src/libcamera/pipeline_handler.cpp | 50 ++-- src/libcamera/stream.cpp | 116 +++----- src/qcam/main_window.cpp | 11 +- src/qcam/main_window.h | 3 +- test/camera/capture.cpp | 35 ++- test/camera/configuration_default.cpp | 20 +- test/camera/configuration_set.cpp | 41 ++- test/camera/statemachine.cpp | 38 ++- 17 files changed, 1034 insertions(+), 660 deletions(-)