From patchwork Tue Mar 5 18:51:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10840011 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2E221515 for ; Tue, 5 Mar 2019 18:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A1F2CA93 for ; Tue, 5 Mar 2019 18:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95F2B2CABC; Tue, 5 Mar 2019 18:52:18 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 770FA2CA93 for ; Tue, 5 Mar 2019 18:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728862AbfCESwP (ORCPT ); Tue, 5 Mar 2019 13:52:15 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:49199 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbfCESwM (ORCPT ); Tue, 5 Mar 2019 13:52:12 -0500 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 6F315200010; Tue, 5 Mar 2019 18:52:10 +0000 (UTC) From: Jacopo Mondi To: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 31/31] media: rcar-csi2: Implement has_route() Date: Tue, 5 Mar 2019 19:51:50 +0100 Message-Id: <20190305185150.20776-32-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305185150.20776-1-jacopo+renesas@jmondi.org> References: <20190305185150.20776-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that the rcar-csi2 subdevice supports internal routing, add an has_route() operation used during graph traversal. The internal routing between the sink and the source pads depends on the virtual channel used to transmit the video stream from the remote subdevice to the R-Car CSI-2 receiver. Signed-off-by: Jacopo Mondi --- drivers/media/platform/rcar-vin/rcar-csi2.c | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index cc7077b40f18..6c46bcc0ee83 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -1028,7 +1028,42 @@ static int rcsi2_confirm_start_v3m_e3(struct rcar_csi2 *priv) * Platform Device Driver. */ +static bool rcar_csi2_has_route(struct media_entity *entity, + unsigned int pad0, unsigned int pad1) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct rcar_csi2 *priv = sd_to_csi2(sd); + struct v4l2_mbus_frame_desc fd; + unsigned int i; + int ret; + + /* Support only direct sink->source routes. */ + if (pad0 != RCAR_CSI2_SINK) + return false; + + /* Get the frame description: from CSI-2 VC to source pad number. */ + ret = rcsi2_get_remote_frame_desc(priv, &fd); + if (ret) + return ret; + + for (i = 0; i < fd.num_entries; i++) { + struct v4l2_mbus_frame_desc_entry *entry = &fd.entry[i]; + int source_pad = rcsi2_vc_to_pad(entry->bus.csi2.channel); + if (source_pad < 0) { + dev_err(priv->dev, "Virtual Channel out of range: %u\n", + entry->bus.csi2.channel); + return -EINVAL; + } + + if (source_pad == pad1) + return true; + } + + return false; +} + static const struct media_entity_operations rcar_csi2_entity_ops = { + .has_route = rcar_csi2_has_route, .link_validate = v4l2_subdev_link_validate, };