Skip to content

Commit

Permalink
ASoC: Intel: skl_hda_dsp_generic: support BT audio offload
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
brentlu committed Jul 31, 2024
1 parent 24e7e25 commit 6f78e60
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
13 changes: 13 additions & 0 deletions sound/soc/intel/boards/skl_hda_dsp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ SND_SOC_DAILINK_DEF(dmic_codec,
SND_SOC_DAILINK_DEF(dmic16k,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));

SND_SOC_DAILINK_DEF(bt_offload_pin,
DAILINK_COMP_ARRAY(COMP_CPU(""))); /* initialized in driver probe function */
SND_SOC_DAILINK_DEF(dummy,
DAILINK_COMP_ARRAY(COMP_DUMMY()));

SND_SOC_DAILINK_DEF(platform,
DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));

Expand Down Expand Up @@ -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 = NULL, /* initialized in driver probe function */
.id = 8,
.dpcm_playback = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(bt_offload_pin, dummy, platform),
},
};

int skl_hda_hdmi_jack_init(struct snd_soc_card *card)
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/intel/boards/skl_hda_dsp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "../../codecs/hdac_hda.h"
#include "hda_dsp_common.h"

#define HDA_DSP_MAX_BE_DAI_LINKS 7
#define HDA_DSP_MAX_BE_DAI_LINKS 8

struct skl_hda_hdmi_pcm {
struct list_head head;
Expand All @@ -35,6 +35,8 @@ struct skl_hda_private {
const char *platform_name;
bool common_hdmi_codec_drv;
bool idisp_codec;
bool bt_offload_present;
int ssp_bt;
};

extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
Expand Down
37 changes: 33 additions & 4 deletions sound/soc/intel/boards/skl_hda_dsp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,20 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
#define IDISP_DAI_COUNT 3
#define HDAC_DAI_COUNT 2
#define DMIC_DAI_COUNT 2
#define BT_DAI_COUNT 1

/* there are two routes per iDisp output */
#define IDISP_ROUTE_COUNT (IDISP_DAI_COUNT * 2)
#define IDISP_CODEC_MASK 0x4

#define HDA_CODEC_AUTOSUSPEND_DELAY_MS 1000

static int skl_hda_fill_card_info(struct snd_soc_card *card,
static int skl_hda_fill_card_info(struct device *dev, struct snd_soc_card *card,
struct snd_soc_acpi_mach_params *mach_params)
{
struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_dai_link *dai_link;
struct snd_soc_dai_link *bt_link;
u32 codec_count, codec_mask;
int i, num_links, num_route;

Expand All @@ -120,7 +122,7 @@ static int skl_hda_fill_card_info(struct snd_soc_card *card,

if (codec_mask == IDISP_CODEC_MASK) {
/* topology with iDisp as the only HDA codec */
num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT;
num_links = IDISP_DAI_COUNT + DMIC_DAI_COUNT + BT_DAI_COUNT;
num_route = IDISP_ROUTE_COUNT;

/*
Expand All @@ -129,7 +131,7 @@ static int skl_hda_fill_card_info(struct snd_soc_card *card,
* num_links of dai links need to be registered
* to ASoC.
*/
for (i = 0; i < DMIC_DAI_COUNT; i++) {
for (i = 0; i < (DMIC_DAI_COUNT + BT_DAI_COUNT); i++) {
skl_hda_be_dai_links[IDISP_DAI_COUNT + i] =
skl_hda_be_dai_links[IDISP_DAI_COUNT +
HDAC_DAI_COUNT + i];
Expand All @@ -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 -= BT_DAI_COUNT;
} else {
if (codec_mask == IDISP_CODEC_MASK)
bt_link = &skl_hda_be_dai_links[IDISP_DAI_COUNT + DMIC_DAI_COUNT];
else
bt_link = &skl_hda_be_dai_links[IDISP_DAI_COUNT + HDAC_DAI_COUNT + DMIC_DAI_COUNT];

/* complete the link name and dai name with SSP port number */
bt_link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT",
ctx->ssp_bt);
if (!bt_link->name)
return -ENOMEM;

bt_link->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SSP%d Pin",
ctx->ssp_bt);
if (!bt_link->cpus->dai_name)
return -ENOMEM;
}

card->num_links = num_links;
card->num_dapm_routes = num_route;

Expand Down Expand Up @@ -213,7 +237,12 @@ static int skl_hda_audio_probe(struct platform_device *pdev)

snd_soc_card_set_drvdata(card, ctx);

ret = skl_hda_fill_card_info(card, &mach->mach_params);
if (hweight_long(mach->mach_params.bt_link_mask) == 1) {
ctx->bt_offload_present = true;
ctx->ssp_bt = fls(mach->mach_params.bt_link_mask) - 1;
}

ret = skl_hda_fill_card_info(&pdev->dev, card, &mach->mach_params);
if (ret < 0) {
dev_err(&pdev->dev, "Unsupported HDAudio/iDisp configuration found\n");
return ret;
Expand Down

0 comments on commit 6f78e60

Please sign in to comment.