Lines Matching full:codec

3  * HD-audio codec driver binding
19 * find a matching codec id
23 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in hda_codec_match() local
28 u32 id = codec->probe_id ? codec->probe_id : codec->core.vendor_id; in hda_codec_match()
29 u32 rev_id = codec->core.revision_id; in hda_codec_match()
34 codec->preset = list; in hda_codec_match()
44 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in hda_codec_unsol_event() local
45 struct hda_codec_driver *driver = hda_codec_to_driver(codec); in hda_codec_unsol_event()
48 if (codec->card->shutdown || 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()
56 driver->ops->unsol_event(codec, ev); in hda_codec_unsol_event()
60 * snd_hda_codec_set_name - set the codec name
61 * @codec: the HDA codec
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
91 struct hda_codec_driver *driver = hda_codec_to_driver(codec); in hda_codec_driver_probe()
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()
120 err = driver->ops->probe(codec, codec->preset); in hda_codec_driver_probe()
123 err = snd_hda_codec_build_pcms(codec); in hda_codec_driver_probe()
126 err = snd_hda_codec_build_controls(codec); in hda_codec_driver_probe()
130 if (!codec->bus->bus_probing && codec->card->registered) { in hda_codec_driver_probe()
131 err = snd_card_register(codec->card); in hda_codec_driver_probe()
134 snd_hda_codec_register(codec); in hda_codec_driver_probe()
137 codec->core.lazy_cache = true; in hda_codec_driver_probe()
142 driver->ops->remove(codec); in hda_codec_driver_probe()
147 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_probe()
148 codec->preset = NULL; in hda_codec_driver_probe()
154 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_remove() local
155 struct hda_codec_driver *driver = hda_codec_to_driver(codec); in hda_codec_driver_remove()
157 if (codec->bus->core.ext_ops) { in hda_codec_driver_remove()
158 if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach)) in hda_codec_driver_remove()
160 return codec->bus->core.ext_ops->hdev_detach(&codec->core); in hda_codec_driver_remove()
163 snd_hda_codec_disconnect_pcms(codec); in hda_codec_driver_remove()
164 snd_hda_jack_tbl_disconnect(codec); in hda_codec_driver_remove()
165 if (!refcount_dec_and_test(&codec->pcm_ref)) in hda_codec_driver_remove()
166 wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref)); in hda_codec_driver_remove()
167 snd_power_sync_ref(codec->bus->card); in hda_codec_driver_remove()
170 driver->ops->remove(codec); in hda_codec_driver_remove()
171 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_remove()
172 codec->preset = NULL; in hda_codec_driver_remove()
205 static inline bool codec_probed(struct hda_codec *codec) in codec_probed() argument
207 return device_attach(hda_codec_dev(codec)) > 0 && codec->preset; in codec_probed()
210 /* try to auto-load codec module */
211 static void request_codec_module(struct hda_codec *codec) in request_codec_module() argument
217 switch (codec->probe_id) { in request_codec_module()
220 mod = "snd-hda-codec-hdmi"; in request_codec_module()
225 mod = "snd-hda-codec-generic"; in request_codec_module()
229 snd_hdac_codec_modalias(&codec->core, modalias, sizeof(modalias)); in request_codec_module()
239 /* try to auto-load and bind the codec module */
240 static void codec_bind_module(struct hda_codec *codec) in codec_bind_module() argument
243 request_codec_module(codec); in codec_bind_module()
244 if (codec_probed(codec)) in codec_bind_module()
250 /* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
251 static bool is_likely_hdmi_codec(struct hda_codec *codec) in is_likely_hdmi_codec() argument
259 if (!codec->wcaps) in is_likely_hdmi_codec()
262 for_each_hda_codec_node(nid, codec) { in is_likely_hdmi_codec()
263 unsigned int wcaps = get_wcaps(codec, nid); in is_likely_hdmi_codec()
276 /* no HDMI codec parser support */
277 #define is_likely_hdmi_codec(codec) false argument
280 static int codec_bind_generic(struct hda_codec *codec) in codec_bind_generic() argument
282 if (codec->probe_id) in codec_bind_generic()
285 if (is_likely_hdmi_codec(codec)) { in codec_bind_generic()
286 codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; in codec_bind_generic()
287 request_codec_module(codec); in codec_bind_generic()
288 if (codec_probed(codec)) in codec_bind_generic()
292 codec->probe_id = HDA_CODEC_ID_GENERIC; in codec_bind_generic()
293 request_codec_module(codec); in codec_bind_generic()
294 if (codec_probed(codec)) in codec_bind_generic()
300 #define is_generic_config(codec) \ argument
301 (codec->modelname && !strcmp(codec->modelname, "generic"))
303 #define is_generic_config(codec) 0 argument
307 * snd_hda_codec_configure - (Re-)configure the HD-audio codec
308 * @codec: the HDA codec
310 * Start parsing of the given codec tree and (re-)initialize the whole
311 * codec driver binding.
315 int snd_hda_codec_configure(struct hda_codec *codec) in snd_hda_codec_configure() argument
319 if (codec->configured) in snd_hda_codec_configure()
322 if (is_generic_config(codec)) in snd_hda_codec_configure()
323 codec->probe_id = HDA_CODEC_ID_GENERIC; in snd_hda_codec_configure()
325 codec->probe_id = 0; in snd_hda_codec_configure()
327 if (!device_is_registered(&codec->core.dev)) { in snd_hda_codec_configure()
328 err = snd_hdac_device_register(&codec->core); in snd_hda_codec_configure()
333 if (!codec->preset) in snd_hda_codec_configure()
334 codec_bind_module(codec); in snd_hda_codec_configure()
335 if (!codec->preset) { in snd_hda_codec_configure()
336 err = codec_bind_generic(codec); in snd_hda_codec_configure()
338 codec_dbg(codec, "Unable to bind the codec\n"); in snd_hda_codec_configure()
343 codec->configured = 1; in snd_hda_codec_configure()