Merge remote-tracking branch 'asoc/topic/intel' into asoc-next
authorMark Brown <broonie@kernel.org>
Fri, 1 Sep 2017 11:12:19 +0000 (12:12 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 1 Sep 2017 11:12:19 +0000 (12:12 +0100)
1  2 
sound/soc/codecs/Makefile
sound/soc/codecs/hdac_hdmi.c
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
sound/soc/intel/skylake/skl.c

@@@ -113,7 -113,6 +113,7 @@@ snd-soc-pcm512x-i2c-objs := pcm512x-i2c
  snd-soc-pcm512x-spi-objs := pcm512x-spi.o
  snd-soc-rl6231-objs := rl6231.o
  snd-soc-rl6347a-objs := rl6347a.o
 +snd-soc-rt274-objs := rt274.o
  snd-soc-rt286-objs := rt286.o
  snd-soc-rt298-objs := rt298.o
  snd-soc-rt5514-objs := rt5514.o
@@@ -321,6 -320,7 +321,7 @@@ obj-$(CONFIG_SND_SOC_MAX98088)     += snd-s
  obj-$(CONFIG_SND_SOC_MAX98090)        += snd-soc-max98090.o
  obj-$(CONFIG_SND_SOC_MAX98095)        += snd-soc-max98095.o
  obj-$(CONFIG_SND_SOC_MAX98357A)       += snd-soc-max98357a.o
+ obj-$(CONFIG_SND_SOC_MAX98371)        += snd-soc-max98371.o
  obj-$(CONFIG_SND_SOC_MAX9867) += snd-soc-max9867.o
  obj-$(CONFIG_SND_SOC_MAX98925)        += snd-soc-max98925.o
  obj-$(CONFIG_SND_SOC_MAX98926)        += snd-soc-max98926.o
@@@ -350,7 -350,6 +351,7 @@@ obj-$(CONFIG_SND_SOC_PCM512x_I2C)  += sn
  obj-$(CONFIG_SND_SOC_PCM512x_SPI)     += snd-soc-pcm512x-spi.o
  obj-$(CONFIG_SND_SOC_RL6231)  += snd-soc-rl6231.o
  obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o
 +obj-$(CONFIG_SND_SOC_RT274)   += snd-soc-rt274.o
  obj-$(CONFIG_SND_SOC_RT286)   += snd-soc-rt286.o
  obj-$(CONFIG_SND_SOC_RT298)   += snd-soc-rt298.o
  obj-$(CONFIG_SND_SOC_RT5514)  += snd-soc-rt5514.o
@@@ -121,6 -121,10 +121,10 @@@ struct hdac_hdmi_dai_port_map 
        struct hdac_hdmi_cvt *cvt;
  };
  
+ struct hdac_hdmi_drv_data {
+       unsigned int vendor_nid;
+ };
  struct hdac_hdmi_priv {
        struct hdac_hdmi_dai_port_map dai_map[HDA_MAX_CVTS];
        struct list_head pin_list;
        int num_ports;
        struct mutex pin_mutex;
        struct hdac_chmap chmap;
+       struct hdac_hdmi_drv_data *drv_data;
  };
  
  static struct hdac_hdmi_pcm *
@@@ -1321,6 -1326,7 +1326,7 @@@ static int hdac_hdmi_add_pin(struct hda
  }
  
  #define INTEL_VENDOR_NID 0x08
+ #define INTEL_GLK_VENDOR_NID 0x0b
  #define INTEL_GET_VENDOR_VERB 0xf81
  #define INTEL_SET_VENDOR_VERB 0x781
  #define INTEL_EN_DP12                 0x02 /* enable DP 1.2 features */
  static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdac)
  {
        unsigned int vendor_param;
+       struct hdac_ext_device *edev = to_ehdac_device(hdac);
+       struct hdac_hdmi_priv *hdmi = edev->private_data;
+       unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
  
-       vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0,
+       vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0,
                                INTEL_GET_VENDOR_VERB, 0);
        if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS)
                return;
  
        vendor_param |= INTEL_EN_ALL_PIN_CVTS;
-       vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0,
+       vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0,
                                INTEL_SET_VENDOR_VERB, vendor_param);
        if (vendor_param == -1)
                return;
  static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac)
  {
        unsigned int vendor_param;
+       struct hdac_ext_device *edev = to_ehdac_device(hdac);
+       struct hdac_hdmi_priv *hdmi = edev->private_data;
+       unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
  
-       vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0,
+       vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0,
                                INTEL_GET_VENDOR_VERB, 0);
        if (vendor_param == -1 || vendor_param & INTEL_EN_DP12)
                return;
  
        /* enable DP1.2 mode */
        vendor_param |= INTEL_EN_DP12;
