From patchwork Wed Oct 21 16:48:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 7458741 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 37E369F37F for ; Wed, 21 Oct 2015 16:48:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EFBB20889 for ; Wed, 21 Oct 2015 16:48:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id E14DF20875 for ; Wed, 21 Oct 2015 16:48:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 064BC6E09F; Wed, 21 Oct 2015 09:48:09 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id E183E6E09F for ; Wed, 21 Oct 2015 09:48:07 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 79E26AD06; Wed, 21 Oct 2015 16:48:05 +0000 (UTC) Date: Wed, 21 Oct 2015 18:48:06 +0200 Message-ID: From: Takashi Iwai To: Daniel Vetter Subject: Re: [alsa-devel] HDMI codec, way forward? In-Reply-To: References: <20151018171641.GV32532@n2100.arm.linux.org.uk> <20151020033809.GZ27370@localhost> <20151020080800.GU32532@n2100.arm.linux.org.uk> <20151020140148.GC27370@localhost> <20151021092744.GC32532@n2100.arm.linux.org.uk> <20151021140307.GE32532@n2100.arm.linux.org.uk> <20151021153601.GH16848@phenom.ffwll.local> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: alsa-devel@alsa-project.org, Russell King - ARM Linux , Vinod Koul , broonie@kernel.org, Arnaud Pouliquen , lgirdwood@gmail.com, dri-devel@lists.freedesktop.org, peter.ujfalusi@ti.com, tomi.valkeinen@ti.com, Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. -- 8< -- From: Takashi Iwai Subject: [PATCH 2/3] ALSA: hda - Implement deferred probe for i915 audio component For Intel controllers that mandate i915 binding, the probe is deferred and done through the component master bind ops. The controller driver needs to pass its ops to continue the probe. For the legacy HDA, we just call the existing azx_probe_continue() there. A possible drawback is that there might be no longer fallback working when the i915 graphics is unavailable, e.g. boot with nomodeset option, on SKL/BSW. Signed-off-by: Takashi Iwai --- include/sound/hda_i915.h | 7 ++++-- sound/hda/hdac_i915.c | 60 ++++++++++++++++++++++------------------------- sound/pci/hda/hda_intel.c | 45 +++++++++++++++++++---------------- 3 files changed, 58 insertions(+), 54 deletions(-) diff --git a/include/sound/hda_i915.h b/include/sound/hda_i915.h index 7b19f1f8cc23..b42449af6cd2 100644 --- a/include/sound/hda_i915.h +++ b/include/sound/hda_i915.h @@ -4,13 +4,15 @@ #ifndef __SOUND_HDA_I915_H #define __SOUND_HDA_I915_H +#include #include #ifdef CONFIG_SND_HDA_I915 int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable); 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_init(struct hdac_bus *bus, + const struct component_master_ops *codec_ops); int snd_hdac_i915_exit(struct hdac_bus *bus); int snd_hdac_i915_register_notifier(struct hdac_device *codec, const struct i915_audio_component_audio_ops *); @@ -27,7 +29,8 @@ static inline int snd_hdac_get_display_clk(struct hdac_bus *bus) { return 0; } -static inline int snd_hdac_i915_init(struct hdac_bus *bus) +static inline int snd_hdac_i915_init(struct hdac_bus *bus, + const struct component_master_ops *codec_ops) { return -ENODEV; } diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index e36ed18f23c4..f6fc16cfd02c 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -21,6 +21,11 @@ #include #include +struct hdac_gfx_component { + struct i915_audio_component acomp; + const struct component_master_ops *ops; +}; + int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable) { struct i915_audio_component *acomp = bus->audio_component; @@ -85,6 +90,8 @@ static int hdac_component_master_bind(struct device *dev) struct hdac_device *codec = dev_to_hdac_dev(dev); struct hdac_bus *bus = codec->bus; struct i915_audio_component *acomp = bus->audio_component; + struct hdac_gfx_component *hda_comp = + container_of(acomp, struct hdac_gfx_component, acomp); int ret; ret = component_bind_all(dev, acomp); @@ -106,6 +113,14 @@ static int hdac_component_master_bind(struct device *dev) goto out_unbind; } + if (hda_comp->ops && hda_comp->ops->bind) { + ret = hda_comp->ops->bind(dev); + if (ret < 0) { + module_put(acomp->ops->owner); + goto out_unbind; + } + } + return 0; out_unbind: @@ -119,7 +134,11 @@ static void hdac_component_master_unbind(struct device *dev) struct hdac_device *codec = dev_to_hdac_dev(dev); struct hdac_bus *bus = codec->bus; struct i915_audio_component *acomp = bus->audio_component; + struct hdac_gfx_component *hda_comp = + container_of(acomp, struct hdac_gfx_component, acomp); + if (hda_comp->ops && hda_comp->ops->unbind) + hda_comp->ops->unbind(dev); module_put(acomp->ops->owner); component_unbind_all(dev, acomp); WARN_ON(acomp->ops || acomp->dev); @@ -150,45 +169,22 @@ int snd_hdac_i915_register_notifier(struct hdac_device *codec, } EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier); -int snd_hdac_i915_init(struct hdac_bus *bus) +int snd_hdac_i915_init(struct hdac_bus *bus, + const struct component_master_ops *codec_ops) { struct component_match *match = NULL; struct device *dev = bus->dev; - struct i915_audio_component *acomp; - int ret; + struct hdac_gfx_component *hda_comp; - acomp = kzalloc(sizeof(*acomp), GFP_KERNEL); - if (!acomp) + hda_comp = kzalloc(sizeof(*hda_comp), GFP_KERNEL); + if (!hda_comp) return -ENOMEM; - bus->audio_component = acomp; + bus->audio_component = &hda_comp->acomp; + hda_comp->ops = codec_ops; component_match_add(dev, &match, hdac_component_master_match, bus); - ret = component_master_add_with_match(dev, &hdac_component_master_ops, - match); - if (ret < 0) - goto out_err; - - /* - * Atm, we don't support deferring the component binding, so make sure - * i915 is loaded and that the binding successfully completes. - */ - request_module("i915"); - - if (!acomp->ops) { - ret = -ENODEV; - goto out_master_del; - } - dev_dbg(dev, "bound to i915 component master\n"); - - return 0; -out_master_del: - component_master_del(dev, &hdac_component_master_ops); -out_err: - kfree(acomp); - bus->audio_component = NULL; - dev_err(dev, "failed to add i915 component master (%d)\n", ret); - - return ret; + return component_master_add_with_match(dev, &hdac_component_master_ops, + match); } EXPORT_SYMBOL_GPL(snd_hdac_i915_init); diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index c38c68f57938..78deda018894 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1884,6 +1884,20 @@ static const struct hda_controller_ops pci_hda_ops = { .link_power = azx_intel_link_power, }; +#ifdef CONFIG_SND_HDA_I915 +static int azx_i915_bind(struct device *dev) +{ + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip = card->private_data; + + return azx_probe_continue(chip); +} + +static const struct component_master_ops component_ops = { + .bind = azx_i915_bind, +}; +#endif /* CONFIG_SND_HDA_I915 */ + static int azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { @@ -1943,10 +1957,19 @@ static int azx_probe(struct pci_dev *pci, } #endif /* CONFIG_SND_HDA_PATCH_LOADER */ -#ifndef CONFIG_SND_HDA_I915 - if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { +#ifdef CONFIG_SND_HDA_I915 + /* HSW/BDW controllers need this power */ + if (CONTROLLER_IN_GPU(pci)) + hda->need_i915_power = 1; + err = snd_hdac_i915_init(azx_bus(chip), &component_ops); + if (err < 0) + goto out_free; + schedule_probe = false; /* continue via bind ops */ +#else dev_err(card->dev, "Haswell must build in CONFIG_SND_HDA_I915\n"); #endif + } if (schedule_probe) schedule_work(&hda->probe_work); @@ -1983,23 +2006,6 @@ static int azx_probe_continue(struct azx *chip) * display codec needs the power and it can be released after probe. */ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { - /* HSW/BDW controllers need this power */ - if (CONTROLLER_IN_GPU(pci)) - hda->need_i915_power = 1; - - err = snd_hdac_i915_init(bus); - if (err < 0) { - /* if the controller is bound only with HDMI/DP - * (for HSW and BDW), we need to abort the probe; - * for other chips, still continue probing as other - * codecs can be on the same link. - */ - if (CONTROLLER_IN_GPU(pci)) - goto out_free; - else - goto skip_i915; - } - err = snd_hdac_display_power(bus, true); if (err < 0) { dev_err(chip->card->dev, @@ -2008,7 +2014,6 @@ static int azx_probe_continue(struct azx *chip) } } - skip_i915: err = azx_first_init(chip); if (err < 0) goto out_free;