diff options
author | Dylan Reid <dgreid@chromium.org> | 2014-02-28 23:41:23 (GMT) |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-03-01 10:22:30 (GMT) |
commit | 679089944317963e9abf51899b48db3b6f424489 (patch) | |
tree | 5429c4b0401f778ad67ea54879a52bc3387be12f /sound/pci/hda/hda_controller.c | |
parent | 05e848788e30b2ee0b2736b99b6e458b6c7a4e7d (diff) | |
download | linux-679089944317963e9abf51899b48db3b6f424489.tar.xz |
ALSA: hda - Pull pages allocation to hda_controller
Pull allocation from first_init to a new function in hda_controller.c.
Short term this will allow the dsp loader to be moved as well. In
later commits it will allow the same allocation to be used by the
platform hda driver.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_controller.c')
-rw-r--r-- | sound/pci/hda/hda_controller.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index fcc5c30..bf5e890 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -1014,5 +1014,48 @@ int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, } EXPORT_SYMBOL_GPL(azx_attach_pcm_stream); +int azx_alloc_stream_pages(struct azx *chip) +{ + int i, err; + struct snd_card *card = chip->card; + + 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, + BDL_SIZE, + &chip->azx_dev[i].bdl); + if (err < 0) { + dev_err(card->dev, "cannot allocate BDL\n"); + return -ENOMEM; + } + } + /* allocate memory for the position buffer */ + err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV, + chip->num_streams * 8, &chip->posbuf); + if (err < 0) { + dev_err(card->dev, "cannot allocate posbuf\n"); + return -ENOMEM; + } + return 0; +} +EXPORT_SYMBOL_GPL(azx_alloc_stream_pages); + +void azx_free_stream_pages(struct azx *chip) +{ + int i; + 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); + } + if (chip->rb.area) + chip->ops->dma_free_pages(chip, &chip->rb); + if (chip->posbuf.area) + chip->ops->dma_free_pages(chip, &chip->posbuf); +} +EXPORT_SYMBOL_GPL(azx_free_stream_pages); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Common HDA driver funcitons"); |