From patchwork Tue Feb 13 16:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 128273 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4459911ljc; Tue, 13 Feb 2018 09:03:39 -0800 (PST) X-Google-Smtp-Source: AH8x227NUABUfcnwbu/zseUjrwWrDxvhL9YKbfkw9OBvcM7+WYdcEloOcE1lb3OVjNlRe0ZYuKN8 X-Received: by 10.98.34.139 with SMTP id p11mr1903660pfj.119.1518541419392; Tue, 13 Feb 2018 09:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518541419; cv=none; d=google.com; s=arc-20160816; b=yty7qlZxM723VMBa5PTMtFcKEsXSsqLK1281KnL9GYHB1hT/Xquh0Xhnxv49dNJR5R ybXlqJQcDAX8RiY+I9pc3nTdpxpSzbHvhpwieYBsbCNDRwlUwSKGRNjHIV+VFgkYgpGg Uzs9Ud9nnaA80WNoQAtouDAq7ossTzHPBiSWcSnLfutAgkDpmvtxAaq7KWDzy64KNJut +WCHfXtkpwks7PS7NhF1MqJuUrNvaEnN/KXkJbe+CQmyUnx8drdEGQhQ5T8WdE1OoqZN A+4LivfL/EBixzHAHIwJ9IIaUL2g6m20BTdg0Rdo9oxHE6PHGjDLLTcrnVa9sRekzO7J i6nw== 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:arc-authentication-results; bh=4Cif7NSMj1tJeZC9NVKtYwWyChTOSNNGYgcUkU/6x50=; b=KCvNU5XKe7j3Vg85sLI6tILuvNKLyrIha4kbfawajLS1R9APZC+UtqqrKUktkzqGsg mheu6fuFZR5+wCyueYr6ehg4rkY7c70XPr1e9z4FBTmmf06KPg985yqkez0pJB+oEqk9 QdPACgh5ZEjCCrbu30Yv7zcu/mPA9u65ZC8Sj0luCcF2oeQpfKsDmMIg1/BEdxmfhN+L leqPShroI29SCZr/FWQHOHMNKmyvCLIZsBKAp3xiOArbmrKXNYi6xElCarI9hu6Hgzjj FqsZ3r34v2poFTZBH4bGzCN0bcFnhHKrymmh7RfsgrYw6VjTxNNOj7B33D0zQk6IQhoj qPeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kl0Io3WJ; 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 k131si1167293pgc.101.2018.02.13.09.03.39; Tue, 13 Feb 2018 09:03:39 -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=kl0Io3WJ; 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 S965395AbeBMRDf (ORCPT + 28 others); Tue, 13 Feb 2018 12:03:35 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36780 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965497AbeBMRBo (ORCPT ); Tue, 13 Feb 2018 12:01:44 -0500 Received: by mail-wm0-f68.google.com with SMTP id f3so17294458wmc.1 for ; Tue, 13 Feb 2018 09:01:44 -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; bh=4Cif7NSMj1tJeZC9NVKtYwWyChTOSNNGYgcUkU/6x50=; b=kl0Io3WJ6sPI5cainvDkq9Ngwge3kXpkIhTm4lcFitZaKEu0IvLOt9/i/QvPJb7Jio TYzQBQUG7izAHuRrata3+tLDRqV+T4BqDUcUu6OClu+Oq5EzrmfsuScww3uMLZQaRr5c 7uoq/1VVe0v107pL0m1/E0+3tkYD8U8GEmLW8= 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=4Cif7NSMj1tJeZC9NVKtYwWyChTOSNNGYgcUkU/6x50=; b=O74g2/1uGmjMFDVSqP4F+w/6Nt7LZPd0xBNpIboUBB9w6AFiyMckkDLwg3jTNeY6rc 8p35x9ijS47JehxkE/akkhh5IqGCeBEEEa0PuFvcZrVzDoIyh8xWSYp6NobkQoBUw2dp 9PqExHbqeAwLTgM4dwBL32VtoSqsTUn49Qex19EaKNttNYVNiccAZsIroqjei7rnQvvz DMxG9xmI3mj9Wo+rGDVFqluesPpFfzmUao2nR1cqVF3+tE5pVAa8TPsJhDi56m2Tc6Ar gerjAO2fabwG2TB8wyxomuYya1qrL+JMm+kIK/QB4JWxo8cZkapCKEH1eVAkfZwbtPYX rxTA== X-Gm-Message-State: APf1xPA9XMCuh3w6eUMmSWuy6YkhHXZsT8dWzubK2gc12v5sdEVwUu4m bSd0DmAejPRZbVcR2Ik133JQbA== X-Received: by 10.28.137.85 with SMTP id l82mr1935818wmd.109.1518541303194; Tue, 13 Feb 2018 09:01:43 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id y145sm7432723wmd.43.2018.02.13.09.01.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Feb 2018 09:01:42 -0800 (PST) From: srinivas.kandagatla@linaro.org To: andy.gross@linaro.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Cc: david.brown@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com, spatakok@qti.qualcomm.com, Srinivas Kandagatla Subject: [PATCH v3 21/25] ASoC: qcom: q6afe-dai: add support to 4 MI2S ports Date: Tue, 13 Feb 2018 16:58:33 +0000 Message-Id: <20180213165837.1620-22-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180213165837.1620-1-srinivas.kandagatla@linaro.org> References: <20180213165837.1620-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 This patch adds support to 4 MI2S dais supported on LPASS IP. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6afe-dai.c | 154 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) -- 2.15.1 diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c index 39badb701be0..b6db1ae654e8 100644 --- a/sound/soc/qcom/qdsp6/q6afe-dai.c +++ b/sound/soc/qcom/qdsp6/q6afe-dai.c @@ -139,6 +139,31 @@ static int q6hdmi_hw_params(struct snd_pcm_substream *substream, return 0; } +static int q6i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct q6afe_dai_data *dai_data = q6afe_get_dai_data(dai->dev); + struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; + + + i2s->sample_rate = params_rate(params); + i2s->bit_width = params_width(params); + i2s->num_channels = params_channels(params); + + return 0; +} + +static int q6i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct q6afe_dai_data *dai_data = q6afe_get_dai_data(dai->dev); + struct q6afe_i2s_cfg *i2s = &dai_data->port_config[dai->id].i2s_cfg; + + i2s->fmt = fmt; + + return 0; +} + static int q6afe_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -163,6 +188,34 @@ static void q6afe_dai_shutdown(struct snd_pcm_substream *substream, } +static int q6afe_mi2s_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct q6afe_dai_data *dai_data = q6afe_get_dai_data(dai->dev); + int rc; + + if (dai_data->is_port_started[dai->id]) { + /* stop the port and restart with new port config */ + rc = q6afe_port_stop(dai_data->port[dai->id]); + if (rc < 0) { + dev_err(dai->dev, "fail to close AFE port\n"); + return rc; + } + } + + q6afe_i2s_port_prepare(dai_data->port[dai->id], + &dai_data->port_config[dai->id].i2s_cfg); + + rc = q6afe_port_start(dai_data->port[dai->id]); + if (rc < 0) { + dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); + return rc; + } + dai_data->is_port_started[dai->id] = true; + + return 0; +} + static int q6afe_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -224,6 +277,26 @@ static int q6slim_set_channel_map(struct snd_soc_dai *dai, return 0; } +static int q6afe_mi2s_set_sysclk(struct snd_soc_dai *dai, + int clk_id, unsigned int freq, int dir) +{ + struct q6afe_dai_data *dai_data = q6afe_get_dai_data(dai->dev); + struct q6afe_port *port = dai_data->port[dai->id]; + + switch (clk_id) { + case LPAIF_DIG_CLK: + return q6afe_port_set_sysclk(port, clk_id, 0, 5, freq, dir); + case LPAIF_BIT_CLK: + case LPAIF_OSR_CLK: + return q6afe_port_set_sysclk(port, clk_id, + Q6AFE_LPASS_CLK_SRC_INTERNAL, + Q6AFE_LPASS_CLK_ROOT_DEFAULT, + freq, dir); + } + + return 0; +} + static const struct snd_soc_dapm_route q6afe_dapm_routes[] = { {"HDMI Playback", NULL, "HDMI_RX"}, {"Slimbus1 Playback", NULL, "SLIMBUS_1_RX"}, @@ -233,6 +306,10 @@ static const struct snd_soc_dapm_route q6afe_dapm_routes[] = { {"Slimbus5 Playback", NULL, "SLIMBUS_5_RX"}, {"Slimbus6 Playback", NULL, "SLIMBUS_6_RX"}, + {"Primary MI2S Playback", NULL, "PRI_MI2S_RX"}, + {"Secondary MI2S Playback", NULL, "SEC_MI2S_RX"}, + {"Tertiary MI2S Playback", NULL, "TERT_MI2S_RX"}, + {"Quaternary MI2S Playback", NULL, "QUAT_MI2S_RX"}, }; static struct snd_soc_dai_ops q6hdmi_ops = { @@ -242,6 +319,15 @@ static struct snd_soc_dai_ops q6hdmi_ops = { .startup = q6afe_dai_startup, }; +static struct snd_soc_dai_ops q6i2s_ops = { + .prepare = q6afe_mi2s_prepare, + .hw_params = q6i2s_hw_params, + .set_fmt = q6i2s_set_fmt, + .shutdown = q6afe_dai_shutdown, + .startup = q6afe_dai_startup, + .set_sysclk = q6afe_mi2s_set_sysclk, +}; + static struct snd_soc_dai_ops q6slim_ops = { .prepare = q6afe_dai_prepare, .hw_params = q6slim_hw_params, @@ -422,6 +508,63 @@ static struct snd_soc_dai_driver q6afe_dais[] = { .id = SLIMBUS_6_RX, .probe = msm_dai_q6_dai_probe, .remove = msm_dai_q6_dai_remove, + }, { + .playback = { + .stream_name = "Primary MI2S Playback", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE, + .rate_min = 8000, + .rate_max = 48000, + }, + .id = PRIMARY_MI2S_RX, + .name = "PRI_MI2S_RX", + .ops = &q6i2s_ops, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, + }, { + .playback = { + .stream_name = "Secondary MI2S Playback", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 48000, + }, + .name = "SEC_MI2S_RX", + .id = SECONDARY_MI2S_RX, + .ops = &q6i2s_ops, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, + }, { + .playback = { + .stream_name = "Tertiary MI2S Playback", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 48000, + }, + .name = "TERT_MI2S_RX", + .id = TERTIARY_MI2S_RX, + .ops = &q6i2s_ops, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, + }, { + .playback = { + .stream_name = "Quaternary MI2S Playback", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .rate_min = 8000, + .rate_max = 48000, + }, + .name = "QUAT_MI2S_RX", + .id = QUATERNARY_MI2S_RX, + .ops = &q6i2s_ops, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, }, }; @@ -452,6 +595,17 @@ static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = { SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_RX", "Slimbus4 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_OUT("SLIMBUS_5_RX", "Slimbus5 Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_OUT("SLIMBUS_6_RX", "Slimbus6 Playback", 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("QUAT_MI2S_RX", "Quaternary MI2S Playback", + 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("TERT_MI2S_RX", "Tertiary MI2S Playback", + 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("SEC_MI2S_RX", "Secondary MI2S Playback", + 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("SEC_MI2S_RX_SD1", + "Secondary MI2S Playback SD1", + 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("PRI_MI2S_RX", "Primary MI2S Playback", + 0, 0, 0, 0), }; static const struct snd_soc_component_driver q6afe_dai_component = {