[ALSA] Tiny clean up of PCM codes

- Make snd_pcm_prepare() static
- Clean up snd_pcm_kernel_*_ioctl() functions, reduce exports

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2006-03-27 16:22:45 +02:00 committed by Jaroslav Kysela
parent 82756b2785
commit bf1bbb5a49
4 changed files with 23 additions and 41 deletions

View File

@ -460,7 +460,6 @@ int snd_pcm_info_user(struct snd_pcm_substream *substream,
struct snd_pcm_info __user *info); struct snd_pcm_info __user *info);
int snd_pcm_status(struct snd_pcm_substream *substream, int snd_pcm_status(struct snd_pcm_substream *substream,
struct snd_pcm_status *status); struct snd_pcm_status *status);
int snd_pcm_prepare(struct snd_pcm_substream *substream);
int snd_pcm_start(struct snd_pcm_substream *substream); int snd_pcm_start(struct snd_pcm_substream *substream);
int snd_pcm_stop(struct snd_pcm_substream *substream, int status); int snd_pcm_stop(struct snd_pcm_substream *substream, int status);
int snd_pcm_drain_done(struct snd_pcm_substream *substream); int snd_pcm_drain_done(struct snd_pcm_substream *substream);
@ -468,8 +467,6 @@ int snd_pcm_drain_done(struct snd_pcm_substream *substream);
int snd_pcm_suspend(struct snd_pcm_substream *substream); int snd_pcm_suspend(struct snd_pcm_substream *substream);
int snd_pcm_suspend_all(struct snd_pcm *pcm); int snd_pcm_suspend_all(struct snd_pcm *pcm);
#endif #endif
int snd_pcm_kernel_playback_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int snd_pcm_kernel_capture_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct snd_pcm_substream **rsubstream); int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct snd_pcm_substream **rsubstream);
void snd_pcm_release_substream(struct snd_pcm_substream *substream); void snd_pcm_release_substream(struct snd_pcm_substream *substream);

View File

@ -959,12 +959,12 @@ static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
if (substream != NULL) { if (substream != NULL) {
snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
substream->runtime->oss.prepare = 1; substream->runtime->oss.prepare = 1;
} }
substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
if (substream != NULL) { if (substream != NULL) {
snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
substream->runtime->oss.prepare = 1; substream->runtime->oss.prepare = 1;
} }
return 0; return 0;
@ -979,7 +979,7 @@ static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file)
if (substream != NULL) { if (substream != NULL) {
if ((err = snd_pcm_oss_make_ready(substream)) < 0) if ((err = snd_pcm_oss_make_ready(substream)) < 0)
return err; return err;
snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL); snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL);
} }
/* note: all errors from the start action are ignored */ /* note: all errors from the start action are ignored */
/* OSS apps do not know, how to handle them */ /* OSS apps do not know, how to handle them */
@ -1108,7 +1108,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
__direct: __direct:
saved_f_flags = substream->ffile->f_flags; saved_f_flags = substream->ffile->f_flags;
substream->ffile->f_flags &= ~O_NONBLOCK; substream->ffile->f_flags &= ~O_NONBLOCK;
err = snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
substream->ffile->f_flags = saved_f_flags; substream->ffile->f_flags = saved_f_flags;
if (err < 0) if (err < 0)
return err; return err;
@ -1120,7 +1120,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
if ((err = snd_pcm_oss_make_ready(substream)) < 0) if ((err = snd_pcm_oss_make_ready(substream)) < 0)
return err; return err;
runtime = substream->runtime; runtime = substream->runtime;
err = snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
if (err < 0) if (err < 0)
return err; return err;
runtime->oss.buffer_used = 0; runtime->oss.buffer_used = 0;
@ -1437,7 +1437,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
cmd = SNDRV_PCM_IOCTL_DROP; cmd = SNDRV_PCM_IOCTL_DROP;
runtime->oss.prepare = 1; runtime->oss.prepare = 1;
} }
err = snd_pcm_kernel_playback_ioctl(psubstream, cmd, NULL); err = snd_pcm_kernel_ioctl(psubstream, cmd, NULL);
if (err < 0) if (err < 0)
return err; return err;
} }
@ -1458,7 +1458,7 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr
cmd = SNDRV_PCM_IOCTL_DROP; cmd = SNDRV_PCM_IOCTL_DROP;
runtime->oss.prepare = 1; runtime->oss.prepare = 1;
} }
err = snd_pcm_kernel_capture_ioctl(csubstream, cmd, NULL); err = snd_pcm_kernel_ioctl(csubstream, cmd, NULL);
if (err < 0) if (err < 0)
return err; return err;
} }
@ -1495,7 +1495,7 @@ static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file)
runtime = substream->runtime; runtime = substream->runtime;
if (runtime->oss.params || runtime->oss.prepare) if (runtime->oss.params || runtime->oss.prepare)
return 0; return 0;
err = snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay); err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay);
if (err == -EPIPE) if (err == -EPIPE)
delay = 0; /* hack for broken OSS applications */ delay = 0; /* hack for broken OSS applications */
else if (err < 0) else if (err < 0)

