From patchwork Tue Nov 26 23:35:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2348 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 17C3060C21 for ; Wed, 27 Nov 2019 00:39:26 +0100 (CET) X-Halon-ID: de628624-10a5-11ea-a0b9-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de [84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id de628624-10a5-11ea-a0b9-005056917f90; Wed, 27 Nov 2019 00:39:22 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Nov 2019 00:35:50 +0100 Message-Id: <20191126233620.1695316-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/30] libcamera: Rework buffer API 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-List-Received-Date: Tue, 26 Nov 2019 23:39:26 -0000 Hi, This series reworks the buffer API across the whole library. The two main reasons for the rework is - The current buffer API is cumbersome to work with as the variations between internally allocated buffers (from a V4L2 video device) and externally (from other source in the system or other V4l2 video device) is slightly different. - V4L2 concepts such as buffer index have "leaked" into the application facing interface which makes the API less intuitive to work with as one needs to know more about V4L2 and its limitations to use. As changing the buffer API touches most parts of the library this series is unfortunately quiet large and some patches are also quiet large. I have really tried to break things apart as best I could. The series starts by adding the new FrameBuffer interface building blocks and then slowly proceeds to replace the existing API with the new one. The series is tested on all upstream pipelines and IPAs without any regressions. Niklas Söderlund (30): libcamera: pipelines: Align bookkeeping in queueRequest() libcamera: Remove buffer index from logging libcamera: buffer: Add BufferInfo container for buffer metadata information libcamera: buffer: Add FileDecriptor to help deal with file descriptors libcamera: buffer: Add Dmabuf to describe a dma buffer libcamera: buffer: Add FrameBuffer interface ipa: Switch to FrameBuffer interface libcamera: buffer: Switch from Plane to Dmabuf libcamera: buffers: Remove Plane class libcamera: buffer: Drop private function setRequest() libcamera: v4l2_videodevice: Align which type variable is used in queueBuffer() libcamera: v4l2_videodevice: Remove assertion involving BufferPool libcamera: v4l2_videodevice: Extract exportDmaBuffer() to export DMA buffer libcamera: request: In addBuffer() do not fetch stream from Buffer libcamera: buffer: Move capture information to BufferInfo libcamera: buffer: Buffer remove metadata information libcamera: v4l2_videodevice: Add support for multi plane output buffers libcamera: v4l2_videodevice: Add V4L2BufferCache to deal with index mapping libcamera: v4l2_videodevice: Add new buffer interface libcamera: stream: Add prototypes for new interface libcamera: pipelines: Explicitly allocate streams libcamera: v4l2_videodevice: Add V4L2Stream to facilitate buffers libcamera: pipelines: Switch to V4L2Stream libcamera: stream: Make FrameBuffer support mandatory libcamera: allocator: Add BufferAllocator to help applications allocate buffers libcamera: camera: Start streams before pipeline libcamera: Switch to FrameBuffer interface libcamera: Remove dead code after switch to FrameBuffer libcamera: pipeline: Remove explicit buffer handling libcamera: camera: Remove the prepared state include/ipa/ipa_interface.h | 2 +- include/libcamera/allocator.h | 39 ++ include/libcamera/buffer.h | 118 ++--- include/libcamera/camera.h | 8 +- include/libcamera/meson.build | 1 + include/libcamera/request.h | 14 +- include/libcamera/stream.h | 29 +- src/android/camera_device.cpp | 34 +- src/cam/buffer_writer.cpp | 11 +- src/cam/buffer_writer.h | 3 +- src/cam/capture.cpp | 55 +- src/cam/capture.h | 4 +- src/ipa/libipa/ipa_interface_wrapper.cpp | 7 +- src/ipa/rkisp1/rkisp1.cpp | 14 +- src/libcamera/allocator.cpp | 141 ++++++ src/libcamera/buffer.cpp | 478 +++++++++--------- src/libcamera/camera.cpp | 157 ++---- src/libcamera/include/pipeline_handler.h | 14 +- src/libcamera/include/v4l2_videodevice.h | 65 ++- src/libcamera/ipa_context_wrapper.cpp | 8 +- src/libcamera/ipa_interface.cpp | 7 +- src/libcamera/meson.build | 1 + src/libcamera/pipeline/ipu3/ipu3.cpp | 315 +++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 165 +++--- src/libcamera/pipeline/uvcvideo.cpp | 50 +- src/libcamera/pipeline/vimc.cpp | 51 +- src/libcamera/pipeline_handler.cpp | 66 +-- src/libcamera/request.cpp | 24 +- src/libcamera/stream.cpp | 265 ++-------- src/libcamera/v4l2_videodevice.cpp | 445 +++++++++++----- src/qcam/main_window.cpp | 64 +-- src/qcam/main_window.h | 6 +- test/camera/buffer_import.cpp | 411 +++++---------- test/camera/capture.cpp | 41 +- test/camera/statemachine.cpp | 89 +--- test/ipa/ipa_wrappers_test.cpp | 38 +- test/v4l2_videodevice/buffer_sharing.cpp | 39 +- test/v4l2_videodevice/capture_async.cpp | 16 +- test/v4l2_videodevice/request_buffers.cpp | 11 +- test/v4l2_videodevice/stream_on_off.cpp | 6 +- test/v4l2_videodevice/v4l2_m2mdevice.cpp | 44 +- test/v4l2_videodevice/v4l2_videodevice_test.h | 2 +- 42 files changed, 1503 insertions(+), 1855 deletions(-) create mode 100644 include/libcamera/allocator.h create mode 100644 src/libcamera/allocator.cpp