{"id":15225,"url":"https://patchwork.libcamera.org/api/1.1/patches/15225/?format=json","web_url":"https://patchwork.libcamera.org/patch/15225/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>","date":"2021-12-28T18:50:14","name":"[libcamera-devel,v4] v4l2: V4L2CameraProxy: Add EXPBUF as one of the supported ioctl","commit_ref":"d769a595666bc4054fa59b9d13881a38497ea6ec","pull_url":null,"state":"accepted","archived":false,"hash":"0eb79fa7d9a51ea5e9084fa6f8525f812d90480e","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/1.1/people/85/?format=json","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15225/mbox/","series":[{"id":2869,"url":"https://patchwork.libcamera.org/api/1.1/series/2869/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2869","date":"2021-12-28T18:50:14","name":"[libcamera-devel,v4] v4l2: V4L2CameraProxy: Add EXPBUF as one of the supported ioctl","version":4,"mbox":"https://patchwork.libcamera.org/series/2869/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15225/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15225/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EC331BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Dec 2021 18:50:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48CC46090D;\n\tTue, 28 Dec 2021 19:50:41 +0100 (CET)","from mail-pf1-x429.google.com (mail-pf1-x429.google.com\n\t[IPv6:2607:f8b0:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FF6360868\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 19:50:39 +0100 (CET)","by mail-pf1-x429.google.com with SMTP id v13so16899315pfi.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Dec 2021 10:50:39 -0800 (PST)","from localhost.localdomain ([1.186.167.40])\n\tby smtp.googlemail.com with ESMTPSA id\n\ty37sm17364303pga.78.2021.12.28.10.50.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 28 Dec 2021 10:50:36 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"Jgsm5pnD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tLP0XldOg1Bw18eM0riUCiEGfSJEojf/dBbJZeRVWMM=;\n\tb=Jgsm5pnD1Qz+IVkTHfNU1y8BdBudmAys6Qq4+vMEhUmyE7GjnKwgk3tyv4n/yq6rRI\n\tGyK5aNViJzNwj+uE9sghWU4hwJ27Bx1wcfX7nr27RVLLpTjlomw9jPJVjTtfohxOB0L0\n\tKeMD1YFPx1/Y55907xAWt24n/Ygvt/bZyRDy3Q0WREA97Dfc34Q5JU4/aP8N0kOkEKO4\n\t4I22k6FXGRbK/fBeznxmXWOgIIstaetnyAlzi7OLnpAi40RI4fcAnAlwHS6+5ec8sxhV\n\tTPkZRgfjhYaM8XQZQJN8HwDBp1TrAwLK9L3LH4ngPD6R1lFwzbL65PfY09eD9uXOSsWf\n\t9wGg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tLP0XldOg1Bw18eM0riUCiEGfSJEojf/dBbJZeRVWMM=;\n\tb=2VnupVVL1qLnXpKep5OxMaZ9qYttPU+bMWf1IAs+M9q9Tt3g73A06NynZYB6gxSU/G\n\tsuSiwTUqaELwwlEdmDfuIBnb0Wv1n9LE3OSVsaViiGNdYEkhNwtofGh6y1SURxxyS8UN\n\tdICgklr9S6XxFKwznh+Fv4ZAtZBDt+FAxaZ7z4GrU18R9Y3cFvV2HmbftpQpHt7sEHbq\n\tsICTVVlQKvvck14Qk5bSqzl0D+drN3V2BeRUnaz89kXCheUQrUbfi8K+ZpZGvegBADDC\n\tvJeMQz11RHMMCymvgdz6BBzDh6xdBUdRZaO5lVK1woDfTzcrFKHjOiM6TJInnv0cjDZh\n\tftuQ==","X-Gm-Message-State":"AOAM533Iqj1J+z4ExSQofX9kOUEfzPQl9eaJCUVnmay4aG0MV9QkKk+f\n\tMWcWfIF70wQ4GAe/lfx/5gpDfhiGOGg=","X-Google-Smtp-Source":"ABdhPJzrqerPyoXhbcvdKJEYIep//LWiJTMvjJucUvjil43dEyPxPjOLB7gJImzPlYLYMl1Z57z/Yg==","X-Received":"by 2002:a05:6a00:114d:b0:4a2:89e6:659e with SMTP id\n\tb13-20020a056a00114d00b004a289e6659emr23309219pfm.38.1640717437204; \n\tTue, 28 Dec 2021 10:50:37 -0800 (PST)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 29 Dec 2021 00:20:14 +0530","Message-Id":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4] v4l2: V4L2CameraProxy: Add EXPBUF as\n\tone of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"To support DMABUF as one of the memory buffer, we need to implement\nEXPBUF in the v4l2 compat layer.\n\nThis patch implements vidioc_expbuf as one of the supported ioctls.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=89\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\n src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n src/v4l2/v4l2_camera_proxy.h   |  1 +\n 2 files changed, 31 insertions(+)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex c1375777c185..4d529bc29a4d 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -624,6 +624,32 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n \treturn 0;\n }\n \n+int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n+{\n+\tLOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n+\n+\tif (!hasOwnership(file))\n+\t\treturn -EBUSY;\n+\n+\t/* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n+\tif (!validateBufferType(arg->type))\n+\t\treturn -EINVAL;\n+\n+\tif (arg->index >= bufferCount_)\n+\t\treturn -EINVAL;\n+\n+\tif (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n+\t\treturn -EINVAL;\n+\n+\tmemset(arg->reserved, 0, sizeof(arg->reserved));\n+\n+\t/* \\todo honor the O_ACCMODE flags passed to this function */\n+\targ->fd = fcntl(vcam_->getBufferFd(arg->index),\n+\t\t\targ->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n+\n+\treturn 0;\n+}\n+\n int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n {\n \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n@@ -685,6 +711,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n \tVIDIOC_QUERYBUF,\n \tVIDIOC_QBUF,\n \tVIDIOC_DQBUF,\n+\tVIDIOC_EXPBUF,\n \tVIDIOC_STREAMON,\n \tVIDIOC_STREAMOFF,\n };\n@@ -755,6 +782,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n \tcase VIDIOC_DQBUF:\n \t\tret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_);\n \t\tbreak;\n+\tcase VIDIOC_EXPBUF:\n+\t\tret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n+\t\tbreak;\n \tcase VIDIOC_STREAMON:\n \t\tret = vidioc_streamon(file, static_cast<int *>(arg));\n \t\tbreak;\ndiff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\nindex fa0a49e0439b..14e027c3e7d1 100644\n--- a/src/v4l2/v4l2_camera_proxy.h\n+++ b/src/v4l2/v4l2_camera_proxy.h\n@@ -60,6 +60,7 @@ private:\n \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n \tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n \t\t\t libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);\n+\tint vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n \tint vidioc_streamon(V4L2CameraFile *file, int *arg);\n \tint vidioc_streamoff(V4L2CameraFile *file, int *arg);\n \n","prefixes":["libcamera-devel","v4"]}