RTLinux & PC Speaker from user space?

RTLinux & PC Speaker from user space?

Post by Mile Blento » Fri, 15 Oct 2004 22:17:34



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

 
 
 

1. PC-Speaker driver& Linux- HELP- _PLEASE!!!_

Hi there,
I've been trying to configure my kernel to make use of the pcsndrv-0.7
driver (driver for the PC-Speaker w/out soundcard) - I began at noon,
and it's almost midnight- not only does the driver still not work,
but I honestly think I'm about to go insane...
The problem is this, the pcsndrv-0.7 package (obtained from sunsite.unc.edu)
consists of some code plus patches against the 1.1.35 kernel.
I've obtained the 1.1.35 sources, and am able to patch it without
problems. However, because I'm running the show on a laptop (Thinkpad 500),
I need to be able to patch up to at least 1.1.47 so as to be able
to make use of my PCMCIA driver & modem. With the soundriver patches
installed, only patches through 1.1.38 can be applied successfully, and
I start getting patch rejections begining with patch39 (the problem
file is linux/init/main.c). Is there a way around this? How does one
normally apply non-standard patches in concert with standard distribution
patches?

Thanks much in advance- in the meanwhile, I'll go beat my head against
a wall...

2. Understanding SYNCPPP

3. Fixed Address Spaces in RTLinux

4. mailx sleeps

5. Can PC BIOS Values Be Accessed In User Space?

6. Can Win95 and Linux exist together?

7. How to implement RTLinux on PC?

8. Warning! -- SONY SUBSTANDARD SERVICE

9. Kernel space to user space

10. exchange data from user space to kernel space

11. kernel space access to user space functions

12. Problem mapping PCI memory space to user space

13. Kernel space <-> User space