-       vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0,
+       vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0,
                                INTEL_SET_VENDOR_VERB, vendor_param);
        if (vendor_param == -1)
                return;
  
  }
  
 -static struct snd_soc_dai_ops hdmi_dai_ops = {
 +static const struct snd_soc_dai_ops hdmi_dai_ops = {
        .startup = hdac_hdmi_pcm_open,
        .shutdown = hdac_hdmi_pcm_close,
        .hw_params = hdac_hdmi_set_hw_params,
@@@ -1858,7 -1870,7 +1870,7 @@@ static void hdmi_codec_complete(struct 
  #define hdmi_codec_complete NULL
  #endif
  
 -static struct snd_soc_codec_driver hdmi_hda_codec = {
 +static const struct snd_soc_codec_driver hdmi_hda_codec = {
        .probe          = hdmi_codec_probe,
        .remove         = hdmi_codec_remove,
        .idle_bias_off  = true,
@@@ -1927,6 -1939,14 +1939,14 @@@ static int hdac_hdmi_get_spk_alloc(stru
        return port->eld.info.spk_alloc;
  }
  
+ static struct hdac_hdmi_drv_data intel_glk_drv_data  = {
+       .vendor_nid = INTEL_GLK_VENDOR_NID,
+ };
+ static struct hdac_hdmi_drv_data intel_drv_data  = {
+       .vendor_nid = INTEL_VENDOR_NID,
+ };
  static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
  {
        struct hdac_device *codec = &edev->hdac;
        struct hdac_ext_link *hlink = NULL;
        int num_dais = 0;
        int ret = 0;
+       struct hdac_driver *hdrv = drv_to_hdac_driver(codec->dev.driver);
+       const struct hda_device_id *hdac_id = hdac_get_device_id(codec, hdrv);
  
        /* hold the ref while we probe */
        hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev));
        hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached;
        hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc;
  
+       if (hdac_id->driver_data)
+               hdmi_priv->drv_data =
+                       (struct hdac_hdmi_drv_data *)hdac_id->driver_data;
+       else
+               hdmi_priv->drv_data = &intel_drv_data;
        dev_set_drvdata(&codec->dev, edev);
  
        INIT_LIST_HEAD(&hdmi_priv->pin_list);
@@@ -2127,7 -2155,8 +2155,8 @@@ static const struct hda_device_id hdmi_
        HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
        HDA_CODEC_EXT_ENTRY(0x8086280a, 0x100000, "Broxton HDMI", 0),
        HDA_CODEC_EXT_ENTRY(0x8086280b, 0x100000, "Kabylake HDMI", 0),
-       HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI", 0),
+       HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI",
+                                                  &intel_glk_drv_data),
        {}
  };
  
@@@ -18,6 -18,7 +18,7 @@@
   * GNU General Public License for more details.
   */
  
+ #include <linux/input.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
  #include <sound/core.h>
@@@ -62,7 -63,10 +63,10 @@@ struct kbl_codec_private 
  enum {
        KBL_DPCM_AUDIO_PB = 0,
        KBL_DPCM_AUDIO_CP,
+       KBL_DPCM_AUDIO_HS_PB,
+       KBL_DPCM_AUDIO_ECHO_REF_CP,
        KBL_DPCM_AUDIO_DMIC_CP,
+       KBL_DPCM_AUDIO_RT5514_DSP,
        KBL_DPCM_AUDIO_HDMI1_PB,
        KBL_DPCM_AUDIO_HDMI2_PB,
  };
@@@ -81,8 -85,8 +85,8 @@@ static const struct snd_soc_dapm_widge
        SND_SOC_DAPM_SPK("Left Spk", NULL),
        SND_SOC_DAPM_SPK("Right Spk", NULL),
        SND_SOC_DAPM_MIC("DMIC", NULL),
-       SND_SOC_DAPM_SPK("DP", NULL),
-       SND_SOC_DAPM_SPK("HDMI", NULL),
+       SND_SOC_DAPM_SPK("HDMI1", NULL),
+       SND_SOC_DAPM_SPK("HDMI2", NULL),
  
  };
  
@@@ -99,23 -103,25 +103,25 @@@ static const struct snd_soc_dapm_route 
        { "IN1P", NULL, "Headset Mic" },
        { "IN1N", NULL, "Headset Mic" },
  
-       { "HDMI", NULL, "hif5 Output" },
-       { "DP", NULL, "hif6 Output" },
        /* CODEC BE connections */
        { "Left HiFi Playback", NULL, "ssp0 Tx" },
        { "Right HiFi Playback", NULL, "ssp0 Tx" },
-       { "ssp0 Tx", NULL, "codec0_out" },
+       { "ssp0 Tx", NULL, "spk_out" },
  
        { "AIF Playback", NULL, "ssp1 Tx" },
-       { "ssp1 Tx", NULL, "codec1_out" },
+       { "ssp1 Tx", NULL, "hs_out" },
  
-       { "codec0_in", NULL, "ssp1 Rx" },
+       { "hs_in", NULL, "ssp1 Rx" },
        { "ssp1 Rx", NULL, "AIF Capture" },
  
        { "codec1_in", NULL, "ssp0 Rx" },
        { "ssp0 Rx", NULL, "AIF1 Capture" },
  
+       /* IV feedback path */
+       { "codec0_fb_in", NULL, "ssp0 Rx"},
+       { "ssp0 Rx", NULL, "Left HiFi Capture" },
+       { "ssp0 Rx", NULL, "Right HiFi Capture" },
        /* DMIC */
        { "DMIC1L", NULL, "DMIC" },
        { "DMIC1R", NULL, "DMIC" },
@@@ -173,6 -179,7 +179,7 @@@ static int kabylake_rt5663_codec_init(s
        int ret;
        struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card);
        struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_jack *jack;
  
        /*
         * Headset buttons map to the google Reference headset.
                return ret;
        }
  
+       jack = &ctx->kabylake_headset;
+       snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA);
+       snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
+       snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
+       snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
        rt5663_set_jack_detect(codec, &ctx->kabylake_headset);
  
        ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC");
@@@ -319,9 -332,7 +332,9 @@@ static int kabylake_rt5663_hw_params(st
        int ret;
  
        /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */
 -      rt5663_sel_asrc_clk_src(codec_dai->codec, RT5663_DA_STEREO_FILTER, 1);
 +      rt5663_sel_asrc_clk_src(codec_dai->codec,
 +                      RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER,
 +                      RT5663_CLK_SEL_I2S1_ASRC);
  
        ret = snd_soc_dai_set_sysclk(codec_dai,
                        RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
@@@ -351,18 -362,34 +364,25 @@@ static int kabylake_ssp0_hw_params(stru
                                return ret;
                        }
  
 -                      ret = snd_soc_dai_set_pll(codec_dai, 0,
 -                              RT5514_PLL1_S_BCLK, RT5514_AIF1_BCLK_FREQ,
 -                                              RT5514_AIF1_SYSCLK_FREQ);
 -                      if (ret < 0) {
 -                              dev_err(rtd->dev, "set bclk err: %d\n", ret);
 -                              return ret;
 -                      }
 -
                        ret = snd_soc_dai_set_sysclk(codec_dai,
 -                              RT5514_SCLK_S_PLL1, RT5514_AIF1_SYSCLK_FREQ,
 -                                                      SND_SOC_CLOCK_IN);
 +                              RT5514_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN);
                        if (ret < 0) {
 -                              dev_err(rtd->dev, "set sclk err: %d\n", ret);
 +                              dev_err(rtd->dev, "set sysclk err: %d\n", ret);
                                return ret;
                        }
                }
