Skip to content

Commit e1d2075

Browse files
committed
lib: dai: Fix dai_get_device
dai_get_device is called using DAI-types from IPC definition but calls dai_config_get() which returnes a Zephyr DAI type. So, in order to fix this, we introduce `dai_type_to_zephyr` which converts a DAI-type from IPC definition to a Zephyr DAI type, so that later we can compare types in the same space. The current code works because the two DAI types are matching, but it is no longer the case with latest introduces types. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
1 parent f3ac6ed commit e1d2075

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

src/lib/dai.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,45 @@ const struct device *zephyr_dev[] = {
151151
#endif
152152
};
153153

154+
/* convert sof_ipc_dai_type to Zephyr dai_type */
155+
int dai_type_to_zephyr(uint32_t type)
156+
{
157+
switch (type) {
158+
case SOF_DAI_INTEL_SSP:
159+
return DAI_INTEL_SSP;
160+
case SOF_DAI_INTEL_DMIC:
161+
return DAI_INTEL_DMIC;
162+
case SOF_DAI_INTEL_HDA:
163+
return DAI_INTEL_HDA;
164+
case SOF_DAI_INTEL_ALH:
165+
return DAI_INTEL_ALH;
166+
case SOF_DAI_IMX_SAI:
167+
return DAI_IMX_SAI;
168+
case SOF_DAI_IMX_ESAI:
169+
return DAI_IMX_ESAI;
170+
case SOF_DAI_AMD_BT:
171+
return DAI_AMD_BT;
172+
case SOF_DAI_AMD_SP:
173+
return DAI_AMD_SP;
174+
case SOF_DAI_AMD_DMIC:
175+
return DAI_AMD_DMIC;
176+
case SOF_DAI_MEDIATEK_AFE:
177+
return DAI_MEDIATEK_AFE;
178+
case SOF_DAI_AMD_HS:
179+
case SOF_DAI_AMD_SP_VIRTUAL:
180+
case SOF_DAI_AMD_HS_VIRTUAL:
181+
case SOF_DAI_IMX_MICFIL:
182+
case SOF_DAI_AMD_SW_AUDIO:
183+
return -ENOTSUP;
184+
default:
185+
return -EINVAL;
186+
}
187+
}
188+
154189
const struct device *dai_get_device(uint32_t type, uint32_t index)
155190
{
156191
struct dai_config cfg;
192+
int z_type;
157193
int dir;
158194
int i;
159195

@@ -162,7 +198,8 @@ const struct device *dai_get_device(uint32_t type, uint32_t index)
162198
for (i = 0; i < ARRAY_SIZE(zephyr_dev); i++) {
163199
if (dai_config_get(zephyr_dev[i], &cfg, dir))
164200
continue;
165-
if (cfg.type == type && cfg.dai_index == index)
201+
z_type = dai_type_to_zephyr(type);
202+
if (cfg.type == z_type && cfg.dai_index == index)
166203
return zephyr_dev[i];
167204
}
168205

0 commit comments

Comments
 (0)