From patchwork Thu Mar 28 20:06:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10875931 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 5F63914DE for ; Thu, 28 Mar 2019 20:06:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A77A28B7E for ; Thu, 28 Mar 2019 20:06:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E5FA28F53; Thu, 28 Mar 2019 20:06: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=-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 B5E5328B7E for ; Thu, 28 Mar 2019 20:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbfC1UGf (ORCPT ); Thu, 28 Mar 2019 16:06:35 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:42461 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbfC1UGf (ORCPT ); Thu, 28 Mar 2019 16:06:35 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 653BFE0020; Thu, 28 Mar 2019 20:06:32 +0000 (UTC) From: Jacopo Mondi To: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se Cc: Jacopo Mondi , luca@lucaceresoli.net, ian.arkver.dev@gmail.com, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 31/31] media: rcar-csi2: Implement has_route() Date: Thu, 28 Mar 2019 21:06:08 +0100 Message-Id: <20190328200608.9463-32-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190328200608.9463-1-jacopo+renesas@jmondi.org> References: <20190328200608.9463-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 | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index 54713e9e5366..5ec2947a0732 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -1028,7 +1028,39 @@ 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; + + /* Support only direct sink->source routes. */ + if (pad0 != RCAR_CSI2_SINK) + return false; + + /* Get the frame description: already validate at 'bound' time. */ + rcsi2_get_remote_frame_desc(priv, &fd); + 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 false; + } + + 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, };