-               if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME) ||
-                       !strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
-                       ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF0, 3, 8, 16);
+               if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) {
+                       ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16);
                        if (ret < 0) {
-                               dev_err(rtd->dev, "set TDM slot err:%d\n", ret);
+                               dev_err(rtd->dev, "DEV0 TDM slot err:%d\n", ret);
+                               return ret;
+                       }
+               }
+               if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) {
+                       ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16);
+                       if (ret < 0) {
+                               dev_err(rtd->dev, "DEV1 TDM slot err:%d\n", ret);
                                return ret;
                        }
                }
@@@ -442,6 -469,36 +462,36 @@@ static struct snd_soc_dai_link kabylake
                .dpcm_capture = 1,
                .ops = &kabylake_rt5663_fe_ops,
        },
+       [KBL_DPCM_AUDIO_HS_PB] = {
+               .name = "Kbl Audio Headset Playback",
+               .stream_name = "Headset Audio",
+               .cpu_dai_name = "System Pin2",
+               .codec_name = "snd-soc-dummy",
+               .codec_dai_name = "snd-soc-dummy-dai",
+               .platform_name = "0000:00:1f.3",
+               .dpcm_playback = 1,
+               .nonatomic = 1,
+               .dynamic = 1,
+       },
+       [KBL_DPCM_AUDIO_ECHO_REF_CP] = {
+               .name = "Kbl Audio Echo Reference cap",
+               .stream_name = "Echoreference Capture",
+               .cpu_dai_name = "Echoref Pin",
+               .codec_name = "snd-soc-dummy",
+               .codec_dai_name = "snd-soc-dummy-dai",
+               .platform_name = "0000:00:1f.3",
+               .init = NULL,
+               .capture_only = 1,
+               .nonatomic = 1,
+       },
+       [KBL_DPCM_AUDIO_RT5514_DSP] = {
+               .name = "rt5514 dsp",
+               .stream_name = "Wake on Voice",
+               .cpu_dai_name = "spi-PRP0001:00",
+               .platform_name = "spi-PRP0001:00",
+               .codec_name = "snd-soc-dummy",
+               .codec_dai_name = "snd-soc-dummy-dai",
+       },
        [KBL_DPCM_AUDIO_DMIC_CP] = {
                .name = "Kbl Audio DMIC cap",
                .stream_name = "dmiccap",
@@@ -548,10 -605,12 +598,12 @@@ static int kabylake_card_late_probe(str
  {
        struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
        struct kbl_hdmi_pcm *pcm;
+       struct snd_soc_codec *codec = NULL;
        int err, i = 0;
        char jack_name[NAME_SIZE];
  
        list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
+               codec = pcm->codec_dai->codec;
                err = snd_soc_card_jack_new(card, jack_name,
                                SND_JACK_AVOUT, &ctx->kabylake_hdmi[i],
                                NULL, 0);
                i++;
        }
  
-       return 0;
+       if (!codec)
+               return -EINVAL;
+       return hdac_hdmi_jack_port_init(codec, &card->dapm);
  }
  
  /*
@@@ -415,7 -415,7 +415,7 @@@ static int skl_free(struct hdac_ext_bu
        snd_hdac_ext_stop_streams(ebus);
  
        if (bus->irq >= 0)
-               free_irq(bus->irq, (void *)bus);
+               free_irq(bus->irq, (void *)ebus);
        snd_hdac_bus_free_stream_pages(bus);
        snd_hdac_stream_free_all(ebus);
        snd_hdac_link_free_all(ebus);
@@@ -528,7 -528,7 +528,7 @@@ static int probe_codec(struct hdac_ext_
  }
  
  /* Codec initialization */
- static int skl_codec_create(struct hdac_ext_bus *ebus)
+ static void skl_codec_create(struct hdac_ext_bus *ebus)
  {
        struct hdac_bus *bus = ebus_to_hbus(ebus);
        int c, max_slots;
                        }
                }
        }
