Lines Matching +full:dmic +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt286.c -- RT286 ALSA SoC audio codec driver
23 #include <sound/soc-dapm.h>
196 snd_soc_component_write(component, rt286->index_cache[i].reg, in rt286_index_sync()
197 rt286->index_cache[i].def); in rt286_index_sync()
223 if (!rt286->component) in rt286_jack_detect()
224 return -EINVAL; in rt286_jack_detect()
226 dapm = snd_soc_component_get_dapm(rt286->component); in rt286_jack_detect()
228 if (rt286->pdata.cbj_en) { in rt286_jack_detect()
229 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); in rt286_jack_detect()
233 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
242 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x24); in rt286_jack_detect()
245 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
248 regmap_read(rt286->regmap, RT286_CBJ_CTRL2, &val); in rt286_jack_detect()
253 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
256 regmap_read(rt286->regmap, in rt286_jack_detect()
262 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
268 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
273 regmap_write(rt286->regmap, RT286_SET_MIC1, 0x20); in rt286_jack_detect()
274 regmap_update_bits(rt286->regmap, in rt286_jack_detect()
278 regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); in rt286_jack_detect()
280 regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf); in rt286_jack_detect()
310 snd_soc_jack_report(rt286->jack, status, in rt286_jack_detect_work()
320 rt286->jack = jack; in rt286_mic_detect()
324 if (rt286->jack->status & SND_JACK_HEADPHONE) in rt286_mic_detect()
326 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2); in rt286_mic_detect()
328 snd_soc_jack_report(rt286->jack, rt286->jack->status, in rt286_mic_detect()
332 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0); in rt286_mic_detect()
343 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_mclk_mode()
346 if (rt286->clk_id == RT286_SCLK_S_MCLK) in is_mclk_mode()
352 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0);
402 "Mic", "RECMIX", "Dmic"
426 /* HP-OUT source */
433 /* SPK-OUT source */
443 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt286_spk_event()
465 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt286_set_dmic1_event()
484 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt286_ldo2_event()
503 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt286_mic1_event()
548 /* DMIC */
554 SND_SOC_DAPM_SUPPLY("DMIC Receiver", SND_SOC_NOPM,
633 {"DMIC1", NULL, "DMIC Receiver"},
634 {"DMIC2", NULL, "DMIC Receiver"},
640 {"ADC 0 Mux", "Dmic", "DMIC1"},
643 {"ADC 1 Mux", "Dmic", "DMIC2"},
683 struct snd_soc_component *component = dai->component; in rt286_hw_params()
696 dev_err(component->dev, "Unsupported sample rate %d\n", in rt286_hw_params()
698 return -EINVAL; in rt286_hw_params()
700 switch (rt286->sys_clk) { in rt286_hw_params()
704 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt286_hw_params()
705 params_rate(params), rt286->sys_clk); in rt286_hw_params()
706 return -EINVAL; in rt286_hw_params()
712 dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", in rt286_hw_params()
713 params_rate(params), rt286->sys_clk); in rt286_hw_params()
714 return -EINVAL; in rt286_hw_params()
721 val |= (params_channels(params) - 1); in rt286_hw_params()
723 dev_err(component->dev, "Unsupported channels %d\n", in rt286_hw_params()
725 return -EINVAL; in rt286_hw_params()
750 return -EINVAL; in rt286_hw_params()
755 dev_dbg(component->dev, "format val = 0x%x\n", val); in rt286_hw_params()
765 struct snd_soc_component *component = dai->component; in rt286_set_dai_fmt()
777 return -EINVAL; in rt286_set_dai_fmt()
798 return -EINVAL; in rt286_set_dai_fmt()
800 /* bit 15 Stream Type 0:PCM 1:Non-PCM */ in rt286_set_dai_fmt()
808 int clk_id, unsigned int freq, int dir) in rt286_set_dai_sysclk() argument
810 struct snd_soc_component *component = dai->component; in rt286_set_dai_sysclk()
813 dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); in rt286_set_dai_sysclk()
829 switch (freq) { in rt286_set_dai_sysclk()
832 dev_err(component->dev, "Should not use MCLK\n"); in rt286_set_dai_sysclk()
833 return -EINVAL; in rt286_set_dai_sysclk()
840 dev_err(component->dev, "Should not use MCLK\n"); in rt286_set_dai_sysclk()
841 return -EINVAL; in rt286_set_dai_sysclk()
861 dev_err(component->dev, "Unsupported system clock\n"); in rt286_set_dai_sysclk()
862 return -EINVAL; in rt286_set_dai_sysclk()
865 rt286->sys_clk = freq; in rt286_set_dai_sysclk()
866 rt286->clk_id = clk_id; in rt286_set_dai_sysclk()
873 struct snd_soc_component *component = dai->component; in rt286_set_bclk_ratio()
875 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt286_set_bclk_ratio()
929 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x1, 0x1); in rt286_irq()
937 snd_soc_jack_report(rt286->jack, status, in rt286_irq()
940 pm_wakeup_event(&rt286->i2c->dev, 300); in rt286_irq()
949 rt286->component = component; in rt286_probe()
950 INIT_DELAYED_WORK(&rt286->jack_detect_work, rt286_jack_detect_work); in rt286_probe()
952 if (rt286->i2c->irq) in rt286_probe()
953 schedule_delayed_work(&rt286->jack_detect_work, in rt286_probe()
962 cancel_delayed_work_sync(&rt286->jack_detect_work); in rt286_remove()
963 rt286->component = NULL; in rt286_remove()
971 regcache_cache_only(rt286->regmap, true); in rt286_suspend()
972 regcache_mark_dirty(rt286->regmap); in rt286_suspend()
981 regcache_cache_only(rt286->regmap, false); in rt286_resume()
983 regcache_sync(rt286->regmap); in rt286_resume()
1005 .name = "rt286-aif1",
1025 .name = "rt286-aif2",
1134 struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt286_i2c_probe()
1138 rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286), in rt286_i2c_probe()
1141 return -ENOMEM; in rt286_i2c_probe()
1143 rt286->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt286_regmap); in rt286_i2c_probe()
1144 if (IS_ERR(rt286->regmap)) { in rt286_i2c_probe()
1145 ret = PTR_ERR(rt286->regmap); in rt286_i2c_probe()
1146 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt286_i2c_probe()
1151 ret = regmap_read(rt286->regmap, in rt286_i2c_probe()
1154 dev_err(&i2c->dev, "I2C error %d\n", ret); in rt286_i2c_probe()
1158 dev_err(&i2c->dev, in rt286_i2c_probe()
1161 return -ENODEV; in rt286_i2c_probe()
1164 rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def, in rt286_i2c_probe()
1166 if (!rt286->index_cache) in rt286_i2c_probe()
1167 return -ENOMEM; in rt286_i2c_probe()
1169 rt286->index_cache_size = INDEX_CACHE_SIZE; in rt286_i2c_probe()
1170 rt286->i2c = i2c; in rt286_i2c_probe()
1175 regmap_write(rt286->regmap, rt286->index_cache[i].reg, in rt286_i2c_probe()
1176 rt286->index_cache[i].def); in rt286_i2c_probe()
1178 regmap_write(rt286->regmap, rt286_reg[i].reg, in rt286_i2c_probe()
1182 rt286->pdata = *pdata; in rt286_i2c_probe()
1186 rt286->pdata.cbj_en = true; in rt286_i2c_probe()
1188 regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3); in rt286_i2c_probe()
1191 regmap_write(rt286->regmap, in rt286_i2c_probe()
1195 if (!rt286->pdata.cbj_en) { in rt286_i2c_probe()
1196 regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000); in rt286_i2c_probe()
1197 regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816); in rt286_i2c_probe()
1198 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1201 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1207 if (!rt286->pdata.gpio2_en) in rt286_i2c_probe()
1208 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x40); in rt286_i2c_probe()
1210 regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0); in rt286_i2c_probe()
1214 regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000); in rt286_i2c_probe()
1216 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0xc, 0x0); in rt286_i2c_probe()
1217 regmap_update_bits(rt286->regmap, RT286_POWER_CTRL1, 0x1001, 0x1001); in rt286_i2c_probe()
1220 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL2, 0x403a, 0x401a); in rt286_i2c_probe()
1221 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737); in rt286_i2c_probe()
1222 regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f); in rt286_i2c_probe()
1225 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1227 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1229 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1231 regmap_update_bits(rt286->regmap, in rt286_i2c_probe()
1235 if (rt286->i2c->irq) { in rt286_i2c_probe()
1236 ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq, in rt286_i2c_probe()
1239 dev_err(&i2c->dev, in rt286_i2c_probe()
1245 ret = devm_snd_soc_register_component(&i2c->dev, in rt286_i2c_probe()
1256 if (i2c->irq) in rt286_i2c_remove()
1257 free_irq(i2c->irq, rt286); in rt286_i2c_remove()