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
24 * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup
28 * This function is supposed to be used only by a HD-audio controller
38 struct drm_audio_component *acomp = bus->audio_component;
40 if (!acomp || !acomp->ops)
41 return -ENODEV;
43 if (!acomp->ops->codec_wake_override)
46 dev_dbg(bus->dev, "%s codec wakeup\n", str_enable_disable(enable));
48 acomp->ops->codec_wake_override(acomp->dev, enable);
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;
70 dev_dbg(bus->dev, "display power %s\n", str_enable_disable(enable));
72 guard(mutex)(&bus->lock);
74 set_bit(idx, &bus->display_power_status);
76 clear_bit(idx, &bus->display_power_status);
78 if (!acomp || !acomp->ops)
81 if (bus->display_power_status) {
82 if (!bus->display_power_active) {
83 unsigned long cookie = -1;
85 if (acomp->ops->get_power)
86 cookie = acomp->ops->get_power(acomp->dev);
90 bus->display_power_active = cookie;
93 if (bus->display_power_active) {
94 unsigned long cookie = bus->display_power_active;
96 if (acomp->ops->put_power)
97 acomp->ops->put_power(acomp->dev, cookie);
99 bus->display_power_active = 0;
106 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
112 * This function is supposed to be used only by a HD-audio controller
121 struct hdac_bus *bus = codec->bus;
122 struct drm_audio_component *acomp = bus->audio_component;
125 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)
126 return -ENODEV;
128 if (acomp->audio_ops && acomp->audio_ops->pin2port) {
129 port = acomp->audio_ops->pin2port(codec, nid);
131 return -EINVAL;
134 return acomp->ops->sync_audio_rate(acomp->dev, port, pipe, rate);
139 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
143 * @audio_enabled: the pointer to store the current audio state
147 * This function is supposed to be used only by a HD-audio controller
150 * This function queries the current state of the audio on the given
162 struct hdac_bus *bus = codec->bus;
163 struct drm_audio_component *acomp = bus->audio_component;
166 if (!acomp || !acomp->ops || !acomp->ops->get_eld)
167 return -ENODEV;
170 if (acomp->audio_ops && acomp->audio_ops->pin2port) {
171 port = acomp->audio_ops->pin2port(codec, nid);
173 return -EINVAL;
176 return acomp->ops->get_eld(acomp->dev, port, pipe, audio_enabled,
187 return -EINVAL;
193 if (WARN_ON(!(acomp->dev && acomp->ops))) {
194 ret = -EINVAL;
199 if (!try_module_get(acomp->ops->owner)) {
200 ret = -ENODEV;
204 if (acomp->audio_ops && acomp->audio_ops->master_bind) {
205 ret = acomp->audio_ops->master_bind(dev, acomp);
210 complete_all(&acomp->master_bind_complete);
214 module_put(acomp->ops->owner);
217 complete_all(&acomp->master_bind_complete);
226 if (acomp->audio_ops && acomp->audio_ops->master_unbind)
227 acomp->audio_ops->master_unbind(dev, acomp);
228 module_put(acomp->ops->owner);
230 WARN_ON(acomp->ops || acomp->dev);
239 * snd_hdac_acomp_register_notifier - Register audio component ops
241 * @aops: audio component ops
243 * This function is supposed to be used only by a HD-audio controller
253 if (!bus->audio_component)
254 return -ENODEV;
256 bus->audio_component->audio_ops = aops;
262 * snd_hdac_acomp_init - Initialize audio component
264 * @aops: audio component ops
268 * This function is supposed to be used only by a HD-audio controller
271 * This function initializes and sets up the audio component to communicate
286 struct device *dev = bus->dev;
291 return -EBUSY;
296 return -ENOMEM;
297 acomp->audio_ops = aops;
298 init_completion(&acomp->master_bind_complete);
299 bus->audio_component = acomp;
311 bus->audio_component = NULL;
313 dev_info(dev, "failed to add audio component master (%d)\n", ret);
320 * snd_hdac_acomp_exit - Finalize audio component
323 * This function is supposed to be used only by a HD-audio controller
326 * This function releases the audio component that has been used.
332 struct device *dev = bus->dev;
333 struct drm_audio_component *acomp = bus->audio_component;
338 if (WARN_ON(bus->display_power_active) && acomp->ops)
339 acomp->ops->put_power(acomp->dev, bus->display_power_active);
341 bus->display_power_active = 0;
342 bus->display_power_status = 0;
346 bus->audio_component = NULL;