Lines Matching refs:codec
24 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in hda_codec_match() local
29 u32 id = codec->probe_id ? codec->probe_id : codec->core.vendor_id; in hda_codec_match()
30 u32 rev_id = codec->core.revision_id; in hda_codec_match()
35 codec->preset = list; in hda_codec_match()
45 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in hda_codec_unsol_event() local
48 if (codec->bus->shutdown) in hda_codec_unsol_event()
52 if (codec->core.dev.power.power_state.event != PM_EVENT_ON) in hda_codec_unsol_event()
55 if (codec->patch_ops.unsol_event) in hda_codec_unsol_event()
56 codec->patch_ops.unsol_event(codec, ev); in hda_codec_unsol_event()
64 int snd_hda_codec_set_name(struct hda_codec *codec, const char *name) in snd_hda_codec_set_name() argument
70 err = snd_hdac_device_set_chip_name(&codec->core, name); in snd_hda_codec_set_name()
75 if (!*codec->card->mixername || in snd_hda_codec_set_name()
76 codec->bus->mixer_assigned >= codec->core.addr) { in snd_hda_codec_set_name()
77 snprintf(codec->card->mixername, in snd_hda_codec_set_name()
78 sizeof(codec->card->mixername), "%s %s", in snd_hda_codec_set_name()
79 codec->core.vendor_name, codec->core.chip_name); in snd_hda_codec_set_name()
80 codec->bus->mixer_assigned = codec->core.addr; in snd_hda_codec_set_name()
89 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_probe() local
94 if (codec->bus->core.ext_ops) { in hda_codec_driver_probe()
95 if (WARN_ON(!codec->bus->core.ext_ops->hdev_attach)) in hda_codec_driver_probe()
97 return codec->bus->core.ext_ops->hdev_attach(&codec->core); in hda_codec_driver_probe()
100 if (WARN_ON(!codec->preset)) in hda_codec_driver_probe()
103 err = snd_hda_codec_set_name(codec, codec->preset->name); in hda_codec_driver_probe()
106 err = snd_hdac_regmap_init(&codec->core); in hda_codec_driver_probe()
115 patch = (hda_codec_patch_t)codec->preset->driver_data; in hda_codec_driver_probe()
117 err = patch(codec); in hda_codec_driver_probe()
122 err = snd_hda_codec_build_pcms(codec); in hda_codec_driver_probe()
125 err = snd_hda_codec_build_controls(codec); in hda_codec_driver_probe()
129 if (!codec->bus->bus_probing && codec->card->registered) { in hda_codec_driver_probe()
130 err = snd_card_register(codec->card); in hda_codec_driver_probe()
133 snd_hda_codec_register(codec); in hda_codec_driver_probe()
136 codec->core.lazy_cache = true; in hda_codec_driver_probe()
140 if (codec->patch_ops.free) in hda_codec_driver_probe()
141 codec->patch_ops.free(codec); in hda_codec_driver_probe()
146 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_probe()
147 codec->preset = NULL; in hda_codec_driver_probe()
153 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_remove() local
155 if (codec->bus->core.ext_ops) { in hda_codec_driver_remove()
156 if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach)) in hda_codec_driver_remove()
158 return codec->bus->core.ext_ops->hdev_detach(&codec->core); in hda_codec_driver_remove()
161 snd_hda_codec_disconnect_pcms(codec); in hda_codec_driver_remove()
162 snd_hda_jack_tbl_disconnect(codec); in hda_codec_driver_remove()
163 if (!refcount_dec_and_test(&codec->pcm_ref)) in hda_codec_driver_remove()
164 wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref)); in hda_codec_driver_remove()
165 snd_power_sync_ref(codec->bus->card); in hda_codec_driver_remove()
167 if (codec->patch_ops.free) in hda_codec_driver_remove()
168 codec->patch_ops.free(codec); in hda_codec_driver_remove()
169 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_remove()
170 codec->preset = NULL; in hda_codec_driver_remove()
203 static inline bool codec_probed(struct hda_codec *codec) in codec_probed() argument
205 return device_attach(hda_codec_dev(codec)) > 0 && codec->preset; in codec_probed()
209 static void request_codec_module(struct hda_codec *codec) in request_codec_module() argument
215 switch (codec->probe_id) { in request_codec_module()
227 snd_hdac_codec_modalias(&codec->core, modalias, sizeof(modalias)); in request_codec_module()
238 static void codec_bind_module(struct hda_codec *codec) in codec_bind_module() argument
241 request_codec_module(codec); in codec_bind_module()
242 if (codec_probed(codec)) in codec_bind_module()
249 static bool is_likely_hdmi_codec(struct hda_codec *codec) in is_likely_hdmi_codec() argument
257 if (!codec->wcaps) in is_likely_hdmi_codec()
260 for_each_hda_codec_node(nid, codec) { in is_likely_hdmi_codec()
261 unsigned int wcaps = get_wcaps(codec, nid); in is_likely_hdmi_codec()
275 #define is_likely_hdmi_codec(codec) false argument
278 static int codec_bind_generic(struct hda_codec *codec) in codec_bind_generic() argument
280 if (codec->probe_id) in codec_bind_generic()
283 if (is_likely_hdmi_codec(codec)) { in codec_bind_generic()
284 codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; in codec_bind_generic()
285 request_codec_module(codec); in codec_bind_generic()
286 if (codec_probed(codec)) in codec_bind_generic()
290 codec->probe_id = HDA_CODEC_ID_GENERIC; in codec_bind_generic()
291 request_codec_module(codec); in codec_bind_generic()
292 if (codec_probed(codec)) in codec_bind_generic()
298 #define is_generic_config(codec) \ argument
299 (codec->modelname && !strcmp(codec->modelname, "generic"))
301 #define is_generic_config(codec) 0 argument
313 int snd_hda_codec_configure(struct hda_codec *codec) in snd_hda_codec_configure() argument
317 if (codec->configured) in snd_hda_codec_configure()
320 if (is_generic_config(codec)) in snd_hda_codec_configure()
321 codec->probe_id = HDA_CODEC_ID_GENERIC; in snd_hda_codec_configure()
323 codec->probe_id = 0; in snd_hda_codec_configure()
325 if (!device_is_registered(&codec->core.dev)) { in snd_hda_codec_configure()
326 err = snd_hdac_device_register(&codec->core); in snd_hda_codec_configure()
331 if (!codec->preset) in snd_hda_codec_configure()
332 codec_bind_module(codec); in snd_hda_codec_configure()
333 if (!codec->preset) { in snd_hda_codec_configure()
334 err = codec_bind_generic(codec); in snd_hda_codec_configure()
336 codec_dbg(codec, "Unable to bind the codec\n"); in snd_hda_codec_configure()
341 codec->configured = 1; in snd_hda_codec_configure()