ALSA: hda - Pass bus io_ops directly from the top-level driver
[firefly-linux-kernel-4.4.55.git] / sound / pci / hda / hda_controller.c
index b4474e27631d6ef932421c1263fda1db0aff6be9..aadce642aabc01f2c7e0c8c57dca3338f2a7fad4 100644 (file)
@@ -985,8 +985,8 @@ static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
 static int azx_alloc_cmd_io(struct azx *chip)
 {
        /* single page (at least 4096 bytes) must suffice for both ringbuffes */
-       return chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
-                                         PAGE_SIZE, &chip->rb);
+       return chip->io_ops->dma_alloc_pages(azx_bus(chip), SNDRV_DMA_TYPE_DEV,
+                                            PAGE_SIZE, &chip->rb);
 }
 
 static void azx_init_cmd_io(struct azx *chip)
@@ -1328,8 +1328,9 @@ static int azx_single_get_response(struct hda_bus *bus, unsigned int addr,
  */
 
 /* send a command */
-static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
+static int azx_send_cmd(struct hdac_bus *_bus, unsigned int val)
 {
+       struct hda_bus *bus = to_hda_bus(_bus);
        struct azx *chip = bus->private_data;
 
        if (chip->disabled)
@@ -1342,9 +1343,10 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
 }
 
 /* get a response */
-static int azx_get_response(struct hda_bus *bus, unsigned int addr,
+static int azx_get_response(struct hdac_bus *_bus, unsigned int addr,
                            unsigned int *res)
 {
+       struct hda_bus *bus = to_hda_bus(_bus);
        struct azx *chip = bus->private_data;
        if (chip->disabled)
                return 0;
@@ -1354,6 +1356,11 @@ static int azx_get_response(struct hda_bus *bus, unsigned int addr,
                return azx_rirb_get_response(bus, addr, res);
 }
 
+static const struct hdac_bus_ops bus_core_ops = {
+       .command = azx_send_cmd,
+       .get_response = azx_get_response,
+};
+
 #ifdef CONFIG_SND_HDA_DSP_LOADER
 /*
  * DSP loading code (e.g. for CA0132)
@@ -1389,8 +1396,8 @@ static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
        azx_dev->locked = 1;
        spin_unlock_irq(&chip->reg_lock);
 
-       err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV_SG,
-                                        byte_size, bufp);
+       err = chip->io_ops->dma_alloc_pages(&bus->core, SNDRV_DMA_TYPE_DEV_SG,
+                                           byte_size, bufp);
        if (err < 0)
                goto err_alloc;
 
@@ -1415,7 +1422,7 @@ static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
        return azx_dev->stream_tag;
 
  error:
-       chip->ops->dma_free_pages(chip, bufp);
+       chip->io_ops->dma_free_pages(&bus->core, bufp);
  err_alloc:
        spin_lock_irq(&chip->reg_lock);
        if (azx_dev->opened)
@@ -1457,7 +1464,7 @@ static void azx_load_dsp_cleanup(struct hda_bus *bus,
        azx_dev->period_bytes = 0;
        azx_dev->format_val = 0;
 
-       chip->ops->dma_free_pages(chip, dmab);
+       chip->io_ops->dma_free_pages(&bus->core, dmab);
        dmab->area = NULL;
 
        spin_lock_irq(&chip->reg_lock);
@@ -1476,14 +1483,14 @@ int azx_alloc_stream_pages(struct azx *chip)
        for (i = 0; i < chip->num_streams; i++) {
                dsp_lock_init(&chip->azx_dev[i]);
                /* allocate memory for the BDL for each stream */
-               err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
+               err = chip->io_ops->dma_alloc_pages(azx_bus(chip), SNDRV_DMA_TYPE_DEV,
                                                 BDL_SIZE,
                                                 &chip->azx_dev[i].bdl);
                if (err < 0)
                        return -ENOMEM;
        }
        /* allocate memory for the position buffer */
-       err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
+       err = chip->io_ops->dma_alloc_pages(azx_bus(chip), SNDRV_DMA_TYPE_DEV,
                                         chip->num_streams * 8, &chip->posbuf);
        if (err < 0)
                return -ENOMEM;
@@ -1502,13 +1509,13 @@ void azx_free_stream_pages(struct azx *chip)
        if (chip->azx_dev) {
                for (i = 0; i < chip->num_streams; i++)
                        if (chip->azx_dev[i].bdl.area)
-                               chip->ops->dma_free_pages(
-                                       chip, &chip->azx_dev[i].bdl);
+                               chip->io_ops->dma_free_pages(azx_bus(chip),
+                                                            &chip->azx_dev[i].bdl);
        }
        if (chip->rb.area)
-               chip->ops->dma_free_pages(chip, &chip->rb);
+               chip->io_ops->dma_free_pages(azx_bus(chip), &chip->rb);
        if (chip->posbuf.area)
-               chip->ops->dma_free_pages(chip, &chip->posbuf);
+               chip->io_ops->dma_free_pages(azx_bus(chip), &chip->posbuf);
 }
 EXPORT_SYMBOL_GPL(azx_free_stream_pages);
 
@@ -1762,15 +1769,16 @@ static int probe_codec(struct azx *chip, int addr)
 {
        unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
                (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
+       struct hdac_bus *bus = &chip->bus->core;
        int err;
        unsigned int res;
 
-       mutex_lock(&chip->bus->core.cmd_mutex);
+       mutex_lock(&bus->cmd_mutex);
        chip->probing = 1;
-       azx_send_cmd(chip->bus, cmd);
-       err = azx_get_response(chip->bus, addr, &res);
+       azx_send_cmd(bus, cmd);
+       err = azx_get_response(bus, addr, &res);
        chip->probing = 0;
-       mutex_unlock(&chip->bus->core.cmd_mutex);
+       mutex_unlock(&bus->cmd_mutex);
        if (err < 0 || res == -1)
                return -EIO;
        dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
@@ -1811,8 +1819,6 @@ static int get_jackpoll_interval(struct azx *chip)
 }
 
 static struct hda_bus_ops bus_ops = {
-       .command = azx_send_cmd,
-       .get_response = azx_get_response,
        .attach_pcm = azx_attach_pcm_stream,
        .bus_reset = azx_bus_reset,
 #ifdef CONFIG_SND_HDA_DSP_LOADER
@@ -1828,7 +1834,7 @@ int azx_bus_create(struct azx *chip, const char *model)
        struct hda_bus *bus;
        int err;
 
-       err = snd_hda_bus_new(chip->card, &bus);
+       err = snd_hda_bus_new(chip->card, &bus_core_ops, chip->io_ops, &bus);
        if (err < 0)
                return err;
 
@@ -1966,6 +1972,3 @@ int azx_init_stream(struct azx *chip)
        return 0;
 }
 EXPORT_SYMBOL_GPL(azx_init_stream);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Common HDA driver functions");