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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, int channel,
|
static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream,
|
||||||
snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count)
|
int channel, unsigned long pos,
|
||||||
|
void __user *src, unsigned long count)
|
||||||
{
|
{
|
||||||
/* channel is not used (interleaved data) */
|
/* channel is not used (interleaved data) */
|
||||||
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
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)
|
if (copy_from_user_toio(chip->data_buffer + pos, src, count))
|
||||||
return -EINVAL;
|
return -EFAULT;
|
||||||
|
chip->buffer_end = chip->data_buffer + pos + count;
|
||||||
|
|
||||||
|
if (chip->empty) {
|
||||||
|
chip->empty = 0;
|
||||||
|
dac_audio_start_timer(chip);
|
||||||
|
}
|
||||||
|
|
||||||
if (!count)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy_toio(chip->data_buffer + b_pos, src, b_count);
|
static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream,
|
||||||
chip->buffer_end = chip->data_buffer + b_pos + b_count;
|
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) {
|
if (chip->empty) {
|
||||||
chip->empty = 0;
|
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,
|
static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream,
|
||||||
int channel, snd_pcm_uframes_t pos,
|
int channel, unsigned long pos,
|
||||||
snd_pcm_uframes_t count)
|
unsigned long count)
|
||||||
{
|
{
|
||||||
/* channel is not used (interleaved data) */
|
/* channel is not used (interleaved data) */
|
||||||
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
struct snd_sh_dac *chip = snd_pcm_substream_chip(substream);
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
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)
|
memset_io(chip->data_buffer + pos, 0, count);
|
||||||
return -EINVAL;
|
chip->buffer_end = chip->data_buffer + pos + count;
|
||||||
|
|
||||||
if (!count)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memset_io(chip->data_buffer + b_pos, 0, b_count);
|
|
||||||
chip->buffer_end = chip->data_buffer + b_pos + b_count;
|
|
||||||
|
|
||||||
if (chip->empty) {
|
if (chip->empty) {
|
||||||
chip->empty = 0;
|
chip->empty = 0;
|
||||||
|
@ -256,8 +261,9 @@ static struct snd_pcm_ops snd_sh_dac_pcm_ops = {
|
||||||
.prepare = snd_sh_dac_pcm_prepare,
|
.prepare = snd_sh_dac_pcm_prepare,
|
||||||
.trigger = snd_sh_dac_pcm_trigger,
|
.trigger = snd_sh_dac_pcm_trigger,
|
||||||
.pointer = snd_sh_dac_pcm_pointer,
|
.pointer = snd_sh_dac_pcm_pointer,
|
||||||
.copy = snd_sh_dac_pcm_copy,
|
.copy_user = snd_sh_dac_pcm_copy,
|
||||||
.silence = snd_sh_dac_pcm_silence,
|
.copy_kernel = snd_sh_dac_pcm_copy_kernel,
|
||||||
|
.fill_silence = snd_sh_dac_pcm_silence,
|
||||||
.mmap = snd_pcm_lib_mmap_iomem,
|
.mmap = snd_pcm_lib_mmap_iomem,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue