Skip to content
Merged
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
23 changes: 15 additions & 8 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,15 +1143,22 @@ static int create_bt_dailinks(struct snd_soc_card *card,
struct snd_soc_dai_link **dai_links, int *be_id)
{
struct device *dev = card->dev;
int port = (sof_sdw_quirk & SOF_BT_OFFLOAD_SSP_MASK) >>
SOF_BT_OFFLOAD_SSP_SHIFT;
char *name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev);
char *cpu_dai_name;
char *name;
int port;
int ret;

if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
port = (sof_sdw_quirk & SOF_BT_OFFLOAD_SSP_MASK) >> SOF_BT_OFFLOAD_SSP_SHIFT;
else
port = fls(mach->mach_params.bt_link_mask) - 1;

Choose a reason for hiding this comment

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

@bardliao , If bt_link_mask is reset to 0 because of incorrect settings, it may result in an invalid port value.

    if (hweight_long(mach->mach_params.bt_link_mask) > 1) {
            dev_warn(sdev->dev, "invalid BT link mask %#x found, reset the mask\n",
                    mach->mach_params.bt_link_mask);
            mach->mach_params.bt_link_mask = 0;
    }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure how can it happen. create_bt_dailinks() is only called when sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT || mach_params->bt_link_mask. Shouldn't bt_link_mask always > 0 in the else case?

Choose a reason for hiding this comment

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

Yes, in the else case. However, I see your point. The pre-condition has already excluded the 0 value. LGTM, just last question: the bt_link_mask method seems only available to modify the NHLT SSP assignment, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bt_link_mask is usually from the NHLT SSP assignment, but we can use the bt_link_mask module parameter to overwrite it.


name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
if (!name || !cpu_dai_name)
return -ENOMEM;

int ret;

ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1, 1, cpu_dai_name, "dummy",
snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
Expand Down Expand Up @@ -1248,7 +1255,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
mach_params->dmic_num = DMIC_DEFAULT_CHANNELS;
}

if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT || mach_params->bt_link_mask)
bt_num = 1;

dev_dbg(dev, "DAI link numbers: sdw %d, ssp %d, dmic %d, hdmi %d, bt: %d\n",
Expand Down Expand Up @@ -1303,7 +1310,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
goto err_end;

/* BT */
if (sof_sdw_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) {
if (bt_num) {
ret = create_bt_dailinks(card, &dai_links, &be_id);
if (ret)
goto err_end;
Expand Down
Loading