From patchwork Fri Jun 16 07:39:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9790789 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 0413260326 for ; Fri, 16 Jun 2017 07:39:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0E6280B0 for ; Fri, 16 Jun 2017 07:39:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F642857E; Fri, 16 Jun 2017 07:39:40 +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.9 required=2.0 tests=BAYES_00,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 8DC05280B0 for ; Fri, 16 Jun 2017 07:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdFPHji (ORCPT ); Fri, 16 Jun 2017 03:39:38 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36631 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752760AbdFPHjf (ORCPT ); Fri, 16 Jun 2017 03:39:35 -0400 Received: by mail-pg0-f65.google.com with SMTP id v18so4542384pgb.3 for ; Fri, 16 Jun 2017 00:39:35 -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=cjWx0F6FyoIqC56Ffw58/pX/XeujEUmNaarN+Qk+ckM=; b=ZD/L/iM2pWGJn9VzLfoUbekpKErdJ5X2U7Wr7iQhUORLmWB+tNvAveflmLW9qa22Bx pgl5oxwvZ2STzewBlvJ6MG4e9p+owsEICyFsmLyT5y7bCFKilJskIKZpWMXU4wfo+3cD P5VXNd5yRpkv8jDpCJ6T2Co+a6nS89t4ph9nCf+HKFC+PqTWsUfXgENz2ofk0zyo8sta UE2g09z74xlOgFdNqQsHGgmN0XvdChOF2JjMh/Tats4FGqNdughw/Zhm+2gky11QVwG9 wzfMwKTA8CCzCpULdyxru207xGKKgVEQcmaZKaIrERcJ+v/UpJXBIDGbI9nEEpOLKLr8 aJ3A== X-Gm-Message-State: AKS2vOzf2r70bjPUZOSczInNQ3VAUFN+iBer0G4pqxZwORYbgfLTkQDp 9AD/b5Ztm0SbXJbVBvM= X-Received: by 10.98.144.80 with SMTP id a77mr9524409pfe.148.1497598769335; Fri, 16 Jun 2017 00:39:29 -0700 (PDT) Received: from jade.nodan1.kt.home.ne.jp (202-72-64-244.koalanet.ne.jp. [202.72.64.244]) by smtp.gmail.com with ESMTPSA id a2sm2760568pfj.8.2017.06.16.00.39.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 00:39:28 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Javier Martinez Canillas , Mauro Carvalho Chehab , Shuah Khan , Gustavo Padovan Subject: [PATCH 02/12] [media] vb2: split out queueing from vb_core_qbuf() Date: Fri, 16 Jun 2017 16:39:05 +0900 Message-Id: <20170616073915.5027-3-gustavo@padovan.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170616073915.5027-1-gustavo@padovan.org> References: <20170616073915.5027-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 to do the actual queueing of the buffer. Signed-off-by: Gustavo Padovan Acked-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 51 ++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 3107e21..ea83126 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1367,6 +1367,34 @@ static int vb2_start_streaming(struct vb2_queue *q) return ret; } +static int __vb2_core_qbuf(struct vb2_buffer *vb, struct vb2_queue *q) +{ + int ret; + + /* + * If already streaming, give the buffer to driver for processing. + * If not, the buffer will be given to driver on next streamon. + */ + if (q->start_streaming_called) + __enqueue_in_driver(vb); + + /* + * If streamon has been called, and we haven't yet called + * start_streaming() since not enough buffers were queued, and + * we now have reached the minimum number of queued buffers, + * then we can finally call start_streaming(). + */ + if (q->streaming && !q->start_streaming_called && + q->queued_count >= q->min_buffers_needed) { + ret = vb2_start_streaming(q); + if (ret) + return ret; + } + + 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; @@ -1404,32 +1432,11 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *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. - */ - 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 - * we now have reached the minimum number of queued buffers, - * then we can finally call start_streaming(). - */ - if (q->streaming && !q->start_streaming_called && - q->queued_count >= q->min_buffers_needed) { - ret = vb2_start_streaming(q); - if (ret) - return ret; - } - - dprintk(1, "qbuf of buffer %d succeeded\n", vb->index); - return 0; + return __vb2_core_qbuf(vb, q); } EXPORT_SYMBOL_GPL(vb2_core_qbuf);