Commit 817790cc authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: aw2: 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-27-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8c847a42
Loading
Loading
Loading
Loading
+12 −33
Original line number Diff line number Diff line
@@ -109,9 +109,6 @@ static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_playback_close(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_hw_params(struct snd_pcm_substream *substream,
				 struct snd_pcm_hw_params *hw_params);
static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_prepare_capture(struct snd_pcm_substream *substream);
static int snd_aw2_pcm_trigger_playback(struct snd_pcm_substream *substream,
@@ -170,8 +167,6 @@ static const struct snd_pcm_ops snd_aw2_playback_ops = {
	.open = snd_aw2_pcm_playback_open,
	.close = snd_aw2_pcm_playback_close,
	.ioctl = snd_pcm_lib_ioctl,
	.hw_params = snd_aw2_pcm_hw_params,
	.hw_free = snd_aw2_pcm_hw_free,
	.prepare = snd_aw2_pcm_prepare_playback,
	.trigger = snd_aw2_pcm_trigger_playback,
	.pointer = snd_aw2_pcm_pointer_playback,
@@ -182,8 +177,6 @@ static const struct snd_pcm_ops snd_aw2_capture_ops = {
	.open = snd_aw2_pcm_capture_open,
	.close = snd_aw2_pcm_capture_close,
	.ioctl = snd_pcm_lib_ioctl,
	.hw_params = snd_aw2_pcm_hw_params,
	.hw_free = snd_aw2_pcm_hw_free,
	.prepare = snd_aw2_pcm_prepare_capture,
	.trigger = snd_aw2_pcm_trigger_capture,
	.pointer = snd_aw2_pcm_pointer_capture,
@@ -411,20 +404,6 @@ static int snd_aw2_pcm_capture_close(struct snd_pcm_substream *substream)
	return 0;
}

 /* hw_params callback */
static int snd_aw2_pcm_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));
}

/* hw_free callback */
static int snd_aw2_pcm_hw_free(struct snd_pcm_substream *substream)
{
	return snd_pcm_lib_free_pages(substream);
}

/* prepare callback for playback */
static int snd_aw2_pcm_prepare_playback(struct snd_pcm_substream *substream)
{
@@ -611,7 +590,7 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
	snd_pcm_set_managed_buffer_all(pcm_playback_ana,
				       SNDRV_DMA_TYPE_DEV,
				       &chip->pci->dev,
				       64 * 1024, 64 * 1024);
@@ -643,7 +622,7 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
	snd_pcm_set_managed_buffer_all(pcm_playback_num,
				       SNDRV_DMA_TYPE_DEV,
				       &chip->pci->dev,
				       64 * 1024, 64 * 1024);
@@ -676,7 +655,7 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
	snd_pcm_set_managed_buffer_all(pcm_capture,
				       SNDRV_DMA_TYPE_DEV,
				       &chip->pci->dev,
				       64 * 1024, 64 * 1024);