From patchwork Thu Jan 10 15:06:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 155195 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1997405jaa; Thu, 10 Jan 2019 07:06:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4aZ0uwpGoj0eHpc9da+H7Jig+1X8a8U4pHG38PQuqgXKi05MoyQPYurf2yssRPbDfAhVcx X-Received: by 2002:a17:902:1126:: with SMTP id d35mr10019146pla.1.1547132803705; Thu, 10 Jan 2019 07:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547132803; cv=none; d=google.com; s=arc-20160816; b=ayll7OJ/+cZ3/VS3ArEHDsxivxIXB2oRalKnexIi9i0WRFAEcRJkD5Z82dCOjM+Zhd dZzJ5h2+JTJ+SL18D15HRRtHgOBKsfpv/FMnuzxaWO5vmgzlnh2yeKqvmZhkOVu8Mi3O NuEIG9hk1Ztz7u4O/rpQF6twJS8JeAfWWXJNd7MxIbGBmxQak/IFb9LTBhLKHzp6RS9k +5PPb1H2JEZWdU+vxuZAZdzNSHp2eWVrb/X31OMSdmp4wHurC/0iCh6PBncxrgh5RBhn nvrh6tbh+LkPAHiPxYsiOdoS5CbA7hPEEOV6Kk8K/MvzCM4gClLuW9Ijv6c2nQ5s6ng9 Awjw== 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=93hAixu+loUiIS/qra8rwBnM/zzZDxWYh2jnBMzxqlw=; b=OUjVcOEEcr8zpZeDM8FC9k+P6lQNykpWjKbNo5/ATJF+q/qCUWHNZDn24JiWGLtDfP 8VacODqh87Pg1Ao9T26BmuWdG1LYlTw5NUaY/AHjbbVkIPdW/BHWxjDUSBk2uJlw8oWn gvBct0U1llSY1TJrpllOGJBma3uZe55uBFpa2nN4QE2GH2/GFenQ6NXjww9+Le5LsTvy kPKRXSi1LUK0IhkEOLA6/VKLSSx9xligLLviy94sTXtqdF8LDXcFM7Dm/XYGOzVnZDjv zd9v2dpDE1p72UP/DgPC9RmLWn3G6teq2Qtuu8eoTzOTEW/0vGozbHkjcwbhrmt+j9jr L/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U8mTj8DV; 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 z61si34056451plb.49.2019.01.10.07.06.43; Thu, 10 Jan 2019 07:06:43 -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=U8mTj8DV; 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 S1729532AbfAJPGl (ORCPT + 31 others); Thu, 10 Jan 2019 10:06:41 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33210 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729490AbfAJPGg (ORCPT ); Thu, 10 Jan 2019 10:06:36 -0500 Received: by mail-wr1-f67.google.com with SMTP id c14so11829384wrr.0 for ; Thu, 10 Jan 2019 07:06:35 -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=U8mTj8DVH8zx3DMoSxfYcTtbCSsuH4WdztWvylHQQfbebGSjwDV6Y0y69ZVFjOoPew rX3FzzkBBhyyK078QDDHVacdnq8R273e7FYVjM3GpuuSmTkJuvLzJj5HGdCVxE8uzY40 rq0ibHQ8Asbnt68Ig06uExrRxQ4vPJzwOsQEg= 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=JD0Ei5FNBWrtlXfiL55x5vmlqwkz/lGfy+0C82D8Kj73qIug40SlTQIG5QTzI8ZaBE iSuGnnkbmMdAXc5lWfUQ6Kx9LvmvovhTxplJzx0RzJWrslpzqC5FBkzb5p9R1RAtMqTH Dtw0WOIRiS+fXLRHzAFaaw2KuqsXKIwWVISK0bNlZLGSrCscW6/TU5IXz4Ru6+6fYhjW xztjJZcGBR0iggnBZSh66ThXpbtGy/cS0iVLcvycBlmX/DS8TG1znNyLHm8SA0EfYLY0 u1qjUMXPMBPHce7XnrnL5FltRNzCi1X5CojR9Oib0A9DOU1UWybgpP7KNJVKh1VObXp9 taFQ== X-Gm-Message-State: AJcUukfEgH+Ch/XEZL+b6tqokrNv404Td9p5jWT5zEdzezJDQWEFtAZa rxgJwyeSG/u22WYaU4JnshL/5w== X-Received: by 2002:adf:9083:: with SMTP id i3mr9480214wri.124.1547132794773; Thu, 10 Jan 2019 07:06:34 -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 b12sm51063754wrt.17.2019.01.10.07.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 07:06:33 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Cc: robh+dt@kernel.org, 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 v5 8/8] ASoC: apq8096: add slim support Date: Thu, 10 Jan 2019 15:06:16 +0000 Message-Id: <20190110150616.2332-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110150616.2332-1-srinivas.kandagatla@linaro.org> References: <20190110150616.2332-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 Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8096.c | 71 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) -- 2.20.1 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; + } } }