From patchwork Fri Mar 9 17:49:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 10271479 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 4105E603B5 for ; Fri, 9 Mar 2018 17:52:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EEB4298C3 for ; Fri, 9 Mar 2018 17:52:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22FCF29EA1; Fri, 9 Mar 2018 17:52:36 +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=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 873C129E37 for ; Fri, 9 Mar 2018 17:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932535AbeCIRty (ORCPT ); Fri, 9 Mar 2018 12:49:54 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:44798 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932337AbeCIRtw (ORCPT ); Fri, 9 Mar 2018 12:49:52 -0500 Received: by mail-qt0-f196.google.com with SMTP id g60so11601337qtd.11; Fri, 09 Mar 2018 09:49:52 -0800 (PST) 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=IgHrS9zuqWTjODyKSuEADO/gM8wMQEHL9jK2BEy9yW4=; b=La+mmnheRerLfUHZCro5wDxUv4xeK3z+S2AZQwKE+LzRaeuE0wGl0Szc7pKqJD5T6y fgwA96ZsoZCSemWgnNZql3waMSx7qS5I82kqkHb0vCmoufcJU5EIvGSQB3V79MM66UFz HE5p1bAaCCjfy4U04TjXmMTAJF9zBR4PXu1xWJyfTla0jF5BtiSfIDu8yU99xyNyFL5Q HFEVstG1UROC74S1VWShWgXjWlJGAVHgHy/vfjom7HxISWw1e9Z71k9ogIzgBFncpsxr dfXP1LIhkvAp5SysKtYppvBFyep9iw1Khh+J7qOTalNvyuzl9pO7f74sXdJKC241UQNx zVsQ== X-Gm-Message-State: AElRT7HPcE9UceJSGLIvIC6Fzv1xMQZvcDHSZRNCp9i89t2cCZYPozfh tKLjMehvp4s/heBtdrN2CS0PvIqW X-Google-Smtp-Source: AG47ELusDpCcYDOr6O8O31fGjflpObvCy577+QemAuPK7HHtmjLnwihSQOPbNfk24z6N/abwTGYqfQ== X-Received: by 10.237.54.103 with SMTP id e94mr44660669qtb.112.1520617791349; Fri, 09 Mar 2018 09:49:51 -0800 (PST) Received: from localhost.localdomain ([2804:14c:138:2ada:4961:b672:c997:efad]) by smtp.gmail.com with ESMTPSA id g4sm873976qke.91.2018.03.09.09.49.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Mar 2018 09:49:50 -0800 (PST) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: kernel@collabora.com, Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , Pawel Osciak , Alexandre Courbot , Sakari Ailus , Brian Starkey , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: [PATCH v8 04/13] [media] vb2: add is_unordered callback for drivers Date: Fri, 9 Mar 2018 14:49:11 -0300 Message-Id: <20180309174920.22373-5-gustavo@padovan.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180309174920.22373-1-gustavo@padovan.org> References: <20180309174920.22373-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 Explicit synchronization benefits a lot from ordered queues, they fit better in a pipeline with DRM for example so create a opt-in way for drivers notify videobuf2 that the queue is unordered. Drivers don't need implement it if the queue is ordered. v2: - improve comments for is_unordered flag (Hans) v3: - make it bool (Hans) - create vb2_ops_set_unordered() helper Signed-off-by: Gustavo Padovan --- drivers/media/common/videobuf2/videobuf2-v4l2.c | 6 ++++++ include/media/videobuf2-core.h | 6 ++++++ include/media/videobuf2-v4l2.h | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c index 886a2d8d5c6c..68291ba8632d 100644 --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c @@ -961,6 +961,12 @@ void vb2_ops_wait_finish(struct vb2_queue *vq) } EXPORT_SYMBOL_GPL(vb2_ops_wait_finish); +bool vb2_ops_set_unordered(struct vb2_queue *q) +{ + return true; +} +EXPORT_SYMBOL_GPL(vb2_ops_set_unordered); + MODULE_DESCRIPTION("Driver helper framework for Video for Linux 2"); MODULE_AUTHOR("Pawel Osciak , Marek Szyprowski"); MODULE_LICENSE("GPL"); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 5b6c541e4e1b..46a9e674f7e1 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -370,6 +370,10 @@ struct vb2_buffer { * callback by calling vb2_buffer_done() with either * %VB2_BUF_STATE_DONE or %VB2_BUF_STATE_ERROR; may use * vb2_wait_for_all_buffers() function + * @is_unordered: tell if the queue is unordered, i.e. buffers can be + * dequeued in a different order from how they were queued. + * The default is assumed to be ordered and this function + * only needs to be implemented for unordered queues. * @buf_queue: passes buffer vb to the driver; driver may start * hardware operation on this buffer; driver should give * the buffer back by calling vb2_buffer_done() function; @@ -393,6 +397,7 @@ struct vb2_ops { int (*start_streaming)(struct vb2_queue *q, unsigned int count); void (*stop_streaming)(struct vb2_queue *q); + bool (*is_unordered)(struct vb2_queue *q); void (*buf_queue)(struct vb2_buffer *vb); }; @@ -566,6 +571,7 @@ struct vb2_queue { u32 cnt_wait_finish; u32 cnt_start_streaming; u32 cnt_stop_streaming; + u32 cnt_is_unordered; #endif }; diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 3d5e2d739f05..9de3c887c875 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -291,4 +291,14 @@ void vb2_ops_wait_prepare(struct vb2_queue *vq); */ void vb2_ops_wait_finish(struct vb2_queue *vq); +/** + * vb2_ops_set_unordered - helper function to mark queue as unordered + * + * @vq: pointer to &struct vb2_queue + * + * This helper just return true to notify that the driver can't deal with + * ordered queues. + */ +bool vb2_ops_set_unordered(struct vb2_queue *q); + #endif /* _MEDIA_VIDEOBUF2_V4L2_H */