i386/113540: decrease i8254 calibration precision to make it work with Xbox, remove warnings

Bruce Evans brde at optusnet.com.au
Mon Jun 11 12:13:36 UTC 2007


On Mon, 11 Jun 2007, Ed Schouten wrote:

> * Bruce Evans <brde at optusnet.com.au> wrote:
>>  On Sun, 10 Jun 2007, Ed Schouten wrote:
>> [...]
>>> - It decreases the precision of the timer (by default disabled) timer
>>>  calibration code from 1% to 10%; this is needed because the Xbox clock
>>>  is 6% off.
>>
>>  Is it only 6% off because the default is 6% off?  The error margin is
>>  supposed to be just a sanity check, but if the i8254 clock frequency is
>>  not required to be nearly 1193182 then this frequency can be almost
>>  anything in theory and no sanity check works.
>
> On all Xboxes it's 6% off.

I mean, is it always different from the current default of 1193182 by about
-6%.  A 6% difference depending on the machine sub-type would be surprising.

>>> - It removes the hardcoded Xbox timer value from the Xbox configuration
>>>  file and enables timer calibration.
>>
>>  I hope to remove the timer calibration.  It was mainly for RTC calibration,
>>  ...
>
> So what do you think about this patch:
>
> 	http://g-rave.nl/junk/freebsd-xbox-clock.diff
>
> We don't depend on the calibration code anymore, but just set the new
> standard timer frequency in i8254_init(). It doesn't touch any existing
> code outside ifdef's.

That's much simpler.

Grep for TIMER_FREQ and values like 119 and 149 in the kernel and in
utilities like kbdcontrol and you will find a few more problems.  The
variable is supposed to be used, but some places use the macro or
worse.  The spkr driver seems to do everything correctly, but everything
else has messes converting from "pitch"es to periods in i8254 timer
ticks.  The magic numbers here are:

- 119 = first few digits of 1193182.
   1193182 may be found in kbdcontrol.c.
- 149 = first few digits of 1491 = the period in 1193182-Hz timer ticks for
         the intended syscons default bell frequncy of BELL_PITCH = 800 Hz
       = the frequency that results from not converting BELL_PITCH to
 	1193182-Hz timer ticks.
   1491 may be found miscalculated as 1493 in the dead pcvt driver.

Bruce


More information about the freebsd-i386 mailing list