ALSA: aaci: Use managed buffer allocation
Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped, and the if block is flattened accordingly. Link: https://lore.kernel.org/r/20191209094943.14984-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
9b2433a9c5
commit
8ee0c75869
|
@ -483,11 +483,6 @@ static int aaci_pcm_hw_free(struct snd_pcm_substream *substream)
|
||||||
snd_ac97_pcm_close(aacirun->pcm);
|
snd_ac97_pcm_close(aacirun->pcm);
|
||||||
aacirun->pcm_open = 0;
|
aacirun->pcm_open = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear out the DMA and any allocated buffers.
|
|
||||||
*/
|
|
||||||
snd_pcm_lib_free_pages(substream);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,6 +497,7 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
struct snd_pcm_hw_params *params)
|
struct snd_pcm_hw_params *params)
|
||||||
{
|
{
|
||||||
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
struct aaci_runtime *aacirun = substream->runtime->private_data;
|
||||||
|
struct aaci *aaci = substream->private_data;
|
||||||
unsigned int channels = params_channels(params);
|
unsigned int channels = params_channels(params);
|
||||||
unsigned int rate = params_rate(params);
|
unsigned int rate = params_rate(params);
|
||||||
int dbl = rate > 48000;
|
int dbl = rate > 48000;
|
||||||
|
@ -517,25 +513,19 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
if (dbl && channels != 2)
|
if (dbl && channels != 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
err = snd_pcm_lib_malloc_pages(substream,
|
err = snd_ac97_pcm_open(aacirun->pcm, rate, channels,
|
||||||
params_buffer_bytes(params));
|
aacirun->pcm->r[dbl].slots);
|
||||||
if (err >= 0) {
|
|
||||||
struct aaci *aaci = substream->private_data;
|
|
||||||
|
|
||||||
err = snd_ac97_pcm_open(aacirun->pcm, rate, channels,
|
aacirun->pcm_open = err == 0;
|
||||||
aacirun->pcm->r[dbl].slots);
|
aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
|
||||||
|
aacirun->cr |= channels_to_slotmask[channels + dbl * 2];
|
||||||
|
|
||||||
aacirun->pcm_open = err == 0;
|
/*
|
||||||
aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
|
* fifo_bytes is the number of bytes we transfer to/from
|
||||||
aacirun->cr |= channels_to_slotmask[channels + dbl * 2];
|
* the FIFO, including padding. So that's x4. As we're
|
||||||
|
* in compact mode, the FIFO is half the size.
|
||||||
/*
|
*/
|
||||||
* fifo_bytes is the number of bytes we transfer to/from
|
aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2;
|
||||||
* the FIFO, including padding. So that's x4. As we're
|
|
||||||
* in compact mode, the FIFO is half the size.
|
|
||||||
*/
|
|
||||||
aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -937,9 +927,9 @@ static int aaci_init_pcm(struct aaci *aaci)
|
||||||
|
|
||||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
|
||||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
|
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
|
||||||
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
|
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
|
||||||
aaci->card->dev,
|
aaci->card->dev,
|
||||||
0, 64 * 1024);
|
0, 64 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue