Lines Matching +full:audio +full:- +full:controller
1 // SPDX-License-Identifier: GPL-2.0
2 // hdac_component.c - routines for sync between HD-A core and DRM driver
23 * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup
27 * This function is supposed to be used only by a HD-audio controller
37 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_set_codec_wakeup()
39 if (!acomp || !acomp->ops) in snd_hdac_set_codec_wakeup()
40 return -ENODEV; in snd_hdac_set_codec_wakeup()
42 if (!acomp->ops->codec_wake_override) in snd_hdac_set_codec_wakeup()
45 dev_dbg(bus->dev, "%s codec wakeup\n", in snd_hdac_set_codec_wakeup()
48 acomp->ops->codec_wake_override(acomp->dev, enable); in snd_hdac_set_codec_wakeup()
55 * snd_hdac_display_power - Power up / down the power refcount
57 * @idx: HDA codec address, pass HDA_CODEC_IDX_CONTROLLER for controller
60 * This function is used by either HD-audio controller or codec driver that
68 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_display_power()
70 dev_dbg(bus->dev, "display power %s\n", in snd_hdac_display_power()
73 mutex_lock(&bus->lock); in snd_hdac_display_power()
75 set_bit(idx, &bus->display_power_status); in snd_hdac_display_power()
77 clear_bit(idx, &bus->display_power_status); in snd_hdac_display_power()
79 if (!acomp || !acomp->ops) in snd_hdac_display_power()
82 if (bus->display_power_status) { in snd_hdac_display_power()
83 if (!bus->display_power_active) { in snd_hdac_display_power()
84 unsigned long cookie = -1; in snd_hdac_display_power()
86 if (acomp->ops->get_power) in snd_hdac_display_power()
87 cookie = acomp->ops->get_power(acomp->dev); in snd_hdac_display_power()
91 bus->display_power_active = cookie; in snd_hdac_display_power()
94 if (bus->display_power_active) { in snd_hdac_display_power()
95 unsigned long cookie = bus->display_power_active; in snd_hdac_display_power()
97 if (acomp->ops->put_power) in snd_hdac_display_power()
98 acomp->ops->put_power(acomp->dev, cookie); in snd_hdac_display_power()
100 bus->display_power_active = 0; in snd_hdac_display_power()
104 mutex_unlock(&bus->lock); in snd_hdac_display_power()
109 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
115 * This function is supposed to be used only by a HD-audio controller
124 struct hdac_bus *bus = codec->bus; in snd_hdac_sync_audio_rate()
125 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_sync_audio_rate()
128 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) in snd_hdac_sync_audio_rate()
129 return -ENODEV; in snd_hdac_sync_audio_rate()
131 if (acomp->audio_ops && acomp->audio_ops->pin2port) { in snd_hdac_sync_audio_rate()
132 port = acomp->audio_ops->pin2port(codec, nid); in snd_hdac_sync_audio_rate()
134 return -EINVAL; in snd_hdac_sync_audio_rate()
137 return acomp->ops->sync_audio_rate(acomp->dev, port, pipe, rate); in snd_hdac_sync_audio_rate()
142 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
146 * @audio_enabled: the pointer to store the current audio state
150 * This function is supposed to be used only by a HD-audio controller
153 * This function queries the current state of the audio on the given
165 struct hdac_bus *bus = codec->bus; in snd_hdac_acomp_get_eld()
166 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_acomp_get_eld()
169 if (!acomp || !acomp->ops || !acomp->ops->get_eld) in snd_hdac_acomp_get_eld()
170 return -ENODEV; in snd_hdac_acomp_get_eld()
173 if (acomp->audio_ops && acomp->audio_ops->pin2port) { in snd_hdac_acomp_get_eld()
174 port = acomp->audio_ops->pin2port(codec, nid); in snd_hdac_acomp_get_eld()
176 return -EINVAL; in snd_hdac_acomp_get_eld()
179 return acomp->ops->get_eld(acomp->dev, port, pipe, audio_enabled, in snd_hdac_acomp_get_eld()
190 return -EINVAL; in hdac_component_master_bind()
196 if (WARN_ON(!(acomp->dev && acomp->ops))) { in hdac_component_master_bind()
197 ret = -EINVAL; in hdac_component_master_bind()
202 if (!try_module_get(acomp->ops->owner)) { in hdac_component_master_bind()
203 ret = -ENODEV; in hdac_component_master_bind()
207 if (acomp->audio_ops && acomp->audio_ops->master_bind) { in hdac_component_master_bind()
208 ret = acomp->audio_ops->master_bind(dev, acomp); in hdac_component_master_bind()
213 complete_all(&acomp->master_bind_complete); in hdac_component_master_bind()
217 module_put(acomp->ops->owner); in hdac_component_master_bind()
220 complete_all(&acomp->master_bind_complete); in hdac_component_master_bind()
229 if (acomp->audio_ops && acomp->audio_ops->master_unbind) in hdac_component_master_unbind()
230 acomp->audio_ops->master_unbind(dev, acomp); in hdac_component_master_unbind()
231 module_put(acomp->ops->owner); in hdac_component_master_unbind()
233 WARN_ON(acomp->ops || acomp->dev); in hdac_component_master_unbind()
242 * snd_hdac_acomp_register_notifier - Register audio component ops
244 * @aops: audio component ops
246 * This function is supposed to be used only by a HD-audio controller
256 if (!bus->audio_component) in snd_hdac_acomp_register_notifier()
257 return -ENODEV; in snd_hdac_acomp_register_notifier()
259 bus->audio_component->audio_ops = aops; in snd_hdac_acomp_register_notifier()
265 * snd_hdac_acomp_init - Initialize audio component
267 * @aops: audio component ops
271 * This function is supposed to be used only by a HD-audio controller
274 * This function initializes and sets up the audio component to communicate
289 struct device *dev = bus->dev; in snd_hdac_acomp_init()
294 return -EBUSY; in snd_hdac_acomp_init()
299 return -ENOMEM; in snd_hdac_acomp_init()
300 acomp->audio_ops = aops; in snd_hdac_acomp_init()
301 init_completion(&acomp->master_bind_complete); in snd_hdac_acomp_init()
302 bus->audio_component = acomp; in snd_hdac_acomp_init()
314 bus->audio_component = NULL; in snd_hdac_acomp_init()
316 dev_info(dev, "failed to add audio component master (%d)\n", ret); in snd_hdac_acomp_init()
323 * snd_hdac_acomp_exit - Finalize audio component
326 * This function is supposed to be used only by a HD-audio controller
329 * This function releases the audio component that has been used.
335 struct device *dev = bus->dev; in snd_hdac_acomp_exit()
336 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_acomp_exit()
341 if (WARN_ON(bus->display_power_active) && acomp->ops) in snd_hdac_acomp_exit()
342 acomp->ops->put_power(acomp->dev, bus->display_power_active); in snd_hdac_acomp_exit()
344 bus->display_power_active = 0; in snd_hdac_acomp_exit()
345 bus->display_power_status = 0; in snd_hdac_acomp_exit()
349 bus->audio_component = NULL; in snd_hdac_acomp_exit()