From patchwork Mon Jan 19 17:15:31 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: 5671701 Return-Path: X-Original-To: patchwork-dri-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 0E99E9F358 for ; Tue, 20 Jan 2015 19:43:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F9E3202DD for ; Tue, 20 Jan 2015 19:43:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0AFE42034A for ; Tue, 20 Jan 2015 19:43:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E1396E63D; Tue, 20 Jan 2015 11:43:16 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [212.27.42.6]) by gabe.freedesktop.org (Postfix) with ESMTP id D07716E63D for ; Tue, 20 Jan 2015 11:43:14 -0800 (PST) Received: from localhost (unknown [IPv6:2a01:e35:2f5c:9de0:21c:dfff:fe9f:57fb]) by smtp6-g21.free.fr (Postfix) with ESMTP id 67F1982317; Tue, 20 Jan 2015 20:41:06 +0100 (CET) X-Mailbox-Line: From c8943506a056073292ef525a85e9ed89b6e90eb0 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Jean-Francois Moine Date: Mon, 19 Jan 2015 18:15:31 +0100 Subject: [PATCH v10 1/9] ASoC: kirkwood: dynamically build the DAI array 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prepares the driver to the creation of the DAIs from a graph of ports. Signed-off-by: Jean-Francois Moine --- sound/soc/kirkwood/kirkwood-i2s.c | 108 ++++++++++++++------------------------ sound/soc/kirkwood/kirkwood.h | 1 + 2 files changed, 40 insertions(+), 69 deletions(-) diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index def7d82..62d9c12 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -438,49 +438,8 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { .set_fmt = kirkwood_i2s_set_fmt, }; -static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = { - { - .name = "i2s", - .id = 0, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_I2S_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_I2S_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, - { - .name = "spdif", - .id = 1, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, -}; - -static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { - { +/* DAI sample for I2S and external clock */ +static struct snd_soc_dai_driver kirkwood_i2s_dai_i2s_ext = { .name = "i2s", .id = 0, .playback = { @@ -500,42 +459,52 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { .formats = KIRKWOOD_I2S_FORMATS, }, .ops = &kirkwood_i2s_dai_ops, - }, - { - .name = "spdif", - .id = 1, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 5512, - .rate_max = 192000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 5512, - .rate_max = 192000, - .formats = KIRKWOOD_SPDIF_FORMATS, - }, - .ops = &kirkwood_i2s_dai_ops, - }, }; static const struct snd_soc_component_driver kirkwood_i2s_component = { .name = DRV_NAME, }; +/* create the DAIs */ +static int kirkwood_i2s_create_dais(struct kirkwood_dma_data *priv) +{ + int i, ndai, dai[2]; + + ndai = 2; + dai[0] = 0; /* i2s(0) - spdif(1) */ + dai[1] = 1; + for (i = 0; i < ndai; i++) { + memcpy(&priv->dais[i], &kirkwood_i2s_dai_i2s_ext, + sizeof(priv->dais[0])); + priv->dais[i].id = i; + if (dai[i] == 1) { + priv->dais[i].name = "spdif"; + priv->dais[i].playback.formats = + KIRKWOOD_SPDIF_FORMATS; + priv->dais[i].capture.formats = + KIRKWOOD_SPDIF_FORMATS; + } + if (IS_ERR(priv->extclk)) { + priv->dais[i].playback.rates = + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + priv->dais[i].capture.rates = + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000; + } + } + return ndai; +} + static int kirkwood_i2s_dev_probe(struct platform_device *pdev) { struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; - struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai; struct kirkwood_dma_data *priv; struct resource *mem; struct device_node *np = pdev->dev.of_node; - int err; + int err, ndais; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) { @@ -585,7 +554,6 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) } else { dev_info(&pdev->dev, "found external clock\n"); clk_prepare_enable(priv->extclk); - soc_dai = kirkwood_i2s_dai_extclk; } } @@ -602,8 +570,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; } + ndais = kirkwood_i2s_create_dais(priv); + err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, - soc_dai, 2); + priv->dais, ndais); if (err) { dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component; diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index 90e32a7..a24d2c2 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -135,6 +135,7 @@ struct kirkwood_dma_data { void __iomem *io; struct clk *clk; struct clk *extclk; + struct snd_soc_dai_driver dais[2]; uint32_t ctl_play; uint32_t ctl_rec; struct snd_pcm_substream *substream_play;