diff options
author | Dylan Reid <dgreid@chromium.org> | 2014-02-28 23:41:13 (GMT) |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-03-01 10:20:37 (GMT) |
commit | 408308133380fcd87a79520a2060850e68fdc2f3 (patch) | |
tree | ae38bec99ae1de1adb02f4008113cbbd448ee68e /sound/pci/hda/hda_priv.h | |
parent | 2538a4f583e0e287f4ab96e431316789987d96b6 (diff) | |
download | linux-408308133380fcd87a79520a2060850e68fdc2f3.tar.xz |
ALSA: hda - Allow different ops to read/write registers
The forthcoming platform hda driver needs to override the way
registers are read and written. In preparation for that, introduce a
reg_ops struct that can be implemented differently by the new driver.
Change the existing macros to use the new structure, and move them to
hda_priv.h where they will be accessible to both PCI and platform
drivers.
Start with register access, but later commits will add more ops that
differ between PCI and platform.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_priv.h')
-rw-r--r-- | sound/pci/hda/hda_priv.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h index 7656494..6d082d6 100644 --- a/sound/pci/hda/hda_priv.h +++ b/sound/pci/hda/hda_priv.h @@ -285,6 +285,17 @@ struct azx_rb { u32 res[AZX_MAX_CODECS]; /* last read value */ }; +/* Functions to read/write to hda registers. */ +struct hda_controller_ops { + /* Register Access */ + void (*writel)(u32 value, u32 *addr); + u32 (*readl)(u32 *addr); + void (*writew)(u16 value, u16 *addr); + u16 (*readw)(u16 *addr); + void (*writeb)(u8 value, u8 *addr); + u8 (*readb)(u8 *addr); +}; + struct azx_pcm { struct azx *chip; struct snd_pcm *pcm; @@ -307,6 +318,9 @@ struct azx { int capture_index_offset; int num_streams; + /* Register interaction. */ + const struct hda_controller_ops *ops; + /* pci resources */ unsigned long addr; void __iomem *remap_addr; @@ -395,4 +409,34 @@ struct azx { #define azx_snoop(chip) true #endif +/* + * macros for easy use + */ + +#define azx_writel(chip, reg, value) \ + ((chip)->ops->writel(value, (chip)->remap_addr + ICH6_REG_##reg)) +#define azx_readl(chip, reg) \ + ((chip)->ops->readl((chip)->remap_addr + ICH6_REG_##reg)) +#define azx_writew(chip, reg, value) \ + ((chip)->ops->writew(value, (chip)->remap_addr + ICH6_REG_##reg)) +#define azx_readw(chip, reg) \ + ((chip)->ops->readw((chip)->remap_addr + ICH6_REG_##reg)) +#define azx_writeb(chip, reg, value) \ + ((chip)->ops->writeb(value, (chip)->remap_addr + ICH6_REG_##reg)) +#define azx_readb(chip, reg) \ + ((chip)->ops->readb((chip)->remap_addr + ICH6_REG_##reg)) + +#define azx_sd_writel(chip, dev, reg, value) \ + ((chip)->ops->writel(value, (dev)->sd_addr + ICH6_REG_##reg)) +#define azx_sd_readl(chip, dev, reg) \ + ((chip)->ops->readl((dev)->sd_addr + ICH6_REG_##reg)) +#define azx_sd_writew(chip, dev, reg, value) \ + ((chip)->ops->writew(value, (dev)->sd_addr + ICH6_REG_##reg)) +#define azx_sd_readw(chip, dev, reg) \ + ((chip)->ops->readw((dev)->sd_addr + ICH6_REG_##reg)) +#define azx_sd_writeb(chip, dev, reg, value) \ + ((chip)->ops->writeb(value, (dev)->sd_addr + ICH6_REG_##reg)) +#define azx_sd_readb(chip, dev, reg) \ + ((chip)->ops->readb((dev)->sd_addr + ICH6_REG_##reg)) + #endif /* __SOUND_HDA_PRIV_H */ |