-       return 0;
  }
  
  static const struct hdac_bus_ops bus_core_ops = {
@@@ -612,9 -610,7 +610,7 @@@ static void skl_probe_work(struct work_
                dev_info(bus->dev, "no hda codecs found!\n");
  
        /* create codec instances */
-       err = skl_codec_create(ebus);
-       if (err < 0)
-               goto out_err;
+       skl_codec_create(ebus);
  
        if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) {
                err = snd_hdac_display_power(bus, false);
@@@ -702,6 -698,8 +698,8 @@@ static int skl_first_init(struct hdac_e
                return -ENXIO;
        }
  
+       skl_init_chip(bus, true);
        snd_hdac_bus_parse_capabilities(bus);
  
        if (skl_acquire_irq(ebus, 0) < 0)
@@@ -879,12 -877,12 +877,12 @@@ static void skl_remove(struct pci_dev *
  
  static struct sst_codecs skl_codecs = {
        .num_codecs = 1,
 -      .codecs = {"NAU88L25"}
 +      .codecs = {"10508825"}
  };
  
  static struct sst_codecs kbl_codecs = {
        .num_codecs = 1,
 -      .codecs = {"NAU88L25"}
 +      .codecs = {"10508825"}
  };
  
  static struct sst_codecs bxt_codecs = {
@@@ -941,7 -939,6 +939,7 @@@ static struct sst_acpi_mach sst_bxtp_de
                .machine_quirk = sst_acpi_codec_list,
                .quirk_data = &bxt_codecs,
        },
 +      {}
  };
  
  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",
+       },
  
        {}
  };
@@@ -992,9 -994,16 +995,17 @@@ static struct sst_acpi_mach sst_glk_dev
                .drv_name = "glk_alc298s_i2s",
                .fw_filename = "intel/dsp_fw_glk.bin",
        },
 +      {}
  };
  
+ static const struct sst_acpi_mach sst_cnl_devdata[] = {
+       {
+               .id = "INT34C2",
+               .drv_name = "cnl_rt274",
+               .fw_filename = "intel/dsp_fw_cnl.bin",
+       },
+ };
  /* PCI IDs */
  static const struct pci_device_id skl_ids[] = {
        /* Sunrise Point-LP */
        /* GLK */
        { PCI_DEVICE(0x8086, 0x3198),
                .driver_data = (unsigned long)&sst_glk_devdata},
+       /* CNL */
+       { PCI_DEVICE(0x8086, 0x9dc8),
+               .driver_data = (unsigned long)&sst_cnl_devdata},
        { 0, }
  };
  MODULE_DEVICE_TABLE(pci, skl_ids);