Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp927704rwb; Thu, 15 Dec 2022 04:27:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7NJQed0k1AA5hQgREFOZAxZzxnm38e1YbidncB9vgLqee70ZOZXRTHWFqVbKEfH1HxdU3/ X-Received: by 2002:a17:903:3254:b0:189:907b:7cbb with SMTP id ji20-20020a170903325400b00189907b7cbbmr29321961plb.50.1671107270046; Thu, 15 Dec 2022 04:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671107270; cv=none; d=google.com; s=arc-20160816; b=bj6MsHk5Mwpoac802uj/q5N58DoQq17WNJ3SzGgyWzwCUVhSE3ZNFBG2WP3WjKL1kU eT5FFKgAz59Kay2TN9za0wU9g+OE0hbDNFPnJjTGAX4bSTH22fG8EUUSoPt7XQwxFsWm imyBuexpbFqvrtIvY8/T3GqNeFa6OsVHzXItvbVwywj9Wev+imkAzEz/3+Ds+1SGVtWl +ejdKtXMeIFm/TPfWrFULvNG7hZ7/mBs8ogi9gCahgJgyGiSJgTJSjEOiMCQsW1YOibL W9BNSUQWMSaLPSChVb5fHS9orfgTT19F6VjJTCGhdJ2MoB5Jv5EKxXMg7Y+jN+OQwNCq QRiA== 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=I4PYjgNicgrMi3i0IuPJPqPNI/6gPz9QpsGyalCKUao=; b=sIvHGmVvlBAQispS2pK3kmH0uUHgGr4aRRSeabhwM70TcgxdF5BQsvS4HjsK80Iyd0 QAQUAb9FR6GTuxH67xY9WnqncV8Izcw03f/IuEcXuR213CUyMAKNqvqjMxHAjgt3ITOi gWWBatMwOQrablg5Q+MkSuD2u7FowRyT34tVGxcD/B/IpbAGfSXC4XHyfbISKhVijQzW zXfcJGk0rJ9S115WwjZTps+xBFSpbRk28GntpcGetv//vAm7lo9gBLiwm/dzXPfIyM3e ptz2DLhBbr/dQVhYlfEwsa7j9zlBpXIPq+Yr2C3hiMS4Jn/jnK5Ojg5r0hKlRjVfz5pT QTWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lVI1YP8y; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19-20020a170902c61300b0018862b7f8bbsi5219913plr.198.2022.12.15.04.27.41; Thu, 15 Dec 2022 04:27:50 -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=lVI1YP8y; 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 S230145AbiLOMSZ (ORCPT + 68 others); Thu, 15 Dec 2022 07:18:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbiLOMRf (ORCPT ); Thu, 15 Dec 2022 07:17:35 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BEBB2EF35; Thu, 15 Dec 2022 04:17:29 -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 3F4B7211D; Thu, 15 Dec 2022 13:17:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671106638; bh=DyXV7qGSaobPbyvyLrqyLGXFh+Ld4BfW7tqXJBD6c5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVI1YP8yiqsQxvJD0RQ0GWHhxYSrjj7Qt7mk1qQ4nKst4MRGpoVgNCLncR1AYpSVZ eJQfheERStDPRplSykP8LXROtv416Z01CpP3MTbJ/9f/rvAhSRD3deElb07UvTFgjf zTV4kntc6alNxqp4d6WIHkkSuZhaXW7HlHhsxS3w= 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 , Jacopo Mondi Subject: [PATCH v16 15/20] media: subdev: add v4l2_subdev_set_routing_with_fmt() helper Date: Thu, 15 Dec 2022 14:16:29 +0200 Message-Id: <20221215121634.287100-16-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 Content-Transfer-Encoding: 8bit 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 v4l2_subdev_set_routing_with_fmt() is the same as v4l2_subdev_set_routing(), but additionally initializes all the streams with the given format. Signed-off-by: Tomi Valkeinen Reviewed-by: Hans Verkuil Reviewed-by: Jacopo Mondi --- drivers/media/v4l2-core/v4l2-subdev.c | 22 ++++++++++++++++++++++ include/media/v4l2-subdev.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index c02048e388d1..9e154f419df8 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1464,6 +1464,28 @@ __v4l2_subdev_next_active_route(const struct v4l2_subdev_krouting *routing, } EXPORT_SYMBOL_GPL(__v4l2_subdev_next_active_route); +int v4l2_subdev_set_routing_with_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing, + const struct v4l2_mbus_framefmt *fmt) +{ + struct v4l2_subdev_stream_configs *stream_configs; + unsigned int i; + int ret; + + ret = v4l2_subdev_set_routing(sd, state, routing); + if (ret) + return ret; + + stream_configs = &state->stream_configs; + + for (i = 0; i < stream_configs->num_configs; ++i) + stream_configs->configs[i].fmt = *fmt; + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_set_routing_with_fmt); + struct v4l2_mbus_framefmt * v4l2_subdev_state_get_stream_format(struct v4l2_subdev_state *state, unsigned int pad, u32 stream) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 6f4719e28ad1..020ad79182cc 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1481,6 +1481,22 @@ __v4l2_subdev_next_active_route(const struct v4l2_subdev_krouting *routing, for ((route) = NULL; \ ((route) = __v4l2_subdev_next_active_route((routing), (route)));) +/** + * v4l2_subdev_set_routing_with_fmt() - Set given routing and format to subdev + * state + * @sd: The subdevice + * @state: The subdevice state + * @routing: Routing that will be copied to subdev state + * @fmt: Format used to initialize all the streams + * + * This is the same as v4l2_subdev_set_routing, but additionally initializes + * all the streams using the given format. + */ +int v4l2_subdev_set_routing_with_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, + struct v4l2_subdev_krouting *routing, + const struct v4l2_mbus_framefmt *fmt); + /** * v4l2_subdev_state_get_stream_format() - Get pointer to a stream format * @state: subdevice state -- 2.34.1