aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2014-02-28 18:41:23 -0500
committerTakashi Iwai <tiwai@suse.de>2014-03-01 05:22:30 -0500
commit679089944317963e9abf51899b48db3b6f424489 (patch)
tree5429c4b0401f778ad67ea54879a52bc3387be12f
parent05e848788e30b2ee0b2736b99b6e458b6c7a4e7d (diff)
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>
-rw-r--r--sound/pci/hda/hda_controller.c43
-rw-r--r--sound/pci/hda/hda_controller.h4
-rw-r--r--sound/pci/hda/hda_intel.c34
3 files changed, 52 insertions, 29 deletions
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index fcc5c3063967..bf5e89027fc1 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,
1014} 1014}
1015EXPORT_SYMBOL_GPL(azx_attach_pcm_stream); 1015EXPORT_SYMBOL_GPL(azx_attach_pcm_stream);
1016 1016
1017int azx_alloc_stream_pages(struct azx *chip)
1018{
1019 int i, err;
1020 struct snd_card *card = chip->card;
1021
1022 for (i = 0; i < chip->num_streams; i++) {
1023 dsp_lock_init(&chip->azx_dev[i]);
1024 /* allocate memory for the BDL for each stream */
1025 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
1026 BDL_SIZE,
1027 &chip->azx_dev[i].bdl);
1028 if (err < 0) {
1029 dev_err(card->dev, "cannot allocate BDL\n");
1030 return -ENOMEM;
1031 }
1032 }
1033 /* allocate memory for the position buffer */
1034 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
1035 chip->num_streams * 8, &chip->posbuf);
1036 if (err < 0) {
1037 dev_err(card->dev, "cannot allocate posbuf\n");
1038 return -ENOMEM;
1039 }
1040 return 0;
1041}
1042EXPORT_SYMBOL_GPL(azx_alloc_stream_pages);
1043
1044void azx_free_stream_pages(struct azx *chip)
1045{
1046 int i;
1047 if (chip->azx_dev) {
1048 for (i = 0; i < chip->num_streams; i++)
1049 if (chip->azx_dev[i].bdl.area)
1050 chip->ops->dma_free_pages(
1051 chip, &chip->azx_dev[i].bdl);
1052 }
1053 if (chip->rb.area)
1054 chip->ops->dma_free_pages(chip, &chip->rb);
1055 if (chip->posbuf.area)
1056 chip->ops->dma_free_pages(chip, &chip->posbuf);
1057}
1058EXPORT_SYMBOL_GPL(azx_free_stream_pages);
1059
1017MODULE_LICENSE("GPL"); 1060MODULE_LICENSE("GPL");
1018MODULE_DESCRIPTION("Common HDA driver funcitons"); 1061MODULE_DESCRIPTION("Common HDA driver funcitons");
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
index a62cdde93a2b..9ea6b44e033d 100644
--- a/sound/pci/hda/hda_controller.h
+++ b/sound/pci/hda/hda_controller.h
@@ -54,4 +54,8 @@ int setup_bdle(struct azx *chip,
54#define dsp_is_locked(dev) 0 54#define dsp_is_locked(dev) 0
55#endif 55#endif
56 56
57/* Allocation functions. */
58int azx_alloc_stream_pages(struct azx *chip);
59void azx_free_stream_pages(struct azx *chip);
60
57#endif /* __SOUND_HDA_CONTROLLER_H */ 61#endif /* __SOUND_HDA_CONTROLLER_H */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f86ee2bb4529..4a0b228d70f7 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1864,16 +1864,7 @@ static int azx_free(struct azx *chip)
1864 if (chip->remap_addr) 1864 if (chip->remap_addr)
1865 iounmap(chip->remap_addr); 1865 iounmap(chip->remap_addr);
1866 1866
1867 if (chip->azx_dev) { 1867 azx_free_stream_pages(chip);
1868 for (i = 0; i < chip->num_streams; i++)
1869 if (chip->azx_dev[i].bdl.area)
1870 chip->ops->dma_free_pages(
1871 chip, &chip->azx_dev[i].bdl);
1872 }
1873 if (chip->rb.area)
1874 chip->ops->dma_free_pages(chip, &chip->rb);
1875 if (chip->posbuf.area)
1876 chip->ops->dma_free_pages(chip, &chip->posbuf);
1877 if (chip->region_requested) 1868 if (chip->region_requested)
1878 pci_release_regions(chip->pci); 1869 pci_release_regions(chip->pci);
1879 pci_disable_device(chip->pci); 1870 pci_disable_device(chip->pci);
@@ -2210,7 +2201,7 @@ static int azx_first_init(struct azx *chip)
2210 int dev = chip->dev_index; 2201 int dev = chip->dev_index;
2211 struct pci_dev *pci = chip->pci; 2202 struct pci_dev *pci = chip->pci;
2212 struct snd_card *card = chip->card; 2203 struct snd_card *card = chip->card;
2213 int i, err; 2204 int err;
2214 unsigned short gcap; 2205 unsigned short gcap;
2215 2206
2216#if BITS_PER_LONG != 64 2207#if BITS_PER_LONG != 64
@@ -2322,24 +2313,9 @@ static int azx_first_init(struct azx *chip)
2322 return -ENOMEM; 2313 return -ENOMEM;
2323 } 2314 }
2324 2315
2325 for (i = 0; i < chip->num_streams; i++) { 2316 err = azx_alloc_stream_pages(chip);
2326 dsp_lock_init(&chip->azx_dev[i]); 2317 if (err < 0)
2327 /* allocate memory for the BDL for each stream */ 2318 return err;
2328 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
2329 BDL_SIZE,
2330 &chip->azx_dev[i].bdl);
2331 if (err < 0) {
2332 dev_err(card->dev, "cannot allocate BDL\n");
2333 return -ENOMEM;
2334 }
2335 }
2336 /* allocate memory for the position buffer */
2337 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
2338 chip->num_streams * 8, &chip->posbuf);
2339 if (err < 0) {
2340 dev_err(card->dev, "cannot allocate posbuf\n");
2341 return -ENOMEM;
2342 }
2343 /* allocate CORB/RIRB */ 2319 /* allocate CORB/RIRB */
2344 err = azx_alloc_cmd_io(chip); 2320 err = azx_alloc_cmd_io(chip);
2345 if (err < 0) 2321 if (err < 0)