From patchwork Tue Sep 6 17:09:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9317681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A956C60760 for ; Tue, 6 Sep 2016 17:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CA2A28DC3 for ; Tue, 6 Sep 2016 17:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90F7228E20; Tue, 6 Sep 2016 17:13:15 +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=-1.8 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C4D628DC3 for ; Tue, 6 Sep 2016 17:13:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhJuU-0006Pv-DC; Tue, 06 Sep 2016 17:11:46 +0000 Received: from mail-pa0-f68.google.com ([209.85.220.68]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhJtP-00057v-0y; Tue, 06 Sep 2016 17:10:40 +0000 Received: by mail-pa0-f68.google.com with SMTP id pp5so4737793pac.2; Tue, 06 Sep 2016 10:10:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vShygwJ+ULlZWqlBQjFDGylc/A9EN2fJIUTeIRC7Cd0=; b=Hh9HZBl8En374eWAx6jtDUFY72Pp+vr/CGMAR2C9kOP9Rfj9r7gmHznHvpUiyJ6Vju JWx+FhEguuqZmARZS/NElPnlapT/rZkLw5JdfNYyu7m0q/DpEJ75f31ZipbDKpvwguTD l8rYLL6VGe3YjrVMyiZrcKxy5bp7Di6tL8ckYfs4/7AkzT+CWD7RhO2y9I1LHT5zTaiX qqlfmXxBoZwVy3ITDKLk3NbiOE3GWERRQE6QI06Qh+/b5syPxswo3eSqbghEgMQNOmo8 jS+4qhCkcERbzMYQjeV8Vsq11e72k7y1yufjvwHcKegWedW3HxlrL04tqRwWBkvACYox zu/w== X-Gm-Message-State: AE9vXwM3HFg6GzFfvqM9Os0Vb7W+TmbabLzWb61ri+17YI9NVzRD0Hw+Ed1EwvL6wAcx1A== X-Received: by 10.66.62.164 with SMTP id z4mr73526684par.156.1473181816984; Tue, 06 Sep 2016 10:10:16 -0700 (PDT) Received: from user5-HP-Z620-Workstation.corp.google.com ([172.22.52.170]) by smtp.gmail.com with ESMTPSA id y184sm42349184pfg.94.2016.09.06.10.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 10:10:16 -0700 (PDT) From: Chris Zhong To: dianders@chromium.org, heiko@sntech.de, zhengxing@rock-chips.com, cychiang@chromium.org Subject: [v2 PATCH 2/2] ASoC: rockchip: Add DP dai-links to the rk3399-gru machine driver Date: Tue, 6 Sep 2016 10:09:52 -0700 Message-Id: <1473181792-15398-1-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473137335-14541-3-git-send-email-zyw@rock-chips.com> References: <1473137335-14541-3-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160906_101039_213293_4D68CFAB X-CRM114-Status: GOOD ( 14.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, robh+dt@kernel.org, perex@perex.cz, linux-rockchip@lists.infradead.org, broonie@kernel.org, zyw@rock-chips.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds DP audio output support to the rk3399-gru machine driver. Signed-off-by: Chris Zhong --- Changes in v2: - correct the commit message .../bindings/sound/rockchip,rk3399-gru-sound.txt | 13 +++--- sound/soc/rockchip/rk3399_gru_sound.c | 48 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/rockchip,rk3399-gru-sound.txt b/Documentation/devicetree/bindings/sound/rockchip,rk3399-gru-sound.txt index f19b6c8..222124b 100644 --- a/Documentation/devicetree/bindings/sound/rockchip,rk3399-gru-sound.txt +++ b/Documentation/devicetree/bindings/sound/rockchip,rk3399-gru-sound.txt @@ -1,15 +1,16 @@ -ROCKCHIP with MAX98357A/RT5514/DA7219 codecs on GRU boards +ROCKCHIP with MAX98357A/RT5514/DA7219 codecs and DP via spdif on GRU boards Required properties: - compatible: "rockchip,rk3399-gru-sound" -- rockchip,cpu: The phandle of the Rockchip I2S controller that's - connected to the codecs -- rockchip,codec: The phandle of the MAX98357A/RT5514/DA7219 codecs +- rockchip,cpu: The phandle of the Rockchip I2S controller controller that's + connected to the codecs, and the SPDIF controller that's connected to DP +- rockchip,codec: The phandle of the MAX98357A/RT5514/DA7219 codecs and of the + DP encoder node Example: sound { compatible = "rockchip,rk3399-gru-sound"; - rockchip,cpu = <&i2s0>; - rockchip,codec = <&max98357a &rt5514 &da7219>; + rockchip,cpu = <&i2s0 &spdif>; + rockchip,codec = <&max98357a &rt5514 &da7219 &cdn_dp 1>; }; diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 164b6da..50e5d9a 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -226,10 +227,30 @@ static struct snd_soc_ops rockchip_sound_da7219_ops = { .hw_params = rockchip_sound_da7219_hw_params, }; +static struct snd_soc_jack cdn_dp_card_jack; + +static int cdn_dp_init(struct snd_soc_pcm_runtime *runtime) +{ + struct snd_soc_card *card = runtime->card; + struct snd_soc_codec *codec = runtime->codec; + int ret; + + /* enable jack detection */ + ret = snd_soc_card_jack_new(card, "DP Jack", SND_JACK_LINEOUT, + &cdn_dp_card_jack, NULL, 0); + if (ret) { + dev_err(card->dev, "Can't new DP Jack %d\n", ret); + return ret; + } + + return hdmi_codec_set_jack_detect(codec, &cdn_dp_card_jack); +} + enum { DAILINK_MAX98357A, DAILINK_RT5514, DAILINK_DA7219, + DAILINK_CDNDP, DAILINK_RT5514_DSP, }; @@ -264,6 +285,14 @@ static struct snd_soc_dai_link rockchip_dailinks[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, }, + [DAILINK_CDNDP] = { + .name = "DP", + .stream_name = "DP PCM", + .codec_dai_name = "spdif-hifi", + .init = cdn_dp_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + }, /* RT5514 DSP for voice wakeup via spi bus */ [DAILINK_RT5514_DSP] = { .name = "RT5514 DSP", @@ -334,6 +363,25 @@ static int rockchip_sound_probe(struct platform_device *pdev) return -ENODEV; } + cpu_node = of_parse_phandle(pdev->dev.of_node, "rockchip,cpu", 1); + if (!cpu_node) { + dev_err(&pdev->dev, "Property 'rockchip,cpu 1' missing or invalid\n"); + return -EINVAL; + } + + rockchip_dailinks[DAILINK_CDNDP].platform_of_node = cpu_node; + rockchip_dailinks[DAILINK_CDNDP].cpu_of_node = cpu_node; + + rockchip_dailinks[DAILINK_CDNDP].codec_of_node = + of_parse_phandle(pdev->dev.of_node, "rockchip,codec", + DAILINK_CDNDP); + if (!rockchip_dailinks[DAILINK_CDNDP].codec_of_node) { + dev_err(&pdev->dev, + "Property[%d] 'rockchip,codec' missing or invalid\n", + DAILINK_CDNDP); + return -EINVAL; + } + rockchip_dailinks[DAILINK_RT5514_DSP].cpu_name = kstrdup_const(dev_name(dev), GFP_KERNEL); rockchip_dailinks[DAILINK_RT5514_DSP].cpu_dai_name = kstrdup_const(dev_name(dev), GFP_KERNEL); rockchip_dailinks[DAILINK_RT5514_DSP].platform_name = kstrdup_const(dev_name(dev), GFP_KERNEL);