Skip to content

Commit

Permalink
ASoC: Intel: sof_rt5682 add support for HDMI_In capture
Browse files Browse the repository at this point in the history
Adding support for 2 streams of HDMI-In capture via I2S with rt5682s
codec variant

Signed-off-by: apoorv <[email protected]>
  • Loading branch information
apoorvintel committed Jul 10, 2023
1 parent e2b8ebc commit d44f43f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
64 changes: 64 additions & 0 deletions sound/soc/intel/boards/sof_rt5682.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@
#define SOF_MAX98390_TWEETER_SPEAKER_PRESENT BIT(25)
#define SOF_RT1019_SPEAKER_AMP_PRESENT BIT(26)

/* HDMI capture*/
#define SOF_SSP_HDMI_CAPTURE_PRESENT BIT(27)
#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 28
#define SOF_NO_OF_HDMI_CAPTURE_SSP_MASK (GENMASK(29, 28))
#define SOF_NO_OF_HDMI_CAPTURE_SSP(quirk) \
(((quirk) << SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT) & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK)

#define SOF_HDMI_CAPTURE_1_SSP_SHIFT 30
#define SOF_HDMI_CAPTURE_1_SSP_MASK (GENMASK(32, 30))
#define SOF_HDMI_CAPTURE_1_SSP(quirk) \
(((unsigned long)(quirk) << SOF_HDMI_CAPTURE_1_SSP_SHIFT) & SOF_HDMI_CAPTURE_1_SSP_MASK)

#define SOF_HDMI_CAPTURE_2_SSP_SHIFT 33
#define SOF_HDMI_CAPTURE_2_SSP_MASK (GENMASK(35, 33))
#define SOF_HDMI_CAPTURE_2_SSP(quirk) \
(((unsigned long)(quirk) << SOF_HDMI_CAPTURE_2_SSP_SHIFT) & SOF_HDMI_CAPTURE_2_SSP_MASK)


/* Default: MCLK on, MCLK 19.2M, SSP0 */
static unsigned long sof_rt5682_quirk = SOF_RT5682_MCLK_EN |
Expand Down Expand Up @@ -634,6 +651,7 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
struct snd_soc_dai_link_component *cpus;
struct snd_soc_dai_link *links;
int i, id = 0;
int hdmi_id_offset = 0;

links = devm_kcalloc(dev, sof_audio_card_rt5682.num_links,
sizeof(struct snd_soc_dai_link), GFP_KERNEL);
Expand Down Expand Up @@ -857,6 +875,37 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
links[id].num_cpus = 1;
}

/* HDMI-In SSP */
if (sof_rt5682_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) {
int num_of_hdmi_ssp = (sof_rt5682_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >>
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;

for (i = 1; i <= num_of_hdmi_ssp; i++) {
int port = (i == 1 ? (sof_rt5682_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >>
SOF_HDMI_CAPTURE_1_SSP_SHIFT :
(sof_rt5682_quirk & SOF_HDMI_CAPTURE_2_SSP_MASK) >>
SOF_HDMI_CAPTURE_2_SSP_SHIFT);

links[id].cpus = &cpus[id];
links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
"SSP%d Pin", port);
if (!links[id].cpus->dai_name)
return NULL;
links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port);
if (!links[id].name)
return NULL;
links[id].id = id + hdmi_id_offset;
links[id].codecs = dummy_component;
links[id].num_codecs = ARRAY_SIZE(dummy_component);
links[id].platforms = platform_component;
links[id].num_platforms = ARRAY_SIZE(platform_component);
links[id].dpcm_capture = 1;
links[id].no_pcm = 1;
links[id].num_cpus = 1;
id++;
}
}

return links;
devm_err:
return NULL;
Expand Down Expand Up @@ -962,6 +1011,11 @@ static int sof_audio_probe(struct platform_device *pdev)
if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT)
sof_audio_card_rt5682.num_links++;

if (sof_rt5682_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT)
sof_audio_card_rt5682.num_links +=
(sof_rt5682_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >>
SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT;

dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp,
dmic_be_num, hdmi_num, ctx->idisp_codec);
if (!dai_links)
Expand Down Expand Up @@ -1186,6 +1240,16 @@ static const struct platform_device_id board_ids[] = {
SOF_RT5682_SSP_AMP(0) |
SOF_RT5682_NUM_HDMIDEV(3)),
},
{
.name = "adl_rt5682_c1_h02",
.driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN |
SOF_RT5682_SSP_CODEC(1) |
SOF_RT5682_NUM_HDMIDEV(3) |
SOF_NO_OF_HDMI_CAPTURE_SSP(2) |
SOF_HDMI_CAPTURE_1_SSP(0) |
SOF_HDMI_CAPTURE_2_SSP(2) |
SOF_SSP_HDMI_CAPTURE_PRESENT),
},
{ }
};
MODULE_DEVICE_TABLE(platform, board_ids);
Expand Down
17 changes: 12 additions & 5 deletions sound/soc/intel/common/soc-acpi-intel-adl-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,6 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
.quirk_data = &adl_max98390_amp,
.sof_tplg_filename = "sof-adl-max98390-rt5682.tplg",
},
{
.comp_ids = &adl_rt5682_rt5682s_hp,
.drv_name = "adl_rt5682",
.sof_tplg_filename = "sof-adl-rt5682.tplg",
},
{
.id = "10134242",
.drv_name = "adl_mx98360a_cs4242",
Expand All @@ -595,6 +590,18 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = {
SND_SOC_ACPI_TPLG_INTEL_SSP_MSB |
SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER,
},
{
.comp_ids = &adl_rt5682_rt5682s_hp,
.drv_name = "adl_rt5682_c1_h02",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &adl_lt6911_hdmi,
.sof_tplg_filename = "sof-adl-rt5682-ssp1-hdmi-ssp02.tplg",
},
{
.comp_ids = &adl_rt5682_rt5682s_hp,
.drv_name = "adl_rt5682",
.sof_tplg_filename = "sof-adl-rt5682.tplg",
},
/* place amp-only boards in the end of table */
{
.id = "CSC3541",
Expand Down

0 comments on commit d44f43f

Please sign in to comment.