Commit 07ed72ba authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: sb: Use managed buffer allocation

Clean up the driver with the new managed buffer allocation API.
The hw_params and hw_free callbacks became superfluous and got
dropped.

Link: https://lore.kernel.org/r/20191209094943.14984-15-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9ce57056
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -232,18 +232,6 @@ static void snd_sb16_setup_rate(struct snd_sb *chip,
	spin_unlock_irqrestore(&chip->reg_lock, flags);
}

static int snd_sb16_hw_params(struct snd_pcm_substream *substream,
			      struct snd_pcm_hw_params *hw_params)
{
	return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
}

static int snd_sb16_hw_free(struct snd_pcm_substream *substream)
{
	snd_pcm_lib_free_pages(substream);
	return 0;
}

static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream)
{
	unsigned long flags;
@@ -830,8 +818,6 @@ static const struct snd_pcm_ops snd_sb16_playback_ops = {
	.open =		snd_sb16_playback_open,
	.close =	snd_sb16_playback_close,
	.ioctl =	snd_pcm_lib_ioctl,
	.hw_params =	snd_sb16_hw_params,
	.hw_free =	snd_sb16_hw_free,
	.prepare =	snd_sb16_playback_prepare,
	.trigger =	snd_sb16_playback_trigger,
	.pointer =	snd_sb16_playback_pointer,
@@ -841,8 +827,6 @@ static const struct snd_pcm_ops snd_sb16_capture_ops = {
	.open =		snd_sb16_capture_open,
	.close =	snd_sb16_capture_close,
	.ioctl =	snd_pcm_lib_ioctl,
	.hw_params =	snd_sb16_hw_params,
	.hw_free =	snd_sb16_hw_free,
	.prepare =	snd_sb16_capture_prepare,
	.trigger =	snd_sb16_capture_trigger,
	.pointer =	snd_sb16_capture_pointer,
@@ -873,9 +857,8 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
		pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
	}

	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					      card->dev,
					      64*1024, 128*1024);
	snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
				       card->dev, 64*1024, 128*1024);
	return 0;
}

+2 −19
Original line number Diff line number Diff line
@@ -225,18 +225,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream,
	return 0;
}

static int snd_sb8_hw_params(struct snd_pcm_substream *substream,
			     struct snd_pcm_hw_params *hw_params)
{
	return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
}

static int snd_sb8_hw_free(struct snd_pcm_substream *substream)
{
	snd_pcm_lib_free_pages(substream);
	return 0;
}

static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream)
{
	unsigned long flags;
@@ -559,8 +547,6 @@ static const struct snd_pcm_ops snd_sb8_playback_ops = {
	.open =			snd_sb8_open,
	.close =		snd_sb8_close,
	.ioctl =		snd_pcm_lib_ioctl,
	.hw_params =		snd_sb8_hw_params,
	.hw_free =		snd_sb8_hw_free,
	.prepare =		snd_sb8_playback_prepare,
	.trigger =		snd_sb8_playback_trigger,
	.pointer =		snd_sb8_playback_pointer,
@@ -570,8 +556,6 @@ static const struct snd_pcm_ops snd_sb8_capture_ops = {
	.open =			snd_sb8_open,
	.close =		snd_sb8_close,
	.ioctl =		snd_pcm_lib_ioctl,
	.hw_params =		snd_sb8_hw_params,
	.hw_free =		snd_sb8_hw_free,
	.prepare =		snd_sb8_capture_prepare,
	.trigger =		snd_sb8_capture_trigger,
	.pointer =		snd_sb8_capture_pointer,
@@ -595,9 +579,8 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device)

	if (chip->dma8 > 3 || chip->dma16 >= 0)
		max_prealloc = 128 * 1024;
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					      card->dev,
					      64*1024, max_prealloc);
	snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
				       card->dev, 64*1024, max_prealloc);

	return 0;
}