Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3411904imm; Sun, 16 Sep 2018 18:00:22 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda4b6INr9CRZxCp/fxrDVPAu+AneODV1KsMB55qwKQ/LBhkEmDSy0yWzQ9eaLaV/d8iT+Tk X-Received: by 2002:a63:69c3:: with SMTP id e186-v6mr20299349pgc.431.1537146022164; Sun, 16 Sep 2018 18:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537146022; cv=none; d=google.com; s=arc-20160816; b=Q8yC0Mn+HSZQ8K1hg4n+cIQTDnRulzcTcwu812iaY9W8hxwkBfH1BrvXn6gNylYZ1L vzluLViEM/aPhkvS1vU1j7LLnS/vPPeLsp+pTvMOjsWeevXuI3PhBgJgDf+lWUVnF9KD SY8q6AnTdYAtN9Rl9OcPUbQPPezBGztbxlaguyxLjQBeVQIDSKI831d6fhGEd8r/x4G3 SIH5S0NKxtHOs2+7m6kRbIUxGcL8/YMmqkxs0hZrDWhSyQS19+Dy5LQdvVFP3Ed6E51w ZUW1+IpTMIQeSaW5Ok31PLonke1btID8tsBNkW4mRh+IdAOTElMxI+t2/9eWItknyl+L 98KQ== 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=dvr1+u+GWDUT4D8sJhOESjjMP71KMy0uL9Ux5vjdK5aZVYZ+LGC+X3BcdsmBKxDidc SmGhlAO3U56CNrTtavzAVjt1Z+mr7QaO5K20hpfVelWK8SwvL4LlpYiI8ijZrzC0RIrl Qcu3c6lF/5VNnO68dJGsXoKwchkcOhyiZuYakaiSxZqGndWe7hzpusGQkloMUZS/3EzT ND4gcUE1a5oiwxSbcVlXi2ZmsX/lRB2Bnw7yLBhCV4FXp+ZzAOoeqtzwSbVQaqNrQ8CO TigyjEQwZq7wi0OmoGS5uRGZQzIJh32fxURQ4DGtOD1yXocF4+GSp2aDudlTah+imKH2 WLDA== 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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 n8-v6si14060970pgl.101.2018.09.16.18.00.06; Sun, 16 Sep 2018 18:00:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728570AbeIQGX1 (ORCPT + 99 others); Mon, 17 Sep 2018 02:23:27 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:37426 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728488AbeIQGXL (ORCPT ); Mon, 17 Sep 2018 02:23:11 -0400 Received: by mail-it0-f65.google.com with SMTP id h20-v6so8921164itf.2 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=UKjBFz9QPMXtKUc3Zne7JlodGIr6L4YC5pO/gCZJASbXrZ7Rc3zsSje0KiEZXBLv/u 7iUDA+3O56cez3IwyICYrszGTbPJjeIsSu+uRgOtqYkCI2Z58kJ2o7XiJxJT8Tk63ZLi 9S+R+LTo/dcCEqcC9mTjkeThBstj5UmutDq9IvG3QJawd3BU8FCFJhoL8PZTOaM1XVFa ZbPeudwDLmp3E0Rf9M/R6UJL5YmQhDYqElv8ns5Mpt3/CZCicfNT1zakhtzRGGpIoLPV xIKj00MFnzzRsXmaN+ZrgJ7LW0XA8Vm2vHoaaUGsoPGs4f5P+Nn4WbBVlXOtnye9LXEr aKfw== X-Gm-Message-State: APzg51DMrvk/jDVkU4qVuJpBlqWVuQPFmh1LWBA9nizmPIKOiRO/wS8b /yYzz5tXuN676CQViF3WXJssiw== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8096.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) 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++; } } -- 2.9.3