Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jun 2004 05:50:32 GMT
From:      "Jukka A. Ukkonen" <Jukka.Ukkonen@mawit.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/67995: Morse plays beeps 10 times faster than it should.
Message-ID:  <200406160550.i5G5oW43088085@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/67995; it has been noted by GNATS.

From: "Jukka A. Ukkonen" <Jukka.Ukkonen@mawit.com>
To: freebsd-gnats-submit@FreeBSD.org, jau@iki.fi
Cc:  
Subject: Re: misc/67995: Morse plays beeps 10 times faster than it should.
Date: Wed, 16 Jun 2004 08:46:09 +0300

 In fact there could be a better fix, because it seems the speaker ioctl()
 interface is depending on the system HZ value. We just fetch the real HZ
 value from the kernel and use that as the multiplier for the speaker ioctl()
 duration field.
 This became sort of a lengthy patch for a small thing, because the
 system does not provide HZ as part of the standard API.
 
 	// jau
 
 
 --- morse.c.orig	Wed Jun 16 07:26:18 2004
 +++ morse.c	Wed Jun 16 08:32:37 2004
 @@ -67,6 +67,33 @@
   #include <machine/speaker.h>
   #endif
 
 +struct clockrate {
 +    unsigned	hz;
 +    unsigned	tick;
 +    unsigned	tickadj;
 +    unsigned	stathz;
 +    unsigned	profhz;
 +};
 +
 +_HZ ()
 +{
 +    struct clockrate	rates;
 +    size_t		bufsize = sizeof (rates);
 +    int			ret;
 +
 +    ret = sysctlbyname ("kern.clockrate",
 +			(void *) &rates, &bufsize, NULL, 0);
 +
 +    if (ret < 0)
 +	return (100);	/* Wild guess. */
 +
 +    return (rates.hz);
 +}
 +
 +static unsigned	    _hz;
 +
 +#define	HZ  (! _hz ? (_hz = _HZ ()) : _hz)
 +
   struct morsetab {
   	char            inchar;
   	char           *morse;
 @@ -374,7 +401,7 @@
   		dot_clock = 1 / dot_clock;	/* duration of a dot */
   		dot_clock = dot_clock / 2;	/* dot_clock runs at twice */
   						/* the dot rate */
 -		dot_clock = dot_clock * 100;	/* scale for ioctl */
 +		dot_clock = dot_clock * HZ;	/* scale for ioctl */
   	}
 
   	argc -= optind;



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