Lines Matching +full:audio +full:- +full:core
1 // SPDX-License-Identifier: GPL-2.0
2 // hdac_component.c - routines for sync between HD-A core and DRM driver
9 #include <sound/core.h>
24 * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup
25 * @bus: HDA core bus
28 * This function is supposed to be used only by a HD-audio controller
38 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_set_codec_wakeup()
40 if (!acomp || !acomp->ops) in snd_hdac_set_codec_wakeup()
41 return -ENODEV; in snd_hdac_set_codec_wakeup()
43 if (!acomp->ops->codec_wake_override) in snd_hdac_set_codec_wakeup()
46 dev_dbg(bus->dev, "%s codec wakeup\n", str_enable_disable(enable)); 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
56 * @bus: HDA core bus
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", str_enable_disable(enable)); in snd_hdac_display_power()
72 mutex_lock(&bus->lock); in snd_hdac_display_power()
74 set_bit(idx, &bus->display_power_status); in snd_hdac_display_power()
76 clear_bit(idx, &bus->display_power_status); in snd_hdac_display_power()
78 if (!acomp || !acomp->ops) in snd_hdac_display_power()
81 if (bus->display_power_status) { in snd_hdac_display_power()
82 if (!bus->display_power_active) { in snd_hdac_display_power()
83 unsigned long cookie = -1; in snd_hdac_display_power()
85 if (acomp->ops->get_power) in snd_hdac_display_power()
86 cookie = acomp->ops->get_power(acomp->dev); in snd_hdac_display_power()
90 bus->display_power_active = cookie; in snd_hdac_display_power()
93 if (bus->display_power_active) { in snd_hdac_display_power()
94 unsigned long cookie = bus->display_power_active; in snd_hdac_display_power()
96 if (acomp->ops->put_power) in snd_hdac_display_power()
97 acomp->ops->put_power(acomp->dev, cookie); in snd_hdac_display_power()
99 bus->display_power_active = 0; in snd_hdac_display_power()
103 mutex_unlock(&bus->lock); in snd_hdac_display_power()
108 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
114 * This function is supposed to be used only by a HD-audio controller
123 struct hdac_bus *bus = codec->bus; in snd_hdac_sync_audio_rate()
124 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_sync_audio_rate()
127 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) in snd_hdac_sync_audio_rate()
128 return -ENODEV; in snd_hdac_sync_audio_rate()
130 if (acomp->audio_ops && acomp->audio_ops->pin2port) { in snd_hdac_sync_audio_rate()
131 port = acomp->audio_ops->pin2port(codec, nid); in snd_hdac_sync_audio_rate()
133 return -EINVAL; in snd_hdac_sync_audio_rate()
136 return acomp->ops->sync_audio_rate(acomp->dev, port, pipe, rate); in snd_hdac_sync_audio_rate()
141 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
145 * @audio_enabled: the pointer to store the current audio state
149 * This function is supposed to be used only by a HD-audio controller
152 * This function queries the current state of the audio on the given
164 struct hdac_bus *bus = codec->bus; in snd_hdac_acomp_get_eld()
165 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_acomp_get_eld()
168 if (!acomp || !acomp->ops || !acomp->ops->get_eld) in snd_hdac_acomp_get_eld()
169 return -ENODEV; in snd_hdac_acomp_get_eld()
172 if (acomp->audio_ops && acomp->audio_ops->pin2port) { in snd_hdac_acomp_get_eld()
173 port = acomp->audio_ops->pin2port(codec, nid); in snd_hdac_acomp_get_eld()
175 return -EINVAL; in snd_hdac_acomp_get_eld()
178 return acomp->ops->get_eld(acomp->dev, port, pipe, audio_enabled, in snd_hdac_acomp_get_eld()
189 return -EINVAL; in hdac_component_master_bind()
195 if (WARN_ON(!(acomp->dev && acomp->ops))) { in hdac_component_master_bind()
196 ret = -EINVAL; in hdac_component_master_bind()
201 if (!try_module_get(acomp->ops->owner)) { in hdac_component_master_bind()
202 ret = -ENODEV; in hdac_component_master_bind()
206 if (acomp->audio_ops && acomp->audio_ops->master_bind) { in hdac_component_master_bind()
207 ret = acomp->audio_ops->master_bind(dev, acomp); in hdac_component_master_bind()
212 complete_all(&acomp->master_bind_complete); in hdac_component_master_bind()
216 module_put(acomp->ops->owner); in hdac_component_master_bind()
219 complete_all(&acomp->master_bind_complete); in hdac_component_master_bind()
228 if (acomp->audio_ops && acomp->audio_ops->master_unbind) in hdac_component_master_unbind()
229 acomp->audio_ops->master_unbind(dev, acomp); in hdac_component_master_unbind()
230 module_put(acomp->ops->owner); in hdac_component_master_unbind()
232 WARN_ON(acomp->ops || acomp->dev); in hdac_component_master_unbind()
241 * snd_hdac_acomp_register_notifier - Register audio component ops
242 * @bus: HDA core bus
243 * @aops: audio component ops
245 * This function is supposed to be used only by a HD-audio controller
255 if (!bus->audio_component) in snd_hdac_acomp_register_notifier()
256 return -ENODEV; in snd_hdac_acomp_register_notifier()
258 bus->audio_component->audio_ops = aops; in snd_hdac_acomp_register_notifier()
264 * snd_hdac_acomp_init - Initialize audio component
265 * @bus: HDA core bus
266 * @aops: audio component ops
270 * This function is supposed to be used only by a HD-audio controller
273 * This function initializes and sets up the audio component to communicate
288 struct device *dev = bus->dev; in snd_hdac_acomp_init()
293 return -EBUSY; in snd_hdac_acomp_init()
298 return -ENOMEM; in snd_hdac_acomp_init()
299 acomp->audio_ops = aops; in snd_hdac_acomp_init()
300 init_completion(&acomp->master_bind_complete); in snd_hdac_acomp_init()
301 bus->audio_component = acomp; in snd_hdac_acomp_init()
313 bus->audio_component = NULL; in snd_hdac_acomp_init()
315 dev_info(dev, "failed to add audio component master (%d)\n", ret); in snd_hdac_acomp_init()
322 * snd_hdac_acomp_exit - Finalize audio component
323 * @bus: HDA core bus
325 * This function is supposed to be used only by a HD-audio controller
328 * This function releases the audio component that has been used.
334 struct device *dev = bus->dev; in snd_hdac_acomp_exit()
335 struct drm_audio_component *acomp = bus->audio_component; in snd_hdac_acomp_exit()
340 if (WARN_ON(bus->display_power_active) && acomp->ops) in snd_hdac_acomp_exit()
341 acomp->ops->put_power(acomp->dev, bus->display_power_active); in snd_hdac_acomp_exit()
343 bus->display_power_active = 0; in snd_hdac_acomp_exit()
344 bus->display_power_status = 0; in snd_hdac_acomp_exit()
348 bus->audio_component = NULL; in snd_hdac_acomp_exit()