From patchwork Thu Dec 19 10:31: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: 182066 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp293839iln; Thu, 19 Dec 2019 02:33:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyEwWSSCnqdPFn8ZR3zPxwFzgluTLK3DBnjLwJi1cZmRcCZqvQrqa5l1s+PVn5Uqa3OY1YO X-Received: by 2002:a05:6830:145:: with SMTP id j5mr7692104otp.242.1576751609657; Thu, 19 Dec 2019 02:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576751609; cv=none; d=google.com; s=arc-20160816; b=Lf4pkukfY7gNcAMiSlCWmdXAzjGqHMBEU4uLZ/8e3TCYgfEZfUStgNumN/wTInpUbD e1TcXkFV2NV6LSxo+p+lZ5r5w5ipuJ9eWRkLeXeT9u6IRya43Llu+tbsyiV6lSpCRXLG pvmetqrc9ehw2lbLP7f5/KmJQQz+l3Gi6C163kHcbtOhu/PumjDyHlvaZINKqrdW81Pf bZMguj7ESnQPDzZL492XIV2NTqn4G13AzViVNB4Syf9Qqo1jNDsGLbPm8qBbGb0xqnWO KsMVvE7f7cIEMAjXkz0R/8ML/xYAXMyzdFmOa1QDNkcTlmKXroyGBJN5457g1F1VlK25 i9Dw== 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=UpfkndITw/1h6ZYfXIWQrUX2mzHma7l6m7IK0V8q2nM=; b=ATIoYOSgC5NxzJSNGNS0cvq411aJwLDKSxrt1LHZ7fUq8bGJp6WqNwe2pmYNDKl1pJ fDy3AM/MiDxznw9uIKZxZNW5QDi/MX2FaprVklPyF4xQ1Vh5o4DTLoU9AvAh/tG63CIf EUdtQn7hG7UKkNOUBXWOFzwVYs89EupCysmrDRhvNubTgy/3M/gy1uK7XSr4irn266Qs AfjBCsMsnIj2MHmV5jfHTnsjRra64+pc4QTiyRmOSf4cKSOuDauRVqKoiLfJOn5KoFZE K+VdvLn5xiM2EzktZG3UiLMe1a6WqDrZxcKNElCoUok4XLLXFSsauztfSBR5Qp5J3Rjx WnQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Jq/RoVBQ"; 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 u186si2983657oig.29.2019.12.19.02.33.29; Thu, 19 Dec 2019 02:33:29 -0800 (PST) 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="Jq/RoVBQ"; 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 S1726992AbfLSKd1 (ORCPT + 27 others); Thu, 19 Dec 2019 05:33:27 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39744 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbfLSKdT (ORCPT ); Thu, 19 Dec 2019 05:33:19 -0500 Received: by mail-wm1-f65.google.com with SMTP id 20so4934102wmj.4 for ; Thu, 19 Dec 2019 02:33:17 -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=UpfkndITw/1h6ZYfXIWQrUX2mzHma7l6m7IK0V8q2nM=; b=Jq/RoVBQUdYougVCwhsmeMWjBjrNCV266LCRZYiOKSQCC+HXqnkdyFQNLqbV3MQfjk t4Ro8rV3EKvd4KHJqxr8Ldmg6vZxVW18xqPRqQ5+YdNa6aT/IVZjHV/M3/VUMo4XXImK BFeXhpMFYhwAY5fqnVWVHs+holLoSXbry+uDxP7kjoMd8l33khaUEtoP7rHWELMiaMfy ZNx6rE0HyNd9nKxLTtTg8m2CPnrZ9lINMdS05P3Z+H7wR/KyXAqCyu4wbwbNYuTORc6k Cdq3snOBdrvb5cHDDxDwpa1yt3c1FQYnDhJhViq3v8DtUHkje3sFj0OdZSw/NmgjfrKk FoHQ== 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=UpfkndITw/1h6ZYfXIWQrUX2mzHma7l6m7IK0V8q2nM=; b=UBiykm76Dm3Wpl53+pr1D2f+FtahK4WXEj6MP91kz3m0wTct83Sna5Q79cSd/UP1s6 ingFTTE4/JXleOIchN3D4k4GOatheuotoq6i9gjtfhqxlJIOm+kj76XRInd0ozDtGWhg 3KsK3pvw0JHXMLdx++6Ht8s9HnRF6dDhmQe3861CPS5aS/1+RxkCdZfFIPTxosMYyuRc obdZUg+tcEBB/DjEel1ORwJrekg1PFdnphQOob1Cdkd+Z/JEFsMOaMTGro1ZZYgdQitF elKPTloi89476UxSXv4yJE8mHel8tHoqN/FVY4yZxDMWuOy7edEcMhOdt2sj8sy+c8Ss /lDw== X-Gm-Message-State: APjAAAVDgUsZkOWXnYaOnyzu15wQDY6+r7Oevd5KyW+PeeisIyLC/WZV 7AC2PIYfV0sX7jNhlOz1pr8KpQ== X-Received: by 2002:a05:600c:2207:: with SMTP id z7mr8847992wml.138.1576751596755; Thu, 19 Dec 2019 02:33:16 -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 i11sm5962942wrs.10.2019.12.19.02.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 02:33:15 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org, lee.jones@linaro.org, linus.walleij@linaro.org Cc: robh@kernel.org, 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 v6 11/11] ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga Date: Thu, 19 Dec 2019 10:31:53 +0000 Message-Id: <20191219103153.14875-12-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191219103153.14875-1-srinivas.kandagatla@linaro.org> References: <20191219103153.14875-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 86 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 28f3cef696e6..3b5547a27aad 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,11 @@ 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; + case QUATERNARY_MI2S_RX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); break; @@ -173,7 +214,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 +265,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; } @@ -256,6 +325,14 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) } snd_soc_dai_set_fmt(cpu_dai, fmt); snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt); + break; + case QUATERNARY_MI2S_RX: + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT, + MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); + + break; case QUATERNARY_TDM_RX_0: @@ -294,6 +371,8 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) } } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); @@ -338,6 +417,9 @@ static void sdm845_snd_shutdown(struct snd_pcm_substream *substream) 0, SNDRV_PCM_STREAM_PLAYBACK); } break; + case SLIMBUS_0_RX...SLIMBUS_6_TX: + case QUATERNARY_MI2S_RX: + break; default: pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); @@ -451,6 +533,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);