Skip to content

Commit af2ab6c

Browse files
committed
ASoc: SOF: misc updates for 6.10
Merge series from Pierre-Louis Bossart <[email protected]>: Fixes when fw_lib_prefix is not set, updated error messages, improved dmesg logs to SoundWire configurations not supported by ACPI tables/topology and support for IEC61937 passthrough.
2 parents 34c43ad + eed4872 commit af2ab6c

File tree

4 files changed

+162
-76
lines changed

4 files changed

+162
-76
lines changed

sound/soc/sof/debug.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,27 @@ int snd_sof_dbg_init(struct snd_sof_dev *sdev)
326326

327327
debugfs_create_str("fw_path", 0444, fw_profile,
328328
(char **)&plat_data->fw_filename_prefix);
329-
debugfs_create_str("fw_lib_path", 0444, fw_profile,
330-
(char **)&plat_data->fw_lib_prefix);
329+
/* library path is not valid for IPC3 */
330+
if (plat_data->ipc_type != SOF_IPC_TYPE_3) {
331+
/*
332+
* fw_lib_prefix can be NULL if the vendor/platform does not
333+
* support loadable libraries
334+
*/
335+
if (plat_data->fw_lib_prefix) {
336+
debugfs_create_str("fw_lib_path", 0444, fw_profile,
337+
(char **)&plat_data->fw_lib_prefix);
338+
} else {
339+
static char *fw_lib_path;
340+
341+
fw_lib_path = devm_kasprintf(sdev->dev, GFP_KERNEL,
342+
"Not supported");
343+
if (!fw_lib_path)
344+
return -ENOMEM;
345+
346+
debugfs_create_str("fw_lib_path", 0444, fw_profile,
347+
(char **)&fw_lib_path);
348+
}
349+
}
331350
debugfs_create_str("tplg_path", 0444, fw_profile,
332351
(char **)&plat_data->tplg_filename_prefix);
333352
debugfs_create_str("fw_name", 0444, fw_profile,

sound/soc/sof/intel/hda.c

Lines changed: 88 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
16451645
{
16461646
struct snd_sof_pdata *pdata = sdev->pdata;
16471647
const struct snd_soc_acpi_link_adr *link;
1648+
struct sdw_extended_slave_id *ids;
16481649
struct snd_soc_acpi_mach *mach;
16491650
struct sof_intel_hda_dev *hdev;
16501651
u32 link_mask;
@@ -1653,92 +1654,109 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
16531654
hdev = pdata->hw_pdata;
16541655
link_mask = hdev->info.link_mask;
16551656

1657+
if (!link_mask) {
1658+
dev_info(sdev->dev, "SoundWire links not enabled\n");
1659+
return NULL;
1660+
}
1661+
1662+
if (!hdev->sdw) {
1663+
dev_dbg(sdev->dev, "SoundWire context not allocated\n");
1664+
return NULL;
1665+
}
1666+
1667+
if (!hdev->sdw->num_slaves) {
1668+
dev_warn(sdev->dev, "No SoundWire peripheral detected in ACPI tables\n");
1669+
return NULL;
1670+
}
1671+
16561672
/*
16571673
* Select SoundWire machine driver if needed using the
16581674
* alternate tables. This case deals with SoundWire-only
16591675
* machines, for mixed cases with I2C/I2S the detection relies
16601676
* on the HID list.
16611677
*/
1662-
if (link_mask) {
1663-
for (mach = pdata->desc->alt_machines;
1664-
mach && mach->link_mask; mach++) {
1665-
/*
1666-
* On some platforms such as Up Extreme all links
1667-
* are enabled but only one link can be used by
1668-
* external codec. Instead of exact match of two masks,
1669-
* first check whether link_mask of mach is subset of
1670-
* link_mask supported by hw and then go on searching
1671-
* link_adr
1672-
*/
1673-
if (~link_mask & mach->link_mask)
1674-
continue;
1675-
1676-
/* No need to match adr if there is no links defined */
1677-
if (!mach->links)
1678-
break;
1679-
1680-
link = mach->links;
1681-
for (i = 0; i < hdev->info.count && link->num_adr;
1682-
i++, link++) {
1683-
/*
1684-
* Try next machine if any expected Slaves
1685-
* are not found on this link.
1686-
*/
1687-
if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1688-
hdev->sdw->ids,
1689-
hdev->sdw->num_slaves))
1690-
break;
1691-
}
1692-
/* Found if all Slaves are checked */
1693-
if (i == hdev->info.count || !link->num_adr)
1694-
break;
1695-
}
1696-
if (mach && mach->link_mask) {
1697-
int dmic_num = 0;
1698-
bool tplg_fixup;
1699-
const char *tplg_filename;
1700-
1701-
mach->mach_params.links = mach->links;
1702-
mach->mach_params.link_mask = mach->link_mask;
1703-
mach->mach_params.platform = dev_name(sdev->dev);
1678+
for (mach = pdata->desc->alt_machines;
1679+
mach && mach->link_mask; mach++) {
1680+
/*
1681+
* On some platforms such as Up Extreme all links
1682+
* are enabled but only one link can be used by
1683+
* external codec. Instead of exact match of two masks,
1684+
* first check whether link_mask of mach is subset of
1685+
* link_mask supported by hw and then go on searching
1686+
* link_adr
1687+
*/
1688+
if (~link_mask & mach->link_mask)
1689+
continue;
17041690

1705-
if (pdata->tplg_filename) {
1706-
tplg_fixup = false;
1707-
} else {
1708-
tplg_fixup = true;
1709-
tplg_filename = mach->sof_tplg_filename;
1710-
}
1691+
/* No need to match adr if there is no links defined */
1692+
if (!mach->links)
1693+
break;
17111694

1695+
link = mach->links;
1696+
for (i = 0; i < hdev->info.count && link->num_adr;
1697+
i++, link++) {
17121698
/*
1713-
* DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1714-
* link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1715-
* if all conditions are true:
1716-
* a) 2 or fewer links are used by SoundWire
1717-
* b) the NHLT table reports the presence of microphones
1699+
* Try next machine if any expected Slaves
1700+
* are not found on this link.
17181701
*/
1719-
if (hweight_long(mach->link_mask) <= 2) {
1720-
int ret;
1721-
1722-
ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
1723-
&dmic_num, tplg_fixup);
1724-
if (ret < 0)
1725-
return NULL;
1726-
}
1727-
if (tplg_fixup)
1728-
pdata->tplg_filename = tplg_filename;
1729-
mach->mach_params.dmic_num = dmic_num;
1702+
if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
1703+
hdev->sdw->ids,
1704+
hdev->sdw->num_slaves))
1705+
break;
1706+
}
1707+
/* Found if all Slaves are checked */
1708+
if (i == hdev->info.count || !link->num_adr)
1709+
break;
1710+
}
1711+
if (mach && mach->link_mask) {
1712+
int dmic_num = 0;
1713+
bool tplg_fixup;
1714+
const char *tplg_filename;
1715+
1716+
mach->mach_params.links = mach->links;
1717+
mach->mach_params.link_mask = mach->link_mask;
1718+
mach->mach_params.platform = dev_name(sdev->dev);
1719+
1720+
if (pdata->tplg_filename) {
1721+
tplg_fixup = false;
1722+
} else {
1723+
tplg_fixup = true;
1724+
tplg_filename = mach->sof_tplg_filename;
1725+
}
17301726

1731-
dev_dbg(sdev->dev,
1732-
"SoundWire machine driver %s topology %s\n",
1733-
mach->drv_name,
1734-
pdata->tplg_filename);
1727+
/*
1728+
* DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1729+
* link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1730+
* if all conditions are true:
1731+
* a) 2 or fewer links are used by SoundWire
1732+
* b) the NHLT table reports the presence of microphones
1733+
*/
1734+
if (hweight_long(mach->link_mask) <= 2) {
1735+
int ret;
17351736

1736-
return mach;
1737+
ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
1738+
&dmic_num, tplg_fixup);
1739+
if (ret < 0)
1740+
return NULL;
17371741
}
1742+
if (tplg_fixup)
1743+
pdata->tplg_filename = tplg_filename;
1744+
mach->mach_params.dmic_num = dmic_num;
17381745

