summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_controller.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-04-14 22:13:18 +0200
committerTakashi Iwai <tiwai@suse.de>2015-04-16 08:47:22 +0200
commita41d122449bea303ada415ef5fb2bf434f5481f9 (patch)
treee6f516f463dcf330567f226d4e9b1f43b2bc9e0e /sound/pci/hda/hda_controller.h
parentALSA: hda - Migrate more hdac_stream codes (diff)
downloadlinux-a41d122449bea303ada415ef5fb2bf434f5481f9.tar.xz
linux-a41d122449bea303ada415ef5fb2bf434f5481f9.zip
ALSA: hda - Embed bus into controller object
... and replace with the existing hda-core helper codes. This reduces lots of lines, finally. Since struct hda_bus is now embedded into struct azx, snd_hda_bus_new() is moved and expanded from hda_codec.c to hda_controller.c, accordingly. Also private_free bus ops and private_data field are removed because we no longer need to point azx object from bus (we can use container_of()) The spin locks are consolidated into the single one, bus->reg_lock. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_controller.h')
-rw-r--r--sound/pci/hda/hda_controller.h65
1 files changed, 20 insertions, 45 deletions
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
index b45568d83860..e8edb02c12d3 100644
--- a/sound/pci/hda/hda_controller.h
+++ b/sound/pci/hda/hda_controller.h
@@ -75,18 +75,6 @@ struct azx_dev {
#define azx_stream(dev) (&(dev)->core)
#define stream_to_azx_dev(s) container_of(s, struct azx_dev, core)
-/* CORB/RIRB */
-struct azx_rb {
- u32 *buf; /* CORB/RIRB buffer
- * Each CORB entry is 4byte, RIRB is 8byte
- */
- dma_addr_t addr; /* physical address of CORB/RIRB buffer */
- /* for RIRB */
- unsigned short rp, wp; /* read/write pointers */
- int cmds[AZX_MAX_CODECS]; /* number of pending requests */
- u32 res[AZX_MAX_CODECS]; /* last read value */
-};
-
struct azx;
/* Functions to read/write to hda registers. */
@@ -116,6 +104,8 @@ typedef unsigned int (*azx_get_pos_callback_t)(struct azx *, struct azx_dev *);
typedef int (*azx_get_delay_callback_t)(struct azx *, struct azx_dev *, unsigned int pos);
struct azx {
+ struct hda_bus bus;
+
struct snd_card *card;
struct pci_dev *pci;
int dev_index;
@@ -132,38 +122,21 @@ struct azx {
/* Register interaction. */
const struct hda_controller_ops *ops;
- const struct hdac_io_ops *io_ops;
/* position adjustment callbacks */
azx_get_pos_callback_t get_position[2];
azx_get_delay_callback_t get_delay[2];
- /* pci resources */
- unsigned long addr;
- void __iomem *remap_addr;
- int irq;
-
/* locks */
- spinlock_t reg_lock;
struct mutex open_mutex; /* Prevents concurrent open/close operations */
/* PCM */
struct list_head pcm_list; /* azx_pcm list */
/* HD codec */
- unsigned short codec_mask;
int codec_probe_mask; /* copied from probe_mask option */
- struct hda_bus *bus;
unsigned int beep_mode;
- /* CORB/RIRB */
- struct azx_rb corb;
- struct azx_rb rirb;
-
- /* CORB/RIRB and position buffers */
- struct snd_dma_buffer rb;
- struct snd_dma_buffer posbuf;
-
#ifdef CONFIG_SND_HDA_PATCH_LOADER
const struct firmware *fw;
#endif
@@ -172,7 +145,6 @@ struct azx {
const int *bdl_pos_adj;
int poll_count;
unsigned int running:1;
- unsigned int initialized:1;
unsigned int single_cmd:1;
unsigned int polling_mode:1;
unsigned int msi:1;
@@ -182,15 +154,13 @@ struct azx {
unsigned int region_requested:1;
unsigned int disabled:1; /* disabled by VGA-switcher */
- /* for debugging */
- unsigned int last_cmd[AZX_MAX_CODECS];
-
#ifdef CONFIG_SND_HDA_DSP_LOADER
struct azx_dev saved_azx_dev;
#endif
};
-#define azx_bus(chip) (&(chip)->bus->core)
+#define azx_bus(chip) (&(chip)->bus.core)
+#define bus_to_azx(_bus) container_of(_bus, struct azx, bus.core)
#ifdef CONFIG_X86
#define azx_snoop(chip) ((chip)->snoop)
@@ -203,17 +173,17 @@ struct azx {
*/
#define azx_writel(chip, reg, value) \
- ((chip)->io_ops->reg_writel(value, (chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_writel(azx_bus(chip), reg, value)
#define azx_readl(chip, reg) \
- ((chip)->io_ops->reg_readl((chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_readl(azx_bus(chip), reg)
#define azx_writew(chip, reg, value) \
- ((chip)->io_ops->reg_writew(value, (chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_writew(azx_bus(chip), reg, value)
#define azx_readw(chip, reg) \
- ((chip)->io_ops->reg_readw((chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_readw(azx_bus(chip), reg)
#define azx_writeb(chip, reg, value) \
- ((chip)->io_ops->reg_writeb(value, (chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_writeb(azx_bus(chip), reg, value)
#define azx_readb(chip, reg) \
- ((chip)->io_ops->reg_readb((chip)->remap_addr + AZX_REG_##reg))
+ snd_hdac_chip_readb(azx_bus(chip), reg)
#define azx_sd_writel(chip, dev, reg, value) \
snd_hdac_stream_writel(&(dev)->core, reg, value)
@@ -244,19 +214,24 @@ unsigned int azx_get_pos_posbuf(struct azx *chip, struct azx_dev *azx_dev);
void azx_stop_all_streams(struct azx *chip);
/* Allocation functions. */
-int azx_alloc_stream_pages(struct azx *chip);
-void azx_free_stream_pages(struct azx *chip);
+#define azx_alloc_stream_pages(chip) \
+ snd_hdac_bus_alloc_stream_pages(azx_bus(chip))
+#define azx_free_stream_pages(chip) \
+ snd_hdac_bus_free_stream_pages(azx_bus(chip))
/* Low level azx interface */
void azx_init_chip(struct azx *chip, bool full_reset);
void azx_stop_chip(struct azx *chip);
-void azx_enter_link_reset(struct azx *chip);
+#define azx_enter_link_reset(chip) \
+ snd_hdac_bus_enter_link_reset(azx_bus(chip))
irqreturn_t azx_interrupt(int irq, void *dev_id);
/* Codec interface */
-int azx_bus_create(struct azx *chip, const char *model);
+int azx_bus_init(struct azx *chip, const char *model,
+ const struct hdac_io_ops *io_ops);
int azx_probe_codecs(struct azx *chip, unsigned int max_slots);
int azx_codec_configure(struct azx *chip);
-int azx_init_stream(struct azx *chip);
+int azx_init_streams(struct azx *chip);
+void azx_free_streams(struct azx *chip);
#endif /* __SOUND_HDA_CONTROLLER_H */