Commit 7a6d4a5a authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda: Use managed buffer allocation

Clean up the common driver module 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-41-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 247ed102
...@@ -107,7 +107,7 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -107,7 +107,7 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
struct azx *chip = apcm->chip; struct azx *chip = apcm->chip;
struct azx_dev *azx_dev = get_azx_dev(substream); struct azx_dev *azx_dev = get_azx_dev(substream);
int ret; int ret = 0;
trace_azx_pcm_hw_params(chip, azx_dev); trace_azx_pcm_hw_params(chip, azx_dev);
dsp_lock(azx_dev); dsp_lock(azx_dev);
...@@ -119,8 +119,6 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -119,8 +119,6 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
azx_dev->core.bufsize = 0; azx_dev->core.bufsize = 0;
azx_dev->core.period_bytes = 0; azx_dev->core.period_bytes = 0;
azx_dev->core.format_val = 0; azx_dev->core.format_val = 0;
ret = snd_pcm_lib_malloc_pages(substream,
params_buffer_bytes(hw_params));
unlock: unlock:
dsp_unlock(azx_dev); dsp_unlock(azx_dev);
...@@ -132,7 +130,6 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -132,7 +130,6 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
struct azx_dev *azx_dev = get_azx_dev(substream); struct azx_dev *azx_dev = get_azx_dev(substream);
struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream); struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream);
int err;
/* reset BDL address */ /* reset BDL address */
dsp_lock(azx_dev); dsp_lock(azx_dev);
...@@ -141,10 +138,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -141,10 +138,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
snd_hda_codec_cleanup(apcm->codec, hinfo, substream); snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
err = snd_pcm_lib_free_pages(substream);
azx_stream(azx_dev)->prepared = 0; azx_stream(azx_dev)->prepared = 0;
dsp_unlock(azx_dev); dsp_unlock(azx_dev);
return err; return 0;
} }
static int azx_pcm_prepare(struct snd_pcm_substream *substream) static int azx_pcm_prepare(struct snd_pcm_substream *substream)
...@@ -766,9 +762,8 @@ int snd_hda_attach_pcm_stream(struct hda_bus *_bus, struct hda_codec *codec, ...@@ -766,9 +762,8 @@ int snd_hda_attach_pcm_stream(struct hda_bus *_bus, struct hda_codec *codec,
size = MAX_PREALLOC_SIZE; size = MAX_PREALLOC_SIZE;
if (chip->uc_buffer) if (chip->uc_buffer)
type = SNDRV_DMA_TYPE_DEV_UC_SG; type = SNDRV_DMA_TYPE_DEV_UC_SG;
snd_pcm_lib_preallocate_pages_for_all(pcm, type, snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev,
chip->card->dev, size, MAX_PREALLOC_SIZE);
size, MAX_PREALLOC_SIZE);
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