From patchwork Thu Dec 15 12:16:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 33595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp316049wrn; Thu, 15 Dec 2022 04:19:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6p/6n3qATd6jsxeWpp7jrTptPKeRCu4lykcB8l0+iePp3YaeVBI6hbhCfkpcVgzeoCb2eG X-Received: by 2002:a05:6a21:168d:b0:ad:79bb:7869 with SMTP id np13-20020a056a21168d00b000ad79bb7869mr21646038pzb.56.1671106741175; Thu, 15 Dec 2022 04:19:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671106741; cv=none; d=google.com; s=arc-20160816; b=TbzKNP4r8qIGN8uXHn81RDWXYT83JiyCaAqZNo4z0rvVnkVHNEJxQnab8U+48LjH5f 8FPGksm8KEwFpTCrtftUGWw46qpGP9bmn6yndlxSQ7Z4EIK/9fFWzjG0tHFc6BgVztw+ aEcVyZ6B1jZHt/aI4lB90z801Nd3WEZaX5UPvOCM12Jfos3TpUuQosuLM2Y8cxjt2n93 h0rYVmJaXQW87O3NKmheIGTLvb1E6wA7wj6rXEoLTzygaL7RCBG0eG51yl+agD6oR8z7 h7KTDF26smoYIUBisEVugi4nGmzz5I2ANPXTYv5sGSIV3WnqSMsQPBKkJffnvXp7wBmB aIYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RzSaXikXaZvGWTloENJItZuJXnCXP2XS7tJFdDYFkmY=; b=v+sd5OzXavU45DZnEtwFXbCEVcfF7lCXgw4mbHQ2uVb3EIniO2um5DtTY3VI6LzUco QGc0BK+5y0fWcMYj5cHuzw/Ry5LFLiEoYtFKgoPUbDj1I1H4rWRSR141xdkWiOETmI+O ZSbxfvBdraLaryUObouvDQPKyJQFqzsObdk1cDeYr0hhqE2pSNJ7122hbrySIaZNPsRo xr6g9lvQXcPBKp0gBJG03o/1D2xyo5SkL2PsEbef2nCfzTQc68cyZ/vNiF9c0otVtAO0 pttQhF9vlXotBuPhnW8Q73n4wGvTdtDBpc8DykMGTDF/9SbEMQOebiKErwhP4fl/mSn3 yG+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SR3QTIdZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a635a49000000b004778463363csi2744807pgm.76.2022.12.15.04.18.46; Thu, 15 Dec 2022 04:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SR3QTIdZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbiLOMRk (ORCPT + 99 others); Thu, 15 Dec 2022 07:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbiLOMRQ (ORCPT ); Thu, 15 Dec 2022 07:17:16 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B18B2E9F5; Thu, 15 Dec 2022 04:17:15 -0800 (PST) Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7278A1932; Thu, 15 Dec 2022 13:17:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671106632; bh=ya4gI9BzvGCXt5VVe6/pDgj2f4lcvw/cggAf9QTW91Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SR3QTIdZ6VUxoJMOTAISOuu8p1F+xD6cIH8iSpQiEKXhELkSDpVlg53+n7DqKeAKA sRtQklXEjn+Po/Od9Yqs3L3qC7lE2apg+x5b58MevJlqOjApi/nSeCuBljOL87Bptu aQbiTOjYk41LJ1Va1B9EnCLG2aUbzG46AiUe7K9A= From: Tomi Valkeinen To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, sakari.ailus@linux.intel.com, Jacopo Mondi , Laurent Pinchart , niklas.soderlund+renesas@ragnatech.se, Mauro Carvalho Chehab , Hans Verkuil , satish.nagireddy@getcruise.com, Tomasz Figa Cc: Tomi Valkeinen Subject: [PATCH v16 07/20] media: subdev: add v4l2_subdev_has_pad_interdep() Date: Thu, 15 Dec 2022 14:16:21 +0200 Message-Id: <20221215121634.287100-8-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215121634.287100-1-tomi.valkeinen@ideasonboard.com> References: <20221215121634.287100-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752282422289525062?= X-GMAIL-MSGID: =?utf-8?q?1752282422289525062?= Add a v4l2_subdev_has_pad_interdep() helper function which can be used for media_entity_operations.has_pad_interdep op. It considers two pads interdependent if there is an active route between pad0 and pad1. Signed-off-by: Tomi Valkeinen --- drivers/media/v4l2-core/v4l2-subdev.c | 31 +++++++++++++++++++++++++++ include/media/v4l2-subdev.h | 18 ++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index c31b44800e39..b16121485f79 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1056,6 +1056,37 @@ int v4l2_subdev_link_validate(struct media_link *link) } EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate); +bool v4l2_subdev_has_pad_interdep(struct media_entity *entity, + unsigned int pad0, unsigned int pad1) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct v4l2_subdev_krouting *routing; + struct v4l2_subdev_state *state; + unsigned int i; + + state = v4l2_subdev_lock_and_get_active_state(sd); + + routing = &state->routing; + + for (i = 0; i < routing->num_routes; ++i) { + struct v4l2_subdev_route *route = &routing->routes[i]; + + if (!(route->flags & V4L2_SUBDEV_ROUTE_FL_ACTIVE)) + continue; + + if ((route->sink_pad == pad0 && route->source_pad == pad1) || + (route->source_pad == pad0 && route->sink_pad == pad1)) { + v4l2_subdev_unlock_state(state); + return true; + } + } + + v4l2_subdev_unlock_state(state); + + return false; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_has_pad_interdep); + struct v4l2_subdev_state * __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name, struct lock_class_key *lock_key) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 4934dc9468a8..45c41f4d6a2b 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1241,6 +1241,24 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, */ int v4l2_subdev_link_validate(struct media_link *link); +/** + * v4l2_subdev_has_pad_interdep - MC has_pad_interdep implementation for subdevs + * + * @entity: pointer to &struct media_entity + * @pad0: pad number for the first pad + * @pad1: pad number for the second pad + * + * This function is an implementation of the + * media_entity_operations.has_pad_interdep operation for subdevs that + * implement the multiplexed streams API (as indicated by the + * V4L2_SUBDEV_FL_STREAMS subdev flag). + * + * It considers two pads interdependent if there is an active route between pad0 + * and pad1. + */ +bool v4l2_subdev_has_pad_interdep(struct media_entity *entity, + unsigned int pad0, unsigned int pad1); + /** * __v4l2_subdev_state_alloc - allocate v4l2_subdev_state *