Lines Matching refs:rt700
3 // rt700.c -- rt700 ALSA SoC audio driver
30 #include "rt700.h"
61 static unsigned int rt700_button_detect(struct rt700_priv *rt700)
66 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE1, &val80);
69 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE2, &val81);
106 static int rt700_headset_detect(struct rt700_priv *rt700)
112 ret = rt700_index_read(rt700->regmap,
122 ret = rt700_index_read(rt700->regmap,
128 ret = regmap_read(rt700->regmap, reg, &jack_status);
137 rt700->jack_type = SND_JACK_HEADPHONE;
140 rt700->jack_type = SND_JACK_HEADSET;
158 struct rt700_priv *rt700 =
163 if (!rt700->hs_jack)
166 if (!snd_soc_card_is_instantiated(rt700->component->card))
170 ret = regmap_read(rt700->regmap, reg, &jack_status);
177 if (rt700->jack_type == 0) {
178 ret = rt700_headset_detect(rt700);
181 if (rt700->jack_type == SND_JACK_HEADSET)
182 btn_type = rt700_button_detect(rt700);
183 } else if (rt700->jack_type == SND_JACK_HEADSET) {
185 btn_type = rt700_button_detect(rt700);
189 rt700->jack_type = 0;
192 dev_dbg(&rt700->slave->dev,
193 "in %s, jack_type=0x%x\n", __func__, rt700->jack_type);
194 dev_dbg(&rt700->slave->dev,
197 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type,
204 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type,
210 &rt700->jack_btn_check_work, msecs_to_jiffies(200));
221 struct rt700_priv *rt700 = container_of(work, struct rt700_priv,
227 ret = regmap_read(rt700->regmap, reg, &jack_status);
233 if (rt700->jack_type == SND_JACK_HEADSET) {
235 btn_type = rt700_button_detect(rt700);
238 rt700->jack_type = 0;
242 ret = rt700_index_read(rt700->regmap, RT700_COMBO_JACK_AUTO_CTL2, ®);
249 dev_dbg(&rt700->slave->dev,
251 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type,
258 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type,
264 &rt700->jack_btn_check_work, msecs_to_jiffies(200));
273 static void rt700_jack_init(struct rt700_priv *rt700)
275 struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt700->component);
279 regmap_write(rt700->regmap,
282 if (rt700->hs_jack) {
284 regmap_write(rt700->regmap,
286 regmap_write(rt700->regmap,
288 regmap_write(rt700->regmap,
290 rt700_index_write(rt700->regmap, 0x10, 0x2420);
291 rt700_index_write(rt700->regmap, 0x19, 0x2e11);
293 dev_dbg(&rt700->slave->dev, "in %s enable\n", __func__);
296 &rt700->jack_detect_work, msecs_to_jiffies(250));
298 regmap_write(rt700->regmap,
300 regmap_write(rt700->regmap,
302 regmap_write(rt700->regmap,
305 dev_dbg(&rt700->slave->dev, "in %s disable\n", __func__);
310 regmap_write(rt700->regmap,
317 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
320 rt700->hs_jack = hs_jack;
323 if (!rt700->first_hw_init)
338 rt700_jack_init(rt700);
345 static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h,
351 regmap_read(rt700->regmap, addr_l, r_val);
356 regmap_read(rt700->regmap, addr_h, l_val);
367 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
380 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
400 regmap_write(rt700->regmap,
424 regmap_write(rt700->regmap,
426 regmap_write(rt700->regmap,
431 regmap_write(rt700->regmap,
436 regmap_write(rt700->regmap,
445 rt700_get_gain(rt700, addr_h, addr_l, val_h,
452 regmap_write(rt700->regmap,
461 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
474 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
526 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
541 ret = regmap_read(rt700->regmap, reg, &val);
555 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
577 ret = regmap_read(rt700->regmap, reg, &val2);
588 regmap_write(rt700->regmap, reg, val);
635 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
639 regmap_write(rt700->regmap,
643 regmap_write(rt700->regmap,
655 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
659 regmap_write(rt700->regmap,
663 regmap_write(rt700->regmap,
675 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
679 regmap_write(rt700->regmap,
683 regmap_write(rt700->regmap,
695 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
699 regmap_write(rt700->regmap,
703 regmap_write(rt700->regmap,
715 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
722 regmap_write(rt700->regmap,
727 regmap_write(rt700->regmap,
740 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
747 regmap_write(rt700->regmap,
752 regmap_write(rt700->regmap,
819 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
822 rt700->component = component;
824 if (!rt700->first_hw_init)
838 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
843 regmap_write(rt700->regmap,
850 regmap_write(rt700->regmap,
894 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
907 if (!rt700->slave)
930 retval = sdw_stream_add_slave(rt700->slave, &stream_config,
967 regmap_write(rt700->regmap, RT700_DAC_FORMAT_H, val);
968 regmap_write(rt700->regmap, RT700_ADC_FORMAT_H, val);
977 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
981 if (!rt700->slave)
984 sdw_stream_remove_slave(rt700->slave, sdw_stream);
1001 .name = "rt700-aif1",
1020 .name = "rt700-aif2",
1050 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1053 clk_freq = (rt700->params.curr_dr_freq >> 1);
1078 regmap_write(rt700->regmap, 0xe0, value);
1079 regmap_write(rt700->regmap, 0xf0, value);
1090 struct rt700_priv *rt700;
1093 rt700 = devm_kzalloc(dev, sizeof(*rt700), GFP_KERNEL);
1094 if (!rt700)
1097 dev_set_drvdata(dev, rt700);
1098 rt700->slave = slave;
1099 rt700->sdw_regmap = sdw_regmap;
1100 rt700->regmap = regmap;
1102 regcache_cache_only(rt700->regmap, true);
1104 mutex_init(&rt700->disable_irq_lock);
1106 INIT_DELAYED_WORK(&rt700->jack_detect_work,
1108 INIT_DELAYED_WORK(&rt700->jack_btn_check_work,
1115 rt700->hw_init = false;
1116 rt700->first_hw_init = false;
1146 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1148 rt700->disable_irq = false;
1150 if (rt700->hw_init)
1153 regcache_cache_only(rt700->regmap, false);
1154 if (rt700->first_hw_init)
1155 regcache_cache_bypass(rt700->regmap, true);
1160 if (!rt700->first_hw_init)
1167 regmap_write(rt700->regmap, 0xff01, 0x0000);
1168 regmap_write(rt700->regmap, 0x7520, 0x001a);
1169 regmap_write(rt700->regmap, 0x7420, 0xc003);
1172 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
1174 regmap_write(rt700->regmap, RT700_SET_PIN_HP, 0x40);
1175 regmap_write(rt700->regmap, RT700_SET_PIN_SPK, 0x40);
1176 regmap_write(rt700->regmap, RT700_SET_EAPD_SPK, RT700_EAPD_HIGH);
1177 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC1, 0x20);
1178 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC2, 0x20);
1179 regmap_write(rt700->regmap, RT700_SET_PIN_MIC2, 0x20);
1182 regmap_write(rt700->regmap, 0x4f12, 0x91);
1183 regmap_write(rt700->regmap, 0x4e12, 0xd6);
1184 regmap_write(rt700->regmap, 0x4d12, 0x11);
1185 regmap_write(rt700->regmap, 0x4c12, 0x20);
1186 regmap_write(rt700->regmap, 0x4f13, 0x91);
1187 regmap_write(rt700->regmap, 0x4e13, 0xd6);
1188 regmap_write(rt700->regmap, 0x4d13, 0x11);
1189 regmap_write(rt700->regmap, 0x4c13, 0x21);
1191 regmap_write(rt700->regmap, 0x4f19, 0x02);
1192 regmap_write(rt700->regmap, 0x4e19, 0xa1);
1193 regmap_write(rt700->regmap, 0x4d19, 0x90);
1194 regmap_write(rt700->regmap, 0x4c19, 0x80);
1197 regmap_write(rt700->regmap, 0x371b, 0x40);
1198 regmap_write(rt700->regmap, 0x731b, 0xb0);
1199 regmap_write(rt700->regmap, 0x839b, 0x00);
1202 rt700_index_write(rt700->regmap, 0x4a, 0x201b);
1203 rt700_index_write(rt700->regmap, 0x45, 0x5089);
1204 rt700_index_write(rt700->regmap, 0x6b, 0x5064);
1205 rt700_index_write(rt700->regmap, 0x48, 0xd249);
1208 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
1214 if (rt700->hs_jack)
1215 rt700_jack_init(rt700);
1217 if (rt700->first_hw_init) {
1218 regcache_cache_bypass(rt700->regmap, false);
1219 regcache_mark_dirty(rt700->regmap);
1221 rt700->first_hw_init = true;
1224 rt700->hw_init = true;