On Wed, 21 Oct 2015 18:48:06 +0200, Takashi Iwai wrote:
On Wed, 21 Oct 2015 18:46:23 +0200, Takashi Iwai wrote:
Below is a test patch I cooked quickly. This is the third patch applied after other two more patches: a cleanup patch and a patch for deferred probe of HD-audio with component.
And this is the patch to defer the probe.
... and the first patch, a sort of cleanup, is here (sorry for the mess).
I put these three in test/hda-i915 branch of my sound git tree.
Takashi
---- 8< ---- From: Takashi Iwai tiwai@suse.de Subject: [PATCH 1/3] ALSA: hda - Pass hdac_device object at notifier registration
For dropping the local static variable in hdac_i915.c, add an argument to pass the hdac_device object to snd-Hdac_i915_register_notifier(). This allows us (in theory) having individual audio component per bus.
Signed-off-by: Takashi Iwai tiwai@suse.de --- include/sound/hda_i915.h | 6 ++++-- sound/hda/hdac_i915.c | 21 +++++++++++++-------- sound/pci/hda/patch_hdmi.c | 5 +++-- 3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/include/sound/hda_i915.h b/include/sound/hda_i915.h index 930b41e5acf4..7b19f1f8cc23 100644 --- a/include/sound/hda_i915.h +++ b/include/sound/hda_i915.h @@ -12,7 +12,8 @@ int snd_hdac_display_power(struct hdac_bus *bus, bool enable); int snd_hdac_get_display_clk(struct hdac_bus *bus); int snd_hdac_i915_init(struct hdac_bus *bus); int snd_hdac_i915_exit(struct hdac_bus *bus); -int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops *); +int snd_hdac_i915_register_notifier(struct hdac_device *codec, + const struct i915_audio_component_audio_ops *); #else static inline int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) { @@ -34,7 +35,8 @@ static inline int snd_hdac_i915_exit(struct hdac_bus *bus) { return 0; } -static inline int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops *ops) +static inline int snd_hdac_i915_register_notifier(struct hdac_device *codec, + const struct i915_audio_component_audio_ops *ops) { return -ENODEV; } diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index 55c3df4458f7..e36ed18f23c4 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -21,8 +21,6 @@ #include <sound/hdaudio.h> #include <sound/hda_i915.h>
-static struct i915_audio_component *hdac_acomp; - int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) { struct i915_audio_component *acomp = bus->audio_component; @@ -84,7 +82,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk);
static int hdac_component_master_bind(struct device *dev) { - struct i915_audio_component *acomp = hdac_acomp; + struct hdac_device *codec = dev_to_hdac_dev(dev); + struct hdac_bus *bus = codec->bus; + struct i915_audio_component *acomp = bus->audio_component; int ret;
ret = component_bind_all(dev, acomp); @@ -116,7 +116,9 @@ out_unbind:
static void hdac_component_master_unbind(struct device *dev) { - struct i915_audio_component *acomp = hdac_acomp; + struct hdac_device *codec = dev_to_hdac_dev(dev); + struct hdac_bus *bus = codec->bus; + struct i915_audio_component *acomp = bus->audio_component;
module_put(acomp->ops->owner); component_unbind_all(dev, acomp); @@ -134,12 +136,16 @@ static int hdac_component_master_match(struct device *dev, void *data) return !strcmp(dev->driver->name, "i915"); }
-int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops *aops) +int snd_hdac_i915_register_notifier(struct hdac_device *codec, + const struct i915_audio_component_audio_ops *aops) { - if (WARN_ON(!hdac_acomp)) + struct hdac_bus *bus = codec->bus; + struct i915_audio_component *acomp = bus->audio_component; + + if (WARN_ON(!acomp)) return -ENODEV;
- hdac_acomp->audio_ops = aops; + acomp->audio_ops = aops; return 0; } EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier); @@ -155,7 +161,6 @@ int snd_hdac_i915_init(struct hdac_bus *bus) if (!acomp) return -ENOMEM; bus->audio_component = acomp; - hdac_acomp = acomp;
component_match_add(dev, &match, hdac_component_master_match, bus); ret = component_master_add_with_match(dev, &hdac_component_master_ops, diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index f503a883bef3..fbd60ea98f19 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2216,7 +2216,7 @@ static void generic_hdmi_free(struct hda_codec *codec) int pin_idx;
if (is_haswell_plus(codec) || is_valleyview_plus(codec)) - snd_hdac_i915_register_notifier(NULL); + snd_hdac_i915_register_notifier(&codec->core, NULL);
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); @@ -2381,7 +2381,8 @@ static int patch_generic_hdmi(struct hda_codec *codec) codec->depop_delay = 0; spec->i915_audio_ops.audio_ptr = codec; spec->i915_audio_ops.pin_eld_notify = intel_pin_eld_notify; - snd_hdac_i915_register_notifier(&spec->i915_audio_ops); + snd_hdac_i915_register_notifier(&codec->core, + &spec->i915_audio_ops); }
if (hdmi_parse_codec(codec) < 0) {