From patchwork Tue Nov 30 08:58:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 14881 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 11206BDB13 for ; Tue, 30 Nov 2021 08:59:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34377605B4; Tue, 30 Nov 2021 09:59:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EdxJQ3Vn"; dkim-atps=neutral Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D56D460230 for ; Tue, 30 Nov 2021 09:59:07 +0100 (CET) Received: by mail-pg1-x532.google.com with SMTP id j11so9156968pgs.2 for ; Tue, 30 Nov 2021 00:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Jw+LipgdGzjWcoydliNySzQq4j9bCXeiAIAwp8Tn7zs=; b=EdxJQ3VnfwmKmV0XxjvyzwMG9/wmiN05EJYsZeX5lFtA66KoTfhVlOezis9ahV7DDC YYExUTUGbM7w5rW3qYX8G2Rcg0uJg0UfW/tMzFhOvu5oE92J+4eyqj5LigfQuNw4+GqK PXwXLT7RvvWxYgKkt7kZONg+inHgfv6n3AVbupdwK2qUMUuQFXCpnBbg4PiaNsMCAebg fwcZeET9C6dwx9tC9jCeoxPjGSCdclElktUg+RDPmi+7nza5KfryTWZXSSrMa9MQFeKu xY1uNQf944qpZmCIfFNcMQcAosljAkKolOgIX2ZBS1SMmQj6CHZOvLpmXlPUqCVHCH89 WlUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Jw+LipgdGzjWcoydliNySzQq4j9bCXeiAIAwp8Tn7zs=; b=Op9OQ7EE6BJxfCIunLxnMlQ+rzE4hIDSMMIClYH8L0+DpPmJ1vAplWxiaHIWg/fSO5 dRt5cWb8+rZkQZ+NVPd723HymegymLGhnQVYFjgZeXr609aOjJg4HU1rUStFDpkw7Fvq SwQkFsXoZvCYzEylLxFzYk2oEFPj7gWiJ4Qg3Pyd60ntblKuZQWkULMlptjbYv9wkh5p z8y2sItd+ByhkU5BKejeOieiB5yqeYDejyEioIpq4Gtyotq07kwW7cKrIuSxsl6U8uiC rgzy4Ne0nD6PFpi7q537kj7vpKIA3h4PDGWKGwbrYOfV59gCQ/hgIQjm0fpF2KlKzVbp 9PKw== X-Gm-Message-State: AOAM531fp5clEOAnKox59VKzZBVRdzXP4zuNlxtk9DOiSG/ym644jg9j 6b6r5KbexL71Ac/Uz4/0EISt7DnfSXcxfmIn X-Google-Smtp-Source: ABdhPJyL/EijjL/usrNLlKWh4ynBLj2sEPIR5Oi89iNJxbNdUsQaihcHRj6V7j84Uv0juE8Q8FfnJg== X-Received: by 2002:a65:40c3:: with SMTP id u3mr39606432pgp.160.1638262745997; Tue, 30 Nov 2021 00:59:05 -0800 (PST) Received: from localhost.localdomain ([1.186.166.200]) by smtp.googlemail.com with ESMTPSA id v10sm20838133pfu.123.2021.11.30.00.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 00:59:05 -0800 (PST) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Nov 2021 14:28:30 +0530 Message-Id: <20211130085830.1529550-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add support for DMABUF buffer I/O in REQBUF ioctl 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: , Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To support importing DMABUF, we need to reqbufs with DMABUF mode. This patch enables using V4L2_MEMORY_DMABUF as one of the memory types in vidioc_reqbuf to initialise DMA Buffer I/O Bug: https://bugs.libcamera.org/show_bug.cgi?id=89 Signed-off-by: Vedant Paranjape --- src/v4l2/v4l2_camera_proxy.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index f194e06345b7..49db766d9f9d 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type) bool V4L2CameraProxy::validateMemoryType(uint32_t memory) { - return memory == V4L2_MEMORY_MMAP; + return (memory == V4L2_MEMORY_MMAP) || + (memory == V4L2_MEMORY_DMABUF); } void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig) @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf if (!hasOwnership(file) && owner_) return -EBUSY; - arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP; + arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP | + V4L2_BUF_CAP_SUPPORTS_DMABUF; memset(arg->reserved, 0, sizeof(arg->reserved)); if (arg->count == 0) { @@ -511,7 +513,7 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf struct v4l2_buffer buf = {}; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.length = v4l2PixFormat_.sizeimage; - buf.memory = V4L2_MEMORY_MMAP; + buf.memory = arg->memory; buf.m.offset = i * v4l2PixFormat_.sizeimage; buf.index = i; buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;