From patchwork Mon Dec 3 13:51:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26B7A1731 for ; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 154322AFDF for ; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 078162B018; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0F6B2AFDF for ; Mon, 3 Dec 2018 13:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725947AbeLCNw4 (ORCPT ); Mon, 3 Dec 2018 08:52:56 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:56335 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbeLCNwz (ORCPT ); Mon, 3 Dec 2018 08:52:55 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodXgJCsx; Mon, 03 Dec 2018 14:51:48 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 1/9] videodev2.h: add tag support Date: Mon, 3 Dec 2018 14:51:35 +0100 Message-Id: <20181203135143.45487-2-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfPKm7D+DcfHMGZkh0Vmoy61UBV91Vf1Rj8UM12ORSLzvEbyS3z3RlW8JyJQVGkHQRahvdJWe05zLbDxqCm5facgqL0wYb0EvQTvH3JuEpI/btjq7GOz5 DsTS4A7LRafkreYJmOmni290t6bcfZxg5ZEhsIka2zeOQwee3CknngkOTayH0WiomOTiuxBlO6B3Wf7KlUa4jvXdfx7EijbtUtDa2s8cktJTykh/5y5RKEpf pb6QfZ3Msd7R4UZH14TgRvypQVzBaL6+AgrylLXpZ6GDh1toxr54SumvKSIqTwCIqckEhoRXr+qj+pUxaYirSw9tODaAaQTHfFGE56SHG32qClK+DQW3863O +DZlLb9jBtX05Mmnvpyk0Blu8m5RXvpKwDsChR7YYI15Gps1OJE44MF3A4HnHXSeB6Q4V94bO2T2Vg5AI26jtZH7xdK8Zg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Add support for 'tags' to struct v4l2_buffer. These can be used by m2m devices so userspace can set a tag for an output buffer and this value will then be copied to the capture buffer(s). This tag can be used to refer to capture buffers, something that is needed by stateless HW codecs. The new V4L2_BUF_CAP_SUPPORTS_TAGS capability indicates whether or not tags are supported. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- include/uapi/linux/videodev2.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 2a223835214c..99b2b13a5757 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -880,6 +880,7 @@ struct v4l2_requestbuffers { #define V4L2_BUF_CAP_SUPPORTS_DMABUF (1 << 2) #define V4L2_BUF_CAP_SUPPORTS_REQUESTS (1 << 3) #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) +#define V4L2_BUF_CAP_SUPPORTS_TAGS (1 << 5) /** * struct v4l2_plane - plane info for multi-planar buffers @@ -924,6 +925,7 @@ struct v4l2_plane { * @field: enum v4l2_field; field order of the image in the buffer * @timestamp: frame timestamp * @timecode: frame timecode + * @tag: buffer tag * @sequence: sequence count of this frame * @memory: enum v4l2_memory; the method, in which the actual video data is * passed @@ -951,7 +953,10 @@ struct v4l2_buffer { __u32 flags; __u32 field; struct timeval timestamp; - struct v4l2_timecode timecode; + union { + struct v4l2_timecode timecode; + __u32 tag; + }; __u32 sequence; /* memory location */ @@ -989,6 +994,8 @@ struct v4l2_buffer { #define V4L2_BUF_FLAG_IN_REQUEST 0x00000080 /* timecode field is valid */ #define V4L2_BUF_FLAG_TIMECODE 0x00000100 +/* tag field is valid */ +#define V4L2_BUF_FLAG_TAG 0x00000200 /* Buffer is prepared for queuing */ #define V4L2_BUF_FLAG_PREPARED 0x00000400 /* Cache handling flags */ From patchwork Mon Dec 3 13:51:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEC5A18A7 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF4512AF57 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D36052B015; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EC452B020 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:51490 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbeLCNw5 (ORCPT ); Mon, 3 Dec 2018 08:52:57 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodYgJCt9; Mon, 03 Dec 2018 14:51:48 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 2/9] vb2: add tag support Date: Mon, 3 Dec 2018 14:51:36 +0100 Message-Id: <20181203135143.45487-3-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfPKm7D+DcfHMGZkh0Vmoy61UBV91Vf1Rj8UM12ORSLzvEbyS3z3RlW8JyJQVGkHQRahvdJWe05zLbDxqCm5facgqL0wYb0EvQTvH3JuEpI/btjq7GOz5 DsTS4A7LRafkreYJmOmni290t6bcfZxg5ZEhsIka2zeOQwee3CknngkOTayH0WiomOTiuxBlO6B3Wf7KlUa4jvXdfx7EijbtUtDa2s8cktJTykh/5y5RKEpf pb6QfZ3Msd7R4UZH14TgRvypQVzBaL6+AgrylLXpZ6GDh1toxr54SumvKSIqTwCIqckEhoRXr+qj+pUxaYirSw9tODaAaQTHfFGE56SHG32qClK+DQW3863O +DZlLb9jBtX05Mmnvpyk0Blu8m5RXvpKwDsChR7YYI15Gps1OJE44MF3A4HnHXSeB6Q4V94bO2T2Vg5AI26jtZH7xdK8Zg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Add support for tags to vb2. Besides just storing and setting the tag this patch also adds the vb2_find_tag() function that can be used to find a buffer with the given tag. This function will only look at DEQUEUED and DONE buffers, i.e. buffers that are already processed. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- .../media/common/videobuf2/videobuf2-v4l2.c | 43 ++++++++++++++++--- include/media/videobuf2-v4l2.h | 21 ++++++++- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 1244c246d0c4..ecbf4f0755cb 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -50,7 +50,8 @@ module_param(debug, int, 0644); V4L2_BUF_FLAG_TIMESTAMP_MASK) /* Output buffer flags that should be passed on to the driver */ #define V4L2_BUFFER_OUT_FLAGS (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \ - V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE) + V4L2_BUF_FLAG_KEYFRAME | \ + V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TAG) /* * __verify_planes_array() - verify that the planes array passed in struct @@ -144,8 +145,11 @@ static void __copy_timestamp(struct vb2_buffer *vb, const void *pb) */ if (q->copy_timestamp) vb->timestamp = timeval_to_ns(&b->timestamp); - vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; - if (b->flags & V4L2_BUF_FLAG_TIMECODE) + vbuf->flags |= b->flags & + (V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TAG); + if (b->flags & V4L2_BUF_FLAG_TAG) + vbuf->tag = b->tag; + else if (b->flags & V4L2_BUF_FLAG_TIMECODE) vbuf->timecode = b->timecode; } }; @@ -194,6 +198,7 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b } vbuf->sequence = 0; vbuf->request_fd = -1; + vbuf->tag = 0; if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { switch (b->memory) { @@ -313,13 +318,19 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b } if (V4L2_TYPE_IS_OUTPUT(b->type)) { + if ((b->flags & V4L2_BUF_FLAG_TIMECODE) && + (b->flags & V4L2_BUF_FLAG_TAG)) { + dprintk(1, "buffer flag TIMECODE cannot be combined with flag TAG\n"); + return -EINVAL; + } + /* * For output buffers mask out the timecode flag: * this will be handled later in vb2_qbuf(). * The 'field' is valid metadata for this output buffer * and so that needs to be copied here. */ - vbuf->flags &= ~V4L2_BUF_FLAG_TIMECODE; + vbuf->flags &= ~(V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TAG); vbuf->field = b->field; } else { /* Zero any output buffer flags as this is a capture buffer */ @@ -460,7 +471,10 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) b->flags = vbuf->flags; b->field = vbuf->field; b->timestamp = ns_to_timeval(vb->timestamp); - b->timecode = vbuf->timecode; + if (b->flags & V4L2_BUF_FLAG_TAG) + b->tag = vbuf->tag; + else if (b->flags & V4L2_BUF_FLAG_TIMECODE) + b->timecode = vbuf->timecode; b->sequence = vbuf->sequence; b->reserved2 = 0; b->request_fd = 0; @@ -586,6 +600,25 @@ static const struct vb2_buf_ops v4l2_buf_ops = { .copy_timestamp = __copy_timestamp, }; +int vb2_find_tag(const struct vb2_queue *q, u32 tag, + unsigned int start_idx) +{ + unsigned int i; + + for (i = start_idx; i < q->num_buffers; i++) { + struct vb2_buffer *vb = q->bufs[i]; + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + + if ((vb->state == VB2_BUF_STATE_DEQUEUED || + vb->state == VB2_BUF_STATE_DONE) && + (vbuf->flags & V4L2_BUF_FLAG_TAG) && + vbuf->tag == tag) + return i; + } + return -1; +} +EXPORT_SYMBOL_GPL(vb2_find_tag); + /* * vb2_querybuf() - query video buffer information * @q: videobuf queue diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 727855463838..c2a541af6b2c 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -31,8 +31,9 @@ * @field: field order of the image in the buffer, as defined by * &enum v4l2_field. * @timecode: frame timecode. + * @tag: user specified buffer tag value. * @sequence: sequence count of this frame. - * @request_fd: the request_fd associated with this buffer + * @request_fd: the request_fd associated with this buffer. * @planes: plane information (userptr/fd, length, bytesused, data_offset). * * Should contain enough information to be able to cover all the fields @@ -44,6 +45,7 @@ struct vb2_v4l2_buffer { __u32 flags; __u32 field; struct v4l2_timecode timecode; + __u32 tag; __u32 sequence; __s32 request_fd; struct vb2_plane planes[VB2_MAX_PLANES]; @@ -55,6 +57,23 @@ struct vb2_v4l2_buffer { #define to_vb2_v4l2_buffer(vb) \ container_of(vb, struct vb2_v4l2_buffer, vb2_buf) +/** + * vb2_find_tag() - Find buffer with given tag in the queue + * + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @tag: the tag to find. Only buffers in state DEQUEUED or DONE + * are considered. + * @start_idx: the start index (usually 0) in the buffer array to start + * searching from. Note that there may be multiple buffers + * with the same tag value, so you can restart the search + * by setting @start_idx to the previously found index + 1. + * + * Returns the buffer index of the buffer with the given @tag, or + * -1 if no buffer with @tag was found. + */ +int vb2_find_tag(const struct vb2_queue *q, u32 tag, + unsigned int start_idx); + int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); /** From patchwork Mon Dec 3 13:51:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709605 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73B2813AF for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 632072B015 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 579D22B021; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07EF72B015 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbeLCNw5 (ORCPT ); Mon, 3 Dec 2018 08:52:57 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:38682 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeLCNw4 (ORCPT ); Mon, 3 Dec 2018 08:52:56 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodYgJCtT; Mon, 03 Dec 2018 14:51:49 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 3/9] v4l2-ioctl.c: log v4l2_buffer tag Date: Mon, 3 Dec 2018 14:51:37 +0100 Message-Id: <20181203135143.45487-4-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfMXm6jLv2Eo43/UtInbvT2v0hLznuwIKS2qV71CzSNfqvPfQ8/pcy2z0zacxjmPV1MaJk4yhMY83qyncG48w0Zk5PxhnGJsHRpmB+0EI46KJh7biKxAI jUmEieVAddT5N5r/6UZf5ZR8ryk/qxeebYc5qhR/wkhnllV1kbBEa66n5MHMRI8vTdMYUgVNRvbV2PmuwDyY/ra+o61IueVSAbMlTsWsvRXXIw6rHxyHFC/g wGtN1FKj9ZO4PwPE4ZGCSu9Nir4uAejRiTNv+iNSH5fEMW80gsoEebPcv54KkXhagk3+c40Xraud2ltnCfPeEJtagsDYuXy27DnOkGl+Erxng+Ydj4e803sH agZNIUbZgPIOksS5hyvr6/WSyBBxJDEnwOXVQaTGKvF7G0usvvr3zokszpcjSWU3SnmQmwYuvS5Eebc1UnX28kT6BKqu2w== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil When debugging is on, log the new tag field of struct v4l2_buffer as well. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index e384142d2826..653497f31104 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -498,9 +498,12 @@ static void v4l_print_buffer(const void *arg, bool write_only) p->bytesused, p->m.userptr, p->length); } - printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, flags=0x%08x, frames=%d, userbits=0x%08x\n", - tc->hours, tc->minutes, tc->seconds, - tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); + if (p->flags & V4L2_BUF_FLAG_TAG) + printk(KERN_DEBUG "tag=%x\n", p->tag); + else if (p->flags & V4L2_BUF_FLAG_TIMECODE) + printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, flags=0x%08x, frames=%d, userbits=0x%08x\n", + tc->hours, tc->minutes, tc->seconds, + tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); } static void v4l_print_exportbuffer(const void *arg, bool write_only) From patchwork Mon Dec 3 13:51:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A12B13AF for ; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A28B2AFE9 for ; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E87B2AFF5; Mon, 3 Dec 2018 13:51:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E03F62B01C for ; Mon, 3 Dec 2018 13:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725989AbeLCNw5 (ORCPT ); Mon, 3 Dec 2018 08:52:57 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:59036 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbeLCNw5 (ORCPT ); Mon, 3 Dec 2018 08:52:57 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodZgJCti; Mon, 03 Dec 2018 14:51:49 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 4/9] buffer.rst: document the new buffer tag feature. Date: Mon, 3 Dec 2018 14:51:38 +0100 Message-Id: <20181203135143.45487-5-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfMXm6jLv2Eo43/UtInbvT2v0hLznuwIKS2qV71CzSNfqvPfQ8/pcy2z0zacxjmPV1MaJk4yhMY83qyncG48w0Zk5PxhnGJsHRpmB+0EI46KJh7biKxAI jUmEieVAddT5N5r/6UZf5ZR8ryk/qxeebYc5qhR/wkhnllV1kbBEa66n5MHMRI8vTdMYUgVNRvbV2PmuwDyY/ra+o61IueVSAbMlTsWsvRXXIw6rHxyHFC/g wGtN1FKj9ZO4PwPE4ZGCSu9Nir4uAejRiTNv+iNSH5fEMW80gsoEebPcv54KkXhagk3+c40Xraud2ltnCfPeEJtagsDYuXy27DnOkGl+Erxng+Ydj4e803sH agZNIUbZgPIOksS5hyvr6/WSyBBxJDEnwOXVQaTGKvF7G0usvvr3zokszpcjSWU3SnmQmwYuvS5Eebc1UnX28kT6BKqu2w== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Document V4L2_BUF_FLAG_TAG. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- Documentation/media/uapi/v4l/buffer.rst | 32 ++++++++++++++----- .../media/uapi/v4l/vidioc-reqbufs.rst | 4 +++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst index 2e266d32470a..3c09a94c5a10 100644 --- a/Documentation/media/uapi/v4l/buffer.rst +++ b/Documentation/media/uapi/v4l/buffer.rst @@ -220,17 +220,25 @@ struct v4l2_buffer use ``V4L2_BUF_FLAG_TIMESTAMP_COPY`` the application has to fill in the timestamp which will be copied by the driver to the capture stream. - * - struct :c:type:`v4l2_timecode` + * - union + * - + - struct :c:type:`v4l2_timecode` - ``timecode`` - - - - When ``type`` is ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` and the - ``V4L2_BUF_FLAG_TIMECODE`` flag is set in ``flags``, this + - When the ``V4L2_BUF_FLAG_TIMECODE`` flag is set in ``flags``, this structure contains a frame timecode. In :c:type:`V4L2_FIELD_ALTERNATE ` mode the top and bottom field contain the same timecode. Timecodes are intended to help video editing and are typically recorded on video tapes, but also embedded in compressed formats like MPEG. This field is independent of the ``timestamp`` and ``sequence`` fields. + * - + - __u32 + - ``tag`` + - When the ``V4L2_BUF_FLAG_TAG`` flag is set in ``flags``, this + field contains a user-specified tag value. + + It is used by stateless codecs where this tag can be used to + refer to buffers that contain reference frames. * - __u32 - ``sequence`` - @@ -567,6 +575,14 @@ Buffer Flags when the ``VIDIOC_DQBUF`` ioctl is called. Applications can set this bit and the corresponding ``timecode`` structure when ``type`` refers to an output stream. + * .. _`V4L2-BUF-FLAG-TAG`: + + - ``V4L2_BUF_FLAG_TAG`` + - 0x00000200 + - The ``tag`` field is valid. Applications can set + this bit and the corresponding ``tag`` field. If tags are + supported then the ``V4L2_BUF_CAP_SUPPORTS_TAGS`` capability + is also set. * .. _`V4L2-BUF-FLAG-PREPARED`: - ``V4L2_BUF_FLAG_PREPARED`` @@ -704,10 +720,10 @@ enum v4l2_memory Timecodes ========= -The struct :c:type:`v4l2_timecode` structure is designed to hold a -:ref:`smpte12m` or similar timecode. (struct -struct :c:type:`timeval` timestamps are stored in struct -:c:type:`v4l2_buffer` field ``timestamp``.) +The :c:type:`v4l2_buffer_timecode` structure is designed to hold a +:ref:`smpte12m` or similar timecode. +(struct :c:type:`timeval` timestamps are stored in the struct +:c:type:`v4l2_buffer` ``timestamp`` field.) .. c:type:: v4l2_timecode diff --git a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst index e62a15782790..38a7d0aee483 100644 --- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst +++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst @@ -118,6 +118,7 @@ aborting or finishing any DMA in progress, an implicit .. _V4L2-BUF-CAP-SUPPORTS-DMABUF: .. _V4L2-BUF-CAP-SUPPORTS-REQUESTS: .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: +.. _V4L2-BUF-CAP-SUPPORTS-TAGS: .. cssclass:: longtable @@ -143,6 +144,9 @@ aborting or finishing any DMA in progress, an implicit - The kernel allows calling :ref:`VIDIOC_REQBUFS` while buffers are still mapped or exported via DMABUF. These orphaned buffers will be freed when they are unmapped or when the exported DMABUF fds are closed. + * - ``V4L2_BUF_CAP_SUPPORTS_TAGS`` + - 0x00000020 + - This buffer type supports ``V4L2_BUF_FLAG_TAG``. Return Value ============ From patchwork Mon Dec 3 13:51:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A35B01731 for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9460D2AF57 for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 884A22B015; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 240812AF57 for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:37961 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodZgJCu4; Mon, 03 Dec 2018 14:51:50 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 5/9] v4l2-mem2mem: add v4l2_m2m_buf_copy_data helper function Date: Mon, 3 Dec 2018 14:51:39 +0100 Message-Id: <20181203135143.45487-6-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKvZrTWFyJx5pqld1EVIEexBmLhyizlWuNyDdaPsLhiZjTL3JFPHYa34FOP0nyOy9q50mQp93g4ApLr0HUY86TtfGCyz46iOQWpkWro617FhfcbTGQI4 ApQMev5MqpOqf3mzN+DYAP+xtkhi4LO6QPuj9bqIq2MR94kvaf/lfF9gfUcs03RNcccrQwjjjkKzL4P+RZtp9sdwLciTZwFlQ2I941SwLCjsMxm//Wepnsw0 PycFewz056fZ8pr4y/QBhQJGqLGOat38KYvkpkGV+k0EIK0lmcD6DvCcOtEw9y+iSVRJ8XzQO4mMyE6jhX6+N4ADv/VqcdnVSZB0dGy/tGIE9mCBwqGLWL8Q NWfXecWJSCOqbWPCBLMnGWnylcGoyfeKLaZkzDG1QEaF+FsKA/ehnDCUfckDp6oTUcY4kROesxllcqiQoscbpuUZYjMUdw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Memory-to-memory devices should copy various parts of struct v4l2_buffer from the output buffer to the capture buffer. Add a helper function that does that to simplify the driver code. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/v4l2-core/v4l2-mem2mem.c | 23 +++++++++++++++++++++++ include/media/v4l2-mem2mem.h | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 5bbdec55b7d7..a9cb1ac33dc0 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -975,6 +975,29 @@ void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, } EXPORT_SYMBOL_GPL(v4l2_m2m_buf_queue); +void v4l2_m2m_buf_copy_data(const struct vb2_v4l2_buffer *out_vb, + struct vb2_v4l2_buffer *cap_vb, + bool copy_frame_flags) +{ + u32 mask = V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TAG | + V4L2_BUF_FLAG_TSTAMP_SRC_MASK; + + if (copy_frame_flags) + mask |= V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_PFRAME | + V4L2_BUF_FLAG_BFRAME; + + cap_vb->vb2_buf.timestamp = out_vb->vb2_buf.timestamp; + + if (out_vb->flags & V4L2_BUF_FLAG_TAG) + cap_vb->tag = out_vb->tag; + if (out_vb->flags & V4L2_BUF_FLAG_TIMECODE) + cap_vb->timecode = out_vb->timecode; + cap_vb->field = out_vb->field; + cap_vb->flags &= ~mask; + cap_vb->flags |= out_vb->flags & mask; +} +EXPORT_SYMBOL_GPL(v4l2_m2m_buf_copy_data); + void v4l2_m2m_request_queue(struct media_request *req) { struct media_request_object *obj, *obj_safe; diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 5467264771ec..bb4feb6969d2 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -622,6 +622,27 @@ v4l2_m2m_dst_buf_remove_by_idx(struct v4l2_m2m_ctx *m2m_ctx, unsigned int idx) return v4l2_m2m_buf_remove_by_idx(&m2m_ctx->cap_q_ctx, idx); } +/** + * v4l2_m2m_buf_copy_data() - copy buffer data from the output buffer to the + * capture buffer + * + * @out_vb: the output buffer that is the source of the data. + * @cap_vb: the capture buffer that will receive the data. + * @copy_frame_flags: copy the KEY/B/PFRAME flags as well. + * + * This helper function copies the timestamp, timecode (if the TIMECODE + * buffer flag was set), tag (if the TAG buffer flag was set), field + * and the TIMECODE, TAG, KEYFRAME, BFRAME, PFRAME and TSTAMP_SRC_MASK + * flags from @out_vb to @cap_vb. + * + * If @copy_frame_flags is false, then the KEYFRAME, BFRAME and PFRAME + * flags are not copied. This is typically needed for encoders that + * set this bits explicitly. + */ +void v4l2_m2m_buf_copy_data(const struct vb2_v4l2_buffer *out_vb, + struct vb2_v4l2_buffer *cap_vb, + bool copy_frame_flags); + /* v4l2 request helper */ void v4l2_m2m_request_queue(struct media_request *req); From patchwork Mon Dec 3 13:51:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2865F13AF for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 194952AFDE for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D4CD2AFD6; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92BB62B018 for ; Mon, 3 Dec 2018 13:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726082AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:60316 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodagJCuO; Mon, 03 Dec 2018 14:51:50 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 6/9] vb2: add new supports_tags queue flag Date: Mon, 3 Dec 2018 14:51:40 +0100 Message-Id: <20181203135143.45487-7-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKvZrTWFyJx5pqld1EVIEexBmLhyizlWuNyDdaPsLhiZjTL3JFPHYa34FOP0nyOy9q50mQp93g4ApLr0HUY86TtfGCyz46iOQWpkWro617FhfcbTGQI4 ApQMev5MqpOqf3mzN+DYAP+xtkhi4LO6QPuj9bqIq2MR94kvaf/lfF9gfUcs03RNcccrQwjjjkKzL4P+RZtp9sdwLciTZwFlQ2I941SwLCjsMxm//Wepnsw0 PycFewz056fZ8pr4y/QBhQJGqLGOat38KYvkpkGV+k0EIK0lmcD6DvCcOtEw9y+iSVRJ8XzQO4mMyE6jhX6+N4ADv/VqcdnVSZB0dGy/tGIE9mCBwqGLWL8Q NWfXecWJSCOqbWPCBLMnGWnylcGoyfeKLaZkzDG1QEaF+FsKA/ehnDCUfckDp6oTUcY4kROesxllcqiQoscbpuUZYjMUdw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Add new flag to indicate that buffer tags are supported. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 ++ include/media/videobuf2-core.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index ecbf4f0755cb..189dd7fb12c0 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -665,6 +665,8 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps) *caps |= V4L2_BUF_CAP_SUPPORTS_DMABUF; if (q->supports_requests) *caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS; + if (q->supports_tags) + *caps |= V4L2_BUF_CAP_SUPPORTS_TAGS; } int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index e86981d615ae..81f2dbfd0094 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -473,6 +473,7 @@ struct vb2_buf_ops { * has not been called. This is a vb1 idiom that has been adopted * also by vb2. * @supports_requests: this queue supports the Request API. + * @supports_tags: this queue supports tags in struct v4l2_buffer. * @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first * time this is called. Set to 0 when the queue is canceled. * If this is 1, then you cannot queue buffers from a request. @@ -547,6 +548,7 @@ struct vb2_queue { unsigned allow_zero_bytesused:1; unsigned quirk_poll_must_check_waiting_for_buffers:1; unsigned supports_requests:1; + unsigned supports_tags:1; unsigned uses_qbuf:1; unsigned uses_requests:1; From patchwork Mon Dec 3 13:51:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 553B013AF for ; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CC6E2AFDE for ; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CC092B007; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A122AFE7 for ; Mon, 3 Dec 2018 13:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbeLCNxA (ORCPT ); Mon, 3 Dec 2018 08:53:00 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:51384 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodagJCug; Mon, 03 Dec 2018 14:51:51 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 7/9] vim2m: add tag support Date: Mon, 3 Dec 2018 14:51:41 +0100 Message-Id: <20181203135143.45487-8-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfA6GOB1FMkYJlcf+3ZEuX75mlo4mkglfzvf2fzALXrSlSLf/hwGmPh7bZ4jleKZYp50SpxtDEemIyPuKvRvmUjnOOXrS1Un50C6KBSTF1Zvw6Qcctf1G xkpCKN/vrOVV995bg8MzYq3RBhyCrjDXGpQLs9GnfGFKuOBkNgtjwNQIvCrKBkuKt4usF43DXX1+o0QLoa3mL3dl19tKjhsFoF3IrHpWZWJ/vEflJJqic7vP gC81LCAOvhQUa/R8WNn1JBGJvu9ngl6tZOL7tg+Uvku2AlBdFxowtC4PmmpEtPFB7vavBz03vsZObDv9ROa/aL9wIeVzfu8TToL2hlFa6JHvugWyrzZmT8EY TVGxB/p24d6K/GevWPS7bF/6ME/naOtovRmvbWwJkJCdnlLTkZInlmlKChw830u5rqYvGYDTy3WaPRIBWz64XFQjng+1tw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Copy tags in vim2m. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/platform/vim2m.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c index d01821a6906a..be328483a53a 100644 --- a/drivers/media/platform/vim2m.c +++ b/drivers/media/platform/vim2m.c @@ -241,17 +241,7 @@ static int device_process(struct vim2m_ctx *ctx, out_vb->sequence = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; in_vb->sequence = q_data->sequence++; - out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp; - - if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) - out_vb->timecode = in_vb->timecode; - out_vb->field = in_vb->field; - out_vb->flags = in_vb->flags & - (V4L2_BUF_FLAG_TIMECODE | - V4L2_BUF_FLAG_KEYFRAME | - V4L2_BUF_FLAG_PFRAME | - V4L2_BUF_FLAG_BFRAME | - V4L2_BUF_FLAG_TSTAMP_SRC_MASK); + v4l2_m2m_buf_copy_data(out_vb, in_vb, true); switch (ctx->mode) { case MEM2MEM_HFLIP | MEM2MEM_VFLIP: @@ -855,6 +845,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; src_vq->lock = &ctx->dev->dev_mutex; src_vq->supports_requests = true; + src_vq->supports_tags = true; ret = vb2_queue_init(src_vq); if (ret) @@ -868,6 +859,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = &ctx->dev->dev_mutex; + dst_vq->supports_tags = true; return vb2_queue_init(dst_vq); } From patchwork Mon Dec 3 13:51:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07C371731 for ; Mon, 3 Dec 2018 13:51:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E78072AFE7 for ; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D98542AFF6; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5890C2AFE7 for ; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbeLCNw7 (ORCPT ); Mon, 3 Dec 2018 08:52:59 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:38682 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbeLCNw6 (ORCPT ); Mon, 3 Dec 2018 08:52:58 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodbgJCv9; Mon, 03 Dec 2018 14:51:51 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 8/9] vicodec: add tag support Date: Mon, 3 Dec 2018 14:51:42 +0100 Message-Id: <20181203135143.45487-9-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfA6GOB1FMkYJlcf+3ZEuX75mlo4mkglfzvf2fzALXrSlSLf/hwGmPh7bZ4jleKZYp50SpxtDEemIyPuKvRvmUjnOOXrS1Un50C6KBSTF1Zvw6Qcctf1G xkpCKN/vrOVV995bg8MzYq3RBhyCrjDXGpQLs9GnfGFKuOBkNgtjwNQIvCrKBkuKt4usF43DXX1+o0QLoa3mL3dl19tKjhsFoF3IrHpWZWJ/vEflJJqic7vP gC81LCAOvhQUa/R8WNn1JBGJvu9ngl6tZOL7tg+Uvku2AlBdFxowtC4PmmpEtPFB7vavBz03vsZObDv9ROa/aL9wIeVzfu8TToL2hlFa6JHvugWyrzZmT8EY TVGxB/p24d6K/GevWPS7bF/6ME/naOtovRmvbWwJkJCdnlLTkZInlmlKChw830u5rqYvGYDTy3WaPRIBWz64XFQjng+1tw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Copy tags in vicodec. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/platform/vicodec/vicodec-core.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c index b7bdfe97215b..4d39ea033653 100644 --- a/drivers/media/platform/vicodec/vicodec-core.c +++ b/drivers/media/platform/vicodec/vicodec-core.c @@ -190,18 +190,8 @@ static int device_process(struct vicodec_ctx *ctx, } out_vb->sequence = q_cap->sequence++; - out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp; - - if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) - out_vb->timecode = in_vb->timecode; - out_vb->field = in_vb->field; out_vb->flags &= ~V4L2_BUF_FLAG_LAST; - out_vb->flags |= in_vb->flags & - (V4L2_BUF_FLAG_TIMECODE | - V4L2_BUF_FLAG_KEYFRAME | - V4L2_BUF_FLAG_PFRAME | - V4L2_BUF_FLAG_BFRAME | - V4L2_BUF_FLAG_TSTAMP_SRC_MASK); + v4l2_m2m_buf_copy_data(in_vb, out_vb, !ctx->is_enc); return 0; } @@ -1083,6 +1073,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; src_vq->lock = ctx->is_enc ? &ctx->dev->enc_mutex : &ctx->dev->dec_mutex; + src_vq->supports_tags = true; ret = vb2_queue_init(src_vq); if (ret) @@ -1098,6 +1089,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = src_vq->lock; + dst_vq->supports_tags = true; return vb2_queue_init(dst_vq); } From patchwork Mon Dec 3 13:51:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10709617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80D9E18A7 for ; Mon, 3 Dec 2018 13:51:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 703202AFDE for ; Mon, 3 Dec 2018 13:51:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 641A72AFE7; Mon, 3 Dec 2018 13:51:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE8932B018 for ; Mon, 3 Dec 2018 13:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbeLCNxB (ORCPT ); Mon, 3 Dec 2018 08:53:01 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:44436 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbeLCNxA (ORCPT ); Mon, 3 Dec 2018 08:53:00 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id TodTgVSsf3Hr7TodbgJCvS; Mon, 03 Dec 2018 14:51:52 +0100 From: hverkuil-cisco@xs4all.nl To: linux-media@vger.kernel.org Cc: Alexandre Courbot , maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com, tfiga@chromium.org, nicolas@ndufresne.ca, sakari.ailus@linux.intel.com, Hans Verkuil Subject: [PATCHv3 9/9] cedrus: add tag support Date: Mon, 3 Dec 2018 14:51:43 +0100 Message-Id: <20181203135143.45487-10-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> References: <20181203135143.45487-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfLvALL4h94gbKbgJdGrcbOoNTipBrc9TJCNi8zho9fz5lmfYJPVCrFBChfu3KGqFSxdT9DnLK3EEIk5jC8ECRvcu9wzlrrxocoe4fB0gZwVbGxH0/03w 6bN8UTxgJK/N9599s5LzbVkQsfchZIE6zZ6SSiLnrcHWiwU4Q9U4pQ5DPY6BY/aUZneENJ9pif1ZCVA6blbtdwhjXimAK6SPLexNZw5mgk20/S37i3kd8SBV rsnXXNV3lTVZIMI/QQA+M6Cn+hiT0TZL0RdPtxjOwQYwJkIZRIN56nYOiLIEbAh4s2iEyHB5zXpq1JUt3UOZ/NbhmYOs+DB/jE3CTRR2RK1zNhhuI4LL+OyZ zOmaoKfnbQ1I14WkGovU9Df0WGjTJkv6XlR3WdUB5z6qgth+Kyb5Olm/dQMIka1kpzZKwmfP2lD2b9vtHS6lNLS3uWHJeQ== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Replace old reference frame indices by new tag method. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- drivers/media/v4l2-core/v4l2-ctrls.c | 9 -------- drivers/staging/media/sunxi/cedrus/cedrus.h | 9 +++++--- .../staging/media/sunxi/cedrus/cedrus_dec.c | 2 ++ .../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 21 ++++++++----------- .../staging/media/sunxi/cedrus/cedrus_video.c | 2 ++ include/uapi/linux/v4l2-controls.h | 14 +++++-------- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 5f2b033a7a42..b854cceb19dc 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1660,15 +1660,6 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, return -EINVAL; } - if (p_mpeg2_slice_params->backward_ref_index >= VIDEO_MAX_FRAME || - p_mpeg2_slice_params->forward_ref_index >= VIDEO_MAX_FRAME) - return -EINVAL; - - if (p_mpeg2_slice_params->pad || - p_mpeg2_slice_params->picture.pad || - p_mpeg2_slice_params->sequence.pad) - return -EINVAL; - return 0; case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION: diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h index 3f61248c57ac..781676b55a1b 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.h +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h @@ -142,11 +142,14 @@ static inline dma_addr_t cedrus_buf_addr(struct vb2_buffer *buf, } static inline dma_addr_t cedrus_dst_buf_addr(struct cedrus_ctx *ctx, - unsigned int index, - unsigned int plane) + int index, unsigned int plane) { - struct vb2_buffer *buf = ctx->dst_bufs[index]; + struct vb2_buffer *buf; + if (index < 0) + return 0; + + buf = ctx->dst_bufs[index]; return buf ? cedrus_buf_addr(buf, &ctx->dst_fmt, plane) : 0; } diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index e40180a33951..0cfd6036d0cd 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -53,6 +53,8 @@ void cedrus_device_run(void *priv) break; } + v4l2_m2m_buf_copy_data(run.src, run.dst, true); + dev->dec_ops[ctx->current_codec]->setup(ctx, &run); spin_unlock_irqrestore(&ctx->dev->irq_lock, flags); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c index 9abd39cae38c..fdde9a099153 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c @@ -82,7 +82,10 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) dma_addr_t fwd_luma_addr, fwd_chroma_addr; dma_addr_t bwd_luma_addr, bwd_chroma_addr; struct cedrus_dev *dev = ctx->dev; + struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q; const u8 *matrix; + int forward_idx; + int backward_idx; unsigned int i; u32 reg; @@ -156,23 +159,17 @@ static void cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg); /* Forward and backward prediction reference buffers. */ + forward_idx = vb2_find_tag(cap_q, slice_params->forward_ref_tag, 0); - fwd_luma_addr = cedrus_dst_buf_addr(ctx, - slice_params->forward_ref_index, - 0); - fwd_chroma_addr = cedrus_dst_buf_addr(ctx, - slice_params->forward_ref_index, - 1); + fwd_luma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 0); + fwd_chroma_addr = cedrus_dst_buf_addr(ctx, forward_idx, 1); cedrus_write(dev, VE_DEC_MPEG_FWD_REF_LUMA_ADDR, fwd_luma_addr); cedrus_write(dev, VE_DEC_MPEG_FWD_REF_CHROMA_ADDR, fwd_chroma_addr); - bwd_luma_addr = cedrus_dst_buf_addr(ctx, - slice_params->backward_ref_index, - 0); - bwd_chroma_addr = cedrus_dst_buf_addr(ctx, - slice_params->backward_ref_index, - 1); + backward_idx = vb2_find_tag(cap_q, slice_params->backward_ref_tag, 0); + bwd_luma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 0); + bwd_chroma_addr = cedrus_dst_buf_addr(ctx, backward_idx, 1); cedrus_write(dev, VE_DEC_MPEG_BWD_REF_LUMA_ADDR, bwd_luma_addr); cedrus_write(dev, VE_DEC_MPEG_BWD_REF_CHROMA_ADDR, bwd_chroma_addr); diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index 5c5fce678b93..293df48326cc 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -522,6 +522,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->lock = &ctx->dev->dev_mutex; src_vq->dev = ctx->dev->dev; src_vq->supports_requests = true; + src_vq->supports_tags = true; ret = vb2_queue_init(src_vq); if (ret) @@ -537,6 +538,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->lock = &ctx->dev->dev_mutex; dst_vq->dev = ctx->dev->dev; + dst_vq->supports_tags = true; return vb2_queue_init(dst_vq); } diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 998983a6e6b7..45a55bb27e5a 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1109,10 +1109,9 @@ struct v4l2_mpeg2_sequence { __u32 vbv_buffer_size; /* ISO/IEC 13818-2, ITU-T Rec. H.262: Sequence extension */ - __u8 profile_and_level_indication; + __u16 profile_and_level_indication; __u8 progressive_sequence; __u8 chroma_format; - __u8 pad; }; struct v4l2_mpeg2_picture { @@ -1130,23 +1129,20 @@ struct v4l2_mpeg2_picture { __u8 intra_vlc_format; __u8 alternate_scan; __u8 repeat_first_field; - __u8 progressive_frame; - __u8 pad; + __u16 progressive_frame; }; struct v4l2_ctrl_mpeg2_slice_params { __u32 bit_size; __u32 data_bit_offset; + __u32 backward_ref_tag; + __u32 forward_ref_tag; struct v4l2_mpeg2_sequence sequence; struct v4l2_mpeg2_picture picture; /* ISO/IEC 13818-2, ITU-T Rec. H.262: Slice */ - __u8 quantiser_scale_code; - - __u8 backward_ref_index; - __u8 forward_ref_index; - __u8 pad; + __u32 quantiser_scale_code; }; struct v4l2_ctrl_mpeg2_quantization {