LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Banajit Goswami <bgoswami@codeaurora.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	andy.gross@linaro.org, broonie@kernel.org,
	linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
	robh+dt@kernel.org
Cc: gregkh@linuxfoundation.org, david.brown@linaro.org,
	mark.rutland@arm.com, lgirdwood@gmail.com, plai@codeaurora.org,
	tiwai@suse.com, perex@perex.cz, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, rohkumar@qti.qualcomm.com,
	spatakok@qti.qualcomm.com
Subject: Re: [PATCH v7 17/24] ASoC: qdsp6: q6routing: Add q6routing driver
Date: Wed, 9 May 2018 01:56:27 -0700	[thread overview]
Message-ID: <bf93d6d6-ba10-21b9-4bbe-224bb39f56f2@codeaurora.org> (raw)
In-Reply-To: <20180501120820.11016-18-srinivas.kandagatla@linaro.org>


On 5/1/2018 5:08 AM, Srinivas Kandagatla wrote:
> This patch adds support to q6 routing driver which configures route
> between ASM and AFE module using ADM apis.
>
> This driver uses dapm widgets to setup the matrix between AFE ports and
> ASM streams.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Reviewed-and-tested-by: Rohit kumar <rohitkr@codeaurora.org>
> ---
>   sound/soc/qcom/Kconfig           |   4 +
>   sound/soc/qcom/qdsp6/Makefile    |   1 +
>   sound/soc/qcom/qdsp6/q6routing.c | 393 +++++++++++++++++++++++++++++++++++++++
>   sound/soc/qcom/qdsp6/q6routing.h |   9 +
>   4 files changed, 407 insertions(+)
>   create mode 100644 sound/soc/qcom/qdsp6/q6routing.c
>   create mode 100644 sound/soc/qcom/qdsp6/q6routing.h
>
> diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig
> index 941774abd94f..43f9ed85efa8 100644
> --- a/sound/soc/qcom/Kconfig
> +++ b/sound/soc/qcom/Kconfig
> @@ -53,6 +53,9 @@ config SND_SOC_QDSP6_AFE
>   config SND_SOC_QDSP6_ADM
>   	tristate
>   
> +config SND_SOC_QDSP6_ROUTING
> +	tristate
> +
>   config SND_SOC_QDSP6_ASM
>   	tristate
>   
> @@ -63,6 +66,7 @@ config SND_SOC_QDSP6
>   	select SND_SOC_QDSP6_CORE
>   	select SND_SOC_QDSP6_AFE
>   	select SND_SOC_QDSP6_ADM
> +	select SND_SOC_QDSP6_ROUTING
>   	select SND_SOC_QDSP6_ASM
>   	help
>   	 To add support for MSM QDSP6 Soc Audio.
> diff --git a/sound/soc/qcom/qdsp6/Makefile b/sound/soc/qcom/qdsp6/Makefile
> index 01d9dcf3375c..0e8e2febb7ec 100644
> --- a/sound/soc/qcom/qdsp6/Makefile
> +++ b/sound/soc/qcom/qdsp6/Makefile
> @@ -2,4 +2,5 @@ obj-$(CONFIG_SND_SOC_QDSP6_COMMON) += q6dsp-common.o
>   obj-$(CONFIG_SND_SOC_QDSP6_CORE) += q6core.o
>   obj-$(CONFIG_SND_SOC_QDSP6_AFE) += q6afe.o
>   obj-$(CONFIG_SND_SOC_QDSP6_ADM) += q6adm.o
> +obj-$(CONFIG_SND_SOC_QDSP6_ROUTING) += q6routing.o
>   obj-$(CONFIG_SND_SOC_QDSP6_ASM) += q6asm.o
> diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
> new file mode 100644
> index 000000000000..72863672f11f
> --- /dev/null
> +++ b/sound/soc/qcom/qdsp6/q6routing.c
> @@ -0,0 +1,393 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
> +// Copyright (c) 2018, Linaro Limited
> +
> +#include <linux/init.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/of_platform.h>
> +#include <linux/bitops.h>
> +#include <linux/component.h>
> +#include <linux/mutex.h>
> +#include <linux/of_device.h>
> +#include <linux/slab.h>
> +#include <sound/core.h>
> +#include <sound/soc.h>
> +#include <sound/soc-dapm.h>
> +#include <sound/pcm.h>
> +#include <sound/control.h>
> +#include <sound/asound.h>
> +#include <sound/pcm_params.h>
> +#include "q6afe.h"
> +#include "q6asm.h"
> +#include "q6adm.h"
> +#include "q6routing.h"
> +
> +#define DRV_NAME "q6routing-component"
> +
> +struct session_data {
> +	int state;
> +	int port_id;
> +	int path_type;
> +	int app_type;
> +	int acdb_id;
> +	int sample_rate;
> +	int bits_per_sample;
> +	int channels;
> +	int perf_mode;
> +	int numcopps;
> +	int fedai_id;
> +	unsigned long copp_map;
> +};
> +
> +struct msm_routing_data {
> +	struct session_data sessions[MAX_SESSIONS];
> +	struct session_data port_data[AFE_MAX_PORTS];
> +	struct device *dev;
> +	struct mutex lock;
> +};
> +
> +static struct msm_routing_data *routing_data;
> +
> +/**
> + * q6routing_stream_open() - Register a new stream for route setup
> + *
> + * @fedai_id: Frontend dai id.
> + * @perf_mode: Performance mode.
> + * @stream_id: ASM stream id to map.
> + * @stream_type: Direction of stream
> + *
> + * Return: Will be an negative on error or a zero on success.
> + */
> +int q6routing_stream_open(int fedai_id, int perf_mode,
> +			   int stream_id, int stream_type)
> +{
> +	int j, topology, num_copps = 0;
> +	struct route_payload payload;
> +	int copp_idx;
> +	struct session_data *session, *pdata;
> +
> +	if (!routing_data) {
> +		pr_err("Routing driver not yet ready\n");
> +		return -EINVAL;
> +	}
> +
> +	session = &routing_data->sessions[stream_id - 1];
> +	pdata = &routing_data->port_data[session->port_id];
> +
> +	mutex_lock(&routing_data->lock);
> +	session->fedai_id = fedai_id;
> +
> +	session->path_type = pdata->path_type;
> +	session->sample_rate = pdata->sample_rate;
> +	session->channels = pdata->channels;
> +	session->bits_per_sample = pdata->bits_per_sample;
> +
> +	payload.num_copps = 0; /* only RX needs to use payload */
> +	topology = NULL_COPP_TOPOLOGY;
> +	copp_idx = q6adm_open(routing_data->dev, session->port_id,
> +			      session->path_type, session->sample_rate,
> +			      session->channels, topology, perf_mode,
> +			      session->bits_per_sample, 0, 0);
> +
> +	if (copp_idx < 0) {
> +		mutex_unlock(&routing_data->lock);
> +		return -EINVAL;
> +	}
> +
> +	set_bit(copp_idx, &session->copp_map);
> +
> +	for_each_set_bit(j, &session->copp_map, MAX_COPPS_PER_PORT) {
> +		payload.port_id[num_copps] = session->port_id;
> +		payload.copp_idx[num_copps] = j;
> +		num_copps++;
> +	}
> +
> +	if (num_copps) {
> +		payload.num_copps = num_copps;
> +		payload.session_id = stream_id;
> +		q6adm_matrix_map(routing_data->dev, session->path_type,
> +				 payload, perf_mode);
> +	}
> +	mutex_unlock(&routing_data->lock);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(q6routing_stream_open);
> +
> +static struct session_data *get_session_from_id(struct msm_routing_data *data,
> +						int fedai_id)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAX_SESSIONS; i++) {
> +		if (fedai_id == data->sessions[i].fedai_id)
> +			return &data->sessions[i];
> +	}
> +
> +	return NULL;
> +}
> +/**
> + * q6routing_stream_close() - Deregister a stream
> + *
> + * @fedai_id: Frontend dai id.
> + * @stream_type: Direction of stream
> + *
> + * Return: Will be an negative on error or a zero on success.
> + */
> +void q6routing_stream_close(int fedai_id, int stream_type)
> +{
> +	struct session_data *session;
> +	int idx;
> +
> +	session = get_session_from_id(routing_data, fedai_id);
> +	if (!session)
> +		return;
> +
> +	for_each_set_bit(idx, &session->copp_map, MAX_COPPS_PER_PORT)
> +		q6adm_close(routing_data->dev, session->port_id,
> +			    session->perf_mode, idx);
> +
> +	session->fedai_id = -1;
> +	session->copp_map = 0;
> +}
> +EXPORT_SYMBOL_GPL(q6routing_stream_close);
> +
> +static int msm_routing_get_audio_mixer(struct snd_kcontrol *kcontrol,
> +				       struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_dapm_context *dapm =
> +	    snd_soc_dapm_kcontrol_dapm(kcontrol);
> +	struct soc_mixer_control *mc =
> +	    (struct soc_mixer_control *)kcontrol->private_value;
> +	int session_id = mc->shift;
> +	struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
> +	struct msm_routing_data *priv = dev_get_drvdata(c->dev);
> +	struct session_data *session = &priv->sessions[session_id];
> +
> +	if (session->port_id == mc->reg)
> +		ucontrol->value.integer.value[0] = 1;
> +	else
> +		ucontrol->value.integer.value[0] = 0;
> +
> +	return 0;
> +}
> +
> +static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
> +				       struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_dapm_context *dapm =
> +				    snd_soc_dapm_kcontrol_dapm(kcontrol);
> +	struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
> +	struct msm_routing_data *data = dev_get_drvdata(c->dev);
> +	struct soc_mixer_control *mc =
> +		    (struct soc_mixer_control *)kcontrol->private_value;
> +	struct snd_soc_dapm_update *update = NULL;
> +	int be_id = mc->reg;
> +	int session_id = mc->shift;
> +	struct session_data *session = &data->sessions[session_id];
> +
> +	if (ucontrol->value.integer.value[0]) {
> +		session->port_id = be_id;
> +		snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, update);
> +	} else {
> +		session->port_id = -1;
> +		snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, update);
> +	}
> +
> +	return 1;
> +}
> +
> +static const struct snd_kcontrol_new hdmi_mixer_controls[] = {
> +	SOC_SINGLE_EXT("MultiMedia1", HDMI_RX,
> +		       MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0,
At some point in future, when FE DAI IDs become more than "31", 
SOC_DOUBLE_EXT would need to be used with "reg" marked with SND_SOC_NOPM 
and FE DAI and BE DAI IDs passed in shift_left and shift_right. This is 
to avoid having any "shift" operation issue in DAPM code, when reg is 
not marked with SND_SOC_NOPM, and shift value is more than 31.
However, for now, its OK.

Acked-by: Banajit Goswami <bgoswami@codeaurora.org

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2018-05-09  8:56 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01 12:07 [PATCH v7 00/24] ASoC: qcom: Add support to QDSP based Audio Srinivas Kandagatla
2018-05-01 12:07 ` [PATCH v7 01/24] soc: qcom dt-bindings: Add APR bus bindings Srinivas Kandagatla
2018-05-03 23:30   ` [alsa-devel] " Banajit Goswami
2018-05-04 17:33   ` Bjorn Andersson
2018-05-01 12:07 ` [PATCH v7 02/24] soc: qcom: Add APR bus driver Srinivas Kandagatla
2018-05-04 17:45   ` Bjorn Andersson
2018-05-11  3:18   ` Applied "soc: qcom: Add APR bus driver" to the asoc tree Mark Brown
2018-05-01 12:07 ` [PATCH v7 03/24] ASoC: qdsp6: dt-bindings: Add q6core dt bindings Srinivas Kandagatla
2018-05-03 23:45   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 04/24] ASoC: qdsp6: dt-bindings: Add q6afe " Srinivas Kandagatla
2018-05-01 12:37   ` Rob Herring
2018-05-03 23:50   ` Banajit Goswami
2018-05-11  3:17   ` Applied "ASoC: qdsp6: dt-bindings: Add q6afe dt bindings" to the asoc tree Mark Brown
2018-05-01 12:08 ` [PATCH v7 05/24] ASoC: qdsp6: dt-bindings: Add q6adm dt bindings Srinivas Kandagatla
2018-05-03 23:53   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 06/24] ASoC: qdsp6: dt-bindings: Add q6asm " Srinivas Kandagatla
2018-05-03 23:56   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 07/24] ASoC: qdsp6: q6common: Add qdsp6 helper functions Srinivas Kandagatla
2018-05-04  1:35   ` Banajit Goswami
2018-05-11  3:15   ` Applied "ASoC: qdsp6: q6common: Add qdsp6 helper functions" to the asoc tree Mark Brown
2018-05-01 12:08 ` [PATCH v7 08/24] ASoC: qdsp6: q6core: Add q6core driver Srinivas Kandagatla
2018-05-04 19:04   ` Banajit Goswami
2018-05-09  6:06     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 09/24] ASoC: qdsp6: q6afe: Add q6afe driver Srinivas Kandagatla
2018-05-09  2:40   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 10/24] ASoC: qdsp6: qdafe: Add SLIMBus port Support Srinivas Kandagatla
2018-05-09  2:55   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 11/24] ASoC: qdsp6: q6afe: Add support to MI2S ports Srinivas Kandagatla
2018-05-09  3:21   ` Banajit Goswami
2018-05-09  6:05     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 12/24] ASoC: qdsp6: q6afe: Add support to MI2S sysclks Srinivas Kandagatla
2018-05-09  4:29   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 13/24] ASoC: qdsp6: q6adm: Add q6adm driver Srinivas Kandagatla
2018-05-09  7:55   ` Banajit Goswami
2018-05-09  8:08     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 14/24] ASoC: qdsp6: q6asm: Add q6asm driver Srinivas Kandagatla
2018-05-09  8:10   ` Banajit Goswami
2018-05-09  8:15     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 15/24] ASoC: qdsp6: q6asm: Add support to memory map and unmap Srinivas Kandagatla
2018-05-09  8:23   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 16/24] ASoC: qdsp6: q6asm: Add support to audio stream apis Srinivas Kandagatla
2018-05-04  7:11   ` [alsa-devel] " Rohit Kumar
2018-05-04  8:24     ` Srinivas Kandagatla
2018-05-09 10:16   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 17/24] ASoC: qdsp6: q6routing: Add q6routing driver Srinivas Kandagatla
2018-05-09  8:56   ` Banajit Goswami [this message]
2018-05-01 12:08 ` [PATCH v7 18/24] ASoC: qdsp6: q6routing: Add support to all SLIMBus Mixers Srinivas Kandagatla
2018-05-09  8:39   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 19/24] ASoC: qdsp6: q6routing: Add support to MI2S Mixers Srinivas Kandagatla
2018-05-09  8:34   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 20/24] ASoC: qdsp6: q6afe: Add q6afe dai driver Srinivas Kandagatla
2018-05-09  9:42   ` Banajit Goswami
2018-05-09  9:43     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 21/24] ASoC: qdsp6: q6asm: Add q6asm " Srinivas Kandagatla
2018-05-09  9:57   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 22/24] ASoC: qdsp6: dt-bindings: Add apq8096 machine bindings Srinivas Kandagatla
2018-05-09  9:01   ` Banajit Goswami
2018-05-01 12:08 ` [PATCH v7 23/24] ASoC: qcom: apq8096: Add db820c machine driver Srinivas Kandagatla
2018-05-09  9:15   ` Banajit Goswami
2018-05-09 10:03     ` Srinivas Kandagatla
2018-05-01 12:08 ` [PATCH v7 24/24] MAINTAINERS: Add myself as co-maintainer of qcom audio Srinivas Kandagatla
2018-05-09  9:16   ` Banajit Goswami

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf93d6d6-ba10-21b9-4bbe-224bb39f56f2@codeaurora.org \
    --to=bgoswami@codeaurora.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy.gross@linaro.org \
    --cc=broonie@kernel.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=perex@perex.cz \
    --cc=plai@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=rohkumar@qti.qualcomm.com \
    --cc=spatakok@qti.qualcomm.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    --subject='Re: [PATCH v7 17/24] ASoC: qdsp6: q6routing: Add q6routing driver' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).