ASoC: SDCA: class_function: xlate sound-dai cell by entity index

sdca_asoc_populate_dais() sets each DAI id from the SDCA Function's
entity array index.  ASoC's default of_xlate_dai_name treats the
phandle cell as a positional index into the DAI list, so on a Function
with non-DAI entries between dataport entities a sound-dai phandle
resolves to the wrong DAI.

Register a custom of_xlate_dai_name that walks the entity array and
returns the dataport entity whose array index matches the cell value.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20260925161049.758913-6-srinivas.kandagatla@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Srinivas Kandagatla 2026-09-25 17:10:46 +01:00 committed by Mark Brown
parent 3273ec3e14
commit e0e876c99f
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -216,9 +216,43 @@ static int class_function_set_jack(struct snd_soc_component *component,
return sdca_jack_set_jack(core->irq_info, jack);
}
/*
* DT phandle cell is the SDCA entity index (matches dais[].id), not the
* positional DAI index the default xlate assumes.
*/
static int class_function_of_xlate_dai_name(struct snd_soc_component *component,
const struct of_phandle_args *args,
const char **dai_name)
{
struct class_function_drv *drv = snd_soc_component_get_drvdata(component);
struct sdca_function_data *function = drv->function;
struct sdca_entity *entity;
u32 target;
if (args->args_count != 1)
return -EINVAL;
target = args->args[0];
if (target >= function->num_entities)
goto err;
entity = &function->entities[target];
if ((entity->type != SDCA_ENTITY_TYPE_IT &&
entity->type != SDCA_ENTITY_TYPE_OT) || !entity->iot.is_dataport)
goto err;
*dai_name = entity->label;
return 0;
err:
dev_err(component->dev, "xlate: no dataport entity at index %u (num_entities=%d)\n",
target, function->num_entities);
return -EINVAL;
}
static const struct snd_soc_component_driver class_function_component_drv = {
.fixup_controls = class_function_component_fixup_controls,
.remove = class_function_component_remove,
.of_xlate_dai_name = class_function_of_xlate_dai_name,
.endianness = 1,
};