Skip to content

Commit

Permalink
ALSA: hda: pass intel_hda to all i915 interface functions
Browse files Browse the repository at this point in the history
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@intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
  • Loading branch information
Imre Deak authored and Daniel Vetter committed Jan 12, 2015
1 parent 347de1f commit 926981a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
12 changes: 6 additions & 6 deletions sound/pci/hda/hda_i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down
28 changes: 16 additions & 12 deletions sound/pci/hda/hda_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down
19 changes: 11 additions & 8 deletions sound/pci/hda/hda_intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 926981a

Please sign in to comment.