From patchwork Fri Nov 8 07:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 21860 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 E8916BE173 for ; Fri, 8 Nov 2024 07:50:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A1C3760589; Fri, 8 Nov 2024 08:50:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YX88PFgY"; dkim-atps=neutral Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EFC565486 for ; Fri, 8 Nov 2024 08:50:46 +0100 (CET) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-207115e3056so18969835ad.2 for ; Thu, 07 Nov 2024 23:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1731052244; x=1731657044; 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=EVMZf6bLtabM0cvavXBD/DzwTkqLfLsoZvAUbTT4PTo=; b=YX88PFgYmsQJOCYu0RPz7CYWVoreROP+r7cvYuGc8M5d7sjRT+mDSZtoCwhGa6dvGC O2Nhs8huHhi7tNQTIk1xn3sljruj8ZFJifFLi31B3BBuCQbbUZkLkflUzVmKxBiHi6Gs crSRYUC2RplRvq1c/Unk9kuEd+jJinVbXIm1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731052244; x=1731657044; 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=EVMZf6bLtabM0cvavXBD/DzwTkqLfLsoZvAUbTT4PTo=; b=Mks6vUEdVghLx8OsLPQE0o68HNfVAsrOngucF60r4PpNP2Nk3YZ7qlXqE4mdEftWeF jWTUxkvgpEXBaecF3IuQnLRLYjaDYwPAKAkQpe8/RtDGCzqt940AQ2liLx1Ng9mAnZlx 3bQIOEnmQR1evouH2gHa1p4026LAeSBccUGCNZihqCbPhQnXfYctwNwQiaiNQs7VHz2+ 7aODwiiXXP0rEOrrHELPuxwtPqtlHyeMM+NYmCy8EiwoxexkAuGAUfgr6UBBy3ALxn34 YIApnIBWD8BLULEmxU/sf2O+vh9f0mwr0i2L+29i6R5gNgP2EZYRMvOPr59YBRCLXk6q XjBw== X-Gm-Message-State: AOJu0YziYesIBjyn5vQenVQ82KVJgolQ8vQBkVWFv42V2k0lJcyRZeTh CTOcTcyBq9cM/ZRfuk6DyN6ce7GCrW1A8y8m2VG/uMtC0sEF/V6ChXYIKODuHtI0qbeOa2rkc5n R8Q== X-Google-Smtp-Source: AGHT+IH6uHH8r2n1lVh5oQR8ah5K/LGkTzqyZko8CStIlsmYGxTcKi9vvBMiofzT7y746s3O3ak+uQ== X-Received: by 2002:a17:902:ecc2:b0:20c:c694:f6c6 with SMTP id d9443c01a7336-211835bbc05mr21081035ad.49.1731052244387; Thu, 07 Nov 2024 23:50:44 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (27.247.221.35.bc.googleusercontent.com. [35.221.247.27]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177e62dd4sm24343295ad.218.2024.11.07.23.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 23:50:44 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Han-Lin Chen , Harvey Yang Subject: [PATCH 1/1] libcamera: Extend V4L2 videodevice to accept media request API Date: Fri, 8 Nov 2024 07:38:27 +0000 Message-ID: <20241108075039.2116460-2-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog In-Reply-To: <20241108075039.2116460-1-chenghaoyang@chromium.org> References: <20241108075039.2116460-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" From: Han-Lin Chen Add request fd as an extra argument to V4L2 device queueBuffer. Default to -1 for backward compatibility. It's used to bind multiple buffers into the same request. Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/v4l2_videodevice.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index f021c2a01..6e2b1e1f1 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -218,7 +218,7 @@ public: int importBuffers(unsigned int count); int releaseBuffers(); - int queueBuffer(FrameBuffer *buffer); + int queueBuffer(FrameBuffer *buffer, int requestFd = -1); Signal bufferReady; int streamOn(); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 14eba0561..0c6ea086d 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1604,6 +1604,7 @@ int V4L2VideoDevice::releaseBuffers() /** * \brief Queue a buffer to the video device * \param[in] buffer The buffer to be queued + * \param[in] requestFd The fd of the request to queue the buffer to * * For capture video devices the \a buffer will be filled with data by the * device. For output video devices the \a buffer shall contain valid data and @@ -1618,7 +1619,7 @@ int V4L2VideoDevice::releaseBuffers() * * \return 0 on success or a negative error code otherwise */ -int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) +int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer, int requestFd) { struct v4l2_plane v4l2Planes[VIDEO_MAX_PLANES] = {}; struct v4l2_buffer buf = {}; @@ -1647,6 +1648,10 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) buf.type = bufferType_; buf.memory = memoryType_; buf.field = V4L2_FIELD_NONE; + if (requestFd >= 0) { + buf.flags |= V4L2_BUF_FLAG_REQUEST_FD; + buf.request_fd = requestFd; + } bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); const std::vector &planes = buffer->planes();