ASoC: Intel: Add Kabylake machine driver for RT5663
Subsystems (3)
v2 cover ASoC: Intel: Add Kabylake machine driver for RT5663
Add kabylake machine driver & corresponding driver entry in machine table for rt5663 codec.
For this particular machine,
the RT5663 is a headset codec connected on ssp1.
there is no dmic and speaker connected.
Modify the machine driver in kbl_rt5663_max98927 to reuse the
common codes.
V2: adjust the code order.
Kevin Cheng (2):
ASoC: Intel: Add Kabylake machine driver for RT5663
ASoC: Intel: Add Kabylake RT5663 machine driver entry
sound/soc/intel/boards/kbl_rt5663_max98927.c | 246 +++++++++++++++++++++++---- sound/soc/intel/skylake/skl.c | 5 + 2 files changed, 214 insertions(+), 37 deletions(-)
Signature · 1 line
2.12.2
PATCH v2 1/2 ASoC: Intel: Add Kabylake machine driver for RT5663
This patch adds Kabylake I2S machine driver which uses RT5663 as headset on ssp1.
--- sound/soc/intel/boards/kbl_rt5663_max98927.c | 246 +++++++++++++++++++++++---- 1 file changed, 209 insertions(+), 37 deletions(-)
sound/soc/intel/boards/kbl_rt5663_max98927.c +209 -37
@@ -34,7 +34,7 @@#define MAXIM_DEV0_NAME "i2c-MX98927:00"#define MAXIM_DEV1_NAME "i2c-MX98927:01" -static struct snd_soc_card kabylake_audio_card; +static struct snd_soc_card *kabylake_audio_card;static const struct snd_pcm_hw_constraint_list *dmic_constraints;static struct snd_soc_jack skylake_hdmi[3 ];
@@ -117,6 +117,49 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "iDisp1 Tx", NULL, "iDisp1_out"}, }; +enum { + KBL_DPCM_AUDIO_5663_PB = 0, + KBL_DPCM_AUDIO_5663_CP, + KBL_DPCM_AUDIO_5663_HDMI1_PB, + KBL_DPCM_AUDIO_5663_HDMI2_PB, +}; + +static const struct snd_kcontrol_new kabylake_5663_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), +}; + +static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), +}; + +static const struct snd_soc_dapm_route kabylake_5663_map[] = { + { "Headphone Jack", NULL, "HPOL" }, + { "Headphone Jack", NULL, "HPOR" }, + + /* other jacks */ + { "IN1P", NULL, "Headset Mic" }, + { "IN1N", NULL, "Headset Mic" }, + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "AIF Playback", NULL, "ssp1 Tx" }, + { "ssp1 Tx", NULL, "codec1_out" }, + + { "codec0_in", NULL, "ssp1 Rx" }, + { "ssp1 Rx", NULL, "AIF Capture" }, + + { "hifi2", NULL, "iDisp2 Tx"}, + { "iDisp2 Tx", NULL, "iDisp2_out"}, + { "hifi1", NULL, "iDisp1 Tx"}, + { "iDisp1 Tx", NULL, "iDisp1_out"}, +}; + static struct snd_soc_codec_conf max98927_codec_conf[] = { { .dev_name = MAXIM_DEV0_NAME,
@@ -165,7 +208,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)* Headset buttons map to the google Reference headset. * These can be configured by userspace. */ - ret =snd_soc_card_jack_new (&kabylake_audio_card,"Headset Jack" , + ret =snd_soc_card_jack_new (kabylake_audio_card,"Headset Jack" ,SND_JACK_HEADSET |SND_JACK_BTN_0 |SND_JACK_BTN_1 |SND_JACK_BTN_2 |SND_JACK_BTN_3 , &ctx->kabylake_headset,NULL ,0 );
@@ -173,8 +216,18 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)dev_err (rtd->dev,"Headset Jack creation failed %d\n" , ret);return ret; } -rt5663_set_jack_detect (codec, &ctx->kabylake_headset); +return ret; +} + +static int kabylake_rt5663_max98927_codec_init (struct snd_soc_pcm_runtime *rtd) +{ +int ret; + + ret =kabylake_rt5663_codec_init (rtd); +if (ret) +return ret; + ret =snd_soc_dapm_ignore_suspend (&rtd->card->dapm,"SoC DMIC" );if (ret) {dev_err (rtd->dev,"SoC DMIC ignore suspend failed %d\n" , ret);
@@ -184,7 +237,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd)return ret; } -static int kabylake_hdmi1_init (struct snd_soc_pcm_runtime *rtd) +static int kabylake_hdmi_init (struct snd_soc_pcm_runtime *rtd,int device) {struct kbl_rt5663_private *ctx =snd_soc_card_get_drvdata (rtd->card);struct snd_soc_dai *dai = rtd->codec_dai;
@@ -194,7 +247,7 @@ static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)if (!pcm)return -ENOMEM ; - pcm->device =KBL_DPCM_AUDIO_HDMI1_PB ; + pcm->device = device; pcm->codec_dai = dai;list_add_tail (&pcm->head, &ctx->hdmi_pcm_list);
@@ -202,40 +255,29 @@ static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd)return 0 ; } -static int kabylake_hdmi2_init (struct snd_soc_pcm_runtime *rtd) +static int kabylake_hdmi1_init (struct snd_soc_pcm_runtime *rtd) { -struct kbl_rt5663_private *ctx =snd_soc_card_get_drvdata (rtd->card); -struct snd_soc_dai *dai = rtd->codec_dai; -struct kbl_hdmi_pcm *pcm; - - pcm =devm_kzalloc (rtd->card->dev,sizeof (*pcm),GFP_KERNEL ); -if (!pcm) -return -ENOMEM ; - - pcm->device =KBL_DPCM_AUDIO_HDMI2_PB ; - pcm->codec_dai = dai; - -list_add_tail (&pcm->head, &ctx->hdmi_pcm_list); +return kabylake_hdmi_init (rtd,KBL_DPCM_AUDIO_HDMI1_PB ); +} -return 0 ; +static int kabylake_hdmi2_init (struct snd_soc_pcm_runtime *rtd) +{ +return kabylake_hdmi_init (rtd,KBL_DPCM_AUDIO_HDMI2_PB ); }static int kabylake_hdmi3_init (struct snd_soc_pcm_runtime *rtd) { -struct kbl_rt5663_private *ctx =snd_soc_card_get_drvdata (rtd->card); -struct snd_soc_dai *dai = rtd->codec_dai; -struct kbl_hdmi_pcm *pcm; - - pcm =devm_kzalloc (rtd->card->dev,sizeof (*pcm),GFP_KERNEL ); -if (!pcm) -return -ENOMEM ; - - pcm->device =KBL_DPCM_AUDIO_HDMI3_PB ; - pcm->codec_dai = dai; +return kabylake_hdmi_init (rtd,KBL_DPCM_AUDIO_HDMI3_PB ); +} -list_add_tail (&pcm->head, &ctx->hdmi_pcm_list); +static int kabylake_5663_hdmi1_init (struct snd_soc_pcm_runtime *rtd) +{ +return kabylake_hdmi_init (rtd,KBL_DPCM_AUDIO_5663_HDMI1_PB ); +} -return 0 ; +static int kabylake_5663_hdmi2_init (struct snd_soc_pcm_runtime *rtd) +{ +return kabylake_hdmi_init (rtd,KBL_DPCM_AUDIO_5663_HDMI2_PB ); }static unsigned int rates[] = {
@@ -538,7 +580,7 @@ static struct snd_soc_dai_link kabylake_dais[] = { .no_pcm = 1, .codec_name = "i2c-10EC5663:00", .codec_dai_name = KBL_REALTEK_CODEC_DAI, - .init = kabylake_rt5663_codec_init, + .init = kabylake_rt5663_max98927_codec_init, .dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ignore_pmdown_time = 1,
@@ -594,6 +636,108 @@ static struct snd_soc_dai_link kabylake_dais[] = { }, }; +static struct snd_soc_dai_link kabylake_5663_dais[] = { +/* Front End DAI links */ + [KBL_DPCM_AUDIO_5663_PB ] = { + .name ="Kbl Audio Port" , + .stream_name ="Audio" , + .cpu_dai_name ="System Pin" , + .platform_name ="0000:00:1f.3" , + .dynamic =1 , + .codec_name ="snd-soc-dummy" , + .codec_dai_name ="snd-soc-dummy-dai" , + .nonatomic =1 , + .trigger = { +SND_SOC_DPCM_TRIGGER_POST ,SND_SOC_DPCM_TRIGGER_POST }, + .dpcm_playback =1 , + .ops = &kabylake_rt5663_fe_ops, + }, + [KBL_DPCM_AUDIO_5663_CP ] = { + .name ="Kbl Audio Capture Port" , + .stream_name ="Audio Record" , + .cpu_dai_name ="System Pin" , + .platform_name ="0000:00:1f.3" , + .dynamic =1 , + .codec_name ="snd-soc-dummy" , + .codec_dai_name ="snd-soc-dummy-dai" , + .nonatomic =1 , + .trigger = { +SND_SOC_DPCM_TRIGGER_POST ,SND_SOC_DPCM_TRIGGER_POST }, + .dpcm_capture =1 , + .ops = &kabylake_rt5663_fe_ops, + }, + [KBL_DPCM_AUDIO_5663_HDMI1_PB ] = { + .name ="Kbl HDMI Port1" , + .stream_name ="Hdmi1" , + .cpu_dai_name ="HDMI1 Pin" , + .codec_name ="snd-soc-dummy" , + .codec_dai_name ="snd-soc-dummy-dai" , + .platform_name ="0000:00:1f.3" , + .dpcm_playback =1 , + .init =NULL , + .trigger = { +SND_SOC_DPCM_TRIGGER_POST ,SND_SOC_DPCM_TRIGGER_POST }, + .nonatomic =1 , + .dynamic =1 , + }, + [KBL_DPCM_AUDIO_5663_HDMI2_PB ] = { + .name ="Kbl HDMI Port2" , + .stream_name ="Hdmi2" , + .cpu_dai_name ="HDMI2 Pin" , + .codec_name ="snd-soc-dummy" , + .codec_dai_name ="snd-soc-dummy-dai" , + .platform_name ="0000:00:1f.3" , + .dpcm_playback =1 , + .init =NULL , + .trigger = { +SND_SOC_DPCM_TRIGGER_POST ,SND_SOC_DPCM_TRIGGER_POST }, + .nonatomic =1 , + .dynamic =1 , + }, + +/* Back End DAI links */ + { +/* SSP1 - Codec */ + .name ="SSP1-Codec" , + .id =0 , + .cpu_dai_name ="SSP1 Pin" , + .platform_name ="0000:00:1f.3" , + .no_pcm =1 , + .codec_name ="i2c-10EC5663:00" , + .codec_dai_name =KBL_REALTEK_CODEC_DAI , + .init = kabylake_rt5663_codec_init, + .dai_fmt =SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_NB_NF | +SND_SOC_DAIFMT_CBS_CFS , + .ignore_pmdown_time =1 , + .be_hw_params_fixup = kabylake_ssp_fixup, + .ops = &kabylake_rt5663_ops, + .dpcm_playback =1 , + .dpcm_capture =1 , + }, + { + .name ="iDisp1" , + .id =1 , + .cpu_dai_name ="iDisp1 Pin" , + .codec_name ="ehdaudio0D2" , + .codec_dai_name ="intel-hdmi-hifi1" , + .platform_name ="0000:00:1f.3" , + .dpcm_playback =1 , + .init = kabylake_5663_hdmi1_init, + .no_pcm =1 , + }, + { + .name ="iDisp2" , + .id =2 , + .cpu_dai_name ="iDisp2 Pin" , + .codec_name ="ehdaudio0D2" , + .codec_dai_name ="intel-hdmi-hifi2" , + .platform_name ="0000:00:1f.3" , + .init = kabylake_5663_hdmi2_init, + .dpcm_playback =1 , + .no_pcm =1 , + }, +}; +#define NAME_SIZE 32static int kabylake_card_late_probe (struct snd_soc_card *card) {
@@ -624,7 +768,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) }/* kabylake audio machine driver for SPT + RT5663 */ -static struct snd_soc_card kabylake_audio_card = { +static struct snd_soc_card kabylake_audio_card_rt5663_m98927 = { .name ="kblrt5663max" , .owner =THIS_MODULE , .dai_link = kabylake_dais,
@@ -641,6 +785,22 @@ static struct snd_soc_card kabylake_audio_card = { .late_probe = kabylake_card_late_probe, }; +/* kabylake audio machine driver for RT5663 */ +static struct snd_soc_card kabylake_audio_card_rt5663 = { + .name ="kblrt5663" , + .owner =THIS_MODULE , + .dai_link = kabylake_5663_dais, + .num_links =ARRAY_SIZE (kabylake_5663_dais), + .controls = kabylake_5663_controls, + .num_controls =ARRAY_SIZE (kabylake_5663_controls), + .dapm_widgets = kabylake_5663_widgets, + .num_dapm_widgets =ARRAY_SIZE (kabylake_5663_widgets), + .dapm_routes = kabylake_5663_map, + .num_dapm_routes =ARRAY_SIZE (kabylake_5663_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; +static int kabylake_audio_probe (struct platform_device *pdev) {struct kbl_rt5663_private *ctx;
@@ -652,19 +812,30 @@ static int kabylake_audio_probe(struct platform_device *pdev)INIT_LIST_HEAD (&ctx->hdmi_pcm_list); - kabylake_audio_card.dev = &pdev->dev; -snd_soc_card_set_drvdata (&kabylake_audio_card, ctx); + kabylake_audio_card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + + kabylake_audio_card->dev = &pdev->dev; +snd_soc_card_set_drvdata (kabylake_audio_card, ctx); pdata =dev_get_drvdata (&pdev->dev);if (pdata) dmic_constraints = pdata->dmic_num ==2 ? &constraints_dmic_2ch : &constraints_dmic_channels; -return devm_snd_soc_register_card (&pdev->dev, &kabylake_audio_card); +return devm_snd_soc_register_card (&pdev->dev, kabylake_audio_card); }static const struct platform_device_id kbl_board_ids[] = { - { .name ="kbl_rt5663_m98927" }, + { + .name ="kbl_rt5663" , + .driver_data = (kernel_ulong_t)&kabylake_audio_card_rt5663, + }, + { + .name ="kbl_rt5663_m98927" , + .driver_data = + (kernel_ulong_t)&kabylake_audio_card_rt5663_m98927, + }, { } };
@@ -684,4 +855,5 @@ MODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode");MODULE_AUTHOR ("Naveen M <[email protected]>" );MODULE_AUTHOR ("Harsha Priya <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:kbl_rt5663" );MODULE_ALIAS ("platform:kbl_rt5663_m98927" );
Signature · 1 line
2.12.2
PATCH v2 2/2 ASoC: Intel: Add Kabylake RT5663 machine driver entry
In reply to Kevin ChengAdds Kabylake rt5663 machine driver entry into machine table
--- sound/soc/intel/skylake/skl.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/intel/skylake/skl.c +5 -0
@@ -981,6 +981,11 @@ static struct sst_acpi_mach sst_kbl_devdata[] = { .quirk_data = &kbl_poppy_codecs, .pdata = &skl_dmic_data }, + { + .id = "10EC5663", + .drv_name = "kbl_rt5663", + .fw_filename = "intel/dsp_fw_kbl.bin", + }, {} };
Signature · 1 line
2.12.2
Quoted 9 lines · Kevin Cheng
Add kabylake machine driver & corresponding driver entry in machine table for rt5663 codec.
For this particular machine,
the RT5663 is a headset codec connected on ssp1.
there is no dmic and speaker connected.Modify the machine driver in
kbl_rt5663_max98927to reuse the
common codes.
Signature · 1 line
~Vinod