Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,8 @@ static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev,
return adr_dev;
}

#define SDW_ENUM_TIMEOUT_MS 3000

static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev)
{
struct snd_sof_pdata *pdata = sdev->pdata;
Expand All @@ -1315,7 +1317,9 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
struct sdw_peripherals *peripherals;
struct snd_soc_acpi_mach *mach;
struct sof_intel_hda_dev *hdev;
struct sdw_slave *slave;
int link_index, link_num;
unsigned long time;
int amp_index = 1;
u32 link_mask = 0;
int i;
Expand Down Expand Up @@ -1416,14 +1420,32 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
if (!links)
return NULL;

/*
* Recalculate the link_mask as a link will be empty if all peripherals on the link are
* not enumerated
*/
link_mask = 0;
/* Generate snd_soc_acpi_link_adr struct for each peripheral reported by the ACPI table */
for (i = 0; i < peripherals->num_peripherals; i++) {
slave = peripherals->array[i];

/* Check if the SoundWire peripheral is present */
if (sof_debug_check_flag(SOF_DBG_CHECK_SDW_PERIPHERAL) && !slave->dev_num_sticky) {
/* Wait for the peripheral to enumerate */
time = wait_for_completion_timeout(&slave->enumeration_complete,
msecs_to_jiffies(SDW_ENUM_TIMEOUT_MS));
if (!time) {
dev_warn(&slave->dev, "SoundWire peripheral is not present\n");
Comment thread
bardliao marked this conversation as resolved.
continue;
}
}
/* link_index = the number of used links below the current link */
link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));
links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i],
link_index = hweight32(link_mask & (BIT(slave->bus->link_id) - 1));
links[link_index].adr_d = find_acpi_adr_device(sdev->dev, slave,
&links[link_index], &amp_index);
if (!links[link_index].adr_d)
return NULL;
link_mask |= BIT(slave->bus->link_id);
}

mach->drv_name = "sof_sdw";
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ struct snd_sof_pcm_stream;
* DSPLESS_MODE is not set.
* No audio functionality when enabled.
*/
#define SOF_DBG_CHECK_SDW_PERIPHERAL BIT(17) /* Check if SoundWire peripherals are
* present while selecting machine driver
*/
Comment on lines +59 to +61
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new macro definition line is very long due to the inline block comment; consider moving the comment above the #define (or shortening it) to better match kernel style and avoid checkpatch line-length warnings.

Suggested change
#define SOF_DBG_CHECK_SDW_PERIPHERAL BIT(17) /* Check if SoundWire peripherals are
* present while selecting machine driver
*/
/* Check if SoundWire peripherals are present while selecting machine driver */
#define SOF_DBG_CHECK_SDW_PERIPHERAL BIT(17)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aligned to other DBG flag defines.


/* Flag definitions used for controlling the DSP dump behavior */
#define SOF_DBG_DUMP_REGS BIT(0)
Expand Down
Loading