From patchwork Mon Sep 17 00:57:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 146817 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3197192ljw; Sun, 16 Sep 2018 17:58:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZJDylcgyj6P4RFHNYzI4F0ifLj4e8cFYZTXaCP61Vh93Z9lLoYnQGgeqGqU+CAty0Tx2Wd X-Received: by 2002:a62:1089:: with SMTP id 9-v6mr23533402pfq.30.1537145915807; Sun, 16 Sep 2018 17:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537145915; cv=none; d=google.com; s=arc-20160816; b=ps1Y19I0Ny7aURYYzsUZbdMbKO1VhSRprNtMrrWCRRxsdozrpVwnGF5/3uy/aPkGRn 5+XjeRNVOzX+W/M9dQ1v67qgAUdavWYQXW8qCj+MJcQ325IC4Ux2wWmVJtWvSE7Za7Om VZQpW5RfBNGJVQbmmgZZCl9Lo4Ex9kdcYNfO5jx5BKED5iOGuTJPoaY5ekk/bYbMl8ZY vCuaBh8dl8H95lb9S6fMRFB91q2zgUhxl/H+STbOTPDGqVKS0G6Io/umEVOB78Q9QhVZ +y5UcgamhljlCss9Pvvg4+4KrpePTK+joJpmkMooNyLmiHynD7wjiE50AuS2RAOAS89Q zulA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=v5jS0hoerWyQtchbz0v9U6626LMgnW646KmdSHqbOOU=; b=wBwITWe0SSyUBbckUf/peb5A/U7cejM8s+VJvBJs8EKA6jCO42cwXBcMOFHyHjtDkW g6fE9nCZm4lnCObFkYhBFkZJqzzxEogc9p5t5Bjkjqv3cdshruR4PSg41iTRbEUXauuu ky2NrCC4y4OjTGzmzyDj5fzMrhD7gn1a4YX8d7Jfycj3k20jrTnS/j7BYABjWweQ+psR bz5KBe7UbJEe0IlH3QGjdAneJAWdapwEE2vRjtr8XmKj+B7Oy2WwsjHOsBctsDjLixgf tYHIgBOcflHmXxSamPaVw/3l4+m56H6qeBZGTrU4vSn9qCjdd6E/uZd6afWXdEJJVxAw SWsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YZ9HTA0J; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si13710910plg.453.2018.09.16.17.58.35; Sun, 16 Sep 2018 17:58:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YZ9HTA0J; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbeIQGX1 (ORCPT + 6 others); Mon, 17 Sep 2018 02:23:27 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:33288 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728376AbeIQGXL (ORCPT ); Mon, 17 Sep 2018 02:23:11 -0400 Received: by mail-it0-f68.google.com with SMTP id j198-v6so9720694ita.0 for ; Sun, 16 Sep 2018 17:58:18 -0700 (PDT) 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; bh=v5jS0hoerWyQtchbz0v9U6626LMgnW646KmdSHqbOOU=; b=YZ9HTA0J4LFhATXY/qb234fa1YOFDPUfJrJgVG9/vqeknXt3bO+iYgunv4huQh/tPU kcuEnCOIjlwhHLxmxl9oIHqvZqShKOoTSRTo09SPsOXIZHzqUUciRYeyATlvuc0bWIzN IBJVgY1D13BhMJJqc6sB/a0MhwMKpFCPhiykc= 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; bh=v5jS0hoerWyQtchbz0v9U6626LMgnW646KmdSHqbOOU=; b=gTktYxFnySWGHQXPugJab5LU39TSUzn+GYg0+SnkHAoTd203/ADar60P//znZ+ZL5g ncaGLUPLq8g/vbQ4ZPHBF8WHiA7QijUoz8mgKjzFk0EyIjr4II/xJK1s7T+QsfD6GGM8 Dm/zCD5YLeloYkLEeX84adpnGNGYGdGHQJWt4xHvgzOa9hGNv7uhm6A7wtOh7TDMcSAQ Im9JCXNzYKvO+3WIqXrzG0U4uQt+/8OvD9+ObQXe3LdS5OJO6B64wl5/YIe+uaGt89t3 OrTFcqHHMZ+WFO1G+R0+04+qkApHCrlVGjeOABT8MUNH9em10A5M3oMoCbPc0VNpAiAT Zbjw== X-Gm-Message-State: APzg51Btip1lUbp+h+uw3o3lxjnIRI0Yb0FlzEs8/3jBOKtdmdF8LGxc z0mtfoxkUlkcGpqrvWf7sCJHOA== X-Received: by 2002:a24:2911:: with SMTP id p17-v6mr10801747itp.134.1537145897718; Sun, 16 Sep 2018 17:58:17 -0700 (PDT) Received: from localhost.localdomain ([209.82.80.116]) by smtp.gmail.com with ESMTPSA id f64-v6sm829972ite.4.2018.09.16.17.58.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Sep 2018 17:58:17 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: lee.jones@linaro.org, robh+dt@kernel.org, broonie@kernel.org Cc: mark.rutland@arm.com, lgirdwood@gmail.com, bgoswami@codeaurora.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v4 12/14] ASoC: apq8096: add slim support Date: Sun, 16 Sep 2018 17:57:25 -0700 Message-Id: <20180917005727.32728-13-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180917005727.32728-1-srinivas.kandagatla@linaro.org> References: <20180917005727.32728-1-srinivas.kandagatla@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8096.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) -- 2.9.3 diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c index 1543e85..66a28c2 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,80 @@ 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; + struct snd_soc_card *card = rtd->card; + 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) { + dev_err(card->dev, "failed to get codec chan map : %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) + dev_err(card->dev, "Failed to set cpu chan map : %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 = card->dai_link; int i, num_links = card->num_links; for (i = 0; i < num_links; i++) { - 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; + } link++; } }