From patchwork Thu Oct 20 06:00:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: anish kumar X-Patchwork-Id: 9386043 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 7F82160487 for ; Thu, 20 Oct 2016 07:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67BB729AF3 for ; Thu, 20 Oct 2016 07:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59B7329B0C; Thu, 20 Oct 2016 07:14:03 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, 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 F3C8E29AF1 for ; Thu, 20 Oct 2016 07:14:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 070A5267063; Thu, 20 Oct 2016 09:13:59 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5289C2666CF; Thu, 20 Oct 2016 09:11:42 +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 49CD1267029; Thu, 20 Oct 2016 08:00:45 +0200 (CEST) Received: from mail-vk0-f68.google.com (mail-vk0-f68.google.com [209.85.213.68]) by alsa0.perex.cz (Postfix) with ESMTP id 25BB1267018 for ; Thu, 20 Oct 2016 08:00:38 +0200 (CEST) Received: by mail-vk0-f68.google.com with SMTP id 2so2334094vkb.1 for ; Wed, 19 Oct 2016 23:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=xmtHwRJMneo9te4l6N6dDscLwejgw/iarqwfHPmKioQ=; b=QRY6uAwTdz6xcWTAisxbx3wSIJUmo4r8US7sKZqr3LxoDRDXwFwgDUmQc8ywlS49oj JaBHeYaTDHcc8QaXTggN+VlWXVE0ZGRjP35Ba0jsjmxkfuaINSrtqBCJypiuDoCKS/fH iyo+1rhYPyPdYebGgcBkRSaSlzINKEsOZiWr7FE48eHrGV6gmWvWJUJkKVYmFH3Nb5IV pQHUBoIsD5VGYrPovt1N3RD6sP0lVAsWCmazkcTFXyMzZ/6JExJoeG6nSkS0+sk4VCgh fvah47rLtunYEl/u1Azi5hNEfEuhGq2tZwnHvnSQcEDbHpbzmwZYPx13m/4LHbWckPHL RCFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=xmtHwRJMneo9te4l6N6dDscLwejgw/iarqwfHPmKioQ=; b=M26W2D0HKWP7CQb7ULjE+M00v46BUnqQieCq462u7onaCu2rZlXLsE9ZLs61UA9+XB FwTJSkJ3rjCVP2fRmrGbQoXvNxOVJofK2hv2hOixpGB6FQsW4f4SRn3dKew1FvW//CrI fLJCX3IUsCwOYaWi2L3NPiC5R26glhOIk3Wi+ZmHeOsC7uvKn6mU5z7JCfRZj3Dyiytn fXWwBJQ4rVt0nVr8yjnrNPmsISPvohr7L21gz3qwbGBv6y5mkk8kmIyGl5rzI1l8mf1x sI/zD3f2am0aQBkdbzvE/RwJtJ/Ym0mN9K6d0sTnUpjZHMMiBVL3o1ELwCs6k6RIvDUu WgTw== X-Gm-Message-State: AA6/9Rnbj056VhwKBiTwbtjBnTY8yeKoCB8t+x+GrA6FKlnG5GPA8J+N8YFE1u9IRRrggvxEPUMifqg1PECzzQ== X-Received: by 10.31.3.25 with SMTP id 25mr7986281vkd.116.1476943237919; Wed, 19 Oct 2016 23:00:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.88.84 with HTTP; Wed, 19 Oct 2016 23:00:37 -0700 (PDT) From: anish kumar Date: Wed, 19 Oct 2016 23:00:37 -0700 Message-ID: To: perex@perex.cz, tiwai@suse.com, "broonie@kernel.org" , Linux-ALSA , Liam Girdwood , Charles Keepax Subject: [alsa-devel] [PATCH] Codec to codec dai link description 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: anish kumar --- Documentation/sound/alsa/soc/codec_to_codec.txt | 114 ++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/sound/alsa/soc/codec_to_codec.txt diff --git a/Documentation/sound/alsa/soc/codec_to_codec.txt b/Documentation/sound/alsa/soc/codec_to_codec.txt new file mode 100644 index 0000000..b0f221d --- /dev/null +++ b/Documentation/sound/alsa/soc/codec_to_codec.txt @@ -0,0 +1,114 @@ +Creating codec to codec dai link for ALSA dapm +=================================================== + +Mostly the flow of audio is always from CPU to codec so your system +will look as below: + + ---------- --------- +| | dai | | + CPU -------> codec +| | | | + --------- --------- + +In case your system looks as below: + --------- + | | + codec-2 + | | + --------- + | + dai-2 + | + ---------- --------- +| | dai-1 | | + CPU -------> codec-1 +| | | | + ---------- --------- + | + dai-3 + | + --------- + | | + codec-3 + | | + --------- + +Suppose codec-2 is a bluetooth chip and codec-3 is connected to +a speaker and you have a below scenario: +codec-2 will receive the audio data and the user wants to play that +audio through codec-3 without involving the CPU.This +aforementioned case is the ideal case when codec to codec +connection should be used. + +Your dai_link should appear as below in your machine +file: + +static const struct snd_soc_pcm_stream dummy_params = { + .formats = SNDRV_PCM_FMTBIT_S24_LE, + .rate_min = 48000, + .rate_max = 48000, + .channels_min = 2, + .channels_max = 2, +}; + +{ + .name = "your_name", + .stream_name = "your_stream_name", + .cpu_dai_name = "snd-soc-dummy-dai", + .codec_name = "codec-2, + .codec_dai_name = "codec-2-dai_name", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .ignore_suspend = 1, + .params = &dummy_params, +}, +{ + .name = "your_name", + .stream_name = "your_stream_name", + .cpu_dai_name = "snd-soc-dummy-dai", + .codec_name = "codec-3, + .codec_dai_name = "codec-3-dai_name", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .ignore_suspend = 1, + .params = &dummy_params, +}, + +Note the "params" callback which lets the dapm know that this +dai_link is a codec to codec connection. +Also, in above code cpu_dai should be replaced with your actual +cpu dai but in case you don't have a actual cpu dai then dummy will +do. + +You can browse the speyside.c for an actual example code in mainline. + +Note that in current device tree there is no way to mark a dai_link +as codec to codec. However, it may change in future. + +In dapm core a route is created between cpu_dai playback widget +and codec_dai capture widget for playback path and vice-versa is +true for capture path. In order for this aforementioned route to get +triggered, DAPM needs to find a valid endpoint which could be either +a sink or source widget corresponding to playback and capture path +respectively. + +Below is what you can use it to trigger the widgets provided you have +stream name ending with "Playback" and "Capture" for cpu and +codec dai's. + +static const struct snd_soc_dapm_widget aif_dapm_widgets[] = { + SND_SOC_DAPM_SPK("dummyspk", NULL), + SND_SOC_DAPM_MIC("dummymic", NULL), +}; + +static const struct snd_soc_dapm_route audio_i2s_map[] = { + {"dummyspk", NULL, "Playback"}, + {"Capture", NULL, "dummymic"}, +}; + +Above code is good for quick testing but in order to mainline it +you are expected to create a thin codec driver for the speaker +amp rather than doing this sort of thing, as that at least +sets appropriate constraints for the device even if it needs +no control. For an example of such a driver you can see: +sound/soc/codecs/wm8727.c