• Home
  • Raw
  • Download

Lines Matching +full:codec +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0-only
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()
31 for (list = driver->id; list->vendor_id; list++) { in hda_codec_match()
32 if (list->vendor_id == id && in hda_codec_match()
33 (!list->rev_id || list->rev_id == rev_id)) { in hda_codec_match()
34 codec->preset = list; in hda_codec_match()
38 return 0; in hda_codec_match()
44 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in hda_codec_unsol_event() local
47 if (codec->bus->shutdown) in hda_codec_unsol_event()
51 if (codec->core.dev.power.power_state.event != PM_EVENT_ON) in hda_codec_unsol_event()
54 if (codec->patch_ops.unsol_event) in hda_codec_unsol_event()
55 codec->patch_ops.unsol_event(codec, ev); in hda_codec_unsol_event()
59 * snd_hda_codec_set_name - set the codec name
60 * @codec: the HDA codec
63 int snd_hda_codec_set_name(struct hda_codec *codec, const char *name) in snd_hda_codec_set_name() argument
68 return 0; in snd_hda_codec_set_name()
69 err = snd_hdac_device_set_chip_name(&codec->core, name); in snd_hda_codec_set_name()
70 if (err < 0) in snd_hda_codec_set_name()
74 if (!*codec->card->mixername || in snd_hda_codec_set_name()
75 codec->bus->mixer_assigned >= codec->core.addr) { in snd_hda_codec_set_name()
76 snprintf(codec->card->mixername, in snd_hda_codec_set_name()
77 sizeof(codec->card->mixername), "%s %s", in snd_hda_codec_set_name()
78 codec->core.vendor_name, codec->core.chip_name); in snd_hda_codec_set_name()
79 codec->bus->mixer_assigned = codec->core.addr; in snd_hda_codec_set_name()
82 return 0; in snd_hda_codec_set_name()
88 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_probe() local
89 struct module *owner = dev->driver->owner; in hda_codec_driver_probe()
93 if (codec->bus->core.ext_ops) { in hda_codec_driver_probe()
94 if (WARN_ON(!codec->bus->core.ext_ops->hdev_attach)) in hda_codec_driver_probe()
95 return -EINVAL; in hda_codec_driver_probe()
96 return codec->bus->core.ext_ops->hdev_attach(&codec->core); in hda_codec_driver_probe()
99 if (WARN_ON(!codec->preset)) in hda_codec_driver_probe()
100 return -EINVAL; in hda_codec_driver_probe()
102 err = snd_hda_codec_set_name(codec, codec->preset->name); in hda_codec_driver_probe()
103 if (err < 0) in hda_codec_driver_probe()
105 err = snd_hdac_regmap_init(&codec->core); in hda_codec_driver_probe()
106 if (err < 0) in hda_codec_driver_probe()
110 err = -EINVAL; in hda_codec_driver_probe()
114 patch = (hda_codec_patch_t)codec->preset->driver_data; in hda_codec_driver_probe()
116 err = patch(codec); in hda_codec_driver_probe()
117 if (err < 0) in hda_codec_driver_probe()
121 err = snd_hda_codec_build_pcms(codec); in hda_codec_driver_probe()
122 if (err < 0) in hda_codec_driver_probe()
124 err = snd_hda_codec_build_controls(codec); in hda_codec_driver_probe()
125 if (err < 0) in hda_codec_driver_probe()
128 if (!codec->bus->bus_probing && codec->card->registered) { in hda_codec_driver_probe()
129 err = snd_card_register(codec->card); in hda_codec_driver_probe()
130 if (err < 0) in hda_codec_driver_probe()
132 snd_hda_codec_register(codec); in hda_codec_driver_probe()
135 codec->core.lazy_cache = true; in hda_codec_driver_probe()
136 return 0; in hda_codec_driver_probe()
139 if (codec->patch_ops.free) in hda_codec_driver_probe()
140 codec->patch_ops.free(codec); in hda_codec_driver_probe()
145 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_probe()
146 codec->preset = NULL; in hda_codec_driver_probe()
152 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_remove() local
154 if (codec->bus->core.ext_ops) { in hda_codec_driver_remove()
155 if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach)) in hda_codec_driver_remove()
156 return -EINVAL; in hda_codec_driver_remove()
157 return codec->bus->core.ext_ops->hdev_detach(&codec->core); in hda_codec_driver_remove()
160 if (codec->patch_ops.free) in hda_codec_driver_remove()
161 codec->patch_ops.free(codec); in hda_codec_driver_remove()
162 snd_hda_codec_cleanup_for_unbind(codec); in hda_codec_driver_remove()
163 codec->preset = NULL; in hda_codec_driver_remove()
164 module_put(dev->driver->owner); in hda_codec_driver_remove()
165 return 0; in hda_codec_driver_remove()
170 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_driver_shutdown() local
172 if (!pm_runtime_suspended(dev) && codec->patch_ops.reboot_notify) in hda_codec_driver_shutdown()
173 codec->patch_ops.reboot_notify(codec); in hda_codec_driver_shutdown()
179 drv->core.driver.name = name; in __hda_codec_driver_register()
180 drv->core.driver.owner = owner; in __hda_codec_driver_register()
181 drv->core.driver.bus = &snd_hda_bus_type; in __hda_codec_driver_register()
182 drv->core.driver.probe = hda_codec_driver_probe; in __hda_codec_driver_register()
183 drv->core.driver.remove = hda_codec_driver_remove; in __hda_codec_driver_register()
184 drv->core.driver.shutdown = hda_codec_driver_shutdown; in __hda_codec_driver_register()
185 drv->core.driver.pm = &hda_codec_driver_pm; in __hda_codec_driver_register()
186 drv->core.type = HDA_DEV_LEGACY; in __hda_codec_driver_register()
187 drv->core.match = hda_codec_match; in __hda_codec_driver_register()
188 drv->core.unsol_event = hda_codec_unsol_event; in __hda_codec_driver_register()
189 return driver_register(&drv->core.driver); in __hda_codec_driver_register()
195 driver_unregister(&drv->core.driver); in hda_codec_driver_unregister()
199 static inline bool codec_probed(struct hda_codec *codec) in codec_probed() argument
201 return device_attach(hda_codec_dev(codec)) > 0 && codec->preset; in codec_probed()
204 /* try to auto-load codec module */
205 static void request_codec_module(struct hda_codec *codec) in request_codec_module() argument
211 switch (codec->probe_id) { in request_codec_module()
214 mod = "snd-hda-codec-hdmi"; in request_codec_module()
219 mod = "snd-hda-codec-generic"; in request_codec_module()
223 snd_hdac_codec_modalias(&codec->core, modalias, sizeof(modalias)); in request_codec_module()
233 /* try to auto-load and bind the codec module */
234 static void codec_bind_module(struct hda_codec *codec) in codec_bind_module() argument
237 request_codec_module(codec); in codec_bind_module()
238 if (codec_probed(codec)) in codec_bind_module()
244 /* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
245 static bool is_likely_hdmi_codec(struct hda_codec *codec) in is_likely_hdmi_codec() argument
249 for_each_hda_codec_node(nid, codec) { in is_likely_hdmi_codec()
250 unsigned int wcaps = get_wcaps(codec, nid); in is_likely_hdmi_codec()
263 /* no HDMI codec parser support */
264 #define is_likely_hdmi_codec(codec) false argument
267 static int codec_bind_generic(struct hda_codec *codec) in codec_bind_generic() argument
269 if (codec->probe_id) in codec_bind_generic()
270 return -ENODEV; in codec_bind_generic()
272 if (is_likely_hdmi_codec(codec)) { in codec_bind_generic()
273 codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI; in codec_bind_generic()
274 request_codec_module(codec); in codec_bind_generic()
275 if (codec_probed(codec)) in codec_bind_generic()
276 return 0; in codec_bind_generic()
279 codec->probe_id = HDA_CODEC_ID_GENERIC; in codec_bind_generic()
280 request_codec_module(codec); in codec_bind_generic()
281 if (codec_probed(codec)) in codec_bind_generic()
282 return 0; in codec_bind_generic()
283 return -ENODEV; in codec_bind_generic()
287 #define is_generic_config(codec) \ argument
288 (codec->modelname && !strcmp(codec->modelname, "generic"))
290 #define is_generic_config(codec) 0 argument
294 * snd_hda_codec_configure - (Re-)configure the HD-audio codec
295 * @codec: the HDA codec
297 * Start parsing of the given codec tree and (re-)initialize the whole
300 * Returns 0 if successful or a negative error code.
302 int snd_hda_codec_configure(struct hda_codec *codec) in snd_hda_codec_configure() argument
306 if (codec->configured) in snd_hda_codec_configure()
307 return 0; in snd_hda_codec_configure()
309 if (is_generic_config(codec)) in snd_hda_codec_configure()
310 codec->probe_id = HDA_CODEC_ID_GENERIC; in snd_hda_codec_configure()
312 codec->probe_id = 0; in snd_hda_codec_configure()
314 if (!device_is_registered(&codec->core.dev)) { in snd_hda_codec_configure()
315 err = snd_hdac_device_register(&codec->core); in snd_hda_codec_configure()
316 if (err < 0) in snd_hda_codec_configure()
320 if (!codec->preset) in snd_hda_codec_configure()
321 codec_bind_module(codec); in snd_hda_codec_configure()
322 if (!codec->preset) { in snd_hda_codec_configure()
323 err = codec_bind_generic(codec); in snd_hda_codec_configure()
324 if (err < 0) { in snd_hda_codec_configure()
325 codec_dbg(codec, "Unable to bind the codec\n"); in snd_hda_codec_configure()
330 codec->configured = 1; in snd_hda_codec_configure()
331 return 0; in snd_hda_codec_configure()