Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit ee88f4e

Browse files
committed
ALSA: mips: Use managed buffer allocation
Clean up the drivers 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-18-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 15fbacf commit ee88f4e

File tree

2 files changed

+4
-41
lines changed

2 files changed

+4
-41
lines changed

sound/mips/hal2.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -505,23 +505,6 @@ static const struct snd_pcm_hardware hal2_pcm_hw = {
505505
.periods_max = 1024,
506506
};
507507

508-
static int hal2_pcm_hw_params(struct snd_pcm_substream *substream,
509-
struct snd_pcm_hw_params *params)
510-
{
511-
int err;
512-
513-
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
514-
if (err < 0)
515-
return err;
516-
517-
return 0;
518-
}
519-
520-
static int hal2_pcm_hw_free(struct snd_pcm_substream *substream)
521-
{
522-
return snd_pcm_lib_free_pages(substream);
523-
}
524-
525508
static int hal2_playback_open(struct snd_pcm_substream *substream)
526509
{
527510
struct snd_pcm_runtime *runtime = substream->runtime;
@@ -702,8 +685,6 @@ static const struct snd_pcm_ops hal2_playback_ops = {
702685
.open = hal2_playback_open,
703686
.close = hal2_playback_close,
704687
.ioctl = snd_pcm_lib_ioctl,
705-
.hw_params = hal2_pcm_hw_params,
706-
.hw_free = hal2_pcm_hw_free,
707688
.prepare = hal2_playback_prepare,
708689
.trigger = hal2_playback_trigger,
709690
.pointer = hal2_playback_pointer,
@@ -714,8 +695,6 @@ static const struct snd_pcm_ops hal2_capture_ops = {
714695
.open = hal2_capture_open,
715696
.close = hal2_capture_close,
716697
.ioctl = snd_pcm_lib_ioctl,
717-
.hw_params = hal2_pcm_hw_params,
718-
.hw_free = hal2_pcm_hw_free,
719698
.prepare = hal2_capture_prepare,
720699
.trigger = hal2_capture_trigger,
721700
.pointer = hal2_capture_pointer,
@@ -740,8 +719,8 @@ static int hal2_pcm_create(struct snd_hal2 *hal2)
740719
&hal2_playback_ops);
741720
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
742721
&hal2_capture_ops);
743-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
744-
NULL, 0, 1024 * 1024);
722+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
723+
NULL, 0, 1024 * 1024);
745724

746725
return 0;
747726
}

sound/mips/sgio2audio.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -577,20 +577,6 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream)
577577
return 0;
578578
}
579579

580-
581-
/* hw_params callback */
582-
static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream,
583-
struct snd_pcm_hw_params *hw_params)
584-
{
585-
return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
586-
}
587-
588-
/* hw_free callback */
589-
static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream)
590-
{
591-
return snd_pcm_lib_free_pages(substream);
592-
}
593-
594580
/* prepare callback */
595581
static int snd_sgio2audio_pcm_prepare(struct snd_pcm_substream *substream)
596582
{
@@ -716,8 +702,7 @@ static int snd_sgio2audio_new_pcm(struct snd_sgio2audio *chip)
716702
&snd_sgio2audio_playback1_ops);
717703
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
718704
&snd_sgio2audio_capture_ops);
719-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
720-
NULL, 0, 0);
705+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
721706

722707
/* create second pcm device with one outputs and no input */
723708
err = snd_pcm_new(chip->card, "SGI O2 Audio", 1, 1, 0, &pcm);
@@ -730,8 +715,7 @@ static int snd_sgio2audio_new_pcm(struct snd_sgio2audio *chip)
730715
/* set operators */
731716
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
732717
&snd_sgio2audio_playback2_ops);
733-
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
734-
NULL, 0, 0);
718+
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
735719

736720
return 0;
737721
}

0 commit comments

Comments
 (0)