[alsa-devel] [PATCH 5.6 00/71] ALSA: Use managed buffer allocation
Hi,
we already got a PCM core extension in 5.5-rc1 for allocating / releasing the PCM buffers implicitly, so called managed buffer allocation mode. This patch set is to apply this new mode for the actual (non-ASoC) drivers. The patches for ASoC and the other subsystems will follow in later patch sets. Also, other PCM API changes will follow later, too.
This won't change anything from the functional POV, but merely cleanups.
Takashi
===
Takashi Iwai (71): ALSA: aoa: Use managed buffer allocation ALSA: aaci: Use managed buffer allocation ALSA: atmel: Use managed buffer allocation ALSA: aloop: Use managed buffer allocation ALSA: dummy: Use managed buffer allocation ALSA: ml403: Use managed buffer allocation ALSA: pcsp: Use managed buffer allocation ALSA: vx: Use managed buffer allocation ALSA: firewire: Use managed buffer allocation ALSA: ad1816a: Use managed buffer allocation ALSA: cmi8330: Use managed buffer allocation ALSA: es1688: Use managed buffer allocation ALSA: es18xx: Use managed buffer allocation ALSA: sb: Use managed buffer allocation ALSA: gus: Use managed buffer allocation ALSA: wss: Use managed buffer allocation ALSA: mips: Use managed buffer allocation ALSA: parisc: Use managed buffer allocation ALSA: ad1889: Use managed buffer allocation ALSA: ali5451: Use managed buffer allocation ALSA: als300: Use managed buffer allocation ALSA: als4000: Use managed buffer allocation ALSA: asihpi: Use managed buffer allocation ALSA: atiixp: Use managed buffer allocation ALSA: au88x0: Use managed buffer allocation ALSA: aw2: Use managed buffer allocation ALSA: azt3328: Use managed buffer allocation ALSA: bt87x: Use managed buffer allocation ALSA: ca0106: Use managed buffer allocation ALSA: cmipci: Use managed buffer allocation ALSA: cs4281: Use managed buffer allocation ALSA: cs5535: Use managed buffer allocation ALSA: ctxfi: Use managed buffer allocation ALSA: echoaudio: Use managed buffer allocation ALSA: emu10k1x: Use managed buffer allocation ALSA: emu10k1: Use managed buffer allocation ALSA: ens137x: Use managed buffer allocation ALSA: es1938: Use managed buffer allocation ALSA: fm801: Use managed buffer allocation ALSA: hda: Use managed buffer allocation ALSA: ice1712: Use managed buffer allocation ALSA: ice1724: Use managed buffer allocation ALSA: intel8x0: Use managed buffer allocation ALSA: lola: Use managed buffer allocation ALSA: lx6464es: Use managed buffer allocation ALSA: maestro3: Use managed buffer allocation ALSA: mixart: Use managed buffer allocation ALSA: oxygen: Use managed buffer allocation ALSA: pcxhr: Use managed buffer allocation ALSA: riptide: Use managed buffer allocation ALSA: rme32: Use managed buffer allocation ALSA: sis7019: Use managed buffer allocation ALSA: sonicvibes: Use managed buffer allocation ALSA: trident: Use managed buffer allocation ALSA: via82xx: Use managed buffer allocation ALSA: ymfpci: Use managed buffer allocation ALSA: pdaudiocf: Use managed buffer allocation ALSA: pmac: Use managed buffer allocation ALSA: ps3: Use managed buffer allocation ALSA: aica: Use managed buffer allocation ALSA: sh: Use managed buffer allocation ALSA: sparc: Use managed buffer allocation ALSA: spi: Use managed buffer allocation ALSA: 6fire: Use managed buffer allocation ALSA: caiaq: Use managed buffer allocation ALSA: hiface: Use managed buffer allocation ALSA: line6: Use managed buffer allocation ALSA: ua101: Use managed buffer allocation ALSA: usx2y: Use managed buffer allocation ALSA: usb-audio: Use managed buffer allocation ALSA: hdml-lpe-audio: Use managed buffer allocation
sound/aoa/soundbus/i2sbus/pcm.c | 11 +------ sound/arm/aaci.c | 40 +++++++++-------------- sound/atmel/ac97c.c | 20 ++---------- sound/drivers/aloop.c | 12 ++----- sound/drivers/dummy.c | 14 ++------ sound/drivers/ml403-ac97cr.c | 29 +++-------------- sound/drivers/pcsp/pcsp_lib.c | 17 ++++------ sound/drivers/vx/vx_pcm.c | 27 ++------------- sound/firewire/bebob/bebob_pcm.c | 11 ++----- sound/firewire/dice/dice-pcm.c | 13 +++----- sound/firewire/digi00x/digi00x-pcm.c | 11 ++----- sound/firewire/fireface/ff-pcm.c | 9 ++--- sound/firewire/fireworks/fireworks_pcm.c | 11 ++----- sound/firewire/isight.c | 10 ++---- sound/firewire/motu/motu-pcm.c | 11 ++----- sound/firewire/oxfw/oxfw-pcm.c | 17 +++------- sound/firewire/tascam/tascam-pcm.c | 11 ++----- sound/isa/ad1816a/ad1816a_lib.c | 20 ++---------- sound/isa/cmi8330.c | 5 ++- sound/isa/es1688/es1688_lib.c | 20 ++---------- sound/isa/es18xx.c | 24 +++----------- sound/isa/gus/gus_pcm.c | 28 +++++----------- sound/isa/sb/sb16_main.c | 21 ++---------- sound/isa/sb/sb8_main.c | 21 ++---------- sound/isa/wss/wss_lib.c | 23 ++----------- sound/mips/hal2.c | 25 ++------------ sound/mips/sgio2audio.c | 20 ++---------- sound/parisc/harmony.c | 18 +++------- sound/pci/ad1889.c | 24 ++------------ sound/pci/ali5451/ali5451.c | 30 ++--------------- sound/pci/als300.c | 23 ++----------- sound/pci/als4000.c | 23 ++----------- sound/pci/asihpi/asihpi.c | 10 ++---- sound/pci/atiixp.c | 14 +++----- sound/pci/atiixp_modem.c | 9 ++--- sound/pci/au88x0/au88x0_pcm.c | 15 ++------- sound/pci/aw2/aw2-alsa.c | 45 +++++++------------------ sound/pci/azt3328.c | 30 +++-------------- sound/pci/bt87x.c | 14 +++----- sound/pci/ca0106/ca0106_main.c | 56 ++++---------------------------- sound/pci/cmipci.c | 36 ++++++-------------- sound/pci/cs4281.c | 20 ++---------- sound/pci/cs5535audio/cs5535audio_pcm.c | 12 +++---- sound/pci/ctxfi/ctpcm.c | 15 +++------ sound/pci/echoaudio/echoaudio.c | 19 +++-------- sound/pci/emu10k1/emu10k1x.c | 15 ++++----- sound/pci/emu10k1/emupcm.c | 41 ++++------------------- sound/pci/emu10k1/p16v.c | 48 ++++----------------------- sound/pci/ens1370.c | 27 +++------------ sound/pci/es1938.c | 28 ++-------------- sound/pci/fm801.c | 20 ++---------- sound/pci/hda/hda_controller.c | 13 +++----- sound/pci/ice1712/ice1712.c | 42 +++++------------------- sound/pci/ice1712/ice1724.c | 25 +++++--------- sound/pci/intel8x0.c | 11 +++---- sound/pci/intel8x0m.c | 23 +++---------- sound/pci/lola/lola_pcm.c | 11 +++---- sound/pci/lx6464es/lx6464es.c | 14 ++------ sound/pci/maestro3.c | 9 ++--- sound/pci/mixart/mixart.c | 14 +++----- sound/pci/oxygen/oxygen_pcm.c | 52 +++++++++++++---------------- sound/pci/pcxhr/pcxhr.c | 31 ++++-------------- sound/pci/riptide/riptide.c | 10 +++--- sound/pci/rme32.c | 35 ++++---------------- sound/pci/sis7019.c | 25 ++------------ sound/pci/sonicvibes.c | 20 ++---------- sound/pci/trident/trident_main.c | 49 +++++++++++----------------- sound/pci/via82xx.c | 45 ++++++++++--------------- sound/pci/via82xx_modem.c | 9 ++--- sound/pci/ymfpci/ymfpci_main.c | 33 +++++-------------- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 25 ++------------ sound/ppc/pmac.c | 28 ++-------------- sound/ppc/snd_ps3.c | 28 +++------------- sound/sh/aica.c | 29 +++-------------- sound/sh/sh_dac_audio.c | 20 ++---------- sound/sparc/amd7930.c | 20 ++---------- sound/sparc/cs4231.c | 17 ++-------- sound/sparc/dbri.c | 13 ++------ sound/spi/at73c213.c | 11 ++----- sound/usb/6fire/pcm.c | 17 +--------- sound/usb/caiaq/audio.c | 13 ++------ sound/usb/hiface/pcm.c | 18 ++-------- sound/usb/line6/pcm.c | 13 ++------ sound/usb/misc/ua101.c | 23 +++---------- sound/usb/pcm.c | 15 +++------ sound/usb/usx2y/usbusx2yaudio.c | 26 +++++---------- sound/usb/usx2y/usx2yhwdeppcm.c | 18 +++++----- sound/x86/intel_hdmi_audio.c | 16 ++++----- 88 files changed, 402 insertions(+), 1492 deletions(-)
Clean up the driver with the new managed buffer allocation API. The hw_params callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/aoa/soundbus/i2sbus/pcm.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index a94e4023fadf..44397e72c868 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -294,12 +294,6 @@ void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev) } #endif
-static int i2sbus_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in) { struct i2sbus_dev *i2sdev = snd_pcm_substream_chip(substream); @@ -308,7 +302,6 @@ static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in) get_pcm_info(i2sdev, in, &pi, NULL); if (pi->dbdma_ring.stopping) i2sbus_wait_for_stop(i2sdev, pi); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -781,7 +774,6 @@ static const struct snd_pcm_ops i2sbus_playback_ops = { .open = i2sbus_playback_open, .close = i2sbus_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = i2sbus_hw_params, .hw_free = i2sbus_playback_hw_free, .prepare = i2sbus_playback_prepare, .trigger = i2sbus_playback_trigger, @@ -851,7 +843,6 @@ static const struct snd_pcm_ops i2sbus_record_ops = { .open = i2sbus_record_open, .close = i2sbus_record_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = i2sbus_hw_params, .hw_free = i2sbus_record_hw_free, .prepare = i2sbus_record_prepare, .trigger = i2sbus_record_trigger, @@ -1026,7 +1017,7 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, dev->pcm->private_free = i2sbus_private_free;
/* well, we really should support scatter/gather DMA */ - snd_pcm_lib_preallocate_pages_for_all( + snd_pcm_set_managed_buffer_all( dev->pcm, SNDRV_DMA_TYPE_DEV, &macio_get_pci_dev(i2sdev->macio)->dev, 64 * 1024, 64 * 1024);
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/arm/aaci.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index b5399b0090a7..1e9ea0fe4f49 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -483,11 +483,6 @@ static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) snd_ac97_pcm_close(aacirun->pcm); aacirun->pcm_open = 0;
- /* - * Clear out the DMA and any allocated buffers. - */ - snd_pcm_lib_free_pages(substream); - return 0; }
@@ -502,6 +497,7 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct aaci_runtime *aacirun = substream->runtime->private_data; + struct aaci *aaci = substream->private_data; unsigned int channels = params_channels(params); unsigned int rate = params_rate(params); int dbl = rate > 48000; @@ -517,25 +513,19 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, if (dbl && channels != 2) return -EINVAL;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(params)); - if (err >= 0) { - struct aaci *aaci = substream->private_data; + err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, + aacirun->pcm->r[dbl].slots);
- err = snd_ac97_pcm_open(aacirun->pcm, rate, channels, - aacirun->pcm->r[dbl].slots); + aacirun->pcm_open = err == 0; + 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; - aacirun->cr |= channels_to_slotmask[channels + dbl * 2]; - - /* - * fifo_bytes is the number of bytes we transfer to/from - * 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; - } + /* + * fifo_bytes is the number of bytes we transfer to/from + * 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; } @@ -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_CAPTURE, &aaci_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - aaci->card->dev, - 0, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + aaci->card->dev, + 0, 64 * 1024); }
return ret;
Clean up the driver with the new managed buffer allocation API. The hw_free_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/atmel/ac97c.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index eef7ec77db1a..44507e43ed28 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -159,12 +159,6 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval;
/* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -172,19 +166,13 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex);
- return retval; + return 0; }
static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); - int retval; - - retval = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (retval < 0) - return retval;
/* Set restrictions to params. */ mutex_lock(&opened_mutex); @@ -192,7 +180,7 @@ static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream, chip->cur_format = params_format(hw_params); mutex_unlock(&opened_mutex);
- return retval; + return 0; }
static int atmel_ac97c_playback_prepare(struct snd_pcm_substream *substream) @@ -461,7 +449,6 @@ static const struct snd_pcm_ops atmel_ac97_playback_ops = { .close = atmel_ac97c_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_playback_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_playback_prepare, .trigger = atmel_ac97c_playback_trigger, .pointer = atmel_ac97c_playback_pointer, @@ -472,7 +459,6 @@ static const struct snd_pcm_ops atmel_ac97_capture_ops = { .close = atmel_ac97c_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_ac97c_capture_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = atmel_ac97c_capture_prepare, .trigger = atmel_ac97c_capture_trigger, .pointer = atmel_ac97c_capture_pointer, @@ -600,7 +586,7 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pdev->dev, hw.periods_min * hw.period_bytes_min, hw.buffer_bytes_max);
Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/drivers/aloop.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 6bb46423f5ae..104fb738cf48 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -905,12 +905,6 @@ static void loopback_runtime_free(struct snd_pcm_runtime *runtime) kfree(dpcm); }
-static int loopback_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); -} - static int loopback_hw_free(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -920,7 +914,7 @@ static int loopback_hw_free(struct snd_pcm_substream *substream) mutex_lock(&dpcm->loopback->cable_lock); cable->valid &= ~(1 << substream->stream); mutex_unlock(&dpcm->loopback->cable_lock); - return snd_pcm_lib_free_pages(substream); + return 0; }
static unsigned int get_cable_index(struct snd_pcm_substream *substream) @@ -1306,7 +1300,6 @@ static const struct snd_pcm_ops loopback_pcm_ops = { .open = loopback_open, .close = loopback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = loopback_hw_params, .hw_free = loopback_hw_free, .prepare = loopback_prepare, .trigger = loopback_trigger, @@ -1325,8 +1318,7 @@ static int loopback_pcm_new(struct loopback *loopback, return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &loopback_pcm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &loopback_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
pcm->private_data = loopback; pcm->info_flags = 0;
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/drivers/dummy.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 022a0db692e0..ab6062dcd1b3 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -529,15 +529,7 @@ static int dummy_pcm_hw_params(struct snd_pcm_substream *substream, substream->runtime->dma_bytes = params_buffer_bytes(hw_params); return 0; } - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int dummy_pcm_hw_free(struct snd_pcm_substream *substream) -{ - if (fake_buffer) - return 0; - return snd_pcm_lib_free_pages(substream); + return 0; }
static int dummy_pcm_open(struct snd_pcm_substream *substream) @@ -657,7 +649,6 @@ static struct snd_pcm_ops dummy_pcm_ops = { .close = dummy_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, - .hw_free = dummy_pcm_hw_free, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, .pointer = dummy_pcm_pointer, @@ -668,7 +659,6 @@ static struct snd_pcm_ops dummy_pcm_ops_no_buf = { .close = dummy_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = dummy_pcm_hw_params, - .hw_free = dummy_pcm_hw_free, .prepare = dummy_pcm_prepare, .trigger = dummy_pcm_trigger, .pointer = dummy_pcm_pointer, @@ -700,7 +690,7 @@ static int snd_card_dummy_pcm(struct snd_dummy *dummy, int device, pcm->info_flags = 0; strcpy(pcm->name, "Dummy PCM"); if (!fake_buffer) { - snd_pcm_lib_preallocate_pages_for_all(pcm, + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, NULL, 0, 64*1024);
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous (they were only useless debug prints) and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/drivers/ml403-ac97cr.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-)
diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index 70a6d1832698..fad63783b4ae 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -670,23 +670,6 @@ snd_ml403_ac97cr_pcm_capture_prepare(struct snd_pcm_substream *substream) return 0; }
-static int snd_ml403_ac97cr_hw_free(struct snd_pcm_substream *substream) -{ - PDEBUG(WORK_INFO, "hw_free()\n"); - return snd_pcm_lib_free_pages(substream); -} - -static int -snd_ml403_ac97cr_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - PDEBUG(WORK_INFO, "hw_params(): desired buffer bytes=%d, desired " - "period bytes=%d\n", - params_buffer_bytes(hw_params), params_period_bytes(hw_params)); - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - static int snd_ml403_ac97cr_playback_open(struct snd_pcm_substream *substream) { struct snd_ml403_ac97cr *ml403_ac97cr; @@ -749,8 +732,6 @@ static const struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { .open = snd_ml403_ac97cr_playback_open, .close = snd_ml403_ac97cr_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ml403_ac97cr_hw_params, - .hw_free = snd_ml403_ac97cr_hw_free, .prepare = snd_ml403_ac97cr_pcm_playback_prepare, .trigger = snd_ml403_ac97cr_pcm_playback_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, @@ -760,8 +741,6 @@ static const struct snd_pcm_ops snd_ml403_ac97cr_capture_ops = { .open = snd_ml403_ac97cr_capture_open, .close = snd_ml403_ac97cr_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ml403_ac97cr_hw_params, - .hw_free = snd_ml403_ac97cr_hw_free, .prepare = snd_ml403_ac97cr_pcm_capture_prepare, .trigger = snd_ml403_ac97cr_pcm_capture_trigger, .pointer = snd_ml403_ac97cr_pcm_pointer, @@ -1241,10 +1220,10 @@ snd_ml403_ac97cr_pcm(struct snd_ml403_ac97cr *ml403_ac97cr, int device) strcpy(pcm->name, "ML403AC97CR DAC/ADC"); ml403_ac97cr->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64 * 1024, - 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64 * 1024, + 128 * 1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/drivers/pcsp/pcsp_lib.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index f91316bf01cb..4fdc4dbdae57 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -214,12 +214,7 @@ static int snd_pcsp_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_pcsp *chip = snd_pcm_substream_chip(substream); - int err; pcsp_sync_stop(chip); - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; return 0; }
@@ -230,7 +225,7 @@ static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream) printk(KERN_INFO "PCSP: hw_free called\n"); #endif pcsp_sync_stop(chip); - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_pcsp_playback_prepare(struct snd_pcm_substream *substream) @@ -350,11 +345,11 @@ int snd_pcsp_new_pcm(struct snd_pcsp *chip) chip->pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; strcpy(chip->pcm->name, "pcsp");
- snd_pcm_lib_preallocate_pages_for_all(chip->pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - PCSP_BUFFER_SIZE, - PCSP_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(chip->pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + PCSP_BUFFER_SIZE, + PCSP_BUFFER_SIZE);
return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/drivers/vx/vx_pcm.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index f17e0a76c73c..615e8b2b85f6 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -772,23 +772,6 @@ static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs) return pipe->position; }
-/* - * vx_pcm_hw_params - hw_params callback for playback and capture - */ -static int vx_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * vx_pcm_hw_free - hw_free callback for playback and capture - */ -static int vx_pcm_hw_free(struct snd_pcm_substream *subs) -{ - return snd_pcm_lib_free_pages(subs); -} - /* * vx_pcm_prepare - prepare callback for playback and capture */ @@ -861,8 +844,6 @@ static const struct snd_pcm_ops vx_pcm_playback_ops = { .open = vx_pcm_playback_open, .close = vx_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = vx_pcm_hw_params, - .hw_free = vx_pcm_hw_free, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_playback_pointer, @@ -1081,8 +1062,6 @@ static const struct snd_pcm_ops vx_pcm_capture_ops = { .open = vx_pcm_capture_open, .close = vx_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = vx_pcm_hw_params, - .hw_free = vx_pcm_hw_free, .prepare = vx_pcm_prepare, .trigger = vx_pcm_trigger, .pointer = vx_pcm_capture_pointer, @@ -1230,9 +1209,9 @@ int snd_vx_pcm_new(struct vx_core *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &vx_pcm_playback_ops); if (ins) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &vx_pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), - 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), + 0, 0);
pcm->private_data = chip; pcm->private_free = snd_vx_pcm_free;
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/firewire/bebob/bebob_pcm.c | 11 +++-------- sound/firewire/dice/dice-pcm.c | 13 ++++--------- sound/firewire/digi00x/digi00x-pcm.c | 11 +++-------- sound/firewire/fireface/ff-pcm.c | 9 ++------- sound/firewire/fireworks/fireworks_pcm.c | 11 +++-------- sound/firewire/isight.c | 10 ++-------- sound/firewire/motu/motu-pcm.c | 11 +++-------- sound/firewire/oxfw/oxfw-pcm.c | 17 ++++------------- sound/firewire/tascam/tascam-pcm.c | 11 +++-------- 9 files changed, 27 insertions(+), 77 deletions(-)
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..2ee91ff6891e 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -214,10 +214,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_bebob *bebob = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -231,7 +227,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&bebob->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&bebob->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int @@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) "%s PCM", bebob->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index be79d659eedf..122f95068170 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -266,10 +266,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_dice *dice = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int events_per_period = params_period_size(hw_params); @@ -288,7 +284,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&dice->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dice->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int capture_prepare(struct snd_pcm_substream *substream) @@ -457,9 +453,8 @@ int snd_dice_create_pcm(struct snd_dice *dice) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); }
return 0; diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index 57cbce4fd836..3c0566d78b56 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -190,10 +190,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_dg00x *dg00x = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -207,7 +203,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&dg00x->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dg00x->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) "%s PCM", dg00x->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index 4e3bd9a2bec0..2ffa12fd44f8 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -230,10 +230,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_ff *ff = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&ff->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) "%s PCM", ff->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index e69896d748df..09d6bc98647c 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -250,10 +250,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_efw *efw = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -267,7 +263,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&efw->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&efw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index d9f1b962bfef..214f77b0e8b7 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct isight *isight = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err;
WRITE_ONCE(isight->pcm_active, true);
@@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream) isight_stop_streaming(isight); mutex_unlock(&isight->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int isight_start_streaming(struct isight *isight) @@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight) strcpy(pcm->name, "iSight"); isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; isight->pcm->ops = &ops; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index 349b4d09e84f..d95a8b3cc03f 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -218,10 +218,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_motu *motu = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -235,7 +231,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&motu->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -251,7 +247,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&motu->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int capture_prepare(struct snd_pcm_substream *substream) @@ -378,8 +374,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 9124603edabe..6ea08300b49e 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -239,10 +239,6 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, struct snd_oxfw *oxfw = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int channels = params_channels(hw_params); @@ -258,7 +254,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&oxfw->mutex); }
- return err; + return 0; } static int pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) @@ -266,10 +262,6 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_oxfw *oxfw = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int channels = params_channels(hw_params); @@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_playback_hw_free(struct snd_pcm_substream *substream) { @@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); if (cap > 0) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c index 8e9b444c8bff..9f86c2d7e79e 100644 --- a/sound/firewire/tascam/tascam-pcm.c +++ b/sound/firewire/tascam/tascam-pcm.c @@ -119,10 +119,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_tscm *tscm = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params); @@ -136,7 +132,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&tscm->mutex); }
- return err; + return 0; }
static int pcm_hw_free(struct snd_pcm_substream *substream) @@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&tscm->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) "%s PCM", tscm->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; }
Hi,
I'm not opposed to this patchset. The direction is preferable.
However changes in this patchset brings bugs in error path of each implementation for pcm.hw_params.
On Mon, Dec 09, 2019 at 10:48:41AM +0100, Takashi Iwai wrote:
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..2ee91ff6891e 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -214,10 +214,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_bebob *bebob = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
- if (err < 0)
return err;
- if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params);
@@ -231,7 +227,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&bebob->mutex); }
- return err;
- return 0;
}
This should return the err variable to report failure of isochronous resources reservation.
However I found that ALSA oxfw/fireface drivers returns 0 even if it fails. This is bug since v5.3 kernel.
Would you please apply below two patches into your three, then modify your patch for all firewire drivers to return error correctly?
======== 8< --------
From a2cddad1c74e8e825739db63c17c0efabed1c93d Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto o-takashi@sakamocchi.jp Date: Tue, 10 Dec 2019 00:03:04 +0900 Subject: [PATCH 1/2] ALSA: oxfw: fix return value in error path of isochronous resources reservation
Even if isochronous resources reservation fails, error code doesn't return in pcm.hw_params callback.
Cc: stable@vger.kernel.org #5.3+ Fixes: 4f380d007052 ("ALSA: oxfw: configure packet format in pcm.hw_params callback") Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- sound/firewire/oxfw/oxfw-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 9124603edabe..67fd3e844dd6 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -285,7 +285,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&oxfw->mutex); }
- return 0; + return err; }
static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
On Mon, 09 Dec 2019 16:16:56 +0100, Takashi Sakamoto wrote:
Hi,
I'm not opposed to this patchset. The direction is preferable.
However changes in this patchset brings bugs in error path of each implementation for pcm.hw_params.
On Mon, Dec 09, 2019 at 10:48:41AM +0100, Takashi Iwai wrote:
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..2ee91ff6891e 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -214,10 +214,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_bebob *bebob = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
- if (err < 0)
return err;
- if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params);
@@ -231,7 +227,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&bebob->mutex); }
- return err;
- return 0;
}
This should return the err variable to report failure of isochronous resources reservation.
However I found that ALSA oxfw/fireface drivers returns 0 even if it fails. This is bug since v5.3 kernel.
Would you please apply below two patches into your three, then modify your patch for all firewire drivers to return error correctly?
Yes, that sounds like a correct fix. Thank you for spotting out.
So, please go ahead, submit these two patches, then I'll update the fix containing your correction above and submit as v2 (maybe only for this, as the whole series is too big to re-submit).
Takashi
On Mon, 09 Dec 2019 16:58:02 +0100, Takashi Iwai wrote:
On Mon, 09 Dec 2019 16:16:56 +0100, Takashi Sakamoto wrote:
Hi,
I'm not opposed to this patchset. The direction is preferable.
However changes in this patchset brings bugs in error path of each implementation for pcm.hw_params.
On Mon, Dec 09, 2019 at 10:48:41AM +0100, Takashi Iwai wrote:
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..2ee91ff6891e 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -214,10 +214,6 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_bebob *bebob = substream->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
- if (err < 0)
return err;
- if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); unsigned int frames_per_period = params_period_size(hw_params);
@@ -231,7 +227,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, mutex_unlock(&bebob->mutex); }
- return err;
- return 0;
}
This should return the err variable to report failure of isochronous resources reservation.
However I found that ALSA oxfw/fireface drivers returns 0 even if it fails. This is bug since v5.3 kernel.
Would you please apply below two patches into your three, then modify your patch for all firewire drivers to return error correctly?
Yes, that sounds like a correct fix. Thank you for spotting out.
So, please go ahead, submit these two patches, then I'll update the fix containing your correction above and submit as v2 (maybe only for this, as the whole series is too big to re-submit).
Never mind, the patches there were already good enough, so I applied these two now. Will resend v2 fix for this patch.
thanks,
Takashi
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- v1->v2: corrected the return value to propate the error initialize err variable for covering uninitialized compiler errors
sound/firewire/bebob/bebob_pcm.c | 11 +++-------- sound/firewire/dice/dice-pcm.c | 13 ++++--------- sound/firewire/digi00x/digi00x-pcm.c | 11 +++-------- sound/firewire/fireface/ff-pcm.c | 11 +++-------- sound/firewire/fireworks/fireworks_pcm.c | 11 +++-------- sound/firewire/isight.c | 10 ++-------- sound/firewire/motu/motu-pcm.c | 11 +++-------- sound/firewire/oxfw/oxfw-pcm.c | 19 +++++-------------- sound/firewire/tascam/tascam-pcm.c | 11 +++-------- 9 files changed, 29 insertions(+), 79 deletions(-)
diff --git a/sound/firewire/bebob/bebob_pcm.c b/sound/firewire/bebob/bebob_pcm.c index d4edd06d32cf..5fbf1d74c544 100644 --- a/sound/firewire/bebob/bebob_pcm.c +++ b/sound/firewire/bebob/bebob_pcm.c @@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_bebob *bebob = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&bebob->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int @@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) "%s PCM", bebob->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c index be79d659eedf..2700f7f6f754 100644 --- a/sound/firewire/dice/dice-pcm.c +++ b/sound/firewire/dice/dice-pcm.c @@ -264,11 +264,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_dice *dice = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dice->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int capture_prepare(struct snd_pcm_substream *substream) @@ -457,9 +453,8 @@ int snd_dice_create_pcm(struct snd_dice *dice) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); }
return 0; diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index 57cbce4fd836..bacf9b860f3f 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -188,11 +188,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_dg00x *dg00x = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dg00x->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) "%s PCM", dg00x->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index bd91c6ecb112..a52a4344ec6f 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -228,11 +228,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_ff *ff = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&ff->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) "%s PCM", ff->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index e69896d748df..8e60d22acbcc 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c @@ -248,11 +248,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_efw *efw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&efw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); end: return err; } diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index d9f1b962bfef..214f77b0e8b7 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct isight *isight = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err;
WRITE_ONCE(isight->pcm_active, true);
@@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream) isight_stop_streaming(isight); mutex_unlock(&isight->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int isight_start_streaming(struct isight *isight) @@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight) strcpy(pcm->name, "iSight"); isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; isight->pcm->ops = &ops; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index 005970931030..931978eb30c9 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_motu *motu = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&motu->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int capture_prepare(struct snd_pcm_substream *substream) @@ -374,8 +370,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/oxfw/oxfw-pcm.c b/sound/firewire/oxfw/oxfw-pcm.c index 67fd3e844dd6..974e53bbae10 100644 --- a/sound/firewire/oxfw/oxfw-pcm.c +++ b/sound/firewire/oxfw/oxfw-pcm.c @@ -237,11 +237,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_oxfw *oxfw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -264,11 +260,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_oxfw *oxfw = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; } static int pcm_playback_hw_free(struct snd_pcm_substream *substream) { @@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); if (cap > 0) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; } diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c index 8e9b444c8bff..92551ca3460c 100644 --- a/sound/firewire/tascam/tascam-pcm.c +++ b/sound/firewire/tascam/tascam-pcm.c @@ -117,11 +117,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_tscm *tscm = substream->private_data; - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; + int err = 0;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { unsigned int rate = params_rate(hw_params); @@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&tscm->mutex);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) "%s PCM", tscm->card->shortname); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; }
Hi,
On Mon, Dec 09, 2019 at 08:24:22PM +0100, Takashi Iwai wrote:
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de
v1->v2: corrected the return value to propate the error initialize err variable for covering uninitialized compiler errors
sound/firewire/bebob/bebob_pcm.c | 11 +++-------- sound/firewire/dice/dice-pcm.c | 13 ++++--------- sound/firewire/digi00x/digi00x-pcm.c | 11 +++-------- sound/firewire/fireface/ff-pcm.c | 11 +++-------- sound/firewire/fireworks/fireworks_pcm.c | 11 +++-------- sound/firewire/isight.c | 10 ++-------- sound/firewire/motu/motu-pcm.c | 11 +++-------- sound/firewire/oxfw/oxfw-pcm.c | 19 +++++-------------- sound/firewire/tascam/tascam-pcm.c | 11 +++-------- 9 files changed, 29 insertions(+), 79 deletions(-)
These changes are fine to me.
Acked-by: Takashi Sakamoto o-takashi@sakamocchi.jp
Regards
Takashi Sakamoto
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/ad1816a/ad1816a_lib.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index c4c60ebe2417..adc35051c5e9 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -206,17 +206,6 @@ static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int SNDRV_PCM_STREAM_CAPTURE, cmd, 1); }
-static int snd_ad1816a_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_ad1816a_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream) { struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); @@ -645,8 +634,6 @@ static const struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1816a_hw_params, - .hw_free = snd_ad1816a_hw_free, .prepare = snd_ad1816a_playback_prepare, .trigger = snd_ad1816a_playback_trigger, .pointer = snd_ad1816a_playback_pointer, @@ -656,8 +643,6 @@ static const struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1816a_hw_params, - .hw_free = snd_ad1816a_hw_free, .prepare = snd_ad1816a_capture_prepare, .trigger = snd_ad1816a_capture_trigger, .pointer = snd_ad1816a_capture_pointer, @@ -680,9 +665,8 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device) strcpy(pcm->name, snd_ad1816a_chip_id(chip)); snd_ad1816a_init(chip);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->card->dev, - 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, + 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
chip->pcm = pcm; return 0;
Clean up the driver with the new managed buffer allocation API. The actual removal of superfluous code will be done in ad1848 and sb codec drivers later.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/cmi8330.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index bb7d4940ac25..f8ec59a5bb8f 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -455,9 +455,8 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &chip->streams[SNDRV_PCM_STREAM_PLAYBACK].ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops);
- 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); chip->pcm = pcm;
return 0;
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/es1688/es1688_lib.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index a28dabaae0d3..d2c268595168 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -341,17 +341,6 @@ static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char va return 0; }
-static int snd_es1688_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_es1688_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; @@ -693,8 +682,6 @@ static const struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, .ioctl = snd_es1688_ioctl, - .hw_params = snd_es1688_hw_params, - .hw_free = snd_es1688_hw_free, .prepare = snd_es1688_playback_prepare, .trigger = snd_es1688_playback_trigger, .pointer = snd_es1688_playback_pointer, @@ -704,8 +691,6 @@ static const struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, .ioctl = snd_es1688_ioctl, - .hw_params = snd_es1688_hw_params, - .hw_free = snd_es1688_hw_free, .prepare = snd_es1688_capture_prepare, .trigger = snd_es1688_capture_trigger, .pointer = snd_es1688_capture_pointer, @@ -728,9 +713,8 @@ int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device) strcpy(pcm->name, snd_es1688_chip_id(chip)); chip->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, 64*1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/es18xx.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 01ad15086c4a..1346447ffe01 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -434,7 +434,7 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); - int shift, err; + int shift;
shift = 0; if (params_channels(hw_params) == 2) @@ -453,16 +453,9 @@ static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, } else { chip->dma1_shift = shift; } - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; return 0; }
-static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, struct snd_pcm_substream *substream) { @@ -543,7 +536,7 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_es18xx *chip = snd_pcm_substream_chip(substream); - int shift, err; + int shift;
shift = 0; if ((chip->caps & ES18XX_DUPLEX_MONO) && @@ -557,8 +550,6 @@ static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, if (snd_pcm_format_width(params_format(hw_params)) == 16) shift++; chip->dma1_shift = shift; - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; return 0; }
@@ -915,7 +906,6 @@ static int snd_es18xx_playback_close(struct snd_pcm_substream *substream) else chip->playback_b_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
@@ -924,7 +914,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
chip->capture_a_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
@@ -1656,7 +1645,6 @@ static const struct snd_pcm_ops snd_es18xx_playback_ops = { .close = snd_es18xx_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_playback_hw_params, - .hw_free = snd_es18xx_pcm_hw_free, .prepare = snd_es18xx_playback_prepare, .trigger = snd_es18xx_playback_trigger, .pointer = snd_es18xx_playback_pointer, @@ -1667,7 +1655,6 @@ static const struct snd_pcm_ops snd_es18xx_capture_ops = { .close = snd_es18xx_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_es18xx_capture_hw_params, - .hw_free = snd_es18xx_pcm_hw_free, .prepare = snd_es18xx_capture_prepare, .trigger = snd_es18xx_capture_trigger, .pointer = snd_es18xx_capture_pointer, @@ -1701,10 +1688,9 @@ static int snd_es18xx_pcm(struct snd_card *card, int device) sprintf(pcm->name, "ESS AudioDrive ES%x", chip->version); chip->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, - chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, + chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/sb/sb16_main.c | 21 ++------------------- sound/isa/sb/sb8_main.c | 21 ++------------------- 2 files changed, 4 insertions(+), 38 deletions(-)
diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 0768bbf8fd71..07ebf2c49443 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -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; }
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 8221b85bb330..5804fa523600 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -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; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/gus/gus_pcm.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 6385b61aa094..bd3a54bc4a94 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -423,11 +423,8 @@ static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream, struct snd_gus_card *gus = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct gus_pcm_private *pcmp = runtime->private_data; - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - if (err > 0) { /* change */ + + if (runtime->buffer_changed) { struct snd_gf1_mem_block *block; if (pcmp->memory > 0) { snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory); @@ -471,7 +468,6 @@ static int snd_gf1_pcm_playback_hw_free(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct gus_pcm_private *pcmp = runtime->private_data;
- snd_pcm_lib_free_pages(substream); if (pcmp->pvoices[0]) { snd_gf1_free_voice(pcmp->gus, pcmp->pvoices[0]); pcmp->pvoices[0] = NULL; @@ -574,12 +570,7 @@ static int snd_gf1_pcm_capture_hw_params(struct snd_pcm_substream *substream, gus->gf1.pcm_rcntrl_reg |= 4; if (snd_pcm_format_unsigned(params_format(hw_params))) gus->gf1.pcm_rcntrl_reg |= 0x80; - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_gf1_pcm_capture_prepare(struct snd_pcm_substream *substream) @@ -846,7 +837,6 @@ static const struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .close = snd_gf1_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_gf1_pcm_capture_hw_params, - .hw_free = snd_gf1_pcm_capture_hw_free, .prepare = snd_gf1_pcm_capture_prepare, .trigger = snd_gf1_pcm_capture_trigger, .pointer = snd_gf1_pcm_capture_pointer, @@ -875,9 +865,9 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops);
for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - card->dev, - 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + card->dev, + 64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024); pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; @@ -885,9 +875,9 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_gf1_pcm_capture_ops); if (gus->gf1.dma2 == gus->gf1.dma1) pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, card->dev, - 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, card->dev, + 64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024); } strcpy(pcm->name, pcm->id); if (gus->interwave) {
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/isa/wss/wss_lib.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index c43f2602249b..0ef89c97ccd2 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -982,10 +982,7 @@ static int snd_wss_playback_hw_params(struct snd_pcm_substream *substream, { struct snd_wss *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; - int err;
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; new_pdfr = snd_wss_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_wss_get_rate(params_rate(hw_params)); @@ -993,11 +990,6 @@ static int snd_wss_playback_hw_params(struct snd_pcm_substream *substream, return 0; }
-static int snd_wss_playback_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_wss_playback_prepare(struct snd_pcm_substream *substream) { struct snd_wss *chip = snd_pcm_substream_chip(substream); @@ -1025,10 +1017,7 @@ static int snd_wss_capture_hw_params(struct snd_pcm_substream *substream, { struct snd_wss *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; - int err;
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; new_cdfr = snd_wss_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_wss_get_rate(params_rate(hw_params)); @@ -1036,11 +1025,6 @@ static int snd_wss_capture_hw_params(struct snd_pcm_substream *substream, return 0; }
-static int snd_wss_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_wss_capture_prepare(struct snd_pcm_substream *substream) { struct snd_wss *chip = snd_pcm_substream_chip(substream); @@ -1889,7 +1873,6 @@ static const struct snd_pcm_ops snd_wss_playback_ops = { .close = snd_wss_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_playback_hw_params, - .hw_free = snd_wss_playback_hw_free, .prepare = snd_wss_playback_prepare, .trigger = snd_wss_trigger, .pointer = snd_wss_playback_pointer, @@ -1900,7 +1883,6 @@ static const struct snd_pcm_ops snd_wss_capture_ops = { .close = snd_wss_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_wss_capture_hw_params, - .hw_free = snd_wss_capture_hw_free, .prepare = snd_wss_capture_prepare, .trigger = snd_wss_trigger, .pointer = snd_wss_capture_pointer, @@ -1927,9 +1909,8 @@ int snd_wss_pcm(struct snd_wss *chip, int device) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_wss_chip_id(chip));
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->card->dev, - 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, + 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
chip->pcm = pcm; return 0;
Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/mips/hal2.c | 25 ++----------------------- sound/mips/sgio2audio.c | 20 ++------------------ 2 files changed, 4 insertions(+), 41 deletions(-)
diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index c9e060939708..e80ebe521218 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -505,23 +505,6 @@ static const struct snd_pcm_hardware hal2_pcm_hw = { .periods_max = 1024, };
-static int hal2_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - int err; - - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - - return 0; -} - -static int hal2_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int hal2_playback_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -702,8 +685,6 @@ static const struct snd_pcm_ops hal2_playback_ops = { .open = hal2_playback_open, .close = hal2_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hal2_pcm_hw_params, - .hw_free = hal2_pcm_hw_free, .prepare = hal2_playback_prepare, .trigger = hal2_playback_trigger, .pointer = hal2_playback_pointer, @@ -714,8 +695,6 @@ static const struct snd_pcm_ops hal2_capture_ops = { .open = hal2_capture_open, .close = hal2_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hal2_pcm_hw_params, - .hw_free = hal2_pcm_hw_free, .prepare = hal2_capture_prepare, .trigger = hal2_capture_trigger, .pointer = hal2_capture_pointer, @@ -740,8 +719,8 @@ static int hal2_pcm_create(struct snd_hal2 *hal2) &hal2_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &hal2_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 0, 1024 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 0, 1024 * 1024);
return 0; } diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 9d20ce6118a0..481f5ffff61b 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -577,20 +577,6 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream) return 0; }
- -/* hw_params callback */ -static int snd_sgio2audio_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_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* prepare callback */ static int snd_sgio2audio_pcm_prepare(struct snd_pcm_substream *substream) { @@ -716,8 +702,7 @@ static int snd_sgio2audio_new_pcm(struct snd_sgio2audio *chip) &snd_sgio2audio_playback1_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sgio2audio_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
/* create second pcm device with one outputs and no input */ 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) /* set operators */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sgio2audio_playback2_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/parisc/harmony.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 6acc59c25379..1a4c40aafcbe 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -567,20 +567,12 @@ static int snd_harmony_hw_params(struct snd_pcm_substream *ss, struct snd_pcm_hw_params *hw) { - int err; struct snd_harmony *h = snd_pcm_substream_chip(ss); - err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); - if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) + if (h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) ss->runtime->dma_addr = __pa(ss->runtime->dma_area); - - return err; -}
-static int -snd_harmony_hw_free(struct snd_pcm_substream *ss) -{ - return snd_pcm_lib_free_pages(ss); + return 0; }
static const struct snd_pcm_ops snd_harmony_playback_ops = { @@ -588,7 +580,6 @@ static const struct snd_pcm_ops snd_harmony_playback_ops = { .close = snd_harmony_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, - .hw_free = snd_harmony_hw_free, .prepare = snd_harmony_playback_prepare, .trigger = snd_harmony_playback_trigger, .pointer = snd_harmony_playback_pointer, @@ -599,7 +590,6 @@ static const struct snd_pcm_ops snd_harmony_capture_ops = { .close = snd_harmony_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_harmony_hw_params, - .hw_free = snd_harmony_hw_free, .prepare = snd_harmony_capture_prepare, .trigger = snd_harmony_capture_trigger, .pointer = snd_harmony_capture_pointer, @@ -656,8 +646,8 @@ snd_harmony_pcm_init(struct snd_harmony *h) }
/* pre-allocate space for DMA */ - snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev, - MAX_BUF_SIZE, MAX_BUF_SIZE); + snd_pcm_set_managed_buffer_all(pcm, h->dma.type, h->dma.dev, + MAX_BUF_SIZE, MAX_BUF_SIZE);
h->st.format = snd_harmony_set_data_format(h, SNDRV_PCM_FORMAT_S16_BE, 1);
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ad1889.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 5b6452df8bbd..12c6a7975100 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -257,20 +257,6 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip) return 0; }
-static int -snd_ad1889_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_ad1889_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static const struct snd_pcm_hardware snd_ad1889_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, @@ -563,8 +549,6 @@ static const struct snd_pcm_ops snd_ad1889_playback_ops = { .open = snd_ad1889_playback_open, .close = snd_ad1889_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1889_hw_params, - .hw_free = snd_ad1889_hw_free, .prepare = snd_ad1889_playback_prepare, .trigger = snd_ad1889_playback_trigger, .pointer = snd_ad1889_playback_pointer, @@ -574,8 +558,6 @@ static const struct snd_pcm_ops snd_ad1889_capture_ops = { .open = snd_ad1889_capture_open, .close = snd_ad1889_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ad1889_hw_params, - .hw_free = snd_ad1889_hw_free, .prepare = snd_ad1889_capture_prepare, .trigger = snd_ad1889_capture_trigger, .pointer = snd_ad1889_capture_pointer, @@ -632,10 +614,8 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device) chip->psubs = NULL; chip->csubs = NULL;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - BUFFER_BYTES_MAX / 2, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + BUFFER_BYTES_MAX / 2, BUFFER_BYTES_MAX);
return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ali5451/ali5451.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index ae29df085ae1..8d8d54be331b 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1138,13 +1138,7 @@ static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_ali_voice *pvoice = runtime->private_data; struct snd_ali_voice *evoice = pvoice->extra; - int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; - /* voice management */
if (params_buffer_size(hw_params) / 2 != @@ -1175,7 +1169,6 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream) struct snd_ali_voice *pvoice = runtime->private_data; struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
- snd_pcm_lib_free_pages(substream); if (evoice) { snd_ali_free_voice(codec, evoice); pvoice->extra = NULL; @@ -1183,18 +1176,6 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream) return 0; }
-static int snd_ali_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_ali_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ali_playback_prepare(struct snd_pcm_substream *substream) { struct snd_ali *codec = snd_pcm_substream_chip(substream); @@ -1538,8 +1519,6 @@ static const struct snd_pcm_ops snd_ali_capture_ops = { .open = snd_ali_capture_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ali_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1557,7 +1536,7 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream, snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); - return snd_ali_hw_params(substream, hw_params); + return 0; }
static struct snd_pcm_hardware snd_ali_modem = @@ -1614,7 +1593,6 @@ static const struct snd_pcm_ops snd_ali_modem_playback_ops = { .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1625,7 +1603,6 @@ static const struct snd_pcm_ops snd_ali_modem_capture_ops = { .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ali_modem_hw_params, - .hw_free = snd_ali_hw_free, .prepare = snd_ali_prepare, .trigger = snd_ali_trigger, .pointer = snd_ali_pointer, @@ -1671,9 +1648,8 @@ static int snd_ali_pcm(struct snd_ali *codec, int device, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &codec->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &codec->pci->dev, 64*1024, 128*1024);
pcm->info_flags = 0; pcm->dev_class = desc->class;
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/als300.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/sound/pci/als300.c b/sound/pci/als300.c index cfbb8cacaaac..0bb5a0fea23a 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -378,7 +378,6 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream) data = substream->runtime->private_data; kfree(data); chip->playback_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
@@ -407,22 +406,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream) data = substream->runtime->private_data; kfree(data); chip->capture_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
-static int snd_als300_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)); -} - -static int snd_als300_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_als300_playback_prepare(struct snd_pcm_substream *substream) { u32 tmp; @@ -554,8 +540,6 @@ static const struct snd_pcm_ops snd_als300_playback_ops = { .open = snd_als300_playback_open, .close = snd_als300_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als300_pcm_hw_params, - .hw_free = snd_als300_pcm_hw_free, .prepare = snd_als300_playback_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, @@ -565,8 +549,6 @@ static const struct snd_pcm_ops snd_als300_capture_ops = { .open = snd_als300_capture_open, .close = snd_als300_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als300_pcm_hw_params, - .hw_free = snd_als300_pcm_hw_free, .prepare = snd_als300_capture_prepare, .trigger = snd_als300_trigger, .pointer = snd_als300_pointer, @@ -591,9 +573,8 @@ static int snd_als300_new_pcm(struct snd_als300 *chip) &snd_als300_capture_ops);
/* pre-allocation of buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/als4000.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index d6f5487afe52..ea51913ea134 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -354,18 +354,6 @@ CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S16L_STEREO */ }; #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format])
-static int snd_als4000_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_als4000_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static int snd_als4000_capture_prepare(struct snd_pcm_substream *substream) { struct snd_sb *chip = snd_pcm_substream_chip(substream); @@ -633,7 +621,6 @@ static int snd_als4000_playback_close(struct snd_pcm_substream *substream) struct snd_sb *chip = snd_pcm_substream_chip(substream);
chip->playback_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
@@ -652,7 +639,6 @@ static int snd_als4000_capture_close(struct snd_pcm_substream *substream) struct snd_sb *chip = snd_pcm_substream_chip(substream);
chip->capture_substream = NULL; - snd_pcm_lib_free_pages(substream); return 0; }
@@ -662,8 +648,6 @@ static const struct snd_pcm_ops snd_als4000_playback_ops = { .open = snd_als4000_playback_open, .close = snd_als4000_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als4000_hw_params, - .hw_free = snd_als4000_hw_free, .prepare = snd_als4000_playback_prepare, .trigger = snd_als4000_playback_trigger, .pointer = snd_als4000_playback_pointer @@ -673,8 +657,6 @@ static const struct snd_pcm_ops snd_als4000_capture_ops = { .open = snd_als4000_capture_open, .close = snd_als4000_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_als4000_hw_params, - .hw_free = snd_als4000_hw_free, .prepare = snd_als4000_capture_prepare, .trigger = snd_als4000_capture_trigger, .pointer = snd_als4000_capture_pointer @@ -693,9 +675,8 @@ static int snd_als4000_pcm(struct snd_sb *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024);
chip->pcm = pcm;
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/asihpi/asihpi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 147005fdd3ea..ccdaaf28dcf8 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -449,9 +449,6 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, unsigned int bytes_per_sec;
print_hwparams(substream, params); - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; err = snd_card_asihpi_format_alsa2hpi(params_format(params), &format); if (err) return err; @@ -509,7 +506,6 @@ snd_card_asihpi_hw_free(struct snd_pcm_substream *substream) if (dpcm->hpi_buffer_attached) hpi_stream_host_buffer_detach(dpcm->h_stream);
- snd_pcm_lib_free_pages(substream); return 0; }
@@ -1324,9 +1320,9 @@ static int snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, int device)
/*? do we want to emulate MMAP for non-BBM cards? Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &asihpi->pci->dev, - 64*1024, BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &asihpi->pci->dev, + 64*1024, BUFFER_BYTES_MAX);
return 0; }
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/atiixp.c | 14 ++++---------- sound/pci/atiixp_modem.c | 9 ++------- 2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 1e1ededf8eb2..6fb56952c9c7 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -952,9 +952,6 @@ static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, struct atiixp_dma *dma = substream->runtime->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params);
@@ -994,7 +991,6 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) dma->pcm_open_flag = 0; } atiixp_clear_dma_packets(chip, dma, substream); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -1283,9 +1279,8 @@ static int snd_atiixp_pcm_new(struct atiixp *chip) strcpy(pcm->name, "ATI IXP AC97"); chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024);
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, chip->max_channels, 0, @@ -1316,9 +1311,8 @@ static int snd_atiixp_pcm_new(struct atiixp *chip) strcpy(pcm->name, "ATI IXP IEC958 (Direct)"); chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024);
/* pre-select AC97 SPDIF slots 10/11 */ for (i = 0; i < NUM_ATI_CODECS; i++) { diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 6f088c1949f3..dc40fdaa71cb 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -783,9 +783,6 @@ static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, int err; int i;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params);
@@ -812,7 +809,6 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) struct atiixp_dma *dma = substream->runtime->private_data;
atiixp_clear_dma_packets(chip, dma, substream); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -994,9 +990,8 @@ static int snd_atiixp_pcm_new(struct atiixp_modem *chip) strcpy(pcm->name, "ATI IXP MC97"); chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 128*1024);
return 0; }
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/au88x0/au88x0_pcm.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index a2dcf43beedf..9d7436cd7b0f 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -209,15 +209,7 @@ snd_vortex_pcm_hw_params(struct snd_pcm_substream *substream, { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) (substream->runtime->private_data); - int err;
- // Alloc buffer memory. - err = - snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) { - dev_err(chip->card->dev, "Vortex: pcm page alloc failed!\n"); - return err; - } /* pr_info( "Vortex: periods %d, period_bytes %d, channels = %d\n", params_periods(hw_params), params_period_bytes(hw_params), params_channels(hw_params)); @@ -304,7 +296,7 @@ static int snd_vortex_pcm_hw_free(struct snd_pcm_substream *substream) substream->runtime->private_data = NULL; spin_unlock_irq(&chip->lock);
- return snd_pcm_lib_free_pages(substream); + return 0; }
/* prepare callback */ @@ -636,9 +628,8 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr) /* pre-allocation of Scatter-Gather buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci_dev->dev, - 0x10000, 0x10000); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci_dev->dev, 0x10000, 0x10000);
switch (VORTEX_PCM_TYPE(pcm)) { case VORTEX_PCM_ADB:
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/aw2/aw2-alsa.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 1cbfae856a2a..d68ae91650a7 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -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,10 +590,10 @@ 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, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_playback_ana, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024);
err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, &pcm_playback_num); @@ -643,10 +622,10 @@ 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, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_playback_num, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024);
err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, &pcm_capture); @@ -676,10 +655,10 @@ 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, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm_capture, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + 64 * 1024, 64 * 1024);
/* Create control */ err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/azt3328.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index f475370faaaa..5fac2d60ba2d 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1205,20 +1205,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip) } #endif /* AZF_USE_AC97_LAYER */
-static int -snd_azf3328_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_azf3328_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - return 0; -} - static void snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec, enum azf_freq_t bitrate, @@ -2080,8 +2066,6 @@ static const struct snd_pcm_ops snd_azf3328_playback_ops = { .open = snd_azf3328_pcm_playback_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2091,8 +2075,6 @@ static const struct snd_pcm_ops snd_azf3328_capture_ops = { .open = snd_azf3328_pcm_capture_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2102,8 +2084,6 @@ static const struct snd_pcm_ops snd_azf3328_i2s_out_ops = { .open = snd_azf3328_pcm_i2s_out_open, .close = snd_azf3328_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_azf3328_hw_params, - .hw_free = snd_azf3328_hw_free, .prepare = snd_azf3328_pcm_prepare, .trigger = snd_azf3328_pcm_trigger, .pointer = snd_azf3328_pcm_pointer @@ -2134,9 +2114,8 @@ snd_azf3328_pcm(struct snd_azf3328 *chip) chip->pcm[AZF_CODEC_PLAYBACK] = pcm; chip->pcm[AZF_CODEC_CAPTURE] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024);
err = snd_pcm_new(chip->card, "AZF3328 I2S OUT", AZF_PCMDEV_I2S_OUT, 1, 0, &pcm); @@ -2150,9 +2129,8 @@ snd_azf3328_pcm(struct snd_azf3328 *chip) strcpy(pcm->name, chip->card->shortname); chip->pcm[AZF_CODEC_I2S_OUT] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 64*1024);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/bt87x.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 6bf5ac3600c5..3fe522b32426 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -452,12 +452,7 @@ static int snd_bt87x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_bt87x *chip = snd_pcm_substream_chip(substream); - int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; return snd_bt87x_create_risc(chip, substream, params_periods(hw_params), params_period_bytes(hw_params)); @@ -468,7 +463,6 @@ static int snd_bt87x_hw_free(struct snd_pcm_substream *substream) struct snd_bt87x *chip = snd_pcm_substream_chip(substream);
snd_bt87x_free_risc(chip); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -699,10 +693,10 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) pcm->private_data = chip; strcpy(pcm->name, name); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 128 * 1024, - ALIGN(255 * 4092, 1024)); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 128 * 1024, + ALIGN(255 * 4092, 1024)); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ca0106/ca0106_main.c | 56 +++++------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-)
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index abc2440dc2d9..758cb4dd4b00 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -707,34 +707,6 @@ static int snd_ca0106_pcm_open_3_capture(struct snd_pcm_substream *substream) return snd_ca0106_pcm_open_capture_channel(substream, 3); }
-/* hw_params callback */ -static int snd_ca0106_pcm_hw_params_playback(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_ca0106_pcm_hw_free_playback(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - -/* hw_params callback */ -static int snd_ca0106_pcm_hw_params_capture(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_ca0106_pcm_hw_free_capture(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* prepare playback callback */ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) { @@ -1097,8 +1069,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_front_ops = { .open = snd_ca0106_pcm_open_playback_front, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1108,8 +1078,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_0_ops = { .open = snd_ca0106_pcm_open_0_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1119,8 +1087,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_1_ops = { .open = snd_ca0106_pcm_open_1_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1130,8 +1096,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_2_ops = { .open = snd_ca0106_pcm_open_2_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1141,8 +1105,6 @@ static const struct snd_pcm_ops snd_ca0106_capture_3_ops = { .open = snd_ca0106_pcm_open_3_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_capture, - .hw_free = snd_ca0106_pcm_hw_free_capture, .prepare = snd_ca0106_pcm_prepare_capture, .trigger = snd_ca0106_pcm_trigger_capture, .pointer = snd_ca0106_pcm_pointer_capture, @@ -1152,8 +1114,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { .open = snd_ca0106_pcm_open_playback_center_lfe, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1163,8 +1123,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { .open = snd_ca0106_pcm_open_playback_unknown, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1174,8 +1132,6 @@ static const struct snd_pcm_ops snd_ca0106_playback_rear_ops = { .open = snd_ca0106_pcm_open_playback_rear, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ca0106_pcm_hw_params_playback, - .hw_free = snd_ca0106_pcm_hw_free_playback, .prepare = snd_ca0106_pcm_prepare_playback, .trigger = snd_ca0106_pcm_trigger_playback, .pointer = snd_ca0106_pcm_pointer_playback, @@ -1388,17 +1344,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device) for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 64*1024, 64*1024); }
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 64*1024, 64*1024); }
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/cmipci.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index dd9d62e2b633..1eac076f4692 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -666,12 +666,6 @@ static void snd_cmipci_set_pll(struct cmipci *cm, unsigned int rate, unsigned in } #endif /* USE_VAR48KRATE */
-static int snd_cmipci_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_cmipci_playback2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { @@ -686,7 +680,7 @@ static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream, cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI; mutex_unlock(&cm->open_mutex); } - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; }
static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) @@ -697,11 +691,6 @@ static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) udelay(10); }
-static int snd_cmipci_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} -
/* */ @@ -1371,14 +1360,14 @@ static int snd_cmipci_playback_hw_free(struct snd_pcm_substream *substream) setup_spdif_playback(cm, substream, 0, 0); restore_mixer_state(cm); snd_cmipci_silence_hack(cm, &cm->channel[0]); - return snd_cmipci_hw_free(substream); + return 0; }
static int snd_cmipci_playback2_hw_free(struct snd_pcm_substream *substream) { struct cmipci *cm = snd_pcm_substream_chip(substream); snd_cmipci_silence_hack(cm, &cm->channel[1]); - return snd_cmipci_hw_free(substream); + return 0; }
/* capture */ @@ -1420,7 +1409,7 @@ static int snd_cmipci_capture_spdif_hw_free(struct snd_pcm_substream *subs) snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); spin_unlock_irq(&cm->reg_lock);
- return snd_cmipci_hw_free(subs); + return 0; }
@@ -1829,7 +1818,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_ops = { .open = snd_cmipci_playback_open, .close = snd_cmipci_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_prepare, .trigger = snd_cmipci_playback_trigger, @@ -1840,8 +1828,6 @@ static const struct snd_pcm_ops snd_cmipci_capture_ops = { .open = snd_cmipci_capture_open, .close = snd_cmipci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, - .hw_free = snd_cmipci_hw_free, .prepare = snd_cmipci_capture_prepare, .trigger = snd_cmipci_capture_trigger, .pointer = snd_cmipci_capture_pointer, @@ -1862,7 +1848,6 @@ static const struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { .open = snd_cmipci_playback_spdif_open, .close = snd_cmipci_playback_spdif_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_playback_hw_free, .prepare = snd_cmipci_playback_spdif_prepare, /* set up rate */ .trigger = snd_cmipci_playback_trigger, @@ -1873,7 +1858,6 @@ static const struct snd_pcm_ops snd_cmipci_capture_spdif_ops = { .open = snd_cmipci_capture_spdif_open, .close = snd_cmipci_capture_spdif_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cmipci_hw_params, .hw_free = snd_cmipci_capture_spdif_hw_free, .prepare = snd_cmipci_capture_spdif_prepare, .trigger = snd_cmipci_capture_trigger, @@ -1901,8 +1885,8 @@ static int snd_cmipci_pcm_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI DAC/ADC"); cm->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024);
return 0; } @@ -1923,8 +1907,8 @@ static int snd_cmipci_pcm2_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI 2nd DAC"); cm->pcm2 = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024);
return 0; } @@ -1946,8 +1930,8 @@ static int snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) strcpy(pcm->name, "C-Media PCI IEC958"); cm->pcm_spdif = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cm->pci->dev, 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cm->pci->dev, 64*1024, 128*1024);
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, cm->max_channels, 0,
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/cs4281.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 058c1414b777..ea665d42107e 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -780,17 +780,6 @@ static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma, snd_cs4281_pokeBA0(chip, dma->regFSIC, 0); }
-static int snd_cs4281_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_cs4281_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_cs4281_playback_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -939,8 +928,6 @@ static const struct snd_pcm_ops snd_cs4281_playback_ops = { .open = snd_cs4281_playback_open, .close = snd_cs4281_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cs4281_hw_params, - .hw_free = snd_cs4281_hw_free, .prepare = snd_cs4281_playback_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, @@ -950,8 +937,6 @@ static const struct snd_pcm_ops snd_cs4281_capture_ops = { .open = snd_cs4281_capture_open, .close = snd_cs4281_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_cs4281_hw_params, - .hw_free = snd_cs4281_hw_free, .prepare = snd_cs4281_capture_prepare, .trigger = snd_cs4281_trigger, .pointer = snd_cs4281_pointer, @@ -974,9 +959,8 @@ static int snd_cs4281_pcm(struct cs4281 *chip, int device) strcpy(pcm->name, "CS4281"); chip->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 512*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev, + 64*1024, 512*1024);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/cs5535audio/cs5535audio_pcm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 4642e5384e83..0b2a23c6d277 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -236,10 +236,6 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, struct cs5535audio_dma *dma = substream->runtime->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; dma->buf_addr = substream->runtime->dma_addr; dma->buf_bytes = params_buffer_bytes(hw_params);
@@ -267,7 +263,7 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) dma->pcm_open_flag = 0; } cs5535audio_clear_dma_packets(cs5535au, dma, substream); - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_cs5535audio_playback_prepare(struct snd_pcm_substream *substream) @@ -431,9 +427,9 @@ int snd_cs5535audio_pcm(struct cs5535audio *cs5535au) pcm->info_flags = 0; strcpy(pcm->name, "CS5535 Audio");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &cs5535au->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &cs5535au->pci->dev, + 64*1024, 128*1024); cs5535au->pcm = pcm;
return 0;
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ctxfi/ctpcm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 7ae5b238703c..5ee2316827d8 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -178,15 +178,10 @@ static int ct_pcm_hw_params(struct snd_pcm_substream *substream, { struct ct_atc *atc = snd_pcm_substream_chip(substream); struct ct_atc_pcm *apcm = substream->runtime->private_data; - int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; /* clear previous resources */ atc->pcm_release_resources(atc, apcm); - return err; + return 0; }
static int ct_pcm_hw_free(struct snd_pcm_substream *substream) @@ -196,8 +191,7 @@ static int ct_pcm_hw_free(struct snd_pcm_substream *substream)
/* clear previous resources */ atc->pcm_release_resources(atc, apcm); - /* Free snd-allocated pages */ - return snd_pcm_lib_free_pages(substream); + return 0; }
@@ -449,9 +443,8 @@ int ct_alsa_pcm_create(struct ct_atc *atc, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &ct_pcm_capture_ops);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &atc->pci->dev, - 128*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &atc->pci->dev, 128*1024, 128*1024);
chs = 2; switch (device) {
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/echoaudio/echoaudio.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 1465813bf7c6..f8a4a8f6982e 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -547,16 +547,6 @@ static int init_engine(struct snd_pcm_substream *substream, "pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n", params_buffer_bytes(hw_params), params_periods(hw_params), params_period_bytes(hw_params)); - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) { - dev_err(chip->card->dev, "malloc_pages err=%d\n", err); - spin_lock_irq(&chip->lock); - free_pipes(chip, pipe); - spin_unlock_irq(&chip->lock); - pipe->index = -1; - return err; - }
sglist_init(chip, pipe); edge = PAGE_SIZE; @@ -671,7 +661,6 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) } spin_unlock_irq(&chip->lock);
- snd_pcm_lib_free_pages(substream); return 0; }
@@ -872,10 +861,10 @@ static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
for (stream = 0; stream < 2; stream++) for (ss = pcm->streams[stream].substream; ss; ss = ss->next) - snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG, - dev, - ss->number ? 0 : 128<<10, - 256<<10); + snd_pcm_set_managed_buffer(ss, SNDRV_DMA_TYPE_DEV_SG, + dev, + ss->number ? 0 : 128<<10, + 256<<10); }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/emu10k1/emu10k1x.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 241b4a0631ab..ef34fe711813 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -411,8 +411,7 @@ static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, epcm->voice->epcm = epcm; }
- return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; }
/* hw_free callback */ @@ -432,7 +431,7 @@ static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) epcm->voice = NULL; }
- return snd_pcm_lib_free_pages(substream); + return 0; }
/* prepare callback */ @@ -594,8 +593,7 @@ static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substrea epcm->voice->use = 1; }
- return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; }
/* hw_free callback */ @@ -615,7 +613,7 @@ static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) epcm->voice = NULL; }
- return snd_pcm_lib_free_pages(substream); + return 0; }
/* prepare capture callback */ @@ -876,9 +874,8 @@ static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device) } emu->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, 32*1024, 32*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 1 << 2, NULL);
Clean up the driver with the new managed buffer allocation API. The normal playback streams need a workaround for the aligned buffer, and cannot apply the straight snd_pcm_lib_malloc() stuff, so they remain untouched, while other streams are converted to the new managed mode.
Most of hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/emu10k1/emupcm.c | 41 +++++++-------------------------------- sound/pci/emu10k1/p16v.c | 48 +++++++--------------------------------------- 2 files changed, 14 insertions(+), 75 deletions(-)
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 9a8cf3c7dd67..3a68148f6ecf 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -569,17 +569,6 @@ static const struct snd_pcm_hardware snd_emu10k1_efx_playback = .fifo_size = 0, };
-static int snd_emu10k1_capture_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_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); @@ -1372,8 +1361,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1410,15 +1397,15 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device) strcpy(pcm->name, "ADC Capture/Standard PCM Playback"); emu->pcm = pcm;
+ /* playback substream can't use managed buffers due to alignment */ for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, &emu->pci->dev, 64*1024, 64*1024);
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, 64*1024, 64*1024);
return 0; } @@ -1454,8 +1441,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1477,9 +1462,8 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device) strcpy(pcm->name, "Mic Capture"); emu->pcm_mic = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, + 64*1024, 64*1024);
return 0; } @@ -1551,8 +1535,6 @@ static const struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_capture_hw_params, - .hw_free = snd_emu10k1_capture_hw_free, .prepare = snd_emu10k1_capture_prepare, .trigger = snd_emu10k1_capture_trigger, .pointer = snd_emu10k1_capture_pointer, @@ -1633,12 +1615,6 @@ static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substr fx8010_pb_trans_copy); }
-static int snd_emu10k1_fx8010_playback_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_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); @@ -1647,7 +1623,6 @@ static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substre
for (i = 0; i < pcm->channels; i++) snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -1793,7 +1768,6 @@ static const struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_emu10k1_fx8010_playback_hw_params, .hw_free = snd_emu10k1_fx8010_playback_hw_free, .prepare = snd_emu10k1_fx8010_playback_prepare, .trigger = snd_emu10k1_fx8010_playback_trigger, @@ -1852,9 +1826,8 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device) if (err < 0) return err;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, + 64*1024, 64*1024);
return 0; } diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index ab8876855989..2263db4c954b 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -282,36 +282,6 @@ static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream) return snd_p16v_pcm_open_capture_channel(substream, 0); }
-/* hw_params callback */ -static int snd_p16v_pcm_hw_params_playback(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_params callback */ -static int snd_p16v_pcm_hw_params_capture(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_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - -/* hw_free callback */ -static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - - /* prepare playback callback */ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) { @@ -583,8 +553,6 @@ static const struct snd_pcm_ops snd_p16v_playback_front_ops = { .open = snd_p16v_pcm_open_playback_front, .close = snd_p16v_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_p16v_pcm_hw_params_playback, - .hw_free = snd_p16v_pcm_hw_free_playback, .prepare = snd_p16v_pcm_prepare_playback, .trigger = snd_p16v_pcm_trigger_playback, .pointer = snd_p16v_pcm_pointer_playback, @@ -594,8 +562,6 @@ static const struct snd_pcm_ops snd_p16v_capture_ops = { .open = snd_p16v_pcm_open_capture, .close = snd_p16v_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_p16v_pcm_hw_params_capture, - .hw_free = snd_p16v_pcm_hw_free_capture, .prepare = snd_p16v_pcm_prepare_capture, .trigger = snd_p16v_pcm_trigger_capture, .pointer = snd_p16v_pcm_pointer_capture, @@ -642,10 +608,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - (65536 - 64) * 8, - (65536 - 64) * 8); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + (65536 - 64) * 8, + (65536 - 64) * 8); /* dev_dbg(emu->card->dev, "preallocate playback substream: err=%d\n", err); @@ -655,9 +621,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device) for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) { - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, - &emu->pci->dev, - 65536 - 64, 65536 - 64); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV, + &emu->pci->dev, + 65536 - 64, 65536 - 64); /* dev_dbg(emu->card->dev, "preallocate capture substream: err=%d\n", err);
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ens1370.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 0499dc863202..19d8238e130c 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -856,17 +856,6 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd) * PCM part */
-static int snd_ensoniq_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_ensoniq_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) { struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); @@ -1216,8 +1205,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback1_ops = { .open = snd_ensoniq_playback1_open, .close = snd_ensoniq_playback1_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_playback1_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback1_pointer, @@ -1227,8 +1214,6 @@ static const struct snd_pcm_ops snd_ensoniq_playback2_ops = { .open = snd_ensoniq_playback2_open, .close = snd_ensoniq_playback2_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_playback2_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_playback2_pointer, @@ -1238,8 +1223,6 @@ static const struct snd_pcm_ops snd_ensoniq_capture_ops = { .open = snd_ensoniq_capture_open, .close = snd_ensoniq_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ensoniq_hw_params, - .hw_free = snd_ensoniq_hw_free, .prepare = snd_ensoniq_capture_prepare, .trigger = snd_ensoniq_trigger, .pointer = snd_ensoniq_capture_pointer, @@ -1274,9 +1257,8 @@ static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) strcpy(pcm->name, CHIP_NAME " DAC2/ADC"); ensoniq->pcm1 = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ensoniq->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ensoniq->pci->dev, 64*1024, 128*1024);
#ifdef CHIP1370 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -1307,9 +1289,8 @@ static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) strcpy(pcm->name, CHIP_NAME " DAC1"); ensoniq->pcm2 = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ensoniq->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ensoniq->pci->dev, 64*1024, 128*1024);
#ifdef CHIP1370 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/es1938.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index c571c5d380ca..95d562fff06c 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -863,25 +863,6 @@ static int snd_es1938_capture_copy_kernel(struct snd_pcm_substream *substream, return 0; }
-/* - * buffer management - */ -static int snd_es1938_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) - -{ - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - return 0; -} - -static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* ---------------------------------------------------------------------- * Audio1 Capture (ADC) * ----------------------------------------------------------------------*/ @@ -997,8 +978,6 @@ static const struct snd_pcm_ops snd_es1938_playback_ops = { .open = snd_es1938_playback_open, .close = snd_es1938_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_es1938_pcm_hw_params, - .hw_free = snd_es1938_pcm_hw_free, .prepare = snd_es1938_playback_prepare, .trigger = snd_es1938_playback_trigger, .pointer = snd_es1938_playback_pointer, @@ -1008,8 +987,6 @@ static const struct snd_pcm_ops snd_es1938_capture_ops = { .open = snd_es1938_capture_open, .close = snd_es1938_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_es1938_pcm_hw_params, - .hw_free = snd_es1938_pcm_hw_free, .prepare = snd_es1938_capture_prepare, .trigger = snd_es1938_capture_trigger, .pointer = snd_es1938_capture_pointer, @@ -1031,9 +1008,8 @@ static int snd_es1938_new_pcm(struct es1938 *chip, int device) pcm->info_flags = 0; strcpy(pcm->name, "ESS Solo-1");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024);
chip->pcm = pcm; return 0;
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/fm801.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index a7f8109acced..707173254c55 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -435,17 +435,6 @@ static int snd_fm801_capture_trigger(struct snd_pcm_substream *substream, return 0; }
-static int snd_fm801_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_fm801_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_fm801_playback_prepare(struct snd_pcm_substream *substream) { struct fm801 *chip = snd_pcm_substream_chip(substream); @@ -685,8 +674,6 @@ static const struct snd_pcm_ops snd_fm801_playback_ops = { .open = snd_fm801_playback_open, .close = snd_fm801_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_fm801_hw_params, - .hw_free = snd_fm801_hw_free, .prepare = snd_fm801_playback_prepare, .trigger = snd_fm801_playback_trigger, .pointer = snd_fm801_playback_pointer, @@ -696,8 +683,6 @@ static const struct snd_pcm_ops snd_fm801_capture_ops = { .open = snd_fm801_capture_open, .close = snd_fm801_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_fm801_hw_params, - .hw_free = snd_fm801_hw_free, .prepare = snd_fm801_capture_prepare, .trigger = snd_fm801_capture_trigger, .pointer = snd_fm801_capture_pointer, @@ -720,9 +705,8 @@ static int snd_fm801_pcm(struct fm801 *chip, int device) strcpy(pcm->name, "FM801"); chip->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &pdev->dev, - chip->multichannel ? 128*1024 : 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &pdev->dev, + chip->multichannel ? 128*1024 : 64*1024, 128*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps,
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/hda/hda_controller.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 2f3b7a35f2d9..eb0bb2265685 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -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 *chip = apcm->chip; struct azx_dev *azx_dev = get_azx_dev(substream); - int ret; + int ret = 0;
trace_azx_pcm_hw_params(chip, azx_dev); dsp_lock(azx_dev); @@ -119,8 +119,6 @@ static int azx_pcm_hw_params(struct snd_pcm_substream *substream, azx_dev->core.bufsize = 0; azx_dev->core.period_bytes = 0; azx_dev->core.format_val = 0; - ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params));
unlock: dsp_unlock(azx_dev); @@ -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_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream); - int err;
/* reset BDL address */ dsp_lock(azx_dev); @@ -141,10 +138,9 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
- err = snd_pcm_lib_free_pages(substream); azx_stream(azx_dev)->prepared = 0; dsp_unlock(azx_dev); - return err; + return 0; }
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, size = MAX_PREALLOC_SIZE; if (chip->uc_buffer) type = SNDRV_DMA_TYPE_DEV_UC_SG; - snd_pcm_lib_preallocate_pages_for_all(pcm, type, - chip->card->dev, - size, MAX_PREALLOC_SIZE); + snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev, + size, MAX_PREALLOC_SIZE); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ice1712/ice1712.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index deadba40131c..1783584e90c5 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -479,21 +479,6 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id) }
-/* - * PCM part - misc - */ - -static int snd_ice1712_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_ice1712_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - /* * PCM part - consumer I/O */ @@ -837,8 +822,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ops = { .open = snd_ice1712_playback_open, .close = snd_ice1712_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_prepare, .trigger = snd_ice1712_playback_trigger, .pointer = snd_ice1712_playback_pointer, @@ -848,8 +831,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_ds_ops = { .open = snd_ice1712_playback_ds_open, .close = snd_ice1712_playback_ds_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_ds_prepare, .trigger = snd_ice1712_playback_ds_trigger, .pointer = snd_ice1712_playback_ds_pointer, @@ -859,8 +840,6 @@ static const struct snd_pcm_ops snd_ice1712_capture_ops = { .open = snd_ice1712_capture_open, .close = snd_ice1712_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ice1712_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_capture_prepare, .trigger = snd_ice1712_capture_trigger, .pointer = snd_ice1712_capture_pointer, @@ -883,9 +862,8 @@ static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device) strcpy(pcm->name, "ICE1712 consumer"); ice->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 64*1024, 64*1024);
dev_warn(ice->card->dev, "Consumer PCM code does not work well at the moment --jk\n"); @@ -909,9 +887,8 @@ static int snd_ice1712_pcm_ds(struct snd_ice1712 *ice, int device) strcpy(pcm->name, "ICE1712 consumer (DS)"); ice->pcm_ds = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 64*1024, 128*1024);
return 0; } @@ -1063,7 +1040,7 @@ static int snd_ice1712_playback_pro_hw_params(struct snd_pcm_substream *substrea struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; }
static int snd_ice1712_capture_pro_prepare(struct snd_pcm_substream *substream) @@ -1085,7 +1062,7 @@ static int snd_ice1712_capture_pro_hw_params(struct snd_pcm_substream *substream struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return 0; }
static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substream *substream) @@ -1221,7 +1198,6 @@ static const struct snd_pcm_ops snd_ice1712_playback_pro_ops = { .close = snd_ice1712_playback_pro_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_playback_pro_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_playback_pro_prepare, .trigger = snd_ice1712_pro_trigger, .pointer = snd_ice1712_playback_pro_pointer, @@ -1232,7 +1208,6 @@ static const struct snd_pcm_ops snd_ice1712_capture_pro_ops = { .close = snd_ice1712_capture_pro_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_ice1712_capture_pro_hw_params, - .hw_free = snd_ice1712_hw_free, .prepare = snd_ice1712_capture_pro_prepare, .trigger = snd_ice1712_pro_trigger, .pointer = snd_ice1712_capture_pro_pointer, @@ -1254,9 +1229,8 @@ static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1712 multi");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024);
ice->pcm_pro = pcm;
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ice1712/ice1724.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index c80a16ee6e76..ba992ce47282 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -704,7 +704,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); - int i, chs, err; + int i, chs;
chs = params_channels(hw_params); mutex_lock(&ice->open_mutex); @@ -740,11 +740,7 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, } mutex_unlock(&ice->open_mutex);
- err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + return snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); }
static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) @@ -758,7 +754,7 @@ static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) if (ice->pcm_reserved[i] == substream) ice->pcm_reserved[i] = NULL; mutex_unlock(&ice->open_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream) @@ -1142,9 +1138,8 @@ static int snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1724");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024);
ice->pcm_pro = pcm;
@@ -1340,9 +1335,8 @@ static int snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, name);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024);
ice->pcm = pcm;
@@ -1454,9 +1448,8 @@ static int snd_vt1724_pcm_indep(struct snd_ice1712 *ice, int device) pcm->info_flags = 0; strcpy(pcm->name, "ICE1724 Surround PCM");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &ice->pci->dev, - 256*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &ice->pci->dev, 256*1024, 256*1024);
ice->pcm_ds = pcm;
Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/intel8x0.c | 11 ++++------- sound/pci/intel8x0m.c | 23 ++++------------------- 2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 12374ba08ca2..b171816e58a8 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -901,9 +901,6 @@ static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream, int dbl = params_rate(hw_params) > 48000; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; if (ichdev->pcm_open_flag) { snd_ac97_pcm_close(ichdev->pcm); ichdev->pcm_open_flag = 0; @@ -929,7 +926,7 @@ static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream) snd_ac97_pcm_close(ichdev->pcm); ichdev->pcm_open_flag = 0; } - return snd_pcm_lib_free_pages(substream); + return 0; }
static void snd_intel8x0_setup_pcm_out(struct intel8x0 *chip, @@ -1487,9 +1484,9 @@ static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device, strcpy(pcm->name, chip->card->shortname); chip->pcm[device] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, intel8x0_dma_type(chip), - &chip->pci->dev, - rec->prealloc_size, rec->prealloc_max_size); + snd_pcm_set_managed_buffer_all(pcm, intel8x0_dma_type(chip), + &chip->pci->dev, + rec->prealloc_size, rec->prealloc_max_size);
if (rec->playback_ops && rec->playback_ops->open == snd_intel8x0_playback_open) { diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index a9add5fedfcb..897c989bedd1 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -553,17 +553,6 @@ static int snd_intel8x0m_pcm_trigger(struct snd_pcm_substream *substream, int cm return 0; }
-static int snd_intel8x0m_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_intel8x0m_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static snd_pcm_uframes_t snd_intel8x0m_pcm_pointer(struct snd_pcm_substream *substream) { struct intel8x0m *chip = snd_pcm_substream_chip(substream); @@ -674,8 +663,6 @@ static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { .open = snd_intel8x0m_playback_open, .close = snd_intel8x0m_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_intel8x0m_hw_params, - .hw_free = snd_intel8x0m_hw_free, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, @@ -685,8 +672,6 @@ static const struct snd_pcm_ops snd_intel8x0m_capture_ops = { .open = snd_intel8x0m_capture_open, .close = snd_intel8x0m_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_intel8x0m_hw_params, - .hw_free = snd_intel8x0m_hw_free, .prepare = snd_intel8x0m_pcm_prepare, .trigger = snd_intel8x0m_pcm_trigger, .pointer = snd_intel8x0m_pcm_pointer, @@ -733,10 +718,10 @@ static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device, strcpy(pcm->name, chip->card->shortname); chip->pcm[device] = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - rec->prealloc_size, - rec->prealloc_max_size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + rec->prealloc_size, + rec->prealloc_max_size);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/lola/lola_pcm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c index 856bcca60128..a01a06896084 100644 --- a/sound/pci/lola/lola_pcm.c +++ b/sound/pci/lola/lola_pcm.c @@ -282,8 +282,7 @@ static int lola_pcm_hw_params(struct snd_pcm_substream *substream, str->bufsize = 0; str->period_bytes = 0; str->format_verb = 0; - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; }
static int lola_pcm_hw_free(struct snd_pcm_substream *substream) @@ -296,7 +295,7 @@ static int lola_pcm_hw_free(struct snd_pcm_substream *substream) lola_stream_reset(chip, str); lola_cleanup_slave_streams(pcm, str); mutex_unlock(&chip->open_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; }
/* @@ -610,9 +609,9 @@ int lola_create_pcm(struct lola *chip) snd_pcm_set_ops(pcm, i, &lola_pcm_ops); } /* buffer pre-allocation */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 1024 * 64, 32 * 1024 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 1024 * 64, 32 * 1024 * 1024); return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/lx6464es/lx6464es.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index d0f63fa54121..a74d8eade3e2 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -342,23 +342,18 @@ static int lx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, int is_capture) { struct lx6464es *chip = snd_pcm_substream_chip(substream); - int err = 0;
dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n");
mutex_lock(&chip->setup_mutex);
- /* set dma buffer */ - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (is_capture) chip->capture_stream.stream = substream; else chip->playback_stream.stream = substream;
mutex_unlock(&chip->setup_mutex); - return err; + return 0; }
static int lx_pcm_hw_params_playback(struct snd_pcm_substream *substream, @@ -400,8 +395,6 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream) chip->hardware_running[is_capture] = 0; }
- err = snd_pcm_lib_free_pages(substream); - if (is_capture) chip->capture_stream.stream = NULL; else @@ -845,9 +838,8 @@ static int lx_pcm_create(struct lx6464es *chip) pcm->nonatomic = true; strcpy(pcm->name, card_name);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - size, size); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, size, size);
chip->pcm = pcm; chip->capture_stream.is_capture = 1;
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/maestro3.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index cc8594d76c70..f4076e2a6400 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -1381,10 +1381,7 @@ static int snd_m3_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct m3_dma *s = substream->runtime->private_data; - int err;
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; /* set buffer address */ s->buffer_addr = substream->runtime->dma_addr; if (s->buffer_addr & 0x3) { @@ -1401,7 +1398,6 @@ static int snd_m3_pcm_hw_free(struct snd_pcm_substream *substream) if (substream->runtime->private_data == NULL) return 0; s = substream->runtime->private_data; - snd_pcm_lib_free_pages(substream); s->buffer_addr = 0; return 0; } @@ -1860,9 +1856,8 @@ snd_m3_pcm(struct snd_m3 * chip, int device) strcpy(pcm->name, chip->card->driver); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 64*1024);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/mixart/mixart.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 674d37ec96b3..79a57f3761c5 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -624,10 +624,7 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs, return err; }
- /* allocate buffer */ - err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); - - if (err > 0) { + if (subs->runtime->buffer_changed) { struct mixart_bufferinfo *bufferinfo; int i = (chip->chip_idx * MIXART_MAX_STREAM_PER_CARD) + (stream->pcm_number * (MIXART_PLAYBACK_STREAMS+MIXART_CAPTURE_STREAMS)) + subs->number; if( subs->stream == SNDRV_PCM_STREAM_CAPTURE ) { @@ -647,13 +644,12 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs, } mutex_unlock(&mgr->setup_mutex);
- return err; + return 0; }
static int snd_mixart_hw_free(struct snd_pcm_substream *subs) { struct snd_mixart *chip = snd_pcm_substream_chip(subs); - snd_pcm_lib_free_pages(subs); mixart_sync_nonblock_events(chip->mgr); return 0; } @@ -947,9 +943,9 @@ static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm) (chip->chip_idx + 1) << 24; } #endif - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->mgr->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->mgr->pci->dev, + 32*1024, 32*1024); }
/*
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/oxygen/oxygen_pcm.c | 52 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 203c8fe48a01..4c2bf6952e21 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -304,12 +304,6 @@ static int oxygen_hw_params(struct snd_pcm_substream *substream, { struct oxygen *chip = snd_pcm_substream_chip(substream); unsigned int channel = oxygen_substream_channel(substream); - int err; - - err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err;
oxygen_write32(chip, channel_base_registers[channel], (u32)substream->runtime->dma_addr); @@ -529,7 +523,7 @@ static int oxygen_hw_free(struct snd_pcm_substream *substream) oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask); spin_unlock_irq(&chip->reg_lock);
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream) @@ -711,17 +705,17 @@ int oxygen_pcm_init(struct oxygen *chip) pcm->private_data = chip; strcpy(pcm->name, "Multichannel"); if (outs) - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES_MULTICH, - BUFFER_BYTES_MAX_MULTICH); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES_MULTICH, + BUFFER_BYTES_MAX_MULTICH); if (ins) - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); }
outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF); @@ -738,10 +732,10 @@ int oxygen_pcm_init(struct oxygen *chip) &oxygen_rec_c_ops); pcm->private_data = chip; strcpy(pcm->name, "Digital"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); }
if (chip->has_ac97_1) { @@ -768,10 +762,10 @@ int oxygen_pcm_init(struct oxygen *chip) &oxygen_rec_b_ops); pcm->private_data = chip; strcpy(pcm->name, outs ? "Front Panel" : "Analog 2"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); }
ins = !!(chip->model.device_config & CAPTURE_3_FROM_I2S_3); @@ -786,10 +780,10 @@ int oxygen_pcm_init(struct oxygen *chip) OXYGEN_REC_C_ROUTE_MASK); pcm->private_data = chip; strcpy(pcm->name, "Analog 3"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - DEFAULT_BUFFER_BYTES, - BUFFER_BYTES_MAX); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + DEFAULT_BUFFER_BYTES, + BUFFER_BYTES_MAX); } return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/pcxhr/pcxhr.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 4af34d6d92df..72c0d1552f30 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -940,32 +940,16 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs, struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); struct pcxhr_mgr *mgr = chip->mgr; struct pcxhr_stream *stream = subs->runtime->private_data; - snd_pcm_format_t format; - int err; - int channels; - - /* set up channels */ - channels = params_channels(hw); - - /* set up format for the stream */ - format = params_format(hw);
mutex_lock(&mgr->setup_mutex);
- stream->channels = channels; - stream->format = format; - - /* allocate buffer */ - err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); + /* set up channels */ + stream->channels = params_channels(hw); + /* set up format for the stream */ + stream->format = params_format(hw);
mutex_unlock(&mgr->setup_mutex);
- return err; -} - -static int pcxhr_hw_free(struct snd_pcm_substream *subs) -{ - snd_pcm_lib_free_pages(subs); return 0; }
@@ -1139,7 +1123,6 @@ static const struct snd_pcm_ops pcxhr_ops = { .ioctl = snd_pcm_lib_ioctl, .prepare = pcxhr_prepare, .hw_params = pcxhr_hw_params, - .hw_free = pcxhr_hw_free, .trigger = pcxhr_trigger, .pointer = pcxhr_stream_pointer, }; @@ -1170,9 +1153,9 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip) pcm->nonatomic = true; strcpy(pcm->name, name);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->mgr->pci->dev, - 32*1024, 32*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->mgr->pci->dev, + 32*1024, 32*1024); chip->pcm = pcm; return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/riptide/riptide.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index abcea86045ec..b855de52e198 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1558,8 +1558,7 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream, return err; } data->sgdbuf = (struct sgd *)sgdlist->area; - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return 0; }
static int snd_riptide_hw_free(struct snd_pcm_substream *substream) @@ -1581,7 +1580,7 @@ static int snd_riptide_hw_free(struct snd_pcm_substream *substream) data->sgdlist.area = NULL; } } - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_riptide_playback_open(struct snd_pcm_substream *substream) @@ -1692,9 +1691,8 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device) pcm->info_flags = 0; strcpy(pcm->name, "RIPTIDE"); chip->pcm = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, 64 * 1024, 128 * 1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/rme32.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 58a4b8df25d4..aab47e5d96dc 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -662,11 +662,7 @@ snd_rme32_playback_hw_params(struct snd_pcm_substream *substream, struct rme32 *rme32 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- if (rme32->fullduplex_mode) { - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - } else { + if (!rme32->fullduplex_mode) { runtime->dma_area = (void __force *)(rme32->iobase + RME32_IO_DATA_BUFFER); runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; @@ -717,11 +713,7 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, struct rme32 *rme32 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- if (rme32->fullduplex_mode) { - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); - if (err < 0) - return err; - } else { + if (!rme32->fullduplex_mode) { runtime->dma_area = (void __force *)rme32->iobase + RME32_IO_DATA_BUFFER; runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER; @@ -771,14 +763,6 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, return 0; }
-static int snd_rme32_pcm_hw_free(struct snd_pcm_substream *substream) -{ - struct rme32 *rme32 = snd_pcm_substream_chip(substream); - if (! rme32->fullduplex_mode) - return 0; - return snd_pcm_lib_free_pages(substream); -} - static void snd_rme32_pcm_start(struct rme32 * rme32, int from_pause) { if (!from_pause) { @@ -1195,7 +1179,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_ops = { .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_playback_pointer, @@ -1210,7 +1193,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_ops = { .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_pointer, @@ -1252,7 +1234,6 @@ static const struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops = { .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_playback_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_playback_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_playback_fd_pointer, @@ -1264,7 +1245,6 @@ static const struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops = { .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_rme32_capture_hw_params, - .hw_free = snd_rme32_pcm_hw_free, .prepare = snd_rme32_capture_prepare, .trigger = snd_rme32_pcm_trigger, .pointer = snd_rme32_capture_fd_pointer, @@ -1374,9 +1354,8 @@ static int snd_rme32_create(struct rme32 *rme32) &snd_rme32_playback_spdif_fd_ops); snd_pcm_set_ops(rme32->spdif_pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_rme32_capture_spdif_fd_ops); - snd_pcm_lib_preallocate_pages_for_all(rme32->spdif_pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 0, RME32_MID_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(rme32->spdif_pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 0, RME32_MID_BUFFER_SIZE); rme32->spdif_pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; } else { snd_pcm_set_ops(rme32->spdif_pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -1406,9 +1385,9 @@ static int snd_rme32_create(struct rme32 *rme32) &snd_rme32_playback_adat_fd_ops); snd_pcm_set_ops(rme32->adat_pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_rme32_capture_adat_fd_ops); - snd_pcm_lib_preallocate_pages_for_all(rme32->adat_pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 0, RME32_MID_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(rme32->adat_pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 0, RME32_MID_BUFFER_SIZE); rme32->adat_pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; } else { snd_pcm_set_ops(rme32->adat_pcm, SNDRV_PCM_STREAM_PLAYBACK,
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/sis7019.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index ef7dd290ae05..4639bc21b42d 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -499,18 +499,6 @@ static int sis_substream_close(struct snd_pcm_substream *substream) return 0; }
-static int sis_playback_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 sis_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int sis_pcm_playback_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -701,11 +689,6 @@ static int sis_capture_hw_params(struct snd_pcm_substream *substream, if (rc) goto out;
- rc = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (rc < 0) - goto out; - rc = sis_alloc_timing_voice(substream, hw_params);
out: @@ -864,8 +847,6 @@ static const struct snd_pcm_ops sis_playback_ops = { .open = sis_playback_open, .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = sis_playback_hw_params, - .hw_free = sis_hw_free, .prepare = sis_pcm_playback_prepare, .trigger = sis_pcm_trigger, .pointer = sis_pcm_pointer, @@ -876,7 +857,6 @@ static const struct snd_pcm_ops sis_capture_ops = { .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = sis_capture_hw_params, - .hw_free = sis_hw_free, .prepare = sis_pcm_capture_prepare, .trigger = sis_pcm_trigger, .pointer = sis_pcm_pointer, @@ -904,9 +884,8 @@ static int sis_pcm_create(struct sis7019 *sis) /* Try to preallocate some memory, but it's not the end of the * world if this fails. */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &sis->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &sis->pci->dev, 64*1024, 128*1024);
return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/sonicvibes.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 31cbc811ad37..e117d8450b2d 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -681,17 +681,6 @@ static int snd_sonicvibes_capture_trigger(struct snd_pcm_substream *substream, return snd_sonicvibes_trigger(sonic, 2, cmd); }
-static int snd_sonicvibes_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_sonicvibes_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_sonicvibes_playback_prepare(struct snd_pcm_substream *substream) { struct sonicvibes *sonic = snd_pcm_substream_chip(substream); @@ -847,8 +836,6 @@ static const struct snd_pcm_ops snd_sonicvibes_playback_ops = { .open = snd_sonicvibes_playback_open, .close = snd_sonicvibes_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sonicvibes_hw_params, - .hw_free = snd_sonicvibes_hw_free, .prepare = snd_sonicvibes_playback_prepare, .trigger = snd_sonicvibes_playback_trigger, .pointer = snd_sonicvibes_playback_pointer, @@ -858,8 +845,6 @@ static const struct snd_pcm_ops snd_sonicvibes_capture_ops = { .open = snd_sonicvibes_capture_open, .close = snd_sonicvibes_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sonicvibes_hw_params, - .hw_free = snd_sonicvibes_hw_free, .prepare = snd_sonicvibes_capture_prepare, .trigger = snd_sonicvibes_capture_trigger, .pointer = snd_sonicvibes_capture_pointer, @@ -883,9 +868,8 @@ static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device) strcpy(pcm->name, "S3 SonicVibes"); sonic->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &sonic->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &sonic->pci->dev, 64*1024, 128*1024);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/trident/trident_main.c | 49 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 07022c0dad40..93789069e78f 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -808,12 +808,9 @@ static int snd_trident_allocate_pcm_mem(struct snd_pcm_substream *substream, struct snd_trident *trident = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_trident_voice *voice = runtime->private_data; - int err;
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; if (trident->tlb.entries) { - if (err > 0) { /* change */ + if (runtime->buffer_changed) { if (voice->memblk) snd_trident_free_pages(trident, voice->memblk); voice->memblk = snd_trident_alloc_pages(trident, substream); @@ -911,7 +908,6 @@ static int snd_trident_hw_free(struct snd_pcm_substream *substream) voice->memblk = NULL; } } - snd_pcm_lib_free_pages(substream); if (evoice != NULL) { snd_trident_free_voice(trident, evoice); voice->extra = NULL; @@ -1128,11 +1124,6 @@ static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) static int snd_trident_si7018_capture_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - int err; - - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; - return snd_trident_allocate_evoice(substream, hw_params); }
@@ -1154,7 +1145,6 @@ static int snd_trident_si7018_capture_hw_free(struct snd_pcm_substream *substrea struct snd_trident_voice *voice = runtime->private_data; struct snd_trident_voice *evoice = voice ? voice->extra : NULL;
- snd_pcm_lib_free_pages(substream); if (evoice != NULL) { snd_trident_free_voice(trident, evoice); voice->extra = NULL; @@ -2183,17 +2173,17 @@ int snd_trident_pcm(struct snd_trident *trident, int device) if (trident->tlb.entries) { struct snd_pcm_substream *substream; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) - snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, - &trident->pci->dev, - 64*1024, 128*1024); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV_SG, + &trident->pci->dev, + 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024); } else { - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024); }
return 0; @@ -2242,13 +2232,13 @@ int snd_trident_foldback_pcm(struct snd_trident *trident, int device) trident->foldback = foldback;
if (trident->tlb.entries) - snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV_SG, - &trident->pci->dev, - 0, 128*1024); + snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV_SG, + &trident->pci->dev, + 0, 128*1024); else - snd_pcm_lib_preallocate_pages_for_all(foldback, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(foldback, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, + 64*1024, 128*1024);
return 0; } @@ -2282,9 +2272,8 @@ int snd_trident_spdif_pcm(struct snd_trident *trident, int device) strcpy(spdif->name, "Trident 4DWave IEC958"); trident->spdif = spdif;
- snd_pcm_lib_preallocate_pages_for_all(spdif, SNDRV_DMA_TYPE_DEV, - &trident->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(spdif, SNDRV_DMA_TYPE_DEV, + &trident->pci->dev, 64*1024, 128*1024);
return 0; }
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/via82xx.c | 45 ++++++++++++++++++--------------------------- sound/pci/via82xx_modem.c | 9 ++------- 2 files changed, 20 insertions(+), 34 deletions(-)
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 30c817b6b635..d116f32096c1 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -919,18 +919,10 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, { struct via82xx *chip = snd_pcm_substream_chip(substream); struct viadev *viadev = substream->runtime->private_data; - int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; - err = build_via_table(viadev, substream, chip->pci, - params_periods(hw_params), - params_period_bytes(hw_params)); - if (err < 0) - return err; - - return 0; + return build_via_table(viadev, substream, chip->pci, + params_periods(hw_params), + params_period_bytes(hw_params)); }
/* @@ -943,7 +935,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) struct viadev *viadev = substream->runtime->private_data;
clean_via_table(viadev, substream, chip->pci); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -1453,9 +1444,9 @@ static int snd_via8233_pcm_new(struct via82xx *chip) /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE);
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, @@ -1477,9 +1468,9 @@ static int snd_via8233_pcm_new(struct via82xx *chip) /* set up capture */ init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE);
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, 6, 0, @@ -1520,9 +1511,9 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) /* capture */ init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE);
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_alt_chmaps, 6, 0, @@ -1546,9 +1537,9 @@ static int snd_via8233a_pcm_new(struct via82xx *chip) /* set up playback */ init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); return 0; }
@@ -1576,9 +1567,9 @@ static int snd_via686_pcm_new(struct via82xx *chip) init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, VIA_MAX_BUFSIZE); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, + 64*1024, VIA_MAX_BUFSIZE); return 0; }
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 0edb9ea6e8a6..22eaa9216598 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -642,9 +642,6 @@ static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, struct viadev *viadev = substream->runtime->private_data; int err;
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); - if (err < 0) - return err; err = build_via_table(viadev, substream, chip->pci, params_periods(hw_params), params_period_bytes(hw_params)); @@ -667,7 +664,6 @@ static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) struct viadev *viadev = substream->runtime->private_data;
clean_via_table(viadev, substream, chip->pci); - snd_pcm_lib_free_pages(substream); return 0; }
@@ -849,9 +845,8 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip) init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - &chip->pci->dev, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG, + &chip->pci->dev, 64*1024, 128*1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pci/ymfpci/ymfpci_main.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 125c11ed5064..748bbdcb2c52 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -628,8 +628,6 @@ static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream, struct snd_ymfpci_pcm *ypcm = runtime->private_data; int err;
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) - return err; if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0) return err; return 0; @@ -647,7 +645,6 @@ static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream)
/* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); - snd_pcm_lib_free_pages(substream); if (ypcm->voices[1]) { snd_ymfpci_voice_free(chip, ypcm->voices[1]); ypcm->voices[1] = NULL; @@ -683,19 +680,13 @@ static int snd_ymfpci_playback_prepare(struct snd_pcm_substream *substream) return 0; }
-static int snd_ymfpci_capture_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_ymfpci_capture_hw_free(struct snd_pcm_substream *substream) { struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
/* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_ymfpci_capture_prepare(struct snd_pcm_substream *substream) @@ -1124,7 +1115,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { .open = snd_ymfpci_capture_rec_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ymfpci_capture_hw_params, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1148,9 +1138,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI"); chip->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, NULL); @@ -1160,7 +1149,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { .open = snd_ymfpci_capture_ac97_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ymfpci_capture_hw_params, .hw_free = snd_ymfpci_capture_hw_free, .prepare = snd_ymfpci_capture_prepare, .trigger = snd_ymfpci_capture_trigger, @@ -1184,9 +1172,8 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) chip->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97"); chip->pcm2 = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024);
return 0; } @@ -1218,9 +1205,8 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI - IEC958"); chip->pcm_spdif = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024);
return 0; } @@ -1260,9 +1246,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) strcpy(pcm->name, "YMFPCI - Rear PCM"); chip->pcm_4ch = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - 64*1024, 256*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, 64*1024, 256*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, surround_map, 2, 0, NULL);
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index 067b1c3a3e02..a4be4d1b0f7d 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -83,23 +83,6 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd) return ret; }
-/* - * pdacf_pcm_hw_params - hw_params callback for playback and capture - */ -static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * pdacf_pcm_hw_free - hw_free callback for playback and capture - */ -static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) -{ - return snd_pcm_lib_free_pages(subs); -} - /* * pdacf_pcm_prepare - prepare callback for playback and capture */ @@ -256,8 +239,6 @@ static const struct snd_pcm_ops pdacf_pcm_capture_ops = { .open = pdacf_pcm_capture_open, .close = pdacf_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = pdacf_pcm_hw_params, - .hw_free = pdacf_pcm_hw_free, .prepare = pdacf_pcm_prepare, .trigger = pdacf_pcm_trigger, .pointer = pdacf_pcm_capture_pointer, @@ -277,9 +258,9 @@ int snd_pdacf_pcm_new(struct snd_pdacf *chip) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pdacf_pcm_capture_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), - 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + snd_dma_continuous_data(GFP_KERNEL | GFP_DMA32), + 0, 0);
pcm->private_data = chip; pcm->info_flags = 0;
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/ppc/pmac.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 1b11e53f6a62..1629f91d7ae2 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -107,24 +107,6 @@ static inline int another_stream(int stream) SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; }
-/* - * allocate buffers - */ -static int snd_pmac_pcm_hw_params(struct snd_pcm_substream *subs, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); -} - -/* - * release buffers - */ -static int snd_pmac_pcm_hw_free(struct snd_pcm_substream *subs) -{ - snd_pcm_lib_free_pages(subs); - return 0; -} - /* * get a stream of the opposite direction */ @@ -672,8 +654,6 @@ static const struct snd_pcm_ops snd_pmac_playback_ops = { .open = snd_pmac_playback_open, .close = snd_pmac_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_pmac_pcm_hw_params, - .hw_free = snd_pmac_pcm_hw_free, .prepare = snd_pmac_playback_prepare, .trigger = snd_pmac_playback_trigger, .pointer = snd_pmac_playback_pointer, @@ -683,8 +663,6 @@ static const struct snd_pcm_ops snd_pmac_capture_ops = { .open = snd_pmac_capture_open, .close = snd_pmac_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_pmac_pcm_hw_params, - .hw_free = snd_pmac_pcm_hw_free, .prepare = snd_pmac_capture_prepare, .trigger = snd_pmac_capture_trigger, .pointer = snd_pmac_capture_pointer, @@ -721,9 +699,9 @@ int snd_pmac_pcm_new(struct snd_pmac *chip) chip->capture.cur_freqs = chip->freqs_ok;
/* preallocate 64k buffer */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->pdev->dev, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->pdev->dev, + 64 * 1024, 64 * 1024);
return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/ppc/snd_ps3.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-)
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index c213eb7ca23c..c6c004958e6f 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -535,22 +535,6 @@ static int snd_ps3_pcm_close(struct snd_pcm_substream *substream) return 0; };
-static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - size_t size; - - /* alloc transport buffer */ - size = params_buffer_bytes(hw_params); - snd_pcm_lib_malloc_pages(substream, size); - return 0; -}; - -static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -}; - static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream, unsigned int delay_ms) { @@ -759,8 +743,6 @@ static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { .open = snd_ps3_pcm_open, .close = snd_ps3_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_ps3_pcm_hw_params, - .hw_free = snd_ps3_pcm_hw_free, .prepare = snd_ps3_pcm_prepare, .trigger = snd_ps3_pcm_trigger, .pointer = snd_ps3_pcm_pointer, @@ -1007,11 +989,11 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; /* pre-alloc PCM DMA buffer*/ - snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, - SNDRV_DMA_TYPE_DEV, - &dev->core, - SND_PS3_PCM_PREALLOC_SIZE, - SND_PS3_PCM_PREALLOC_SIZE); + snd_pcm_set_managed_buffer_all(the_card.pcm, + SNDRV_DMA_TYPE_DEV, + &dev->core, + SND_PS3_PCM_PREALLOC_SIZE, + SND_PS3_PCM_PREALLOC_SIZE);
/* * allocate null buffer
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/sh/aica.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/sound/sh/aica.c b/sound/sh/aica.c index bf1fb0d8a930..8ff88d71439e 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -363,23 +363,6 @@ static int snd_aicapcm_pcm_close(struct snd_pcm_substream return 0; }
-static int snd_aicapcm_pcm_hw_free(struct snd_pcm_substream - *substream) -{ - /* Free the DMA buffer */ - return snd_pcm_lib_free_pages(substream); -} - -static int snd_aicapcm_pcm_hw_params(struct snd_pcm_substream - *substream, struct snd_pcm_hw_params - *hw_params) -{ - /* Allocate a DMA buffer using ALSA built-ins */ - return - snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - static int snd_aicapcm_pcm_prepare(struct snd_pcm_substream *substream) { @@ -417,8 +400,6 @@ static const struct snd_pcm_ops snd_aicapcm_playback_ops = { .open = snd_aicapcm_pcm_open, .close = snd_aicapcm_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_aicapcm_pcm_hw_params, - .hw_free = snd_aicapcm_pcm_hw_free, .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, @@ -441,11 +422,11 @@ static int __init snd_aicapcmchip(struct snd_card_aica snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_aicapcm_playback_ops); /* Allocate the DMA buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - AICA_BUFFER_SIZE, - AICA_BUFFER_SIZE); + snd_pcm_set_managed_buffer_all(pcm, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + AICA_BUFFER_SIZE, + AICA_BUFFER_SIZE); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/sh/sh_dac_audio.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index f9e36abc98ac..1406b50f3f78 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -125,18 +125,6 @@ static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream) return 0; }
-static int snd_sh_dac_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)); -} - -static int snd_sh_dac_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); @@ -241,8 +229,6 @@ static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { .open = snd_sh_dac_pcm_open, .close = snd_sh_dac_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_sh_dac_pcm_hw_params, - .hw_free = snd_sh_dac_pcm_hw_free, .prepare = snd_sh_dac_pcm_prepare, .trigger = snd_sh_dac_pcm_trigger, .pointer = snd_sh_dac_pcm_pointer, @@ -267,10 +253,8 @@ static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops);
/* buffer size=48K */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 48 * 1024, - 48 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 48 * 1024, 48 * 1024);
return 0; }
Clean up the drivers with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/sparc/amd7930.c | 20 ++------------------ sound/sparc/cs4231.c | 17 ++--------------- sound/sparc/dbri.c | 13 +++---------- 3 files changed, 7 insertions(+), 43 deletions(-)
diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index d4b8ccc61dc2..d39973605cca 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -723,23 +723,10 @@ static int snd_amd7930_capture_close(struct snd_pcm_substream *substream) return 0; }
-static int snd_amd7930_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_amd7930_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - static const struct snd_pcm_ops snd_amd7930_playback_ops = { .open = snd_amd7930_playback_open, .close = snd_amd7930_playback_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_amd7930_hw_params, - .hw_free = snd_amd7930_hw_free, .prepare = snd_amd7930_playback_prepare, .trigger = snd_amd7930_playback_trigger, .pointer = snd_amd7930_playback_pointer, @@ -749,8 +736,6 @@ static const struct snd_pcm_ops snd_amd7930_capture_ops = { .open = snd_amd7930_capture_open, .close = snd_amd7930_capture_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_amd7930_hw_params, - .hw_free = snd_amd7930_hw_free, .prepare = snd_amd7930_capture_prepare, .trigger = snd_amd7930_capture_trigger, .pointer = snd_amd7930_capture_pointer, @@ -776,9 +761,8 @@ static int snd_amd7930_pcm(struct snd_amd7930 *amd) strcpy(pcm->name, amd->card->shortname); amd->pcm = pcm;
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 64*1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64*1024, 64*1024);
return 0; } diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 138841e0f2ae..874da942b662 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -889,12 +889,7 @@ static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; - int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_cs4231_get_rate(params_rate(hw_params)); @@ -933,12 +928,7 @@ static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, { struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; - int err;
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) - return err; new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), params_channels(hw_params)) | snd_cs4231_get_rate(params_rate(hw_params)); @@ -1205,7 +1195,6 @@ static const struct snd_pcm_ops snd_cs4231_playback_ops = { .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_playback_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = snd_cs4231_playback_prepare, .trigger = snd_cs4231_trigger, .pointer = snd_cs4231_playback_pointer, @@ -1216,7 +1205,6 @@ static const struct snd_pcm_ops snd_cs4231_capture_ops = { .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_cs4231_capture_hw_params, - .hw_free = snd_pcm_lib_free_pages, .prepare = snd_cs4231_capture_prepare, .trigger = snd_cs4231_trigger, .pointer = snd_cs4231_capture_pointer, @@ -1242,9 +1230,8 @@ static int snd_cs4231_pcm(struct snd_card *card) pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, "CS4231");
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - &chip->op->dev, - 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, + &chip->op->dev, 64 * 1024, 128 * 1024);
chip->pcm = pcm;
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 4911103421ff..315d5a04a33e 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2099,12 +2099,6 @@ static int snd_dbri_hw_params(struct snd_pcm_substream *substream, if (ret != 0) return ret;
- if ((ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params))) < 0) { - printk(KERN_ERR "malloc_pages failed with %d\n", ret); - return ret; - } - /* hw_params can get called multiple times. Only map the DMA once. */ if (info->dvma_buffer == 0) { @@ -2151,7 +2145,7 @@ static int snd_dbri_hw_free(struct snd_pcm_substream *substream) info->pipe = -1; }
- return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_dbri_prepare(struct snd_pcm_substream *substream) @@ -2248,9 +2242,8 @@ static int snd_dbri_pcm(struct snd_card *card) pcm->info_flags = 0; strcpy(pcm->name, card->shortname);
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64 * 1024, 64 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64 * 1024, 64 * 1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/spi/at73c213.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 4de1ba9a418d..8b1b5c86cebf 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -242,13 +242,7 @@ static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream, val = SSC_BFINS(TFMR_DATNB, channels - 1, val); ssc_writel(chip->ssc->regs, TFMR, val);
- return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int snd_at73c213_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return 0; }
static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream) @@ -324,7 +318,6 @@ static const struct snd_pcm_ops at73c213_playback_ops = { .close = snd_at73c213_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_at73c213_pcm_hw_params, - .hw_free = snd_at73c213_pcm_hw_free, .prepare = snd_at73c213_pcm_prepare, .trigger = snd_at73c213_pcm_trigger, .pointer = snd_at73c213_pcm_pointer, @@ -347,7 +340,7 @@ static int snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops);
- snd_pcm_lib_preallocate_pages_for_all(chip->pcm, + snd_pcm_set_managed_buffer_all(chip->pcm, SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, 64 * 1024, 64 * 1024); out:
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/6fire/pcm.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index cdc5dd7fbe16..706aa3fac351 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c @@ -446,18 +446,6 @@ static int usb6fire_pcm_close(struct snd_pcm_substream *alsa_sub) return 0; }
-static int usb6fire_pcm_hw_params(struct snd_pcm_substream *alsa_sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(alsa_sub, - params_buffer_bytes(hw_params)); -} - -static int usb6fire_pcm_hw_free(struct snd_pcm_substream *alsa_sub) -{ - return snd_pcm_lib_free_pages(alsa_sub); -} - static int usb6fire_pcm_prepare(struct snd_pcm_substream *alsa_sub) { struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); @@ -555,8 +543,6 @@ static const struct snd_pcm_ops pcm_ops = { .open = usb6fire_pcm_open, .close = usb6fire_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = usb6fire_pcm_hw_params, - .hw_free = usb6fire_pcm_hw_free, .prepare = usb6fire_pcm_prepare, .trigger = usb6fire_pcm_trigger, .pointer = usb6fire_pcm_pointer, @@ -658,8 +644,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip) strcpy(pcm->name, "DMX 6Fire USB"); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
rt->instance = pcm;
Clean up the driver with the new managed buffer allocation API. The hw_params callback became superfluous and dropped. The hw_free callback still remains because of the substream deactivation sync call.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/caiaq/audio.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 970eb0865ba3..8513b120e57e 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -167,17 +167,11 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) return 0; }
-static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); -} - static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) { struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); deactivate_substream(cdev, sub); - return snd_pcm_lib_free_pages(sub); + return 0; }
/* this should probably go upstream */ @@ -328,7 +322,6 @@ static const struct snd_pcm_ops snd_usb_caiaq_ops = { .open = snd_usb_caiaq_substream_open, .close = snd_usb_caiaq_substream_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_usb_caiaq_pcm_hw_params, .hw_free = snd_usb_caiaq_pcm_hw_free, .prepare = snd_usb_caiaq_pcm_prepare, .trigger = snd_usb_caiaq_pcm_trigger, @@ -841,8 +834,8 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) &snd_usb_caiaq_ops); snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usb_caiaq_ops); - snd_pcm_lib_preallocate_pages_for_all(cdev->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(cdev->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0);
cdev->data_cb_info = kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info),
Clean up the driver with the new managed buffer allocation API. The hw_params and hw_free callbacks became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/hiface/pcm.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index e0de71917274..cc0639a1b419 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -415,18 +415,6 @@ static int hiface_pcm_close(struct snd_pcm_substream *alsa_sub) return 0; }
-static int hiface_pcm_hw_params(struct snd_pcm_substream *alsa_sub, - struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(alsa_sub, - params_buffer_bytes(hw_params)); -} - -static int hiface_pcm_hw_free(struct snd_pcm_substream *alsa_sub) -{ - return snd_pcm_lib_free_pages(alsa_sub); -} - static int hiface_pcm_prepare(struct snd_pcm_substream *alsa_sub) { struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); @@ -513,8 +501,6 @@ static const struct snd_pcm_ops pcm_ops = { .open = hiface_pcm_open, .close = hiface_pcm_close, .ioctl = snd_pcm_lib_ioctl, - .hw_params = hiface_pcm_hw_params, - .hw_free = hiface_pcm_hw_free, .prepare = hiface_pcm_prepare, .trigger = hiface_pcm_trigger, .pointer = hiface_pcm_pointer, @@ -613,8 +599,8 @@ int hiface_pcm_init(struct hiface_chip *chip, u8 extra_freq)
strlcpy(pcm->name, "USB-SPDIF Audio", sizeof(pcm->name)); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0);
rt->instance = pcm;
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/line6/pcm.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index 9c437c716cfd..fdbdfb7bce92 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -359,13 +359,6 @@ int snd_line6_hw_params(struct snd_pcm_substream *substream, if (ret < 0) goto error;
- ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) { - line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM); - goto error; - } - pstr->period = params_period_bytes(hw_params); error: mutex_unlock(&line6pcm->state_mutex); @@ -381,7 +374,7 @@ int snd_line6_hw_free(struct snd_pcm_substream *substream) mutex_lock(&line6pcm->state_mutex); line6_buffer_release(line6pcm, pstr, LINE6_STREAM_PCM); mutex_unlock(&line6pcm->state_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; }
@@ -501,8 +494,8 @@ static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_line6_capture_ops);
/* pre-allocation of buffers */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 64 * 1024, 128 * 1024); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, + NULL, 64 * 1024, 128 * 1024); return 0; }
Clean up the driver with the new managed buffer allocation API. The hw_free callback became superfluous and got dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/misc/ua101.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index 566a4a31528a..a7b68447f3ad 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -730,11 +730,7 @@ static int capture_pcm_hw_params(struct snd_pcm_substream *substream, mutex_lock(&ua->mutex); err = start_usb_capture(ua); mutex_unlock(&ua->mutex); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + return err; }
static int playback_pcm_hw_params(struct snd_pcm_substream *substream, @@ -748,16 +744,7 @@ static int playback_pcm_hw_params(struct snd_pcm_substream *substream, if (err >= 0) err = start_usb_playback(ua); mutex_unlock(&ua->mutex); - if (err < 0) - return err; - - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); -} - -static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); + return err; }
static int capture_pcm_prepare(struct snd_pcm_substream *substream) @@ -885,7 +872,6 @@ static const struct snd_pcm_ops capture_pcm_ops = { .close = capture_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = capture_pcm_hw_params, - .hw_free = ua101_pcm_hw_free, .prepare = capture_pcm_prepare, .trigger = capture_pcm_trigger, .pointer = capture_pcm_pointer, @@ -896,7 +882,6 @@ static const struct snd_pcm_ops playback_pcm_ops = { .close = playback_pcm_close, .ioctl = snd_pcm_lib_ioctl, .hw_params = playback_pcm_hw_params, - .hw_free = ua101_pcm_hw_free, .prepare = playback_pcm_prepare, .trigger = playback_pcm_trigger, .pointer = playback_pcm_pointer, @@ -1294,8 +1279,8 @@ static int ua101_probe(struct usb_interface *interface, strcpy(ua->pcm->name, name); snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); - snd_pcm_lib_preallocate_pages_for_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0);
err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], &ua->midi_list, &midi_quirk);
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/usx2y/usbusx2yaudio.c | 26 +++++++++----------------- sound/usb/usx2y/usx2yhwdeppcm.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 25a0939f410a..7eb9805a4326 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -764,14 +764,6 @@ static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream, } }
- err = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (err < 0) { - snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", - substream, params_buffer_bytes(hw_params), err); - goto error; - } - error: mutex_unlock(&usX2Y(card)->pcm_mutex); return err; @@ -806,7 +798,7 @@ static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream) } } mutex_unlock(&subs->usX2Y->pcm_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; } /* * prepare callback @@ -968,16 +960,16 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
if (playback_endpoint) { - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); }
- snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); usX2Y(card)->pcm_devs++;
return 0; diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 997493e839ee..419d9f07d197 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -376,7 +376,7 @@ static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream) } } mutex_unlock(&subs->usX2Y->pcm_mutex); - return snd_pcm_lib_free_pages(substream); + return 0; }
static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs) @@ -726,14 +726,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card) pcm->info_flags = 0;
sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); - snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024); + snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, + SNDRV_DMA_TYPE_CONTINUOUS, + NULL, + 64*1024, 128*1024);
return 0; }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/usb/pcm.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 9c8930bb00c8..7caaa04ae546 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -785,11 +785,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, if (ret) return ret;
- ret = snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); - if (ret < 0) - goto stop_pipeline; - subs->pcm_format = params_format(hw_params); subs->period_bytes = params_period_bytes(hw_params); subs->period_frames = params_period_size(hw_params); @@ -853,7 +848,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) snd_usb_unlock_shutdown(subs->stream->chip); }
- return snd_pcm_lib_free_pages(substream); + return 0; }
/* @@ -1803,9 +1798,9 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs) struct device *dev = subs->dev->bus->controller;
if (snd_usb_use_vmalloc) - snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_VMALLOC, - NULL, 0, 0); + snd_pcm_set_managed_buffer(s, SNDRV_DMA_TYPE_VMALLOC, + NULL, 0, 0); else - snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_DEV_SG, - dev, 64*1024, 512*1024); + snd_pcm_set_managed_buffer(s, SNDRV_DMA_TYPE_DEV_SG, + dev, 64*1024, 512*1024); }
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.
Signed-off-by: Takashi Iwai tiwai@suse.de --- sound/x86/intel_hdmi_audio.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c index cd389d21219a..a67692ca08af 100644 --- a/sound/x86/intel_hdmi_audio.c +++ b/sound/x86/intel_hdmi_audio.c @@ -1132,16 +1132,13 @@ static int had_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_intelhad *intelhaddata; - int buf_size, retval; + int buf_size;
intelhaddata = snd_pcm_substream_chip(substream); buf_size = params_buffer_bytes(hw_params); - retval = snd_pcm_lib_malloc_pages(substream, buf_size); - if (retval < 0) - return retval; dev_dbg(intelhaddata->dev, "%s:allocated memory = %d\n", __func__, buf_size); - return retval; + return 0; }
/* @@ -1154,7 +1151,7 @@ static int had_pcm_hw_free(struct snd_pcm_substream *substream) intelhaddata = snd_pcm_substream_chip(substream); had_do_reset(intelhaddata);
- return snd_pcm_lib_free_pages(substream); + return 0; }
/* @@ -1801,10 +1798,9 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) /* allocate dma pages; * try to allocate 600k buffer as default which is large enough */ - snd_pcm_lib_preallocate_pages_for_all(pcm, - SNDRV_DMA_TYPE_DEV_UC, - card->dev, - HAD_DEFAULT_BUFFER, HAD_MAX_BUFFER); + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_UC, + card->dev, HAD_DEFAULT_BUFFER, + HAD_MAX_BUFFER);
/* create controls */ for (i = 0; i < ARRAY_SIZE(had_controls); i++) {
participants (2)
-
Takashi Iwai
-
Takashi Sakamoto