diff options
author | Takashi Iwai <tiwai@suse.de> | 2018-07-11 09:17:22 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-07-17 16:25:19 -0400 |
commit | ae891abe7c2ccf75b69ca8330225e37ecc06924e (patch) | |
tree | b5b8e9c886221b22ae76e7a3480cad15fa1086b4 /sound/hda | |
parent | 9a9b13dd275dfe49ee0cf3ae5dc931069eb41475 (diff) |
drm/i915: Split audio component to a generic type
For allowing other drivers to use the DRM audio component, rename the
i915_audio_component_* with drm_audio_component_*, and split the
generic part into drm_audio_component.h. The i915 specific stuff
remains in struct i915_audio_component, which contains
drm_audio_component as the base.
The license of drm_audio_component.h is kept to MIT as same as the the
original i915_component.h.
This is a preliminary change for further development, and no
functional changes by this patch itself, merely code-split and
renames.
v1->v2: Use SPDX for drm_audio_component.h, fix remaining i915
argument in drm_audio_component.h
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/hdac_i915.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index cbe818eda336..1a88c1aaf9bb 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c | |||
@@ -16,13 +16,13 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/pci.h> | 17 | #include <linux/pci.h> |
18 | #include <linux/component.h> | 18 | #include <linux/component.h> |
19 | #include <drm/i915_component.h> | 19 | #include <drm/drm_audio_component.h> |
20 | #include <sound/core.h> | 20 | #include <sound/core.h> |
21 | #include <sound/hdaudio.h> | 21 | #include <sound/hdaudio.h> |
22 | #include <sound/hda_i915.h> | 22 | #include <sound/hda_i915.h> |
23 | #include <sound/hda_register.h> | 23 | #include <sound/hda_register.h> |
24 | 24 | ||
25 | static struct i915_audio_component *hdac_acomp; | 25 | static struct drm_audio_component *hdac_acomp; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup | 28 | * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup |
@@ -39,7 +39,7 @@ static struct i915_audio_component *hdac_acomp; | |||
39 | */ | 39 | */ |
40 | int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) | 40 | int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) |
41 | { | 41 | { |
42 | struct i915_audio_component *acomp = bus->audio_component; | 42 | struct drm_audio_component *acomp = bus->audio_component; |
43 | 43 | ||
44 | if (!acomp || !acomp->ops) | 44 | if (!acomp || !acomp->ops) |
45 | return -ENODEV; | 45 | return -ENODEV; |
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_set_codec_wakeup); | |||
74 | */ | 74 | */ |
75 | int snd_hdac_display_power(struct hdac_bus *bus, bool enable) | 75 | int snd_hdac_display_power(struct hdac_bus *bus, bool enable) |
76 | { | 76 | { |
77 | struct i915_audio_component *acomp = bus->audio_component; | 77 | struct drm_audio_component *acomp = bus->audio_component; |
78 | 78 | ||
79 | if (!acomp || !acomp->ops) | 79 | if (!acomp || !acomp->ops) |
80 | return -ENODEV; | 80 | return -ENODEV; |
@@ -83,14 +83,14 @@ int snd_hdac_display_power(struct hdac_bus *bus, bool enable) | |||
83 | enable ? "enable" : "disable"); | 83 | enable ? "enable" : "disable"); |
84 | 84 | ||
85 | if (enable) { | 85 | if (enable) { |
86 | if (!bus->i915_power_refcount++) { | 86 | if (!bus->drm_power_refcount++) { |
87 | acomp->ops->get_power(acomp->dev); | 87 | acomp->ops->get_power(acomp->dev); |
88 | snd_hdac_set_codec_wakeup(bus, true); | 88 | snd_hdac_set_codec_wakeup(bus, true); |
89 | snd_hdac_set_codec_wakeup(bus, false); | 89 | snd_hdac_set_codec_wakeup(bus, false); |
90 | } | 90 | } |
91 | } else { | 91 | } else { |
92 | WARN_ON(!bus->i915_power_refcount); | 92 | WARN_ON(!bus->drm_power_refcount); |
93 | if (!--bus->i915_power_refcount) | 93 | if (!--bus->drm_power_refcount) |
94 | acomp->ops->put_power(acomp->dev); | 94 | acomp->ops->put_power(acomp->dev); |
95 | } | 95 | } |
96 | 96 | ||
@@ -119,7 +119,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_display_power); | |||
119 | */ | 119 | */ |
120 | void snd_hdac_i915_set_bclk(struct hdac_bus *bus) | 120 | void snd_hdac_i915_set_bclk(struct hdac_bus *bus) |
121 | { | 121 | { |
122 | struct i915_audio_component *acomp = bus->audio_component; | 122 | struct drm_audio_component *acomp = bus->audio_component; |
123 | struct pci_dev *pci = to_pci_dev(bus->dev); | 123 | struct pci_dev *pci = to_pci_dev(bus->dev); |
124 | int cdclk_freq; | 124 | int cdclk_freq; |
125 | unsigned int bclk_m, bclk_n; | 125 | unsigned int bclk_m, bclk_n; |
@@ -206,7 +206,7 @@ int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, | |||
206 | int dev_id, int rate) | 206 | int dev_id, int rate) |
207 | { | 207 | { |
208 | struct hdac_bus *bus = codec->bus; | 208 | struct hdac_bus *bus = codec->bus; |
209 | struct i915_audio_component *acomp = bus->audio_component; | 209 | struct drm_audio_component *acomp = bus->audio_component; |
210 | int port, pipe; | 210 | int port, pipe; |
211 | 211 | ||
212 | if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) | 212 | if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate) |
@@ -244,7 +244,7 @@ int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id, | |||
244 | bool *audio_enabled, char *buffer, int max_bytes) | 244 | bool *audio_enabled, char *buffer, int max_bytes) |
245 | { | 245 | { |
246 | struct hdac_bus *bus = codec->bus; | 246 | struct hdac_bus *bus = codec->bus; |
247 | struct i915_audio_component *acomp = bus->audio_component; | 247 | struct drm_audio_component *acomp = bus->audio_component; |
248 | int port, pipe; | 248 | int port, pipe; |
249 | 249 | ||
250 | if (!acomp || !acomp->ops || !acomp->ops->get_eld) | 250 | if (!acomp || !acomp->ops || !acomp->ops->get_eld) |
@@ -262,7 +262,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_acomp_get_eld); | |||
262 | 262 | ||
263 | static int hdac_component_master_bind(struct device *dev) | 263 | static int hdac_component_master_bind(struct device *dev) |
264 | { | 264 | { |
265 | struct i915_audio_component *acomp = hdac_acomp; | 265 | struct drm_audio_component *acomp = hdac_acomp; |
266 | int ret; | 266 | int ret; |
267 | 267 | ||
268 | ret = component_bind_all(dev, acomp); | 268 | ret = component_bind_all(dev, acomp); |
@@ -294,7 +294,7 @@ out_unbind: | |||
294 | 294 | ||
295 | static void hdac_component_master_unbind(struct device *dev) | 295 | static void hdac_component_master_unbind(struct device *dev) |
296 | { | 296 | { |
297 | struct i915_audio_component *acomp = hdac_acomp; | 297 | struct drm_audio_component *acomp = hdac_acomp; |
298 | 298 | ||
299 | module_put(acomp->ops->owner); | 299 | module_put(acomp->ops->owner); |
300 | component_unbind_all(dev, acomp); | 300 | component_unbind_all(dev, acomp); |
@@ -323,7 +323,7 @@ static int hdac_component_master_match(struct device *dev, void *data) | |||
323 | * | 323 | * |
324 | * Returns zero for success or a negative error code. | 324 | * Returns zero for success or a negative error code. |
325 | */ | 325 | */ |
326 | int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops *aops) | 326 | int snd_hdac_i915_register_notifier(const struct drm_audio_component_audio_ops *aops) |
327 | { | 327 | { |
328 | if (!hdac_acomp) | 328 | if (!hdac_acomp) |
329 | return -ENODEV; | 329 | return -ENODEV; |
@@ -361,7 +361,8 @@ int snd_hdac_i915_init(struct hdac_bus *bus) | |||
361 | { | 361 | { |
362 | struct component_match *match = NULL; | 362 | struct component_match *match = NULL; |
363 | struct device *dev = bus->dev; | 363 | struct device *dev = bus->dev; |
364 | struct i915_audio_component *acomp; | 364 | struct i915_audio_component *i915_acomp; |
365 | struct drm_audio_component *acomp; | ||
365 | int ret; | 366 | int ret; |
366 | 367 | ||
367 | if (WARN_ON(hdac_acomp)) | 368 | if (WARN_ON(hdac_acomp)) |
@@ -370,9 +371,10 @@ int snd_hdac_i915_init(struct hdac_bus *bus) | |||
370 | if (!i915_gfx_present()) | 371 | if (!i915_gfx_present()) |
371 | return -ENODEV; | 372 | return -ENODEV; |
372 | 373 | ||
373 | acomp = kzalloc(sizeof(*acomp), GFP_KERNEL); | 374 | i915_acomp = kzalloc(sizeof(*i915_acomp), GFP_KERNEL); |
374 | if (!acomp) | 375 | if (!i915_acomp) |
375 | return -ENOMEM; | 376 | return -ENOMEM; |
377 | acomp = &i915_acomp->base; | ||
376 | bus->audio_component = acomp; | 378 | bus->audio_component = acomp; |
377 | hdac_acomp = acomp; | 379 | hdac_acomp = acomp; |
378 | 380 | ||
@@ -421,13 +423,13 @@ EXPORT_SYMBOL_GPL(snd_hdac_i915_init); | |||
421 | int snd_hdac_i915_exit(struct hdac_bus *bus) | 423 | int snd_hdac_i915_exit(struct hdac_bus *bus) |
422 | { | 424 | { |
423 | struct device *dev = bus->dev; | 425 | struct device *dev = bus->dev; |
424 | struct i915_audio_component *acomp = bus->audio_component; | 426 | struct drm_audio_component *acomp = bus->audio_component; |
425 | 427 | ||
426 | if (!acomp) | 428 | if (!acomp) |
427 | return 0; | 429 | return 0; |
428 | 430 | ||
429 | WARN_ON(bus->i915_power_refcount); | 431 | WARN_ON(bus->drm_power_refcount); |
430 | if (bus->i915_power_refcount > 0 && acomp->ops) | 432 | if (bus->drm_power_refcount > 0 && acomp->ops) |
431 | acomp->ops->put_power(acomp->dev); | 433 | acomp->ops->put_power(acomp->dev); |
432 | 434 | ||
433 | component_master_del(dev, &hdac_component_master_ops); | 435 | component_master_del(dev, &hdac_component_master_ops); |