Commit 21de5673 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: nm256: Convert to new PCM copy ops

Replace the copy and the silence ops with the new ops.
The conversion is straightforward with standard helper functions, and
now we can drop the bytes <-> frames conversions in callbacks.
Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b96c3a15
...@@ -695,53 +695,68 @@ snd_nm256_capture_pointer(struct snd_pcm_substream *substream) ...@@ -695,53 +695,68 @@ snd_nm256_capture_pointer(struct snd_pcm_substream *substream)
*/ */
static int static int
snd_nm256_playback_silence(struct snd_pcm_substream *substream, snd_nm256_playback_silence(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */ int channel, unsigned long pos, unsigned long count)
snd_pcm_uframes_t pos,
snd_pcm_uframes_t count)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct nm256_stream *s = runtime->private_data; 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); memset_io(s->bufptr + pos, 0, count);
return 0; return 0;
} }
static int static int
snd_nm256_playback_copy(struct snd_pcm_substream *substream, snd_nm256_playback_copy(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */ int channel, unsigned long pos,
snd_pcm_uframes_t pos, void __user *src, unsigned long count)
void __user *src,
snd_pcm_uframes_t count)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct nm256_stream *s = runtime->private_data; 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)) if (copy_from_user_toio(s->bufptr + pos, src, count))
return -EFAULT; return -EFAULT;
return 0; 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 * copy to user
*/ */
static int static int
snd_nm256_capture_copy(struct snd_pcm_substream *substream, snd_nm256_capture_copy(struct snd_pcm_substream *substream,
int channel, /* not used (interleaved data) */ int channel, unsigned long pos,
snd_pcm_uframes_t pos, void __user *dst, unsigned long count)
void __user *dst,
snd_pcm_uframes_t count)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct nm256_stream *s = runtime->private_data; 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)) if (copy_to_user_fromio(dst, s->bufptr + pos, count))
return -EFAULT; return -EFAULT;
return 0; 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__ */ #endif /* !__i386__ */
...@@ -911,8 +926,9 @@ static const struct snd_pcm_ops snd_nm256_playback_ops = { ...@@ -911,8 +926,9 @@ static const struct snd_pcm_ops snd_nm256_playback_ops = {
.trigger = snd_nm256_playback_trigger, .trigger = snd_nm256_playback_trigger,
.pointer = snd_nm256_playback_pointer, .pointer = snd_nm256_playback_pointer,
#ifndef __i386__ #ifndef __i386__
.copy = snd_nm256_playback_copy, .copy_user = snd_nm256_playback_copy,
.silence = snd_nm256_playback_silence, .copy_kernel = snd_nm256_playback_copy_kernel,
.fill_silence = snd_nm256_playback_silence,
#endif #endif
.mmap = snd_pcm_lib_mmap_iomem, .mmap = snd_pcm_lib_mmap_iomem,
}; };
...@@ -926,7 +942,8 @@ static const struct snd_pcm_ops snd_nm256_capture_ops = { ...@@ -926,7 +942,8 @@ static const struct snd_pcm_ops snd_nm256_capture_ops = {
.trigger = snd_nm256_capture_trigger, .trigger = snd_nm256_capture_trigger,
.pointer = snd_nm256_capture_pointer, .pointer = snd_nm256_capture_pointer,
#ifndef __i386__ #ifndef __i386__
.copy = snd_nm256_capture_copy, .copy_user = snd_nm256_capture_copy,
.copy_kernel = snd_nm256_capture_copy_kernel,
#endif #endif
.mmap = snd_pcm_lib_mmap_iomem, .mmap = snd_pcm_lib_mmap_iomem,
}; };
......
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