Commit 8e2c7524 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: via82xx: Use managed buffer allocation

Clean up the drivers with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.

Link: https://lore.kernel.org/r/20191209094943.14984-56-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c79eafa0
...@@ -919,18 +919,10 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, ...@@ -919,18 +919,10 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream,
{ {
struct via82xx *chip = snd_pcm_substream_chip(substream); struct via82xx *chip = snd_pcm_substream_chip(substream);
struct viadev *viadev = substream->runtime->private_data; struct viadev *viadev = substream->runtime->private_data;
int err;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); return build_via_table(viadev, substream, chip->pci,
if (err < 0)
return err;
err = build_via_table(viadev, substream, chip->pci,
params_periods(hw_params), params_periods(hw_params),
params_period_bytes(hw_params)); params_period_bytes(hw_params));
if (err < 0)
return err;
return 0;
} }
/* /*
...@@ -943,7 +935,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) ...@@ -943,7 +935,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream)
struct viadev *viadev = substream->runtime->private_data; struct viadev *viadev = substream->runtime->private_data;
clean_via_table(viadev, substream, chip->pci); clean_via_table(viadev, substream, chip->pci);
snd_pcm_lib_free_pages(substream);
return 0; return 0;
} }
...@@ -1453,7 +1444,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip) ...@@ -1453,7 +1444,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip)
/* capture */ /* capture */
init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev,
64*1024, VIA_MAX_BUFSIZE); 64*1024, VIA_MAX_BUFSIZE);
...@@ -1477,7 +1468,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip) ...@@ -1477,7 +1468,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip)
/* set up capture */ /* set up capture */
init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev,
64*1024, VIA_MAX_BUFSIZE); 64*1024, VIA_MAX_BUFSIZE);
...@@ -1520,7 +1511,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) ...@@ -1520,7 +1511,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip)
/* capture */ /* capture */
init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev,
64*1024, VIA_MAX_BUFSIZE); 64*1024, VIA_MAX_BUFSIZE);
...@@ -1546,7 +1537,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) ...@@ -1546,7 +1537,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip)
/* set up playback */ /* set up playback */
init_viadev(chip, chip->playback_devno, 0x30, 3, 0); init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev,
64*1024, VIA_MAX_BUFSIZE); 64*1024, VIA_MAX_BUFSIZE);
return 0; return 0;
...@@ -1576,7 +1567,7 @@ static int snd_via686_pcm_new(struct via82xx *chip) ...@@ -1576,7 +1567,7 @@ static int snd_via686_pcm_new(struct via82xx *chip)
init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0);
init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev,
64*1024, VIA_MAX_BUFSIZE); 64*1024, VIA_MAX_BUFSIZE);
return 0; return 0;
......
...@@ -642,9 +642,6 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, ...@@ -642,9 +642,6 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream,
struct viadev *viadev = substream->runtime->private_data; struct viadev *viadev = substream->runtime->private_data;
int err; int err;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
err = build_via_table(viadev, substream, chip->pci, err = build_via_table(viadev, substream, chip->pci,
params_periods(hw_params), params_periods(hw_params),
params_period_bytes(hw_params)); params_period_bytes(hw_params));
...@@ -667,7 +664,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) ...@@ -667,7 +664,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream)
struct viadev *viadev = substream->runtime->private_data; struct viadev *viadev = substream->runtime->private_data;
clean_via_table(viadev, substream, chip->pci); clean_via_table(viadev, substream, chip->pci);
snd_pcm_lib_free_pages(substream);
return 0; return 0;
} }
...@@ -849,9 +845,8 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip) ...@@ -849,9 +845,8 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip)
init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
&chip->pci->dev, &chip->pci->dev, 64*1024, 128*1024);
64*1024, 128*1024);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment