ALSA: sh: Convert to the new PCM ops
Replace the copy and the silence ops with the new PCM ops. Fixed also the user-space buffer copy with the proper copy_from_user*() variant. Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
4b83eff81c
commit
1cc2f8ba0b
|
@ -184,23 +184,36 @@ static int snd_sh_dac_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
||||
snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
|
||||
static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream,
|
||||
int channel, unsigned long pos,
|
||||
void __user *src, unsigned long count)
|
||||
{
|
||||
/* channel is not used (interleaved data) */
|
||||
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
ssize_t b_count = frames_to_bytes(runtime , count);
|
||||
ssize_t b_pos = frames_to_bytes(runtime , pos);
|
||||
|
||||
if (count < 0)
|
||||
return -EINVAL;
|
||||
if (copy_from_user_toio(chip->data_buffer + pos, src, count))
|
||||
return -EFAULT;
|
||||
chip->buffer_end = chip->data_buffer + pos + count;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
if (chip->empty) {
|
||||
chip->empty = 0;
|
||||
dac_audio_start_timer(chip);
|
||||
}
|
||||
|
||||
memcpy_toio(chip->data_buffer + b_pos, src, b_count);
|
||||
chip->buffer_end = chip->data_buffer + b_pos + b_count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream,
|
||||
int channel, unsigned long pos,
|
||||
void *src, unsigned long count)
|
||||
{
|
||||
/* channel is not used (interleaved data) */
|
||||
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
|
||||
memcpy_toio(chip->data_buffer + pos, src, count);
|
||||
chip->buffer_end = chip->data_buffer + pos + count;
|
||||
|
||||
if (chip->empty) {
|
||||
chip->empty = 0;
|
||||
|
@ -211,23 +224,15 @@ static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
|||
}
|
||||
|
||||
static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream,
|
||||
int channel, snd_pcm_uframes_t pos,
|
||||
snd_pcm_uframes_t count)
|
||||
int channel, unsigned long pos,
|
||||
unsigned long count)
|
||||
{
|
||||
/* channel is not used (interleaved data) */
|
||||
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
ssize_t b_count = frames_to_bytes(runtime , count);
|
||||
ssize_t b_pos = frames_to_bytes(runtime , pos);
|
||||
|
||||
if (count < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
memset_io(chip->data_buffer + b_pos, 0, b_count);
|
||||
chip->buffer_end = chip->data_buffer + b_pos + b_count;
|
||||
memset_io(chip->data_buffer + pos, 0, count);
|
||||
chip->buffer_end = chip->data_buffer + pos + count;
|
||||
|
||||
if (chip->empty) {
|
||||
chip->empty = 0;
|
||||
|
@ -256,8 +261,9 @@ static struct snd_pcm_ops snd_sh_dac_pcm_ops = {
|
|||
.prepare = snd_sh_dac_pcm_prepare,
|
||||
.trigger = snd_sh_dac_pcm_trigger,
|
||||
.pointer = snd_sh_dac_pcm_pointer,
|
||||
.copy = snd_sh_dac_pcm_copy,
|
||||
.silence = snd_sh_dac_pcm_silence,
|
||||
.copy_user = snd_sh_dac_pcm_copy,
|
||||
.copy_kernel = snd_sh_dac_pcm_copy_kernel,
|
||||
.fill_silence = snd_sh_dac_pcm_silence,
|
||||
.mmap = snd_pcm_lib_mmap_iomem,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user