Received: by 10.192.165.148 with SMTP id m20csp5257548imm; Wed, 9 May 2018 01:57:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYyyX4f+AIydtc+3NgdpJc+5YGy6c0R97JlyhznjEUAUWsCGOVNd8UIBJPe9JEPLP6Isng X-Received: by 2002:a65:4a48:: with SMTP id a8-v6mr23717785pgu.395.1525856260440; Wed, 09 May 2018 01:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525856260; cv=none; d=google.com; s=arc-20160816; b=orYPh2jhpVC6hPDlG+d0/BNucnE525GjgyJTZTVPgwWAiHkeBzYxLlZeAQTE6K+2y4 9ousncNJTmHRz5B3Miwl0xl4S25lXBLUIkQq0o8dN6P8jzA2pYhuF9l6hoxF7oVVVWpr JUdihQ8a9ZxQPabtvns+5JjS4sT9wT1iIPQJYgdHSqhuISWlA5nIrbv6a7quNgnMcL9A SgNv/wLEKSO198rS2zEHkyZTm01ytV4HGRYWxWYfzPLz2iNTmnljqLF/pkerZJcwNLks z7NIsnelBJDIaSpzAorcdQmPTYIi63vn1dT2nHxFZ2KA356iPMSHUu/wxcNSpom8I2pF oTHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=zekxLcJdyVqqkiO1mj0FAWPgSSEPqoSlvJtUgYM7wJ8=; b=dsQwHy6qHgKJqII9RiscWLJjbI3oTQQWlvoJ03r1kzFt4UiibM0E//+KoSo2shAF00 835RRoy0U8cKfGNPH409GxBNS3rexZWFz1NrkE8AVhQ/Me/tbmruW4cPxlbY284fYQKs zrHZnH11cX/ZZaQXfKdNgdeoyoaAs8VSNiq3NhJbQZJDrAK19zORmSmRla3Jp38AIoRD 4HF1posEvhqamhCanE5/DBT7XnfH4W1ZMPbCIRRaWynRi/D7EIflnOESEPgzzknsfDkA BF84HGiaPo4fPNm6tdfnws7FTOVGgZqUg6wXZKYY7Sh03CXQUZ6KcmQsHxpCg5WD7xbY BF2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=OP87TS81; dkim=pass header.i=@codeaurora.org header.s=default header.b=jQYo79Nk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p73si23345912pfk.275.2018.05.09.01.57.26; Wed, 09 May 2018 01:57:40 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=OP87TS81; dkim=pass header.i=@codeaurora.org header.s=default header.b=jQYo79Nk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934536AbeEII4t (ORCPT + 99 others); Wed, 9 May 2018 04:56:49 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46906 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934443AbeEII4b (ORCPT ); Wed, 9 May 2018 04:56:31 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D8440601A0; Wed, 9 May 2018 08:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525856190; bh=WL13a8it0toXUUrXv+wPHp/mOu5B/Mk8YRIVeHz9wik=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=OP87TS81LqZCTC1pd2JaCLQcDdkf6ZHSbzJ4s4x33piiE4lm91HTQIWnTjD8GR1w/ oXXaVeL8KIkn6G92+UYE85VSEq296gpi/wrZucXGhBj0ogJ6v9kGPBrbH05hsQN+0G Pm4lvL3uNONiTaSm/SrvKGI+Lc/ej2o3g0hAO/K4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.110.9.49] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bgoswami@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5E502601A0; Wed, 9 May 2018 08:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525856189; bh=WL13a8it0toXUUrXv+wPHp/mOu5B/Mk8YRIVeHz9wik=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jQYo79NkFLr6rknJY6BlabIt8kNVjzaDRlN2nHvAsS5rW8nFaZDYuyfuWmYJ7fGT/ ozPHXDehA6UMODYKz/1Yb2KbCSWU0W0uDdCeowYwbTn0Z9010X9grRhQBHDW7ZSyBr osMmtv7DsP1OSabEVk8od42r8Gqbu6hkLT15lg7g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5E502601A0 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgoswami@codeaurora.org Subject: Re: [PATCH v7 17/24] ASoC: qdsp6: q6routing: Add q6routing driver To: Srinivas Kandagatla , 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 References: <20180501120820.11016-1-srinivas.kandagatla@linaro.org> <20180501120820.11016-18-srinivas.kandagatla@linaro.org> From: Banajit Goswami Message-ID: Date: Wed, 9 May 2018 01:56:27 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180501120820.11016-18-srinivas.kandagatla@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 > Reviewed-and-tested-by: Rohit kumar > --- > 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#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