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