From patchwork Wed Dec 5 10:20:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10713809 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 3165313AF for ; Wed, 5 Dec 2018 10:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 204942CD45 for ; Wed, 5 Dec 2018 10:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 144702CD49; Wed, 5 Dec 2018 10:20:50 +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 8EC342CD45 for ; Wed, 5 Dec 2018 10:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727614AbeLEKUs (ORCPT ); Wed, 5 Dec 2018 05:20:48 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:35333 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbeLEKUs (ORCPT ); Wed, 5 Dec 2018 05:20:48 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUIQgJehf; Wed, 05 Dec 2018 11:20:47 +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: [PATCHv4 01/10] videodev2.h: add tag support Date: Wed, 5 Dec 2018 11:20:31 +0100 Message-Id: <20181205102040.11741-2-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfG3mIdY9eUAC3AkQ/eMG8VEtMpbIDQ7PH0bCQimHkJPpmxn55UspX/xgNkNrKz3PlGEVDLEtVBPjULh3fPVihksOMrWPGClue40r5aJDgGozbcx77qni 7Cb24q4jjsNTlGVr4d4dD9JciPx7fybVNtz6iI5nXxJmM4uUtfEyxAw3b4sMUt0iH551uVagb399UAQgwjN3cPRCLKMm9x38SEuiMVccI+o5Eo5P7k+9+H0n GwUV7eJbc3fO5ZkaM7ZidMwelFbNeS7ru4HASO4U9drOJFpRRdIjx29HUViGenooxUsn2lDtvgt20ueOfAoHEL7FkfM/3BI1OO4EReW6jk13Cj+KmBj9+Ny8 GEIe8k9D7+kyqsgWBBtltymviq5VFQ4Z04eDe4Ji/PAQUlv7/op1uH/apkSU3xj0j/W6ZuQZVpG+Y7y8ftM1C9/PcLeU/Q== 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 2db1635de956..9095d7abe10d 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -881,6 +881,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 @@ -940,6 +941,7 @@ struct v4l2_plane { * @length: size in bytes of the buffer (NOT its payload) for single-plane * buffers (when type != *_MPLANE); number of elements in the * planes array for multi-plane buffers + * @tag: buffer tag * @request_fd: fd of the request that this buffer should use * * Contains data exchanged by application and driver using one of the Streaming @@ -964,7 +966,10 @@ struct v4l2_buffer { __s32 fd; } m; __u32 length; - __u32 reserved2; + union { + __u32 reserved2; + __u32 tag; + }; union { __s32 request_fd; __u32 reserved; @@ -990,6 +995,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 Wed Dec 5 10:20:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10713813 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 DEECB1731 for ; Wed, 5 Dec 2018 10:20:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD9612CD45 for ; Wed, 5 Dec 2018 10:20:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1A462CD49; Wed, 5 Dec 2018 10:20:51 +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 3C6262CD45 for ; Wed, 5 Dec 2018 10:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727659AbeLEKUu (ORCPT ); Wed, 5 Dec 2018 05:20:50 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:39796 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbeLEKUu (ORCPT ); Wed, 5 Dec 2018 05:20:50 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUIRgJehs; Wed, 05 Dec 2018 11:20:47 +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: [PATCHv4 02/10] vb2: add tag support Date: Wed, 5 Dec 2018 11:20:32 +0100 Message-Id: <20181205102040.11741-3-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfG3mIdY9eUAC3AkQ/eMG8VEtMpbIDQ7PH0bCQimHkJPpmxn55UspX/xgNkNrKz3PlGEVDLEtVBPjULh3fPVihksOMrWPGClue40r5aJDgGozbcx77qni 7Cb24q4jjsNTlGVr4d4dD9JciPx7fybVNtz6iI5nXxJmM4uUtfEyxAw3b4sMUt0iH551uVagb399UAQgwjN3cPRCLKMm9x38SEuiMVccI+o5Eo5P7k+9+H0n GwUV7eJbc3fO5ZkaM7ZidMwelFbNeS7ru4HASO4U9drOJFpRRdIjx29HUViGenooxUsn2lDtvgt20ueOfAoHEL7FkfM/3BI1OO4EReW6jk13Cj+KmBj9+Ny8 GEIe8k9D7+kyqsgWBBtltymviq5VFQ4Z04eDe4Ji/PAQUlv7/op1uH/apkSU3xj0j/W6ZuQZVpG+Y7y8ftM1C9/PcLeU/Q== 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 | 39 ++++++++++++++++--- include/media/videobuf2-v4l2.h | 21 +++++++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 1244c246d0c4..e0e31e1c67c9 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,7 +145,10 @@ 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; + vbuf->flags |= b->flags & + (V4L2_BUF_FLAG_TIMECODE | V4L2_BUF_FLAG_TAG); + if (b->flags & V4L2_BUF_FLAG_TAG) + vbuf->tag = b->tag; 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) { @@ -314,12 +319,12 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b if (V4L2_TYPE_IS_OUTPUT(b->type)) { /* - * For output buffers mask out the timecode flag: - * this will be handled later in vb2_qbuf(). + * For output buffers mask out the timecode and tag flags: + * these 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 +465,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; + if (b->flags & V4L2_BUF_FLAG_TIMECODE) + b->timecode = vbuf->timecode; b->sequence = vbuf->sequence; b->reserved2 = 0; b->request_fd = 0; @@ -586,6 +594,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 Wed Dec 5 10:20:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10713815 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 4A6A517D5 for ; Wed, 5 Dec 2018 10:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B1C42CD45 for ; Wed, 5 Dec 2018 10:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F9E42CD46; Wed, 5 Dec 2018 10:20: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 CF1792CD4E for ; Wed, 5 Dec 2018 10:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727677AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:51611 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727540AbeLEKUt (ORCPT ); Wed, 5 Dec 2018 05:20:49 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUIRgJeiA; Wed, 05 Dec 2018 11:20: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: [PATCHv4 03/10] v4l2-ioctl.c: log v4l2_buffer tag Date: Wed, 5 Dec 2018 11:20:33 +0100 Message-Id: <20181205102040.11741-4-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKI+hqaJArCk5zM7Bxic5lRQOtyIAXP+4YvHkyTK/PmIsza2iHo4UwfCZUp8Xk6KoF6T73y0rIKZzR17eKB5MgMkPYCoyIZA5qIM6U/m6ctruywdwH8x hIxblW1A4tYWTWEtDbkOHelC6om+Y8XF+jaxqJS9H6n5Nyy8gZXRqZBrMZTMOwO6f7E0Y4VLM+kmC/5/9c/3rU2ecMWo2wKfrYfPw9fOA6QE+u3pZLTzp7ZS GHNfvVy3E+U2U0deDjNJZ9lBIEefsU/KXrnVhpJjPFeNUA16Mb75j1HFU84ja3V9hiUeOXq77jEYwiY6rd4haqPDFvt/fCs+MjjN6C747AyHENW06ennG0+H WSRnC3lb7dOrVI300N0hlqK/vZ+PlsJNa9flJOQIYSRIW9thwP/sNlAblfD0jTfKrCSScYFvMNeFRT8SsSCowK/SipxCRA== 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 b9616b1f227b..07c6c939a23c 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); + 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 Wed Dec 5 10:20:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10713821 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 4993F1731 for ; Wed, 5 Dec 2018 10:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392F12CD45 for ; Wed, 5 Dec 2018 10:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D7DD2CD49; Wed, 5 Dec 2018 10:20: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 C17FE2CD45 for ; Wed, 5 Dec 2018 10:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727675AbeLEKUu (ORCPT ); Wed, 5 Dec 2018 05:20:50 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:35963 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727491AbeLEKUu (ORCPT ); Wed, 5 Dec 2018 05:20:50 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUISgJeib; Wed, 05 Dec 2018 11:20: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: [PATCHv4 04/10] buffer.rst: document the new buffer tag feature. Date: Wed, 5 Dec 2018 11:20:34 +0100 Message-Id: <20181205102040.11741-5-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKI+hqaJArCk5zM7Bxic5lRQOtyIAXP+4YvHkyTK/PmIsza2iHo4UwfCZUp8Xk6KoF6T73y0rIKZzR17eKB5MgMkPYCoyIZA5qIM6U/m6ctruywdwH8x hIxblW1A4tYWTWEtDbkOHelC6om+Y8XF+jaxqJS9H6n5Nyy8gZXRqZBrMZTMOwO6f7E0Y4VLM+kmC/5/9c/3rU2ecMWo2wKfrYfPw9fOA6QE+u3pZLTzp7ZS GHNfvVy3E+U2U0deDjNJZ9lBIEefsU/KXrnVhpJjPFeNUA16Mb75j1HFU84ja3V9hiUeOXq77jEYwiY6rd4haqPDFvt/fCs+MjjN6C747AyHENW06ennG0+H WSRnC3lb7dOrVI300N0hlqK/vZ+PlsJNa9flJOQIYSRIW9thwP/sNlAblfD0jTfKrCSScYFvMNeFRT8SsSCowK/SipxCRA== 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 | 17 ++++++++++++++--- Documentation/media/uapi/v4l/vidioc-reqbufs.rst | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst index 2e266d32470a..f83ee00cb30b 100644 --- a/Documentation/media/uapi/v4l/buffer.rst +++ b/Documentation/media/uapi/v4l/buffer.rst @@ -301,10 +301,13 @@ struct v4l2_buffer elements in the ``planes`` array. The driver will fill in the actual number of valid elements in that array. * - __u32 - - ``reserved2`` + - ``tag`` - - - A place holder for future extensions. Drivers and applications - must set this to 0. + - 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 - ``request_fd`` - @@ -567,6 +570,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`` 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 Wed Dec 5 10:20: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: 10713817 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 D60C013AF for ; Wed, 5 Dec 2018 10:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C646B2CD45 for ; Wed, 5 Dec 2018 10:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA54C2CD49; Wed, 5 Dec 2018 10:20: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 65B902CD45 for ; Wed, 5 Dec 2018 10:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727849AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:55171 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUISgJeiw; Wed, 05 Dec 2018 11:20: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: [PATCHv4 05/10] buffer.rst: clean up timecode documentation Date: Wed, 5 Dec 2018 11:20:35 +0100 Message-Id: <20181205102040.11741-6-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKI+hqaJArCk5zM7Bxic5lRQOtyIAXP+4YvHkyTK/PmIsza2iHo4UwfCZUp8Xk6KoF6T73y0rIKZzR17eKB5MgMkPYCoyIZA5qIM6U/m6ctruywdwH8x hIxblW1A4tYWTWEtDbkOHelC6om+Y8XF+jaxqJS9H6n5Nyy8gZXRqZBrMZTMOwO6f7E0Y4VLM+kmC/5/9c/3rU2ecMWo2wKfrYfPw9fOA6QE+u3pZLTzp7ZS GHNfvVy3E+U2U0deDjNJZ9lBIEefsU/KXrnVhpJjPFeNUA16Mb75j1HFU84ja3V9hiUeOXq77jEYwiY6rd4haqPDFvt/fCs+MjjN6C747AyHENW06ennG0+H WSRnC3lb7dOrVI300N0hlqK/vZ+PlsJNa9flJOQIYSRIW9thwP/sNlAblfD0jTfKrCSScYFvMNeFRT8SsSCowK/SipxCRA== 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 V4L2_BUF_FLAG_TIMECODE is not video capture specific, so drop that part. The 'Timecodes' section was a bit messy, so that's cleaned up. Signed-off-by: Hans Verkuil Reviewed-by: Paul Kocialkowski Reviewed-by: Alexandre Courbot --- Documentation/media/uapi/v4l/buffer.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst index f83ee00cb30b..359b131a212d 100644 --- a/Documentation/media/uapi/v4l/buffer.rst +++ b/Documentation/media/uapi/v4l/buffer.rst @@ -223,8 +223,7 @@ struct v4l2_buffer * - 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 @@ -715,10 +714,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 From patchwork Wed Dec 5 10:20: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: 10713829 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 CECBB1731 for ; Wed, 5 Dec 2018 10:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2902CD45 for ; Wed, 5 Dec 2018 10:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2FE02CD49; Wed, 5 Dec 2018 10:20:57 +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 4EE722CD45 for ; Wed, 5 Dec 2018 10:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbeLEKU4 (ORCPT ); Wed, 5 Dec 2018 05:20:56 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:35333 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbeLEKUu (ORCPT ); Wed, 5 Dec 2018 05:20:50 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUISgJejE; Wed, 05 Dec 2018 11:20: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: [PATCHv4 06/10] v4l2-mem2mem: add v4l2_m2m_buf_copy_data helper function Date: Wed, 5 Dec 2018 11:20:36 +0100 Message-Id: <20181205102040.11741-7-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKM3yVjLB5506EvfR1mN60fB22EHfVQ4CG0Yo0ak7JCVAY/0IZESGypv2+GeV0EvK7ztLNS5meJNANnS8qZP4rUf4nAogXAcfLzw2zXDnM+u/A5ytJS0 m8ANMEzQWxQuQuJfRVLYnOwqx7h2MwR2siUGdfQBE7KEcO+sqNPcQYPEVqNueLfsiTCYpjBocjlhKAAryXKWNXHmh9Gbmsu85dyZpsL1NcxOkTVH6DG84vDN cArUhtHVQlDZkTEH2W0sk0iv3e8daaMqBpyKNS/OaRg8XkroDsaafYITcSicMWR9+/X6RExSkYm5wQR1G1hP4OfzyBEIktRT55RgEoAreUInjP+ACEXuUIqG ymw7rQnx0eSc0FaqeNHTbtgWGs581DFT/YEzrLARpdETfaapj9w7drd6pqSJg394bBYAl5uYpid1LOp10wd1rS4sMpa6/w== 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 Wed Dec 5 10:20: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: 10713827 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 60FD01731 for ; Wed, 5 Dec 2018 10:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51C0A2CD45 for ; Wed, 5 Dec 2018 10:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42F152CD46; Wed, 5 Dec 2018 10:20: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 143672CD52 for ; Wed, 5 Dec 2018 10:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbeLEKUy (ORCPT ); Wed, 5 Dec 2018 05:20:54 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:34119 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727652AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUITgJejb; Wed, 05 Dec 2018 11:20: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: [PATCHv4 07/10] vb2: add new supports_tags queue flag Date: Wed, 5 Dec 2018 11:20:37 +0100 Message-Id: <20181205102040.11741-8-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfKM3yVjLB5506EvfR1mN60fB22EHfVQ4CG0Yo0ak7JCVAY/0IZESGypv2+GeV0EvK7ztLNS5meJNANnS8qZP4rUf4nAogXAcfLzw2zXDnM+u/A5ytJS0 m8ANMEzQWxQuQuJfRVLYnOwqx7h2MwR2siUGdfQBE7KEcO+sqNPcQYPEVqNueLfsiTCYpjBocjlhKAAryXKWNXHmh9Gbmsu85dyZpsL1NcxOkTVH6DG84vDN cArUhtHVQlDZkTEH2W0sk0iv3e8daaMqBpyKNS/OaRg8XkroDsaafYITcSicMWR9+/X6RExSkYm5wQR1G1hP4OfzyBEIktRT55RgEoAreUInjP+ACEXuUIqG ymw7rQnx0eSc0FaqeNHTbtgWGs581DFT/YEzrLARpdETfaapj9w7drd6pqSJg394bBYAl5uYpid1LOp10wd1rS4sMpa6/w== 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 e0e31e1c67c9..5aa5b1ea90a8 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -659,6 +659,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 Wed Dec 5 10:20: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: 10713819 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 861B617D5 for ; Wed, 5 Dec 2018 10:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76E3D2CD45 for ; Wed, 5 Dec 2018 10:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B6F32CD49; Wed, 5 Dec 2018 10:20: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 18E282CD45 for ; Wed, 5 Dec 2018 10:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbeLEKUw (ORCPT ); Wed, 5 Dec 2018 05:20:52 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:47352 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUITgJek2; Wed, 05 Dec 2018 11:20: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: [PATCHv4 08/10] vim2m: add tag support Date: Wed, 5 Dec 2018 11:20:38 +0100 Message-Id: <20181205102040.11741-9-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfJBvDexiEY0pSrleLccKK8Qkrl0Pyg39te+UIJ3BF3yHLQFAoalqhLZ578R0Rt6I1+82yNstcXP4ZYjlHZsTf52x5+qG22i22cP4pDfk087T4tac5Oh0 ATsr30EoLA9V7ORo/Z7SCTCKDDyEU4OShU87kHCgP3moPI5TU1+cJUCGDaHAquTIsyQmxiKDwbkp8Ma+maURjh7fxNDgfFgpcJctOxgtaFVEXlo/M3jp+npP tCuLORHJtLauYwzTgDRRMCqIxCflrZNhtAIrDrg0XksOpybvgbVXgVWowUGiHZJqDzh/2dXlTzNwV6AqgpvWiQX2Y3RNp0SOXr7af/OQXz0ER+I5jIMugk/X pYiImipk39OjtxYwqfbKc2sgmXvb8DcFF6xKfpLqNd06Fb1F+i9ziMZvX77S+XuWQpqk0sOHSCm9xuud5dDKpZ1T8M07Mw== 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 Wed Dec 5 10:20: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: 10713823 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 1798F1731 for ; Wed, 5 Dec 2018 10:20:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0853C2CD46 for ; Wed, 5 Dec 2018 10:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0B612CD51; Wed, 5 Dec 2018 10:20: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 9F71C2CD46 for ; Wed, 5 Dec 2018 10:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727862AbeLEKUx (ORCPT ); Wed, 5 Dec 2018 05:20:53 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:48137 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727660AbeLEKUv (ORCPT ); Wed, 5 Dec 2018 05:20:51 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUIUgJekS; Wed, 05 Dec 2018 11:20: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: [PATCHv4 09/10] vicodec: add tag support Date: Wed, 5 Dec 2018 11:20:39 +0100 Message-Id: <20181205102040.11741-10-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfJBvDexiEY0pSrleLccKK8Qkrl0Pyg39te+UIJ3BF3yHLQFAoalqhLZ578R0Rt6I1+82yNstcXP4ZYjlHZsTf52x5+qG22i22cP4pDfk087T4tac5Oh0 ATsr30EoLA9V7ORo/Z7SCTCKDDyEU4OShU87kHCgP3moPI5TU1+cJUCGDaHAquTIsyQmxiKDwbkp8Ma+maURjh7fxNDgfFgpcJctOxgtaFVEXlo/M3jp+npP tCuLORHJtLauYwzTgDRRMCqIxCflrZNhtAIrDrg0XksOpybvgbVXgVWowUGiHZJqDzh/2dXlTzNwV6AqgpvWiQX2Y3RNp0SOXr7af/OQXz0ER+I5jIMugk/X pYiImipk39OjtxYwqfbKc2sgmXvb8DcFF6xKfpLqNd06Fb1F+i9ziMZvX77S+XuWQpqk0sOHSCm9xuud5dDKpZ1T8M07Mw== 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 Wed Dec 5 10:20: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: 10713825 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 3223413AF for ; Wed, 5 Dec 2018 10:20:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22AAC2CD46 for ; Wed, 5 Dec 2018 10:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16A9F2CD45; Wed, 5 Dec 2018 10:20: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 7E2102CD45 for ; Wed, 5 Dec 2018 10:20:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbeLEKUx (ORCPT ); Wed, 5 Dec 2018 05:20:53 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:48335 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbeLEKUw (ORCPT ); Wed, 5 Dec 2018 05:20:52 -0500 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id UUIKgznz1aOW5UUIUgJeks; Wed, 05 Dec 2018 11:20: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: [PATCHv4 10/10] cedrus: add tag support Date: Wed, 5 Dec 2018 11:20:40 +0100 Message-Id: <20181205102040.11741-11-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 X-CMAE-Envelope: MS4wfH8jM9pT3fCWGO8wK9NWRLQyIEuujk+wbi9vOuhxCbJBCWDzSF8MnEUdMBUqg2NW8Sa4wWoX+MJrkw/4oEIAbx/0GseXBDIdfIjm1LNCDfRs63z2t9mX 6SLcCvGKOutVW/IgOq3uZUO37T2P1vfI7KqGkg9Jh94zwkRbSvwhIg2vGBToYo4HRBPw50xGlS/P//d0k+aF7ARtYnvPfJ5HE5pPSDLNAOvYDb6gDt293RTj Gj8y4wcZrDq0mkWKh/3uioa8COFOILdikx7jh5zOaKr92RvQNbJOH4LZmfGyD6i8wlY0+uTk/YEt5SNmPreWUpZsg2h8PNq6C+vnEVwAT8DQoMZCpugQITrx XEnszpV+TdLqgoGdSYl1N53C7FaY/4ffYKYBwbUAwknEybKsa70Yp49XtQzK30XSayVqnW+AaHDjdcLKKGPq1JbVJKquEQ== 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 129a986fa7e1..e859496e4e95 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1661,15 +1661,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 { From patchwork Wed Dec 5 10:33:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10713831 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 88710109C for ; Wed, 5 Dec 2018 10:33:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74B782946D for ; Wed, 5 Dec 2018 10:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 642652C8D4; Wed, 5 Dec 2018 10:33:59 +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 03C6B2946D for ; Wed, 5 Dec 2018 10:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727182AbeLEKd6 (ORCPT ); Wed, 5 Dec 2018 05:33:58 -0500 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]:42703 "EHLO lb3-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726874AbeLEKd6 (ORCPT ); Wed, 5 Dec 2018 05:33:58 -0500 Received: from [IPv6:2001:420:44c1:2579:69e7:fb8a:bb15:8970] ([IPv6:2001:420:44c1:2579:69e7:fb8a:bb15:8970]) by smtp-cloud7.xs4all.net with ESMTPA id UUV6gzuVGaOW5UUV9gJiuF; Wed, 05 Dec 2018 11:33:56 +0100 Subject: [PATCHv4 11/10] extended-controls.rst: update the mpeg2 compound controls To: hverkuil-cisco@xs4all.nl, 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 References: <20181205102040.11741-1-hverkuil-cisco@xs4all.nl> <20181205102040.11741-11-hverkuil-cisco@xs4all.nl> From: Hans Verkuil Message-ID: <87840d0c-15a8-21f3-7c9c-a46e6b548bad@xs4all.nl> Date: Wed, 5 Dec 2018 11:33:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20181205102040.11741-11-hverkuil-cisco@xs4all.nl> Content-Language: en-US X-CMAE-Envelope: MS4wfBhHr1WfLDWZH8npsrXoeu2SfrtstB6cveivOfbddfl0cXbokKyeE6wb3VR3cnkm/YBV3yOSMCelcO5s2M1LH7qOSupHPrd0LsRXvS/HXDR6G3MVsoRi n9okNJk9ug8Y4ouDw2EqWqyQZZrNxU1SDxU2ixTtvOHYLuDDfKkyS5WVLIySov72SS9/cBu3Cm1jQiTRuiry+adc0VQMtzYyHIDqwj1j48ExAbFweJn6KGhw OxKmlQ5nTrdiCa9LoJTsVOufJy5s/mU9d/9Wd8MrKQ4x3EzNlCITiH8W/XAGEQuAxSvzfkUV9l2CcT5dd1vooSwb2jdcAnM2G98AffzdAyuoz//W1DpnnOWE V056zu9//pvWamRuj4i8s7FYpJEhvMJutnmAoXy9+u+kK1IGKoV0ooqK9Y4RzS0vOQwidj+/eupX2dGmDpBGOHMNF+EqyFP+OxWeC2E4KeV2cVqtV2AnBkAU TxwwioZ0s3XMpLUc2E85E8cw/L+0MhbAI7BSI57A/kqsaBAc5/NwpQtApOXt86AuM1CsIK9iAPjV1zaN 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 The layout of the compound controls has changed to fix 32/64 bit alignment issues and the use of tags instead of buffer indices to refer to buffers. Note that these controls are only used by the cedrus staging driver. Signed-off-by: Hans Verkuil --- .../media/uapi/v4l/extended-controls.rst | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst index 65a1d873196b..b9e3af29a704 100644 --- a/Documentation/media/uapi/v4l/extended-controls.rst +++ b/Documentation/media/uapi/v4l/extended-controls.rst @@ -1528,17 +1528,19 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``picture`` - Structure with MPEG-2 picture metadata, merging relevant fields from the picture header and picture coding extension parts of the bitstream. - * - __u8 + * - __u32 + - ``backward_ref_tag`` + - Tag for the V4L2 buffer to use as backward reference, used with + B-coded and P-coded frames. The tag refers to the ``tag`` field in + struct :c:type:`v4l2_buffer`. + * - __u32 + - ``forward_ref_tag`` + - Tag for the V4L2 buffer to use as forward reference, used with + B-coded frames. The tag refers to the ``tag`` field in + struct :c:type:`v4l2_buffer`. + * - __u32 - ``quantiser_scale_code`` - Code used to determine the quantization scale to use for the IDCT. - * - __u8 - - ``backward_ref_index`` - - Index for the V4L2 buffer to use as backward reference, used with - B-coded and P-coded frames. - * - __u8 - - ``forward_ref_index`` - - Index for the V4L2 buffer to use as forward reference, used with - B-coded frames. .. c:type:: v4l2_mpeg2_sequence @@ -1559,7 +1561,7 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - - ``vbv_buffer_size`` - Used to calculate the required size of the video buffering verifier, defined (in bits) as: 16 * 1024 * vbv_buffer_size. - * - __u8 + * - __u16 - ``profile_and_level_indication`` - The current profile and level indication as extracted from the bitstream. @@ -1617,7 +1619,7 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type - * - __u8 - ``repeat_first_field`` - This flag affects the decoding process of progressive frames. - * - __u8 + * - __u16 - ``progressive_frame`` - Indicates whether the current frame is progressive.