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: 9317767 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 A0FE0607D3 for ; Tue, 6 Sep 2016 18:18:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D5E528E3E for ; Tue, 6 Sep 2016 18:18:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91AE528E55; Tue, 6 Sep 2016 18:18:17 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3FC128E3E for ; Tue, 6 Sep 2016 18:18:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CD75C266B85; Tue, 6 Sep 2016 20:18:12 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 42430266DCD; Tue, 6 Sep 2016 19:54:56 +0200 (CEST) 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 34C7A266DCE; Tue, 6 Sep 2016 19:54:55 +0200 (CEST) Received: from mail-pa0-f65.google.com (mail-pa0-f65.google.com [209.85.220.65]) by alsa0.perex.cz (Postfix) with ESMTP id E787C2667C9 for ; Tue, 6 Sep 2016 19:10:17 +0200 (CEST) Received: by mail-pa0-f65.google.com with SMTP id h5so851025pao.0 for ; 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=hcYeU2wsrZ3maKiMahriOx4FIl952uBCDB+Zc9m+lYDZ/9Mkonb5UwextyHc0MiWLA w6Y1sSM8zh3xJlf6f8tWyQ+4Xdvx7V4NR/1fV3lFaaHutA9xg1t8h+4bwyd64qkKJ57W nZeiAGuC3f1F7F5CFstsoOYmfbDrkunwxzdyZ902uInJp1KX52+gtKnlMdW8k9rkGPFC xoMUr58MkLoyLYBCGr9NkWDUtRLBYJGKY9sfLEojbzy/SFCpohvbo6GIMqgQ8kwU0HAn V68z+eYzVvLjdf057T/y/Wp6isaOJYTH8V1ZK8GoxnydEm1nUPGQhmqyatV5CLdMUT7+ 350A== X-Gm-Message-State: AE9vXwMFJkEmbIJNGb8HDnkkCBA7zi+xxWzmbVCGDr6D3ka3YTwwC+PeRUOdvOiNSKNfoQ== 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 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> 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, linux-rockchip@lists.infradead.org, broonie@kernel.org, zyw@rock-chips.com, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [v2 PATCH 2/2] ASoC: rockchip: Add DP dai-links to the rk3399-gru machine driver 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 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);