Lines Matching refs:rt700
3 // rt700.c -- rt700 ALSA SoC audio driver
29 #include "rt700.h"
60 static unsigned int rt700_button_detect(struct rt700_priv *rt700)
65 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE1, &val80);
68 ret = rt700_index_read(rt700->regmap, RT700_IRQ_FLAG_TABLE2, &val81);
105 static int rt700_headset_detect(struct rt700_priv *rt700)
111 ret = rt700_index_read(rt700->regmap,
121 ret = rt700_index_read(rt700->regmap,
127 ret = regmap_read(rt700->regmap, reg, &jack_status);
136 rt700->jack_type = SND_JACK_HEADPHONE;
139 rt700->jack_type = SND_JACK_HEADSET;
157 struct rt700_priv *rt700 =
162 if (!rt700->hs_jack)
165 if (!rt700->component->card->instantiated)
169 ret = regmap_read(rt700->regmap, reg, &jack_status);
176 if (rt700->jack_type == 0) {
177 ret = rt700_headset_detect(rt700);
180 if (rt700->jack_type == SND_JACK_HEADSET)
181 btn_type = rt700_button_detect(rt700);
182 } else if (rt700->jack_type == SND_JACK_HEADSET) {
184 btn_type = rt700_button_detect(rt700);
188 rt700->jack_type = 0;
191 dev_dbg(&rt700->slave->dev,
192 "in %s, jack_type=0x%x\n", __func__, rt700->jack_type);
193 dev_dbg(&rt700->slave->dev,
196 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type,
203 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type,
209 &rt700->jack_btn_check_work, msecs_to_jiffies(200));
220 struct rt700_priv *rt700 = container_of(work, struct rt700_priv,
226 ret = regmap_read(rt700->regmap, reg, &jack_status);
232 if (rt700->jack_type == SND_JACK_HEADSET) {
234 btn_type = rt700_button_detect(rt700);
237 rt700->jack_type = 0;
241 ret = rt700_index_read(rt700->regmap, RT700_COMBO_JACK_AUTO_CTL2, ®);
248 dev_dbg(&rt700->slave->dev,
250 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type | btn_type,
257 snd_soc_jack_report(rt700->hs_jack, rt700->jack_type,
263 &rt700->jack_btn_check_work, msecs_to_jiffies(200));
272 static void rt700_jack_init(struct rt700_priv *rt700)
275 snd_soc_component_get_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);
319 rt700->hs_jack = hs_jack;
321 if (!rt700->hw_init) {
322 dev_dbg(&rt700->slave->dev,
327 rt700_jack_init(rt700);
332 static void rt700_get_gain(struct rt700_priv *rt700, unsigned int addr_h,
338 regmap_read(rt700->regmap, addr_l, r_val);
343 regmap_read(rt700->regmap, addr_h, l_val);
355 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
368 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
388 regmap_write(rt700->regmap,
412 regmap_write(rt700->regmap,
414 regmap_write(rt700->regmap,
419 regmap_write(rt700->regmap,
424 regmap_write(rt700->regmap,
433 rt700_get_gain(rt700, addr_h, addr_l, val_h,
440 regmap_write(rt700->regmap,
449 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
462 rt700_get_gain(rt700, addr_h, addr_l, val_h, &read_rl, &read_ll);
515 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
530 ret = regmap_read(rt700->regmap, reg, &val);
546 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
568 ret = regmap_read(rt700->regmap, reg, &val2);
579 regmap_write(rt700->regmap, reg, val);
626 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
630 regmap_write(rt700->regmap,
634 regmap_write(rt700->regmap,
646 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
650 regmap_write(rt700->regmap,
654 regmap_write(rt700->regmap,
666 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
670 regmap_write(rt700->regmap,
674 regmap_write(rt700->regmap,
686 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
690 regmap_write(rt700->regmap,
694 regmap_write(rt700->regmap,
706 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
713 regmap_write(rt700->regmap,
718 regmap_write(rt700->regmap,
731 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
738 regmap_write(rt700->regmap,
743 regmap_write(rt700->regmap,
810 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
812 rt700->component = component;
822 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
827 regmap_write(rt700->regmap,
834 regmap_write(rt700->regmap,
896 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
910 if (!rt700->slave)
943 retval = sdw_stream_add_slave(rt700->slave, &stream_config,
980 regmap_write(rt700->regmap, RT700_DAC_FORMAT_H, val);
981 regmap_write(rt700->regmap, RT700_ADC_FORMAT_H, val);
990 struct rt700_priv *rt700 = snd_soc_component_get_drvdata(component);
994 if (!rt700->slave)
997 sdw_stream_remove_slave(rt700->slave, stream->sdw_stream);
1014 .name = "rt700-aif1",
1033 .name = "rt700-aif2",
1063 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1066 clk_freq = (rt700->params.curr_dr_freq >> 1);
1091 regmap_write(rt700->regmap, 0xe0, value);
1092 regmap_write(rt700->regmap, 0xf0, value);
1103 struct rt700_priv *rt700;
1106 rt700 = devm_kzalloc(dev, sizeof(*rt700), GFP_KERNEL);
1107 if (!rt700)
1110 dev_set_drvdata(dev, rt700);
1111 rt700->slave = slave;
1112 rt700->sdw_regmap = sdw_regmap;
1113 rt700->regmap = regmap;
1119 rt700->hw_init = false;
1120 rt700->first_hw_init = false;
1134 struct rt700_priv *rt700 = dev_get_drvdata(dev);
1136 if (rt700->hw_init)
1139 if (rt700->first_hw_init) {
1140 regcache_cache_only(rt700->regmap, false);
1141 regcache_cache_bypass(rt700->regmap, true);
1147 if (!rt700->first_hw_init) {
1164 regmap_write(rt700->regmap, 0xff01, 0x0000);
1165 regmap_write(rt700->regmap, 0x7520, 0x001a);
1166 regmap_write(rt700->regmap, 0x7420, 0xc003);
1169 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
1171 regmap_write(rt700->regmap, RT700_SET_PIN_HP, 0x40);
1172 regmap_write(rt700->regmap, RT700_SET_PIN_SPK, 0x40);
1173 regmap_write(rt700->regmap, RT700_SET_EAPD_SPK, RT700_EAPD_HIGH);
1174 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC1, 0x20);
1175 regmap_write(rt700->regmap, RT700_SET_PIN_DMIC2, 0x20);
1176 regmap_write(rt700->regmap, RT700_SET_PIN_MIC2, 0x20);
1179 regmap_write(rt700->regmap, 0x4f12, 0x91);
1180 regmap_write(rt700->regmap, 0x4e12, 0xd6);
1181 regmap_write(rt700->regmap, 0x4d12, 0x11);
1182 regmap_write(rt700->regmap, 0x4c12, 0x20);
1183 regmap_write(rt700->regmap, 0x4f13, 0x91);
1184 regmap_write(rt700->regmap, 0x4e13, 0xd6);
1185 regmap_write(rt700->regmap, 0x4d13, 0x11);
1186 regmap_write(rt700->regmap, 0x4c13, 0x21);
1188 regmap_write(rt700->regmap, 0x4f19, 0x02);
1189 regmap_write(rt700->regmap, 0x4e19, 0xa1);
1190 regmap_write(rt700->regmap, 0x4d19, 0x90);
1191 regmap_write(rt700->regmap, 0x4c19, 0x80);
1194 regmap_write(rt700->regmap, 0x371b, 0x40);
1195 regmap_write(rt700->regmap, 0x731b, 0xb0);
1196 regmap_write(rt700->regmap, 0x839b, 0x00);
1199 rt700_index_write(rt700->regmap, 0x4a, 0x201b);
1200 rt700_index_write(rt700->regmap, 0x45, 0x5089);
1201 rt700_index_write(rt700->regmap, 0x6b, 0x5064);
1202 rt700_index_write(rt700->regmap, 0x48, 0xd249);
1205 regmap_write(rt700->regmap, RT700_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
1207 if (!rt700->first_hw_init) {
1208 INIT_DELAYED_WORK(&rt700->jack_detect_work,
1210 INIT_DELAYED_WORK(&rt700->jack_btn_check_work,
1218 if (rt700->hs_jack)
1219 rt700_jack_init(rt700);
1221 if (rt700->first_hw_init) {
1222 regcache_cache_bypass(rt700->regmap, false);
1223 regcache_mark_dirty(rt700->regmap);
1225 rt700->first_hw_init = true;
1228 rt700->hw_init = true;