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),
617 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98088_mic_event()
622 if (w->reg == M98088_REG_35_LVL_MIC1) { in max98088_mic_event()
623 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, in max98088_mic_event()
624 (1+max98088->mic1pre)<<M98088_MICPRE_SHIFT); in max98088_mic_event()
626 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, in max98088_mic_event()
627 (1+max98088->mic2pre)<<M98088_MICPRE_SHIFT); in max98088_mic_event()
631 snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, 0); in max98088_mic_event()
634 return -EINVAL; in max98088_mic_event()
641 * The line inputs are 2-channel stereo inputs with the left
647 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98088_line_pga()
652 return -EINVAL; in max98088_line_pga()
656 state = &max98088->ina_state; in max98088_line_pga()
659 state = &max98088->inb_state; in max98088_line_pga()
662 return -EINVAL; in max98088_line_pga()
668 snd_soc_component_update_bits(component, w->reg, in max98088_line_pga()
669 (1 << w->shift), (1 << w->shift)); in max98088_line_pga()
674 snd_soc_component_update_bits(component, w->reg, in max98088_line_pga()
675 (1 << w->shift), 0); in max98088_line_pga()
679 return -EINVAL; in max98088_line_pga()
724 SND_SOC_DAPM_PGA("SPK Left Out", M98088_REG_4D_PWR_EN_OUT,
726 SND_SOC_DAPM_PGA("SPK Right Out", M98088_REG_4D_PWR_EN_OUT,
745 SND_SOC_DAPM_MIXER("Left SPK Mixer", SND_SOC_NOPM, 0, 0,
749 SND_SOC_DAPM_MIXER("Right SPK Mixer", SND_SOC_NOPM, 0, 0,
832 {"Left SPK Mixer", "Left DAC Switch", "DACL"},
833 {"Left SPK Mixer", "Right DAC Switch", "DACR"},
834 {"Left SPK Mixer", "MIC1 Switch", "MIC1 Input"},
835 {"Left SPK Mixer", "MIC2 Switch", "MIC2 Input"},
836 {"Left SPK Mixer", "INA1 Switch", "INA1 Input"},
837 {"Left SPK Mixer", "INA2 Switch", "INA2 Input"},
838 {"Left SPK Mixer", "INB1 Switch", "INB1 Input"},
839 {"Left SPK Mixer", "INB2 Switch", "INB2 Input"},
842 {"Right SPK Mixer", "Left DAC Switch", "DACL"},
843 {"Right SPK Mixer", "Right DAC Switch", "DACR"},
844 {"Right SPK Mixer", "MIC1 Switch", "MIC1 Input"},
845 {"Right SPK Mixer", "MIC2 Switch", "MIC2 Input"},
846 {"Right SPK Mixer", "INA1 Switch", "INA1 Input"},
847 {"Right SPK Mixer", "INA2 Switch", "INA2 Input"},
848 {"Right SPK Mixer", "INB1 Switch", "INB1 Input"},
849 {"Right SPK Mixer", "INB2 Switch", "INB2 Input"},
873 {"SPK Left Out", NULL, "Left SPK Mixer"},
874 {"SPK Right Out", NULL, "Right SPK Mixer"},
880 {"SPKL", NULL, "SPK Left Out"},
881 {"SPKR", NULL, "SPK Right Out"},
940 return -EINVAL; in rate_value()
947 struct snd_soc_component *component = dai->component; in max98088_dai1_hw_params()
954 cdata = &max98088->dai[0]; in max98088_dai1_hw_params()
968 return -EINVAL; in max98088_dai1_hw_params()
974 return -EINVAL; in max98088_dai1_hw_params()
978 cdata->rate = rate; in max98088_dai1_hw_params()
985 if (max98088->sysclk == 0) { in max98088_dai1_hw_params()
986 dev_err(component->dev, "Invalid system clock frequency\n"); in max98088_dai1_hw_params()
987 return -EINVAL; in max98088_dai1_hw_params()
991 pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); in max98088_dai1_hw_params()
1017 struct snd_soc_component *component = dai->component; in max98088_dai2_hw_params()
1024 cdata = &max98088->dai[1]; in max98088_dai2_hw_params()
1038 return -EINVAL; in max98088_dai2_hw_params()
1044 return -EINVAL; in max98088_dai2_hw_params()
1048 cdata->rate = rate; in max98088_dai2_hw_params()
1055 if (max98088->sysclk == 0) { in max98088_dai2_hw_params()
1056 dev_err(component->dev, "Invalid system clock frequency\n"); in max98088_dai2_hw_params()
1057 return -EINVAL; in max98088_dai2_hw_params()
1061 pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); in max98088_dai2_hw_params()
1086 struct snd_soc_component *component = dai->component; in max98088_dai_set_sysclk()
1090 if (freq == max98088->sysclk) in max98088_dai_set_sysclk()
1093 if (!IS_ERR(max98088->mclk)) { in max98088_dai_set_sysclk()
1094 freq = clk_round_rate(max98088->mclk, freq); in max98088_dai_set_sysclk()
1095 clk_set_rate(max98088->mclk, freq); in max98088_dai_set_sysclk()
1104 max98088->mclk_prescaler = 1; in max98088_dai_set_sysclk()
1107 max98088->mclk_prescaler = 2; in max98088_dai_set_sysclk()
1109 dev_err(component->dev, "Invalid master clock frequency\n"); in max98088_dai_set_sysclk()
1110 return -EINVAL; in max98088_dai_set_sysclk()
1120 dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); in max98088_dai_set_sysclk()
1122 max98088->sysclk = freq; in max98088_dai_set_sysclk()
1129 struct snd_soc_component *component = codec_dai->component; in max98088_dai1_set_fmt()
1135 cdata = &max98088->dai[0]; in max98088_dai1_set_fmt()
1137 if (fmt != cdata->fmt) { in max98088_dai1_set_fmt()
1138 cdata->fmt = fmt; in max98088_dai1_set_fmt()
1153 dev_err(component->dev, "Clock mode unsupported"); in max98088_dai1_set_fmt()
1154 return -EINVAL; in max98088_dai1_set_fmt()
1164 return -EINVAL; in max98088_dai1_set_fmt()
1180 return -EINVAL; in max98088_dai1_set_fmt()
1188 if (max98088->digmic) in max98088_dai1_set_fmt()
1199 struct snd_soc_component *component = codec_dai->component; in max98088_dai2_set_fmt()
1204 cdata = &max98088->dai[1]; in max98088_dai2_set_fmt()
1206 if (fmt != cdata->fmt) { in max98088_dai2_set_fmt()
1207 cdata->fmt = fmt; in max98088_dai2_set_fmt()
1222 dev_err(component->dev, "Clock mode unsupported"); in max98088_dai2_set_fmt()
1223 return -EINVAL; in max98088_dai2_set_fmt()
1233 return -EINVAL; in max98088_dai2_set_fmt()
1249 return -EINVAL; in max98088_dai2_set_fmt()
1263 static int max98088_dai1_mute(struct snd_soc_dai *codec_dai, int mute, in max98088_dai1_mute() argument
1266 struct snd_soc_component *component = codec_dai->component; in max98088_dai1_mute()
1269 if (mute) in max98088_dai1_mute()
1279 static int max98088_dai2_mute(struct snd_soc_dai *codec_dai, int mute, in max98088_dai2_mute() argument
1282 struct snd_soc_component *component = codec_dai->component; in max98088_dai2_mute()
1285 if (mute) in max98088_dai2_mute()
1313 if (!IS_ERR(max98088->mclk)) { in max98088_set_bias_level()
1316 clk_disable_unprepare(max98088->mclk); in max98088_set_bias_level()
1318 ret = clk_prepare_enable(max98088->mclk); in max98088_set_bias_level()
1327 regcache_sync(max98088->regmap); in max98088_set_bias_level()
1336 regcache_mark_dirty(max98088->regmap); in max98088_set_bias_level()
1401 dev_err(component->dev, "Bad EQ channel name '%s'\n", name); in max98088_get_channel()
1408 struct max98088_pdata *pdata = max98088->pdata; in max98088_setup_eq1()
1413 cdata = &max98088->dai[0]; in max98088_setup_eq1()
1415 if (!pdata || !max98088->eq_textcnt) in max98088_setup_eq1()
1419 fs = cdata->rate; in max98088_setup_eq1()
1420 sel = cdata->eq_sel; in max98088_setup_eq1()
1424 for (i = 0; i < pdata->eq_cfgcnt; i++) { in max98088_setup_eq1()
1425 if (strcmp(pdata->eq_cfg[i].name, max98088->eq_texts[sel]) == 0 && in max98088_setup_eq1()
1426 abs(pdata->eq_cfg[i].rate - fs) < best_val) { in max98088_setup_eq1()
1428 best_val = abs(pdata->eq_cfg[i].rate - fs); in max98088_setup_eq1()
1432 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98088_setup_eq1()
1433 pdata->eq_cfg[best].name, in max98088_setup_eq1()
1434 pdata->eq_cfg[best].rate, fs); in max98088_setup_eq1()
1440 coef_set = &pdata->eq_cfg[sel]; in max98088_setup_eq1()
1442 m98088_eq_band(component, 0, 0, coef_set->band1); in max98088_setup_eq1()
1443 m98088_eq_band(component, 0, 1, coef_set->band2); in max98088_setup_eq1()
1444 m98088_eq_band(component, 0, 2, coef_set->band3); in max98088_setup_eq1()
1445 m98088_eq_band(component, 0, 3, coef_set->band4); in max98088_setup_eq1()
1446 m98088_eq_band(component, 0, 4, coef_set->band5); in max98088_setup_eq1()
1455 struct max98088_pdata *pdata = max98088->pdata; in max98088_setup_eq2()
1460 cdata = &max98088->dai[1]; in max98088_setup_eq2()
1462 if (!pdata || !max98088->eq_textcnt) in max98088_setup_eq2()
1466 fs = cdata->rate; in max98088_setup_eq2()
1468 sel = cdata->eq_sel; in max98088_setup_eq2()
1471 for (i = 0; i < pdata->eq_cfgcnt; i++) { in max98088_setup_eq2()
1472 if (strcmp(pdata->eq_cfg[i].name, max98088->eq_texts[sel]) == 0 && in max98088_setup_eq2()
1473 abs(pdata->eq_cfg[i].rate - fs) < best_val) { in max98088_setup_eq2()
1475 best_val = abs(pdata->eq_cfg[i].rate - fs); in max98088_setup_eq2()
1479 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98088_setup_eq2()
1480 pdata->eq_cfg[best].name, in max98088_setup_eq2()
1481 pdata->eq_cfg[best].rate, fs); in max98088_setup_eq2()
1487 coef_set = &pdata->eq_cfg[sel]; in max98088_setup_eq2()
1489 m98088_eq_band(component, 1, 0, coef_set->band1); in max98088_setup_eq2()
1490 m98088_eq_band(component, 1, 1, coef_set->band2); in max98088_setup_eq2()
1491 m98088_eq_band(component, 1, 2, coef_set->band3); in max98088_setup_eq2()
1492 m98088_eq_band(component, 1, 3, coef_set->band4); in max98088_setup_eq2()
1493 m98088_eq_band(component, 1, 4, coef_set->band5); in max98088_setup_eq2()
1505 struct max98088_pdata *pdata = max98088->pdata; in max98088_put_eq_enum()
1506 int channel = max98088_get_channel(component, kcontrol->id.name); in max98088_put_eq_enum()
1508 int sel = ucontrol->value.enumerated.item[0]; in max98088_put_eq_enum()
1513 cdata = &max98088->dai[channel]; in max98088_put_eq_enum()
1515 if (sel >= pdata->eq_cfgcnt) in max98088_put_eq_enum()
1516 return -EINVAL; in max98088_put_eq_enum()
1518 cdata->eq_sel = sel; in max98088_put_eq_enum()
1537 int channel = max98088_get_channel(component, kcontrol->id.name); in max98088_get_eq_enum()
1543 cdata = &max98088->dai[channel]; in max98088_get_eq_enum()
1544 ucontrol->value.enumerated.item[0] = cdata->eq_sel; in max98088_get_eq_enum()
1551 struct max98088_pdata *pdata = max98088->pdata; in max98088_handle_eq_pdata()
1559 max98088->eq_enum, in max98088_handle_eq_pdata()
1563 max98088->eq_enum, in max98088_handle_eq_pdata()
1569 cfg = pdata->eq_cfg; in max98088_handle_eq_pdata()
1570 cfgcnt = pdata->eq_cfgcnt; in max98088_handle_eq_pdata()
1575 max98088->eq_textcnt = 0; in max98088_handle_eq_pdata()
1576 max98088->eq_texts = NULL; in max98088_handle_eq_pdata()
1578 for (j = 0; j < max98088->eq_textcnt; j++) { in max98088_handle_eq_pdata()
1579 if (strcmp(cfg[i].name, max98088->eq_texts[j]) == 0) in max98088_handle_eq_pdata()
1583 if (j != max98088->eq_textcnt) in max98088_handle_eq_pdata()
1587 t = krealloc(max98088->eq_texts, in max98088_handle_eq_pdata()
1588 sizeof(char *) * (max98088->eq_textcnt + 1), in max98088_handle_eq_pdata()
1594 t[max98088->eq_textcnt] = cfg[i].name; in max98088_handle_eq_pdata()
1595 max98088->eq_textcnt++; in max98088_handle_eq_pdata()
1596 max98088->eq_texts = t; in max98088_handle_eq_pdata()
1600 max98088->eq_enum.texts = max98088->eq_texts; in max98088_handle_eq_pdata()
1601 max98088->eq_enum.items = max98088->eq_textcnt; in max98088_handle_eq_pdata()
1605 dev_err(component->dev, "Failed to add EQ control: %d\n", ret); in max98088_handle_eq_pdata()
1611 struct max98088_pdata *pdata = max98088->pdata; in max98088_handle_pdata()
1615 dev_dbg(component->dev, "No platform data\n"); in max98088_handle_pdata()
1620 if (pdata->digmic_left_mode) in max98088_handle_pdata()
1623 if (pdata->digmic_right_mode) in max98088_handle_pdata()
1626 max98088->digmic = (regval ? 1 : 0); in max98088_handle_pdata()
1631 regval = ((pdata->receiver_mode) ? M98088_REC_LINEMODE : 0); in max98088_handle_pdata()
1636 if (pdata->eq_cfgcnt) in max98088_handle_pdata()
1646 regcache_mark_dirty(max98088->regmap); in max98088_probe()
1650 max98088->sysclk = (unsigned)-1; in max98088_probe()
1651 max98088->eq_textcnt = 0; in max98088_probe()
1653 cdata = &max98088->dai[0]; in max98088_probe()
1654 cdata->rate = (unsigned)-1; in max98088_probe()
1655 cdata->fmt = (unsigned)-1; in max98088_probe()
1656 cdata->eq_sel = 0; in max98088_probe()
1658 cdata = &max98088->dai[1]; in max98088_probe()
1659 cdata->rate = (unsigned)-1; in max98088_probe()
1660 cdata->fmt = (unsigned)-1; in max98088_probe()
1661 cdata->eq_sel = 0; in max98088_probe()
1663 max98088->ina_state = 0; in max98088_probe()
1664 max98088->inb_state = 0; in max98088_probe()
1665 max98088->ex_mode = 0; in max98088_probe()
1666 max98088->digmic = 0; in max98088_probe()
1667 max98088->mic1pre = 0; in max98088_probe()
1668 max98088->mic2pre = 0; in max98088_probe()
1672 dev_err(component->dev, "Failed to read device revision: %d\n", in max98088_probe()
1676 dev_info(component->dev, "revision %c\n", ret - 0x40 + 'A'); in max98088_probe()
1705 kfree(max98088->eq_texts); in max98088_remove()
1735 max98088 = devm_kzalloc(&i2c->dev, sizeof(struct max98088_priv), in max98088_i2c_probe()
1738 return -ENOMEM; in max98088_i2c_probe()
1740 max98088->regmap = devm_regmap_init_i2c(i2c, &max98088_regmap); in max98088_i2c_probe()
1741 if (IS_ERR(max98088->regmap)) in max98088_i2c_probe()
1742 return PTR_ERR(max98088->regmap); in max98088_i2c_probe()
1744 max98088->mclk = devm_clk_get(&i2c->dev, "mclk"); in max98088_i2c_probe()
1745 if (IS_ERR(max98088->mclk)) in max98088_i2c_probe()
1746 if (PTR_ERR(max98088->mclk) == -EPROBE_DEFER) in max98088_i2c_probe()
1747 return PTR_ERR(max98088->mclk); in max98088_i2c_probe()
1749 max98088->devtype = (uintptr_t)i2c_get_match_data(i2c); in max98088_i2c_probe()
1752 max98088->pdata = i2c->dev.platform_data; in max98088_i2c_probe()
1754 return devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_max98088, in max98088_i2c_probe()