1739-
dev_info(sdev->dev, "No SoundWire machine driver found\n");
1746+
dev_dbg(sdev->dev,
1747+
"SoundWire machine driver %s topology %s\n",
1748+
mach->drv_name,
1749+
pdata->tplg_filename);
1750+
1751+
return mach;
17401752
}
17411753

1754+
dev_info(sdev->dev, "No SoundWire machine driver found for the ACPI-reported configuration:\n");
1755+
ids = hdev->sdw->ids;
1756+
for (i = 0; i < hdev->sdw->num_slaves; i++)
1757+
dev_info(sdev->dev, "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n",
1758+
ids[i].link_id, ids[i].id.mfg_id, ids[i].id.part_id, ids[i].id.sdw_version);
1759+
17421760
return NULL;
17431761
}
17441762
#else

sound/soc/sof/ipc4-topology.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,52 @@ static void sof_ipc4_widget_update_kcontrol_module_id(struct snd_sof_widget *swi
407407
}
408408
}
409409

410+
static int
411+
sof_ipc4_update_card_components_string(struct snd_sof_widget *swidget,
412+
struct snd_sof_pcm *spcm, int dir)
413+
{
414+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
415+
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
416+
struct snd_soc_component *scomp = spcm->scomp;
417+
struct snd_soc_card *card = scomp->card;
418+
const char *pt_marker = "iec61937-pcm";
419+
420+
/*
421+
* Update the card's components list with iec61937-pcm and a list of PCM
422+
* ids where ChainDMA is enabled.
423+
* These PCMs can be used for bytestream passthrough.
424+
*/
425+
if (!pipeline->use_chain_dma)
426+
return 0;
427+
428+
if (card->components) {
429+
const char *tmp = card->components;
430+
431+
if (strstr(card->components, pt_marker))
432+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
433+
"%s,%d",
434+
card->components,
435+
spcm->pcm.pcm_id);
436+
else
437+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
438+
"%s %s:%d",
439+
card->components,
440+
pt_marker,
441+
spcm->pcm.pcm_id);
442+
443+
devm_kfree(card->dev, tmp);
444+
} else {
445+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
446+
"%s:%d", pt_marker,
447+
spcm->pcm.pcm_id);
448+
}
449+
450+
if (!card->components)
451+
return -ENOMEM;
452+
453+
return 0;
454+
}
455+
410456
static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
411457
{
412458
struct sof_ipc4_available_audio_format *available_fmt;
@@ -452,6 +498,10 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
452498
if (!spcm)
453499
goto skip_gtw_cfg;
454500

501+
ret = sof_ipc4_update_card_components_string(swidget, spcm, dir);
502+
if (ret)
503+
goto free_available_fmt;
504+
455505
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
456506
struct snd_sof_pcm_stream *sps = &spcm->stream[dir];
457507

sound/soc/sof/topology.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,10 +1531,9 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
15311531
/* check token parsing reply */
15321532
if (ret < 0) {
15331533
dev_err(scomp->dev,
1534-
"error: failed to add widget id %d type %d name : %s stream %s\n",
1535-
tw->shift, swidget->id, tw->name,
1536-
strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0
1537-
? tw->sname : "none");
1534+
"failed to add widget type %d name : %s stream %s\n",
1535+
swidget->id, tw->name, strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0
1536+
? tw->sname : "none");
15381537
goto widget_free;
15391538
}
15401539

0 commit comments

Comments
 (0)