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 F. Padovan" X-Patchwork-Id: 41935 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLlr6-0005n8-7a; Fri, 16 Jun 2017 07:39:44 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.89/mailfrontend-8) with esmtp id 1dLlr4-0004vQ-k7; Fri, 16 Jun 2017 09:39:44 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdFPHji (ORCPT + 1 other); 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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.6.16.73017 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' 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);