alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [alsa-devel] [PATCH 08/24] ALSA: usb-audio: Convert to the common vmalloc memalloc
Date: Tue,  5 Nov 2019 16:18:40 +0100	[thread overview]
Message-ID: <20191105151856.10785-9-tiwai@suse.de> (raw)
In-Reply-To: <20191105151856.10785-1-tiwai@suse.de>

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.
(*) df3fd6509421: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    6ef6be988f98: 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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/pcm.c | 50 ++++++++------------------------------------------
 1 file changed, 8 insertions(+), 42 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index ff5ab24f3bd1..9c8930bb00c8 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -785,12 +785,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
 	if (ret)
 		return ret;
 
-	if (snd_usb_use_vmalloc)
-		ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
-						       params_buffer_bytes(hw_params));
-	else
-		ret = snd_pcm_lib_malloc_pages(substream,
-					       params_buffer_bytes(hw_params));
+	ret = snd_pcm_lib_malloc_pages(substream,
+				       params_buffer_bytes(hw_params));
 	if (ret < 0)
 		goto stop_pipeline;
 
@@ -857,10 +853,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
 		snd_usb_unlock_shutdown(subs->stream->chip);
 	}
 
-	if (snd_usb_use_vmalloc)
-		return snd_pcm_lib_free_vmalloc_buffer(substream);
-	else
-		return snd_pcm_lib_free_pages(substream);
+	return snd_pcm_lib_free_pages(substream);
 }
 
 /*
@@ -1781,7 +1774,6 @@ static const struct snd_pcm_ops snd_usb_playback_ops = {
 	.prepare =	snd_usb_pcm_prepare,
 	.trigger =	snd_usb_substream_playback_trigger,
 	.pointer =	snd_usb_pcm_pointer,
-	.page =		snd_pcm_lib_get_vmalloc_page,
 };
 
 static const struct snd_pcm_ops snd_usb_capture_ops = {
@@ -1793,43 +1785,14 @@ static const struct snd_pcm_ops snd_usb_capture_ops = {
 	.prepare =	snd_usb_pcm_prepare,
 	.trigger =	snd_usb_substream_capture_trigger,
 	.pointer =	snd_usb_pcm_pointer,
-	.page =		snd_pcm_lib_get_vmalloc_page,
-};
-
-static const struct snd_pcm_ops snd_usb_playback_dev_ops = {
-	.open =		snd_usb_pcm_open,
-	.close =	snd_usb_pcm_close,
-	.ioctl =	snd_pcm_lib_ioctl,
-	.hw_params =	snd_usb_hw_params,
-	.hw_free =	snd_usb_hw_free,
-	.prepare =	snd_usb_pcm_prepare,
-	.trigger =	snd_usb_substream_playback_trigger,
-	.pointer =	snd_usb_pcm_pointer,
-	.page =		snd_pcm_sgbuf_ops_page,
-};
-
-static const struct snd_pcm_ops snd_usb_capture_dev_ops = {
-	.open =		snd_usb_pcm_open,
-	.close =	snd_usb_pcm_close,
-	.ioctl =	snd_pcm_lib_ioctl,
-	.hw_params =	snd_usb_hw_params,
-	.hw_free =	snd_usb_hw_free,
-	.prepare =	snd_usb_pcm_prepare,
-	.trigger =	snd_usb_substream_capture_trigger,
-	.pointer =	snd_usb_pcm_pointer,
-	.page =		snd_pcm_sgbuf_ops_page,
 };
 
 void snd_usb_set_pcm_ops(struct snd_pcm *pcm, int stream)
 {
 	const struct snd_pcm_ops *ops;
 
-	if (snd_usb_use_vmalloc)
-		ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
+	ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
 			&snd_usb_playback_ops : &snd_usb_capture_ops;
-	else
-		ops = stream == SNDRV_PCM_STREAM_PLAYBACK ?
-			&snd_usb_playback_dev_ops : &snd_usb_capture_dev_ops;
 	snd_pcm_set_ops(pcm, stream, ops);
 }
 
@@ -1839,7 +1802,10 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs)
 	struct snd_pcm_substream *s = pcm->streams[subs->direction].substream;
 	struct device *dev = subs->dev->bus->controller;
 
-	if (!snd_usb_use_vmalloc)
+	if (snd_usb_use_vmalloc)
+		snd_pcm_lib_preallocate_pages(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);
 }
-- 
2.16.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2019-11-05 15:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 15:18 [alsa-devel] [PATCH 00/24] Clean up memalloc callers Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 01/24] ALSA: drivers: Remove superfluous snd_dma_continuous_data() Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 02/24] ALSA: mips: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 03/24] ALSA: rme32: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 04/24] ALSA: sh: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 05/24] ALSA: sparc: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 06/24] ALSA: usb: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 07/24] ALSA: 6fire: Drop the dead code Takashi Iwai
2019-11-05 15:18 ` Takashi Iwai [this message]
2019-11-05 15:18 ` [alsa-devel] [PATCH 09/24] ALSA: aloop: Convert to the common vmalloc memalloc Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 10/24] ALSA: firewire: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 11/24] ALSA: 6fire: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 12/24] ALSA: caiaq: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 13/24] ALSA: hiface: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 14/24] ALSA: ua101: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 15/24] ALSA: vx: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 16/24] ALSA: pdaudiocf: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 17/24] ALSA: mips: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 18/24] ALSA: pci: Drop superfluous snd_pcm_sgbuf_ops_page Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 19/24] ALSA: aoa: Avoid non-standard macro usage Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 20/24] ALSA: echoaudio: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 21/24] ALSA: es1968: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 22/24] ALSA: rme: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 23/24] ALSA: pci: " Takashi Iwai
2019-11-05 15:18 ` [alsa-devel] [PATCH 24/24] ALSA: docs: Remove snd_dma_pci_data() usage in documentation Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191105151856.10785-9-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).