Lines Matching refs:rt711
85 static int rt711_calibration(struct rt711_priv *rt711) in rt711_calibration() argument
89 struct regmap *regmap = rt711->regmap; in rt711_calibration()
92 mutex_lock(&rt711->calibrate_mutex); in rt711_calibration()
93 regmap_write(rt711->regmap, in rt711_calibration()
129 regmap_write(rt711->regmap, in rt711_calibration()
131 mutex_unlock(&rt711->calibrate_mutex); in rt711_calibration()
137 static unsigned int rt711_button_detect(struct rt711_priv *rt711) in rt711_button_detect() argument
142 ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, in rt711_button_detect()
146 ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, in rt711_button_detect()
184 static int rt711_headset_detect(struct rt711_priv *rt711) in rt711_headset_detect() argument
190 ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, in rt711_headset_detect()
200 ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, in rt711_headset_detect()
206 ret = regmap_read(rt711->regmap, reg, &jack_status); in rt711_headset_detect()
217 rt711->jack_type = SND_JACK_HEADPHONE; in rt711_headset_detect()
220 rt711->jack_type = SND_JACK_HEADSET; in rt711_headset_detect()
238 struct rt711_priv *rt711 = in rt711_jack_detect_handler() local
243 if (!rt711->hs_jack) in rt711_jack_detect_handler()
246 if (!snd_soc_card_is_instantiated(rt711->component->card)) in rt711_jack_detect_handler()
249 if (pm_runtime_status_suspended(rt711->slave->dev.parent)) { in rt711_jack_detect_handler()
250 dev_dbg(&rt711->slave->dev, in rt711_jack_detect_handler()
257 ret = regmap_read(rt711->regmap, reg, &jack_status); in rt711_jack_detect_handler()
264 if (rt711->jack_type == 0) { in rt711_jack_detect_handler()
265 ret = rt711_headset_detect(rt711); in rt711_jack_detect_handler()
268 if (rt711->jack_type == SND_JACK_HEADSET) in rt711_jack_detect_handler()
269 btn_type = rt711_button_detect(rt711); in rt711_jack_detect_handler()
270 } else if (rt711->jack_type == SND_JACK_HEADSET) { in rt711_jack_detect_handler()
272 btn_type = rt711_button_detect(rt711); in rt711_jack_detect_handler()
276 rt711->jack_type = 0; in rt711_jack_detect_handler()
279 dev_dbg(&rt711->slave->dev, in rt711_jack_detect_handler()
280 "in %s, jack_type=0x%x\n", __func__, rt711->jack_type); in rt711_jack_detect_handler()
281 dev_dbg(&rt711->slave->dev, in rt711_jack_detect_handler()
284 snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, in rt711_jack_detect_handler()
291 snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, in rt711_jack_detect_handler()
297 &rt711->jack_btn_check_work, msecs_to_jiffies(200)); in rt711_jack_detect_handler()
308 struct rt711_priv *rt711 = container_of(work, struct rt711_priv, in rt711_btn_check_handler() local
314 ret = regmap_read(rt711->regmap, reg, &jack_status); in rt711_btn_check_handler()
320 if (rt711->jack_type == SND_JACK_HEADSET) { in rt711_btn_check_handler()
322 btn_type = rt711_button_detect(rt711); in rt711_btn_check_handler()
325 rt711->jack_type = 0; in rt711_btn_check_handler()
329 ret = rt711_index_read(rt711->regmap, RT711_VENDOR_REG, in rt711_btn_check_handler()
337 dev_dbg(&rt711->slave->dev, in rt711_btn_check_handler()
339 snd_soc_jack_report(rt711->hs_jack, rt711->jack_type | btn_type, in rt711_btn_check_handler()
346 snd_soc_jack_report(rt711->hs_jack, rt711->jack_type, in rt711_btn_check_handler()
352 &rt711->jack_btn_check_work, msecs_to_jiffies(200)); in rt711_btn_check_handler()
361 static void rt711_jack_init(struct rt711_priv *rt711) in rt711_jack_init() argument
364 snd_soc_component_get_dapm(rt711->component); in rt711_jack_init()
366 mutex_lock(&rt711->calibrate_mutex); in rt711_jack_init()
369 regmap_write(rt711->regmap, in rt711_jack_init()
372 if (rt711->hs_jack) { in rt711_jack_init()
374 regmap_write(rt711->regmap, in rt711_jack_init()
376 regmap_write(rt711->regmap, in rt711_jack_init()
378 regmap_write(rt711->regmap, in rt711_jack_init()
380 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
382 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
385 switch (rt711->jd_src) { in rt711_jack_init()
390 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
395 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
401 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
406 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
412 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
415 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
420 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
425 rt711_index_update_bits(rt711->regmap, RT711_VENDOR_REG, in rt711_jack_init()
431 dev_warn(rt711->component->dev, "%s: Wrong JD source\n", __func__); in rt711_jack_init()
435 dev_dbg(&rt711->slave->dev, "in %s enable\n", __func__); in rt711_jack_init()
438 &rt711->jack_detect_work, msecs_to_jiffies(250)); in rt711_jack_init()
440 regmap_write(rt711->regmap, in rt711_jack_init()
442 regmap_write(rt711->regmap, in rt711_jack_init()
444 regmap_write(rt711->regmap, in rt711_jack_init()
447 dev_dbg(&rt711->slave->dev, "in %s disable\n", __func__); in rt711_jack_init()
452 regmap_write(rt711->regmap, in rt711_jack_init()
454 mutex_unlock(&rt711->calibrate_mutex); in rt711_jack_init()
460 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_set_jack_detect() local
463 rt711->hs_jack = hs_jack; in rt711_set_jack_detect()
466 if (!rt711->first_hw_init) in rt711_set_jack_detect()
481 rt711_jack_init(rt711); in rt711_set_jack_detect()
489 static void rt711_get_gain(struct rt711_priv *rt711, unsigned int addr_h, in rt711_get_gain() argument
495 regmap_read(rt711->regmap, addr_l, r_val); in rt711_get_gain()
500 regmap_read(rt711->regmap, addr_h, l_val); in rt711_get_gain()
512 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_set_amp_gain_put() local
517 mutex_lock(&rt711->calibrate_mutex); in rt711_set_amp_gain_put()
527 rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); in rt711_set_amp_gain_put()
548 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
574 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
576 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
581 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
586 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
595 rt711_get_gain(rt711, addr_h, addr_l, val_h, in rt711_set_amp_gain_put()
602 regmap_write(rt711->regmap, in rt711_set_amp_gain_put()
605 mutex_unlock(&rt711->calibrate_mutex); in rt711_set_amp_gain_put()
613 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_set_amp_gain_get() local
627 rt711_get_gain(rt711, addr_h, addr_l, val_h, &read_rl, &read_ll); in rt711_set_amp_gain_get()
688 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_mux_get() local
701 ret = regmap_read(rt711->regmap, reg, &val); in rt711_mux_get()
720 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_mux_put() local
740 ret = regmap_read(rt711->regmap, reg, &val2); in rt711_mux_put()
754 regmap_write(rt711->regmap, reg, val); in rt711_mux_put()
789 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_dac_surround_event() local
795 regmap_write(rt711->regmap, in rt711_dac_surround_event()
799 regmap_write(rt711->regmap, in rt711_dac_surround_event()
804 regmap_write(rt711->regmap, in rt711_dac_surround_event()
808 regmap_write(rt711->regmap, in rt711_dac_surround_event()
820 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_adc_09_event() local
824 regmap_write(rt711->regmap, in rt711_adc_09_event()
828 regmap_write(rt711->regmap, in rt711_adc_09_event()
840 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_adc_08_event() local
844 regmap_write(rt711->regmap, in rt711_adc_08_event()
848 regmap_write(rt711->regmap, in rt711_adc_08_event()
906 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_set_bias_level() local
911 regmap_write(rt711->regmap, in rt711_set_bias_level()
918 mutex_lock(&rt711->calibrate_mutex); in rt711_set_bias_level()
919 regmap_write(rt711->regmap, in rt711_set_bias_level()
922 mutex_unlock(&rt711->calibrate_mutex); in rt711_set_bias_level()
932 static int rt711_parse_dt(struct rt711_priv *rt711, struct device *dev) in rt711_parse_dt() argument
935 &rt711->jd_src); in rt711_parse_dt()
942 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_probe() local
945 rt711_parse_dt(rt711, &rt711->slave->dev); in rt711_probe()
946 rt711->component = component; in rt711_probe()
948 if (!rt711->first_hw_init) in rt711_probe()
990 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_pcm_hw_params() local
1003 if (!rt711->slave) in rt711_pcm_hw_params()
1020 retval = sdw_stream_add_slave(rt711->slave, &stream_config, in rt711_pcm_hw_params()
1057 regmap_write(rt711->regmap, RT711_DAC_FORMAT_H, val); in rt711_pcm_hw_params()
1058 regmap_write(rt711->regmap, RT711_ADC1_FORMAT_H, val); in rt711_pcm_hw_params()
1059 regmap_write(rt711->regmap, RT711_ADC2_FORMAT_H, val); in rt711_pcm_hw_params()
1068 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); in rt711_pcm_hw_free() local
1072 if (!rt711->slave) in rt711_pcm_hw_free()
1075 sdw_stream_remove_slave(rt711->slave, sdw_stream); in rt711_pcm_hw_free()
1134 struct rt711_priv *rt711 = dev_get_drvdata(dev); in rt711_clock_config() local
1137 clk_freq = (rt711->params.curr_dr_freq >> 1); in rt711_clock_config()
1162 regmap_write(rt711->regmap, 0xe0, value); in rt711_clock_config()
1163 regmap_write(rt711->regmap, 0xf0, value); in rt711_clock_config()
1172 struct rt711_priv *rt711 = in rt711_calibration_work() local
1175 rt711_calibration(rt711); in rt711_calibration_work()
1181 struct rt711_priv *rt711; in rt711_init() local
1184 rt711 = devm_kzalloc(dev, sizeof(*rt711), GFP_KERNEL); in rt711_init()
1185 if (!rt711) in rt711_init()
1188 dev_set_drvdata(dev, rt711); in rt711_init()
1189 rt711->slave = slave; in rt711_init()
1190 rt711->sdw_regmap = sdw_regmap; in rt711_init()
1191 rt711->regmap = regmap; in rt711_init()
1193 regcache_cache_only(rt711->regmap, true); in rt711_init()
1195 mutex_init(&rt711->calibrate_mutex); in rt711_init()
1196 mutex_init(&rt711->disable_irq_lock); in rt711_init()
1198 INIT_DELAYED_WORK(&rt711->jack_detect_work, rt711_jack_detect_handler); in rt711_init()
1199 INIT_DELAYED_WORK(&rt711->jack_btn_check_work, rt711_btn_check_handler); in rt711_init()
1200 INIT_WORK(&rt711->calibration_work, rt711_calibration_work); in rt711_init()
1206 rt711->hw_init = false; in rt711_init()
1207 rt711->first_hw_init = false; in rt711_init()
1210 rt711->jd_src = RT711_JD2; in rt711_init()
1241 struct rt711_priv *rt711 = dev_get_drvdata(dev); in rt711_io_init() local
1243 rt711->disable_irq = false; in rt711_io_init()
1245 if (rt711->hw_init) in rt711_io_init()
1248 regcache_cache_only(rt711->regmap, false); in rt711_io_init()
1249 if (rt711->first_hw_init) in rt711_io_init()
1250 regcache_cache_bypass(rt711->regmap, true); in rt711_io_init()
1255 if (!rt711->first_hw_init) in rt711_io_init()
1261 rt711_reset(rt711->regmap); in rt711_io_init()
1264 regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0); in rt711_io_init()
1267 regmap_write(rt711->regmap, RT711_SET_PIN_MIC2, 0x25); in rt711_io_init()
1268 regmap_write(rt711->regmap, RT711_SET_PIN_HP, 0xc0); in rt711_io_init()
1269 regmap_write(rt711->regmap, RT711_SET_PIN_DMIC1, 0x20); in rt711_io_init()
1270 regmap_write(rt711->regmap, RT711_SET_PIN_DMIC2, 0x20); in rt711_io_init()
1271 regmap_write(rt711->regmap, RT711_SET_PIN_LINE1, 0x20); in rt711_io_init()
1272 regmap_write(rt711->regmap, RT711_SET_PIN_LINE2, 0x20); in rt711_io_init()
1275 regmap_write(rt711->regmap, RT711_SET_GAIN_HP_H, 0xa080); in rt711_io_init()
1276 regmap_write(rt711->regmap, RT711_SET_GAIN_HP_H, 0x9080); in rt711_io_init()
1277 regmap_write(rt711->regmap, RT711_SET_GAIN_ADC2_H, 0x6080); in rt711_io_init()
1278 regmap_write(rt711->regmap, RT711_SET_GAIN_ADC2_H, 0x5080); in rt711_io_init()
1279 regmap_write(rt711->regmap, RT711_SET_GAIN_ADC1_H, 0x6080); in rt711_io_init()
1280 regmap_write(rt711->regmap, RT711_SET_GAIN_ADC1_H, 0x5080); in rt711_io_init()
1283 regmap_write(rt711->regmap, 0x4f12, 0x91); in rt711_io_init()
1284 regmap_write(rt711->regmap, 0x4e12, 0xd6); in rt711_io_init()
1285 regmap_write(rt711->regmap, 0x4d12, 0x11); in rt711_io_init()
1286 regmap_write(rt711->regmap, 0x4c12, 0x20); in rt711_io_init()
1287 regmap_write(rt711->regmap, 0x4f13, 0x91); in rt711_io_init()
1288 regmap_write(rt711->regmap, 0x4e13, 0xd6); in rt711_io_init()
1289 regmap_write(rt711->regmap, 0x4d13, 0x11); in rt711_io_init()
1290 regmap_write(rt711->regmap, 0x4c13, 0x21); in rt711_io_init()
1291 regmap_write(rt711->regmap, 0x4c21, 0xf0); in rt711_io_init()
1292 regmap_write(rt711->regmap, 0x4d21, 0x11); in rt711_io_init()
1293 regmap_write(rt711->regmap, 0x4e21, 0x11); in rt711_io_init()
1294 regmap_write(rt711->regmap, 0x4f21, 0x01); in rt711_io_init()
1297 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_io_init()
1301 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_io_init()
1303 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_io_init()
1305 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_io_init()
1307 rt711_index_write(rt711->regmap, RT711_VENDOR_REG, in rt711_io_init()
1311 regmap_write(rt711->regmap, RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3); in rt711_io_init()
1313 if (rt711->first_hw_init) in rt711_io_init()
1314 rt711_calibration(rt711); in rt711_io_init()
1316 schedule_work(&rt711->calibration_work); in rt711_io_init()
1322 if (rt711->hs_jack) in rt711_io_init()
1323 rt711_jack_init(rt711); in rt711_io_init()
1325 if (rt711->first_hw_init) { in rt711_io_init()
1326 regcache_cache_bypass(rt711->regmap, false); in rt711_io_init()
1327 regcache_mark_dirty(rt711->regmap); in rt711_io_init()
1329 rt711->first_hw_init = true; in rt711_io_init()
1332 rt711->hw_init = true; in rt711_io_init()