• Home
  • Raw
  • Download

Lines Matching +full:dmic1 +full:- +full:data +full:- +full:pin

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt298.c -- RT298 ALSA SoC audio codec driver
23 #include <sound/soc-dapm.h>
200 snd_soc_component_write(component, rt298->index_cache[i].reg, in rt298_index_sync()
201 rt298->index_cache[i].def); in rt298_index_sync()
227 if (!rt298->component) in rt298_jack_detect()
228 return -EINVAL; in rt298_jack_detect()
230 dapm = snd_soc_component_get_dapm(rt298->component); in rt298_jack_detect()
232 if (rt298->pdata.cbj_en) { in rt298_jack_detect()
233 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); in rt298_jack_detect()
235 if (*hp == rt298->is_hp_in) in rt298_jack_detect()
236 return -1; in rt298_jack_detect()
237 rt298->is_hp_in = *hp; in rt298_jack_detect()
240 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
249 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
251 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
254 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x24); in rt298_jack_detect()
257 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
260 regmap_read(rt298->regmap, RT298_CBJ_CTRL2, &val); in rt298_jack_detect()
265 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
268 regmap_read(rt298->regmap, in rt298_jack_detect()
275 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
280 regmap_write(rt298->regmap, RT298_SET_MIC1, 0x20); in rt298_jack_detect()
281 regmap_update_bits(rt298->regmap, in rt298_jack_detect()
285 regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); in rt298_jack_detect()
287 regmap_read(rt298->regmap, RT298_GET_MIC1_SENSE, &buf); in rt298_jack_detect()
320 snd_soc_jack_report(rt298->jack, status, in rt298_jack_detect_work()
334 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0); in rt298_mic_detect()
341 rt298->jack = jack; in rt298_mic_detect()
342 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2); in rt298_mic_detect()
351 snd_soc_jack_report(rt298->jack, status, in rt298_mic_detect()
361 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_mclk_mode()
364 if (rt298->clk_id == RT298_SCLK_S_MCLK) in is_mclk_mode()
370 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0);
442 /* HP-OUT source */
449 /* SPK-OUT source */
459 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt298_spk_event()
481 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt298_set_dmic1_event()
500 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt298_adc_event()
503 nid = (w->reg >> 20) & 0xff; in rt298_adc_event()
546 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt298_mic1_event()
593 SND_SOC_DAPM_INPUT("DMIC1 Pin"),
594 SND_SOC_DAPM_INPUT("DMIC2 Pin"),
600 SND_SOC_DAPM_PGA_E("DMIC1", RT298_SET_POWER(RT298_DMIC1), 0, 1,
660 SND_SOC_DAPM_OUTPUT("HPO Pin"),
694 {"DMIC1", NULL, "DMIC1 Pin"},
695 {"DMIC2", NULL, "DMIC2 Pin"},
696 {"DMIC1", NULL, "DMIC Receiver"},
703 {"ADC 0 Mux", "Dmic", "DMIC1"},
738 {"HPO Pin", NULL, "HPO L"},
739 {"HPO Pin", NULL, "HPO R"},
746 struct snd_soc_component *component = dai->component; in rt298_hw_params()
757 dev_err(component->dev, "Unsupported sample rate %d\n", in rt298_hw_params()
759 return -EINVAL; in rt298_hw_params()
761 switch (rt298->sys_clk) { in rt298_hw_params()
765 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt298_hw_params()
766 params_rate(params), rt298->sys_clk); in rt298_hw_params()
767 return -EINVAL; in rt298_hw_params()
773 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt298_hw_params()
774 params_rate(params), rt298->sys_clk); in rt298_hw_params()
775 return -EINVAL; in rt298_hw_params()
782 val |= (params_channels(params) - 1); in rt298_hw_params()
784 dev_err(component->dev, "Unsupported channels %d\n", in rt298_hw_params()
786 return -EINVAL; in rt298_hw_params()
812 return -EINVAL; in rt298_hw_params()
817 dev_dbg(component->dev, "format val = 0x%x\n", val); in rt298_hw_params()
827 struct snd_soc_component *component = dai->component; in rt298_set_dai_fmt()
839 return -EINVAL; in rt298_set_dai_fmt()
860 return -EINVAL; in rt298_set_dai_fmt()
862 /* bit 15 Stream Type 0:PCM 1:Non-PCM */ in rt298_set_dai_fmt()
872 struct snd_soc_component *component = dai->component; in rt298_set_dai_sysclk()
875 dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); in rt298_set_dai_sysclk()
892 dev_err(component->dev, "Should not use MCLK\n"); in rt298_set_dai_sysclk()
893 return -EINVAL; in rt298_set_dai_sysclk()
900 dev_err(component->dev, "Should not use MCLK\n"); in rt298_set_dai_sysclk()
901 return -EINVAL; in rt298_set_dai_sysclk()
921 dev_err(component->dev, "Unsupported system clock\n"); in rt298_set_dai_sysclk()
922 return -EINVAL; in rt298_set_dai_sysclk()
925 rt298->sys_clk = freq; in rt298_set_dai_sysclk()
926 rt298->clk_id = clk_id; in rt298_set_dai_sysclk()
933 struct snd_soc_component *component = dai->component; in rt298_set_bclk_ratio()
935 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt298_set_bclk_ratio()
976 static irqreturn_t rt298_irq(int irq, void *data) in rt298_irq() argument
978 struct rt298_priv *rt298 = data; in rt298_irq()
986 regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x1, 0x1); in rt298_irq()
995 snd_soc_jack_report(rt298->jack, status, in rt298_irq()
998 pm_wakeup_event(&rt298->i2c->dev, 300); in rt298_irq()
1008 rt298->component = component; in rt298_probe()
1010 if (rt298->i2c->irq) { in rt298_probe()
1011 regmap_update_bits(rt298->regmap, in rt298_probe()
1014 INIT_DELAYED_WORK(&rt298->jack_detect_work, in rt298_probe()
1016 schedule_delayed_work(&rt298->jack_detect_work, in rt298_probe()
1027 cancel_delayed_work_sync(&rt298->jack_detect_work); in rt298_remove()
1035 rt298->is_hp_in = -1; in rt298_suspend()
1036 regcache_cache_only(rt298->regmap, true); in rt298_suspend()
1037 regcache_mark_dirty(rt298->regmap); in rt298_suspend()
1046 regcache_cache_only(rt298->regmap, false); in rt298_resume()
1048 regcache_sync(rt298->regmap); in rt298_resume()
1070 .name = "rt298-aif1",
1090 .name = "rt298-aif2",
1184 struct rt298_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt298_i2c_probe()
1186 struct device *dev = &i2c->dev; in rt298_i2c_probe()
1190 rt298 = devm_kzalloc(&i2c->dev, sizeof(*rt298), in rt298_i2c_probe()
1193 return -ENOMEM; in rt298_i2c_probe()
1195 rt298->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt298_regmap); in rt298_i2c_probe()
1196 if (IS_ERR(rt298->regmap)) { in rt298_i2c_probe()
1197 ret = PTR_ERR(rt298->regmap); in rt298_i2c_probe()
1198 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt298_i2c_probe()
1203 regmap_read(rt298->regmap, in rt298_i2c_probe()
1206 dev_err(&i2c->dev, in rt298_i2c_probe()
1208 return -ENODEV; in rt298_i2c_probe()
1211 rt298->index_cache = devm_kmemdup(&i2c->dev, rt298_index_def, in rt298_i2c_probe()
1213 if (!rt298->index_cache) in rt298_i2c_probe()
1214 return -ENOMEM; in rt298_i2c_probe()
1216 rt298->index_cache_size = INDEX_CACHE_SIZE; in rt298_i2c_probe()
1217 rt298->i2c = i2c; in rt298_i2c_probe()
1222 regmap_write(rt298->regmap, rt298->index_cache[i].reg, in rt298_i2c_probe()
1223 rt298->index_cache[i].def); in rt298_i2c_probe()
1225 regmap_write(rt298->regmap, rt298_reg[i].reg, in rt298_i2c_probe()
1229 rt298->pdata = *pdata; in rt298_i2c_probe()
1232 acpiid = acpi_match_device(dev->driver->acpi_match_table, dev); in rt298_i2c_probe()
1233 if (acpiid && acpiid->driver_data) { in rt298_i2c_probe()
1234 rt298->pdata = *(struct rt298_platform_data *) in rt298_i2c_probe()
1235 acpiid->driver_data; in rt298_i2c_probe()
1239 rt298->pdata.cbj_en = true; in rt298_i2c_probe()
1240 rt298->pdata.gpio2_en = false; in rt298_i2c_probe()
1244 regmap_update_bits(rt298->regmap, 0x04, 0x80, 0x80); in rt298_i2c_probe()
1245 regmap_update_bits(rt298->regmap, 0x1b, 0x860, 0x860); in rt298_i2c_probe()
1247 regmap_update_bits(rt298->regmap, 0x08, 0x20, 0x20); in rt298_i2c_probe()
1249 regmap_write(rt298->regmap, RT298_SET_AUDIO_POWER, AC_PWRST_D3); in rt298_i2c_probe()
1252 regmap_write(rt298->regmap, in rt298_i2c_probe()
1256 if (!rt298->pdata.cbj_en) { in rt298_i2c_probe()
1257 regmap_write(rt298->regmap, RT298_CBJ_CTRL2, 0x0000); in rt298_i2c_probe()
1258 regmap_write(rt298->regmap, RT298_MIC1_DET_CTRL, 0x0816); in rt298_i2c_probe()
1259 regmap_update_bits(rt298->regmap, in rt298_i2c_probe()
1262 regmap_update_bits(rt298->regmap, in rt298_i2c_probe()
1268 if (!rt298->pdata.gpio2_en) in rt298_i2c_probe()
1269 regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0x40); in rt298_i2c_probe()
1271 regmap_write(rt298->regmap, RT298_SET_DMIC2_DEFAULT, 0); in rt298_i2c_probe()
1275 regmap_write(rt298->regmap, RT298_MISC_CTRL1, 0x0000); in rt298_i2c_probe()
1276 regmap_update_bits(rt298->regmap, in rt298_i2c_probe()
1279 regmap_write(rt298->regmap, RT298_UNSOLICITED_INLINE_CMD, 0x81); in rt298_i2c_probe()
1280 regmap_write(rt298->regmap, RT298_UNSOLICITED_HP_OUT, 0x82); in rt298_i2c_probe()
1281 regmap_write(rt298->regmap, RT298_UNSOLICITED_MIC1, 0x84); in rt298_i2c_probe()
1282 regmap_update_bits(rt298->regmap, RT298_IRQ_FLAG_CTRL, 0x2, 0x2); in rt298_i2c_probe()
1284 rt298->is_hp_in = -1; in rt298_i2c_probe()
1286 if (rt298->i2c->irq) { in rt298_i2c_probe()
1287 ret = request_threaded_irq(rt298->i2c->irq, NULL, rt298_irq, in rt298_i2c_probe()
1290 dev_err(&i2c->dev, in rt298_i2c_probe()
1296 ret = devm_snd_soc_register_component(&i2c->dev, in rt298_i2c_probe()
1307 if (i2c->irq) in rt298_i2c_remove()
1308 free_irq(i2c->irq, rt298); in rt298_i2c_remove()