*参照元 [#cb8f069f] #backlinks *説明 [#c89175f8] -パス: [[linux-2.6.33/sound/core/pcm_native.c]] -FIXME: これは何? --説明 **引数 [#n76b0987] -struct file *file -- --[[linux-2.6.33/file]] -struct snd_pcm_substream *substream -- --[[linux-2.6.33/snd_pcm_substream]] -unsigned int cmd -- -void __user *arg -- **返り値 [#y0b39382] -int -- **参考 [#i6ea9752] *実装 [#a2d4ebb6] static int snd_pcm_capture_ioctl1(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { if (snd_BUG_ON(!substream)) return -ENXIO; if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) return -EINVAL; - --[[linux-2.6.33/snd_BUG_ON()]] - --[[linux-2.6.33/SNDRV_PCM_STREAM_CAPTURE]] switch (cmd) { case SNDRV_PCM_IOCTL_READI_FRAMES: { struct snd_xferi xferi; struct snd_xferi __user *_xferi = arg; struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t result; - --[[linux-2.6.33/SNDRV_PCM_IOCTL_READI_FRAMES]] - --[[linux-2.6.33/snd_xferi]] - --[[linux-2.6.33/snd_pcm_runtime]] - --[[linux-2.6.33/snd_pcm_sframes_t]] if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; if (put_user(0, &_xferi->result)) return -EFAULT; if (copy_from_user(&xferi, _xferi, sizeof(xferi))) return -EFAULT; - --runtime->status は snd_pcm_mmap_status 型のメンバ --[[linux-2.6.33/snd_pcm_mmap_status]] - --[[linux-2.6.33/SNDRV_PCM_STATE_OPEN]] - --[[linux-2.6.33/put_user()]] - --[[linux-2.6.33/copy_from_user()]] result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); __put_user(result, &_xferi->result); - --[[linux-2.6.33/snd_pcm_lib_read()]] - --[[linux-2.6.33/__put_user()]] return result < 0 ? result : 0; } case SNDRV_PCM_IOCTL_READN_FRAMES: { struct snd_xfern xfern; struct snd_xfern __user *_xfern = arg; struct snd_pcm_runtime *runtime = substream->runtime; void *bufs; snd_pcm_sframes_t result; - --[[linux-2.6.33/SNDRV_PCM_IOCTL_READN_FRAMES]] if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; if (runtime->channels > 128) return -EINVAL; if (put_user(0, &_xfern->result)) return -EFAULT; if (copy_from_user(&xfern, _xfern, sizeof(xfern))) return -EFAULT; bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); if (IS_ERR(bufs)) return PTR_ERR(bufs); - --[[linux-2.6.33/memdup_user()]] - --[[linux-2.6.33/IS_ERR()]] - --[[linux-2.6.33/PTR_ERR()]] result = snd_pcm_lib_readv(substream, bufs, xfern.frames); kfree(bufs); __put_user(result, &_xfern->result); - --[[linux-2.6.33/snd_pcm_lib_readv()]] - --[[linux-2.6.33/kfree()]] return result < 0 ? result : 0; } case SNDRV_PCM_IOCTL_REWIND: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; - --[[linux-2.6.33/SNDRV_PCM_IOCTL_REWIND]] if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; - --[[linux-2.6.33/get_user()]] result = snd_pcm_capture_rewind(substream, frames); __put_user(result, _frames); - --[[linux-2.6.33/snd_pcm_capture_rewind()]] return result < 0 ? result : 0; } case SNDRV_PCM_IOCTL_FORWARD: { snd_pcm_uframes_t frames; snd_pcm_uframes_t __user *_frames = arg; snd_pcm_sframes_t result; - --[[linux-2.6.33/SNDRV_PCM_IOCTL_FORWARD]] - --[[linux-2.6.33/snd_pcm_uframes_t]] if (get_user(frames, _frames)) return -EFAULT; if (put_user(0, _frames)) return -EFAULT; result = snd_pcm_capture_forward(substream, frames); __put_user(result, _frames); - --[[linux-2.6.33/snd_pcm_capture_forward()]] return result < 0 ? result : 0; } } return snd_pcm_common_ioctl1(file, substream, cmd, arg); - --[[linux-2.6.33/snd_pcm_common_ioctl1()]] } *コメント [#a6a16f23]