int _oss_ioctl(int fd, unsigned long com, ...) { va_list ap; void *argp; va_start(ap, com); argp = va_arg(ap, void *); va_end(ap); if (IOCGROUP(com) == 'P') return audio_ioctl(fd, com, argp); else if (IOCGROUP(com) == 'M') return mixer_ioctl(fd, com, argp); else return ioctl(fd, com, argp); }
static int jornada56x_audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) { long val = 0; int ret = 0; switch (cmd) { case SNDCTL_DSP_STEREO: ret = get_user(val, (int *) arg); if (ret) break; /* the UDA1341 is stereo only */ ret = (val == 0) ? -EINVAL : 1; ret = put_user(ret, (int *) arg); break; case SNDCTL_DSP_CHANNELS: case SOUND_PCM_READ_CHANNELS: /* the UDA1341 is stereo only */ ret = put_user(2, (long *) arg); break; case SNDCTL_DSP_SPEED: ret = get_user(val, (long *) arg); if (ret) break; jornada56x_set_audio_rate(val); /* fall through */ case SOUND_PCM_READ_RATE: ret = put_user(val, (long *) arg); /* we assume that jornada56x_set_audio_rate() is always OK */ break; case SNDCTL_DSP_SETFMT: case SNDCTL_DSP_GETFMTS: /* we can do 16-bit only */ ret = put_user(AFMT_S16_LE, (long *) arg); break; default: /* Maybe this is meant for the mixer (as per OSS Docs) */ ret = mixer_ioctl(inode, file, cmd, arg); break; } return ret; }
static int davinci_aic33_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) { long val; int ret = 0; DPRINTK(" 0x%08x\n", cmd); /* * These are platform dependent ioctls which are not handled by the * generic davinci-audio module. */ switch (cmd) { case SNDCTL_DSP_STEREO: ret = get_user(val, (int *)arg); if (ret) return ret; /* the Davinci supports AIC33 as stereo, mono on stereo jack */ ret = (val == 0) ? -EINVAL : 1; return put_user(ret, (int *)arg); case SNDCTL_DSP_CHANNELS: ret = get_user(val, (long *)arg); if (ret) { DPRINTK("get_user failed\n"); break; } if (val == STEREO) { DPRINTK("Driver support for AIC33 as stereo\n"); aic33_local.nochan = STEREO; davinci_set_mono_stereo(aic33_local.nochan); } else if (val == MONO) { DPRINTK("Driver support for AIC33 as mono\n"); aic33_local.nochan = MONO; davinci_set_mono_stereo(aic33_local.nochan); } else { DPRINTK ("Driver support for AIC33 as stereo/mono mode\n"); return -EPERM; } case SOUND_PCM_READ_CHANNELS: /* the Davinci supports AIC33 as stereo, mono on stereo jack */ if (aic33_local.nochan == MONO) return put_user(MONO, (long *)arg); else return put_user(STEREO, (long *)arg); case SNDCTL_DSP_SPEED: ret = get_user(val, (long *)arg); if (ret) { DPRINTK("get_user failed\n"); break; } ret = davinci_set_samplerate(val); if (ret) { DPRINTK("davinci_set_samplerate failed\n"); break; } /* fall through */ case SOUND_PCM_READ_RATE: return put_user(audio_samplerate, (long *)arg); case SNDCTL_DSP_SETFMT: /* set Format */ ret = get_user(val, (long *)arg); if (ret) { DPRINTK("get_user failed\n"); break; } if (val != AFMT_S16_LE) { DPRINTK ("Driver supports only AFMT_S16_LE audio format\n"); return -EPERM; } case SOUND_PCM_READ_BITS: case SNDCTL_DSP_GETFMTS: /* we can do 16-bit only */ return put_user(AFMT_S16_LE, (long *)arg); default: /* Maybe this is meant for the mixer (As per OSS Docs) */ return mixer_ioctl(inode, file, cmd, arg); } return ret; }