From patchwork Sat Mar 16 15:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10855931 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 535251823 for ; Sat, 16 Mar 2019 15:47:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1F32966F for ; Sat, 16 Mar 2019 15:47:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E6E92A024; Sat, 16 Mar 2019 15:47:42 +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 C1A612966F for ; Sat, 16 Mar 2019 15:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfCPPrl (ORCPT ); Sat, 16 Mar 2019 11:47:41 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:35781 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbfCPPrl (ORCPT ); Sat, 16 Mar 2019 11:47:41 -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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id E6F9C1BF20E; Sat, 16 Mar 2019 15:47:37 +0000 (UTC) From: Jacopo Mondi To: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, kieran.bingham@ideasonboard.com Cc: Jacopo Mondi , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, dave.stevenson@raspberrypi.org Subject: [RFC 3/5] media: adv748x: Make lanes number depend on routing Date: Sat, 16 Mar 2019 16:47:59 +0100 Message-Id: <20190316154801.20460-4-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190316154801.20460-1-jacopo+renesas@jmondi.org> References: <20190316154801.20460-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 Use the TXA routing information to configure the number of active CSI-2 data lanes. When routing AFE through TXA limit the number of data lanes to 1, while in the canonical HDMI->TXA routing use all the physically available ones. The number of lanes collected from the 'data-lanes' DT property is now used as a the number of physically available data lanes, while the 'num_lanes' variable contains the number of active ones. Signed-off-by: Jacopo Mondi --- drivers/media/i2c/adv748x/adv748x-core.c | 19 ++++++++++++++++++- drivers/media/i2c/adv748x/adv748x.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c index 02135741b1a6..f91c7b83f1bf 100644 --- a/drivers/media/i2c/adv748x/adv748x-core.c +++ b/drivers/media/i2c/adv748x/adv748x-core.c @@ -350,6 +350,8 @@ static int adv748x_link_setup(struct media_entity *entity, struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); bool enable = flags & MEDIA_LNK_FL_ENABLED; u8 csi4_in_sel = 0; + u8 num_lanes; + int ret; /* Refuse to enable multiple links to the same TX at the same time. */ if (enable && tx->src) @@ -373,10 +375,23 @@ static int adv748x_link_setup(struct media_entity *entity, csi4_in_sel |= ADV748X_IO_10_CSI4_IN_SEL_AFE; else csi4_in_sel |= ADV748X_IO_10_CSI1_EN; + + num_lanes = 1; } - if (state->hdmi.tx) + if (state->hdmi.tx) { csi4_in_sel |= ADV748X_IO_10_CSI4_EN; + num_lanes = tx->available_lanes; + } + + /* Update the number of active lanes if it has changed. */ + if (num_lanes != tx->num_lanes) { + tx->num_lanes = num_lanes; + ret = adv748x_write(state, tx->page, 0x00, + 0x80 | tx->num_lanes); + if (ret) + return ret; + } state->csi4_in_sel = csi4_in_sel; @@ -608,6 +623,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state, } state->txa.num_lanes = num_lanes; + state->txa.available_lanes = num_lanes; adv_dbg(state, "TXA: using %u lanes\n", state->txa.num_lanes); } @@ -619,6 +635,7 @@ static int adv748x_parse_csi2_lanes(struct adv748x_state *state, } state->txb.num_lanes = num_lanes; + state->txb.available_lanes = num_lanes; adv_dbg(state, "TXB: using %u lanes\n", state->txb.num_lanes); } diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h index 27c116d09284..6e5c2cb421fe 100644 --- a/drivers/media/i2c/adv748x/adv748x.h +++ b/drivers/media/i2c/adv748x/adv748x.h @@ -80,6 +80,7 @@ struct adv748x_csi2 { unsigned int page; unsigned int port; unsigned int num_lanes; + unsigned int available_lanes; struct media_pad pads[ADV748X_CSI2_NR_PADS]; struct v4l2_ctrl_handler ctrl_hdl;