View File

@ -1111,8 +1111,6 @@ EXPORT_SYMBOL(snd_pcm_link_rwlock);
EXPORT_SYMBOL(snd_pcm_suspend); EXPORT_SYMBOL(snd_pcm_suspend);
EXPORT_SYMBOL(snd_pcm_suspend_all); EXPORT_SYMBOL(snd_pcm_suspend_all);
#endif #endif
EXPORT_SYMBOL(snd_pcm_kernel_playback_ioctl);
EXPORT_SYMBOL(snd_pcm_kernel_capture_ioctl);
EXPORT_SYMBOL(snd_pcm_kernel_ioctl); EXPORT_SYMBOL(snd_pcm_kernel_ioctl);
EXPORT_SYMBOL(snd_pcm_mmap_data); EXPORT_SYMBOL(snd_pcm_mmap_data);
#if SNDRV_PCM_INFO_MMAP_IOMEM #if SNDRV_PCM_INFO_MMAP_IOMEM

View File

@ -1313,7 +1313,7 @@ static struct action_ops snd_pcm_action_prepare = {
* *
* Prepare the PCM substream to be triggerable. * Prepare the PCM substream to be triggerable.
*/ */
int snd_pcm_prepare(struct snd_pcm_substream *substream) static int snd_pcm_prepare(struct snd_pcm_substream *substream)
{ {
int res; int res;
struct snd_card *card = substream->pcm->card; struct snd_card *card = substream->pcm->card;
@ -2736,41 +2736,28 @@ static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd,
return snd_pcm_capture_ioctl1(pcm_file->substream, cmd, (void __user *)arg); return snd_pcm_capture_ioctl1(pcm_file->substream, cmd, (void __user *)arg);
} }
int snd_pcm_kernel_playback_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg)
{
mm_segment_t fs;
int result;
fs = snd_enter_user();
result = snd_pcm_playback_ioctl1(substream, cmd, (void __user *)arg);
snd_leave_user(fs);
return result;
}
int snd_pcm_kernel_capture_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg)
{
mm_segment_t fs;
int result;
fs = snd_enter_user();
result = snd_pcm_capture_ioctl1(substream, cmd, (void __user *)arg);
snd_leave_user(fs);
return result;
}
int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg) unsigned int cmd, void *arg)
{ {
mm_segment_t fs;
int result;
fs = snd_enter_user();
switch (substream->stream) { switch (substream->stream) {
case SNDRV_PCM_STREAM_PLAYBACK: case SNDRV_PCM_STREAM_PLAYBACK:
return snd_pcm_kernel_playback_ioctl(substream, cmd, arg); result = snd_pcm_playback_ioctl1(substream,
cmd, (void __user *)arg);
break;
case SNDRV_PCM_STREAM_CAPTURE: case SNDRV_PCM_STREAM_CAPTURE:
return snd_pcm_kernel_capture_ioctl(substream, cmd, arg); result = snd_pcm_capture_ioctl1(substream,
cmd, (void __user *)arg);
break;
default: default:
return -EINVAL; result = -EINVAL;
break;
} }
snd_leave_user(fs);
return result;
} }
static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count,