From patchwork Mon Mar 13 19:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9621927 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 D0C4060522 for ; Mon, 13 Mar 2017 19:24:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B84A321E5A for ; Mon, 13 Mar 2017 19:24:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD31E2850F; Mon, 13 Mar 2017 19:24:37 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 4AEB22850D for ; Mon, 13 Mar 2017 19:24:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932108AbdCMTYe (ORCPT ); Mon, 13 Mar 2017 15:24:34 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:36380 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751662AbdCMTUr (ORCPT ); Mon, 13 Mar 2017 15:20:47 -0400 Received: by mail-qk0-f196.google.com with SMTP id n141so38449152qke.3; Mon, 13 Mar 2017 12:20:46 -0700 (PDT) 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=t8LJdI3MOMFI5eY7RHwHI666qsc/FL+hKIkbNLrzG14=; b=DohULFakyUcduEYmTnobipjjuqmZoPYiEN4RCYeiVrHCBP1T8ZuaCKWA2wXt/GpfSO eyn5Cfpck2a43kSd7xsNjtskRHMh/uuR6+HhGYrh9szCTmDfhL87yyr5rDzy9ACw8aOW Vcw8za8PHZXxW7IIJSdSEbXNrfJL8Nay0frK6sa/gqX38f2x3BPu4lNyXV6XeHPv5jIK pGV2M3wfd3ytnywY8DPYPOTc3T1q/GngpXdS31hoeWTj+wcpfUlaKFN3q/mU4OS+bXOy x8LA2i66SHP354aRdXA+dcB4nSmBD89sIvx8FPDavhzbz96k8k3HRtBrl0U/4lIQNDpY AwcA== X-Gm-Message-State: AMke39mMhqwRweGgF7YOzbkEZG/NtGLjwXJcS4fwar5X04dAjBFZqfhxDWHH7uZlchKZRw== X-Received: by 10.55.98.144 with SMTP id w138mr31937134qkb.118.1489432845155; Mon, 13 Mar 2017 12:20:45 -0700 (PDT) Received: from localhost.localdomain ([179.159.9.225]) by smtp.gmail.com with ESMTPSA id a19sm12821047qta.48.2017.03.13.12.20.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 12:20:44 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Laurent Pinchart , Javier Martinez Canillas , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: [RFC 01/10] [media] vb2: add explicit fence user API Date: Mon, 13 Mar 2017 16:20:26 -0300 Message-Id: <20170313192035.29859-2-gustavo@padovan.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170313192035.29859-1-gustavo@padovan.org> References: <20170313192035.29859-1-gustavo@padovan.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: Gustavo Padovan Turn the reserved2 field into fence_fd that we will use to send an in-fence to the kernel return an out-fence from the kernel to userspace. Two new flags were added, V4L2_BUF_FLAG_IN_FENCE and V4L2_BUF_FLAG_OUT_FENCE. They should be used when setting in-fence and out-fence, respectively. Signed-off-by: Gustavo Padovan --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 4 ++-- drivers/media/v4l2-core/videobuf2-v4l2.c | 2 +- include/uapi/linux/videodev2.h | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index eac9565..0a522cb 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -348,7 +348,7 @@ struct v4l2_buffer32 { __s32 fd; } m; __u32 length; - __u32 reserved2; + __s32 fence_fd; __u32 reserved; }; @@ -511,7 +511,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) || copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || put_user(kp->sequence, &up->sequence) || - put_user(kp->reserved2, &up->reserved2) || + put_user(kp->fence_fd, &up->fence_fd) || put_user(kp->reserved, &up->reserved) || put_user(kp->length, &up->length)) return -EFAULT; diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 3529849..d23c1bf 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/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->fence_fd = -1; b->reserved = 0; if (q->is_multiplanar) { diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 45184a2..3b6cfa6 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -911,7 +911,7 @@ struct v4l2_buffer { __s32 fd; } m; __u32 length; - __u32 reserved2; + __s32 fence_fd; __u32 reserved; }; @@ -946,8 +946,10 @@ struct v4l2_buffer { #define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000 #define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000 #define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000 +#define V4L2_BUF_FLAG_IN_FENCE 0x00100000 +#define V4L2_BUF_FLAG_OUT_FENCE 0x00200000 /* mem2mem encoder/decoder */ -#define V4L2_BUF_FLAG_LAST 0x00100000 +#define V4L2_BUF_FLAG_LAST 0x00400000 /** * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor