From patchwork Tue Sep 6 04:48:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9315601 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 0C2C4601C0 for ; Tue, 6 Sep 2016 04:51:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1CE328B5B for ; Tue, 6 Sep 2016 04:51:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E680628B5C; Tue, 6 Sep 2016 04:51:23 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6A04F28B7A for ; Tue, 6 Sep 2016 04:51:23 +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 1bh8Kl-0005Y2-Hk; Tue, 06 Sep 2016 04:50:07 +0000 Received: from mail-pf0-f194.google.com ([209.85.192.194]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bh8K9-0005Fh-8i; Tue, 06 Sep 2016 04:49:30 +0000 Received: by mail-pf0-f194.google.com with SMTP id h186so10737717pfg.2; Mon, 05 Sep 2016 21:49:09 -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=B/FYixcNP8omByti1EMh1aj6BN0bHt7iVmOrxjT/H28=; b=ATJ9eVL+X96XeDz0KCEBqvokxc0zz7byDRKsQ4g49Mo6SCh5pes1wZVTb9v/+iuDzy wkZEP8O+O/+bw8BQcEK0vIBjosoAeoiSJrZSpatwAN5zon0ofEoFOYul/1vGFiTPfZLU 3HgpSCC1dY4CGPTj5aOTBYfQLI+lbRvvC/dPfGppYSLsCHu1RF4YCVqWK7j+oiK8MrSQ p96S19sntyR6tR92lFYy09XNTOX3YezIMJ+DE9Md2li6teLWMQi6gwx+Nr97YIMRFPJ0 +h7bvBqaTYDZ+e/fcFJf1PEtu5EUOcqmhxPBBF7Yqg3sMs3finO/7OjN4mi0MbXfqJ73 AdKA== X-Gm-Message-State: AE9vXwOGED8pkSdG1ZstAKGwTpxzducnaqiaupeTBI/7mkIX6jX2YR6J6wh96D8Czssjkg== X-Received: by 10.98.28.67 with SMTP id c64mr16930033pfc.118.1473137348612; Mon, 05 Sep 2016 21:49:08 -0700 (PDT) Received: from user5-HP-Z620-Workstation.corp.google.com ([172.22.52.170]) by smtp.gmail.com with ESMTPSA id s7sm16113398pfk.11.2016.09.05.21.49.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Sep 2016 21:49:07 -0700 (PDT) From: Chris Zhong To: dianders@chromium.org, heiko@sntech.de, zhengxing@rock-chips.com, cychiang@chromium.org Subject: [PATCH 2/2] ASoC: rockchip: Add DP dai-links to the rk3399-gru machine driver Date: Mon, 5 Sep 2016 21:48:55 -0700 Message-Id: <1473137335-14541-3-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473137335-14541-1-git-send-email-zyw@rock-chips.com> References: <1473137335-14541-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160905_214929_395401_ABD3B22F X-CRM114-Status: GOOD ( 14.96 ) 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 , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , Liam Girdwood , Rob Herring , Jaroslav Kysela , linux-rockchip@lists.infradead.org, Mark Brown , Chris Zhong , 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 rk3300-gru machine driver. Signed-off-by: Chris Zhong hychao@chromium.org, broonie@kernel.org --- .../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);