From patchwork Tue Aug 18 14:37:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 256100 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 579EEC433DF for ; Tue, 18 Aug 2020 14:37:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3767E20866 for ; Tue, 18 Aug 2020 14:37:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="gvXXdzxt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727897AbgHROhg (ORCPT ); Tue, 18 Aug 2020 10:37:36 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:43841 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727891AbgHROhX (ORCPT ); Tue, 18 Aug 2020 10:37:23 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id 82jnkV8V2uuXO82jpkcevT; Tue, 18 Aug 2020 16:37:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597761441; bh=nXE++WV7vSTYUsAx1anAj5g+i8ZYaSIMkXK58BSLnyk=; h=From:To:Subject:Date:Message-Id:MIME-Version:From:Subject; b=gvXXdzxt4Q/dqFT6Q+zMQIsM4e+QmrKEHuF6qwhMgipQdJav6mDvFICexBfvXXYuY QT0t1esKEaph1Ey8yvi0zhyzPaFxQlaHmWMymfZxYuLVymVFVD5M5I7xUX7e7u9Q/9 q1pEhBssgEo9LymrZKwtYaE2QdjhClyiipjyTvFKs94vLAfIE+kCsrhM0S84Q1pyfy jqJ/FQumhUyLxwKlh7Il7LOS7vale03vFwzcvjLtFdt5op0wvcK8uSwmgolTk3qG/K RzJJ8uG7OvzN1tPJKJhLfFD1PmiEdTJKRxuvsUpfkIRmvBGzIBENdxZFfrsjkwgeFq Jow+lVmWfQIHg== From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Yunfei Dong , Dikshita Agarwal , Hans Verkuil Subject: [PATCHv2 03/12] media: document read-only requests Date: Tue, 18 Aug 2020 16:37:10 +0200 Message-Id: <20200818143719.102128-4-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> References: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfCuwSrPvT4fumm6uq5Q5WMyOX6OnYFqvqUTKnnAc42oTX5UrWuzWMQXEHZ0Xwab3bjAqBvapkeMtcnah8py0+THUdibAVA3JlkwbJKBA3FfrJVRuZCf9 MutHBxYoEallZtP/q0OB2XnCJYFdu6h4EqCQrwiCWra8okfqXdZAkac5bbCbmkYM4fe4xJG4EgawT0xEbOL5+hT3oI9SgWjgRVgJ29iPievIqXhZJd6d629a vLCVQBuRiPUnJBSOtzjJGfW8g2/2zvya2zTX+mLp3FNEr3SVaCewyR1Wov6ClyHz5BVDVJeeN6e+zXNlMbcW5xoP9uhUmaOfWpjS5OYLoWNoNuaLH/wbAw26 Wji31XDc Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch documents reaed-only requests, including the new V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS capability flag. Based in part on a patch from Yunfei Dong . Signed-off-by: Hans Verkuil --- .../media/mediactl/media-request-ioc-queue.rst | 5 +++++ .../userspace-api/media/mediactl/request-api.rst | 11 +++++++++++ .../userspace-api/media/v4l/vidioc-reqbufs.rst | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/Documentation/userspace-api/media/mediactl/media-request-ioc-queue.rst b/Documentation/userspace-api/media/mediactl/media-request-ioc-queue.rst index ad55b6b32616..4ed1b3585ce1 100644 --- a/Documentation/userspace-api/media/mediactl/media-request-ioc-queue.rst +++ b/Documentation/userspace-api/media/mediactl/media-request-ioc-queue.rst @@ -76,6 +76,11 @@ queued directly and you next try to queue a request, or vice versa. A request must contain at least one buffer, otherwise this ioctl will return an ``ENOENT`` error. +If the :ref:`buffer capabilities ` indicate that +only read-only requests are supported, then the request can only contain +buffers. If anything else is present then this ioctl will return an +``EINVAL`` error. + Return Value ============ diff --git a/Documentation/userspace-api/media/mediactl/request-api.rst b/Documentation/userspace-api/media/mediactl/request-api.rst index 37d9442a541e..88bfe8b735e8 100644 --- a/Documentation/userspace-api/media/mediactl/request-api.rst +++ b/Documentation/userspace-api/media/mediactl/request-api.rst @@ -53,6 +53,13 @@ with different configurations in advance, knowing that the configuration will be applied when needed to get the expected result. Configuration values at the time of request completion are also available for reading. +In some cases it does not make sense for user-space to associate configuration +values with a frame, instead it only makes sense to retrieving configuration +values at the time of request completion. In that case read-only requests can be +used that only allow buffers to be queued and not configuration values. Which +type of requests (regular or read-only) are supported is signalled through +:ref:`buffer capabilities `. + General Usage ------------- @@ -95,6 +102,10 @@ A queued request cannot be modified anymore. output buffers, not for capture buffers. Attempting to add a capture buffer to a request will result in an ``EBADR`` error. +If the buffer type supports only read-only requests, and the request contains +configuration values such as controls, then ``EINVAL`` is returned since no +configuration values are allowed when submitting a read-only request. + If the request contains configurations for multiple entities, individual drivers may synchronize so the requested pipeline's topology is applied before the buffers are processed. Media controller drivers do a best effort implementation diff --git a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst index 75d894d9c36c..13454146d5fc 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst @@ -134,6 +134,7 @@ aborting or finishing any DMA in progress, an implicit .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: +.. _V4L2-BUF-CAP-SUPPORTS-RO-REQUESTS: .. cssclass:: longtable @@ -154,6 +155,7 @@ aborting or finishing any DMA in progress, an implicit * - ``V4L2_BUF_CAP_SUPPORTS_REQUESTS`` - 0x00000008 - This buffer type supports :ref:`requests `. + This flag is mutually exclusive with ``V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS``. * - ``V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS`` - 0x00000010 - The kernel allows calling :ref:`VIDIOC_REQBUFS` while buffers are still @@ -172,6 +174,10 @@ aborting or finishing any DMA in progress, an implicit :ref:`V4L2_FLAG_MEMORY_NON_CONSISTENT `, :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE ` and :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN `. + * - ``V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS`` + - 0x00000080 + - This buffer type supports read-only :ref:`requests `. + This flag is mutually exclusive with ``V4L2_BUF_CAP_SUPPORTS_REQUESTS``. Return Value From patchwork Tue Aug 18 14:37:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 256103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF3D3C433E1 for ; Tue, 18 Aug 2020 14:37:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7FEA2076E for ; Tue, 18 Aug 2020 14:37:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="cOI0XVAx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbgHROhb (ORCPT ); Tue, 18 Aug 2020 10:37:31 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:36829 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727890AbgHROhX (ORCPT ); Tue, 18 Aug 2020 10:37:23 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id 82jnkV8V2uuXO82jpkcevX; Tue, 18 Aug 2020 16:37:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597761441; bh=VT1phX6EYaOI2Ic/hMC9iaTZUXrMxXUqdljNRuY8DPQ=; h=From:To:Subject:Date:Message-Id:MIME-Version:From:Subject; b=cOI0XVAxun1cfCKmFu8QbBIVC/cizaPhjgoYszkQ9tqxrEo8lurXalff7hBpEFGvx OobylfdOeIbFzumxObLVZgaUmc1JKHHWSo6+HIps9vbYp/IKYYeE2qRQiBnLH2FDX1 XrUrz3vHbSnJNARDNHd9BHsH03j7C5GTpGOJnPE3wQSV3S3Gmaplqbifb8E/uqgo5H /wEM7r28NWhI3aQTEmN9HC+MTvK67HCw2dAJBXjwMRZRD5QZd0J1yihBABqKNbKqqS nboFP9/8Ih83arCRK4NG98GfeqGEy+OTdqdmifxJbSO23m27SNwxh3GyXAZFauepmy t6VbD6re+w5qg== From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Yunfei Dong , Dikshita Agarwal , Hans Verkuil Subject: [PATCHv2 04/12] videodev2.h: add V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS Date: Tue, 18 Aug 2020 16:37:11 +0200 Message-Id: <20200818143719.102128-5-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> References: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfCuwSrPvT4fumm6uq5Q5WMyOX6OnYFqvqUTKnnAc42oTX5UrWuzWMQXEHZ0Xwab3bjAqBvapkeMtcnah8py0+THUdibAVA3JlkwbJKBA3FfrJVRuZCf9 MutHBxYoEallZtP/q0OB2XnCJYFdu6h4EqCQrwiCWra8okfqXdZAkac5bbCbmkYM4fe4xJG4EgawT0xEbOL5+hT3oI9SgWjgRVgJ29iPievIqXhZJd6d629a vLCVQBuRiPUnJBSOtzjJGfW8g2/2zvya2zTX+mLp3FNEr3SVaCewyR1Wov6ClyHz5BVDVJeeN6e+zXNlMbcW5xoP9uhUmaOfWpjS5OYLoWNoNuaLH/wbAw26 Wji31XDc Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch adds support for the V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS flag. This flag is used for Read-Only Requests. Based on a patch from Yunfei Dong . Signed-off-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-core.c | 3 +++ drivers/media/common/videobuf2/videobuf2-v4l2.c | 4 +++- drivers/media/v4l2-core/v4l2-mem2mem.c | 3 ++- include/media/videobuf2-core.h | 1 + include/uapi/linux/videodev2.h | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index f544d3393e9d..5194056129de 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2354,6 +2354,9 @@ int vb2_core_queue_init(struct vb2_queue *q) if (WARN_ON(q->requires_requests && !q->supports_requests)) return -EINVAL; + if (WARN_ON(q->supports_ro_requests && !q->supports_requests)) + return -EINVAL; + INIT_LIST_HEAD(&q->queued_list); INIT_LIST_HEAD(&q->done_list); spin_lock_init(&q->done_lock); diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 30caad27281e..9471320caaa0 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -717,7 +717,9 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps) if (q->allow_cache_hints && q->io_modes & VB2_MMAP) *caps |= V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS; #ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API - if (q->supports_requests) + if (q->supports_ro_requests) + *caps |= V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS; + else if (q->supports_requests) *caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS; #endif } diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 95a8f2dc5341..48f87cfe2f63 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -713,7 +713,8 @@ int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, vq = v4l2_m2m_get_vq(m2m_ctx, buf->type); if (V4L2_TYPE_IS_CAPTURE(vq->type) && - (buf->flags & V4L2_BUF_FLAG_REQUEST_FD)) { + (buf->flags & V4L2_BUF_FLAG_REQUEST_FD) && + !vq->supports_ro_requests) { dprintk("%s: requests cannot be used with capture buffers\n", __func__); return -EPERM; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 52ef92049073..af7ecff725a5 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -575,6 +575,7 @@ struct vb2_queue { unsigned int allow_zero_bytesused:1; unsigned int quirk_poll_must_check_waiting_for_buffers:1; unsigned int supports_requests:1; + unsigned int supports_ro_requests:1; unsigned int requires_requests:1; unsigned int uses_qbuf:1; unsigned int uses_requests:1; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index c7b70ff53bc1..7226d6d3c1e4 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -963,6 +963,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) +#define V4L2_BUF_CAP_SUPPORTS_RO_REQUESTS (1 << 7) /** * struct v4l2_plane - plane info for multi-planar buffers From patchwork Tue Aug 18 14:37:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 256104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4043CC433E1 for ; Tue, 18 Aug 2020 14:37:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D3B1207DA for ; Tue, 18 Aug 2020 14:37:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="v+tYen2/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbgHROh2 (ORCPT ); Tue, 18 Aug 2020 10:37:28 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:50027 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727892AbgHROhX (ORCPT ); Tue, 18 Aug 2020 10:37:23 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id 82jnkV8V2uuXO82jpkceve; Tue, 18 Aug 2020 16:37:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597761441; bh=Y6lbDmzt4ElLsjK1gJx6FtHmPT+QGmkuyOV4OeyNY/k=; h=From:To:Subject:Date:Message-Id:MIME-Version:From:Subject; b=v+tYen2/9+ALVSx74weU5IhkQyHKHN8tz5RB84yt38ixAQSjx+mvI01+dnmUFqfRR vBMgZgjHfLvegpZSnrjv6qsPyUGw/cZHMuQR7s+QtQk8raxxJjlVrLoC4Ucg3r9FiW ykwqnZl+KOs/xaEDjubzOeB/A0TFTxnaSSW4hIhwCBiKvrCtR6oc2SA1SKQaVX4Msm 20jxe4HFYDhCc4eukkhqRmNaQlIYkipuwjF24fkF8upvDcp6TOqy82PWgabBxHKQP5 yc0lcHkB9QDJ3SC61bo/05NNAFMht8w9ld7R1gDxu9Of50jJ6oWOFF9HgaU3tCuPLO 0THHj0VjCwsPg== From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Yunfei Dong , Dikshita Agarwal , Hans Verkuil Subject: [PATCHv2 05/12] videobuf2-core: add vb2_request_buffer_first() Date: Tue, 18 Aug 2020 16:37:12 +0200 Message-Id: <20200818143719.102128-6-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> References: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfCuwSrPvT4fumm6uq5Q5WMyOX6OnYFqvqUTKnnAc42oTX5UrWuzWMQXEHZ0Xwab3bjAqBvapkeMtcnah8py0+THUdibAVA3JlkwbJKBA3FfrJVRuZCf9 MutHBxYoEallZtP/q0OB2XnCJYFdu6h4EqCQrwiCWra8okfqXdZAkac5bbCbmkYM4fe4xJG4EgawT0xEbOL5+hT3oI9SgWjgRVgJ29iPievIqXhZJd6d629a vLCVQBuRiPUnJBSOtzjJGfW8g2/2zvya2zTX+mLp3FNEr3SVaCewyR1Wov6ClyHz5BVDVJeeN6e+zXNlMbcW5xoP9uhUmaOfWpjS5OYLoWNoNuaLH/wbAw26 Wji31XDc Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the vb2_request_buffer_first() helper function to obtain the first vb2 buffer in the request. Signed-off-by: Hans Verkuil --- .../media/common/videobuf2/videobuf2-core.c | 19 +++++++++++++++++++ include/media/videobuf2-core.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 5194056129de..01ca0add39c2 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1500,6 +1500,25 @@ unsigned int vb2_request_buffer_cnt(struct media_request *req) } EXPORT_SYMBOL_GPL(vb2_request_buffer_cnt); +struct vb2_buffer *vb2_request_buffer_first(struct media_request *req) +{ + struct media_request_object *obj; + struct vb2_buffer *vb = NULL; + unsigned long flags; + + spin_lock_irqsave(&req->lock, flags); + list_for_each_entry(obj, &req->objects, list) { + if (vb2_request_object_is_buffer(obj)) { + vb = container_of(obj, struct vb2_buffer, req_obj); + break; + } + } + spin_unlock_irqrestore(&req->lock, flags); + + return vb; +} +EXPORT_SYMBOL_GPL(vb2_request_buffer_first); + int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb) { struct vb2_buffer *vb; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index af7ecff725a5..58fbd9ef506a 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1258,4 +1258,11 @@ bool vb2_request_object_is_buffer(struct media_request_object *obj); */ unsigned int vb2_request_buffer_cnt(struct media_request *req); +/** + * vb2_request_buffer_first() - return the first buffer in the request + * + * @req: the request. + */ +struct vb2_buffer *vb2_request_buffer_first(struct media_request *req); + #endif /* _MEDIA_VIDEOBUF2_CORE_H */ From patchwork Tue Aug 18 14:37:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 256105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 075F5C433DF for ; Tue, 18 Aug 2020 14:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDC3D2076E for ; Tue, 18 Aug 2020 14:37:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="JgIvxn63" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727902AbgHROhZ (ORCPT ); Tue, 18 Aug 2020 10:37:25 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:58897 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727895AbgHROhX (ORCPT ); Tue, 18 Aug 2020 10:37:23 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id 82jnkV8V2uuXO82jpkcevx; Tue, 18 Aug 2020 16:37:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597761441; bh=itvpLW26PAwAoKzXIVYdrK7gfIgVYx+7yxm5Sz+P0W8=; h=From:To:Subject:Date:Message-Id:MIME-Version:From:Subject; b=JgIvxn63VHLlHPIUi0vAnHIfu966Ui6G92s8hzmMGopmkqHrLHNovvFOjvdv680Hb o3moYR1Td9CPaxqZMy5YeXWUOAC5aqrPvw+PXBEnZO8O9qe+BNMC10OyWrFH6uHZNq kVwNQLTv11uHTOeRuicTTqpVinjdFp5Yf/iqNzN+zS0jGsDWM1J0hQUPY15DlCVUig zJd2LpDGp72fi0YjteRCtx4LVhTKhLc/TEekBINZnoNuRY39D8NY2Phn6DccPdpiCW PQT5t1I3R+c4ymz0A2scNMwLK2aSGFVe0x1O5fOLI3v86jgW1780vTXKrIaSnirt9C 8VAFggKhPnm2Q== From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Yunfei Dong , Dikshita Agarwal , Hans Verkuil Subject: [PATCHv2 08/12] vivid: add ro_requests module option Date: Tue, 18 Aug 2020 16:37:15 +0200 Message-Id: <20200818143719.102128-9-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> References: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfCuwSrPvT4fumm6uq5Q5WMyOX6OnYFqvqUTKnnAc42oTX5UrWuzWMQXEHZ0Xwab3bjAqBvapkeMtcnah8py0+THUdibAVA3JlkwbJKBA3FfrJVRuZCf9 MutHBxYoEallZtP/q0OB2XnCJYFdu6h4EqCQrwiCWra8okfqXdZAkac5bbCbmkYM4fe4xJG4EgawT0xEbOL5+hT3oI9SgWjgRVgJ29iPievIqXhZJd6d629a vLCVQBuRiPUnJBSOtzjJGfW8g2/2zvya2zTX+mLp3FNEr3SVaCewyR1Wov6ClyHz5BVDVJeeN6e+zXNlMbcW5xoP9uhUmaOfWpjS5OYLoWNoNuaLH/wbAw26 Wji31XDc Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the ro_requests module option to test Read-Only Requests with vivid. Signed-off-by: Hans Verkuil --- Documentation/admin-guide/media/vivid.rst | 10 ++++++++++ drivers/media/test-drivers/vivid/vivid-core.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Documentation/admin-guide/media/vivid.rst b/Documentation/admin-guide/media/vivid.rst index 6d7175f96f74..423a61797a1d 100644 --- a/Documentation/admin-guide/media/vivid.rst +++ b/Documentation/admin-guide/media/vivid.rst @@ -302,6 +302,16 @@ all configurable using the following module options: - 0: forbid hints - 1: allow hints +- ro_requests: + + specifies if the capture device supports the standard Request API (i.e. + userspace can set controls in a request before queueing it), or + the Read-Only Request API (userspace can only read back controls after + the request was completed). Default is 0. + + - 0: regular requests + - 1: read-only requests + Taken together, all these module options allow you to precisely customize the driver behavior and test your application with all sorts of permutations. It is also very suitable to emulate hardware that is not yet available, e.g. diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c index c21bc27bbfeb..cc1510024b68 100644 --- a/drivers/media/test-drivers/vivid/vivid-core.c +++ b/drivers/media/test-drivers/vivid/vivid-core.c @@ -177,6 +177,14 @@ MODULE_PARM_DESC(cache_hints, " user-space cache hints, default is 0.\n" "\t\t 0 == forbid\n" "\t\t 1 == allow"); +static unsigned int ro_requests[VIVID_MAX_DEVS] = { + [0 ... (VIVID_MAX_DEVS - 1)] = 0 +}; +module_param_array(ro_requests, uint, NULL, 0444); +MODULE_PARM_DESC(ro_requests, " use read-only requests instead of regular requests, default is 0.\n" + "\t\t 0 == regular requests\n" + "\t\t 1 == read-only requests"); + static struct vivid_dev *vivid_devs[VIVID_MAX_DEVS]; const struct v4l2_rect vivid_min_rect = { @@ -869,6 +877,8 @@ static int vivid_create_queue(struct vivid_dev *dev, q->lock = &dev->mutex; q->dev = dev->v4l2_dev.dev; q->supports_requests = true; + if (V4L2_TYPE_IS_CAPTURE(buf_type)) + q->supports_ro_requests = (ro_requests[dev->inst] == 1); q->allow_cache_hints = (cache_hints[dev->inst] == 1); return vb2_queue_init(q); From patchwork Tue Aug 18 14:37:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 256101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1820FC433DF for ; Tue, 18 Aug 2020 14:37:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E515020829 for ; Tue, 18 Aug 2020 14:37:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="DqsqoQz4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727892AbgHROhc (ORCPT ); Tue, 18 Aug 2020 10:37:32 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:43599 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727897AbgHROhX (ORCPT ); Tue, 18 Aug 2020 10:37:23 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id 82jnkV8V2uuXO82jpkcew9; Tue, 18 Aug 2020 16:37:22 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1597761442; bh=OLItc/6ATCTjvCKoVPDewrpsgVS2/ejTohaXC+Gu3dQ=; h=From:To:Subject:Date:Message-Id:MIME-Version:From:Subject; b=DqsqoQz4hVBQK/O5XF2BQ99JUJIpa34oHezasDH0LFJLU/A3KRrTx2v9VX7svjAhs 11aa4bdt47W3tb/skPFq33w75JHoBhYLbJEXSslfGbYd/vp2F1TZ8x71pbRM2hCRAz qqhdLjkV1o2nccmMWIEb9+mk5O1nly9+WmvQl6hhCog1173WYniGMSngOS47DegbfC U/ZZpr/rmlh+ZbIuUk4P6Tbck2iAl44cequibE9Tej7M/HyDIVuBgACnlCSZXT+TFb NPRzTb8JUF+Y/8EMDiWUWgAq7vBRUYlMoKdZzQonxA3+B2Yf5vcni1PhZyk6hz+Jx/ tAUgrN3CKipuw== From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Yunfei Dong , Dikshita Agarwal , Hans Verkuil Subject: [PATCHv2 10/12] vim2m: use v4l2_m2m_request_validate() Date: Tue, 18 Aug 2020 16:37:17 +0200 Message-Id: <20200818143719.102128-11-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> References: <20200818143719.102128-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfP7+giVF2yARMvQzXdrB71WPzNzQPnB2vBNV1zfb1go6qlHWCQCw4uRfchZzAtnyfp0sjerWlDwxlnd+NRkCSGe+Ssx86NCHGizcu7rYZjJtzqBclj53 r5W8DV3IokiHycHwkfLGx7GvawPyJu7LvgeL0v+J5Zub5V9htD1Y7Lvh9xeGR9Cd4EmXY/ZOgOaWpXOFuskI4fyg06+A9NTsUNGJHKcnAJEnkBnNbpMlquh6 RSPY9OPI6N0AfK25Z0Ua34xg2WwfPoGnKMLfHaEK/11FnxpdlEvGGMBQWw4nEX0/ro4KOZzEG/+iGxGiB8Qu7HaGmA2IF0gVJ8N25ZZqX0btdRWZiCCj9pku dZHPYtPI Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use v4l2_m2m_request_validate() instead of vb2_request_validate. The v4l2_m2m_request_validate() ensures that a control handler request object is added if it was missing. Signed-off-by: Hans Verkuil --- drivers/media/test-drivers/vim2m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c index a776bb8e0e09..b73de65c0006 100644 --- a/drivers/media/test-drivers/vim2m.c +++ b/drivers/media/test-drivers/vim2m.c @@ -1230,6 +1230,7 @@ static int vim2m_open(struct file *file) goto open_unlock; } + ctx->fh.m2m_ctx->req_ctrl_handler = hdl; v4l2_fh_add(&ctx->fh); atomic_inc(&dev->num_inst); @@ -1299,7 +1300,7 @@ static const struct v4l2_m2m_ops m2m_ops = { }; static const struct media_device_ops m2m_media_ops = { - .req_validate = vb2_request_validate, + .req_validate = v4l2_m2m_request_validate, .req_queue = v4l2_m2m_request_queue, };