* [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper
@ 2026-06-05 9:28 Harendra Gautam
2026-06-05 9:28 ` [PATCH 1/2] ASoC: qcom: Add generic of_xlate_dai_name helper to common Harendra Gautam
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Harendra Gautam @ 2026-06-05 9:28 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Mark Brown, Liam Girdwood, linux-sound, linux-arm-msm, linux-kernel
Multiple Qualcomm ASoC CPU DAI drivers implement the same logic to
resolve a sound-dai phandle argument to a DAI name: iterate the
component's DAI driver array and match by ID. This is currently
duplicated between lpass-cpu.c and qaif-cpu.c.
This series extracts the common logic into a shared helper
asoc_qcom_of_xlate_dai_name() in common.c and refactors lpass-cpu.c
to use it. The QAIF driver (in a separate series) will also use this
helper instead of its own private implementation.
Patch 1: Add asoc_qcom_of_xlate_dai_name() to common.c/h
Patch 2: Refactor lpass-cpu.c to use the new helper
Harendra Gautam (2):
ASoC: qcom: Add generic of_xlate_dai_name helper to common
ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper
sound/soc/qcom/common.c | 34 ++++++++++++++++++++++++++++++++++
sound/soc/qcom/common.h | 5 +++++
sound/soc/qcom/lpass-cpu.c | 19 +++++--------------
3 files changed, 44 insertions(+), 14 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] ASoC: qcom: Add generic of_xlate_dai_name helper to common
2026-06-05 9:28 [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Harendra Gautam
@ 2026-06-05 9:28 ` Harendra Gautam
2026-06-05 9:28 ` [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper Harendra Gautam
2026-06-05 9:41 ` [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Srinivas Kandagatla
2 siblings, 0 replies; 6+ messages in thread
From: Harendra Gautam @ 2026-06-05 9:28 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Mark Brown, Liam Girdwood, linux-sound, linux-arm-msm, linux-kernel
Multiple Qualcomm ASoC CPU DAI drivers need to resolve a sound-dai
phandle argument to a DAI name by searching the component's DAI driver
array by ID. Each driver currently implements this identically.
Extract the common logic into asoc_qcom_of_xlate_dai_name() in
common.c so it can be shared across drivers without duplication.
Signed-off-by: Harendra Gautam <harendra.gautam@oss.qualcomm.com>
---
sound/soc/qcom/common.c | 34 ++++++++++++++++++++++++++++++++++
sound/soc/qcom/common.h | 5 +++++
2 files changed, 39 insertions(+)
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index cf1f3a767cee..46569290d44c 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -23,6 +23,40 @@ static const struct snd_soc_dapm_widget qcom_jack_snd_widgets[] = {
SND_SOC_DAPM_SPK("DP7 Jack", NULL),
};
+/**
+ * asoc_qcom_of_xlate_dai_name - Resolve a sound-dai phandle argument to a
+ * DAI name by searching the DAI driver array.
+ * @dai_drv: Array of DAI drivers registered by the component.
+ * @num_dai: Number of entries in @dai_drv.
+ * @args: Phandle arguments from the sound-dai property; args[0] is the
+ * DAI ID.
+ * @dai_name: Output pointer set to the matched DAI name on success.
+ *
+ * Returns 0 on success, -EINVAL if args_count != 1 or no match is found.
+ */
+int asoc_qcom_of_xlate_dai_name(const struct snd_soc_dai_driver *dai_drv,
+ int num_dai,
+ const struct of_phandle_args *args,
+ const char **dai_name)
+{
+ int id, i;
+
+ if (args->args_count != 1)
+ return -EINVAL;
+
+ id = args->args[0];
+
+ for (i = 0; i < num_dai; i++) {
+ if (dai_drv[i].id == id) {
+ *dai_name = dai_drv[i].name;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(asoc_qcom_of_xlate_dai_name);
+
int qcom_snd_parse_of(struct snd_soc_card *card)
{
struct device_node *np;
diff --git a/sound/soc/qcom/common.h b/sound/soc/qcom/common.h
index ee6662885593..5baf51a39c97 100644
--- a/sound/soc/qcom/common.h
+++ b/sound/soc/qcom/common.h
@@ -6,6 +6,7 @@
#include <dt-bindings/sound/qcom,q6afe.h>
#include <sound/soc.h>
+#include <sound/soc-dai.h>
#define LPASS_MAX_PORT (SENARY_MI2S_TX + 1)
@@ -15,5 +16,9 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
int qcom_snd_dp_jack_setup(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_jack *dp_jack, int id);
+int asoc_qcom_of_xlate_dai_name(const struct snd_soc_dai_driver *dai_drv,
+ int num_dai,
+ const struct of_phandle_args *args,
+ const char **dai_name);
#endif
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper
2026-06-05 9:28 [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Harendra Gautam
2026-06-05 9:28 ` [PATCH 1/2] ASoC: qcom: Add generic of_xlate_dai_name helper to common Harendra Gautam
@ 2026-06-05 9:28 ` Harendra Gautam
2026-06-05 12:21 ` Mark Brown
2026-06-05 9:41 ` [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Srinivas Kandagatla
2 siblings, 1 reply; 6+ messages in thread
From: Harendra Gautam @ 2026-06-05 9:28 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Mark Brown, Liam Girdwood, linux-sound, linux-arm-msm, linux-kernel
Replace the private static asoc_qcom_of_xlate_dai_name() implementation
in lpass-cpu.c with a thin wrapper that calls the new shared helper
from common.c. This removes the duplicate implementation.
Signed-off-by: Harendra Gautam <harendra.gautam@oss.qualcomm.com>
---
sound/soc/qcom/lpass-cpu.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
index 242bc16da36d..35c2c8030024 100644
--- a/sound/soc/qcom/lpass-cpu.c
+++ b/sound/soc/qcom/lpass-cpu.c
@@ -18,6 +18,7 @@
#include <sound/soc-dai.h>
#include "lpass-lpaif-reg.h"
#include "lpass.h"
+#include "common.h"
#define LPASS_CPU_MAX_MI2S_LINES 4
#define LPASS_CPU_I2S_SD0_MASK BIT(0)
@@ -458,30 +459,20 @@ const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops2 = {
};
EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops2);
-static int asoc_qcom_of_xlate_dai_name(struct snd_soc_component *component,
+static int lpass_cpu_of_xlate_dai_name(struct snd_soc_component *component,
const struct of_phandle_args *args,
const char **dai_name)
{
struct lpass_data *drvdata = snd_soc_component_get_drvdata(component);
const struct lpass_variant *variant = drvdata->variant;
- int id = args->args[0];
- int ret = -EINVAL;
- int i;
- for (i = 0; i < variant->num_dai; i++) {
- if (variant->dai_driver[i].id == id) {
- *dai_name = variant->dai_driver[i].name;
- ret = 0;
- break;
- }
- }
-
- return ret;
+ return asoc_qcom_of_xlate_dai_name(variant->dai_driver,
+ variant->num_dai, args, dai_name);
}
static const struct snd_soc_component_driver lpass_cpu_comp_driver = {
.name = "lpass-cpu",
- .of_xlate_dai_name = asoc_qcom_of_xlate_dai_name,
+ .of_xlate_dai_name = lpass_cpu_of_xlate_dai_name,
.legacy_dai_naming = 1,
};
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper
2026-06-05 9:28 [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Harendra Gautam
2026-06-05 9:28 ` [PATCH 1/2] ASoC: qcom: Add generic of_xlate_dai_name helper to common Harendra Gautam
2026-06-05 9:28 ` [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper Harendra Gautam
@ 2026-06-05 9:41 ` Srinivas Kandagatla
2026-06-05 12:23 ` Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Srinivas Kandagatla @ 2026-06-05 9:41 UTC (permalink / raw)
To: Harendra Gautam, Srinivas Kandagatla
Cc: Mark Brown, Liam Girdwood, linux-sound, linux-arm-msm, linux-kernel
On 6/5/26 10:28 AM, Harendra Gautam wrote:
> Multiple Qualcomm ASoC CPU DAI drivers implement the same logic to
> resolve a sound-dai phandle argument to a DAI name: iterate the
> component's DAI driver array and match by ID. This is currently
> duplicated between lpass-cpu.c and qaif-cpu.c.
>
> This series extracts the common logic into a shared helper
> asoc_qcom_of_xlate_dai_name() in common.c and refactors lpass-cpu.c
> to use it. The QAIF driver (in a separate series) will also use this
> helper instead of its own private implementation.
>
> Patch 1: Add asoc_qcom_of_xlate_dai_name() to common.c/h
> Patch 2: Refactor lpass-cpu.c to use the new helper
series itself does not make sense, as you only have one user for this at
the moment.
Please consider making it part of the series that actually has more than
one user for this.
--srini
>
> Harendra Gautam (2):
> ASoC: qcom: Add generic of_xlate_dai_name helper to common
> ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper
>
> sound/soc/qcom/common.c | 34 ++++++++++++++++++++++++++++++++++
> sound/soc/qcom/common.h | 5 +++++
> sound/soc/qcom/lpass-cpu.c | 19 +++++--------------
> 3 files changed, 44 insertions(+), 14 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper
2026-06-05 9:28 ` [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper Harendra Gautam
@ 2026-06-05 12:21 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-06-05 12:21 UTC (permalink / raw)
To: Harendra Gautam
Cc: Srinivas Kandagatla, Liam Girdwood, linux-sound, linux-arm-msm,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
On Fri, Jun 05, 2026 at 02:58:12PM +0530, Harendra Gautam wrote:
> Replace the private static asoc_qcom_of_xlate_dai_name() implementation
> in lpass-cpu.c with a thin wrapper that calls the new shared helper
> from common.c. This removes the duplicate implementation.
>
> Signed-off-by: Harendra Gautam <harendra.gautam@oss.qualcomm.com>
> ---
> sound/soc/qcom/lpass-cpu.c | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c
> index 242bc16da36d..35c2c8030024 100644
> --- a/sound/soc/qcom/lpass-cpu.c
> +++ b/sound/soc/qcom/lpass-cpu.c
> @@ -18,6 +18,7 @@
> #include <sound/soc-dai.h>
> #include "lpass-lpaif-reg.h"
> #include "lpass.h"
> +#include "common.h"
Did you double check that all users of LPASS select SND_SOC_QCOM_COMMON?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper
2026-06-05 9:41 ` [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Srinivas Kandagatla
@ 2026-06-05 12:23 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-06-05 12:23 UTC (permalink / raw)
To: Srinivas Kandagatla
Cc: Harendra Gautam, Liam Girdwood, linux-sound, linux-arm-msm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
On Fri, Jun 05, 2026 at 10:41:33AM +0100, Srinivas Kandagatla wrote:
> Please consider making it part of the series that actually has more than
> one user for this.
Or at least identify additional users that will be added soon, it might
make sense to cut down the size of a larger series by splitting out the
API addition. That's especially true if there's multiple new users that
each need their own series.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-05 12:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-05 9:28 [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Harendra Gautam
2026-06-05 9:28 ` [PATCH 1/2] ASoC: qcom: Add generic of_xlate_dai_name helper to common Harendra Gautam
2026-06-05 9:28 ` [PATCH 2/2] ASoC: qcom: lpass-cpu: Use asoc_qcom_of_xlate_dai_name helper Harendra Gautam
2026-06-05 12:21 ` Mark Brown
2026-06-05 9:41 ` [PATCH 0/2] ASoC: qcom: Refactor of_xlate_dai_name into common helper Srinivas Kandagatla
2026-06-05 12:23 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®