[Intel-gfx] [PATCH v4 4/6] ALSA: hda: pass intel_hda to all i915 interface functions
Imre Deak
imre.deak at intel.com
Thu Jan 8 07:54:16 PST 2015
chip is already passed to most of the i915 interface functions. Unify
the interface by passing intel_hda instead of chip and passing it to all
functions. Passing intel_hda instead of chip makes more sense since this
is an intel specific interface. Also in an upcoming patch we will use
intel_hda in all of these functions so by passing intel_hda we can save
on some pointer casts from chip to intel_hda.
This will be needed by an upcoming patch adding component support.
No functional change.
v2-3: unchanged
v4:
- pass intel_hda instead of chip
Signed-off-by: Imre Deak <imre.deak at intel.com>
Reviewed-by: Takashi Iwai <tiwai at suse.de>
---
sound/pci/hda/hda_i915.c | 12 ++++++------
sound/pci/hda/hda_intel.c | 28 ++++++++++++++++------------
sound/pci/hda/hda_intel.h | 19 +++++++++++--------
3 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 6a7854d..66acd09 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -35,7 +35,7 @@ static int (*get_power)(void);
static int (*put_power)(void);
static int (*get_cdclk)(void);
-int hda_display_power(bool enable)
+int hda_display_power(struct hda_intel *hda, bool enable)
{
if (!get_power || !put_power)
return -ENODEV;
@@ -48,7 +48,7 @@ int hda_display_power(bool enable)
return put_power();
}
-void haswell_set_bclk(struct azx *chip)
+void haswell_set_bclk(struct hda_intel *hda)
{
int cdclk_freq;
unsigned int bclk_m, bclk_n;
@@ -80,12 +80,12 @@ void haswell_set_bclk(struct azx *chip)
break;
}
- azx_writew(chip, EM4, bclk_m);
- azx_writew(chip, EM5, bclk_n);
+ azx_writew(&hda->chip, EM4, bclk_m);
+ azx_writew(&hda->chip, EM5, bclk_n);
}
-int hda_i915_init(void)
+int hda_i915_init(struct hda_intel *hda)
{
int err = 0;
@@ -111,7 +111,7 @@ int hda_i915_init(void)
return err;
}
-int hda_i915_exit(void)
+int hda_i915_exit(struct hda_intel *hda)
{
if (get_power) {
symbol_put(i915_request_power_well);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index e4bc0dc..323abf9 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -803,7 +803,7 @@ static int azx_suspend(struct device *dev)
pci_save_state(pci);
pci_set_power_state(pci, PCI_D3hot);
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
- hda_display_power(false);
+ hda_display_power(hda, false);
return 0;
}
@@ -823,8 +823,8 @@ static int azx_resume(struct device *dev)
return 0;
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
- hda_display_power(true);
- haswell_set_bclk(chip);
+ hda_display_power(hda, true);
+ haswell_set_bclk(hda);
}
pci_set_power_state(pci, PCI_D0);
pci_restore_state(pci);
@@ -876,7 +876,7 @@ static int azx_runtime_suspend(struct device *dev)
azx_enter_link_reset(chip);
azx_clear_irq_pending(chip);
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
- hda_display_power(false);
+ hda_display_power(hda, false);
return 0;
}
@@ -902,8 +902,8 @@ static int azx_runtime_resume(struct device *dev)
return 0;
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
- hda_display_power(true);
- haswell_set_bclk(chip);
+ hda_display_power(hda, true);
+ haswell_set_bclk(hda);
}
/* Read STATESTS before controller reset */
@@ -1125,8 +1125,8 @@ static int azx_free(struct azx *chip)
release_firmware(chip->fw);
#endif
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
- hda_display_power(false);
- hda_i915_exit();
+ hda_display_power(hda, false);
+ hda_i915_exit(hda);
}
kfree(hda);
@@ -1604,8 +1604,12 @@ static int azx_first_init(struct azx *chip)
/* initialize chip */
azx_init_pci(chip);
- if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
- haswell_set_bclk(chip);
+ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
+ struct hda_intel *hda;
+
+ hda = container_of(chip, struct hda_intel, chip);
+ haswell_set_bclk(hda);
+ }
azx_init_chip(chip, (probe_only[dev] & 2) == 0);
@@ -1885,13 +1889,13 @@ static int azx_probe_continue(struct azx *chip)
/* Request power well for Haswell HDA controller and codec */
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
#ifdef CONFIG_SND_HDA_I915
- err = hda_i915_init();
+ err = hda_i915_init(hda);
if (err < 0) {
dev_err(chip->card->dev,
"Error request power-well from i915\n");
goto out_free;
}
- err = hda_display_power(true);
+ err = hda_display_power(hda, true);
if (err < 0) {
dev_err(chip->card->dev,
"Cannot turn on display power on i915\n");
diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h
index 434f254..70b8306 100644
--- a/sound/pci/hda/hda_intel.h
+++ b/sound/pci/hda/hda_intel.h
@@ -44,18 +44,21 @@ struct hda_intel {
};
#ifdef CONFIG_SND_HDA_I915
-int hda_display_power(bool enable);
-void haswell_set_bclk(struct azx *chip);
-int hda_i915_init(void);
-int hda_i915_exit(void);
+int hda_display_power(struct hda_intel *hda, bool enable);
+void haswell_set_bclk(struct hda_intel *hda);
+int hda_i915_init(struct hda_intel *hda);
+int hda_i915_exit(struct hda_intel *hda);
#else
-static inline int hda_display_power(bool enable) { return 0; }
-static inline void haswell_set_bclk(struct azx *chip) { return; }
-static inline int hda_i915_init(void)
+static inline int hda_display_power(struct hda_intel *hda, bool enable)
+{
+ return 0;
+}
+static inline void haswell_set_bclk(struct hda_intel *hda) { return; }
+static inline int hda_i915_init(struct hda_intel *hda)
{
return -ENODEV;
}
-static inline int hda_i915_exit(void)
+static inline int hda_i915_exit(struct hda_intel *hda)
{
return 0;
}
--
2.1.0
More information about the Intel-gfx
mailing list