From patchwork Wed Feb 7 01:48:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10204515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E25D86020F for ; Wed, 7 Feb 2018 01:53:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D490928D6E for ; Wed, 7 Feb 2018 01:53:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7FE228D72; Wed, 7 Feb 2018 01:53:13 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 1699B28D70 for ; Wed, 7 Feb 2018 01:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753081AbeBGBxL (ORCPT ); Tue, 6 Feb 2018 20:53:11 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35293 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbeBGBsi (ORCPT ); Tue, 6 Feb 2018 20:48:38 -0500 Received: by mail-pg0-f65.google.com with SMTP id o13so1893371pgs.2 for ; Tue, 06 Feb 2018 17:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2cf+XgO+zPoWdP5XXwN5JLJt/iMVWqgDweTIAcBnRPM=; b=OrRVOEJSN5IM8KU7mwj10CmG/xq5h08Q16iyLUcZdnalzExfFW2iwdwevhttXgVFsw Y3XULjjV4pkTmcvKpj/0x3YTOyStiC37oARKtk4gTFqxA1mq+MOOTj5QKsxYoOr+Tbw8 ZjY1pbQV5J7hu0Qs4mXjNzxs67YdAr7KBWC7Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2cf+XgO+zPoWdP5XXwN5JLJt/iMVWqgDweTIAcBnRPM=; b=R7PCY0XU+/6SSmyCzFWjJ+iEFqwMuwgUOdB9gO6bEpfeo0PcI0bRsHfj3LJ3Cll93w 1xnhTV0gq3Om7CXKoAVhVkILG782aXMDXgQXPQ0qRE93U7sl/efa56o9ZOZnNVZJ7yWZ s7L2/lfgfY5txMDuoK2qSRP3XbHOqzWAiz8GYPETjxqFjKGEg5skLzavmJQI+n5kFrrY LlcpHMVvu8RIAJvxBU3qLUkhipiISIB2+Bf4Wnnzym1Ty4t5dgfTjJZ3K6S+bumoHcPM p2nNbwPMydGIHANj73Vk5ZoNVPrBBbnFvDjut0kcYfCPji8suKjEuMwzrb6uJxtHR1jT tlag== X-Gm-Message-State: APf1xPAQ6tlJi5uv81O5D1uDLLtpj7Eg5yJ6MpSub9SG4TqmOGvtIS/W SNhyJNgTa+DyeNsukENda3D4YA== X-Google-Smtp-Source: AH8x2265DP/WoFu7a3YSfniJ4EroAls1ILcvGFkHl7kyFVzJhW0x0vEyLk9zJ9sTNI8/zjxhPpe4Eg== X-Received: by 10.99.183.68 with SMTP id w4mr2822233pgt.221.1517968117529; Tue, 06 Feb 2018 17:48:37 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id x26sm528060pfi.141.2018.02.06.17.48.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 17:48:36 -0800 (PST) From: Alexandre Courbot To: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus , Gustavo Padovan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Alexandre Courbot Subject: [RFCv3 02/17] videodev2.h: Add request_fd field to v4l2_buffer Date: Wed, 7 Feb 2018 10:48:06 +0900 Message-Id: <20180207014821.164536-3-acourbot@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180207014821.164536-1-acourbot@chromium.org> References: <20180207014821.164536-1-acourbot@chromium.org> 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 queuing buffers allow for passing the request that should be associated with this buffer. Signed-off-by: Hans Verkuil [acourbot@chromium.org: make request ID 32-bit] Signed-off-by: Alexandre Courbot --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 3 ++- drivers/media/usb/cpia2/cpia2_v4l.c | 2 +- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 9 ++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++-- include/media/videobuf2-v4l2.h | 2 ++ include/uapi/linux/videodev2.h | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index fac3cd6f901d..0034f4d190f2 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -203,7 +203,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, void *pb) b->timestamp = ns_to_timeval(vb->timestamp); b->timecode = vbuf->timecode; b->sequence = vbuf->sequence; - b->reserved2 = 0; + b->request_fd = vbuf->request_fd; b->reserved = 0; if (q->is_multiplanar) { @@ -320,6 +320,7 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, } vb->timestamp = 0; vbuf->sequence = 0; + vbuf->request_fd = b->request_fd; if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { if (b->memory == VB2_MEMORY_USERPTR) { diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c index a1c59f19cf2d..54c5aa0ecd26 100644 --- a/drivers/media/usb/cpia2/cpia2_v4l.c +++ b/drivers/media/usb/cpia2/cpia2_v4l.c @@ -948,7 +948,7 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) buf->sequence = cam->buffers[buf->index].seq; buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; buf->length = cam->frame_size; - buf->reserved2 = 0; + buf->request_fd = 0; buf->reserved = 0; memset(&buf->timecode, 0, sizeof(buf->timecode)); diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 5198c9eeb348..32bf47489a2e 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -386,7 +386,7 @@ struct v4l2_buffer32 { __s32 fd; } m; __u32 length; - __u32 reserved2; + __s32 request_fd; __u32 reserved; }; @@ -486,6 +486,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer __user *kp, { u32 type; u32 length; + s32 request_fd; enum v4l2_memory memory; struct v4l2_plane32 __user *uplane32; struct v4l2_plane __user *uplane; @@ -500,7 +501,9 @@ static int get_v4l2_buffer32(struct v4l2_buffer __user *kp, get_user(memory, &up->memory) || put_user(memory, &kp->memory) || get_user(length, &up->length) || - put_user(length, &kp->length)) + put_user(length, &kp->length) || + get_user(request_fd, &up->request_fd) || + put_user(request_fd, &kp->request_fd)) return -EFAULT; if (V4L2_TYPE_IS_OUTPUT(type)) @@ -604,7 +607,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer __user *kp, assign_in_user(&up->timestamp.tv_usec, &kp->timestamp.tv_usec) || copy_in_user(&up->timecode, &kp->timecode, sizeof(kp->timecode)) || assign_in_user(&up->sequence, &kp->sequence) || - assign_in_user(&up->reserved2, &kp->reserved2) || + assign_in_user(&up->request_fd, &kp->request_fd) || assign_in_user(&up->reserved, &kp->reserved) || get_user(length, &kp->length) || put_user(length, &up->length)) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index e5109e5b8bf5..2f40ac0cdf6e 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -437,13 +437,13 @@ static void v4l_print_buffer(const void *arg, bool write_only) const struct v4l2_plane *plane; int i; - pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, flags=0x%08x, field=%s, sequence=%d, memory=%s", + pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, request_fd=%u, flags=0x%08x, field=%s, sequence=%d, memory=%s", p->timestamp.tv_sec / 3600, (int)(p->timestamp.tv_sec / 60) % 60, (int)(p->timestamp.tv_sec % 60), (long)p->timestamp.tv_usec, p->index, - prt_names(p->type, v4l2_type_names), + prt_names(p->type, v4l2_type_names), p->request_fd, p->flags, prt_names(p->field, v4l2_field_names), p->sequence, prt_names(p->memory, v4l2_memory_names)); diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 126cf559d4ce..a0eef2d42f0d 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -32,6 +32,7 @@ * &enum v4l2_field. * @timecode: frame timecode. * @sequence: sequence count of this frame. + * @request_fd: fd of the request used by the buffer. * * Should contain enough information to be able to cover all the fields * of &struct v4l2_buffer at ``videodev2.h``. @@ -43,6 +44,7 @@ struct vb2_v4l2_buffer { __u32 field; struct v4l2_timecode timecode; __u32 sequence; + __s32 request_fd; }; /* diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 982718965180..4fd46ae8fad5 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -909,6 +909,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 + * @request_fd: fd of the request that this buffer should use * * Contains data exchanged by application and driver using one of the Streaming * I/O methods. @@ -932,7 +933,7 @@ struct v4l2_buffer { __s32 fd; } m; __u32 length; - __u32 reserved2; + __s32 request_fd; __u32 reserved; };