From patchwork Fri Sep 23 07:11:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 9349837 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 4E8176077B for ; Sun, 25 Sep 2016 17:12:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3224328BC7 for ; Sun, 25 Sep 2016 17:12:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2547528BCA; Sun, 25 Sep 2016 17:12:10 +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,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 5997628BC7 for ; Sun, 25 Sep 2016 17:12:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D1AA4266B9F; Sun, 25 Sep 2016 19:12:06 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E35FC2666F6; Sun, 25 Sep 2016 19:09:47 +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 330F5267195; Fri, 23 Sep 2016 09:11:51 +0200 (CEST) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by alsa0.perex.cz (Postfix) with ESMTP id D7BEB26657F for ; Fri, 23 Sep 2016 09:11:45 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id y6so86018111lff.1 for ; Fri, 23 Sep 2016 00:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=UUgUGWr+vGiadOiv8Llml2/7CB1/Luq0OQTlJtt0e2g=; b=yIDa/RXeMFy4mpwCz/PxSH9eCdPWUYwG5O/6sT02Z6YZAVRqT/tSbefdRw04b134Hp w5QieZ7ikwyfHkOstHVjmKay4l1Pthd5nI13n9fBK+k6tWZaoanVNjISjmTXtqB8mCtG WZljuMTb+aaywUX537fDJi/AHJWWGPQBiKxzifpZSW2PfuFxQfbFCqu7boNDaOrSzDLX BUeVyXnpa5r7F0s6B5LgmDlJ1/SeJLV986ADr+vxOZw8ZKzMu4W7mVKW4XfQM93B6a/g XQP0Q+y0lNCfKvd4P9qfYv4w3gKo+wnu+4uR9FzykxTFo5J2xrxRN2xN+eEzC4OEyQKQ b02w== 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; bh=UUgUGWr+vGiadOiv8Llml2/7CB1/Luq0OQTlJtt0e2g=; b=WDoKIyTuPEE779sdfJoTQgmDns+AJWbO4hWvbbDto+eZmm03msNxkhC3UOY7oSOJob vCXqgv9Y+a5QKblci4rn/HcrzNg4+Xli7RvRD37a4gCG4ZOhqN+SUm4kjIZdngCHedrm gsvDYBjFG3QIOfYgpSk+QuiHJwDYM3v4GeVjZ2neGC/92iRLpC7prUB3vNVSPNEFxbTe fNMibA4X4gzSpcr4R16cy0QT7wm7/8zmUgVROEQI9KK2hl4i9gLCmd1d/hEjV8s/pv0a XtwKXGlRkEQBvSfJMCULxpk+9UJwJfByh4Ewzbr2RXb4sd2N/lDEWeFhC0vjrvKPo+t9 Qojg== X-Gm-Message-State: AE9vXwMyuFiOGGsSsbtjynwb76vgM+HaPjZTJR7Q0jY7ZB4sArVmWDiLLfCoSzFBIput7w== X-Received: by 10.46.0.163 with SMTP id e35mr2140316lji.55.1474614704979; Fri, 23 Sep 2016 00:11:44 -0700 (PDT) Received: from hugenb.home (nikaet.starlink.ru. [94.141.168.29]) by smtp.gmail.com with ESMTPSA id s127sm956383lja.46.2016.09.23.00.11.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Sep 2016 00:11:44 -0700 (PDT) From: Nikita Yushchenko To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland , Jaroslav Kysela , Takashi Iwai , =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= , Kuninori Morimoto , Mengdong Lin , Aaro Koskinen , Andrew Lunn , Peter Ujfalusi , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 23 Sep 2016 10:11:12 +0300 Message-Id: <1474614673-12350-1-git-send-email-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.1.4 X-Mailman-Approved-At: Sun, 25 Sep 2016 09:54:12 +0200 Cc: Nikita Yushchenko , Chris Healy Subject: [alsa-devel] [PATCH v2] ASoC: simple-card: add support for aux devices 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 makes it possible to use simple-card in setups where separate amplifier chip is connected to codec's output. Changes from v1: - moved example usage from commit message to Documentation/, as suggested by Kuninori Morimoto, - fixed typo in example usage. Signed-off-by: Nikita Yushchenko --- .../devicetree/bindings/sound/simple-card.txt | 37 ++++++++++++++++++++++ sound/soc/generic/simple-card.c | 34 ++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 59d8628..c7a9393 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -22,6 +22,8 @@ Optional properties: headphones are attached. - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when a microphone is attached. +- simple-audio-card,aux-devs : List of phandles pointing to auxiliary devices, such + as amplifiers, to be added to the sound card. Optional subnodes: @@ -162,3 +164,38 @@ sound { }; }; }; + +Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec +through TPA6130A2 amplifier to headphones: + +&i2c0 { + codec: tlv320dac3100@18 { + compatible = "ti,tlv320dac3100"; + ... + } + + amp: tpa6130a2@60 { + compatible = "ti,tpa6130a2"; + ... + } +} + +sound { + compatible = "simple-audio-card"; + ... + simple-audio-card,widgets = + "Headphone", "Headphone Jack"; + simple-audio-card,routing = + "Headphone Jack", "HPLEFT", + "Headphone Jack", "HPRIGHT", + "LEFTIN", "HPL", + "RIGHTIN", "HPR"; + simple-audio-card,aux-devs = <&>; + simple-audio-card,cpu { + sound-dai = <&ssi2>; + }; + simple-audio-card,codec { + sound-dai = <&codec>; + clocks = ... + }; +}; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 43295f0..f989f34 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -417,6 +417,36 @@ dai_link_of_err: return ret; } +static int asoc_simple_card_parse_aux_devs(struct device_node *node, + struct simple_card_data *priv) +{ + struct device *dev = simple_priv_to_dev(priv); + struct device_node *aux_node; + int i, n, len; + + if (!of_find_property(node, PREFIX "aux-devs", &len)) + return 0; /* Ok to have no aux-devs */ + + n = len / sizeof(__be32); + if (n <= 0) + return -EINVAL; + + priv->snd_card.aux_dev = devm_kzalloc(dev, + n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL); + if (!priv->snd_card.aux_dev) + return -ENOMEM; + + for (i = 0; i < n; i++) { + aux_node = of_parse_phandle(node, PREFIX "aux-devs", i); + if (!aux_node) + return -EINVAL; + priv->snd_card.aux_dev[i].codec_of_node = aux_node; + } + + priv->snd_card.num_aux_devs = n; + return 0; +} + static int asoc_simple_card_parse_of(struct device_node *node, struct simple_card_data *priv) { @@ -474,6 +504,10 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (ret) return ret; + ret = asoc_simple_card_parse_aux_devs(node, priv); + if (ret) + return ret; + return 0; }