From patchwork Thu Sep 15 12:38:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2874ECAAD3 for ; Thu, 15 Sep 2022 12:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbiIOMix (ORCPT ); Thu, 15 Sep 2022 08:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbiIOMiw (ORCPT ); Thu, 15 Sep 2022 08:38:52 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C85480487 for ; Thu, 15 Sep 2022 05:38:51 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id t14so30682802wrx.8 for ; Thu, 15 Sep 2022 05:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=S1Wbe703KgwRjRnGYT1UQwDcnhEdqY3xQGpBo/iRxEg=; b=q3+13rQMZe8hlYwv/HASxaymo9QU7p0gObvq/d5o6KQtnwUylgUQplJPjfYGffqCks 5F8EjLkvigkbDjNM/++o1zWtG42OLmXzp5MMrrYIlwQNsHdvpqwXnTxzuOChx7YdbIF2 fl25J3FTfrJHkdgOmt7xYOzP8q88Yk2acfQB0tgY+2zOLpS0nEI1If4HYXPZvi7zEd6X HnMLg7bfjO8enspJ0UONS20xGgvWOTi6Bf7Evs9FpONh7OZuLB9MCiDWcxESInWFTq2E TcVA11DFo8vV7r5L/1XEAB0Tt4JbgyLxvNiUiSD5VKvCtiaoeo+VhJDF/ghafdcJvrNb lifg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=S1Wbe703KgwRjRnGYT1UQwDcnhEdqY3xQGpBo/iRxEg=; b=YLL3V9RGihlWvHmdDbHE9HEVyngehwtqBUfGagUhcKjR/EtAZP2mq5KJ+zZgntZwob 5mM6Qsbr8B6ETxHZS0xin0qVZ2rVlezJZzfzZISdeGfWmktJNouG/N+ph/Qwesc2sE2w QFy8pU6/CA3NKf/FLSa1Vacb67pIWPXFFEmCkxQhg22yHTYhnMigOASoIEqgCIYdZy2i /rccUgjl6BZu2zWwdgFLYZM+axxKdQ3UoAMSbL/AC2pl7/E/t2XevGZEvcqv5tFSru0r /7MdUSTzjx5o/J2sjvLWy4oSwMPVQeJfsa/YqmYpu8V6b55lUUbPvzJCn1MK8YIm3GW/ 9esw== X-Gm-Message-State: ACgBeo0JOaFgMd9rRzadhKXQ98y59nYLntnOtViQWoNfsll3R/mxNr2l TZXb7I1O0zW291pXJygKaYuZZw== X-Google-Smtp-Source: AA6agR6FwgsGTkzftq/NA192AJGeqy4nG8K/OS7cYBnFj10qXrYUHizyklw0lCpWs5mOS0cI7s/0jw== X-Received: by 2002:a05:6000:1689:b0:22a:a66d:1f37 with SMTP id y9-20020a056000168900b0022aa66d1f37mr10986312wrd.197.1663245529897; Thu, 15 Sep 2022 05:38:49 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:48 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 1/9] ASoC: qdsp6: audioreach: topology use idr_alloc_u32 Date: Thu, 15 Sep 2022 13:38:29 +0100 Message-Id: <20220915123837.11591-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org SubGraph and Module Instance ids take 32 bits, so use idr_alloc_u32 instead of idr_alloc to able to accomdate valid ranges. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/topology.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index bd649c232a06..9a3d9e0eae53 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -44,7 +44,7 @@ static struct audioreach_graph_info *audioreach_tplg_alloc_graph_info(struct q6a INIT_LIST_HEAD(&info->sg_list); mutex_lock(&apm->lock); - ret = idr_alloc(&apm->graph_info_idr, info, graph_id, graph_id + 1, GFP_KERNEL); + ret = idr_alloc_u32(&apm->graph_info_idr, info, &graph_id, graph_id, GFP_KERNEL); mutex_unlock(&apm->lock); if (ret < 0) { @@ -53,7 +53,7 @@ static struct audioreach_graph_info *audioreach_tplg_alloc_graph_info(struct q6a return ERR_PTR(ret); } - info->id = ret; + info->id = graph_id; return info; } @@ -94,7 +94,7 @@ static struct audioreach_sub_graph *audioreach_tplg_alloc_sub_graph(struct q6apm INIT_LIST_HEAD(&sg->container_list); mutex_lock(&apm->lock); - ret = idr_alloc(&apm->sub_graphs_idr, sg, sub_graph_id, sub_graph_id + 1, GFP_KERNEL); + ret = idr_alloc_u32(&apm->sub_graphs_idr, sg, &sub_graph_id, sub_graph_id, GFP_KERNEL); mutex_unlock(&apm->lock); if (ret < 0) { @@ -103,7 +103,7 @@ static struct audioreach_sub_graph *audioreach_tplg_alloc_sub_graph(struct q6apm return ERR_PTR(ret); } - sg->sub_graph_id = ret; + sg->sub_graph_id = sub_graph_id; return sg; } @@ -136,7 +136,7 @@ static struct audioreach_container *audioreach_tplg_alloc_container(struct q6apm INIT_LIST_HEAD(&cont->modules_list); mutex_lock(&apm->lock); - ret = idr_alloc(&apm->containers_idr, cont, container_id, container_id + 1, GFP_KERNEL); + ret = idr_alloc_u32(&apm->containers_idr, cont, &container_id, container_id, GFP_KERNEL); mutex_unlock(&apm->lock); if (ret < 0) { @@ -145,7 +145,7 @@ static struct audioreach_container *audioreach_tplg_alloc_container(struct q6apm return ERR_PTR(ret); } - cont->container_id = ret; + cont->container_id = container_id; cont->sub_graph = sg; /* add to container list */ list_add_tail(&cont->node, &sg->container_list); @@ -181,7 +181,7 @@ static struct audioreach_module *audioreach_tplg_alloc_module(struct q6apm *apm, AR_MODULE_DYNAMIC_INSTANCE_ID_START, AR_MODULE_DYNAMIC_INSTANCE_ID_END, GFP_KERNEL); } else { - ret = idr_alloc(&apm->modules_idr, mod, module_id, module_id + 1, GFP_KERNEL); + ret = idr_alloc_u32(&apm->modules_idr, mod, &module_id, module_id, GFP_KERNEL); } mutex_unlock(&apm->lock); @@ -191,7 +191,7 @@ static struct audioreach_module *audioreach_tplg_alloc_module(struct q6apm *apm, return ERR_PTR(ret); } - mod->instance_id = ret; + mod->instance_id = module_id; /* add to module list */ list_add_tail(&mod->node, &cont->modules_list); mod->container = cont; From patchwork Thu Sep 15 12:38:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ECC4ECAAA1 for ; Thu, 15 Sep 2022 12:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiIOMi4 (ORCPT ); Thu, 15 Sep 2022 08:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiIOMix (ORCPT ); Thu, 15 Sep 2022 08:38:53 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE87880487 for ; Thu, 15 Sep 2022 05:38:52 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id k9so30732542wri.0 for ; Thu, 15 Sep 2022 05:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cF5Zvj+Kzci/ADALngKgDuePH0r1ubNxIDC6FLO5nXI=; b=xRntcD65ImZt0Qvcy5pgORY8i31L4sVZXe4AvYM+9j8OpHdQxrbHMOiDRsipUHWcCd l5AhGGwxRmY+PMQ9DE8rpupkzkthHuG83aHtPMhws4f4NK/xi5uMFP5XOoKW3DFoLC8f kz//kloxDtoXlbLKruVBhpBrOJ/0is+k0tZMz6kH2JfWaPWy3awtygdjC+J1Mk5PNpdm uxFOVftD1ukCEMga7GQc2mQ1u39oOCHPSCe2O9L/4vvacTP/+ma2gRwko/OzE+TkBscy gcOOeMdO1eCw+/p85RqzmwAo3uJB4qwBShSGAW58mIB6Qc8OcqZ7N8NND00Ty9i/Pec8 /uHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cF5Zvj+Kzci/ADALngKgDuePH0r1ubNxIDC6FLO5nXI=; b=NObDLANEsqAeSVqiXNynvFUGE87tV9k0FpJ4i6w8pkJtnMzNh5+rn9wjOKyW8T9xZ/ 8OKJlOv5ShLn9FQozwRzDnpSq2ysXB/wjFHhT+EvX+dQjU92Nvo2H4D2BX5Zg4rGuMSp PO4CE7rDd0d/6lpAclZyoFXfB6aSLm0ogh4X6EKmbS6g+WM/95QcQVZyUbI5DgfC22S8 YKBW2MQDqESynv9run8r7KQapLHrz+iurstyuC0DN98RTB4fiJ7PD1nrcZsXf+jl6b6w KFez02yb/2kp20pvn5Wq0oniBnVNzperiTrvNtVDdW2EQ3k7B2QN5PdRm2pgqrwCU6oZ 3GLA== X-Gm-Message-State: ACgBeo3wW0FJDxY8/fA33tZUy9Tm+yjDvUo4cc3Cl5B7MEJF5oAD1dWc icN4hGCYqo7XPeZrxH6f8QSAoQ== X-Google-Smtp-Source: AA6agR6BXpa+AHGkWqlwHEYogbX1by5tJVRtrI+F2Bpc7XdH5DCzlDtGbU/IgmNpyapi98wEYpw7aQ== X-Received: by 2002:a05:6000:1a8a:b0:22a:43ef:94f0 with SMTP id f10-20020a0560001a8a00b0022a43ef94f0mr17546728wry.279.1663245531516; Thu, 15 Sep 2022 05:38:51 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:50 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 2/9] ASoC: qdsp6: audioreach: remove unused connection_list Date: Thu, 15 Sep 2022 13:38:30 +0100 Message-Id: <20220915123837.11591-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Remove unused connection_list parameter. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 3ee8bfcd0121..36779ad1952d 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -595,7 +595,6 @@ struct audioreach_graph_info { int id; uint32_t num_sub_graphs; struct list_head sg_list; - struct list_head connection_list; }; struct audioreach_sub_graph { From patchwork Thu Sep 15 12:38:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FEEFECAAA1 for ; Thu, 15 Sep 2022 12:39:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbiIOMjA (ORCPT ); Thu, 15 Sep 2022 08:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiIOMiz (ORCPT ); Thu, 15 Sep 2022 08:38:55 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2BD81B3C for ; Thu, 15 Sep 2022 05:38:54 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id e18so7626518wmq.3 for ; Thu, 15 Sep 2022 05:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Zia5PwPjvTpWqvNWhun5tKRspbVbRhZxzacUZUNqQiU=; b=LEWcsEPgF6HIafqmWf43ZmzIXZJKMJkx93tfpFRNdRGFx73qobC4DXt6nEN9rlpDbU UHyOoEkh45rRDUwLn7BNi3wpL/5wRgFPDsiYgeF6wNwlwIBvBmzT/HLv2vceAE8Sh99o lxjzgM30++pHNSjAClJJqC9cGr9PEzE3rYXy6DoEp8jA6RoYJES04whqHHjOo7KUpps5 LfB3IWvVwLLbW8+BR9Pkq7sIYWMDGacrQZipe6vLNLy4B8C4nzSHrMixV9OFbKixqNyT RfcVsHR8cCsGEHRIEX1WYRWE/WKKw2txjIQHxOtkJjUlkpJlCygqlVNuKd1LjaFdPC62 RerQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Zia5PwPjvTpWqvNWhun5tKRspbVbRhZxzacUZUNqQiU=; b=BvA1Yf6+vFzbyJbKkfuOtmNH0ity8WWWomvFprgL2dlgiGWanIDkm3iPlRoBh4SI0b Q5L5oM6Ls8HUNu+NLKBoLIiXQwB/DpEzdbcQit4QRLc2+XgZXI3Y4dQrqDIpQwAN8lZz q/G+BEcf1UvwaKAvlBSx0FekLjTAq8dQtwoGkGSGKrk25Ymia4M+EEGocsG+Q6fqfjyK ztuOulWXaDvtaQgbE2jD4onBDiEzNjFQ7fipTrGgDxCK62gFqf0zSsBuNaKrAAnq3tHt vhZ7UH5fnN3IKufWYBf4WWaxiVCvdAxJZT82qt0yu2Fd+lzZ8QP8W5o6calqGJ1YQ0RY mWnQ== X-Gm-Message-State: ACgBeo2evnrMEbXS3vev8mYU6brLLjd39NS2Uz9YXnn8bToJFEtE4zLH /7FlAQLOQvPuOfUH+gCmP2AWjQ== X-Google-Smtp-Source: AA6agR5ND0ehbZKyqmCXUJNn0CM7WfvUwi3EWXaMkwhqaapsS1+QAdUuIyDZgg3MTZCRmLF8cYL6Zg== X-Received: by 2002:a05:600c:22c7:b0:3b4:92ba:ff99 with SMTP id 7-20020a05600c22c700b003b492baff99mr6939278wmg.190.1663245532832; Thu, 15 Sep 2022 05:38:52 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:52 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 3/9] ASoC: qdsp6: audioreach: update dapm kcontrol private data Date: Thu, 15 Sep 2022 13:38:31 +0100 Message-Id: <20220915123837.11591-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Update kcontrol private date to include more information like graph id and module instance id which its connected to. Also maintain this virtual dapm mixer widget in a list so that we could lookup while FE and BE connection are added. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm.c | 1 + sound/soc/qcom/qdsp6/q6apm.h | 1 + sound/soc/qcom/qdsp6/topology.c | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 794019286c70..81e2d7090fb4 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -731,6 +731,7 @@ static int apm_probe(gpr_device_t *gdev) apm->gdev = gdev; init_waitqueue_head(&apm->wait); + INIT_LIST_HEAD(&apm->widget_list); idr_init(&apm->graph_idr); idr_init(&apm->graph_info_idr); idr_init(&apm->sub_graphs_idr); diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 54eadadf712c..96ad5ea2ae07 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -58,6 +58,7 @@ struct q6apm { struct mutex lock; uint32_t state; + struct list_head widget_list; struct idr graph_idr; struct idr graph_info_idr; struct idr sub_graphs_idr; diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index 9a3d9e0eae53..0c4886d30131 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -16,7 +16,11 @@ #include "audioreach.h" struct snd_ar_control { + u32 graph_id; /* Graph ID */ u32 sgid; /* Sub Graph ID */ + u32 module_instance_id; /* Connected Module Instance ID */ + struct snd_soc_dapm_widget *w; + struct list_head node; struct snd_soc_component *scomp; }; @@ -692,6 +696,7 @@ static int audioreach_widget_load_mixer(struct snd_soc_component *component, struct snd_soc_tplg_vendor_value_elem *w_elem; struct snd_soc_tplg_vendor_array *w_array; struct snd_ar_control *scontrol; + struct q6apm *data = dev_get_drvdata(component->dev); struct snd_soc_dobj *dobj; int tkn_count = 0; @@ -711,6 +716,9 @@ static int audioreach_widget_load_mixer(struct snd_soc_component *component, case AR_TKN_U32_SUB_GRAPH_INSTANCE_ID: scontrol->sgid = le32_to_cpu(w_elem->value); break; + case AR_TKN_DAI_INDEX: + scontrol->graph_id = le32_to_cpu(w_elem->value); + break; default: /* ignore other tokens */ break; } @@ -718,6 +726,9 @@ static int audioreach_widget_load_mixer(struct snd_soc_component *component, w_elem++; } + scontrol->w = w; + list_add_tail(&scontrol->node, &data->widget_list); + return 0; } @@ -819,7 +830,10 @@ static int audioreach_widget_unload(struct snd_soc_component *scomp, if (w->id == snd_soc_dapm_mixer) { /* virtual widget */ - kfree(dobj->private); + struct snd_ar_control *scontrol = dobj->private; + + list_del(&scontrol->node); + kfree(scontrol); return 0; } @@ -998,6 +1012,9 @@ static int audioreach_control_load_mix(struct snd_soc_component *scomp, case AR_TKN_U32_SUB_GRAPH_INSTANCE_ID: scontrol->sgid = le32_to_cpu(c_elem->value); break; + case AR_TKN_DAI_INDEX: + scontrol->graph_id = le32_to_cpu(c_elem->value); + break; default: /* Ignore other tokens */ break; From patchwork Thu Sep 15 12:38:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D8F5ECAAD3 for ; Thu, 15 Sep 2022 12:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiIOMjH (ORCPT ); Thu, 15 Sep 2022 08:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiIOMi6 (ORCPT ); Thu, 15 Sep 2022 08:38:58 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC3283070 for ; Thu, 15 Sep 2022 05:38:56 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id az6so13829681wmb.4 for ; Thu, 15 Sep 2022 05:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XnvKFYYKXcSrDml2+Zs9IIxXB5gFcGZQDx89p5yTLgY=; b=yntXbuZxm0FgsIaciAXKsgkT5M4eRAhhoz1TRvvFWBkI7yKB4BubnUYiym6AZfVrrk iVbcS7psA3bIbJq3h0fLuRk5AgnnrjBDelae42rnSc/MKcqd1UfbAANAwxkhdqROFZxV jmn1bPuJWNocPVlLS4oaJRCXy250snFTRp4E7z54qokXHNJgZ1H2FM7408Xyq80HL2Hl 3FWICGUUkrfX3J75L4LxNEmnEBGP/XVRe4ZfSFhhKPgYuqom2crrXnWO2/IXiN/kisM0 NFjADHxqS7tXVQGHG6OLqJFqgSTQuTqVLFk8SIgPozIqEaMDo8bIgY8l8rOtcRlkOYL8 ua2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XnvKFYYKXcSrDml2+Zs9IIxXB5gFcGZQDx89p5yTLgY=; b=Oxdf/gixC8hyQzA/UooJ+HUl0q0jjqRCODQ3kjkJTfnZKw25EG2gOWu8MsHGueDFZ2 1/aPiXdDgRPDxKiFOfbNrvh0LZZyvLjrCWjD91IG82Hrh7xjNFU1mPn1XsCY58FDy9nG Mnh/WglMZCBYdB2KizU+eSGTpt6kovYJFJT1Yvyn/53B10Ffy9+aaq15sp5m5AL0HJLb lGwg9Mpa9/76xUTmtdlnXhF4jpGa809TpKCUi9LUQCPnOe9OjAdhGyo6lPNRq4bIlnSH YnjTfyyG9XAeiLbP4xmW9uN5bYdHr+HS27O7t87jTpS7uDIEjm0S3+8gGz8j1TETOLQ2 1QXg== X-Gm-Message-State: ACgBeo1eEFzF4o7E7YVKE2X9AQQUL8iY+jSJB11YkfcuHsQ5JJe6QQkF TZhM49UIb+wf2fUFPEgA4wCIuw== X-Google-Smtp-Source: AA6agR6sg6efNFIq/i03biaCsxeZiJeUog6M9uC6LLkh13EMQQ+8/jvc+R9TG81K4P2XelUGyh1/fw== X-Received: by 2002:a05:600c:1694:b0:3b4:6205:1f95 with SMTP id k20-20020a05600c169400b003b462051f95mr6790418wmn.151.1663245534494; Thu, 15 Sep 2022 05:38:54 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:53 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 4/9] ASoC: qdsp6: audioreach: Simplify handing FE and BE graph connections Date: Thu, 15 Sep 2022 13:38:32 +0100 Message-Id: <20220915123837.11591-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Current AudioReach design of connecting FE and BE graph is very complicated and not reliable. Instead used the virtual damp widgets private data to help identify the modules that needs connection at runtime. Also maintain a inter-graph connection info in the graph info, which can be used to both determine if the graphs are connected and at graph build time. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 90 ++++++++----------------- sound/soc/qcom/qdsp6/audioreach.h | 20 ++---- sound/soc/qcom/qdsp6/q6apm.c | 83 +---------------------- sound/soc/qcom/qdsp6/q6apm.h | 5 -- sound/soc/qcom/qdsp6/topology.c | 105 ++++++++++++++++++++++++++---- 5 files changed, 129 insertions(+), 174 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 01dac32c50fd..783211fc0d87 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -332,63 +332,6 @@ static void apm_populate_module_prop_obj(struct apm_mod_prop_obj *obj, obj->prop_id_port.max_op_port = module->max_op_port; } -struct audioreach_module *audioreach_get_container_last_module( - struct audioreach_container *container) -{ - struct audioreach_module *module; - - list_for_each_entry(module, &container->modules_list, node) { - if (module->dst_mod_inst_id == 0) - return module; - } - - return NULL; -} -EXPORT_SYMBOL_GPL(audioreach_get_container_last_module); - -static bool is_module_in_container(struct audioreach_container *container, int module_iid) -{ - struct audioreach_module *module; - - list_for_each_entry(module, &container->modules_list, node) { - if (module->instance_id == module_iid) - return true; - } - - return false; -} - -struct audioreach_module *audioreach_get_container_first_module( - struct audioreach_container *container) -{ - struct audioreach_module *module; - - /* get the first module from both connected or un-connected containers */ - list_for_each_entry(module, &container->modules_list, node) { - if (module->src_mod_inst_id == 0 || - !is_module_in_container(container, module->src_mod_inst_id)) - return module; - } - return NULL; -} -EXPORT_SYMBOL_GPL(audioreach_get_container_first_module); - -struct audioreach_module *audioreach_get_container_next_module( - struct audioreach_container *container, - struct audioreach_module *module) -{ - int nmodule_iid = module->dst_mod_inst_id; - struct audioreach_module *nmodule; - - list_for_each_entry(nmodule, &container->modules_list, node) { - if (nmodule->instance_id == nmodule_iid) - return nmodule; - } - - return NULL; -} -EXPORT_SYMBOL_GPL(audioreach_get_container_next_module); - static void apm_populate_module_list_obj(struct apm_mod_list_obj *obj, struct audioreach_container *container, int sub_graph_id) @@ -400,14 +343,15 @@ static void apm_populate_module_list_obj(struct apm_mod_list_obj *obj, obj->container_id = container->container_id; obj->num_modules = container->num_modules; i = 0; - list_for_each_container_module(module, container) { + list_for_each_entry(module, &container->modules_list, node) { obj->mod_cfg[i].module_id = module->module_id; obj->mod_cfg[i].instance_id = module->instance_id; i++; } } -static void audioreach_populate_graph(struct apm_graph_open_params *open, +static void audioreach_populate_graph(struct q6apm *apm, struct audioreach_graph_info *info, + struct apm_graph_open_params *open, struct list_head *sg_list, int num_sub_graphs) { @@ -428,6 +372,16 @@ static void audioreach_populate_graph(struct apm_graph_open_params *open, mlobj = &ml_data->mod_list_obj[0]; + + if (info->dst_mod_inst_id && info->src_mod_inst_id) { + conn_obj = &mc_data->conn_obj[nconn]; + conn_obj->src_mod_inst_id = info->src_mod_inst_id; + conn_obj->src_mod_op_port_id = info->src_mod_op_port_id; + conn_obj->dst_mod_inst_id = info->dst_mod_inst_id; + conn_obj->dst_mod_ip_port_id = info->dst_mod_ip_port_id; + nconn++; + } + list_for_each_entry(sg, sg_list, node) { struct apm_sub_graph_data *sg_cfg = &sg_data->sg_cfg[i++]; @@ -439,7 +393,7 @@ static void audioreach_populate_graph(struct apm_graph_open_params *open, apm_populate_container_config(cobj, container); apm_populate_module_list_obj(mlobj, container, sg->sub_graph_id); - list_for_each_container_module(module, container) { + list_for_each_entry(module, &container->modules_list, node) { uint32_t src_mod_inst_id; src_mod_inst_id = module->src_mod_inst_id; @@ -462,7 +416,7 @@ static void audioreach_populate_graph(struct apm_graph_open_params *open, } } -void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct list_head *sg_list, int graph_id) +void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info *info) { int payload_size, sg_sz, cont_sz, ml_sz, mp_sz, mc_sz; struct apm_module_param_data *param_data; @@ -475,6 +429,7 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct list_head *sg_list, i struct audioreach_module *module; struct audioreach_sub_graph *sgs; struct apm_mod_list_obj *mlobj; + struct list_head *sg_list; int num_modules_per_list; int num_connections = 0; int num_containers = 0; @@ -482,14 +437,23 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct list_head *sg_list, i int num_modules = 0; int num_modules_list; struct gpr_pkt *pkt; + int graph_id; void *p; + graph_id = info->id; + sg_list = &info->sg_list; + ml_sz = 0; + + /* add FE-BE connections */ + if (info->dst_mod_inst_id && info->src_mod_inst_id) + num_connections++; + list_for_each_entry(sgs, sg_list, node) { num_sub_graphs++; list_for_each_entry(container, &sgs->container_list, node) { num_containers++; num_modules += container->num_modules; - list_for_each_container_module(module, container) { + list_for_each_entry(module, &container->modules_list, node) { if (module->src_mod_inst_id) num_connections++; } @@ -557,7 +521,7 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct list_head *sg_list, i params.mod_conn_list_data->num_connections = num_connections; p += mc_sz; - audioreach_populate_graph(¶ms, sg_list, num_sub_graphs); + audioreach_populate_graph(apm, info, ¶ms, sg_list, num_sub_graphs); return pkt; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 36779ad1952d..1dc6ffcb3362 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -595,6 +595,11 @@ struct audioreach_graph_info { int id; uint32_t num_sub_graphs; struct list_head sg_list; + /* DPCM connection from FE Graph to BE graph */ + uint32_t src_mod_inst_id; + uint32_t src_mod_op_port_id; + uint32_t dst_mod_inst_id; + uint32_t dst_mod_ip_port_id; }; struct audioreach_sub_graph { @@ -693,9 +698,8 @@ void *audioreach_alloc_apm_pkt(int pkt_size, uint32_t opcode, uint32_t token, void *audioreach_alloc_pkt(int payload_size, uint32_t opcode, uint32_t token, uint32_t src_port, uint32_t dest_port); -void *audioreach_alloc_graph_pkt(struct q6apm *apm, - struct list_head *sg_list, - int graph_id); +void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info + *info); /* Topology specific */ int audioreach_tplg_init(struct snd_soc_component *component); @@ -716,14 +720,4 @@ int audioreach_set_media_format(struct q6apm_graph *graph, int audioreach_shared_memory_send_eos(struct q6apm_graph *graph); int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module *module, int vol); -struct audioreach_module *audioreach_get_container_last_module( - struct audioreach_container *container); -struct audioreach_module *audioreach_get_container_first_module( - struct audioreach_container *container); -struct audioreach_module *audioreach_get_container_next_module( - struct audioreach_container *container, - struct audioreach_module *module); -#define list_for_each_container_module(mod, cont) \ - for (mod = audioreach_get_container_first_module(cont); mod != NULL; \ - mod = audioreach_get_container_next_module(cont, mod)) #endif /* __AUDIOREACH_H__ */ diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 81e2d7090fb4..5beb898f28f5 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -63,7 +63,7 @@ static struct audioreach_graph *q6apm_get_audioreach_graph(struct q6apm *apm, ui graph->info = info; graph->id = graph_id; - graph->graph = audioreach_alloc_graph_pkt(apm, &info->sg_list, graph_id); + graph->graph = audioreach_alloc_graph_pkt(apm, info); if (IS_ERR(graph->graph)) { void *err = graph->graph; @@ -178,87 +178,6 @@ static struct audioreach_module *__q6apm_find_module_by_mid(struct q6apm *apm, return NULL; } -static struct audioreach_module *q6apm_graph_get_last_module(struct q6apm *apm, u32 sgid) -{ - struct audioreach_container *container; - struct audioreach_module *module; - struct audioreach_sub_graph *sg; - - mutex_lock(&apm->lock); - sg = idr_find(&apm->sub_graphs_idr, sgid); - mutex_unlock(&apm->lock); - if (!sg) - return NULL; - - container = list_last_entry(&sg->container_list, struct audioreach_container, node); - module = audioreach_get_container_last_module(container); - - return module; -} - -static struct audioreach_module *q6apm_graph_get_first_module(struct q6apm *apm, u32 sgid) -{ - struct audioreach_container *container; - struct audioreach_module *module; - struct audioreach_sub_graph *sg; - - mutex_lock(&apm->lock); - sg = idr_find(&apm->sub_graphs_idr, sgid); - mutex_unlock(&apm->lock); - if (!sg) - return NULL; - - container = list_first_entry(&sg->container_list, struct audioreach_container, node); - module = audioreach_get_container_first_module(container); - - return module; -} - -bool q6apm_is_sub_graphs_connected(struct q6apm *apm, u32 src_sgid, u32 dst_sgid) -{ - struct audioreach_module *module; - u32 iid; - - module = q6apm_graph_get_last_module(apm, src_sgid); - if (!module) - return false; - - iid = module->instance_id; - module = q6apm_graph_get_first_module(apm, dst_sgid); - if (!module) - return false; - - if (module->src_mod_inst_id == iid) - return true; - - return false; -} - -int q6apm_connect_sub_graphs(struct q6apm *apm, u32 src_sgid, u32 dst_sgid, bool connect) -{ - struct audioreach_module *module; - u32 iid; - - if (connect) { - module = q6apm_graph_get_last_module(apm, src_sgid); - if (!module) - return -ENODEV; - - iid = module->instance_id; - } else { - iid = 0; - } - - module = q6apm_graph_get_first_module(apm, dst_sgid); - if (!module) - return -ENODEV; - - /* set src module in dst subgraph first module */ - module->src_mod_inst_id = iid; - - return 0; -} - int q6apm_graph_media_format_shmem(struct q6apm_graph *graph, struct audioreach_module_config *cfg) { diff --git a/sound/soc/qcom/qdsp6/q6apm.h b/sound/soc/qcom/qdsp6/q6apm.h index 96ad5ea2ae07..273f97812741 100644 --- a/sound/soc/qcom/qdsp6/q6apm.h +++ b/sound/soc/qcom/qdsp6/q6apm.h @@ -142,12 +142,7 @@ int q6apm_send_cmd_sync(struct q6apm *apm, struct gpr_pkt *pkt, /* Callback for graph specific */ struct audioreach_module *q6apm_find_module_by_mid(struct q6apm_graph *graph, uint32_t mid); - void q6apm_set_fe_dai_ops(struct snd_soc_dai_driver *dai_drv); -int q6apm_connect_sub_graphs(struct q6apm *apm, u32 src_sgid, u32 dst_sgid, - bool connect); -bool q6apm_is_sub_graphs_connected(struct q6apm *apm, u32 src_sgid, - u32 dst_sgid); int q6apm_graph_get_rx_shmem_module_iid(struct q6apm_graph *graph); #endif /* __APM_GRAPH_ */ diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index 0c4886d30131..f66d7054177c 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -872,7 +872,21 @@ static int audioreach_widget_unload(struct snd_soc_component *scomp, return 0; } -static struct audioreach_module *audioreach_find_widget(struct snd_soc_component *comp, +static struct snd_ar_control *audioreach_find_widget(struct snd_soc_component *comp, + const char *name) +{ + struct q6apm *apm = dev_get_drvdata(comp->dev); + struct snd_ar_control *control; + + list_for_each_entry(control, &apm->widget_list, node) { + if (control->w && !strcmp(name, control->w->name)) + return control; + } + + return NULL; +} + +static struct audioreach_module *audioreach_find_module(struct snd_soc_component *comp, const char *name) { struct q6apm *apm = dev_get_drvdata(comp->dev); @@ -890,14 +904,41 @@ static struct audioreach_module *audioreach_find_widget(struct snd_soc_component static int audioreach_route_load(struct snd_soc_component *scomp, int index, struct snd_soc_dapm_route *route) { - struct audioreach_module *src, *sink; - - src = audioreach_find_widget(scomp, route->source); - sink = audioreach_find_widget(scomp, route->sink); + struct audioreach_module *src_module, *sink_module; + struct snd_ar_control *control; + struct snd_soc_dapm_widget *w; + int i; + + /* check if these are actual modules */ + src_module = audioreach_find_module(scomp, route->source); + sink_module = audioreach_find_module(scomp, route->sink); + + if (sink_module && !src_module) { + control = audioreach_find_widget(scomp, route->source); + if (control) + control->module_instance_id = sink_module->instance_id; + + } else if (!sink_module && src_module && route->control) { + /* check if this is a virtual mixer */ + control = audioreach_find_widget(scomp, route->sink); + if (!control || !control->w) + return 0; + + w = control->w; + + for (i = 0; i < w->num_kcontrols; i++) { + if (!strcmp(route->control, w->kcontrol_news[i].name)) { + struct soc_mixer_control *sm; + struct snd_soc_dobj *dobj; + struct snd_ar_control *scontrol; + + sm = (struct soc_mixer_control *)w->kcontrol_news[i].private_value; + dobj = &sm->dobj; + scontrol = dobj->private; + scontrol->module_instance_id = src_module->instance_id; + } + } - if (src && sink) { - src->dst_mod_inst_id = sink->instance_id; - sink->src_mod_inst_id = src->instance_id; } return 0; @@ -928,6 +969,48 @@ static int audioreach_link_load(struct snd_soc_component *component, int index, return 0; } +static void audioreach_connect_sub_graphs(struct q6apm *apm, + struct snd_ar_control *m1, + struct snd_ar_control *m2, + bool connect) +{ + struct audioreach_graph_info *info; + + mutex_lock(&apm->lock); + info = idr_find(&apm->graph_info_idr, m2->graph_id); + mutex_unlock(&apm->lock); + + if (connect) { + info->src_mod_inst_id = m1->module_instance_id; + info->src_mod_op_port_id = 1; + info->dst_mod_inst_id = m2->module_instance_id; + info->dst_mod_ip_port_id = 2; + + } else { + info->src_mod_inst_id = 0; + info->src_mod_op_port_id = 0; + info->dst_mod_inst_id = 0; + info->dst_mod_ip_port_id = 0; + } +} + +static bool audioreach_is_vmixer_connected(struct q6apm *apm, + struct snd_ar_control *m1, + struct snd_ar_control *m2) +{ + struct audioreach_graph_info *info; + + mutex_lock(&apm->lock); + info = idr_find(&apm->graph_info_idr, m2->graph_id); + mutex_unlock(&apm->lock); + + if (info->dst_mod_inst_id == m2->module_instance_id && + info->src_mod_inst_id == m1->module_instance_id) + return true; + + return false; +} + static int audioreach_get_audio_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -940,7 +1023,7 @@ static int audioreach_get_audio_mixer(struct snd_kcontrol *kcontrol, struct q6apm *data = dev_get_drvdata(c->dev); bool connected; - connected = q6apm_is_sub_graphs_connected(data, scontrol->sgid, dapm_scontrol->sgid); + connected = audioreach_is_vmixer_connected(data, scontrol, dapm_scontrol); if (connected) ucontrol->value.integer.value[0] = 1; else @@ -961,10 +1044,10 @@ static int audioreach_put_audio_mixer(struct snd_kcontrol *kcontrol, struct q6apm *data = dev_get_drvdata(c->dev); if (ucontrol->value.integer.value[0]) { - q6apm_connect_sub_graphs(data, scontrol->sgid, dapm_scontrol->sgid, true); + audioreach_connect_sub_graphs(data, scontrol, dapm_scontrol, true); snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, NULL); } else { - q6apm_connect_sub_graphs(data, scontrol->sgid, dapm_scontrol->sgid, false); + audioreach_connect_sub_graphs(data, scontrol, dapm_scontrol, false); snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, NULL); } return 0; From patchwork Thu Sep 15 12:38:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E63AECAAA1 for ; Thu, 15 Sep 2022 12:39:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbiIOMjI (ORCPT ); Thu, 15 Sep 2022 08:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbiIOMi7 (ORCPT ); Thu, 15 Sep 2022 08:38:59 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D8983BC0 for ; Thu, 15 Sep 2022 05:38:57 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id n17-20020a05600c501100b003a84bf9b68bso13700886wmr.3 for ; Thu, 15 Sep 2022 05:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Sr1UfmKo/5TRBZLXzJD4DkSvxdVH2UE4dAA9W8/Rm7A=; b=LNyn9+DedkSAToLvnrmjcql1/S8NkLjO237hXw6w1zKKGlOvLTOrya5b9etSFFiK5a a2IIZDxLWWfmN6gGpPRe4O8czWW4MAUj1SNVfzfSQrnUtVNTyzNs5lskjd7PRyLxS9up uHJJZlLYjmV15Gf1gRYT4Xd4/EY68prTPyi+QIJQHQwQXt4a8W3GHFnooq6+yIbknbWf SCP6cI1nVSbhZObQlHFB/glvq72I5D6lkY54rhkCjbeHP68HjxpH4O4TqpkjwcKpQvSm n6lYbe8TzKVjHpXZKyzuyM96lC590CARoBR/M1/8B6iOD0PZTRLImprsjxkSsL4JV2De cbow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Sr1UfmKo/5TRBZLXzJD4DkSvxdVH2UE4dAA9W8/Rm7A=; b=zbfTwYJ7XcA5O8bi4Kkj6waiMZX1rgUT679cuWPZcvZh8FA5kNJ/wBoz6sqt2e4jze ySYC+EE9VGCxx9HI12fs3qQ2vXFkBt87AP8HRNwfWNe7vNGwaJOJoIEltw3fRXlRg4au kIy8aXTomong5A0q3FkhDlhou3kqbd69tZ6AKCUCovRnBT60rPHzGRwYUtvErqMpXY6D RNs5biTUbKg/KBeSK4sDx+kcd8RNKckcn5avPHUCrM35QOnsQeXe4fOylFa4VWnHBK8E vQnSDGksaGu38dQ1ApFfBmRV0wWZ5JqLwBzYpzI0vrMjuxbeEnuCAWyesl/2hEhvZJBr prng== X-Gm-Message-State: ACgBeo0A1sZJs9SyB4JjNCvkMv67Tj9MC3tDtiCQGJ/sCB85GVwtDTTV T5Xdoc5omS3lKkFNvekm42COOA== X-Google-Smtp-Source: AA6agR5Y5Tg5yO67Rm0vAjfIHvHG/133jBAHaRJ1ZsbyyWLUrzJn1JVpCiUVBeXD1C3AYA+KIkj65w== X-Received: by 2002:a05:600c:a43:b0:3b4:9250:781f with SMTP id c3-20020a05600c0a4300b003b49250781fmr6757885wmq.110.1663245535995; Thu, 15 Sep 2022 05:38:55 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:55 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 5/9] ASoC: qdsp6: audioreach: simplify module_list sz calculation Date: Thu, 15 Sep 2022 13:38:33 +0100 Message-Id: <20220915123837.11591-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Simplify module_list size calcuation by doing inside modules loop. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 783211fc0d87..bae0b7f67e0b 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -430,7 +430,6 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info struct audioreach_sub_graph *sgs; struct apm_mod_list_obj *mlobj; struct list_head *sg_list; - int num_modules_per_list; int num_connections = 0; int num_containers = 0; int num_sub_graphs = 0; @@ -453,6 +452,9 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info list_for_each_entry(container, &sgs->container_list, node) { num_containers++; num_modules += container->num_modules; + ml_sz = ml_sz + sizeof(struct apm_module_list_params) + + APM_MOD_LIST_OBJ_PSIZE(mlobj, container->num_modules); + list_for_each_entry(module, &container->modules_list, node) { if (module->src_mod_inst_id) num_connections++; @@ -461,11 +463,11 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info } num_modules_list = num_containers; - num_modules_per_list = num_modules/num_containers; sg_sz = APM_SUB_GRAPH_PSIZE(sg_params, num_sub_graphs); cont_sz = APM_CONTAINER_PSIZE(cont_params, num_containers); - ml_sz = ALIGN(sizeof(struct apm_module_list_params) + - num_modules_list * APM_MOD_LIST_OBJ_PSIZE(mlobj, num_modules_per_list), 8); + + ml_sz = ALIGN(ml_sz, 8); + mp_sz = APM_MOD_PROP_PSIZE(mprop, num_modules); mc_sz = APM_MOD_CONN_PSIZE(mcon, num_connections); From patchwork Thu Sep 15 12:38:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C633C6FA8A for ; Thu, 15 Sep 2022 12:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbiIOMjJ (ORCPT ); Thu, 15 Sep 2022 08:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiIOMjA (ORCPT ); Thu, 15 Sep 2022 08:39:00 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97164844EA for ; Thu, 15 Sep 2022 05:38:58 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t7so30639497wrm.10 for ; Thu, 15 Sep 2022 05:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RV4wF232kZpwZvwtbOvkLH7fVkb3VMbqjdLt/ZUggPs=; b=ke/c/lzv6U9ofG/tiCo8KZL3cfn0YNdB/6+zGhj6/qboz95EF4ULmzGMUse72Mzkoh KcbZahR2BtpmyIkS9SxaBtR73Z4g6EjTpLtm598AQPXhlbwxSE4SV+/iS3gx3IdwUunt KeaJRWva6Fk7tT5NICTXrESFXwYtXd1zRqFZXhzDHA00JF9MbdN+YMFBiy2XXDy0/Xfr uzwvULgBsij9yZDBznJl/n8OlFLetz/Do5FWiOLJWdTGDQgyoAsnR0STZEaoS+YIXWdK e6YUJjDnck5spkNHJhLhlR3NGpzF31thC51xAVWWHxxAvakRRDoL+wvyQFLyZkZd8Umm NjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RV4wF232kZpwZvwtbOvkLH7fVkb3VMbqjdLt/ZUggPs=; b=C5hra/EQgET+GNXMHdxvcmd3i5aheWZBKlpUybjz9eqEDkGdDDRLyIwWoQOPy1jvB3 czq+DwozQKIoUxxi225y6IXaFZvuDVC7AyfZaLFm1MXiJMLgD1bR40lK8xpKxUavFp40 V3n57/MHPiS6bjFJiyZwSyEEDXOpOTMYXr/2+y3bsO9DfssNJwfdkjwu5Wdyicx09HFq 6I4BSOp0pO3LbHW9HEVV/UrspKEDAvrzNcMuRhegPrG4M7nQi6sRfUdaN1UM0X0KtQ2p Yo+xdPhmY/5XBgBeScL+gGl0xJ7Da1sqBByLgjqeXuqLX9sNcJYkjrAZ5xIzUSa+DsBU R7Jw== X-Gm-Message-State: ACgBeo2zkWepsgN6K47vAnwoPdE7GeFsFbBN0iLEIfPobzlHF5jhYqEL Tbq+/9Q2sXkX/DX/VjAds98Rhw== X-Google-Smtp-Source: AA6agR5adbW9nWruS/eO1UF0hiNQtR9UN4aG/zxUPSGfS2nBdFjbR7LRzC6nG+tmXRwJ9YmfEzTpUQ== X-Received: by 2002:adf:e94e:0:b0:228:da92:3691 with SMTP id m14-20020adfe94e000000b00228da923691mr24576549wrn.1.1663245537095; Thu, 15 Sep 2022 05:38:57 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:56 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 6/9] ASoC: qdsp6: audioreach: add support for more port connections Date: Thu, 15 Sep 2022 13:38:34 +0100 Message-Id: <20220915123837.11591-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org AudioReach Modules can connect to other modules using source and destination port, and each module in theory can support up to 255 port connections. But in practice this limit is at max 8 ports at a time. So add support for allowing multiple port connections. This support is needed for more detailed graphs like ECNS, speaker protection and so. Signed-off-by: Srinivas Kandagatla --- include/uapi/sound/snd_ar_tokens.h | 27 ++++++++ sound/soc/qcom/qdsp6/audioreach.c | 34 ++++------ sound/soc/qcom/qdsp6/audioreach.h | 9 ++- sound/soc/qcom/qdsp6/topology.c | 102 +++++++++++++++++++++++++---- 4 files changed, 136 insertions(+), 36 deletions(-) diff --git a/include/uapi/sound/snd_ar_tokens.h b/include/uapi/sound/snd_ar_tokens.h index 440c0725660b..b9b9093b4396 100644 --- a/include/uapi/sound/snd_ar_tokens.h +++ b/include/uapi/sound/snd_ar_tokens.h @@ -191,6 +191,33 @@ enum ar_event_types { #define AR_TKN_U32_MODULE_SRC_INSTANCE_ID 208 #define AR_TKN_U32_MODULE_DST_INSTANCE_ID 209 +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID1 210 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID1 211 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID1 212 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID2 213 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID2 214 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID2 215 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID3 216 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID3 217 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID3 218 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID4 219 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID4 220 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID4 221 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID5 222 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID5 223 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID5 224 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID6 225 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID6 226 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID6 227 + +#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID7 228 +#define AR_TKN_U32_MODULE_DST_IN_PORT_ID7 229 +#define AR_TKN_U32_MODULE_DST_INSTANCE_ID7 230 #define AR_TKN_U32_MODULE_HW_IF_IDX 250 #define AR_TKN_U32_MODULE_HW_IF_TYPE 251 diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index bae0b7f67e0b..37f1408f6f6f 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -311,15 +311,6 @@ static void apm_populate_sub_graph_config(struct apm_sub_graph_data *cfg, cfg->sid.scenario_id = sg->scenario_id; } -static void apm_populate_connection_obj(struct apm_module_conn_obj *obj, - struct audioreach_module *module) -{ - obj->src_mod_inst_id = module->src_mod_inst_id; - obj->src_mod_op_port_id = module->src_mod_op_port_id; - obj->dst_mod_inst_id = module->instance_id; - obj->dst_mod_ip_port_id = module->in_port; -} - static void apm_populate_module_prop_obj(struct apm_mod_prop_obj *obj, struct audioreach_module *module) { @@ -394,17 +385,21 @@ static void audioreach_populate_graph(struct q6apm *apm, struct audioreach_graph apm_populate_module_list_obj(mlobj, container, sg->sub_graph_id); list_for_each_entry(module, &container->modules_list, node) { - uint32_t src_mod_inst_id; - - src_mod_inst_id = module->src_mod_inst_id; - module_prop_obj = &mp_data->mod_prop_obj[nmodule]; apm_populate_module_prop_obj(module_prop_obj, module); - if (src_mod_inst_id) { - conn_obj = &mc_data->conn_obj[nconn]; - apm_populate_connection_obj(conn_obj, module); - nconn++; + if (module->max_op_port) { + int pn; + for (pn = 0; pn < module->max_op_port; pn++) { + if (module->dst_mod_inst_id[pn]) { + conn_obj = &mc_data->conn_obj[nconn]; + conn_obj->src_mod_inst_id = module->instance_id; + conn_obj->src_mod_op_port_id = module->src_mod_op_port_id[pn]; + conn_obj->dst_mod_inst_id = module->dst_mod_inst_id[pn]; + conn_obj->dst_mod_ip_port_id = module->dst_mod_ip_port_id[pn]; + nconn++; + } + } } nmodule++; @@ -456,8 +451,7 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info APM_MOD_LIST_OBJ_PSIZE(mlobj, container->num_modules); list_for_each_entry(module, &container->modules_list, node) { - if (module->src_mod_inst_id) - num_connections++; + num_connections += module->num_connections; } } } @@ -502,7 +496,7 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info param_data->module_instance_id = APM_MODULE_INSTANCE_ID; param_data->param_id = APM_PARAM_ID_MODULE_LIST; param_data->param_size = ml_sz - APM_MODULE_PARAM_DATA_SIZE; - params.mod_list_data->num_modules_list = num_sub_graphs; + params.mod_list_data->num_modules_list = num_modules_list; p += ml_sz; /* Module Properties */ diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 1dc6ffcb3362..df5026b646c1 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -627,6 +627,8 @@ struct audioreach_container { struct audioreach_sub_graph *sub_graph; }; +#define AR_MAX_MOD_LINKS 8 + struct audioreach_module { uint32_t module_id; uint32_t instance_id; @@ -637,11 +639,12 @@ struct audioreach_module { uint32_t in_port; uint32_t out_port; + uint32_t num_connections; /* Connections */ uint32_t src_mod_inst_id; - uint32_t src_mod_op_port_id; - uint32_t dst_mod_inst_id; - uint32_t dst_mod_ip_port_id; + uint32_t src_mod_op_port_id[AR_MAX_MOD_LINKS]; + uint32_t dst_mod_inst_id[AR_MAX_MOD_LINKS]; + uint32_t dst_mod_ip_port_id[AR_MAX_MOD_LINKS]; /* Format specifics */ uint32_t ch_fmt; diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index f66d7054177c..9994e9ec01f4 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -412,19 +412,25 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap struct snd_soc_dapm_widget *w) { uint32_t max_ip_port = 0, max_op_port = 0, in_port = 0, out_port = 0; - uint32_t src_mod_inst_id = 0, src_mod_op_port_id = 0; - uint32_t dst_mod_inst_id = 0, dst_mod_ip_port_id = 0; + uint32_t src_mod_op_port_id[AR_MAX_MOD_LINKS] = { 0, }; + uint32_t dst_mod_inst_id[AR_MAX_MOD_LINKS] = { 0, }; + uint32_t dst_mod_ip_port_id[AR_MAX_MOD_LINKS] = { 0, }; + uint32_t src_mod_inst_id = 0; + int module_id = 0, instance_id = 0, tkn_count = 0; struct snd_soc_tplg_vendor_value_elem *mod_elem; struct snd_soc_tplg_vendor_array *mod_array; struct audioreach_module *mod = NULL; + uint32_t token; bool found; + int max_tokens; mod_array = audioreach_get_module_array(private); mod_elem = mod_array->value; - - while (tkn_count <= (le32_to_cpu(mod_array->num_elems) - 1)) { - switch (le32_to_cpu(mod_elem->token)) { + max_tokens = le32_to_cpu(mod_array->num_elems); + while (tkn_count <= (max_tokens - 1)) { + token = le32_to_cpu(mod_elem->token); + switch (token) { /* common module info */ case AR_TKN_U32_MODULE_ID: module_id = le32_to_cpu(mod_elem->value); @@ -454,17 +460,80 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap case AR_TKN_U32_MODULE_OUT_PORTS: out_port = le32_to_cpu(mod_elem->value); break; - case AR_TKN_U32_MODULE_SRC_OP_PORT_ID: - src_mod_op_port_id = le32_to_cpu(mod_elem->value); - break; case AR_TKN_U32_MODULE_SRC_INSTANCE_ID: src_mod_inst_id = le32_to_cpu(mod_elem->value); break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID: + src_mod_op_port_id[0] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID1: + src_mod_op_port_id[1] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID2: + src_mod_op_port_id[2] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID3: + src_mod_op_port_id[3] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID4: + src_mod_op_port_id[4] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID5: + src_mod_op_port_id[5] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID6: + src_mod_op_port_id[6] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_SRC_OP_PORT_ID7: + src_mod_op_port_id[7] = le32_to_cpu(mod_elem->value); + break; case AR_TKN_U32_MODULE_DST_INSTANCE_ID: - dst_mod_inst_id = le32_to_cpu(mod_elem->value); + dst_mod_inst_id[0] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID1: + dst_mod_inst_id[1] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID2: + dst_mod_inst_id[2] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID3: + dst_mod_inst_id[3] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID4: + dst_mod_inst_id[4] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID5: + dst_mod_inst_id[5] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID6: + dst_mod_inst_id[6] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_INSTANCE_ID7: + dst_mod_inst_id[7] = le32_to_cpu(mod_elem->value); break; case AR_TKN_U32_MODULE_DST_IN_PORT_ID: - dst_mod_ip_port_id = le32_to_cpu(mod_elem->value); + dst_mod_ip_port_id[0] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID1: + dst_mod_ip_port_id[1] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID2: + dst_mod_ip_port_id[2] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID3: + dst_mod_ip_port_id[3] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID4: + dst_mod_ip_port_id[4] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID5: + dst_mod_ip_port_id[5] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID6: + dst_mod_ip_port_id[6] = le32_to_cpu(mod_elem->value); + break; + case AR_TKN_U32_MODULE_DST_IN_PORT_ID7: + dst_mod_ip_port_id[7] = le32_to_cpu(mod_elem->value); break; default: break; @@ -475,15 +544,22 @@ static struct audioreach_module *audioreach_parse_common_tokens(struct q6apm *ap } if (mod) { + int pn, id = 0; mod->module_id = module_id; mod->max_ip_port = max_ip_port; mod->max_op_port = max_op_port; mod->in_port = in_port; mod->out_port = out_port; mod->src_mod_inst_id = src_mod_inst_id; - mod->src_mod_op_port_id = src_mod_op_port_id; - mod->dst_mod_inst_id = dst_mod_inst_id; - mod->dst_mod_ip_port_id = dst_mod_ip_port_id; + for (pn = 0; pn < mod->max_op_port; pn++) { + if (src_mod_op_port_id[pn] && dst_mod_inst_id[pn] && dst_mod_ip_port_id[pn]) { + mod->src_mod_op_port_id[id] = src_mod_op_port_id[pn]; + mod->dst_mod_inst_id[id] = dst_mod_inst_id[pn]; + mod->dst_mod_ip_port_id[id] = dst_mod_ip_port_id[pn]; + id++; + mod->num_connections = id; + } + } } return mod; From patchwork Thu Sep 15 12:38:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977334 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D85C6FA89 for ; Thu, 15 Sep 2022 12:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiIOMjJ (ORCPT ); Thu, 15 Sep 2022 08:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiIOMjB (ORCPT ); Thu, 15 Sep 2022 08:39:01 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1B180498 for ; Thu, 15 Sep 2022 05:38:59 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id l8so8425884wmi.2 for ; Thu, 15 Sep 2022 05:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=kAZv18kXUCWvtykG7jA+P3fmOwgdcns1b4nN2opdgaY=; b=YMFknw/gQEtWbcY+cioCGHrSwKgqjFxxHJwyAqoumz4tOkxkqnUddkpsA7CAIzwlrN 4/awiX3hVFI7KsTyhb1dFB0ePEqgPiE6Z5mavLAfOrnu8QqUkoceZVVOUIyvqplAfkcZ Y4DjTbc246HdSWob43dnvAF/83xlSK0/zdlxLRGOb2LE+nbVH95Pj/IILTtsYj2849+N eCtmMpSAROPRhmqlfZtcAxFjv2/WstYnhUW6U60ZMKitRT3sAJb7vgPaGv0wF3+kPaV6 yJp4oAhOwtwvPjypl+OnbRhau0lasiDEReesQTxqufJz0lFYrlZ3MRog/qaswFlzDhpl RMog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=kAZv18kXUCWvtykG7jA+P3fmOwgdcns1b4nN2opdgaY=; b=O05ywH98xHKUBkxOErFNe4BPIxQeeS4nyWC7siFZD5l9WB84Z24aP1kgKWEf2AelAR oq++bXt1IxmmYqiBwXqlU5cGaIwt//DhdK7aHvwCxiuJTsM82UCKWcjLO1MPzZf8JTxT UDUuxM2OCLusook285IUNETemvrVYv9k4vFs5Aox3yfpxO5juGNBmWCrip846dWxZpv/ rGqABifJgnEfjkzMAUeMc0odh8T3DYrL7vGtztCOg0+YPL/6rVXbNW/IKHBso/4wpqnh 3anZEXng2Hg/m+08G+fNzpS/zc6kPujtzDxJi/brnacrSmca/kEnMVzfaG0ETWkzv1+b lXLw== X-Gm-Message-State: ACgBeo1ExVs7dtcZjtYVDHzYQiZbNmcQBJM1nk1XuJPfJ7O8Rkqwd6aI ND1auG4yQL48rMtmXjnC45we3A== X-Google-Smtp-Source: AA6agR51zM7l4hwR8w1N1Qc0v/BpSnm9BXj7bIPvQC+ORcdIgdiz0yE/u3RyjnyeQ7ftseSMyCQf1g== X-Received: by 2002:a1c:f217:0:b0:3a6:61f2:a9c2 with SMTP id s23-20020a1cf217000000b003a661f2a9c2mr6600625wmc.88.1663245538291; Thu, 15 Sep 2022 05:38:58 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:57 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 7/9] ASoC: qdsp6: audioreach: add support to enable SAL Module Date: Thu, 15 Sep 2022 13:38:35 +0100 Message-Id: <20220915123837.11591-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support to Simple Accumulator-Limiter module. Signed-off-by: Srinivas Kandagatla Reported-by: kernel test robot --- sound/soc/qcom/qdsp6/audioreach.c | 76 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 11 +++++ 2 files changed, 87 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 37f1408f6f6f..168bc3020b74 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -656,6 +656,77 @@ static int audioreach_codec_dma_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_sal_limiter_enable(struct q6apm_graph *graph, + struct audioreach_module *module, bool enable) +{ + struct apm_module_param_data *param_data; + struct param_id_sal_limiter_enable *limiter_enable; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = sizeof(*limiter_enable) + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_SAL_LIMITER_ENABLE; + param_data->param_size = sizeof (*limiter_enable); + p = p + APM_MODULE_PARAM_DATA_SIZE; + limiter_enable = p; + + limiter_enable->enable_lim = enable; + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + +static int audioreach_sal_set_media_format(struct q6apm_graph *graph, + struct audioreach_module *module, + struct audioreach_module_config *cfg) +{ + struct apm_module_param_data *param_data; + struct param_id_sal_output_config *media_format; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = sizeof(*media_format) + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_SAL_OUTPUT_CFG; + param_data->param_size = sizeof (*media_format); + p = p + APM_MODULE_PARAM_DATA_SIZE; + media_format = p; + + media_format->bits_per_sample = cfg->bit_width; + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + static int audioreach_i2s_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -976,6 +1047,11 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod case MODULE_ID_CODEC_DMA_SOURCE: rc = audioreach_codec_dma_set_media_format(graph, module, cfg); break; + case MODULE_ID_SAL: + audioreach_sal_set_media_format(graph, module, cfg); + audioreach_sal_limiter_enable(graph, module, true); + break; + default: rc = 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index df5026b646c1..f2b51d8fc718 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -15,6 +15,7 @@ struct q6apm_graph; #define MODULE_ID_PCM_CNV 0x07001003 #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 +#define MODULE_ID_SAL 0x07001010 #define MODULE_ID_CODEC_DMA_SINK 0x07001023 #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 #define MODULE_ID_I2S_SINK 0x0700100A @@ -499,6 +500,16 @@ struct data_logging_config { uint32_t mode; } __packed; +#define PARAM_ID_SAL_OUTPUT_CFG 0x08001016 +struct param_id_sal_output_config { + uint32_t bits_per_sample; +} __packed; + +#define PARAM_ID_SAL_LIMITER_ENABLE 0x0800101E +struct param_id_sal_limiter_enable { + uint32_t enable_lim; +} __packed; + #define PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT 0x08001024 struct param_id_mfc_media_format { From patchwork Thu Sep 15 12:38:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6A4EC6FA89 for ; Thu, 15 Sep 2022 12:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbiIOMjM (ORCPT ); Thu, 15 Sep 2022 08:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229966AbiIOMjH (ORCPT ); Thu, 15 Sep 2022 08:39:07 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56868604A for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id n23-20020a7bc5d7000000b003a62f19b453so17650769wmk.3 for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/rwIpVMtqg6E5+Qn4IKE9HpHCiGyTi0zfy7IdHUtvvk=; b=lVZiZSfPUnZTZe4T+QPQHIt2UCK4rxq70unUHgC+V2ogXC9S/NpvPeFv/+Eu3QcaTJ lNkLgF6gT6dt/FZD/rrkC584Q01Rv8iasK7DeP3gwX8kUq2/GJUzLJp7c7mrzjU/FzHu 5Zb6ygtY3heZUtB4FS3x9r8QE23BGFgKTOf0i6bBnLz1jVVv4H0gkgqQ0exHpiATPoF3 j6ESTP5arrJPZ1e5IQxIwmCBwJP9h0yMnaxqZOzsZFrNkJrrPvbV/jJmeBn/Ly2upxRw PtKV6+10LCMkgX6HnYa3gJEWx/h7a2L29jXwruh8Yj0OEydN8w+IAusglbgndopiEakj oj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/rwIpVMtqg6E5+Qn4IKE9HpHCiGyTi0zfy7IdHUtvvk=; b=nAYUxQwaClj8JLJRuN6t/9Kq9iG36ZYy5TDlUYrHRAEmZbuGzjf1+4uv75et3fF3Vm YAJ8vDHZvEWreybfdY6IYUagzjc/BCV9FEjotv0R6n3hi34vC2DO4nT6kGACP0yGt07v 5GIe3aWblu5B+wOajOYpNS4VhDzZHOhyzVcMzXd1xf053x1PfXvFYSwKi1AWmccb6aiP gH9y7pW5J/9P3YLUcOQhp1xlYhj1siDbuxzwa8sgVv0KCsKhFy3z9snC54HKdD4Qp4Fp YBXsG7OGwAU2wx2YyFZbcLlgu0EllqK846PBPgeCZNl5x9WK+a0r53weK/6eUHVabx7c +d7w== X-Gm-Message-State: ACgBeo1cvTcAIva6KUwULgp09LAcbrXejy1wEnVdydMg0h0bOaBUhQmY QM75pjl5G+UupoVLioCfhqQ9OA== X-Google-Smtp-Source: AA6agR6QJ+PCohDiIPSRYrwnsSPaz6Rql5/97iUsJufNhKd9qLCZw4pJfGzN9o5UhzYdu29AlT/UPg== X-Received: by 2002:a05:600c:41c3:b0:3b4:9668:655a with SMTP id t3-20020a05600c41c300b003b49668655amr6533300wmh.36.1663245539635; Thu, 15 Sep 2022 05:38:59 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:58 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 8/9] ASoC: qdsp6: audioreach: add support for MFC Module Date: Thu, 15 Sep 2022 13:38:36 +0100 Message-Id: <20220915123837.11591-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support to enable and configure Media Format Converter (MFC) Module. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 53 ++++++++++++++++++++++++++++++- sound/soc/qcom/qdsp6/audioreach.h | 1 + 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 168bc3020b74..05b58239cab6 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -159,6 +159,8 @@ struct apm_module_hw_ep_mf_cfg { #define APM_HW_EP_CFG_PSIZE ALIGN(sizeof(struct apm_module_hw_ep_mf_cfg), 8) +#define APM_MFC_CFG_PSIZE(p, n) ALIGN(struct_size(p, channel_mapping, n), 4) + struct apm_module_frame_size_factor_cfg { struct apm_module_param_data param_data; uint32_t frame_size_factor; @@ -727,6 +729,53 @@ static int audioreach_sal_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, + struct audioreach_module *module, + struct audioreach_module_config *cfg) +{ + struct apm_module_param_data *param_data; + struct param_id_mfc_media_format *media_format; + uint32_t num_channels = cfg->num_channels; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) + + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT; + param_data->param_size = APM_MFC_CFG_PSIZE(media_format, num_channels); + p = p + APM_MODULE_PARAM_DATA_SIZE; + media_format = p; + + media_format->sample_rate = cfg->sample_rate; + media_format->bit_width = cfg->bit_width; + media_format->num_channels = cfg->num_channels; + + if (num_channels == 1) { + media_format->channel_mapping[0] = PCM_CHANNEL_L; + } else if (num_channels == 2) { + media_format->channel_mapping[0] = PCM_CHANNEL_L; + media_format->channel_mapping[1] = PCM_CHANNEL_R; + } + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + static int audioreach_i2s_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -1051,7 +1100,9 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod audioreach_sal_set_media_format(graph, module, cfg); audioreach_sal_limiter_enable(graph, module, true); break; - + case MODULE_ID_MFC: + rc = audioreach_mfc_set_media_format(graph, module, cfg); + break; default: rc = 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index f2b51d8fc718..707dfbdbc156 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -16,6 +16,7 @@ struct q6apm_graph; #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 #define MODULE_ID_SAL 0x07001010 +#define MODULE_ID_MFC 0x07001015 #define MODULE_ID_CODEC_DMA_SINK 0x07001023 #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 #define MODULE_ID_I2S_SINK 0x0700100A From patchwork Thu Sep 15 12:38:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12977335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A34ECAAA1 for ; Thu, 15 Sep 2022 12:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiIOMjK (ORCPT ); Thu, 15 Sep 2022 08:39:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbiIOMjG (ORCPT ); Thu, 15 Sep 2022 08:39:06 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F1E85FA3 for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id az24-20020a05600c601800b003a842e4983cso13746648wmb.0 for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=IeAgNZtS8X1tLcgH+uLrT6e6JPredzlWXqw/7cX/H9c=; b=NpEnD4+5UvjApkez7BQRb2H/jI+T6RSMCDPJAnkFcvgXSPoETTKktjQDdmNcFHKOu7 4wZwR0mf9x+JYp5535hBJcYkUgxbr1Fjqll2o8Iz3WrqhfAGa3H1i+HYFrOw/kkKKAtg K1TvILDY1H6J7y8oJG+7RNhKJHm5ueTYTl+RW3+OtXg9lRXESR7fj2V2FskBqsppVz/F LOXuolIGk5olSXyopf2OwoJt1uzFmu6ywiWuU0RQTsmBhQwpZ3oxDk/yPgyAl5ZCvUHd Evf2/6ARERpQn+ZYEbPh7zoMRUQ8pBD/hGEchnASctsbydhzlkJZWORHqCJHjbXE9asX roKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=IeAgNZtS8X1tLcgH+uLrT6e6JPredzlWXqw/7cX/H9c=; b=yvcyBg1sNgfCe/4kwdeoZjeGTTimdd5aClY2U1mM7vpo5SKqusI3tTKLPp9dH0j2nx xLqzXAV0wD5ori8tECS5P5DKbQ/5Rz8LzJ+y1onE8/efiZNAgxGYMoatiNnWD4KFXF2d PpwI0jvn+Ry1nhOltQ1YKUqiTpwDIfJ+TYsJqY2YRnOeRQH7SavlHglhkXvy57tbCKoW +581loLemn0tjdd0XUvT9x5Cci9okYBG2RkX8FX+w6yTVvZmYqMBurPWDhjxfehAMiae WlDcawPTG1UgIjeiC58r2D4xftv/4cYG60gc51HvSqqWgBTlUhJ8ACnfNC/cSmtxK1lf f2dg== X-Gm-Message-State: ACgBeo2zPtCnPTQ0XOeR3Mn2WanuORnrfjFESVi9dion2ruvhNowxFO2 qaF+NpInNQs0ejKjNiHQbuF4dQ== X-Google-Smtp-Source: AA6agR64FpbnVidcThBa1wrEKVXvNGP2DM9m3fJynJiGl7+Y0Kee97YdzuC6a+BOEeZEPauV0G4Nbw== X-Received: by 2002:a05:600c:4f53:b0:3b4:9aad:7845 with SMTP id m19-20020a05600c4f5300b003b49aad7845mr6561451wmq.159.1663245540816; Thu, 15 Sep 2022 05:39:00 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:39:00 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 9/9] ASoC: qdsp6: audioreach: add support to enable module command Date: Thu, 15 Sep 2022 13:38:37 +0100 Message-Id: <20220915123837.11591-10-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support to enable Module command which is required for logging module to be able to debug. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 37 +++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/audioreach.h | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 05b58239cab6..e88ace794d4f 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -729,6 +729,42 @@ static int audioreach_sal_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_module_enable(struct q6apm_graph *graph, + struct audioreach_module *module, + bool enable) +{ + struct apm_module_param_data *param_data; + struct param_id_module_enable *param; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = sizeof(*param) + APM_MODULE_PARAM_DATA_SIZE; + + pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(pkt)) + return PTR_ERR(pkt); + + p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_MODULE_ENABLE; + param_data->param_size = sizeof (*param); + p = p + APM_MODULE_PARAM_DATA_SIZE; + param = p; + + param->enable = enable; + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -1075,6 +1111,7 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod switch (module->module_id) { case MODULE_ID_DATA_LOGGING: + audioreach_module_enable(graph, module, true); rc = audioreach_logging_set_media_format(graph, module); break; case MODULE_ID_PCM_DEC: diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index 707dfbdbc156..1d1d47d47d40 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -537,6 +537,11 @@ struct payload_media_fmt_pcm { uint8_t channel_mapping[]; } __packed; +#define PARAM_ID_MODULE_ENABLE 0x08001026 +struct param_id_module_enable { + uint32_t enable; +} __packed; + #define PARAM_ID_CODEC_DMA_INTF_CFG 0x08001063 struct param_id_codec_dma_intf_cfg {