From patchwork Fri Oct 18 00:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 176754 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp98659ill; Thu, 17 Oct 2019 17:20:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNtP4zxaaBJiWrgyfZzOqQ9wFGFzCgEMgu98IOYyCjE95hMhPsDiQIopcxXsL3x357aj72 X-Received: by 2002:a17:906:1d02:: with SMTP id n2mr6171384ejh.303.1571358015899; Thu, 17 Oct 2019 17:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571358015; cv=none; d=google.com; s=arc-20160816; b=KNizuRw2l+TcKJ9j9FBHl2g14DuREn3KiZLTZwBj1RXCGUB+QznJ1GS5Ukbh2sbn8W OGWOQR3r9CC/Vme0nqfUnpHeRAfO9IrXNj8tA7vYIgQe3+tMABBmNRdyGWEgnGUzqLN4 RIUbwgCZA906LEX4jeL4rjYwJxYfmbe7j12NzL4XgeQA1/8HeA4PgoNU+JKtTD7+Xpmk yfvafgKqJgRoRW7QM7mJo1pJqXjOhY+iIzH/oHF836zR5W8vLP/RDq16z8NNaYoFwn1d C1kummSXJFfqwU0BuHuY2ubpjTT+c67Cnc1l/pvfdByPJW5GEhzmN2RKxgVowQi6wdPp yr1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GWhC+phGxk4cJHdVi7LihKAUgiJg2uxQnJKT5r5d7UQ=; b=jfQ5f0pY0i/ZIUkpMvaD65mLoxzKMFDZbYZE+4Y1t8FMJfCXiZzR7BLpXjOJvCnZBc bzzIYxWDFC9YykeT8a+q/Q11AnpQlufYys33xoqRxAoi5VxBAgICjMVJQQmoz4r1hl/K UWBcpopJyOHyIlPVvuMqLwdTzWxLunOXLsDCIPBtpjjhCm13h5IQAzwLWz4OcYcO8oxm TebQH1uVEomZoEPuSZ1KvWPFPzMMQz13HQMiQBGCay3+EuAtIiO5y0wBV1VrsNqI82Au ydXVUJXRyNhmqxkxbGwCm5w1S9Q9dZGmOi6tv90bA9FH+rwP4nFYU74+NEGz0aQqVaGP 3dTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HPGmM9E1; 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 j4si3093745edl.192.2019.10.17.17.20.15; Thu, 17 Oct 2019 17:20:15 -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=HPGmM9E1; 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 S2503907AbfJRAUO (ORCPT + 8 others); Thu, 17 Oct 2019 20:20:14 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42905 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503878AbfJRAUN (ORCPT ); Thu, 17 Oct 2019 20:20:13 -0400 Received: by mail-wr1-f66.google.com with SMTP id n14so4254093wrw.9 for ; Thu, 17 Oct 2019 17:20:11 -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 :mime-version:content-transfer-encoding; bh=GWhC+phGxk4cJHdVi7LihKAUgiJg2uxQnJKT5r5d7UQ=; b=HPGmM9E1W83HgllFgk9pMxwjTYsbQzRckZu/VM7VC6LPNi3RBrdhW9K14HGxL475w1 d0kQDj9AIH8llEjBFu7TFoOAshhxYE4kNT1ChG4+rGoOzGTv0wJLd7p36TSfhj8aDL+c /LOXysFNnyYWAGvIRUmU03yEpJzLEK3fka2jYJUOCxrXby2XDCz+xCWjn2pbJtxKdR7i BFLd9g8hwRRxbfwgABRAxB2pBvvLfZXddf828UpwkihvSpHjUxBrMUHeCmjwznUuDu/E /DNMBlvdTWff29L98NL+8nrhAdM/Kn6YgZcJ/iX7jRij8f4q4UbvQoSaLotW0wW71Onw xqiw== 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=GWhC+phGxk4cJHdVi7LihKAUgiJg2uxQnJKT5r5d7UQ=; b=J4O1uMlkfa2+J62Qbmh2fJRRHEeh31F4QLeKdGwinqV0j0L/Cjc74M5RW2p3USWGvn vAZDbJl2FGc0GkADsmILzpY0I5zJTe9E2O2DY8tjPp+oDFLv+13HwHdkCv54cSlgGFwz MZGvfVSQlI44pvBXv1ycdlPHFPaZHe1VhUPOHhrwq4FiuBsg0CJYydUTsQRv/+blbmaX T/zVfdtpiTDPVbCUjg50Xsiz2CV60v35+aioXSXssNtqYG9LYfYGMM7cW6bO9voFcjrL scwV35ur9Qab9Ucd43C42wC30gmIt7j1/YMNanhHAEvvY/omwUKehNq0nj5kcYmeN3+H 0eHw== X-Gm-Message-State: APjAAAUiUl8GuvYXzoC9bSP9P8JemKHh2s3S8sW4Il3WyyEyQviAZHcP ZcC77TgYN8vQI0bSEoeAoKSLIg== X-Received: by 2002:adf:f145:: with SMTP id y5mr5032576wro.330.1571358010901; Thu, 17 Oct 2019 17:20:10 -0700 (PDT) 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 z189sm4851248wmc.25.2019.10.17.17.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 17:20:10 -0700 (PDT) From: Srinivas Kandagatla To: robh@kernel.org, broonie@kernel.org, linus.walleij@linaro.org, lee.jones@linaro.org Cc: vinod.koul@linaro.org, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, spapothi@codeaurora.org, bgoswami@codeaurora.org, linux-gpio@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 11/11] ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga Date: Fri, 18 Oct 2019 01:18:49 +0100 Message-Id: <20191018001849.27205-12-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191018001849.27205-1-srinivas.kandagatla@linaro.org> References: <20191018001849.27205-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch adds support to Lenovo Yoga c630 compatible strings and related setup to the sound machine driver. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 71 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 28f3cef696e6..1ed570c19628 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -24,6 +24,9 @@ #define RIGHT_SPK_TDM_TX_MASK 0xC0 #define SPK_TDM_RX_MASK 0x03 #define NUM_TDM_SLOTS 8 +#define SLIM_MAX_TX_PORTS 16 +#define SLIM_MAX_RX_PORTS 16 +#define WCD934X_DEFAULT_MCLK_RATE 9600000 struct sdm845_snd_data { struct snd_soc_jack jack; @@ -36,6 +39,39 @@ struct sdm845_snd_data { static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; +static int sdm845_slim_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_link *dai_link = rtd->dai_link; + 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, i; + + for (i = 0 ; i < dai_link->num_codecs; i++) { + ret = snd_soc_dai_get_channel_map(rtd->codec_dais[i], + &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); + return ret; + } else if (ret == -ENOTSUPP) { + /* Ignore unsupported */ + continue; + } + + 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); + } + + return 0; +} + static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -151,6 +187,9 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, case QUATERNARY_TDM_TX_0: ret = sdm845_tdm_snd_hw_params(substream, params); break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + ret = sdm845_slim_snd_hw_params(substream, params); + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); break; @@ -173,7 +212,20 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); struct snd_jack *jack; - int rval; + struct snd_soc_dai_link *dai_link = rtd->dai_link; + /* + * 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}; + int rval, i; + if (!pdata->jack_setup) { rval = snd_soc_card_jack_new(card, "Headset Jack", @@ -211,6 +263,21 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) return rval; } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + for (i = 0 ; i < dai_link->num_codecs; i++) { + rval = snd_soc_dai_set_channel_map(rtd->codec_dais[i], + ARRAY_SIZE(tx_ch), + tx_ch, + ARRAY_SIZE(rx_ch), + rx_ch); + if (rval != 0 && rval != -ENOTSUPP) + return rval; + + snd_soc_dai_set_sysclk(rtd->codec_dais[i], 0, + WCD934X_DEFAULT_MCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); + } + break; default: break; } @@ -451,6 +518,8 @@ static int sdm845_snd_platform_remove(struct platform_device *pdev) static const struct of_device_id sdm845_snd_device_id[] = { { .compatible = "qcom,sdm845-sndcard" }, + { .compatible = "qcom,db845c-sndcard" }, + { .compatible = "lenovo,yoga-c630-sndcard" }, {}, }; MODULE_DEVICE_TABLE(of, sdm845_snd_device_id);