Commit 54fe8674 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Jaroslav Kysela <perex@suse.cz>

ALSA<-OSS emulation
- added OSS_ALSAEMULVER ioctl
- cleanups for put_user()
parent 60f288ae
......@@ -30,6 +30,8 @@
#include <sound/mixer_oss.h>
#include <linux/soundcard.h>
#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
MODULE_DESCRIPTION("Mixer OSS emulation for ALSA.");
MODULE_LICENSE("GPL");
......@@ -306,34 +308,36 @@ static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd,
tmp = snd_mixer_oss_set_recsrc(fmixer, tmp);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
case OSS_GETVERSION:
return put_user(SNDRV_OSS_VERSION, (int *) arg);
case OSS_ALSAEMULVER:
return put_user(1, (int *) arg);
case SOUND_MIXER_READ_DEVMASK:
tmp = snd_mixer_oss_devmask(fmixer);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
case SOUND_MIXER_READ_STEREODEVS:
tmp = snd_mixer_oss_stereodevs(fmixer);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
case SOUND_MIXER_READ_RECMASK:
tmp = snd_mixer_oss_recmask(fmixer);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
case SOUND_MIXER_READ_CAPS:
tmp = snd_mixer_oss_caps(fmixer);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
case SOUND_MIXER_READ_RECSRC:
tmp = snd_mixer_oss_get_recsrc(fmixer);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
}
}
if (cmd & SIOC_IN) {
......@@ -342,12 +346,12 @@ static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd,
tmp = snd_mixer_oss_set_volume(fmixer, cmd & 0xff, tmp);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
} else if (cmd & SIOC_OUT) {
tmp = snd_mixer_oss_get_volume(fmixer, cmd & 0xff);
if (tmp < 0)
return tmp;
return put_user(tmp, (int *)arg) ? -EFAULT : 0;
return put_user(tmp, (int *)arg);
}
return -ENXIO;
}
......
......@@ -40,6 +40,8 @@
#include <linux/soundcard.h>
#include <sound/initval.h>
#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
static int dsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 0};
static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
static int nonblock_open;
......@@ -1871,7 +1873,9 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
pcm_oss_file = snd_magic_cast(snd_pcm_oss_file_t, file->private_data, return -ENXIO);
if (cmd == OSS_GETVERSION)
return put_user(SNDRV_OSS_VERSION, (int *)arg) ? -EFAULT : 0;
return put_user(SNDRV_OSS_VERSION, (int *)arg);
if (cmd == OSS_ALSAEMULVER)
return put_user(1, (int *)arg);
#if defined(CONFIG_SND_MIXER_OSS) || (defined(MODULE) && defined(CONFIG_SND_MIXER_OSS_MODULE))
if (((cmd >> 8) & 0xff) == 'M') { /* mixer ioctl - for OSS compatibility */
snd_pcm_substream_t *substream;
......@@ -1900,48 +1904,48 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
return -EFAULT;
if ((res = snd_pcm_oss_set_rate(pcm_oss_file, res))<0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SOUND_PCM_READ_RATE:
res = snd_pcm_oss_get_rate(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_STEREO:
if (get_user(res, (int *)arg))
return -EFAULT;
res = res > 0 ? 2 : 1;
if ((res = snd_pcm_oss_set_channels(pcm_oss_file, res)) < 0)
return res;
return put_user(--res, (int *)arg) ? -EFAULT : 0;
return put_user(--res, (int *)arg);
case SNDCTL_DSP_GETBLKSIZE:
res = snd_pcm_oss_get_block_size(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_SETFMT:
if (get_user(res, (int *)arg))
return -EFAULT;
res = snd_pcm_oss_set_format(pcm_oss_file, res);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SOUND_PCM_READ_BITS:
res = snd_pcm_oss_get_format(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_CHANNELS:
if (get_user(res, (int *)arg))
return -EFAULT;
res = snd_pcm_oss_set_channels(pcm_oss_file, res);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SOUND_PCM_READ_CHANNELS:
res = snd_pcm_oss_get_channels(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SOUND_PCM_WRITE_FILTER:
case SOUND_PCM_READ_FILTER:
return -EIO;
......@@ -1953,7 +1957,7 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
res = snd_pcm_oss_set_subdivide(pcm_oss_file, res);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_SETFRAGMENT:
if (get_user(res, (int *)arg))
return -EFAULT;
......@@ -1962,7 +1966,7 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
res = snd_pcm_oss_get_formats(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_GETOSPACE:
case SNDCTL_DSP_GETISPACE:
return snd_pcm_oss_get_space(pcm_oss_file,
......@@ -1975,12 +1979,12 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
res = snd_pcm_oss_get_caps(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_GETTRIGGER:
res = snd_pcm_oss_get_trigger(pcm_oss_file);
if (res < 0)
return res;
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_SETTRIGGER:
if (get_user(res, (int *)arg))
return -EFAULT;
......@@ -2011,7 +2015,7 @@ static int snd_pcm_oss_ioctl(struct inode *inode, struct file *file,
put_user(0, (int *)arg);
return res;
}
return put_user(res, (int *)arg) ? -EFAULT : 0;
return put_user(res, (int *)arg);
case SNDCTL_DSP_PROFILE:
return 0; /* silently ignore */
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment