From patchwork Mon Jan 28 14:27:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 156755 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3492481jaa; Mon, 28 Jan 2019 06:29:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN48teCEgD11ecER2wLK0r74iS5IxyeAHLFcujA12ulJlJiWMy9ptEZFjl4KgLWg899Rvb7U X-Received: by 2002:a5d:6b09:: with SMTP id v9mr23151748wrw.304.1548685761365; Mon, 28 Jan 2019 06:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548685761; cv=none; d=google.com; s=arc-20160816; b=LhwZuC4ektBV5KUIcsiORFA5jipTQulXgN8RVuT/41NkREXeEzRtfC+42y2PdYB+8i kulUyYLbVJZ0ljjKMU08wEp3cNrVyr6SzJSTgzURLiiKQjR68TaZf3kEJQ0Cb6gyNeEy eREpw8WJBDL8nagxLr+w4mWkV3izqAzcahRvhbPZVYYpGX3hVKupSqi5j16bmiD5O4yA +r8SRVWGOFSKgk9TJxgpHKpkk0l9cOpeaVBi7XXriQu4yrHQpe4T/AKHzzpOM3isKLJW cHtQ+lZrtuH1qcK0MJIOEGLwwZYqbd5FkissCFYybAtXrgegtp1th+SCr3k4uVXkT48Z UXzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=Vuj/kl0VPdEyKElgVBwHyuOx2balxSB9k/tUCaufprc=; b=cknKFLKhQh++yVAtW0o9Q3ce9X+rVIn7eA+iKYjlWYtrv/5ZaIT3Ov29xOfrKruPXU OuC1azRUUZq3Y2MvldVKJHOwzDTsaMyvmMFbCNlUOATwYMEAL+iwXSbYVF4l/BJ34PI+ FsGuLEetqQJnDJGr7IUDaqfODaZQSs8RPPiFYBoUrRtH8yQzA1zjE13PduVtRBQ1E0yi H53DxqvD2VgHdZDqzQOZSi25P+nL+0XnNYpp8QnHBmuLmyL2DWULX7nGJ62RsDAvMwxd WGcs/LiXaH/AgW3t9viwexsZA3pxmYkbk2Wyxnm7M8ZQU4cbfUPH3rnO6djLkoTW0uSr gfGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="F/7hx7Ib"; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id t64si40865529wmg.17.2019.01.28.06.29.20; Mon, 28 Jan 2019 06:29:21 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="F/7hx7Ib"; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 05224267549; Mon, 28 Jan 2019 15:28:51 +0100 (CET) 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 BC2842674FF; Mon, 28 Jan 2019 15:28:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by alsa0.perex.cz (Postfix) with ESMTP id BFD722674D6 for ; Mon, 28 Jan 2019 15:28:41 +0100 (CET) Received: by mail-wr1-f68.google.com with SMTP id t6so18231237wrr.12 for ; Mon, 28 Jan 2019 06:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=93hAixu+loUiIS/qra8rwBnM/zzZDxWYh2jnBMzxqlw=; b=F/7hx7IbJPdIa3+TUdMGSQT1nbP7Ub1TNe4IJ0VcJKbLaCbMd5R8PMU/68lrw+wyU0 y5NTCSEwsqIjT/HY2MH6abmnkT/qH1zxxc5eb4Ywlh1Xo96J/oVmAXHTAC1FbKVfvrHo DN7WfDMS2ImhO6t4xBF0lJgIi2oaUHRjl2IUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=93hAixu+loUiIS/qra8rwBnM/zzZDxWYh2jnBMzxqlw=; b=buZQpiVGkGBzQEwcCO1t4IWfc3B/Ae4UnhSPfrO4Cijx3BG0TRiHKa82BpvGSJWXCc OzTe1jhdrCAIdEUq0iYwbpSdRuKGWliphMocHycELfagTjMXVnlLO7jemRg3iJrfWe6i ew6Lozmwy7v6/dBoT+OQDQK+UNc50BPjteZm06+SCLfZRh9OHto5XZDKR9E7YPyGv65S O0jPSizxCyHDZELOW+AVfrAzlx+GYy9elYFimA5oZNnqGDBK042KQgg7n0mzzHZ+uiW2 q8SUIKwgXjpzXCyRaT4zeemhj0lGn+Mmzi1cYxuSte/f7/csy7EAPfGTaIVN1Fgb1E2A 7Dhg== X-Gm-Message-State: AJcUukfqZIaDt4nDJRN/8xRhAaKc4cx0f2honN47Lq264NAMDl/jL5gJ UgLsvN0Q4h6lKHDrVL5SOdCbhg== X-Received: by 2002:adf:ae1a:: with SMTP id x26mr21385262wrc.0.1548685721354; Mon, 28 Jan 2019 06:28:41 -0800 (PST) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id x1sm27261123wru.34.2019.01.28.06.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 06:28:40 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Date: Mon, 28 Jan 2019 14:27:53 +0000 Message-Id: <20190128142753.22396-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128142753.22396-1-srinivas.kandagatla@linaro.org> References: <20190128142753.22396-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, bgoswami@codeaurora.org, lgirdwood@gmail.com, vkoul@kernel.org, robh+dt@kernel.org, Srinivas Kandagatla Subject: [alsa-devel] [PATCH v6 8/8] ASoC: apq8096: add slim support 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 Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8096.c | 71 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) -- 2.20.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c index fb45f396ab4a..94363fd6846a 100644 --- a/sound/soc/qcom/apq8096.c +++ b/sound/soc/qcom/apq8096.c @@ -9,6 +9,10 @@ #include #include "common.h" +#define SLIM_MAX_TX_PORTS 16 +#define SLIM_MAX_RX_PORTS 16 +#define WCD9335_DEFAULT_MCLK_RATE 9600000 + static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -23,14 +27,79 @@ static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; } +static int msm_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS]; + u32 rx_ch_cnt = 0, tx_ch_cnt = 0; + int ret = 0; + + ret = snd_soc_dai_get_channel_map(codec_dai, + &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); + if (ret != 0 && ret != -ENOTSUPP) { + pr_err("failed to get codec chan map, err:%d\n", ret); + goto end; + } else if (ret == -ENOTSUPP) { + return 0; + } + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, + rx_ch_cnt, rx_ch); + else + ret = snd_soc_dai_set_channel_map(cpu_dai, tx_ch_cnt, tx_ch, + 0, NULL); + if (ret != 0 && ret != -ENOTSUPP) + pr_err("Failed to set cpu chan map, err:%d\n", ret); + else if (ret == -ENOTSUPP) + ret = 0; +end: + return ret; +} + +static struct snd_soc_ops apq8096_ops = { + .hw_params = msm_snd_hw_params, +}; + +static int apq8096_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dai *codec_dai = rtd->codec_dai; + + /* + * Codec SLIMBUS configuration + * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13 + * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13 + * TX14, TX15, TX16 + */ + unsigned int rx_ch[SLIM_MAX_RX_PORTS] = {144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156}; + unsigned int tx_ch[SLIM_MAX_TX_PORTS] = {128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143}; + + snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), + tx_ch, ARRAY_SIZE(rx_ch), rx_ch); + + snd_soc_dai_set_sysclk(codec_dai, 0, WCD9335_DEFAULT_MCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); + + return 0; +} + static void apq8096_add_be_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link; int i; for_each_card_prelinks(card, i, link) { - if (link->no_pcm == 1) + if (link->no_pcm == 1) { link->be_hw_params_fixup = apq8096_be_hw_params_fixup; + link->init = apq8096_init; + link->ops = &apq8096_ops; + } } }