From patchwork Wed Oct 9 07:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21556 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 ADBE8C32E7 for ; Wed, 9 Oct 2024 07:47:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 488DE63527; Wed, 9 Oct 2024 09:47:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gJXAPL2e"; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 75E0365373 for ; Wed, 9 Oct 2024 09:46:55 +0200 (CEST) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2e29522f0f1so954000a91.0 for ; Wed, 09 Oct 2024 00:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728460014; x=1729064814; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hIYRjwA8UoGnGjd32bbuoBgeCFx8Qw8gErvHW8Wrnvw=; b=gJXAPL2eqGNQoQrB8Dp6ApUz9n6luulWraxZ45AXh4Z4uBf0H5+rxLOkPLJoMddl6Q aYw5HTv45hYctIJlpRjyAN3IDlFAXM/ZeqmBWL9fKN3ET3XgCxTpwio0DiVPJC0yfolI +Fe12ytUHDb+uG01YUi/j7IB/GzPnBdH0bYY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728460014; x=1729064814; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hIYRjwA8UoGnGjd32bbuoBgeCFx8Qw8gErvHW8Wrnvw=; b=E+9sPZrkjHdRifQ/zv/Jt79aUT0lhmQ3y/r3Oex87TUyEA30Ig/azBXJGF/pldAH6I k1vpk7BUi6Ex78xMfRVExt8xV++CShJWhaF51iH5mUsOwATGDsB78oKbScrFJSgkSrBB Tu7rIiW1lqgt+RfNNoGkKhYftXiboyVae56Nr8IwdWipNQiJw4kMhwMNvMLTjQ8xvtl6 WwX+hLbZuEwQ+3bak15lzhrSRREUkEEQmMQw7ruzC4iWRhgrA6shH5/u59dxeXSbq4rY djGLTx1IgVqHxaIOuhRNnY64F42wgxVI4CSW+wAGJHAb7Ps1W386C/kImjh64eNw6IjX lcfg== X-Gm-Message-State: AOJu0Yy1+gWY+Fx1nTN6SR9cGPBK0Wgtk58oUTnhDr3ExA7FCyEvWUP3 /I+WOV/d2XwoZPvyMFrTc3pf7JzKXaFeEs0KOZRc14/R7Naw75pwFuv7GdhPMciXIi9+hgV4WtE jdw== X-Google-Smtp-Source: AGHT+IGhpAn5NpRtGtKjEr8o4YFApr6aKAtH2EF99znKPWIMSgohChmotRBfaLeiXwS43nFjDpYd2g== X-Received: by 2002:a17:90b:1288:b0:2e0:7012:335a with SMTP id 98e67ed59e1d1-2e2a21eb985mr1820248a91.6.1728460013686; Wed, 09 Oct 2024 00:46:53 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a57077c2sm944414a91.17.2024.10.09.00.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 00:46:53 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang Subject: [PATCH 4/5] libcamera: Add stride in FrameBuffer::Plane Date: Wed, 9 Oct 2024 07:41:22 +0000 Message-ID: <20241009074642.2965791-5-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog In-Reply-To: <20241009074642.2965791-1-chenghaoyang@chromium.org> References: <20241009074642.2965791-1-chenghaoyang@chromium.org> MIME-Version: 1.0 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" Some platforms, like mtkisp7, need the stride information in a FrameBuffer. This patch adds the member variable in FrameBuffer::Plane, and appends the member variable in IPA (de)serializer. Signed-off-by: Harvey Yang --- include/libcamera/framebuffer.h | 1 + src/libcamera/dma_buf_allocator.cpp | 3 ++- src/libcamera/framebuffer.cpp | 5 +++++ src/libcamera/ipa_data_serializer.cpp | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index ff8392430..059c66f31 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -55,6 +55,7 @@ public: SharedFD fd; unsigned int offset = kInvalidOffset; unsigned int length; + unsigned int stride; }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index 262eb53a0..e6a29c2d7 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -255,7 +255,8 @@ DmaBufAllocator::createBuffer(std::string name, return nullptr; for (auto planeSize : planeSizes) { - planes.emplace_back(FrameBuffer::Plane{ fd, offset, planeSize }); + /* \todo Invalid stride information. Consider adding strides as input. */ + planes.emplace_back(FrameBuffer::Plane{ fd, offset, planeSize, 0 }); offset += planeSize; } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 826848f75..61a3cc024 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -282,6 +282,11 @@ FrameBuffer::Private::~Private() * \brief The plane length in bytes */ +/** + * \var FrameBuffer::Plane::stride + * \brief The plane stride in bytes + */ + namespace { ino_t fileDescriptorInode(const SharedFD &fd) diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp index 2189a2466..d9d76c57c 100644 --- a/src/libcamera/ipa_data_serializer.cpp +++ b/src/libcamera/ipa_data_serializer.cpp @@ -572,6 +572,7 @@ SharedFD IPADataSerializer::deserialize(const std::vector &da * 4 byte - SharedFD * 4 bytes - uint32_t Offset * 4 bytes - uint32_t Length + * 4 bytes - uint32_t Stride */ template<> std::tuple, std::vector> @@ -590,6 +591,7 @@ IPADataSerializer::serialize(const FrameBuffer::Plane &data, appendPOD(dataVec, data.offset); appendPOD(dataVec, data.length); + appendPOD(dataVec, data.stride); return { dataVec, fdsVec }; } @@ -608,6 +610,7 @@ IPADataSerializer::deserialize(std::vector::const_i fdsBegin, fdsBegin + 1); ret.offset = readPOD(dataBegin, 4, dataEnd); ret.length = readPOD(dataBegin, 8, dataEnd); + ret.stride = readPOD(dataBegin, 12, dataEnd); return ret; }