From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org, alsa-devel@alsa-project.org,
Takashi Iwai <tiwai@suse.de>
Cc: Jani Nikula <jani.nikula@intel.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH v2 4/5] ALSA: hda: add component support
Date: Tue, 9 Dec 2014 11:41:18 +0200 [thread overview]
Message-ID: <1418118078-3676-3-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1418118078-3676-1-git-send-email-imre.deak@intel.com>
In-Reply-To: <1418056929-7977-5-git-send-email-imre.deak@intel.com>
Register a component master to be used to interface with the i915
driver. This is meant to replace the current interface which is based on
module symbol lookups.
Note that currently we keep the existing behavior and pin the i915
module while the hda driver is loaded. Using the component interface
allows us to remove this dependency once support for dynamically
enabling / disabling the HDMI functionality is added to the driver.
v2:
- change roles between the hda and i915 components (Daniel)
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
sound/pci/hda/hda_i915.c | 137 +++++++++++++++++++++++++++++++++-------------
sound/pci/hda/hda_intel.c | 3 +-
sound/pci/hda/hda_priv.h | 4 ++
3 files changed, 104 insertions(+), 40 deletions(-)
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 4e4b733..2bf6a1b 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -18,8 +18,10 @@
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/component.h>
+#include <drm/i915_component.h>
#include <sound/core.h>
-#include <drm/i915_powerwell.h>
#include "hda_priv.h"
#include "hda_i915.h"
@@ -31,32 +33,33 @@
#define AZX_REG_EM4 0x100c
#define AZX_REG_EM5 0x1010
-static int (*get_power)(void);
-static int (*put_power)(void);
-static int (*get_cdclk)(void);
-
int hda_display_power(struct azx *chip, bool enable)
{
- if (!get_power || !put_power)
+ struct i915_display_component *dcomp = &chip->display_component;
+
+ if (!dcomp->ops)
return -ENODEV;
pr_debug("HDA display power %s \n",
enable ? "Enable" : "Disable");
if (enable)
- return get_power();
+ dcomp->ops->get_power(dcomp->dev);
else
- return put_power();
+ dcomp->ops->put_power(dcomp->dev);
+
+ return 0;
}
void haswell_set_bclk(struct azx *chip)
{
int cdclk_freq;
unsigned int bclk_m, bclk_n;
+ struct i915_display_component *dcomp = &chip->display_component;
- if (!get_cdclk)
+ if (!dcomp->ops)
return;
- cdclk_freq = get_cdclk();
+ cdclk_freq = dcomp->ops->get_cdclk_freq(dcomp->dev);
switch (cdclk_freq) {
case 337500:
bclk_m = 16;
@@ -84,47 +87,104 @@ void haswell_set_bclk(struct azx *chip)
azx_writew(chip, EM5, bclk_n);
}
+static int hda_component_master_bind(struct device *dev)
+{
+ struct snd_card *card = dev_get_drvdata(dev);
+ struct azx *chip = card->private_data;
+ struct i915_display_component *dcomp = &chip->display_component;
+ int ret;
+
+ ret = component_bind_all(dev, dcomp);
+ if (ret < 0)
+ return ret;
+
+ if (WARN_ON(!(dcomp->dev && dcomp->ops && dcomp->ops->get_power &&
+ dcomp->ops->put_power && dcomp->ops->get_cdclk_freq))) {
+ ret = -EINVAL;
+ goto out_unbind;
+ }
+
+ /*
+ * Atm, we don't support dynamic unbinding initiated by the child
+ * component, so pin its containing module until we unbind.
+ */
+ if (!try_module_get(dcomp->ops->owner)) {
+ ret = -ENODEV;
+ goto out_unbind;
+ }
+
+ return 0;
+
+out_unbind:
+ component_unbind_all(dev, dcomp);
+
+ return ret;
+}
+
+static void hda_component_master_unbind(struct device *dev)
+{
+ struct snd_card *card = dev_get_drvdata(dev);
+ struct azx *chip = card->private_data;
+ struct i915_display_component *dcomp = &chip->display_component;
+
+ module_put(dcomp->ops->owner);
+ component_unbind_all(dev, dcomp);
+ WARN_ON(dcomp->ops || dcomp->dev);
+}
+
+static const struct component_master_ops hda_component_master_ops = {
+ .bind = hda_component_master_bind,
+ .unbind = hda_component_master_unbind,
+};
+
+static int hda_component_master_match(struct device *dev, void *data)
+{
+ /* i915 is the only supported component */
+ return !strcmp(dev->driver->name, "i915");
+}
int hda_i915_init(struct azx *chip)
{
- int err = 0;
+ struct component_match *match = NULL;
+ struct device *dev = &chip->pci->dev;
+ struct i915_display_component *dcomp = &chip->display_component;
+ int ret;
- get_power = symbol_request(i915_request_power_well);
- if (!get_power) {
- pr_warn("hda-i915: get_power symbol get fail\n");
- return -ENODEV;
- }
-
- put_power = symbol_request(i915_release_power_well);
- if (!put_power) {
- symbol_put(i915_request_power_well);
- get_power = NULL;
- return -ENODEV;
- }
-
- get_cdclk = symbol_request(i915_get_cdclk_freq);
- if (!get_cdclk) /* may have abnormal BCLK and audio playback rate */
- pr_warn("hda-i915: get_cdclk symbol get fail\n");
-
+ component_match_add(dev, &match, hda_component_master_match, chip);
+ ret = component_master_add_with_match(dev, &hda_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.
+ */
+ ret = request_module("i915");
+ if (ret < 0)
+ goto out_master_del;
+
+ if (!dcomp->ops) {
+ ret = -ENODEV;
+ goto out_master_del;
+ }
+
- pr_debug("HDA driver get symbol successfully from i915 module\n");
+ pr_debug("hda-i915: bound to i915 component\n");
+
+ return 0;
+out_master_del:
+ component_master_del(dev, &hda_component_master_ops);
+out_err:
+ pr_warn("hda-i915: failed to add component master (%d)\n", ret);
- return err;
+ return ret;
}
int hda_i915_exit(struct azx *chip)
{
- if (get_power) {
- symbol_put(i915_request_power_well);
- get_power = NULL;
- }
- if (put_power) {
- symbol_put(i915_release_power_well);
- put_power = NULL;
- }
- if (get_cdclk) {
- symbol_put(i915_get_cdclk_freq);
- get_cdclk = NULL;
- }
+ struct device *dev = &chip->pci->dev;
+
+ component_master_del(dev, &hda_component_master_ops);
return 0;
}
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f3b5dcd..e15b30e 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1912,8 +1912,7 @@ static int azx_probe_continue(struct azx *chip)
#ifdef CONFIG_SND_HDA_I915
err = hda_i915_init(chip);
if (err < 0) {
- dev_err(chip->card->dev,
- "Error request power-well from i915\n");
+ dev_err(chip->card->dev, "Error binding to i915\n");
goto out_free;
}
err = hda_display_power(chip, true);
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
index aa484fd..af227f3 100644
--- a/sound/pci/hda/hda_priv.h
+++ b/sound/pci/hda/hda_priv.h
@@ -18,6 +18,7 @@
#include <linux/clocksource.h>
#include <sound/core.h>
#include <sound/pcm.h>
+#include <drm/i915_component.h>
/*
* registers
@@ -291,6 +292,9 @@ struct azx {
struct pci_dev *pci;
int dev_index;
+ /* i915 component interface */
+ struct i915_display_component display_component;
+
/* chip type specific */
int driver_type;
unsigned int driver_caps;
--
1.8.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2014-12-09 9:41 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-08 16:42 [PATCH 0/5] sanitize hda/i915 interface using the component fw Imre Deak
2014-12-08 16:42 ` [PATCH 1/5] drm/i915: add dev_to_i915_priv helper Imre Deak
2014-12-08 18:36 ` Jani Nikula
2014-12-08 19:54 ` Imre Deak
2014-12-08 20:27 ` Daniel Vetter
2014-12-08 20:40 ` Chris Wilson
2014-12-08 21:26 ` Imre Deak
2014-12-09 9:41 ` [PATCH v2 1/5] drm/i915: add dev_to_i915 helper Imre Deak
2014-12-09 10:08 ` Daniel Vetter
2014-12-09 16:15 ` [PATCH v3 " Imre Deak
2014-12-08 16:42 ` [PATCH 2/5] drm/i915: add component support Imre Deak
2014-12-08 18:44 ` Jani Nikula
2014-12-08 20:23 ` Imre Deak
2014-12-09 9:41 ` [PATCH v2 " Imre Deak
2014-12-09 10:12 ` Daniel Vetter
2014-12-09 10:33 ` Jani Nikula
2014-12-10 9:24 ` Daniel Vetter
2014-12-09 16:15 ` [PATCH v3 " Imre Deak
2014-12-10 8:22 ` Jani Nikula
2014-12-10 13:18 ` Imre Deak
2014-12-08 16:42 ` [PATCH 3/5] ALSA: hda: pass chip to all i915 interface functions Imre Deak
2014-12-08 16:42 ` [PATCH 4/5] ALSA: hda: add component support Imre Deak
2014-12-09 9:41 ` Imre Deak [this message]
2014-12-09 10:19 ` [PATCH v2 " Daniel Vetter
2014-12-09 17:30 ` Takashi Iwai
2014-12-10 9:27 ` Daniel Vetter
2014-12-09 16:15 ` [PATCH v3 " Imre Deak
2014-12-08 16:42 ` [PATCH 5/5] drm/i915: remove unused power_well/get_cdclk_freq api Imre Deak
2014-12-08 18:46 ` Jani Nikula
2014-12-08 20:14 ` [PATCH 0/5] sanitize hda/i915 interface using the component fw Daniel Vetter
2014-12-09 8:59 ` Imre Deak
2014-12-09 10:03 ` Daniel Vetter
2014-12-09 16:56 ` Imre Deak
2014-12-09 17:33 ` Takashi Iwai
2015-01-05 15:29 ` Imre Deak
2015-01-05 15:35 ` Takashi Iwai
2015-01-05 17:25 ` Imre Deak
2015-01-06 10:25 ` Takashi Iwai
2015-01-07 19:49 ` Imre Deak
2015-01-08 14:35 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418118078-3676-3-git-send-email-imre.deak@intel.com \
--to=imre.deak@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox