From patchwork Mon Jan 19 18:50:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 5671901 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 385229F358 for ; Tue, 20 Jan 2015 19:45:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56F582034A for ; Tue, 20 Jan 2015 19:45:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 51F1F202DD for ; Tue, 20 Jan 2015 19:45:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4B684262607; Tue, 20 Jan 2015 20:45:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, FREEMAIL_FROM,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1BE7B260705; Tue, 20 Jan 2015 20:43:56 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 600562606F7; Tue, 20 Jan 2015 20:43:54 +0100 (CET) Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by alsa0.perex.cz (Postfix) with ESMTP id 6632B260705 for ; Tue, 20 Jan 2015 20:43:32 +0100 (CET) Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:21c:dfff:fe9f:57fb]) by smtp6-g21.free.fr (Postfix) with ESMTP id 5F93F822C2; Tue, 20 Jan 2015 20:41:24 +0100 (CET) X-Mailbox-Line: From 18425fc3a59ca2f1fed6cf056c3d2700adee7d4a Mon Sep 17 00:00:00 2001 Message-Id: <18425fc3a59ca2f1fed6cf056c3d2700adee7d4a.1421782532.git.moinejf@free.fr> In-Reply-To: References: From: Jean-Francois Moine Date: Mon, 19 Jan 2015 19:50:54 +0100 To: Mark Brown , Russell King - ARM Linux Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Andrew Jackson , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jyri Sarha , Dave Airlie Subject: [alsa-devel] [PATCH v10 3/9] ASoC: kirkwood: accept the DAI definitions from a graph of ports X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP By default, both output ports 0 (I2S) and 1 (S/PDIF) are defined. A graph of port permits to define only the really connected ports of the board and to identify the remote ends. Signed-off-by: Jean-Francois Moine --- .../devicetree/bindings/sound/mvebu-audio.txt | 30 ++++++++++++++++ sound/soc/kirkwood/kirkwood-i2s.c | 41 ++++++++++++++++++---- sound/soc/kirkwood/kirkwood.h | 3 +- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/mvebu-audio.txt b/Documentation/devicetree/bindings/sound/mvebu-audio.txt index cb8c07c..ae81bf1 100644 --- a/Documentation/devicetree/bindings/sound/mvebu-audio.txt +++ b/Documentation/devicetree/bindings/sound/mvebu-audio.txt @@ -23,6 +23,19 @@ Required properties: "internal" for the internal clock "extclk" for the external clock +Optional nodes: + +- port: one or two ports. + Each port must contain the following property: + + - port-type: must be "i2s" or "spdif" + + and the following node: + + - endpoint: reference of the remote endpoint - see [1] + +[1] Documentation/devicetree/bindings/graph.txt + Example: i2s1: audio-controller@b4000 { @@ -31,4 +44,21 @@ i2s1: audio-controller@b4000 { interrupts = <21>, <22>; clocks = <&gate_clk 13>; clock-names = "internal"; + + port@0 { + port-type = "spdif"; + audio1_spdif0: endpoint@0 { + remote-endpoint = <&spdif_out>; + }; + audio1_spdif1: endpoint@1 { + remote-endpoint = <&tda998x_spdif>; + }; + }; + port@1 { + port-type = "i2s"; + audio1_i2s: endpoint { + remote-endpoint = <&tda998x_i2s>; + }; + }; + }; diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 357f963..8e62bb8 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -466,13 +466,42 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = { }; /* create the DAIs */ -static int kirkwood_i2s_create_dais(struct kirkwood_dma_data *priv) +static int kirkwood_i2s_create_dais(struct device_node *np, + struct kirkwood_dma_data *priv) { - int i, ndai, dai[2]; + struct device_node *of_port; + const char *name; + int i, ret, ndai, dai[2]; - ndai = 2; - dai[0] = 0; /* i2s(0) - spdif(1) */ - dai[1] = 1; + ndai = 0; + if (np) { + for_each_child_of_node(np, of_port) { + if (!of_port->name || + of_node_cmp(of_port->name, "port") != 0) + continue; + ret = of_property_read_string(of_port, + "port-type", + &name); + if (ret) + continue; + if (strcmp(name, "i2s") == 0) { + dai[ndai] = 0; + } else if (strcmp(name, "spdif") == 0) { + dai[ndai] = 1; + } else { + continue; + } + if (++ndai >= 2) + break; + } + } + if (ndai == 0) { /* no DT or no port */ + ndai = 2; + dai[0] = 0; /* i2s(0) - spdif(1) */ + dai[1] = 1; + } else { + priv->is_graph = 1; /* graph of the ports */ + } for (i = 0; i < ndai; i++) { memcpy(&priv->dais[i], &kirkwood_i2s_dai_i2s_ext, sizeof(priv->dais[0])); @@ -570,7 +599,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; } - ndais = kirkwood_i2s_create_dais(priv); + ndais = kirkwood_i2s_create_dais(np, priv); err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, priv->dais, ndais); diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index a24d2c2..b4cbefe 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -141,7 +141,8 @@ struct kirkwood_dma_data { struct snd_pcm_substream *substream_play; struct snd_pcm_substream *substream_rec; int irq; - int burst; + short burst; + short is_graph; }; extern struct snd_soc_platform_driver kirkwood_soc_platform;