Commit b6ed90c0 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: ymfpci: Use managed buffer allocation

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

Link: https://lore.kernel.org/r/20191209094943.14984-57-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8e2c7524
...@@ -628,8 +628,6 @@ static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream, ...@@ -628,8 +628,6 @@ static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream,
struct snd_ymfpci_pcm *ypcm = runtime->private_data; struct snd_ymfpci_pcm *ypcm = runtime->private_data;
int err; 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) if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0)
return err; return err;
return 0; return 0;
...@@ -647,7 +645,6 @@ static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream) ...@@ -647,7 +645,6 @@ static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream)
/* wait, until the PCI operations are not finished */ /* wait, until the PCI operations are not finished */
snd_ymfpci_irq_wait(chip); snd_ymfpci_irq_wait(chip);
snd_pcm_lib_free_pages(substream);
if (ypcm->voices[1]) { if (ypcm->voices[1]) {
snd_ymfpci_voice_free(chip, ypcm->voices[1]); snd_ymfpci_voice_free(chip, ypcm->voices[1]);
ypcm->voices[1] = NULL; ypcm->voices[1] = NULL;
...@@ -683,19 +680,13 @@ static int snd_ymfpci_playback_prepare(struct snd_pcm_substream *substream) ...@@ -683,19 +680,13 @@ static int snd_ymfpci_playback_prepare(struct snd_pcm_substream *substream)
return 0; 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) static int snd_ymfpci_capture_hw_free(struct snd_pcm_substream *substream)
{ {
struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); struct snd_ymfpci *chip = snd_pcm_substream_chip(substream);
/* wait, until the PCI operations are not finished */ /* wait, until the PCI operations are not finished */
snd_ymfpci_irq_wait(chip); 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) 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 = { ...@@ -1124,7 +1115,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = {
.open = snd_ymfpci_capture_rec_open, .open = snd_ymfpci_capture_rec_open,
.close = snd_ymfpci_capture_close, .close = snd_ymfpci_capture_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_ymfpci_capture_hw_params,
.hw_free = snd_ymfpci_capture_hw_free, .hw_free = snd_ymfpci_capture_hw_free,
.prepare = snd_ymfpci_capture_prepare, .prepare = snd_ymfpci_capture_prepare,
.trigger = snd_ymfpci_capture_trigger, .trigger = snd_ymfpci_capture_trigger,
...@@ -1148,9 +1138,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) ...@@ -1148,9 +1138,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device)
strcpy(pcm->name, "YMFPCI"); strcpy(pcm->name, "YMFPCI");
chip->pcm = pcm; chip->pcm = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
&chip->pci->dev, &chip->pci->dev, 64*1024, 256*1024);
64*1024, 256*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
snd_pcm_std_chmaps, 2, 0, NULL); snd_pcm_std_chmaps, 2, 0, NULL);
...@@ -1160,7 +1149,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { ...@@ -1160,7 +1149,6 @@ static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = {
.open = snd_ymfpci_capture_ac97_open, .open = snd_ymfpci_capture_ac97_open,
.close = snd_ymfpci_capture_close, .close = snd_ymfpci_capture_close,
.ioctl = snd_pcm_lib_ioctl, .ioctl = snd_pcm_lib_ioctl,
.hw_params = snd_ymfpci_capture_hw_params,
.hw_free = snd_ymfpci_capture_hw_free, .hw_free = snd_ymfpci_capture_hw_free,
.prepare = snd_ymfpci_capture_prepare, .prepare = snd_ymfpci_capture_prepare,
.trigger = snd_ymfpci_capture_trigger, .trigger = snd_ymfpci_capture_trigger,
...@@ -1184,9 +1172,8 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) ...@@ -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->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97");
chip->pcm2 = pcm; chip->pcm2 = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
&chip->pci->dev, &chip->pci->dev, 64*1024, 256*1024);
64*1024, 256*1024);
return 0; return 0;
} }
...@@ -1218,9 +1205,8 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) ...@@ -1218,9 +1205,8 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device)
strcpy(pcm->name, "YMFPCI - IEC958"); strcpy(pcm->name, "YMFPCI - IEC958");
chip->pcm_spdif = pcm; chip->pcm_spdif = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
&chip->pci->dev, &chip->pci->dev, 64*1024, 256*1024);
64*1024, 256*1024);
return 0; return 0;
} }
...@@ -1260,9 +1246,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) ...@@ -1260,9 +1246,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device)
strcpy(pcm->name, "YMFPCI - Rear PCM"); strcpy(pcm->name, "YMFPCI - Rear PCM");
chip->pcm_4ch = pcm; chip->pcm_4ch = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
&chip->pci->dev, &chip->pci->dev, 64*1024, 256*1024);
64*1024, 256*1024);
return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
surround_map, 2, 0, NULL); surround_map, 2, 0, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment