Lines Matching +full:codec +full:- +full:driver

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
28 * driver that needs the interaction with graphics driver.
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
61 * needs the interaction with graphics driver.
64 * put_power() ops accordingly, toggling the codec wakeup, too.
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
110 * @codec: HDA codec
115 * This function is supposed to be used only by a HD-audio controller
116 * driver that needs the interaction with graphics driver.
121 int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_sync_audio_rate() argument
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
143 * @codec: HDA codec
150 * This function is supposed to be used only by a HD-audio controller
151 * driver that needs the interaction with graphics driver.
162 int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id, in snd_hdac_acomp_get_eld() argument
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
246 * This function is supposed to be used only by a HD-audio controller
247 * driver that needs the interaction with graphics driver.
249 * This function sets the given ops to be called by the graphics driver.
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
271 * This function is supposed to be used only by a HD-audio controller
272 * driver that needs the interaction with graphics driver.
275 * with graphics driver.
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()
323 * snd_hdac_acomp_exit - Finalize audio component
326 * This function is supposed to be used only by a HD-audio controller
327 * driver that needs the interaction with graphics driver.
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()