summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-05-09 01:13:40 -0400
committerTakashi Iwai <tiwai@suse.de>2019-05-09 01:13:40 -0400
commited97c988bdc61ab6fb5d1f5f02a709844557b68f (patch)
tree9eb2087f95a6e319c44cf7f4f1bcd9ab723651d1 /sound
parent7f84ff68be05ec7a5d2acf8fdc734fe5897af48f (diff)
parent7f6647ced298d56027218e47619b7f0d925fc83e (diff)
Merge tag 'asoc-v5.2-5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v5.2 A bunch of driver specific fixes that came in since the initial pull request for v5.2, mainly warning fixes for the newly added Sound Open Firmware code which people appeared to only start looking at after I'd sent the pull request.
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/hdac_hdmi.c13
-rw-r--r--sound/soc/codecs/mt6358.c131
-rw-r--r--sound/soc/sof/core.c2
-rw-r--r--sound/soc/stm/stm32_i2s.c3
4 files changed, 87 insertions, 62 deletions
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 4de1fbfa8827..660e0587f399 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -455,24 +455,11 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
455 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) 455 struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai)
456{ 456{
457 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); 457 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai);
458 struct hdac_device *hdev = hdmi->hdev;
459 struct hdac_hdmi_dai_port_map *dai_map; 458 struct hdac_hdmi_dai_port_map *dai_map;
460 struct hdac_hdmi_port *port;
461 struct hdac_hdmi_pcm *pcm; 459 struct hdac_hdmi_pcm *pcm;
462 int format; 460 int format;
463 461
464 dai_map = &hdmi->dai_map[dai->id]; 462 dai_map = &hdmi->dai_map[dai->id];
465 port = dai_map->port;
466
467 if (!port)
468 return -ENODEV;
469
470 if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) {
471 dev_err(&hdev->dev,
472 "device is not configured for this pin:port%d:%d\n",
473 port->pin->nid, port->id);
474 return -ENODEV;
475 }
476 463
477 format = snd_hdac_calc_stream_format(params_rate(hparams), 464 format = snd_hdac_calc_stream_format(params_rate(hparams),
478 params_channels(hparams), params_format(hparams), 465 params_channels(hparams), params_format(hparams),
diff --git a/sound/soc/codecs/mt6358.c b/sound/soc/codecs/mt6358.c
index d4c4fee6d3d9..50b3fc5457ea 100644
--- a/sound/soc/codecs/mt6358.c
+++ b/sound/soc/codecs/mt6358.c
@@ -320,32 +320,6 @@ enum {
320#define DL_GAIN_N_40DB_REG (DL_GAIN_N_40DB << 7 | DL_GAIN_N_40DB) 320#define DL_GAIN_N_40DB_REG (DL_GAIN_N_40DB << 7 | DL_GAIN_N_40DB)
321#define DL_GAIN_REG_MASK 0x0f9f 321#define DL_GAIN_REG_MASK 0x0f9f
322 322
323static void lo_store_gain(struct mt6358_priv *priv)
324{
325 unsigned int reg;
326 unsigned int gain_l, gain_r;
327
328 regmap_read(priv->regmap, MT6358_ZCD_CON1, &reg);
329 gain_l = (reg >> RG_AUDLOLGAIN_SFT) & RG_AUDLOLGAIN_MASK;
330 gain_r = (reg >> RG_AUDLORGAIN_SFT) & RG_AUDLORGAIN_MASK;
331
332 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL] = gain_l;
333 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR] = gain_r;
334}
335
336static void hp_store_gain(struct mt6358_priv *priv)
337{
338 unsigned int reg;
339 unsigned int gain_l, gain_r;
340
341 regmap_read(priv->regmap, MT6358_ZCD_CON2, &reg);
342 gain_l = (reg >> RG_AUDHPLGAIN_SFT) & RG_AUDHPLGAIN_MASK;
343 gain_r = (reg >> RG_AUDHPRGAIN_SFT) & RG_AUDHPRGAIN_MASK;
344
345 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL] = gain_l;
346 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR] = gain_r;
347}
348
349static void hp_zcd_disable(struct mt6358_priv *priv) 323static void hp_zcd_disable(struct mt6358_priv *priv)
350{ 324{
351 regmap_write(priv->regmap, MT6358_ZCD_CON0, 0x0000); 325 regmap_write(priv->regmap, MT6358_ZCD_CON0, 0x0000);
@@ -405,10 +379,9 @@ static bool is_valid_hp_pga_idx(int reg_idx)
405 reg_idx == DL_GAIN_N_40DB; 379 reg_idx == DL_GAIN_N_40DB;
406} 380}
407 381
408static void headset_volume_ramp(struct mt6358_priv *priv, 382static void headset_volume_ramp(struct mt6358_priv *priv, int from, int to)
409 int from, int to)
410{ 383{
411 int offset = 0, count = 1, reg_idx; 384 int offset = 0, count = 0, reg_idx;
412 385
413 if (!is_valid_hp_pga_idx(from) || !is_valid_hp_pga_idx(to)) 386 if (!is_valid_hp_pga_idx(from) || !is_valid_hp_pga_idx(to))
414 dev_warn(priv->dev, "%s(), volume index is not valid, from %d, to %d\n", 387 dev_warn(priv->dev, "%s(), volume index is not valid, from %d, to %d\n",
@@ -422,7 +395,7 @@ static void headset_volume_ramp(struct mt6358_priv *priv,
422 else 395 else
423 offset = from - to; 396 offset = from - to;
424 397
425 while (offset > 0) { 398 while (offset >= 0) {
426 if (to > from) 399 if (to > from)
427 reg_idx = from + count; 400 reg_idx = from + count;
428 else 401 else
@@ -440,25 +413,76 @@ static void headset_volume_ramp(struct mt6358_priv *priv,
440 } 413 }
441} 414}
442 415
416static int mt6358_put_volsw(struct snd_kcontrol *kcontrol,
417 struct snd_ctl_elem_value *ucontrol)
418{
419 struct snd_soc_component *component =
420 snd_soc_kcontrol_component(kcontrol);
421 struct mt6358_priv *priv = snd_soc_component_get_drvdata(component);
422 struct soc_mixer_control *mc =
423 (struct soc_mixer_control *)kcontrol->private_value;
424 unsigned int reg;
425 int ret;
426
427 ret = snd_soc_put_volsw(kcontrol, ucontrol);
428 if (ret < 0)
429 return ret;
430
431 switch (mc->reg) {
432 case MT6358_ZCD_CON2:
433 regmap_read(priv->regmap, MT6358_ZCD_CON2, &reg);
434 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL] =
435 (reg >> RG_AUDHPLGAIN_SFT) & RG_AUDHPLGAIN_MASK;
436 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR] =
437 (reg >> RG_AUDHPRGAIN_SFT) & RG_AUDHPRGAIN_MASK;
438 break;
439 case MT6358_ZCD_CON1:
440 regmap_read(priv->regmap, MT6358_ZCD_CON1, &reg);
441 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL] =
442 (reg >> RG_AUDLOLGAIN_SFT) & RG_AUDLOLGAIN_MASK;
443 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR] =
444 (reg >> RG_AUDLORGAIN_SFT) & RG_AUDLORGAIN_MASK;
445 break;
446 case MT6358_ZCD_CON3:
447 regmap_read(priv->regmap, MT6358_ZCD_CON3, &reg);
448 priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL] =
449 (reg >> RG_AUDHSGAIN_SFT) & RG_AUDHSGAIN_MASK;
450 priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTR] =
451 (reg >> RG_AUDHSGAIN_SFT) & RG_AUDHSGAIN_MASK;
452 break;
453 case MT6358_AUDENC_ANA_CON0:
454 case MT6358_AUDENC_ANA_CON1:
455 regmap_read(priv->regmap, MT6358_AUDENC_ANA_CON0, &reg);
456 priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1] =
457 (reg >> RG_AUDPREAMPLGAIN_SFT) & RG_AUDPREAMPLGAIN_MASK;
458 regmap_read(priv->regmap, MT6358_AUDENC_ANA_CON1, &reg);
459 priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2] =
460 (reg >> RG_AUDPREAMPRGAIN_SFT) & RG_AUDPREAMPRGAIN_MASK;
461 break;
462 }
463
464 return ret;
465}
466
443static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0); 467static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0);
444static const DECLARE_TLV_DB_SCALE(pga_tlv, 0, 600, 0); 468static const DECLARE_TLV_DB_SCALE(pga_tlv, 0, 600, 0);
445 469
446static const struct snd_kcontrol_new mt6358_snd_controls[] = { 470static const struct snd_kcontrol_new mt6358_snd_controls[] = {
447 /* dl pga gain */ 471 /* dl pga gain */
448 SOC_DOUBLE_TLV("Headphone Volume", 472 SOC_DOUBLE_EXT_TLV("Headphone Volume",
449 MT6358_ZCD_CON2, 0, 7, 0x12, 1, 473 MT6358_ZCD_CON2, 0, 7, 0x12, 1,
450 playback_tlv), 474 snd_soc_get_volsw, mt6358_put_volsw, playback_tlv),
451 SOC_DOUBLE_TLV("Lineout Volume", 475 SOC_DOUBLE_EXT_TLV("Lineout Volume",
452 MT6358_ZCD_CON1, 0, 7, 0x12, 1, 476 MT6358_ZCD_CON1, 0, 7, 0x12, 1,
453 playback_tlv), 477 snd_soc_get_volsw, mt6358_put_volsw, playback_tlv),
454 SOC_SINGLE_TLV("Handset Volume", 478 SOC_SINGLE_EXT_TLV("Handset Volume",
455 MT6358_ZCD_CON3, 0, 0x12, 1, 479 MT6358_ZCD_CON3, 0, 0x12, 1,
456 playback_tlv), 480 snd_soc_get_volsw, mt6358_put_volsw, playback_tlv),
457 /* ul pga gain */ 481 /* ul pga gain */
458 SOC_DOUBLE_R_TLV("PGA Volume", 482 SOC_DOUBLE_R_EXT_TLV("PGA Volume",
459 MT6358_AUDENC_ANA_CON0, MT6358_AUDENC_ANA_CON1, 483 MT6358_AUDENC_ANA_CON0, MT6358_AUDENC_ANA_CON1,
460 8, 4, 0, 484 8, 4, 0,
461 pga_tlv), 485 snd_soc_get_volsw, mt6358_put_volsw, pga_tlv),
462}; 486};
463 487
464/* MUX */ 488/* MUX */
@@ -832,8 +856,6 @@ static int mtk_hp_enable(struct mt6358_priv *priv)
832 /* Reduce ESD resistance of AU_REFN */ 856 /* Reduce ESD resistance of AU_REFN */
833 regmap_write(priv->regmap, MT6358_AUDDEC_ANA_CON2, 0x4000); 857 regmap_write(priv->regmap, MT6358_AUDDEC_ANA_CON2, 0x4000);
834 858
835 /* save target gain to restore after hardware open complete */
836 hp_store_gain(priv);
837 /* Set HPR/HPL gain as minimum (~ -40dB) */ 859 /* Set HPR/HPL gain as minimum (~ -40dB) */
838 regmap_write(priv->regmap, MT6358_ZCD_CON2, DL_GAIN_N_40DB_REG); 860 regmap_write(priv->regmap, MT6358_ZCD_CON2, DL_GAIN_N_40DB_REG);
839 861
@@ -1043,8 +1065,6 @@ static int mtk_hp_spk_enable(struct mt6358_priv *priv)
1043 /* Reduce ESD resistance of AU_REFN */ 1065 /* Reduce ESD resistance of AU_REFN */
1044 regmap_write(priv->regmap, MT6358_AUDDEC_ANA_CON2, 0x4000); 1066 regmap_write(priv->regmap, MT6358_AUDDEC_ANA_CON2, 0x4000);
1045 1067
1046 /* save target gain to restore after hardware open complete */
1047 hp_store_gain(priv);
1048 /* Set HPR/HPL gain to -10dB */ 1068 /* Set HPR/HPL gain to -10dB */
1049 regmap_write(priv->regmap, MT6358_ZCD_CON2, DL_GAIN_N_10DB_REG); 1069 regmap_write(priv->regmap, MT6358_ZCD_CON2, DL_GAIN_N_10DB_REG);
1050 1070
@@ -1104,7 +1124,6 @@ static int mtk_hp_spk_enable(struct mt6358_priv *priv)
1104 hp_main_output_ramp(priv, true); 1124 hp_main_output_ramp(priv, true);
1105 1125
1106 /* Set LO gain as minimum (~ -40dB) */ 1126 /* Set LO gain as minimum (~ -40dB) */
1107 lo_store_gain(priv);
1108 regmap_write(priv->regmap, MT6358_ZCD_CON1, DL_GAIN_N_40DB_REG); 1127 regmap_write(priv->regmap, MT6358_ZCD_CON1, DL_GAIN_N_40DB_REG);
1109 /* apply volume setting */ 1128 /* apply volume setting */
1110 headset_volume_ramp(priv, 1129 headset_volume_ramp(priv,
@@ -1740,6 +1759,21 @@ static void mt6358_dmic_disable(struct mt6358_priv *priv)
1740 regmap_write(priv->regmap, MT6358_AUDENC_ANA_CON9, 0x0000); 1759 regmap_write(priv->regmap, MT6358_AUDENC_ANA_CON9, 0x0000);
1741} 1760}
1742 1761
1762static void mt6358_restore_pga(struct mt6358_priv *priv)
1763{
1764 unsigned int gain_l, gain_r;
1765
1766 gain_l = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1];
1767 gain_r = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2];
1768
1769 regmap_update_bits(priv->regmap, MT6358_AUDENC_ANA_CON0,
1770 RG_AUDPREAMPLGAIN_MASK_SFT,
1771 gain_l << RG_AUDPREAMPLGAIN_SFT);
1772 regmap_update_bits(priv->regmap, MT6358_AUDENC_ANA_CON1,
1773 RG_AUDPREAMPRGAIN_MASK_SFT,
1774 gain_r << RG_AUDPREAMPRGAIN_SFT);
1775}
1776
1743static int mt_mic_type_event(struct snd_soc_dapm_widget *w, 1777static int mt_mic_type_event(struct snd_soc_dapm_widget *w,
1744 struct snd_kcontrol *kcontrol, 1778 struct snd_kcontrol *kcontrol,
1745 int event) 1779 int event)
@@ -1764,6 +1798,7 @@ static int mt_mic_type_event(struct snd_soc_dapm_widget *w,
1764 mt6358_amic_enable(priv); 1798 mt6358_amic_enable(priv);
1765 break; 1799 break;
1766 } 1800 }
1801 mt6358_restore_pga(priv);
1767 1802
1768 break; 1803 break;
1769 case SND_SOC_DAPM_POST_PMD: 1804 case SND_SOC_DAPM_POST_PMD:
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index 5ddbfa8f1a28..32105e0fabe8 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -259,8 +259,10 @@ int snd_sof_create_page_table(struct snd_sof_dev *sdev,
259static int sof_machine_check(struct snd_sof_dev *sdev) 259static int sof_machine_check(struct snd_sof_dev *sdev)
260{ 260{
261 struct snd_sof_pdata *plat_data = sdev->pdata; 261 struct snd_sof_pdata *plat_data = sdev->pdata;
262#if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)
262 struct snd_soc_acpi_mach *machine; 263 struct snd_soc_acpi_mach *machine;
263 int ret; 264 int ret;
265#endif
264 266
265 if (plat_data->machine) 267 if (plat_data->machine)
266 return 0; 268 return 0;
diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 97d5e9901a0e..8ee697ff1f86 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -731,7 +731,8 @@ static const struct snd_soc_dai_ops stm32_i2s_pcm_dai_ops = {
731static const struct snd_pcm_hardware stm32_i2s_pcm_hw = { 731static const struct snd_pcm_hardware stm32_i2s_pcm_hw = {
732 .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP, 732 .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP,
733 .buffer_bytes_max = 8 * PAGE_SIZE, 733 .buffer_bytes_max = 8 * PAGE_SIZE,
734 .period_bytes_max = 2048, 734 .period_bytes_min = 1024,
735 .period_bytes_max = 4 * PAGE_SIZE,
735 .periods_min = 2, 736 .periods_min = 2,
736 .periods_max = 8, 737 .periods_max = 8,
737}; 738};