From patchwork Mon Mar 13 19:20:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9621921 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 BC40B604CC for ; Mon, 13 Mar 2017 19:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A096F205F6 for ; Mon, 13 Mar 2017 19:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 950262850D; Mon, 13 Mar 2017 19:24:18 +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 3BC25205F6 for ; Mon, 13 Mar 2017 19:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754437AbdCMTYG (ORCPT ); Mon, 13 Mar 2017 15:24:06 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:36393 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbdCMTUt (ORCPT ); Mon, 13 Mar 2017 15:20:49 -0400 Received: by mail-qk0-f196.google.com with SMTP id n141so38449330qke.3; Mon, 13 Mar 2017 12:20:48 -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=7KfFbc+q7PShomNw2/TSQVlGoJ+Kd3drfKRnaMI17qI=; b=kEtQZRfBv4pbjLWtqs/TKi0wygfdhDWu5cntFIfUSUVHalfxATuuHhFqrhBDH3mUmj jpfrYR9sn1mLgfpAAKCGUXb58Y8CyZJ76uEDwBlf63f5WjNrGUIzwVh8Zg4lssbPBhks 5tOgStI6iDjdkKBcwt9oxQRPqcNe47AGdNnV2sZN11TJfovxJuHSsK4AA3DUTDxAK7Wc DzpHQObNVDA8hJiyKpdCLSaEIPJakYLPh6XUF46ybVScmSzksHdbRkumwDYZ8EdbnUFp NLydZdOQQjyd51ryZdurnA14SlZIE11mpLoUDI4l8J5bafeX/hy/fuD5ue9N0yViY9TX F0RA== X-Gm-Message-State: AFeK/H2iEQKDVZJg3FbBSFU9lPy2JQd7jUNhKiUOYqsmUXnBe4ONeARciuoDGClaZ5nEKw== X-Received: by 10.55.4.139 with SMTP id 133mr31369101qke.48.1489432848118; Mon, 13 Mar 2017 12:20:48 -0700 (PDT) Received: from localhost.localdomain ([179.159.9.225]) by smtp.gmail.com with ESMTPSA id a19sm12821047qta.48.2017.03.13.12.20.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 12:20:47 -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 02/10] [media] vb2: split out queueing from vb_core_qbuf() Date: Mon, 13 Mar 2017 16:20:27 -0300 Message-Id: <20170313192035.29859-3-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 In order to support explicit synchronization we need to divide vb2_core_qbuf() in two parts one, to be executed before the fence signals and another one after that, to do the actual queueing of the buffer. Signed-off-by: Gustavo Padovan --- drivers/media/v4l2-core/videobuf2-core.c | 65 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 94afbbf9..0e30fcd 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1363,29 +1363,10 @@ static int vb2_start_streaming(struct vb2_queue *q) return ret; } -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) +static int __vb2_core_qbuf(struct vb2_buffer *vb, struct vb2_queue *q) { - struct vb2_buffer *vb; int ret; - vb = q->bufs[index]; - - switch (vb->state) { - case VB2_BUF_STATE_DEQUEUED: - ret = __buf_prepare(vb, pb); - if (ret) - return ret; - break; - case VB2_BUF_STATE_PREPARED: - break; - case VB2_BUF_STATE_PREPARING: - dprintk(1, "buffer still being prepared\n"); - return -EINVAL; - default: - dprintk(1, "invalid buffer state %d\n", vb->state); - return -EINVAL; - } - /* * Add to the queued buffers list, a buffer will stay on it until * dequeued in dqbuf. @@ -1395,11 +1376,6 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) q->waiting_for_buffers = false; vb->state = VB2_BUF_STATE_QUEUED; - if (pb) - call_void_bufop(q, copy_timestamp, vb, pb); - - trace_vb2_qbuf(q, vb); - /* * If already streaming, give the buffer to driver for processing. * If not, the buffer will be given to driver on next streamon. @@ -1407,10 +1383,6 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) if (q->start_streaming_called) __enqueue_in_driver(vb); - /* Fill buffer information for the userspace */ - if (pb) - call_void_bufop(q, fill_user_buffer, vb, pb); - /* * If streamon has been called, and we haven't yet called * start_streaming() since not enough buffers were queued, and @@ -1427,6 +1399,41 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) dprintk(1, "qbuf of buffer %d succeeded\n", vb->index); return 0; } + +int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) +{ + struct vb2_buffer *vb; + int ret; + + vb = q->bufs[index]; + + switch (vb->state) { + case VB2_BUF_STATE_DEQUEUED: + ret = __buf_prepare(vb, pb); + if (ret) + return ret; + break; + case VB2_BUF_STATE_PREPARED: + break; + case VB2_BUF_STATE_PREPARING: + dprintk(1, "buffer still being prepared\n"); + return -EINVAL; + default: + dprintk(1, "invalid buffer state %d\n", vb->state); + return -EINVAL; + } + + if (pb) + call_void_bufop(q, copy_timestamp, vb, pb); + + trace_vb2_qbuf(q, vb); + + /* Fill buffer information for the userspace */ + if (pb) + call_void_bufop(q, fill_user_buffer, vb, pb); + + return __vb2_core_qbuf(vb, q); +} EXPORT_SYMBOL_GPL(vb2_core_qbuf); /**