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
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
29 * driver that needs the interaction with graphics driver.
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
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;
70 dev_dbg(bus->dev, "display power %s\n", str_enable_disable(enable));
72 mutex_lock(&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;
103 mutex_unlock(&bus->lock);
108 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
109 * @codec: HDA codec
114 * This function is supposed to be used only by a HD-audio controller
115 * driver that needs the interaction with graphics driver.
120 int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid,
123 struct hdac_bus *bus = codec->bus;
124 struct drm_audio_component *acomp = bus->audio_component;
127 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)
128 return -ENODEV;
130 if (acomp->audio_ops && acomp->audio_ops->pin2port) {
131 port = acomp->audio_ops->pin2port(codec, nid);
133 return -EINVAL;
136 return acomp->ops->sync_audio_rate(acomp->dev, port, pipe, rate);
141 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
142 * @codec: HDA codec
149 * This function is supposed to be used only by a HD-audio controller
150 * driver that needs the interaction with graphics driver.
161 int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id,
164 struct hdac_bus *bus = codec->bus;
165 struct drm_audio_component *acomp = bus->audio_component;
168 if (!acomp || !acomp->ops || !acomp->ops->get_eld)
169 return -ENODEV;
172 if (acomp->audio_ops && acomp->audio_ops->pin2port) {
173 port = acomp->audio_ops->pin2port(codec, nid);
175 return -EINVAL;
178 return acomp->ops->get_eld(acomp->dev, port, pipe, audio_enabled,
189 return -EINVAL;
195 if (WARN_ON(!(acomp->dev && acomp->ops))) {
196 ret = -EINVAL;
201 if (!try_module_get(acomp->ops->owner)) {
202 ret = -ENODEV;
206 if (acomp->audio_ops && acomp->audio_ops->master_bind) {
207 ret = acomp->audio_ops->master_bind(dev, acomp);
212 complete_all(&acomp->master_bind_complete);
216 module_put(acomp->ops->owner);
219 complete_all(&acomp->master_bind_complete);
228 if (acomp->audio_ops && acomp->audio_ops->master_unbind)
229 acomp->audio_ops->master_unbind(dev, acomp);
230 module_put(acomp->ops->owner);
232 WARN_ON(acomp->ops || acomp->dev);
241 * snd_hdac_acomp_register_notifier - Register audio component ops
245 * This function is supposed to be used only by a HD-audio controller
246 * driver that needs the interaction with graphics driver.
248 * This function sets the given ops to be called by the graphics driver.
255 if (!bus->audio_component)
256 return -ENODEV;
258 bus->audio_component->audio_ops = aops;
264 * snd_hdac_acomp_init - Initialize audio component
270 * This function is supposed to be used only by a HD-audio controller
271 * driver that needs the interaction with graphics driver.
274 * with graphics driver.
288 struct device *dev = bus->dev;
293 return -EBUSY;
298 return -ENOMEM;
299 acomp->audio_ops = aops;
300 init_completion(&acomp->master_bind_complete);
301 bus->audio_component = acomp;
313 bus->audio_component = NULL;
322 * snd_hdac_acomp_exit - Finalize audio component
325 * This function is supposed to be used only by a HD-audio controller
326 * driver that needs the interaction with graphics driver.
334 struct device *dev = bus->dev;
335 struct drm_audio_component *acomp = bus->audio_component;
340 if (WARN_ON(bus->display_power_active) && acomp->ops)
341 acomp->ops->put_power(acomp->dev, bus->display_power_active);
343 bus->display_power_active = 0;
344 bus->display_power_status = 0;
348 bus->audio_component = NULL;