All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Subject: [PATCH 02/14] ALSA: nm256: Convert to new PCM copy ops
Date: Thu, 25 May 2017 21:17:23 +0200	[thread overview]
Message-ID: <20170525191735.13787-3-tiwai@suse.de> (raw)
In-Reply-To: <20170525191735.13787-1-tiwai@suse.de>

Replace the copy and the silence ops with the new merged ops.
The conversion is straightforward with standard helper functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/nm256/nm256.c | 57 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 20 deletions(-)

diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 103fe311e5a9..63f0985dae27 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -695,53 +695,68 @@ snd_nm256_capture_pointer(struct snd_pcm_substream *substream)
  */
 static int
 snd_nm256_playback_silence(struct snd_pcm_substream *substream,
-			   int channel, /* not used (interleaved data) */
-			   snd_pcm_uframes_t pos,
-			   snd_pcm_uframes_t count)
+			   int channel, unsigned long pos, unsigned long count)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct nm256_stream *s = runtime->private_data;
-	count = frames_to_bytes(runtime, count);
-	pos = frames_to_bytes(runtime, pos);
+
 	memset_io(s->bufptr + pos, 0, count);
 	return 0;
 }
 
 static int
 snd_nm256_playback_copy(struct snd_pcm_substream *substream,
-			int channel, /* not used (interleaved data) */
-			snd_pcm_uframes_t pos,
-			void __user *src,
-			snd_pcm_uframes_t count)
+			int channel, unsigned long pos,
+			void __user *src, unsigned long count)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct nm256_stream *s = runtime->private_data;
-	count = frames_to_bytes(runtime, count);
-	pos = frames_to_bytes(runtime, pos);
+
 	if (copy_from_user_toio(s->bufptr + pos, src, count))
 		return -EFAULT;
 	return 0;
 }
 
+static int
+snd_nm256_playback_copy_kernel(struct snd_pcm_substream *substream,
+			       int channel, unsigned long pos,
+			       void *src, unsigned long count)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct nm256_stream *s = runtime->private_data;
+
+	memcpy_toio(s->bufptr + pos, src, count);
+	return 0;
+}
+
 /*
  * copy to user
  */
 static int
 snd_nm256_capture_copy(struct snd_pcm_substream *substream,
-		       int channel, /* not used (interleaved data) */
-		       snd_pcm_uframes_t pos,
-		       void __user *dst,
-		       snd_pcm_uframes_t count)
+		       int channel, unsigned long pos,
+		       void __user *dst, unsigned long count)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct nm256_stream *s = runtime->private_data;
-	count = frames_to_bytes(runtime, count);
-	pos = frames_to_bytes(runtime, pos);
+
 	if (copy_to_user_fromio(dst, s->bufptr + pos, count))
 		return -EFAULT;
 	return 0;
 }
 
+static int
+snd_nm256_capture_copy_kernel(struct snd_pcm_substream *substream,
+			      int channel, unsigned long pos,
+			      void *dst, unsigned long count)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct nm256_stream *s = runtime->private_data;
+
+	memcpy_fromio(dst, s->bufptr + pos, count);
+	return 0;
+}
+
 #endif /* !__i386__ */
 
 
@@ -911,8 +926,9 @@ static const struct snd_pcm_ops snd_nm256_playback_ops = {
 	.trigger =	snd_nm256_playback_trigger,
 	.pointer =	snd_nm256_playback_pointer,
 #ifndef __i386__
-	.copy =		snd_nm256_playback_copy,
-	.silence =	snd_nm256_playback_silence,
+	.copy_user =	snd_nm256_playback_copy,
+	.copy_kernel =	snd_nm256_playback_copy_kernel,
+	.fill_silence =	snd_nm256_playback_silence,
 #endif
 	.mmap =		snd_pcm_lib_mmap_iomem,
 };
@@ -926,7 +942,8 @@ static const struct snd_pcm_ops snd_nm256_capture_ops = {
 	.trigger =	snd_nm256_capture_trigger,
 	.pointer =	snd_nm256_capture_pointer,
 #ifndef __i386__
-	.copy =		snd_nm256_capture_copy,
+	.copy_user =	snd_nm256_capture_copy,
+	.copy_kernel =	snd_nm256_capture_copy_kernel,
 #endif
 	.mmap =		snd_pcm_lib_mmap_iomem,
 };
-- 
2.13.0

  parent reply	other threads:[~2017-05-25 19:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25 19:17 [PATCH 00/14] Revised patchset for PCM in-kernel copy support Takashi Iwai
2017-05-25 19:17 ` [PATCH 01/14] ALSA: pcm: Introduce copy_user, copy_kernel and fill_silence ops Takashi Iwai
2017-05-25 19:17 ` Takashi Iwai [this message]
2017-05-25 19:17 ` [PATCH 03/14] ALSA: rme9652: Convert to the new PCM ops Takashi Iwai
2017-05-25 19:17 ` [PATCH 04/14] ALSA: pcm: Drop the old copy and silence ops Takashi Iwai
2017-05-25 19:17 ` [PATCH 05/14] ALSA: pcm: Check PCM state by a common helper function Takashi Iwai
2017-05-25 19:17 ` [PATCH 06/14] ALSA: pcm: Shuffle codes Takashi Iwai
2017-05-26 13:06   ` Takashi Sakamoto
2017-05-26 15:47     ` Takashi Iwai
2017-05-25 19:17 ` [PATCH 07/14] ALSA: pcm: Call directly the common read/write helpers Takashi Iwai
2017-05-25 19:17 ` [PATCH 08/14] ALSA: pcm: More unification of PCM transfer codes Takashi Iwai
2017-05-25 19:17 ` [PATCH 09/14] ALSA: pcm: Unify read/write loop Takashi Iwai
2017-05-25 19:17 ` [PATCH 10/14] ALSA: pcm: Simplify snd_pcm_playback_silence() Takashi Iwai
2017-05-26 13:21   ` Takashi Sakamoto
2017-05-26 15:46     ` Takashi Iwai
2017-05-25 19:17 ` [PATCH 11/14] ALSA: pcm: Direct in-kernel read/write support Takashi Iwai
2017-05-25 19:17 ` [PATCH 12/14] usb: gadget: u_uac1: Kill set_fs() usage Takashi Iwai
2017-05-25 19:17 ` [PATCH 13/14] ALSA: pcm: Kill set_fs() in PCM OSS layer Takashi Iwai
2017-05-25 19:17 ` [PATCH 14/14] ALSA: pcm: Build OSS writev/readv helpers conditionally Takashi Iwai
2017-05-26 13:59 ` [PATCH 00/14] Revised patchset for PCM in-kernel copy support Takashi Sakamoto

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=20170525191735.13787-3-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=o-takashi@sakamocchi.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.