From patchwork Mon Mar 16 02:41:40 2020 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: 3109 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C2AE60417 for ; Mon, 16 Mar 2020 03:42:31 +0100 (CET) X-Halon-ID: b1b86c1d-672f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b1b86c1d-672f-11ea-9f40-0050569116f7; Mon, 16 Mar 2020 03:42:00 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Mar 2020 03:41:40 +0100 Message-Id: <20200316024146.2474424-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 0/6] libcamera: Add support for a RAW still capture stream 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: Mon, 16 Mar 2020 02:42:31 -0000 Hi, This series is an RFC for how RAW capture can be added to libcamera. It implements a RAW stream in the IPU3 pipeline handler as an example. It targets RAW still image captures and uses a memcpy to copy out the buffer with the RAW data as soon as it's dequeued from the CIO2. The copy is needed as the buffer might need to be used in further processing by the IMGU. Patch 1/6 Defines a new StillCaptureRaw role which can be used to applications to generate configurations for raw capture. Patch 2/6 makes use of this new role in the cam utility. Patch 3/6 is not ready for consumption as it depends on work submitted to the DRM subsystem. The patch is however needed as the new DRM formats are needed to describe the IPU3's RAW pixel format. Patch 4/6 adds a helper to do the actual memcpy of FrameBuffers. I'm not really sure it should be declared in buffers.h. Suggestions for a better location are welcome. Patch 5/6 and 6/6 deals with implementing the RAW stream into the IPU3 pipeline handler. This series depends on Laruent's work [1] to use the improved BufferAllocator with buffer orphaning support. To ease testing [2] may also be useful to allow cam to write two capture streams content to disk without conflict. I have tested this on IPU3 and I can capture both a single RAW stream or a mix of RAW and video, example with both and writing to disk. $ ./cam -c1 -s role=video -s role=stillraw -C -F ... fps: 0.00 stream0 seq: 002055 bytesused: 1382400 stream1 seq: 000001 bytesused: 3269376 fps: 30.30 stream0 seq: 002056 bytesused: 1382400 stream1 seq: 000002 bytesused: 3269376 fps: 30.30 stream0 seq: 002057 bytesused: 1382400 stream1 seq: 000003 bytesused: 3269376 fps: 30.30 stream0 seq: 002058 bytesused: 1382400 stream1 seq: 000004 bytesused: 3269376 ... What I still have to do is find/write a IPU3 RAW frame decoder to verify the captured RAW frames are good. So far I verified each captured frame have a different checksum and the captured metadata (sequence nr etc) make sens. 1. [PATCH 0/9] Simplify buffer management with V4L2 buffer orphaning 2. [PATCH] cam: Create stream names after configuring the camera Niklas Söderlund (6): libcamera: stream: Add StillCaptureRaw role cam: Add option to capture StillCaptureRaw stream [DNI] include: drm_fourcc: Add Bayer FourCC and modifiers libcamera: buffer: Add helper to memcopy a FrameBuffer libcamera: ipu3: Do not unconditionally queue buffers to CIO2 libcamera: ipu3: Add support for a RAW still capture stream include/libcamera/buffer.h | 1 + include/libcamera/stream.h | 1 + include/linux/drm_fourcc.h | 94 +++++++++++++++++ src/cam/main.cpp | 4 +- src/libcamera/buffer.cpp | 43 ++++++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 152 +++++++++++++++++++++++---- src/libcamera/stream.cpp | 4 + 7 files changed, 279 insertions(+), 20 deletions(-)