Lines Matching +full:codec +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * CM9825 HD-audio codec
18 #define CM9825_VERB_SET_HPF_1 0x781
19 #define CM9825_VERB_SET_HPF_2 0x785
20 #define CM9825_VERB_SET_PLL 0x7a0
21 #define CM9825_VERB_SET_NEG 0x7a1
22 #define CM9825_VERB_SET_ADCL 0x7a2
23 #define CM9825_VERB_SET_DACL 0x7a3
24 #define CM9825_VERB_SET_MBIAS 0x7a4
25 #define CM9825_VERB_SET_VNEG 0x7a8
26 #define CM9825_VERB_SET_D2S 0x7a9
27 #define CM9825_VERB_SET_DACTRL 0x7aa
28 #define CM9825_VERB_SET_PDNEG 0x7ac
29 #define CM9825_VERB_SET_VDO 0x7ad
30 #define CM9825_VERB_SET_CDALR 0x7b0
31 #define CM9825_VERB_SET_MTCBA 0x7b1
32 #define CM9825_VERB_SET_OTP 0x7b2
33 #define CM9825_VERB_SET_OCP 0x7b3
34 #define CM9825_VERB_SET_GAD 0x7b4
35 #define CM9825_VERB_SET_TMOD 0x7b5
36 #define CM9825_VERB_SET_SNR 0x7b6
44 struct hda_codec *codec; member
51 {0x43, CM9825_VERB_SET_D2S, 0x62}, /* depop */
52 {0x43, CM9825_VERB_SET_PLL, 0x01}, /* PLL set */
53 {0x43, CM9825_VERB_SET_NEG, 0xc2}, /* NEG set */
54 {0x43, CM9825_VERB_SET_ADCL, 0x00}, /* ADC */
55 {0x43, CM9825_VERB_SET_DACL, 0x02}, /* DACL */
56 {0x43, CM9825_VERB_SET_VNEG, 0x50}, /* VOL NEG */
57 {0x43, CM9825_VERB_SET_MBIAS, 0x00}, /* MBIAS */
58 {0x43, CM9825_VERB_SET_PDNEG, 0x04}, /* SEL OSC */
59 {0x43, CM9825_VERB_SET_CDALR, 0xf6}, /* Class D */
60 {0x43, CM9825_VERB_SET_OTP, 0xcd}, /* OTP set */
66 {0x34, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, /* EAPD set */
67 {0x43, CM9825_VERB_SET_SNR, 0x30}, /* SNR set */
68 {0x43, CM9825_VERB_SET_PLL, 0x00}, /* PLL set */
69 {0x43, CM9825_VERB_SET_ADCL, 0x00}, /* ADC */
70 {0x43, CM9825_VERB_SET_DACL, 0x02}, /* DACL */
71 {0x43, CM9825_VERB_SET_MBIAS, 0x00}, /* MBIAS */
72 {0x43, CM9825_VERB_SET_VNEG, 0x56}, /* VOL NEG */
73 {0x43, CM9825_VERB_SET_D2S, 0x62}, /* depop */
74 {0x43, CM9825_VERB_SET_DACTRL, 0x00}, /* DACTRL set */
75 {0x43, CM9825_VERB_SET_PDNEG, 0x0c}, /* SEL OSC */
76 {0x43, CM9825_VERB_SET_VDO, 0x80}, /* VDO set */
77 {0x43, CM9825_VERB_SET_CDALR, 0xf4}, /* Class D */
78 {0x43, CM9825_VERB_SET_OTP, 0xcd}, /* OTP set */
79 {0x43, CM9825_VERB_SET_MTCBA, 0x61}, /* SR set */
80 {0x43, CM9825_VERB_SET_OCP, 0x33}, /* OTP set */
81 {0x43, CM9825_VERB_SET_GAD, 0x07}, /* ADC -3db */
82 {0x43, CM9825_VERB_SET_TMOD, 0x26}, /* Class D clk */
83 {0x3C, AC_VERB_SET_AMP_GAIN_MUTE |
84 AC_AMP_SET_OUTPUT | AC_AMP_SET_RIGHT, 0x2d}, /* Gain set */
85 {0x3C, AC_VERB_SET_AMP_GAIN_MUTE |
86 AC_AMP_SET_OUTPUT | AC_AMP_SET_LEFT, 0x2d}, /* Gain set */
87 {0x43, CM9825_VERB_SET_HPF_1, 0x40}, /* HPF set */
88 {0x43, CM9825_VERB_SET_HPF_2, 0x40}, /* HPF set */
93 {0x42, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00}, /* PIN off */
94 {0x43, CM9825_VERB_SET_ADCL, 0x88}, /* ADC */
95 {0x43, CM9825_VERB_SET_DACL, 0xaa}, /* DACL */
96 {0x43, CM9825_VERB_SET_MBIAS, 0x10}, /* MBIAS */
97 {0x43, CM9825_VERB_SET_D2S, 0xf2}, /* depop */
98 {0x43, CM9825_VERB_SET_DACTRL, 0x00}, /* DACTRL set */
99 {0x43, CM9825_VERB_SET_VDO, 0xc4}, /* VDO set */
104 {0x43, CM9825_VERB_SET_ADCL, 0x00}, /* ADC */
105 {0x43, CM9825_VERB_SET_DACL, 0x56}, /* DACL */
106 {0x43, CM9825_VERB_SET_MBIAS, 0x00}, /* MBIAS */
107 {0x43, CM9825_VERB_SET_D2S, 0x62}, /* depop */
108 {0x43, CM9825_VERB_SET_DACTRL, 0xe0}, /* DACTRL set */
109 {0x43, CM9825_VERB_SET_VDO, 0x80}, /* VDO set */
110 {0x42, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, /* PIN on */
119 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; in cm9825_unsol_hp_delayed()
121 int err = 0; in cm9825_unsol_hp_delayed()
123 hp_jack_plugin = snd_hda_jack_detect(spec->codec, hp_pin); in cm9825_unsol_hp_delayed()
125 codec_dbg(spec->codec, "hp_jack_plugin %d, hp_pin 0x%X\n", in cm9825_unsol_hp_delayed()
130 snd_hda_codec_write(spec->codec, 0x42, 0, in cm9825_unsol_hp_delayed()
131 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40); in cm9825_unsol_hp_delayed()
133 codec_dbg(spec->codec, "codec_write err %d\n", err); in cm9825_unsol_hp_delayed()
135 snd_hda_sequence_write(spec->codec, spec->chip_hp_remove_verbs); in cm9825_unsol_hp_delayed()
137 snd_hda_sequence_write(spec->codec, in cm9825_unsol_hp_delayed()
138 spec->chip_hp_present_verbs); in cm9825_unsol_hp_delayed()
141 jack = snd_hda_jack_tbl_get(spec->codec, hp_pin); in cm9825_unsol_hp_delayed()
143 jack->block_report = 0; in cm9825_unsol_hp_delayed()
144 snd_hda_jack_report_sync(spec->codec); in cm9825_unsol_hp_delayed()
148 static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb) in hp_callback() argument
150 struct cmi_spec *spec = codec->spec; in hp_callback()
153 /* Delay enabling the HP amp, to let the mic-detection in hp_callback()
157 codec_dbg(spec->codec, "cb->nid 0x%X\n", cb->nid); in hp_callback()
159 tbl = snd_hda_jack_tbl_get(codec, cb->nid); in hp_callback()
161 tbl->block_report = 1; in hp_callback()
162 schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(200)); in hp_callback()
165 static void cm9825_setup_unsol(struct hda_codec *codec) in cm9825_setup_unsol() argument
167 struct cmi_spec *spec = codec->spec; in cm9825_setup_unsol()
169 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; in cm9825_setup_unsol()
171 snd_hda_jack_detect_enable_callback(codec, hp_pin, hp_callback); in cm9825_setup_unsol()
174 static int cm9825_init(struct hda_codec *codec) in cm9825_init() argument
176 snd_hda_gen_init(codec); in cm9825_init()
177 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); in cm9825_init()
179 return 0; in cm9825_init()
182 static void cm9825_remove(struct hda_codec *codec) in cm9825_remove() argument
184 struct cmi_spec *spec = codec->spec; in cm9825_remove()
186 cancel_delayed_work_sync(&spec->unsol_hp_work); in cm9825_remove()
187 snd_hda_gen_remove(codec); in cm9825_remove()
190 static int cm9825_suspend(struct hda_codec *codec) in cm9825_suspend() argument
192 struct cmi_spec *spec = codec->spec; in cm9825_suspend()
194 cancel_delayed_work_sync(&spec->unsol_hp_work); in cm9825_suspend()
196 snd_hda_sequence_write(codec, spec->chip_d3_verbs); in cm9825_suspend()
198 return 0; in cm9825_suspend()
201 static int cm9825_resume(struct hda_codec *codec) in cm9825_resume() argument
203 struct cmi_spec *spec = codec->spec; in cm9825_resume()
204 hda_nid_t hp_pin = 0; in cm9825_resume()
209 snd_hda_codec_write(spec->codec, 0x42, 0, in cm9825_resume()
210 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00); in cm9825_resume()
212 codec_dbg(codec, "codec_write err %d\n", err); in cm9825_resume()
216 snd_hda_codec_init(codec); in cm9825_resume()
218 hp_pin = spec->gen.autocfg.hp_pins[0]; in cm9825_resume()
219 hp_jack_plugin = snd_hda_jack_detect(spec->codec, hp_pin); in cm9825_resume()
221 codec_dbg(spec->codec, "hp_jack_plugin %d, hp_pin 0x%X\n", in cm9825_resume()
226 snd_hda_codec_write(spec->codec, 0x42, 0, in cm9825_resume()
227 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40); in cm9825_resume()
230 codec_dbg(codec, "codec_write err %d\n", err); in cm9825_resume()
232 snd_hda_sequence_write(codec, cm9825_hp_remove_verbs); in cm9825_resume()
235 snd_hda_regmap_sync(codec); in cm9825_resume()
236 hda_call_check_power_status(codec, 0x01); in cm9825_resume()
238 return 0; in cm9825_resume()
241 static int cm9825_probe(struct hda_codec *codec, const struct hda_device_id *id) in cm9825_probe() argument
249 return -ENOMEM; in cm9825_probe()
251 INIT_DELAYED_WORK(&spec->unsol_hp_work, cm9825_unsol_hp_delayed); in cm9825_probe()
252 codec->spec = spec; in cm9825_probe()
253 spec->codec = codec; in cm9825_probe()
254 cfg = &spec->gen.autocfg; in cm9825_probe()
255 snd_hda_gen_spec_init(&spec->gen); in cm9825_probe()
256 spec->chip_d0_verbs = cm9825_std_d0_verbs; in cm9825_probe()
257 spec->chip_d3_verbs = cm9825_std_d3_verbs; in cm9825_probe()
258 spec->chip_hp_present_verbs = cm9825_hp_present_verbs; in cm9825_probe()
259 spec->chip_hp_remove_verbs = cm9825_hp_remove_verbs; in cm9825_probe()
261 snd_hda_sequence_write(codec, spec->chip_d0_verbs); in cm9825_probe()
263 err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0); in cm9825_probe()
264 if (err < 0) in cm9825_probe()
266 err = snd_hda_gen_parse_auto_config(codec, cfg); in cm9825_probe()
267 if (err < 0) in cm9825_probe()
270 cm9825_setup_unsol(codec); in cm9825_probe()
272 return 0; in cm9825_probe()
275 cm9825_remove(codec); in cm9825_probe()
277 codec_info(codec, "Enter err %d\n", err); in cm9825_probe()
299 HDA_CODEC_ID(0x13f69825, "CM9825"),
305 MODULE_DESCRIPTION("CM9825 HD-audio codec");