Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp522911lqh; Tue, 7 May 2024 06:36:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8A4X4RlV1EBtILy7c40RcuB/1xTAZeWfb0wx74d7gqK2M989EhjrIw8/OO6IirTy44wX2jnpXC7M9VXKMgWkPvbF1RskNVV8mGPakVg== X-Google-Smtp-Source: AGHT+IGUqZAIsIgC/LwMRXnmk//z9qbPdykRKQe2C6MBjfCyAwh2fO3LpafWkRlRvWUiR66rhPaj X-Received: by 2002:a05:620a:1a22:b0:78e:f119:1c18 with SMTP id bk34-20020a05620a1a2200b0078ef1191c18mr16818599qkb.41.1715088975434; Tue, 07 May 2024 06:36:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715088975; cv=pass; d=google.com; s=arc-20160816; b=w/O9Xyv3jumL+StHve1+PXIJVhRRm922xRR4PhVOZ2+mFupRmn1Y8XIk/ZSbaG8mLK juveNrd/Km3JDNXP3N5ubKlRHkw1RNVS8q6SWzVUaU3w2cOYnGpfdBwRwZgx5Y9TytHA N7UGuN7DsOYdYj1VUVkIthPvXDQx3ONvxalPrLXklBPZg3VrEmp1PNTTFx/Uar2TvGnp Yqv1PjOVw9ZDup0frhOqHNGIdw6Y4jOKYj3ZzKtXGVa9at+b+PZccKb298Z8UeVdxpOo XcGBgmPlPQHDn/JOP3UrmhNyfhyBCaUNGatbX/gAjHGIYLlsykJ2t9kVpeSKrDIrESsM zQMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=wlNzM09ry4x5F/SvfwoA6Cda7LNRXq8+feF1giEA3Z4=; fh=TG6lSR5U8W/zFJOAVBTJcfmBfgG7WzpRAIozG/flwFM=; b=f8PLx0A4TbbYwgMtZWRJ1QaDC6Dt2E4BiMlAJ+fr/wu206MUsYbRwnVK5Q8Y7D+o3U JnoDr8N8qd92l+oXZqK+umumx4Ds7cQXyMXRrJEWOkl6m0Y49WpWHDWDasffvaKDzdZm 3xdXPR+JsMY5M7UL+Hk5yI9IOmZLSqBspXCuSGszL7rikM2zfZZem5Ee72AxWRv7Bso4 DBk3Jlo5GB4KmJ0SKZjinNeHA4YwveJ7ct5yTI8VuUQ4uA05hBfWZG23gQdWRuy2vp1J cLQabCZC8V4iFIjR7BemjmErj5RHWp2a0TQ52t4lLjQwtNmtRephrupeXtGiwTAo7/N2 CotA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WRp7wQVR; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-171432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y18-20020a05620a09d200b00790fb1f4e97si11116314qky.174.2024.05.07.06.36.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:36:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WRp7wQVR; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-171432-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171432-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1ED2C1C23D8F for ; Tue, 7 May 2024 13:36:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A26D15E813; Tue, 7 May 2024 13:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WRp7wQVR" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 371A315E1FD for ; Tue, 7 May 2024 13:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715088337; cv=none; b=bKQc2iETP4LTMIDBDM5jpgoT18mugF3OvSbp7m9qPKlehApicBJ62oBVZYF2C542bS1K1vLA2kDSs7HfnhhEz+1MCjWiC35ys4yD7V4sU2ay7lQChcR5CHbDy6eFt2SDVpzge/NklGEYLNMAqJIueoSroohCwttCF/UDVgzU/bQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715088337; c=relaxed/simple; bh=1YdTwfuNwxYNe8Mmuq702r1+TT9SLoVk7UjbXryhPHA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=R6ZpPY8peKquFkFnL4lAMkLQPtB9OfNa0hY7CDzLqcInPQTNhrs4Xf26GuJlQLBGJGiwa6lEk4lz4dvNlO1fzBj+voisqiuay0kGijBMQhrMnmrbFa3pwmdfG63pwtkA+CqiqpDjJ8QSZaBXX5H3VckKGEMpR1xGSgUzMrL4mwI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WRp7wQVR; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-41b21ed19f5so21786205e9.2 for ; Tue, 07 May 2024 06:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715088333; x=1715693133; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wlNzM09ry4x5F/SvfwoA6Cda7LNRXq8+feF1giEA3Z4=; b=WRp7wQVRDonbMfkem1T93yUB/lPd4r/1yObNUWYsOZTIYUwHIvFDZXfqJLtn4rs8UR diSJbyxi0hBBXfOkmrpnqT9XxHmzycFyfrRmu3g6hYEOZ0w1jxEhxCH95ImZUtZMeGMA P/1JLblSxR8C/lH8r+iE0TmFEOtwH+a7o08BNG09Niwjrg4vI4kBDtVO5lcBN3UL8HLc mSAc3pk1nAuq1PVVS5MlfuEPnJZNQx+pPG6yTXDhT5vRFtLNNNmyngIm5eAB9WOal4SC gKw2jTVsxruUrGbCBCr/S33zrEkYamME4bGTrMpzc2Rdh9e1nis1FJNLGjaSHm236ABm D+IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715088333; x=1715693133; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wlNzM09ry4x5F/SvfwoA6Cda7LNRXq8+feF1giEA3Z4=; b=BMuihYWfe6p/+oMseGNu7icqc+kC2AQFQbKcwj3PVuFFNcOvguyrEYmO9j43vL7Z32 hd9GRavv8SLA3eynDuMIcNacaosjb01Kv6gPypy+4qFTKiE/oS/D8MfNp34SpXWgNRQY caymUTsBSbyPpYX9QZleD9Ctk0TEHGzS2xZ0Mw2ASFfya32aFjJ2jZgYFIWoXkjTZBpc WKnL2SNd5UgT5IqU39RmoTLB9y6Rds+Lxpfq3DlQkkANIOj6IstPa3kJBsR84KuXSPCt ePvYSFMYoEmB9+46GTsUiU3ExrH6TEcMJX8OxxijsG8zi4NHgNtvZoJF0NZKph1YE3jD czUw== X-Forwarded-Encrypted: i=1; AJvYcCUafJ8AsKR3pCrbbk9BYhaQ4mQuMIUJx1Bil3ODZk7WvsNdhYlzh2wEWkJt7HSlmjC35GqPeBvcRIIQi6+K0A4H7kbjpy2C1Kfnx92o X-Gm-Message-State: AOJu0YzusjE16S5SJ//JFfU/lTXXveLvTDoJSviS4e2ASmr7gqjLv15D QleZEPRpIfWSYkmzXLzjWGPkh+yKxvLxAeCo0bPtKp/95yssuDvSl30ZRKHv5yA= X-Received: by 2002:a05:600c:1d9c:b0:41b:dafe:ff78 with SMTP id p28-20020a05600c1d9c00b0041bdafeff78mr9340116wms.20.1715088333342; Tue, 07 May 2024 06:25:33 -0700 (PDT) Received: from [192.168.1.195] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id p9-20020a05600c1d8900b0041563096e15sm23691996wms.5.2024.05.07.06.25.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 06:25:32 -0700 (PDT) Message-ID: <89cf75d8-1f85-43d8-9c33-377a04b36121@linaro.org> Date: Tue, 7 May 2024 14:25:31 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] ASoC: qcom: q6dsp: Implement proper channel mapping in Audioreach To: Krzysztof Kozlowski , James Schulman , David Rhodes , Richard Fitzgerald , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Lars-Peter Clausen , =?UTF-8?Q?Nuno_S=C3=A1?= , Banajit Goswami Cc: alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240507-asoc-x1e80100-4-channel-mapping-v1-0-b12c13e0a55d@linaro.org> <20240507-asoc-x1e80100-4-channel-mapping-v1-2-b12c13e0a55d@linaro.org> Content-Language: en-US From: Srinivas Kandagatla In-Reply-To: <20240507-asoc-x1e80100-4-channel-mapping-v1-2-b12c13e0a55d@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07/05/2024 11:27, Krzysztof Kozlowski wrote: > Instead of relying on default channel mapping in all Audioreach > platforms, implement set_channel_map() callback to allow sound cards > customize the mapping depending on needs. > > The channel mapping is set on frontend DAIs coming from the topology, > not DTS, thus need to add DAI ops in topology dai_load() callback. > > Signed-off-by: Krzysztof Kozlowski > --- > sound/soc/qcom/qdsp6/audioreach.c | 2 +- > sound/soc/qcom/qdsp6/audioreach.h | 1 + > sound/soc/qcom/qdsp6/q6apm.c | 28 +++++++++++++++++++++++++++- > sound/soc/qcom/qdsp6/q6apm.h | 8 ++++++++ > sound/soc/qcom/qdsp6/topology.c | 12 ++++++++++++ > 5 files changed, 49 insertions(+), 2 deletions(-) Please use the existing q6dma_set_channel_map() and set the channel map for the backend dai from machine driver, this should work. setting channels on FE is not a scalable one. Please take a look at some of the patches that I shared privately. --srini > > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c > index c655f0213723..8175678d8843 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c > @@ -267,7 +267,7 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token > } > EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt); > > -static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) > +void audioreach_set_channel_mapping(u8 *ch_map, int num_channels) > { > if (num_channels == 1) { > ch_map[0] = PCM_CHANNEL_FL; > diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h > index 2c82917b7162..cef9a9015dcc 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.h > +++ b/sound/soc/qcom/qdsp6/audioreach.h > @@ -767,6 +767,7 @@ struct audioreach_module_config { > /* Packet Allocation routines */ > void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t > token); > +void audioreach_set_channel_mapping(u8 *ch_map, int num_channels); > void *audioreach_alloc_cmd_pkt(int payload_size, uint32_t opcode, > uint32_t token, uint32_t src_port, > uint32_t dest_port); > diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c > index 2a2a5bd98110..c29a2dd36992 100644 > --- a/sound/soc/qcom/qdsp6/q6apm.c > +++ b/sound/soc/qcom/qdsp6/q6apm.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > #include > #include > #include "audioreach.h" > @@ -29,6 +30,29 @@ struct apm_graph_mgmt_cmd { > > static struct q6apm *g_apm; > > +static int q6apm_dai_set_channel_map(struct snd_soc_dai *dai, > + unsigned int tx_num, > + const unsigned int *tx_ch_mask, > + unsigned int rx_num, > + const unsigned int *rx_ch_mask) > +{ > + struct q6apm *apm = dev_get_drvdata(dai->dev); > + int i; > + > + if (dai->id >= ARRAY_SIZE(apm->dai_config)) > + return -EINVAL; > + > + apm->dai_config[dai->id].num_channels = rx_num; > + for (i = 0; i < rx_num; i++) > + apm->dai_config[dai->id].channel_map[i] = rx_ch_mask[i]; > + > + return 0; > +} > + > +const struct snd_soc_dai_ops q6apm_dai_ops = { > + .set_channel_map = q6apm_dai_set_channel_map, > +}; > + > int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt, uint32_t rsp_opcode) > { > gpr_device_t *gdev = apm->gdev; > @@ -722,7 +746,7 @@ static int apm_probe(gpr_device_t *gdev) > { > struct device *dev = &gdev->dev; > struct q6apm *apm; > - int ret; > + int ret, i; > > apm = devm_kzalloc(dev, sizeof(*apm), GFP_KERNEL); > if (!apm) > @@ -733,6 +757,8 @@ static int apm_probe(gpr_device_t *gdev) > mutex_init(&apm->lock); > apm->dev = dev; > apm->gdev = gdev; > + for (i = 0; i < ARRAY_SIZE(apm->dai_config); i++) > + audioreach_set_channel_mapping(apm->dai_config[i].channel_map, 4); > init_waitqueue_head(&apm->wait); > > INIT_LIST_HEAD(&apm->widget_list); > diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h > index c248c8d2b1ab..0e2e7b6cd6c1 100644 > --- a/sound/soc/qcom/qdsp6/q6apm.h > +++ b/sound/soc/qcom/qdsp6/q6apm.h > @@ -47,6 +47,11 @@ > #define APM_LAST_BUFFER_FLAG BIT(30) > #define NO_TIMESTAMP 0xFF00 > > +struct q6apm_dai_config { > + unsigned int num_channels; > + u8 channel_map[AR_PCM_MAX_NUM_CHANNEL]; > +}; > + > struct q6apm { > struct device *dev; > gpr_port_t *port; > @@ -65,6 +70,7 @@ struct q6apm { > struct idr sub_graphs_idr; > struct idr containers_idr; > struct idr modules_idr; > + struct q6apm_dai_config dai_config[4]; > }; > > struct audio_buffer { > @@ -108,6 +114,8 @@ struct q6apm_graph { > struct audioreach_graph_info *info; > }; > > +extern const struct snd_soc_dai_ops q6apm_dai_ops; > + > /* Graph Operations */ > struct q6apm_graph *q6apm_graph_open(struct device *dev, q6apm_cb cb, > void *priv, int graph_id); > diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c > index 70572c83e101..9708d200568d 100644 > --- a/sound/soc/qcom/qdsp6/topology.c > +++ b/sound/soc/qcom/qdsp6/topology.c > @@ -1034,6 +1034,17 @@ static int audioreach_tplg_complete(struct snd_soc_component *component) > return 0; > } > > +static int audioreach_dai_load(struct snd_soc_component *cmp, int index, > + struct snd_soc_dai_driver *dai_drv, > + struct snd_soc_tplg_pcm *pcm, > + struct snd_soc_dai *dai) > +{ > + if (pcm) > + dai_drv->ops = &q6apm_dai_ops; > + > + return 0; > +} > + > /* DAI link - used for any driver specific init */ > static int audioreach_link_load(struct snd_soc_component *component, int index, > struct snd_soc_dai_link *link, > @@ -1251,6 +1262,7 @@ static struct snd_soc_tplg_ops audioreach_tplg_ops = { > .widget_unload = audioreach_widget_unload, > > .complete = audioreach_tplg_complete, > + .dai_load = audioreach_dai_load, > .link_load = audioreach_link_load, > > .dapm_route_load = audioreach_route_load, >