Lines Matching defs: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, &reg);
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)
276 snd_soc_component_get_dapm(rt700->component);
280 regmap_write(rt700->regmap,
283 if (rt700->hs_jack) {
285 regmap_write(rt700->regmap,
287 regmap_write(rt700->regmap,
289 regmap_write(rt700->regmap,
291 rt700_index_write(rt700->regmap, 0x10, 0x2420);
292 rt700_index_write(rt700->regmap, 0x19, 0x2e11);
294 dev_dbg(&rt700->slave->dev, "in %s enable\n", __func__);
297 &rt700->jack_detect_work, msecs_to_jiffies(250));
299 regmap_write(rt700->regmap,
301 regmap_write(rt700->regmap,
303 regmap_write(rt700->regmap,
306 dev_dbg(&rt700->slave->dev, "in %s disable\n", __func__);
311 regmap_write(rt700->regmap,
318 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
321 rt700->hs_jack = hs_jack;
324 if (!rt700->first_hw_init)
339 rt700_jack_init(rt700);
347 static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h,
353 regmap_read(rt700->regmap, addr_l, r_val);
358 regmap_read(rt700->regmap, addr_h, l_val);
370 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
383 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
403 regmap_write(rt700->regmap,
427 regmap_write(rt700->regmap,
429 regmap_write(rt700->regmap,
434 regmap_write(rt700->regmap,
439 regmap_write(rt700->regmap,
448 rt700_get_gain(rt700, addr_h, addr_l, val_h,
455 regmap_write(rt700->regmap,
464 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
477 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
530 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
545 ret = regmap_read(rt700->regmap, reg, &val);
561 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
583 ret = regmap_read(rt700->regmap, reg, &val2);
594 regmap_write(rt700->regmap, reg, val);
641 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
645 regmap_write(rt700->regmap,
649 regmap_write(rt700->regmap,
661 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
665 regmap_write(rt700->regmap,
669 regmap_write(rt700->regmap,
681 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
685 regmap_write(rt700->regmap,
689 regmap_write(rt700->regmap,
701 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
705 regmap_write(rt700->regmap,
709 regmap_write(rt700->regmap,
721 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
728 regmap_write(rt700->regmap,
733 regmap_write(rt700->regmap,
746 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
753 regmap_write(rt700->regmap,
758 regmap_write(rt700->regmap,
825 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
828 rt700->component = component;
830 if (!rt700->first_hw_init)
845 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
850 regmap_write(rt700->regmap,
857 regmap_write(rt700->regmap,
901 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
914 if (!rt700->slave)
937 retval = sdw_stream_add_slave(rt700->slave, &stream_config,
974 regmap_write(rt700->regmap, RT700_DAC_FORMAT_H, val);
975 regmap_write(rt700->regmap, RT700_ADC_FORMAT_H, val);
984 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
988 if (!rt700->slave)
991 sdw_stream_remove_slave(rt700->slave, sdw_stream);
1008 .name = "rt700-aif1",
1027 .name = "rt700-aif2",
1057 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1060 clk_freq = (rt700->params.curr_dr_freq >> 1);
1085 regmap_write(rt700->regmap, 0xe0, value);
1086 regmap_write(rt700->regmap, 0xf0, value);
1097 struct rt700_priv *rt700;
1100 rt700 = devm_kzalloc(dev, sizeof(*rt700), GFP_KERNEL);
1101 if (!rt700)
1104 dev_set_drvdata(dev, rt700);
1105 rt700->slave = slave;
1106 rt700->sdw_regmap = sdw_regmap;
1107 rt700->regmap = regmap;
1109 regcache_cache_only(rt700->regmap, true);
1111 mutex_init(&rt700->disable_irq_lock);
1113 INIT_DELAYED_WORK(&rt700->jack_detect_work,
1115 INIT_DELAYED_WORK(&rt700->jack_btn_check_work,
1122 rt700->hw_init = false;
1123 rt700->first_hw_init = false;
1153 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1155 rt700->disable_irq = false;
1157 if (rt700->hw_init)
1160 regcache_cache_only(rt700->regmap, false);
1161 if (rt700->first_hw_init)
1162 regcache_cache_bypass(rt700->regmap, true);
1167 if (!rt700->first_hw_init)
1174 regmap_write(rt700->regmap, 0xff01, 0x0000);
1175 regmap_write(rt700->regmap, 0x7520, 0x001a);
1176 regmap_write(rt700->regmap, 0x7420, 0xc003);
1179 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
1181 regmap_write(rt700->regmap, RT700_SET_PIN_HP, 0x40);
1182 regmap_write(rt700->regmap, RT700_SET_PIN_SPK, 0x40);
1183 regmap_write(rt700->regmap, RT700_SET_EAPD_SPK, RT700_EAPD_HIGH);
1184 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC1, 0x20);
1185 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC2, 0x20);
1186 regmap_write(rt700->regmap, RT700_SET_PIN_MIC2, 0x20);
1189 regmap_write(rt700->regmap, 0x4f12, 0x91);
1190 regmap_write(rt700->regmap, 0x4e12, 0xd6);
1191 regmap_write(rt700->regmap, 0x4d12, 0x11);
1192 regmap_write(rt700->regmap, 0x4c12, 0x20);
1193 regmap_write(rt700->regmap, 0x4f13, 0x91);
1194 regmap_write(rt700->regmap, 0x4e13, 0xd6);
1195 regmap_write(rt700->regmap, 0x4d13, 0x11);
1196 regmap_write(rt700->regmap, 0x4c13, 0x21);
1198 regmap_write(rt700->regmap, 0x4f19, 0x02);
1199 regmap_write(rt700->regmap, 0x4e19, 0xa1);
1200 regmap_write(rt700->regmap, 0x4d19, 0x90);
1201 regmap_write(rt700->regmap, 0x4c19, 0x80);
1204 regmap_write(rt700->regmap, 0x371b, 0x40);
1205 regmap_write(rt700->regmap, 0x731b, 0xb0);
1206 regmap_write(rt700->regmap, 0x839b, 0x00);
1209 rt700_index_write(rt700->regmap, 0x4a, 0x201b);
1210 rt700_index_write(rt700->regmap, 0x45, 0x5089);
1211 rt700_index_write(rt700->regmap, 0x6b, 0x5064);
1212 rt700_index_write(rt700->regmap, 0x48, 0xd249);
1215 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
1221 if (rt700->hs_jack)
1222 rt700_jack_init(rt700);
1224 if (rt700->first_hw_init) {
1225 regcache_cache_bypass(rt700->regmap, false);
1226 regcache_mark_dirty(rt700->regmap);
1228 rt700->first_hw_init = true;
1231 rt700->hw_init = true;