Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Feb 2000 18:41:00 +0000
From:      Mark Ovens <mark@ukug.uk.freebsd.org>
To:        stable@freebsd.org
Cc:        hackers@freebsd.org
Subject:   Bug in ioctl() [Was: Help needed with ioctl() calls]
Message-ID:  <20000219184059.A327@marder-1>
In-Reply-To: <20000219145518.C328@marder-1>
References:  <20000219145518.C328@marder-1>

next in thread | previous in thread | raw e-mail | index | archive | help
Firstly, the cross-post to -hackers seems appropriate but
my apologies if it isn't.

I am now certain that there is a bug in ioctl() (at least for
setting the mixer).

This started out as an attempt to fix a bug in xmms, but making a
debug version of mixer(8) showed it to be affected the same way. The
following illustrates the problem, notice that the pcm is nearly
always set to a value different to that which is passed on the
command-line.

I haven't submitted a PR for this as I'm not 100% certain how for
something like this.

% mixer pcm
Mixer pcm      is currently set to  91:91
% mixer pcm 90:90
Setting the mixer pcm to 90:90.
% mixer pcm
Mixer pcm      is currently set to  91:91
% mixer pcm 88:88
Setting the mixer pcm to 88:88.
% mixer pcm
Mixer pcm      is currently set to  88:88
% mixer pcm 86:86
Setting the mixer pcm to 86:86.
% mixer pcm
Mixer pcm      is currently set to  88:88
% mixer pcm 84:84
Setting the mixer pcm to 84:84.
% mixer pcm
Mixer pcm      is currently set to  85:85
% 




On Sat, Feb 19, 2000 at 02:55:18PM +0000, Mark Ovens wrote:
> # uname -a
> FreeBSD marder-1 3.4-STABLE FreeBSD 3.4-STABLE #0:
> Fri Feb 18 18:14:43 GMT 2000
> root@marder-1:/usr/src/sys/compile/MARDER-1  i386
> 
> 
> I'm trying to debug a problem in the xmms port whereby the volume
> doesn't get set correctly.
> 
> It goes wrong after the ioctl() call to set the volume in /dev/mixer.
> 
> >From /usr/include/machine/soundcard.h:
> 
> #define SOUND_MIXER_PCM         4
> #define MIXER_WRITE(dev)                _IOWR('M', dev, int)
> #define SOUND_MIXER_WRITE_PCM           MIXER_WRITE(SOUND_MIXER_PCM)  
> 
> and the code in question is
> 
> 	int fd, v, l, r;
> 
> 	fd = open(devname, O_RDONLY);
> 
> 	l = 90; r = 90;
> 
> 	v = (r << 8) | l;   /* v == 23130 */
> 
> 	ioctl(fd, SOUND_MIXER_WRITE_PCM, &v);
> 
> 	/* now v == 23387, which is (91 << 8) | 91 */
> 
> Before the ioctl() call the output from mixer(8) was:
> 
> 	Mixer pcm      is currently set to  88:88
> 
> and after:
> 	
> 	Mixer pcm      is currently set to  91:91
> 
> when it should be 90:90
> 
> The appears to be a bug in ioctl(), but is it?
> 
> /dev/mixer is being opened read-only but we appear to be writing to it
> OK, albeit the wrong values.
> 
> I'm getting a bit out of my depth here so a bit of help would be
> appreciated. Is this a bug in ioctl()? If not, any suggestions as to
> what I should do now to find the cause of the problem?
> 
> Thanks.
> 
> -- 
> 	Microsoft: Where do you want to go today?
> 	Linux:     Where do you want to go tomorrow?
> 	BSD:       Are you guys coming, or what?
> 			              -Poster at LinuxWorld 2000
> ________________________________________________________________
>       FreeBSD - The Power To Serve http://www.freebsd.org
>       My Webpage http://ukug.uk.freebsd.org/~mark/
> mailto:mark@ukug.uk.freebsd.org             http://www.radan.com
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-stable" in the body of the message

-- 
	Microsoft: Where do you want to go today?
	Linux:     Where do you want to go tomorrow?
	BSD:       Are you guys coming, or what?
			              -Poster at LinuxWorld 2000
________________________________________________________________
      FreeBSD - The Power To Serve http://www.freebsd.org
      My Webpage http://ukug.uk.freebsd.org/~mark/
mailto:mark@ukug.uk.freebsd.org             http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000219184059.A327>