From owner-freebsd-hackers Sat Feb 19 10:44:50 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from typhoon.mail.pipex.net (typhoon.mail.pipex.net [158.43.128.27]) by hub.freebsd.org (Postfix) with SMTP id BBC3237B9C0 for ; Sat, 19 Feb 2000 10:44:40 -0800 (PST) (envelope-from mark@dogma.freebsd-uk.eu.org) Received: (qmail 24528 invoked from network); 19 Feb 2000 18:41:43 -0000 Received: from usercp90.uk.uudial.com (HELO marder-1.) (62.188.156.119) by smtp.dial.pipex.com with SMTP; 19 Feb 2000 18:41:43 -0000 Received: (from mark@localhost) by marder-1. (8.9.3/8.9.3) id SAA00531; Sat, 19 Feb 2000 18:41:00 GMT (envelope-from mark) Date: Sat, 19 Feb 2000 18:41:00 +0000 From: Mark Ovens To: stable@freebsd.org Cc: hackers@freebsd.org Subject: Bug in ioctl() [Was: Help needed with ioctl() calls] Message-ID: <20000219184059.A327@marder-1> References: <20000219145518.C328@marder-1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: <20000219145518.C328@marder-1> Organization: Total lack of Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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-hackers" in the body of the message