svn commit: r203860 - stable/8/sys/dev/sound/pcm
Alexander Motin
mav at FreeBSD.org
Sun Feb 14 11:53:51 UTC 2010
Author: mav
Date: Sun Feb 14 11:53:51 2010
New Revision: 203860
URL: http://svn.freebsd.org/changeset/base/203860
Log:
MFC r202150, r202170:
Make OSS_GETVERSION ioctl really work. It has 'M' group, not 'P',
as different nearby ones, and was grabbed by MIXER_xxx() handler.
While there, replace '(cmd & MIXER_xxx(0)) == MIXER_xxx(0)' expressions
with more correct '(cmd & ~0xff) == MIXER_xxx(0)'. Use of bit operations
to compare numeric fields doesn't looks sane.
Modified:
stable/8/sys/dev/sound/pcm/dsp.c
stable/8/sys/dev/sound/pcm/mixer.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
stable/8/sys/netinet/ (props changed)
Modified: stable/8/sys/dev/sound/pcm/dsp.c
==============================================================================
--- stable/8/sys/dev/sound/pcm/dsp.c Sun Feb 14 11:04:52 2010 (r203859)
+++ stable/8/sys/dev/sound/pcm/dsp.c Sun Feb 14 11:53:51 2010 (r203860)
@@ -1003,7 +1003,7 @@ dsp_ioctl_channel(struct cdev *dev, stru
if (volch != NULL &&
((j == SOUND_MIXER_PCM && volch->direction == PCMDIR_PLAY) ||
(j == SOUND_MIXER_RECLEV && volch->direction == PCMDIR_REC))) {
- if ((cmd & MIXER_WRITE(0)) == MIXER_WRITE(0)) {
+ if ((cmd & ~0xff) == MIXER_WRITE(0)) {
int left, right, center;
left = *(int *)arg & 0x7f;
@@ -1011,7 +1011,7 @@ dsp_ioctl_channel(struct cdev *dev, stru
center = (left + right) >> 1;
chn_setvolume_multi(volch, SND_VOL_C_PCM, left, right,
center);
- } else if ((cmd & MIXER_READ(0)) == MIXER_READ(0)) {
+ } else if ((cmd & ~0xff) == MIXER_READ(0)) {
*(int *)arg = CHN_GETVOLUME(volch,
SND_VOL_C_PCM, SND_CHN_T_FL);
*(int *)arg |= CHN_GETVOLUME(volch,
@@ -1023,7 +1023,7 @@ dsp_ioctl_channel(struct cdev *dev, stru
case SOUND_MIXER_DEVMASK:
case SOUND_MIXER_CAPS:
case SOUND_MIXER_STEREODEVS:
- if ((cmd & MIXER_READ(0)) == MIXER_READ(0)) {
+ if ((cmd & ~0xff) == MIXER_READ(0)) {
*(int *)arg = 0;
if (rdch != NULL)
*(int *)arg |= SOUND_MASK_RECLEV;
@@ -1034,7 +1034,7 @@ dsp_ioctl_channel(struct cdev *dev, stru
break;
case SOUND_MIXER_RECMASK:
case SOUND_MIXER_RECSRC:
- if ((cmd & MIXER_READ(0)) == MIXER_READ(0))
+ if ((cmd & ~0xff) == MIXER_READ(0))
*(int *)arg = 0;
ret = 0;
break;
@@ -1069,6 +1069,10 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd
chn = NULL;
if (IOCGROUP(cmd) == 'M') {
+ if (cmd == OSS_GETVERSION) {
+ *arg_i = SOUND_VERSION;
+ return (0);
+ }
ret = dsp_ioctl_channel(i_dev, PCM_VOLCH(i_dev), cmd, arg);
if (ret != -1) {
PCM_GIANT_EXIT(d);
Modified: stable/8/sys/dev/sound/pcm/mixer.c
==============================================================================
--- stable/8/sys/dev/sound/pcm/mixer.c Sun Feb 14 11:04:52 2010 (r203859)
+++ stable/8/sys/dev/sound/pcm/mixer.c Sun Feb 14 11:53:51 2010 (r203860)
@@ -1136,7 +1136,7 @@ mixer_ioctl_channel(struct cdev *dev, u_
if ((j == SOUND_MIXER_DEVMASK || j == SOUND_MIXER_CAPS ||
j == SOUND_MIXER_STEREODEVS) &&
- (cmd & MIXER_READ(0)) == MIXER_READ(0)) {
+ (cmd & ~0xff) == MIXER_READ(0)) {
snd_mtxlock(m->lock);
*(int *)arg = mix_getdevs(m);
snd_mtxunlock(m->lock);
@@ -1154,14 +1154,14 @@ mixer_ioctl_channel_proc:
KASSERT(c != NULL, ("%s(): NULL channel", __func__));
CHN_LOCKASSERT(c);
- if ((cmd & MIXER_WRITE(0)) == MIXER_WRITE(0)) {
+ if ((cmd & ~0xff) == MIXER_WRITE(0)) {
int left, right, center;
left = *(int *)arg & 0x7f;
right = (*(int *)arg >> 8) & 0x7f;
center = (left + right) >> 1;
chn_setvolume_multi(c, SND_VOL_C_PCM, left, right, center);
- } else if ((cmd & MIXER_READ(0)) == MIXER_READ(0)) {
+ } else if ((cmd & ~0xff) == MIXER_READ(0)) {
*(int *)arg = CHN_GETVOLUME(c, SND_VOL_C_PCM, SND_CHN_T_FL);
*(int *)arg |=
CHN_GETVOLUME(c, SND_VOL_C_PCM, SND_CHN_T_FR) << 8;
@@ -1214,7 +1214,7 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_lo
struct thread *td, int from)
{
struct snd_mixer *m;
- int ret, *arg_i = (int *)arg;
+ int ret = EINVAL, *arg_i = (int *)arg;
int v = -1, j = cmd & 0xff;
/*
@@ -1248,8 +1248,23 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_lo
snd_mtxunlock(m->lock);
return (EBADF);
}
-
- if ((cmd & MIXER_WRITE(0)) == MIXER_WRITE(0)) {
+ switch (cmd) {
+ case SNDCTL_DSP_GET_RECSRC_NAMES:
+ bcopy((void *)&m->enuminfo, arg, sizeof(oss_mixer_enuminfo));
+ ret = 0;
+ goto done;
+ case SNDCTL_DSP_GET_RECSRC:
+ ret = mixer_get_recroute(m, arg_i);
+ goto done;
+ case SNDCTL_DSP_SET_RECSRC:
+ ret = mixer_set_recroute(m, *arg_i);
+ goto done;
+ case OSS_GETVERSION:
+ *arg_i = SOUND_VERSION;
+ ret = 0;
+ goto done;
+ }
+ if ((cmd & ~0xff) == MIXER_WRITE(0)) {
if (j == SOUND_MIXER_RECSRC)
ret = mixer_setrecsrc(m, *arg_i);
else
@@ -1257,23 +1272,19 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_lo
snd_mtxunlock(m->lock);
return ((ret == 0) ? 0 : ENXIO);
}
-
- if ((cmd & MIXER_READ(0)) == MIXER_READ(0)) {
+ if ((cmd & ~0xff) == MIXER_READ(0)) {
switch (j) {
- case SOUND_MIXER_DEVMASK:
- case SOUND_MIXER_CAPS:
- case SOUND_MIXER_STEREODEVS:
+ case SOUND_MIXER_DEVMASK:
+ case SOUND_MIXER_CAPS:
+ case SOUND_MIXER_STEREODEVS:
v = mix_getdevs(m);
break;
-
- case SOUND_MIXER_RECMASK:
+ case SOUND_MIXER_RECMASK:
v = mix_getrecdevs(m);
break;
-
- case SOUND_MIXER_RECSRC:
+ case SOUND_MIXER_RECSRC:
v = mixer_getrecsrc(m);
break;
-
default:
v = mixer_get(m, j);
}
@@ -1281,29 +1292,8 @@ mixer_ioctl_cmd(struct cdev *i_dev, u_lo
snd_mtxunlock(m->lock);
return ((v != -1) ? 0 : ENXIO);
}
-
- ret = 0;
-
- switch (cmd) {
- case SNDCTL_DSP_GET_RECSRC_NAMES:
- bcopy((void *)&m->enuminfo, arg, sizeof(oss_mixer_enuminfo));
- break;
- case SNDCTL_DSP_GET_RECSRC:
- ret = mixer_get_recroute(m, arg_i);
- break;
- case SNDCTL_DSP_SET_RECSRC:
- ret = mixer_set_recroute(m, *arg_i);
- break;
- case OSS_GETVERSION:
- *arg_i = SOUND_VERSION;
- break;
- default:
- ret = EINVAL;
- break;
- }
-
+done:
snd_mtxunlock(m->lock);
-
return (ret);
}
More information about the svn-src-all
mailing list