From patchwork Mon Aug 23 13:12:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13444 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 CACC4BD87C for ; Mon, 23 Aug 2021 13:12:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 785AD688D2; Mon, 23 Aug 2021 15:12:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Ut7SSl78"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7391F688A2 for ; Mon, 23 Aug 2021 15:12:35 +0200 (CEST) Received: by mail-pf1-x431.google.com with SMTP id m26so15320318pff.3 for ; Mon, 23 Aug 2021 06:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9UJviNb4DpnhQj5osTY6f0kvGeRQy+OdwckPD5N+q80=; b=Ut7SSl78ctnG1noGbqNg58wzBLc5ae+C/rkmQ8XMDvUH0eE/RcZMa2QIfU+i8CT6XG +p+Y3Frp+wPYOtOnC1nFMRig198pimul5BYMjnCRLTdxhFwfvIWOVGPs/JKW42yEePxt 5lfU/ObOselqSIwWD+vDF+ePf+4iRbw3eBlxc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9UJviNb4DpnhQj5osTY6f0kvGeRQy+OdwckPD5N+q80=; b=YzV4/uDFshlHVRrQC5mfKCkbKi0lwcKKiTA1PqBh4VlhDgU3gotcQu83GXKjZOS/vY VrtUjEF5edeBUEvHz7jmh94fUvFo2PaoKhwAnspH+m8TkysBqML703ZeEAXSnkcQgK26 blgCmSY+OFtEL3Mhl2N8epGoAUB8mqhsSVIrTz2V44KCq0jEX161diMRtei9vFJWgmTx W7/cVN3VL+tPECcHGBILVqMAHFZHPUdWyQjZHNIx0htL7nc4WuoA5XvOFGkda3qNa8PR Hy1v4SFQUu8VtjbQg263x8M6u/d0IyoStxH7Bmf6PKHKb/kAGgnL+LoHGiKiSsOAp2cG qSkQ== X-Gm-Message-State: AOAM533OSbUSzqoeI8YMt2rejN/ai011BTNABL5DGF9lawiDHpZ5gKgf o9MSYKRCpldSFcOhpckGgtJZXbtUNiiXbQ== X-Google-Smtp-Source: ABdhPJwYLchTSp3iD14b1Zfh6iztidyRVDwGk9tcSv0N1HKuA5YZJZ5fe6KLBOTgxwvfndgae6x6FA== X-Received: by 2002:a05:6a00:190c:b0:3e2:911c:b7ca with SMTP id y12-20020a056a00190c00b003e2911cb7camr32584189pfi.5.1629724353659; Mon, 23 Aug 2021 06:12:33 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:184e:5d20:8fcb:dfcd]) by smtp.gmail.com with ESMTPSA id j4sm18596891pgi.6.2021.08.23.06.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 06:12:33 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Aug 2021 22:12:12 +0900 Message-Id: <20210823131221.1034059-2-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog In-Reply-To: <20210823131221.1034059-1-hiroh@chromium.org> References: <20210823131221.1034059-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 01/10] libcamera: framebuffer: Add offset to FrameBuffer::Plane 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This adds offset to FrameBuffer::Plane. It enables representing frame buffers that store planes in the same dmabuf at different offsets, as for instance required by the V4L2 NV12 pixel format. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- include/libcamera/framebuffer.h | 1 + src/android/mm/generic_camera_buffer.cpp | 2 -- src/libcamera/framebuffer.cpp | 27 ++++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 28307890..5de3c744 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -42,6 +42,7 @@ class FrameBuffer final : public Extensible public: struct Plane { FileDescriptor fd; + unsigned int offset; unsigned int length; }; diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index b296b3e3..73fbd97a 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -52,8 +52,6 @@ private: int fd_; int flags_; std::vector planeInfo_; - /* \todo remove planes_ is added to MappedBuffer. */ - std::vector> planes_; }; CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer, diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index b401c50e..e9467aa0 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -131,7 +131,7 @@ FrameBuffer::Private::Private() * * The static information describes the memory planes that make a frame. The * planes are specified when creating the FrameBuffer and are expressed as a set - * of dmabuf file descriptors and length. + * of dmabuf file descriptors, offset and length. * * The dynamic information is grouped in a FrameMetadata instance. It is updated * during the processing of a queued capture request, and is valid from the @@ -151,18 +151,18 @@ FrameBuffer::Private::Private() * * Planar pixel formats use multiple memory regions to store the different * colour components of a frame. The Plane structure describes such a memory - * region by a dmabuf file descriptor and a length. A FrameBuffer then - * contains one or multiple planes, depending on the pixel format of the - * frames it is meant to store. + * region by a dmabuf file descriptor, an offset within the dmabuf and a length. + * A FrameBuffer then contains one or multiple planes, depending on the pixel + * format of the frames it is meant to store. * - * To support DMA access, planes are associated with dmabuf objects represented - * by FileDescriptor handles. The Plane class doesn't handle mapping of the - * memory to the CPU, but applications and IPAs may use the dmabuf file - * descriptors to map the plane memory with mmap() and access its contents. + * The offset identifies the location of the plane data from the start of the + * memory referenced by the dmabuf file descriptor. Multiple planes may be + * stored in the same dmabuf, in which case they will reference the same dmabuf + * and different offsets. No two planes may overlap, as specified by their + * offset and length. * - * \todo Once we have a Kernel API which can express offsets within a plane - * this structure shall be extended to contain this information. See commit - * 83148ce8be55e for initial documentation of this feature. + * \todo Specify how an application shall decide whether to use a single or + * multiple dmabufs, based on the camera requirements. */ /** @@ -170,6 +170,11 @@ FrameBuffer::Private::Private() * \brief The dmabuf file descriptor */ +/** + * \var FrameBuffer::Plane::offset + * \brief The plane offset in bytes +*/ + /** * \var FrameBuffer::Plane::length * \brief The plane length in bytes