diff options
author | Vinod Koul <vinod.koul@intel.com> | 2015-06-17 01:50:18 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-06-17 06:33:43 -0400 |
commit | 99463b3a399419b3bd795abce5e10c5de87c98d3 (patch) | |
tree | 7a5da4ee0908ee0f8caa91521e4bb832a3d20124 /sound/hda | |
parent | bab4445f9a083f087d0ebb4ba3e9dde669a6b9a5 (diff) |
ALSA: hda: provide default bus io ops extended hdac
A typical io ops use simple io accessors which can be common for most
drivers, so provide a default ops which will be used if driver doesn't
provide one
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/ext/hdac_ext_bus.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index f1100354c591..0aa5d9eb6c3f 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c | |||
@@ -24,12 +24,65 @@ | |||
24 | MODULE_DESCRIPTION("HDA extended core"); | 24 | MODULE_DESCRIPTION("HDA extended core"); |
25 | MODULE_LICENSE("GPL v2"); | 25 | MODULE_LICENSE("GPL v2"); |
26 | 26 | ||
27 | static void hdac_ext_writel(u32 value, u32 __iomem *addr) | ||
28 | { | ||
29 | writel(value, addr); | ||
30 | } | ||
31 | |||
32 | static u32 hdac_ext_readl(u32 __iomem *addr) | ||
33 | { | ||
34 | return readl(addr); | ||
35 | } | ||
36 | |||
37 | static void hdac_ext_writew(u16 value, u16 __iomem *addr) | ||
38 | { | ||
39 | writew(value, addr); | ||
40 | } | ||
41 | |||
42 | static u16 hdac_ext_readw(u16 __iomem *addr) | ||
43 | { | ||
44 | return readw(addr); | ||
45 | } | ||
46 | |||
47 | static void hdac_ext_writeb(u8 value, u8 __iomem *addr) | ||
48 | { | ||
49 | writeb(value, addr); | ||
50 | } | ||
51 | |||
52 | static u8 hdac_ext_readb(u8 __iomem *addr) | ||
53 | { | ||
54 | return readb(addr); | ||
55 | } | ||
56 | |||
57 | static int hdac_ext_dma_alloc_pages(struct hdac_bus *bus, int type, | ||
58 | size_t size, struct snd_dma_buffer *buf) | ||
59 | { | ||
60 | return snd_dma_alloc_pages(type, bus->dev, size, buf); | ||
61 | } | ||
62 | |||
63 | static void hdac_ext_dma_free_pages(struct hdac_bus *bus, struct snd_dma_buffer *buf) | ||
64 | { | ||
65 | snd_dma_free_pages(buf); | ||
66 | } | ||
67 | |||
68 | static const struct hdac_io_ops hdac_ext_default_io = { | ||
69 | .reg_writel = hdac_ext_writel, | ||
70 | .reg_readl = hdac_ext_readl, | ||
71 | .reg_writew = hdac_ext_writew, | ||
72 | .reg_readw = hdac_ext_readw, | ||
73 | .reg_writeb = hdac_ext_writeb, | ||
74 | .reg_readb = hdac_ext_readb, | ||
75 | .dma_alloc_pages = hdac_ext_dma_alloc_pages, | ||
76 | .dma_free_pages = hdac_ext_dma_free_pages, | ||
77 | }; | ||
78 | |||
27 | /** | 79 | /** |
28 | * snd_hdac_ext_bus_init - initialize a HD-audio extended bus | 80 | * snd_hdac_ext_bus_init - initialize a HD-audio extended bus |
29 | * @ebus: the pointer to extended bus object | 81 | * @ebus: the pointer to extended bus object |
30 | * @dev: device pointer | 82 | * @dev: device pointer |
31 | * @ops: bus verb operators | 83 | * @ops: bus verb operators |
32 | * @io_ops: lowlevel I/O operators | 84 | * @io_ops: lowlevel I/O operators, can be NULL. If NULL core will use |
85 | * default ops | ||
33 | * | 86 | * |
34 | * Returns 0 if successful, or a negative error code. | 87 | * Returns 0 if successful, or a negative error code. |
35 | */ | 88 | */ |
@@ -40,6 +93,10 @@ int snd_hdac_ext_bus_init(struct hdac_ext_bus *ebus, struct device *dev, | |||
40 | int ret; | 93 | int ret; |
41 | static int idx; | 94 | static int idx; |
42 | 95 | ||
96 | /* check if io ops are provided, if not load the defaults */ | ||
97 | if (io_ops == NULL) | ||
98 | io_ops = &hdac_ext_default_io; | ||
99 | |||
43 | ret = snd_hdac_bus_init(&ebus->bus, dev, ops, io_ops); | 100 | ret = snd_hdac_bus_init(&ebus->bus, dev, ops, io_ops); |
44 | if (ret < 0) | 101 | if (ret < 0) |
45 | return ret; | 102 | return ret; |