]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: hda: provide default bus io ops extended hdac
authorVinod Koul <vinod.koul@intel.com>
Wed, 17 Jun 2015 05:50:18 +0000 (11:20 +0530)
committerTakashi Iwai <tiwai@suse.de>
Wed, 17 Jun 2015 10:33:43 +0000 (12:33 +0200)
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>
sound/hda/ext/hdac_ext_bus.c

index f1100354c59144baaf82465a277fd0316a87fe93..0aa5d9eb6c3fd37d20185f41694e510bec1eff27 100644 (file)
 MODULE_DESCRIPTION("HDA extended core");
 MODULE_LICENSE("GPL v2");
 
+static void hdac_ext_writel(u32 value, u32 __iomem *addr)
+{
+       writel(value, addr);
+}
+
+static u32 hdac_ext_readl(u32 __iomem *addr)
+{
+       return readl(addr);
+}
+
+static void hdac_ext_writew(u16 value, u16 __iomem *addr)
+{
+       writew(value, addr);
+}
+
+static u16 hdac_ext_readw(u16 __iomem *addr)
+{
+       return readw(addr);
+}
+
+static void hdac_ext_writeb(u8 value, u8 __iomem *addr)
+{
+       writeb(value, addr);
+}
+
+static u8 hdac_ext_readb(u8 __iomem *addr)
+{
+       return readb(addr);
+}
+
+static int hdac_ext_dma_alloc_pages(struct hdac_bus *bus, int type,
+                          size_t size, struct snd_dma_buffer *buf)
+{
+       return snd_dma_alloc_pages(type, bus->dev, size, buf);
+}
+
+static void hdac_ext_dma_free_pages(struct hdac_bus *bus, struct snd_dma_buffer *buf)
+{
+       snd_dma_free_pages(buf);
+}
+
+static const struct hdac_io_ops hdac_ext_default_io = {
+       .reg_writel = hdac_ext_writel,
+       .reg_readl = hdac_ext_readl,
+       .reg_writew = hdac_ext_writew,
+       .reg_readw = hdac_ext_readw,
+       .reg_writeb = hdac_ext_writeb,
+       .reg_readb = hdac_ext_readb,
+       .dma_alloc_pages = hdac_ext_dma_alloc_pages,
+       .dma_free_pages = hdac_ext_dma_free_pages,
+};
+
 /**
  * snd_hdac_ext_bus_init - initialize a HD-audio extended bus
  * @ebus: the pointer to extended bus object
  * @dev: device pointer
  * @ops: bus verb operators
- * @io_ops: lowlevel I/O operators
+ * @io_ops: lowlevel I/O operators, can be NULL. If NULL core will use
+ * default ops
  *
  * Returns 0 if successful, or a negative error code.
  */
@@ -40,6 +93,10 @@ int snd_hdac_ext_bus_init(struct hdac_ext_bus *ebus, struct device *dev,
        int ret;
        static int idx;
 
+       /* check if io ops are provided, if not load the defaults */
+       if (io_ops == NULL)
+               io_ops = &hdac_ext_default_io;
+
        ret = snd_hdac_bus_init(&ebus->bus, dev, ops, io_ops);
        if (ret < 0)
                return ret;