Lines Matching +full:spk +full:- +full:mute

1 // SPDX-License-Identifier: GPL-2.0-only
3 * max98088.c -- MAX98088 ALSA SoC Audio driver
90 { 0x2b, 0x00 }, /* 2B left SPK mixer */
91 { 0x2c, 0x00 }, /* 2C right SPK mixer */
92 { 0x2d, 0x00 }, /* 2D SPK control */
109 { 0x3d, 0x00 }, /* 3D left SPK volume */
110 { 0x3e, 0x00 }, /* 3E right SPK volume */
337 "Off", "100Hz", "400Hz", "600Hz", "800Hz", "1000Hz", "200-400Hz",
338 "400-600Hz", "400-800Hz",
385 unsigned int sel = ucontrol->value.integer.value[0]; in max98088_mic1pre_set()
387 max98088->mic1pre = sel; in max98088_mic1pre_set()
400 ucontrol->value.integer.value[0] = max98088->mic1pre; in max98088_mic1pre_get()
409 unsigned int sel = ucontrol->value.integer.value[0]; in max98088_mic2pre_set()
411 max98088->mic2pre = sel; in max98088_mic2pre_set()
424 ucontrol->value.integer.value[0] = max98088->mic2pre; in max98088_mic2pre_get()
434 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
435 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
436 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
437 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
442 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
443 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
444 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
623 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98088_mic_event()
628 if (w->reg == M98088_REG_35_LVL_MIC1) { in max98088_mic_event()
629 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, in max98088_mic_event()
630 (1+max98088->mic1pre)<<M98088_MICPRE_SHIFT); in max98088_mic_event()
632 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, in max98088_mic_event()
633 (1+max98088->mic2pre)<<M98088_MICPRE_SHIFT); in max98088_mic_event()
637 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, 0); in max98088_mic_event()
640 return -EINVAL; in max98088_mic_event()
647 * The line inputs are 2-channel stereo inputs with the left
653 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98088_line_pga()
658 return -EINVAL; in max98088_line_pga()
662 state = &max98088->ina_state; in max98088_line_pga()
665 state = &max98088->inb_state; in max98088_line_pga()
668 return -EINVAL; in max98088_line_pga()
674 snd_soc_component_update_bits(component, w->reg, in max98088_line_pga()
675 (1 << w->shift), (1 << w->shift)); in max98088_line_pga()
680 snd_soc_component_update_bits(component, w->reg, in max98088_line_pga()
681 (1 << w->shift), 0); in max98088_line_pga()
685 return -EINVAL; in max98088_line_pga()
734 SND_SOC_DAPM_PGA("SPK Left Out", M98088_REG_4D_PWR_EN_OUT,
736 SND_SOC_DAPM_PGA("SPK Right Out", M98088_REG_4D_PWR_EN_OUT,
755 SND_SOC_DAPM_MIXER("Left SPK Mixer", SND_SOC_NOPM, 0, 0,
759 SND_SOC_DAPM_MIXER("Right SPK Mixer", SND_SOC_NOPM, 0, 0,
846 {"Left SPK Mixer", "Left DAC1 Switch", "DACL1"},
847 {"Left SPK Mixer", "Left DAC2 Switch", "DACL2"},
848 {"Left SPK Mixer", "Right DAC1 Switch", "DACR1"},
849 {"Left SPK Mixer", "Right DAC2 Switch", "DACR2"},
850 {"Left SPK Mixer", "MIC1 Switch", "MIC1 Input"},
851 {"Left SPK Mixer", "MIC2 Switch", "MIC2 Input"},
852 {"Left SPK Mixer", "INA1 Switch", "INA1 Input"},
853 {"Left SPK Mixer", "INA2 Switch", "INA2 Input"},
854 {"Left SPK Mixer", "INB1 Switch", "INB1 Input"},
855 {"Left SPK Mixer", "INB2 Switch", "INB2 Input"},
858 {"Right SPK Mixer", "Left DAC1 Switch", "DACL1"},
859 {"Right SPK Mixer", "Left DAC2 Switch", "DACL2"},
860 {"Right SPK Mixer", "Right DAC1 Switch", "DACR1"},
861 {"Right SPK Mixer", "Right DAC2 Switch", "DACR2"},
862 {"Right SPK Mixer", "MIC1 Switch", "MIC1 Input"},
863 {"Right SPK Mixer", "MIC2 Switch", "MIC2 Input"},
864 {"Right SPK Mixer", "INA1 Switch", "INA1 Input"},
865 {"Right SPK Mixer", "INA2 Switch", "INA2 Input"},
866 {"Right SPK Mixer", "INB1 Switch", "INB1 Input"},
867 {"Right SPK Mixer", "INB2 Switch", "INB2 Input"},
895 {"SPK Left Out", NULL, "Left SPK Mixer"},
896 {"SPK Right Out", NULL, "Right SPK Mixer"},
902 {"SPKL", NULL, "SPK Left Out"},
903 {"SPKR", NULL, "SPK Right Out"},
962 return -EINVAL; in rate_value()
969 struct snd_soc_component *component = dai->component; in max98088_dai1_hw_params()
976 cdata = &max98088->dai[0]; in max98088_dai1_hw_params()
990 return -EINVAL; in max98088_dai1_hw_params()
996 return -EINVAL; in max98088_dai1_hw_params()
1000 cdata->rate = rate; in max98088_dai1_hw_params()
1007 if (max98088->sysclk == 0) { in max98088_dai1_hw_params()
1008 dev_err(component->dev, "Invalid system clock frequency\n"); in max98088_dai1_hw_params()
1009 return -EINVAL; in max98088_dai1_hw_params()
1013 pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); in max98088_dai1_hw_params()
1039 struct snd_soc_component *component = dai->component; in max98088_dai2_hw_params()
1046 cdata = &max98088->dai[1]; in max98088_dai2_hw_params()
1060 return -EINVAL; in max98088_dai2_hw_params()
1066 return -EINVAL; in max98088_dai2_hw_params()
1070 cdata->rate = rate; in max98088_dai2_hw_params()
1077 if (max98088->sysclk == 0) { in max98088_dai2_hw_params()
1078 dev_err(component->dev, "Invalid system clock frequency\n"); in max98088_dai2_hw_params()
1079 return -EINVAL; in max98088_dai2_hw_params()
1083 pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); in max98088_dai2_hw_params()
1108 struct snd_soc_component *component = dai->component; in max98088_dai_set_sysclk()
1112 if (freq == max98088->sysclk) in max98088_dai_set_sysclk()
1115 if (!IS_ERR(max98088->mclk)) { in max98088_dai_set_sysclk()
1116 freq = clk_round_rate(max98088->mclk, freq); in max98088_dai_set_sysclk()
1117 clk_set_rate(max98088->mclk, freq); in max98088_dai_set_sysclk()
1126 max98088->mclk_prescaler = 1; in max98088_dai_set_sysclk()
1129 max98088->mclk_prescaler = 2; in max98088_dai_set_sysclk()
1131 dev_err(component->dev, "Invalid master clock frequency\n"); in max98088_dai_set_sysclk()
1132 return -EINVAL; in max98088_dai_set_sysclk()
1142 dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); in max98088_dai_set_sysclk()
1144 max98088->sysclk = freq; in max98088_dai_set_sysclk()
1151 struct snd_soc_component *component = codec_dai->component; in max98088_dai1_set_fmt()
1157 cdata = &max98088->dai[0]; in max98088_dai1_set_fmt()
1159 if (fmt != cdata->fmt) { in max98088_dai1_set_fmt()
1160 cdata->fmt = fmt; in max98088_dai1_set_fmt()
1175 dev_err(component->dev, "Clock mode unsupported"); in max98088_dai1_set_fmt()
1176 return -EINVAL; in max98088_dai1_set_fmt()
1186 return -EINVAL; in max98088_dai1_set_fmt()
1202 return -EINVAL; in max98088_dai1_set_fmt()
1210 if (max98088->digmic) in max98088_dai1_set_fmt()
1221 struct snd_soc_component *component = codec_dai->component; in max98088_dai2_set_fmt()
1226 cdata = &max98088->dai[1]; in max98088_dai2_set_fmt()
1228 if (fmt != cdata->fmt) { in max98088_dai2_set_fmt()
1229 cdata->fmt = fmt; in max98088_dai2_set_fmt()
1244 dev_err(component->dev, "Clock mode unsupported"); in max98088_dai2_set_fmt()
1245 return -EINVAL; in max98088_dai2_set_fmt()
1255 return -EINVAL; in max98088_dai2_set_fmt()
1271 return -EINVAL; in max98088_dai2_set_fmt()
1285 static int max98088_dai1_mute(struct snd_soc_dai *codec_dai, int mute, in max98088_dai1_mute() argument
1288 struct snd_soc_component *component = codec_dai->component; in max98088_dai1_mute()
1291 if (mute) in max98088_dai1_mute()
1301 static int max98088_dai2_mute(struct snd_soc_dai *codec_dai, int mute, in max98088_dai2_mute() argument
1304 struct snd_soc_component *component = codec_dai->component; in max98088_dai2_mute()
1307 if (mute) in max98088_dai2_mute()
1335 if (!IS_ERR(max98088->mclk)) { in max98088_set_bias_level()
1338 clk_disable_unprepare(max98088->mclk); in max98088_set_bias_level()
1340 ret = clk_prepare_enable(max98088->mclk); in max98088_set_bias_level()
1349 regcache_sync(max98088->regmap); in max98088_set_bias_level()
1358 regcache_mark_dirty(max98088->regmap); in max98088_set_bias_level()
1423 dev_err(component->dev, "Bad EQ channel name '%s'\n", name); in max98088_get_channel()
1430 struct max98088_pdata *pdata = max98088->pdata; in max98088_setup_eq1()
1435 cdata = &max98088->dai[0]; in max98088_setup_eq1()
1437 if (!pdata || !max98088->eq_textcnt) in max98088_setup_eq1()
1441 fs = cdata->rate; in max98088_setup_eq1()
1442 sel = cdata->eq_sel; in max98088_setup_eq1()
1446 for (i = 0; i < pdata->eq_cfgcnt; i++) { in max98088_setup_eq1()
1447 if (strcmp(pdata->eq_cfg[i].name, max98088->eq_texts[sel]) == 0 && in max98088_setup_eq1()
1448 abs(pdata->eq_cfg[i].rate - fs) < best_val) { in max98088_setup_eq1()
1450 best_val = abs(pdata->eq_cfg[i].rate - fs); in max98088_setup_eq1()
1454 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98088_setup_eq1()
1455 pdata->eq_cfg[best].name, in max98088_setup_eq1()
1456 pdata->eq_cfg[best].rate, fs); in max98088_setup_eq1()
1462 coef_set = &pdata->eq_cfg[sel]; in max98088_setup_eq1()
1464 m98088_eq_band(component, 0, 0, coef_set->band1); in max98088_setup_eq1()
1465 m98088_eq_band(component, 0, 1, coef_set->band2); in max98088_setup_eq1()
1466 m98088_eq_band(component, 0, 2, coef_set->band3); in max98088_setup_eq1()
1467 m98088_eq_band(component, 0, 3, coef_set->band4); in max98088_setup_eq1()
1468 m98088_eq_band(component, 0, 4, coef_set->band5); in max98088_setup_eq1()
1477 struct max98088_pdata *pdata = max98088->pdata; in max98088_setup_eq2()
1482 cdata = &max98088->dai[1]; in max98088_setup_eq2()
1484 if (!pdata || !max98088->eq_textcnt) in max98088_setup_eq2()
1488 fs = cdata->rate; in max98088_setup_eq2()
1490 sel = cdata->eq_sel; in max98088_setup_eq2()
1493 for (i = 0; i < pdata->eq_cfgcnt; i++) { in max98088_setup_eq2()
1494 if (strcmp(pdata->eq_cfg[i].name, max98088->eq_texts[sel]) == 0 && in max98088_setup_eq2()
1495 abs(pdata->eq_cfg[i].rate - fs) < best_val) { in max98088_setup_eq2()
1497 best_val = abs(pdata->eq_cfg[i].rate - fs); in max98088_setup_eq2()
1501 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98088_setup_eq2()
1502 pdata->eq_cfg[best].name, in max98088_setup_eq2()
1503 pdata->eq_cfg[best].rate, fs); in max98088_setup_eq2()
1509 coef_set = &pdata->eq_cfg[sel]; in max98088_setup_eq2()
1511 m98088_eq_band(component, 1, 0, coef_set->band1); in max98088_setup_eq2()
1512 m98088_eq_band(component, 1, 1, coef_set->band2); in max98088_setup_eq2()
1513 m98088_eq_band(component, 1, 2, coef_set->band3); in max98088_setup_eq2()
1514 m98088_eq_band(component, 1, 3, coef_set->band4); in max98088_setup_eq2()
1515 m98088_eq_band(component, 1, 4, coef_set->band5); in max98088_setup_eq2()
1527 struct max98088_pdata *pdata = max98088->pdata; in max98088_put_eq_enum()
1528 int channel = max98088_get_channel(component, kcontrol->id.name); in max98088_put_eq_enum()
1530 int sel = ucontrol->value.enumerated.item[0]; in max98088_put_eq_enum()
1535 cdata = &max98088->dai[channel]; in max98088_put_eq_enum()
1537 if (sel >= pdata->eq_cfgcnt) in max98088_put_eq_enum()
1538 return -EINVAL; in max98088_put_eq_enum()
1540 cdata->eq_sel = sel; in max98088_put_eq_enum()
1559 int channel = max98088_get_channel(component, kcontrol->id.name); in max98088_get_eq_enum()
1565 cdata = &max98088->dai[channel]; in max98088_get_eq_enum()
1566 ucontrol->value.enumerated.item[0] = cdata->eq_sel; in max98088_get_eq_enum()
1573 struct max98088_pdata *pdata = max98088->pdata; in max98088_handle_eq_pdata()
1581 max98088->eq_enum, in max98088_handle_eq_pdata()
1585 max98088->eq_enum, in max98088_handle_eq_pdata()
1591 cfg = pdata->eq_cfg; in max98088_handle_eq_pdata()
1592 cfgcnt = pdata->eq_cfgcnt; in max98088_handle_eq_pdata()
1597 max98088->eq_textcnt = 0; in max98088_handle_eq_pdata()
1598 max98088->eq_texts = NULL; in max98088_handle_eq_pdata()
1600 for (j = 0; j < max98088->eq_textcnt; j++) { in max98088_handle_eq_pdata()
1601 if (strcmp(cfg[i].name, max98088->eq_texts[j]) == 0) in max98088_handle_eq_pdata()
1605 if (j != max98088->eq_textcnt) in max98088_handle_eq_pdata()
1609 t = krealloc(max98088->eq_texts, in max98088_handle_eq_pdata()
1610 sizeof(char *) * (max98088->eq_textcnt + 1), in max98088_handle_eq_pdata()
1616 t[max98088->eq_textcnt] = cfg[i].name; in max98088_handle_eq_pdata()
1617 max98088->eq_textcnt++; in max98088_handle_eq_pdata()
1618 max98088->eq_texts = t; in max98088_handle_eq_pdata()
1622 max98088->eq_enum.texts = max98088->eq_texts; in max98088_handle_eq_pdata()
1623 max98088->eq_enum.items = max98088->eq_textcnt; in max98088_handle_eq_pdata()
1627 dev_err(component->dev, "Failed to add EQ control: %d\n", ret); in max98088_handle_eq_pdata()
1633 struct max98088_pdata *pdata = max98088->pdata; in max98088_handle_pdata()
1637 dev_dbg(component->dev, "No platform data\n"); in max98088_handle_pdata()
1642 if (pdata->digmic_left_mode) in max98088_handle_pdata()
1645 if (pdata->digmic_right_mode) in max98088_handle_pdata()
1648 max98088->digmic = (regval ? 1 : 0); in max98088_handle_pdata()
1653 regval = ((pdata->receiver_mode) ? M98088_REC_LINEMODE : 0); in max98088_handle_pdata()
1658 if (pdata->eq_cfgcnt) in max98088_handle_pdata()
1668 regcache_mark_dirty(max98088->regmap); in max98088_probe()
1672 max98088->sysclk = (unsigned)-1; in max98088_probe()
1673 max98088->eq_textcnt = 0; in max98088_probe()
1675 cdata = &max98088->dai[0]; in max98088_probe()
1676 cdata->rate = (unsigned)-1; in max98088_probe()
1677 cdata->fmt = (unsigned)-1; in max98088_probe()
1678 cdata->eq_sel = 0; in max98088_probe()
1680 cdata = &max98088->dai[1]; in max98088_probe()
1681 cdata->rate = (unsigned)-1; in max98088_probe()
1682 cdata->fmt = (unsigned)-1; in max98088_probe()
1683 cdata->eq_sel = 0; in max98088_probe()
1685 max98088->ina_state = 0; in max98088_probe()
1686 max98088->inb_state = 0; in max98088_probe()
1687 max98088->ex_mode = 0; in max98088_probe()
1688 max98088->digmic = 0; in max98088_probe()
1689 max98088->mic1pre = 0; in max98088_probe()
1690 max98088->mic2pre = 0; in max98088_probe()
1694 dev_err(component->dev, "Failed to read device revision: %d\n", in max98088_probe()
1698 dev_info(component->dev, "revision %c\n", ret - 0x40 + 'A'); in max98088_probe()
1727 kfree(max98088->eq_texts); in max98088_remove()
1758 max98088 = devm_kzalloc(&i2c->dev, sizeof(struct max98088_priv), in max98088_i2c_probe()
1761 return -ENOMEM; in max98088_i2c_probe()
1763 max98088->regmap = devm_regmap_init_i2c(i2c, &max98088_regmap); in max98088_i2c_probe()
1764 if (IS_ERR(max98088->regmap)) in max98088_i2c_probe()
1765 return PTR_ERR(max98088->regmap); in max98088_i2c_probe()
1767 max98088->mclk = devm_clk_get(&i2c->dev, "mclk"); in max98088_i2c_probe()
1768 if (IS_ERR(max98088->mclk)) in max98088_i2c_probe()
1769 if (PTR_ERR(max98088->mclk) == -EPROBE_DEFER) in max98088_i2c_probe()
1770 return PTR_ERR(max98088->mclk); in max98088_i2c_probe()
1773 max98088->devtype = id->driver_data; in max98088_i2c_probe()
1776 max98088->pdata = i2c->dev.platform_data; in max98088_i2c_probe()
1778 return devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_max98088, in max98088_i2c_probe()