Received: by 10.192.165.156 with SMTP id m28csp862437imm; Thu, 19 Apr 2018 08:45:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx48uwOByxiOa3zCR13mXuq0jFgb1MrBlaAXD5vp5o9bh+QL7ECb5twhHKBzaMnt72sXaWTk0 X-Received: by 10.101.70.72 with SMTP id k8mr3174359pgr.47.1524152739760; Thu, 19 Apr 2018 08:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524152739; cv=none; d=google.com; s=arc-20160816; b=kkBVhKCaEfrG6/b/ctjnI7p4VjJR85g/alg7SXAoS5yTzLY46LfPoY3TK00nmYqbGc PZHdJPKqnrkpwNLeAjlrKHonvWzrJDOFqB9ImjypyyoQ/PSNyvrt65+CLKT6GfGaXYG+ sZ5zEpPu4CW5LwqrwRKyBnKCaKMAycHapjsVD8QMdkjJLLwFls97IhPwAFFX+rS3WfnB biGILy0oPF0M8HyDR9wch7R8uTFLMy/MFyXp21SbedTspJsUIapWXr7HERuMiLiFCzK+ sgeMghlmBOE+KEjrP3iVz6OyoOvbWj2AMPo+lDcn4Hg956hNgFK/5drjGwoJViVTk0rh S4Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rO6GVqPfq9/bmC0bl8Cj7Pi2VAThPIPgEfYJxJiNUu8=; b=aVVrLmJOD8MMZQDh9FJCg9jaS1om44tNAZsiCv3jZkHX2YRrLYuOTL9t1k+AKkj11I UkKATn53s0bFYn6Dv4jj5usLy9k/lQg4LwBssvNK+j/yFZqg8wLMwyDh8ouxZMCY1iCC BmXy7tTIRPgM1dlvwns+Tgv61V9XzNyXI3yVrZ+jrOy1nIL3X5IQw5mU/rIyd6Qrw8aB mfm4mme7iU+V4YL+E11cUQHYotgjFyQ4tagYwHQSniFft/oafo07Ressf0cI01CRAqQ8 6zowH0UupyfN5wRaT0XrJ9TFLq3Yfzt7N4MLkC22Gc0zAogjSiLKos6B3WMwVqH/RsZq ps5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si1658298pgc.262.2018.04.19.08.45.23; Thu, 19 Apr 2018 08:45:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753421AbeDSPn6 (ORCPT + 99 others); Thu, 19 Apr 2018 11:43:58 -0400 Received: from mail.bootlin.com ([62.4.15.54]:42512 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753122AbeDSPnw (ORCPT ); Thu, 19 Apr 2018 11:43:52 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 675D12072F; Thu, 19 Apr 2018 17:43:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id EDB1E2072F; Thu, 19 Apr 2018 17:43:49 +0200 (CEST) From: Paul Kocialkowski To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Cc: Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Hans Verkuil , Sakari Ailus , Philipp Zabel , Arnd Bergmann , Alexandre Courbot , Tomasz Figa , Paul Kocialkowski Subject: [PATCH v2 03/10] videobuf2-core: Add helper to get buffer private data from media request Date: Thu, 19 Apr 2018 17:41:17 +0200 Message-Id: <20180419154124.17512-4-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180419154124.17512-1-paul.kocialkowski@bootlin.com> References: <20180419154124.17512-1-paul.kocialkowski@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When calling media operation driver callbacks related to media requests, only a pointer to the request itself is provided, which is insufficient to retrieve the driver's context. Since the driver context is usually set as vb2 queue private data and given that the core can determine which objects attached to the request are buffers, it is possible to extract the associated private data for the first buffer found. This is required in order to access the current m2m context from m2m drivers' private data in the context of media request operation callbacks. More specifically, this allows scheduling m2m device runs from the newly-introduced request complete operation. Signed-off-by: Paul Kocialkowski --- drivers/media/common/videobuf2/videobuf2-core.c | 15 +++++++++++++++ include/media/videobuf2-core.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 13c9d9e243dd..6fa46bfc620f 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -1351,6 +1351,21 @@ bool vb2_core_request_has_buffers(struct media_request *req) } EXPORT_SYMBOL_GPL(vb2_core_request_has_buffers); +void *vb2_core_request_find_buffer_priv(struct media_request *req) +{ + struct media_request_object *obj; + struct vb2_buffer *vb; + + obj = media_request_object_find(req, &vb2_core_req_ops, NULL); + if (!obj) + return NULL; + + vb = container_of(obj, struct vb2_buffer, req_obj); + + return vb2_get_drv_priv(vb->vb2_queue); +} +EXPORT_SYMBOL_GPL(vb2_core_request_find_buffer_priv); + int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb, struct media_request *req) { diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 032bd1bec555..65c0cf6afb55 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -1153,4 +1153,5 @@ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type); bool vb2_core_request_has_buffers(struct media_request *req); +void *vb2_core_request_find_buffer_priv(struct media_request *req); #endif /* _MEDIA_VIDEOBUF2_CORE_H */ -- 2.16.3