Skip to content

Commit b315997

Browse files
committed
ALSA: usb-audio: Convert to the common vmalloc memalloc
The recent change (*) in the ALSA memalloc core allows us to drop the special vmalloc-specific allocation and page handling. This patch coverts to the common code. (*) 1fe7f39: ALSA: memalloc: Add vmalloc buffer allocation support 7e8edae: ALSA: pcm: Handle special page mapping in the default mmap handler Also, since the SG-buffer-specific PCM ops becomes identical with the normal PCM ops, unify them again to the single ops, too. Link: https://lore.kernel.org/r/20191105151856.10785-9-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 1158e89 commit b315997

1 file changed

Lines changed: 8 additions & 42 deletions

File tree

‎sound/usb/pcm.c‎

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
785785
if (ret)
786786
return ret;
787787

788-
if (snd_usb_use_vmalloc)
789-
ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
790-
params_buffer_bytes(hw_params));
791-
else
792-
ret = snd_pcm_lib_malloc_pages(substream,
793-
params_buffer_bytes(hw_params));
788+
ret = snd_pcm_lib_malloc_pages(substream,
789+
params_buffer_bytes(hw_params));
794790
if (ret < 0)
795791
goto stop_pipeline;
796792

@@ -857,10 +853,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
857853
snd_usb_unlock_shutdown(subs->stream->chip);
858854
}
859855

860-
if (snd_usb_use_vmalloc)
861-
return snd_pcm_lib_free_vmalloc_buffer(substream);
862-
else
863-
return snd_pcm_lib_free_pages(substream);
856+
return snd_pcm_lib_free_pages(substream);
864857
}
865858

866859
/*
@@ -1781,7 +1774,6 @@ static const struct snd_pcm_ops snd_usb_playback_ops = {
17811774
.prepare = snd_usb_pcm_prepare,
17821775
.trigger = snd_usb_substream_playback_trigger,
17831776
.pointer = snd_usb_pcm_pointer,
1784-
.page = snd_pcm_lib_get_vmalloc_page,
17851777
};
17861778

17871779
static const struct snd_pcm_ops snd_usb_capture_ops = {
@@ -1793,43 +1785,14 @@ static const struct snd_pcm_ops snd_usb_capture_ops = {
17931785
.prepare = snd_usb_pcm_prepare,
17941786
.trigger = snd_usb_substream_capture_trigger,
17951787
.pointer = snd_usb_pcm_pointer,
1796-
.page = snd_pcm_lib_get_vmalloc_page,
1797-
};
1798-
1799-
static const struct snd_pcm_ops snd_usb_playback_dev_ops = {
1800-
.open = snd_usb_pcm_open,
1801-
.close = snd_usb_pcm_close,
1802-
.ioctl = snd_pcm_lib_ioctl,
1803-
.hw_params = snd_usb_hw_params,
1804-
.hw_free = snd_usb_hw_free,
1805-
.prepare = snd_usb_pcm_prepare,
1806-
.trigger = snd_usb_substream_playback_trigger,
1807-
.pointer = snd_usb_pcm_pointer,
1808-
.page = snd_pcm_sgbuf_ops_page,
1809-
};
1810-
1811-
static const struct snd_pcm_ops snd_usb_capture_dev_ops = {
1812-
.open = snd_usb_pcm_open,
1813-
.close = snd_usb_pcm_close,
1814-
.ioctl = snd_pcm_lib_ioctl,
1815-
.hw_params = snd_usb_hw_params,
1816-
.hw_free = snd_usb_hw_free,
1817-
.prepare = snd_usb_pcm_prepare,
1818-
.trigger = snd_usb_substream_capture_trigger,
1819-
.pointer = snd_usb_pcm_pointer,
1820-
.page = snd_pcm_sgbuf_ops_page,
18211788
};
18221789

18231790
void snd_usb_set_pcm_ops(struct snd_pcm *pcm, int stream)
18241791
{
18251792
const struct snd_pcm_ops *ops;
18261793

1827-
if (snd_usb_use_vmalloc)
1828-
ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
1794+
ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
18291795
&snd_usb_playback_ops : &snd_usb_capture_ops;
1830-
else
1831-
ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
1832-
&snd_usb_playback_dev_ops : &snd_usb_capture_dev_ops;
18331796
snd_pcm_set_ops(pcm, stream, ops);
18341797
}
18351798

@@ -1839,7 +1802,10 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs)
18391802
struct snd_pcm_substream *s = pcm->streams[subs->direction].substream;
18401803
struct device *dev = subs->dev->bus->controller;
18411804

1842-
if (!snd_usb_use_vmalloc)
1805+
if (snd_usb_use_vmalloc)
1806+
snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_VMALLOC,
1807+
NULL, 0, 0);
1808+
else
18431809
snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_DEV_SG,
18441810
dev, 64*1024, 512*1024);
18451811
}

0 commit comments

Comments
 (0)