Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BT audio offload on HDA machines #5123

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

brentlu
Copy link

@brentlu brentlu commented Jul 29, 2024

SOF platform driver walks through HNLT endpoints and looks for endpoint which device type is BT sideband (0). Once a BT sideband endpoint is found, the SSP port number will be used to compose link mask and passed to machine driver to create BE link for BT audio offload.

@@ -150,6 +152,28 @@ static int skl_hda_fill_card_info(struct snd_soc_card *card,
}
}

if (!ctx->bt_offload_present) {
/* remove last link since bt audio offload is not supported */
num_links--;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You define #define BT_DAI_COUNT 1, INHO, it is better to use num_links -= BT_DAI_COUNT in case BT_DAI_COUNT is changed one day.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@brentlu brentlu force-pushed the hda-mach-2 branch 2 times, most recently from d197f34 to 6960b82 Compare July 29, 2024 06:34
bardliao
bardliao previously approved these changes Jul 29, 2024
@@ -165,6 +167,12 @@ struct snd_soc_acpi_link_adr {
*/
#define SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME BIT(4)

/*
* when set the BT offload name suffix '-bt' will be appended to topology file
Copy link
Collaborator

Choose a reason for hiding this comment

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

the code appends -bt-ssp%d tot he topology filename...

* when set the BT offload name suffix '-bt' will be appended to topology file
* name if the feature is implemented in ACPI NHLT table
*/
#define SND_SOC_ACPI_TPLG_INTEL_BT_OFFLOAD BIT(5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a documented rule on what order these appends should be done, I believe they must be always <bit(0)><bit(1)>...<bit(last)> ?

@@ -444,6 +444,10 @@ static int mclk_id_override = -1;
module_param_named(mclk_id, mclk_id_override, int, 0444);
MODULE_PARM_DESC(mclk_id, "SOF SSP mclk_id");

static int bt_link_mask_override = 0x0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to initialize to 0

Copy link
Author

Choose a reason for hiding this comment

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

fixed

mach->mach_params.bt_link_mask = check_nhlt_ssp_mask(sdev, NHLT_DEVICE_BT);

/* allow for module parameter override */
if (bt_link_mask_override != 0x00) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (!bt_link_mask_override) { ?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

/* allow for module parameter override */
if (bt_link_mask_override != 0x00) {
dev_dbg(sdev->dev,
"overriding bt link mask detected in NHLT tables 0x%x by kernel param 0x%x\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

New code should use %#x for hexadecimal numbers.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

if (ssp_mask)
dev_info(sdev->dev, "NHLT_DEVICE_I2S detected, ssp_mask %#x\n", ssp_mask);
dev_info(sdev->dev, "NHLT device %d detected, ssp_mask %#x\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would be hard pressed to guess based on the number what device is detected..

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@@ -132,6 +137,14 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic16k, dmic_codec, platform),
},
{
.name = "SSP%d-BT",
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a novel way, but I would rather not set this string as initial name.

Copy link
Author

Choose a reason for hiding this comment

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

fixed

sound/soc/intel/boards/skl_hda_dsp_generic.c Show resolved Hide resolved
return -ENOMEM;

bt_link->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
bt_link->cpus->dai_name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The dai_name comes from topology and in a form of a magic string also?

Copy link
Author

Choose a reason for hiding this comment

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

The name is from here:

SND_SOC_DAILINK_DEF(bt_offload_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP%d Pin")));

@@ -14,7 +14,8 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_hda_machines[] = {
/* .id is not used in this file */
.drv_name = "skl_hda_dsp_generic",
.sof_tplg_filename = "sof-hda-generic", /* the tplg suffix is added at run time */
.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
.tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER |
SND_SOC_ACPI_TPLG_INTEL_BT_OFFLOAD,
Copy link
Collaborator

Choose a reason for hiding this comment

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

and this is going to break a lot of system presumably since we don not have any -bt-ssp topology out there..

Copy link
Author

Choose a reason for hiding this comment

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

I removed all tplg name fixup code and let OSV to decide so we don't break all HDA PC...

Copy link
Member

Choose a reason for hiding this comment

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

I removed all tplg name fixup code and let OSV to decide so we don't break all HDA PC...

The problem is that we don't know who the OSV is, and we don't know how to distribute the required topology. So while the changes look ok at a high-level, who's going to use all this?

I don't want to merge something that creates a headache for support teams. We don't have a plan that makes any sense at the moment.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry I should provide the background story instead of just shooting the patches.

Currently there is a Chrome reference design brox which enables HDA external codec. Since BT audio offload was enabled for I2S Chromebooks, we want this feature could be also supported for HDA Chromebooks as well.

For the kernel driver, we will backport these two patches to Chrome tree and update the module option since Chromebook does not support NHLT table. And for topology, we will backport the patch to cavs2.5 branch and request Google to release the topology.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Looks mostly good now @brentlu, that's an acceptable solution that allows for new functionality without breaking older setups. Thanks for taking this initiative.

sound/soc/sof/intel/hda.c Show resolved Hide resolved
.name = NULL, /* initialized in driver probe function */
.id = 8,
.dpcm_playback = 1,
.dpcm_capture = 1,
Copy link
Member

Choose a reason for hiding this comment

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

I forgot if those flags still exist or have been removed.

Copy link
Author

Choose a reason for hiding this comment

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

not yet removed. still doing some cleanups
https://patchwork.kernel.org/project/alsa-devel/list/?series=874792

Add an new variable bt_link_mask to snd_soc_acpi_mach_params structure.
SSP port mask of BT offload found in NHLT table will be sent to
machine driver to setup BE dai link with correct SSP port number.

This patch only detects and enables the BT dailink. The functionality
will only be unlocked with a topology file that makes a reference to
that BT dailink. For backwards-compatibility reasons, this topology
will not be used by default. Chromebooks and Linux users willing to
experiment shall use the tplg_name kernel parameter to force the use
of an enhanced topology.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Add BT offload BE link to dai link array if the BT offload link mask
is valid (only one bit set).

Signed-off-by: Brent Lu <brent.lu@intel.com>
@plbossart
Copy link
Member

@ujfalusi @bardliao @kv2019i can you take a look?

@plbossart plbossart merged commit bc47b82 into thesofproject:topic/sof-dev Aug 7, 2024
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants