Lines Matching refs: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);
28 u32 id = codec->probe_id ? codec->probe_id : codec->core.vendor_id;
29 u32 rev_id = codec->core.revision_id;
34 codec->preset = list;
44 struct hda_codec *codec = container_of(dev, struct hda_codec, core);
47 if (codec->bus->shutdown)
51 if (codec->core.dev.power.power_state.event != PM_EVENT_ON)
54 if (codec->patch_ops.unsol_event)
55 codec->patch_ops.unsol_event(codec, ev);
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)
69 err = snd_hdac_device_set_chip_name(&codec->core, name);
74 if (!*codec->card->mixername ||
75 codec->bus->mixer_assigned >= codec->core.addr) {
76 snprintf(codec->card->mixername,
77 sizeof(codec->card->mixername), "%s %s",
78 codec->core.vendor_name, codec->core.chip_name);
79 codec->bus->mixer_assigned = codec->core.addr;
88 struct hda_codec *codec = dev_to_hda_codec(dev);
93 if (codec->bus->core.ext_ops) {
94 if (WARN_ON(!codec->bus->core.ext_ops->hdev_attach))
96 return codec->bus->core.ext_ops->hdev_attach(&codec->core);
99 if (WARN_ON(!codec->preset))
102 err = snd_hda_codec_set_name(codec, codec->preset->name);
105 err = snd_hdac_regmap_init(&codec->core);
114 patch = (hda_codec_patch_t)codec->preset->driver_data;
116 err = patch(codec);
121 err = snd_hda_codec_build_pcms(codec);
124 err = snd_hda_codec_build_controls(codec);
128 if (!codec->bus->bus_probing && codec->card->registered) {
129 err = snd_card_register(codec->card);
132 snd_hda_codec_register(codec);
135 codec->core.lazy_cache = true;
139 if (codec->patch_ops.free)
140 codec->patch_ops.free(codec);
145 snd_hda_codec_cleanup_for_unbind(codec);
146 codec->preset = NULL;
152 struct hda_codec *codec = dev_to_hda_codec(dev);
154 if (codec->bus->core.ext_ops) {
155 if (WARN_ON(!codec->bus->core.ext_ops->hdev_detach))
157 return codec->bus->core.ext_ops->hdev_detach(&codec->core);
160 snd_hda_codec_disconnect_pcms(codec);
161 snd_hda_jack_tbl_disconnect(codec);
162 if (!refcount_dec_and_test(&codec->pcm_ref))
163 wait_event(codec->remove_sleep, !refcount_read(&codec->pcm_ref));
164 snd_power_sync_ref(codec->bus->card);
166 if (codec->patch_ops.free)
167 codec->patch_ops.free(codec);
168 snd_hda_codec_cleanup_for_unbind(codec);
169 codec->preset = NULL;
202 static inline bool codec_probed(struct hda_codec *codec)
204 return device_attach(hda_codec_dev(codec)) > 0 && codec->preset;
207 /* try to auto-load codec module */
208 static void request_codec_module(struct hda_codec *codec)
214 switch (codec->probe_id) {
217 mod = "snd-hda-codec-hdmi";
222 mod = "snd-hda-codec-generic";
226 snd_hdac_codec_modalias(&codec->core, modalias, sizeof(modalias));
236 /* try to auto-load and bind the codec module */
237 static void codec_bind_module(struct hda_codec *codec)
240 request_codec_module(codec);
241 if (codec_probed(codec))
247 /* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
248 static bool is_likely_hdmi_codec(struct hda_codec *codec)
256 if (!codec->wcaps)
259 for_each_hda_codec_node(nid, codec) {
260 unsigned int wcaps = get_wcaps(codec, nid);
273 /* no HDMI codec parser support */
274 #define is_likely_hdmi_codec(codec) false
277 static int codec_bind_generic(struct hda_codec *codec)
279 if (codec->probe_id)
282 if (is_likely_hdmi_codec(codec)) {
283 codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI;
284 request_codec_module(codec);
285 if (codec_probed(codec))
289 codec->probe_id = HDA_CODEC_ID_GENERIC;
290 request_codec_module(codec);
291 if (codec_probed(codec))
297 #define is_generic_config(codec) \
298 (codec->modelname && !strcmp(codec->modelname, "generic"))
300 #define is_generic_config(codec) 0
304 * snd_hda_codec_configure - (Re-)configure the HD-audio codec
305 * @codec: the HDA codec
307 * Start parsing of the given codec tree and (re-)initialize the whole
312 int snd_hda_codec_configure(struct hda_codec *codec)
316 if (codec->configured)
319 if (is_generic_config(codec))
320 codec->probe_id = HDA_CODEC_ID_GENERIC;
322 codec->probe_id = 0;
324 if (!device_is_registered(&codec->core.dev)) {
325 err = snd_hdac_device_register(&codec->core);
330 if (!codec->preset)
331 codec_bind_module(codec);
332 if (!codec->preset) {
333 err = codec_bind_generic(codec);
335 codec_dbg(codec, "Unable to bind the codec\n");
340 codec->configured = 1;