Lines Matching +full:rcv +full:- +full:sel

1 // SPDX-License-Identifier: GPL-2.0-only
3 * max98095.c -- MAX98095 ALSA SoC Audio driver
338 "Off", "Elliptical-HPF-16k", "Butterworth-HPF-16k",
339 "Elliptical-HPF-8k", "Butterworth-HPF-8k", "Butterworth-HPF-Fs/240"};
355 unsigned int sel = ucontrol->value.integer.value[0]; in max98095_mic1pre_set() local
357 max98095->mic1pre = sel; in max98095_mic1pre_set()
359 (1+sel)<<M98095_MICPRE_SHIFT); in max98095_mic1pre_set()
370 ucontrol->value.integer.value[0] = max98095->mic1pre; in max98095_mic1pre_get()
379 unsigned int sel = ucontrol->value.integer.value[0]; in max98095_mic2pre_set() local
381 max98095->mic2pre = sel; in max98095_mic2pre_set()
383 (1+sel)<<M98095_MICPRE_SHIFT); in max98095_mic2pre_set()
394 ucontrol->value.integer.value[0] = max98095->mic2pre; in max98095_mic2pre_get()
404 static const DECLARE_TLV_DB_SCALE(max98095_adc_tlv, -1200, 100, 0);
408 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
409 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
410 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
411 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
416 0, 10, TLV_DB_SCALE_ITEM(-5900, 400, 0),
417 11, 18, TLV_DB_SCALE_ITEM(-1700, 200, 0),
418 19, 27, TLV_DB_SCALE_ITEM(-200, 100, 0),
423 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
424 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
425 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
431 0, 2, TLV_DB_SCALE_ITEM(-600, 300, 0),
598 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98095_mic_event()
603 if (w->reg == M98095_05F_LVL_MIC1) { in max98095_mic_event()
604 snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, in max98095_mic_event()
605 (1+max98095->mic1pre)<<M98095_MICPRE_SHIFT); in max98095_mic_event()
607 snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, in max98095_mic_event()
608 (1+max98095->mic2pre)<<M98095_MICPRE_SHIFT); in max98095_mic_event()
612 snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, 0); in max98095_mic_event()
615 return -EINVAL; in max98095_mic_event()
628 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98095_line_pga()
633 return -EINVAL; in max98095_line_pga()
635 state = &max98095->lin_state; in max98095_line_pga()
640 snd_soc_component_update_bits(component, w->reg, in max98095_line_pga()
641 (1 << w->shift), (1 << w->shift)); in max98095_line_pga()
646 snd_soc_component_update_bits(component, w->reg, in max98095_line_pga()
647 (1 << w->shift), 0); in max98095_line_pga()
651 return -EINVAL; in max98095_line_pga()
676 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98095_lineout_event()
680 snd_soc_component_update_bits(component, w->reg, in max98095_lineout_event()
681 (1 << (w->shift+2)), (1 << (w->shift+2))); in max98095_lineout_event()
684 snd_soc_component_update_bits(component, w->reg, in max98095_lineout_event()
685 (1 << (w->shift+2)), 0); in max98095_lineout_event()
688 return -EINVAL; in max98095_lineout_event()
718 SND_SOC_DAPM_PGA("RCV Mono Out", M98095_091_PWR_EN_OUT,
791 SND_SOC_DAPM_OUTPUT("RCV"),
870 {"RCV Mono Out", NULL, "Receiver Mixer"},
878 {"RCV", NULL, "RCV Mono Out"},
935 return -EINVAL; in rate_value()
942 struct snd_soc_component *component = dai->component; in max98095_dai1_hw_params()
949 cdata = &max98095->dai[0]; in max98095_dai1_hw_params()
963 return -EINVAL; in max98095_dai1_hw_params()
967 return -EINVAL; in max98095_dai1_hw_params()
971 cdata->rate = rate; in max98095_dai1_hw_params()
975 if (max98095->sysclk == 0) { in max98095_dai1_hw_params()
976 dev_err(component->dev, "Invalid system clock frequency\n"); in max98095_dai1_hw_params()
977 return -EINVAL; in max98095_dai1_hw_params()
981 do_div(ni, (unsigned long long int)max98095->sysclk); in max98095_dai1_hw_params()
1003 struct snd_soc_component *component = dai->component; in max98095_dai2_hw_params()
1010 cdata = &max98095->dai[1]; in max98095_dai2_hw_params()
1024 return -EINVAL; in max98095_dai2_hw_params()
1028 return -EINVAL; in max98095_dai2_hw_params()
1032 cdata->rate = rate; in max98095_dai2_hw_params()
1036 if (max98095->sysclk == 0) { in max98095_dai2_hw_params()
1037 dev_err(component->dev, "Invalid system clock frequency\n"); in max98095_dai2_hw_params()
1038 return -EINVAL; in max98095_dai2_hw_params()
1042 do_div(ni, (unsigned long long int)max98095->sysclk); in max98095_dai2_hw_params()
1064 struct snd_soc_component *component = dai->component; in max98095_dai3_hw_params()
1071 cdata = &max98095->dai[2]; in max98095_dai3_hw_params()
1085 return -EINVAL; in max98095_dai3_hw_params()
1089 return -EINVAL; in max98095_dai3_hw_params()
1093 cdata->rate = rate; in max98095_dai3_hw_params()
1097 if (max98095->sysclk == 0) { in max98095_dai3_hw_params()
1098 dev_err(component->dev, "Invalid system clock frequency\n"); in max98095_dai3_hw_params()
1099 return -EINVAL; in max98095_dai3_hw_params()
1103 do_div(ni, (unsigned long long int)max98095->sysclk); in max98095_dai3_hw_params()
1124 struct snd_soc_component *component = dai->component; in max98095_dai_set_sysclk()
1128 if (freq == max98095->sysclk) in max98095_dai_set_sysclk()
1131 if (!IS_ERR(max98095->mclk)) { in max98095_dai_set_sysclk()
1132 freq = clk_round_rate(max98095->mclk, freq); in max98095_dai_set_sysclk()
1133 clk_set_rate(max98095->mclk, freq); in max98095_dai_set_sysclk()
1148 dev_err(component->dev, "Invalid master clock frequency\n"); in max98095_dai_set_sysclk()
1149 return -EINVAL; in max98095_dai_set_sysclk()
1152 dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); in max98095_dai_set_sysclk()
1154 max98095->sysclk = freq; in max98095_dai_set_sysclk()
1161 struct snd_soc_component *component = codec_dai->component; in max98095_dai1_set_fmt()
1166 cdata = &max98095->dai[0]; in max98095_dai1_set_fmt()
1168 if (fmt != cdata->fmt) { in max98095_dai1_set_fmt()
1169 cdata->fmt = fmt; in max98095_dai1_set_fmt()
1184 dev_err(component->dev, "Clock mode unsupported"); in max98095_dai1_set_fmt()
1185 return -EINVAL; in max98095_dai1_set_fmt()
1195 return -EINVAL; in max98095_dai1_set_fmt()
1211 return -EINVAL; in max98095_dai1_set_fmt()
1227 struct snd_soc_component *component = codec_dai->component; in max98095_dai2_set_fmt()
1232 cdata = &max98095->dai[1]; in max98095_dai2_set_fmt()
1234 if (fmt != cdata->fmt) { in max98095_dai2_set_fmt()
1235 cdata->fmt = fmt; in max98095_dai2_set_fmt()
1250 dev_err(component->dev, "Clock mode unsupported"); in max98095_dai2_set_fmt()
1251 return -EINVAL; in max98095_dai2_set_fmt()
1261 return -EINVAL; in max98095_dai2_set_fmt()
1277 return -EINVAL; in max98095_dai2_set_fmt()
1294 struct snd_soc_component *component = codec_dai->component; in max98095_dai3_set_fmt()
1299 cdata = &max98095->dai[2]; in max98095_dai3_set_fmt()
1301 if (fmt != cdata->fmt) { in max98095_dai3_set_fmt()
1302 cdata->fmt = fmt; in max98095_dai3_set_fmt()
1317 dev_err(component->dev, "Clock mode unsupported"); in max98095_dai3_set_fmt()
1318 return -EINVAL; in max98095_dai3_set_fmt()
1328 return -EINVAL; in max98095_dai3_set_fmt()
1344 return -EINVAL; in max98095_dai3_set_fmt()
1376 if (IS_ERR(max98095->mclk)) in max98095_set_bias_level()
1380 clk_disable_unprepare(max98095->mclk); in max98095_set_bias_level()
1382 ret = clk_prepare_enable(max98095->mclk); in max98095_set_bias_level()
1390 ret = regcache_sync(max98095->regmap); in max98095_set_bias_level()
1393 dev_err(component->dev, "Failed to sync cache: %d\n", ret); in max98095_set_bias_level()
1405 regcache_mark_dirty(max98095->regmap); in max98095_set_bias_level()
1482 return -EINVAL; in max98095_get_eq_channel()
1490 struct max98095_pdata *pdata = max98095->pdata; in max98095_put_eq_enum()
1491 int channel = max98095_get_eq_channel(kcontrol->id.name); in max98095_put_eq_enum()
1493 unsigned int sel = ucontrol->value.enumerated.item[0]; in max98095_put_eq_enum() local
1499 return -EINVAL; in max98095_put_eq_enum()
1501 if (!pdata || !max98095->eq_textcnt) in max98095_put_eq_enum()
1504 if (sel >= pdata->eq_cfgcnt) in max98095_put_eq_enum()
1505 return -EINVAL; in max98095_put_eq_enum()
1507 cdata = &max98095->dai[channel]; in max98095_put_eq_enum()
1508 cdata->eq_sel = sel; in max98095_put_eq_enum()
1509 fs = cdata->rate; in max98095_put_eq_enum()
1514 for (i = 0; i < pdata->eq_cfgcnt; i++) { in max98095_put_eq_enum()
1515 if (strcmp(pdata->eq_cfg[i].name, max98095->eq_texts[sel]) == 0 && in max98095_put_eq_enum()
1516 abs(pdata->eq_cfg[i].rate - fs) < best_val) { in max98095_put_eq_enum()
1518 best_val = abs(pdata->eq_cfg[i].rate - fs); in max98095_put_eq_enum()
1522 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98095_put_eq_enum()
1523 pdata->eq_cfg[best].name, in max98095_put_eq_enum()
1524 pdata->eq_cfg[best].rate, fs); in max98095_put_eq_enum()
1526 coef_set = &pdata->eq_cfg[best]; in max98095_put_eq_enum()
1534 mutex_lock(&max98095->lock); in max98095_put_eq_enum()
1536 m98095_eq_band(component, channel, 0, coef_set->band1); in max98095_put_eq_enum()
1537 m98095_eq_band(component, channel, 1, coef_set->band2); in max98095_put_eq_enum()
1538 m98095_eq_band(component, channel, 2, coef_set->band3); in max98095_put_eq_enum()
1539 m98095_eq_band(component, channel, 3, coef_set->band4); in max98095_put_eq_enum()
1540 m98095_eq_band(component, channel, 4, coef_set->band5); in max98095_put_eq_enum()
1542 mutex_unlock(&max98095->lock); in max98095_put_eq_enum()
1554 int channel = max98095_get_eq_channel(kcontrol->id.name); in max98095_get_eq_enum()
1557 cdata = &max98095->dai[channel]; in max98095_get_eq_enum()
1558 ucontrol->value.enumerated.item[0] = cdata->eq_sel; in max98095_get_eq_enum()
1566 struct max98095_pdata *pdata = max98095->pdata; in max98095_handle_eq_pdata()
1575 max98095->eq_enum, in max98095_handle_eq_pdata()
1579 max98095->eq_enum, in max98095_handle_eq_pdata()
1584 cfg = pdata->eq_cfg; in max98095_handle_eq_pdata()
1585 cfgcnt = pdata->eq_cfgcnt; in max98095_handle_eq_pdata()
1590 max98095->eq_textcnt = 0; in max98095_handle_eq_pdata()
1591 max98095->eq_texts = NULL; in max98095_handle_eq_pdata()
1593 for (j = 0; j < max98095->eq_textcnt; j++) { in max98095_handle_eq_pdata()
1594 if (strcmp(cfg[i].name, max98095->eq_texts[j]) == 0) in max98095_handle_eq_pdata()
1598 if (j != max98095->eq_textcnt) in max98095_handle_eq_pdata()
1602 t = krealloc(max98095->eq_texts, in max98095_handle_eq_pdata()
1603 sizeof(char *) * (max98095->eq_textcnt + 1), in max98095_handle_eq_pdata()
1609 t[max98095->eq_textcnt] = cfg[i].name; in max98095_handle_eq_pdata()
1610 max98095->eq_textcnt++; in max98095_handle_eq_pdata()
1611 max98095->eq_texts = t; in max98095_handle_eq_pdata()
1615 max98095->eq_enum.texts = max98095->eq_texts; in max98095_handle_eq_pdata()
1616 max98095->eq_enum.items = max98095->eq_textcnt; in max98095_handle_eq_pdata()
1620 dev_err(component->dev, "Failed to add EQ control: %d\n", ret); in max98095_handle_eq_pdata()
1632 dev_err(component->dev, "Bad biquad channel name '%s'\n", name); in max98095_get_bq_channel()
1641 struct max98095_pdata *pdata = max98095->pdata; in max98095_put_bq_enum()
1642 int channel = max98095_get_bq_channel(component, kcontrol->id.name); in max98095_put_bq_enum()
1644 unsigned int sel = ucontrol->value.enumerated.item[0]; in max98095_put_bq_enum() local
1652 if (!pdata || !max98095->bq_textcnt) in max98095_put_bq_enum()
1655 if (sel >= pdata->bq_cfgcnt) in max98095_put_bq_enum()
1656 return -EINVAL; in max98095_put_bq_enum()
1658 cdata = &max98095->dai[channel]; in max98095_put_bq_enum()
1659 cdata->bq_sel = sel; in max98095_put_bq_enum()
1660 fs = cdata->rate; in max98095_put_bq_enum()
1665 for (i = 0; i < pdata->bq_cfgcnt; i++) { in max98095_put_bq_enum()
1666 if (strcmp(pdata->bq_cfg[i].name, max98095->bq_texts[sel]) == 0 && in max98095_put_bq_enum()
1667 abs(pdata->bq_cfg[i].rate - fs) < best_val) { in max98095_put_bq_enum()
1669 best_val = abs(pdata->bq_cfg[i].rate - fs); in max98095_put_bq_enum()
1673 dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", in max98095_put_bq_enum()
1674 pdata->bq_cfg[best].name, in max98095_put_bq_enum()
1675 pdata->bq_cfg[best].rate, fs); in max98095_put_bq_enum()
1677 coef_set = &pdata->bq_cfg[best]; in max98095_put_bq_enum()
1685 mutex_lock(&max98095->lock); in max98095_put_bq_enum()
1687 m98095_biquad_band(component, channel, 0, coef_set->band1); in max98095_put_bq_enum()
1688 m98095_biquad_band(component, channel, 1, coef_set->band2); in max98095_put_bq_enum()
1690 mutex_unlock(&max98095->lock); in max98095_put_bq_enum()
1702 int channel = max98095_get_bq_channel(component, kcontrol->id.name); in max98095_get_bq_enum()
1708 cdata = &max98095->dai[channel]; in max98095_get_bq_enum()
1709 ucontrol->value.enumerated.item[0] = cdata->bq_sel; in max98095_get_bq_enum()
1717 struct max98095_pdata *pdata = max98095->pdata; in max98095_handle_bq_pdata()
1726 max98095->bq_enum, in max98095_handle_bq_pdata()
1730 max98095->bq_enum, in max98095_handle_bq_pdata()
1736 cfg = pdata->bq_cfg; in max98095_handle_bq_pdata()
1737 cfgcnt = pdata->bq_cfgcnt; in max98095_handle_bq_pdata()
1742 max98095->bq_textcnt = 0; in max98095_handle_bq_pdata()
1743 max98095->bq_texts = NULL; in max98095_handle_bq_pdata()
1745 for (j = 0; j < max98095->bq_textcnt; j++) { in max98095_handle_bq_pdata()
1746 if (strcmp(cfg[i].name, max98095->bq_texts[j]) == 0) in max98095_handle_bq_pdata()
1750 if (j != max98095->bq_textcnt) in max98095_handle_bq_pdata()
1754 t = krealloc(max98095->bq_texts, in max98095_handle_bq_pdata()
1755 sizeof(char *) * (max98095->bq_textcnt + 1), in max98095_handle_bq_pdata()
1761 t[max98095->bq_textcnt] = cfg[i].name; in max98095_handle_bq_pdata()
1762 max98095->bq_textcnt++; in max98095_handle_bq_pdata()
1763 max98095->bq_texts = t; in max98095_handle_bq_pdata()
1767 max98095->bq_enum.texts = max98095->bq_texts; in max98095_handle_bq_pdata()
1768 max98095->bq_enum.items = max98095->bq_textcnt; in max98095_handle_bq_pdata()
1772 dev_err(component->dev, "Failed to add Biquad control: %d\n", ret); in max98095_handle_bq_pdata()
1778 struct max98095_pdata *pdata = max98095->pdata; in max98095_handle_pdata()
1782 dev_dbg(component->dev, "No platform data\n"); in max98095_handle_pdata()
1787 if (pdata->digmic_left_mode) in max98095_handle_pdata()
1790 if (pdata->digmic_right_mode) in max98095_handle_pdata()
1796 if (pdata->eq_cfgcnt) in max98095_handle_pdata()
1799 /* Configure bi-quad filters */ in max98095_handle_pdata()
1800 if (pdata->bq_cfgcnt) in max98095_handle_pdata()
1821 max98095->headphone_jack) in max98095_report_jack()
1825 if ((value & M98095_MIC_IN) && max98095->mic_jack) in max98095_report_jack()
1828 if (max98095->headphone_jack == max98095->mic_jack) { in max98095_report_jack()
1829 snd_soc_jack_report(max98095->headphone_jack, in max98095_report_jack()
1833 if (max98095->headphone_jack) in max98095_report_jack()
1834 snd_soc_jack_report(max98095->headphone_jack, in max98095_report_jack()
1836 if (max98095->mic_jack) in max98095_report_jack()
1837 snd_soc_jack_report(max98095->mic_jack, in max98095_report_jack()
1851 if (max98095->pdata->jack_detect_pin5en) in max98095_jack_detect_enable()
1854 if (max98095->pdata->jack_detect_delay) in max98095_jack_detect_enable()
1855 slew = max98095->pdata->jack_detect_delay; in max98095_jack_detect_enable()
1859 dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); in max98095_jack_detect_enable()
1866 dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); in max98095_jack_detect_enable()
1880 dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); in max98095_jack_detect_disable()
1891 struct i2c_client *client = to_i2c_client(component->dev); in max98095_jack_detect()
1894 max98095->headphone_jack = hp_jack; in max98095_jack_detect()
1895 max98095->mic_jack = mic_jack; in max98095_jack_detect()
1899 return -EINVAL; in max98095_jack_detect()
1907 dev_err(component->dev, "Failed to cfg jack irqs %d\n", ret); in max98095_jack_detect()
1911 max98095_report_jack(client->irq, component); in max98095_jack_detect()
1921 if (max98095->headphone_jack || max98095->mic_jack) in max98095_suspend()
1932 struct i2c_client *client = to_i2c_client(component->dev); in max98095_resume()
1936 if (max98095->headphone_jack || max98095->mic_jack) { in max98095_resume()
1938 max98095_report_jack(client->irq, component); in max98095_resume()
1956 dev_err(component->dev, "Failed to reset DSP: %d\n", ret); in max98095_reset()
1962 dev_err(component->dev, "Failed to reset component: %d\n", ret); in max98095_reset()
1971 dev_err(component->dev, "Failed to reset: %d\n", ret); in max98095_reset()
1986 max98095->mclk = devm_clk_get(component->dev, "mclk"); in max98095_probe()
1987 if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) in max98095_probe()
1988 return -EPROBE_DEFER; in max98095_probe()
1993 client = to_i2c_client(component->dev); in max98095_probe()
1997 max98095->sysclk = (unsigned)-1; in max98095_probe()
1998 max98095->eq_textcnt = 0; in max98095_probe()
1999 max98095->bq_textcnt = 0; in max98095_probe()
2001 cdata = &max98095->dai[0]; in max98095_probe()
2002 cdata->rate = (unsigned)-1; in max98095_probe()
2003 cdata->fmt = (unsigned)-1; in max98095_probe()
2004 cdata->eq_sel = 0; in max98095_probe()
2005 cdata->bq_sel = 0; in max98095_probe()
2007 cdata = &max98095->dai[1]; in max98095_probe()
2008 cdata->rate = (unsigned)-1; in max98095_probe()
2009 cdata->fmt = (unsigned)-1; in max98095_probe()
2010 cdata->eq_sel = 0; in max98095_probe()
2011 cdata->bq_sel = 0; in max98095_probe()
2013 cdata = &max98095->dai[2]; in max98095_probe()
2014 cdata->rate = (unsigned)-1; in max98095_probe()
2015 cdata->fmt = (unsigned)-1; in max98095_probe()
2016 cdata->eq_sel = 0; in max98095_probe()
2017 cdata->bq_sel = 0; in max98095_probe()
2019 max98095->lin_state = 0; in max98095_probe()
2020 max98095->mic1pre = 0; in max98095_probe()
2021 max98095->mic2pre = 0; in max98095_probe()
2023 if (client->irq) { in max98095_probe()
2025 ret = request_threaded_irq(client->irq, NULL, in max98095_probe()
2030 dev_err(component->dev, "Failed to request IRQ: %d\n", ret); in max98095_probe()
2037 dev_err(component->dev, "Failure reading hardware revision: %d\n", in max98095_probe()
2041 dev_info(component->dev, "Hardware revision: %c\n", ret - 0x40 + 'A'); in max98095_probe()
2073 if (client->irq) in max98095_probe()
2074 free_irq(client->irq, component); in max98095_probe()
2082 struct i2c_client *client = to_i2c_client(component->dev); in max98095_remove()
2084 if (max98095->headphone_jack || max98095->mic_jack) in max98095_remove()
2087 if (client->irq) in max98095_remove()
2088 free_irq(client->irq, component); in max98095_remove()
2120 max98095 = devm_kzalloc(&i2c->dev, sizeof(struct max98095_priv), in max98095_i2c_probe()
2123 return -ENOMEM; in max98095_i2c_probe()
2125 mutex_init(&max98095->lock); in max98095_i2c_probe()
2127 max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap); in max98095_i2c_probe()
2128 if (IS_ERR(max98095->regmap)) { in max98095_i2c_probe()
2129 ret = PTR_ERR(max98095->regmap); in max98095_i2c_probe()
2130 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); in max98095_i2c_probe()
2135 max98095->devtype = id->driver_data; in max98095_i2c_probe()
2137 max98095->pdata = i2c->dev.platform_data; in max98095_i2c_probe()
2139 ret = devm_snd_soc_register_component(&i2c->dev, in max98095_i2c_probe()