Hello group, I have a problem...
I run 2.4.21 kernel patched with rtlinux-3.2-pre2 on AMD 486 DX/4-WB CPU, and try to use PC speaker from a user space program with the following code:
void Sound( int hz ) { unsigned long i = 1190000 / hz; outb( 0xb6, 0x43 ); outb( i & 0xff, 0x42 ); outb( (i >> 8) & 0xff, 0x42 ); outb(inb(0x61) | 0x03, 0x61); }
void NoSound(void) { outb(inb(0x61) & 0xFC, 0x61); }
void main(void) { while( 1 ) { Sound(1000); sleep(1); NoSound(); sleep(1); } }
When RTL extension is not loaded, above PC speaker code works fine.
The problem occurs when I load RT extension and run the user space sound test again - after first inb/outb operation to port 0x61 some calls to 'gettimeofday' function (in my other user space test prg) give wrong results.
That means that the difference between time obtained between two gettimeofday calls is negative as in this example: t1 = gettime_by_gettimeofday(); t2 = gettime_by_gettimeofday(); t = t2 - t1; /* 't' is negative here??? */
When 't' happens to be negative timewarp is about 4s.
My guess is that above code somehow manages to confuse the RTL tick counter (something to do with access to port
0x61 that controls 8254 counter).
The same code on Intel Pentium 166 MHz works with no problems.
Any idea why this happens or an explanation of the behaviour would be greatly appreciated.
Best regards, Mario