Commit 1facf21e authored by Takashi Iwai's avatar Takashi Iwai

[media] solo6x10: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
The device supports only 1 channel and 8bit sample, so it's always
bytes=frames, and we need no conversion of unit in the callback.
Also, it's a capture stream, thus no silence is needed.
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent aa708c61
...@@ -223,9 +223,9 @@ static snd_pcm_uframes_t snd_solo_pcm_pointer(struct snd_pcm_substream *ss) ...@@ -223,9 +223,9 @@ static snd_pcm_uframes_t snd_solo_pcm_pointer(struct snd_pcm_substream *ss)
return idx * G723_FRAMES_PER_PAGE; return idx * G723_FRAMES_PER_PAGE;
} }
static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel, static int __snd_solo_pcm_copy(struct snd_pcm_substream *ss,
snd_pcm_uframes_t pos, void __user *dst, unsigned long pos, void *dst,
snd_pcm_uframes_t count) unsigned long count, bool in_kernel)
{ {
struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss); struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
struct solo_dev *solo_dev = solo_pcm->solo_dev; struct solo_dev *solo_dev = solo_pcm->solo_dev;
...@@ -242,16 +242,31 @@ static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel, ...@@ -242,16 +242,31 @@ static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel,
if (err) if (err)
return err; return err;
err = copy_to_user(dst + (i * G723_PERIOD_BYTES), if (in_kernel)
solo_pcm->g723_buf, G723_PERIOD_BYTES); memcpy(dst, solo_pcm->g723_buf, G723_PERIOD_BYTES);
else if (copy_to_user((void __user *)dst,
if (err) solo_pcm->g723_buf, G723_PERIOD_BYTES))
return -EFAULT; return -EFAULT;
dst += G723_PERIOD_BYTES;
} }
return 0; return 0;
} }
static int snd_solo_pcm_copy_user(struct snd_pcm_substream *ss, int channel,
unsigned long pos, void __user *dst,
unsigned long count)
{
return __snd_solo_pcm_copy(ss, pos, (void *)dst, count, false);
}
static int snd_solo_pcm_copy_kernel(struct snd_pcm_substream *ss, int channel,
unsigned long pos, void *dst,
unsigned long count)
{
return __snd_solo_pcm_copy(ss, pos, dst, count, true);
}
static const struct snd_pcm_ops snd_solo_pcm_ops = { static const struct snd_pcm_ops snd_solo_pcm_ops = {
.open = snd_solo_pcm_open, .open = snd_solo_pcm_open,
.close = snd_solo_pcm_close, .close = snd_solo_pcm_close,
...@@ -261,7 +276,8 @@ static const struct snd_pcm_ops snd_solo_pcm_ops = { ...@@ -261,7 +276,8 @@ static const struct snd_pcm_ops snd_solo_pcm_ops = {
.prepare = snd_solo_pcm_prepare, .prepare = snd_solo_pcm_prepare,
.trigger = snd_solo_pcm_trigger, .trigger = snd_solo_pcm_trigger,
.pointer = snd_solo_pcm_pointer, .pointer = snd_solo_pcm_pointer,
.copy = snd_solo_pcm_copy, .copy_user = snd_solo_pcm_copy_user,
.copy_kernel = snd_solo_pcm_copy_kernel,
}; };
static int snd_solo_capture_volume_info(struct snd_kcontrol *kcontrol, static int snd_solo_capture_volume_info(struct snd_kcontrol *kcontrol,
......
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