Posted by
Hemos
on from the looking-in-the-innards dept.
There's a pretty cool article running on Linux.com about the how-to for writing kernel drivers - in this case, the PC speaker. Interesting case and it's interesting to see what's going on in there.
A good portion of his article was over-riding the Scheduler interrupt vector to give control to his driver > 100HZ. Is there any better way to do this, since it seems like this method is a little suspect (And multiple drivers using this technique might not work together.)
I'm developing a driver for a bit of cheap hardware that unloads a high-frequency counter onto the host processor and needs to be serviced at about 30kHZ.
-- This.sig for unofficial government use only. Official use subject to $500 fine.
Rediscovered a 20-year-old Technique
by
dschuetz
·
· Score: 5
This is way cool, and it's coolness is not in the least diminished by the fact that something very much like this was used on my old TRS-80 Model I computer, back in, oh, 1981.
There was no audio (hell, there was barely video) on that machine, and the original data storage medium was cassette tapes. Stored at about 300 baud, or so. The output of the cassette port was about the same +5v / 0v range, and people used the same approach to store data on the tape (I think it's called Frequency Shift Keying, but I'm not sure).
Anyway, people also realized early on that you could hook an audio amplifier to the output, and do some rudimentary sound effects. People played with it more, got some very nicely done 'drivers' (as it were) that were easy to call from BASIC, and, volia!, you've added laserbeam sound effects to your Android Nim program.
Then someone really got good with sound (I think it was Leo Christopherson's Ride of the Valkyries program, but it might have been Dancing Demon, too), with a lot more advanced and cool-sounding effects. Then it got really out of hand when someone figured out how to to speech synthesis. Still, to this day, some of the best speech I've heard from a computer.
And this, ladies and gentlemen, was on a 1.77 MHz Z-80.
This is yet another example of how, with all the advanced hardware we've got today, we've lost sight of how to "do more with less." Everyone could learn from this...
Re:Rediscovered a 20-year-old Technique
by
DragonWyatt
·
· Score: 3
Dude, the C64 (Commodore) was truly advanced. It had an awesome SID chip that could do all these wonderful things, and the machine was only 1mhz (.999082 in the UK b/c 50hz!).
But I'm not here to talk about the C64.
There was a program for the 5.25 disk drive that played "A bicycle built for two" by vibrating the heads at varying frequencies. It was a machine language program downloaded into the drive's 2kb buffer, which redirected the boot (IPL?) routine- the code was downloaded to the drive, then the drive was reset.
Its last task after playing the music was to restore the original boot vector, and reset again!
This was undoubtedly inspired by (written by?!!?) the same guys who would cause old IBM drum disks to walk across the floor.
There was also a hack by which you could place a normal audio casette into the Commodore C2n Datasette drive, and read the varying audio pitches as rudimentary digital data- and output it via the SID chip to play audio tapes. Boy did the quality suck! But you could recognize the tune being played, barely.
-- Don't sweat the petty things. But do pet the sweaty things.
Re:Rediscovered a 20-year-old Technique
by
ozbird
·
· Score: 3
There was no audio (hell, there was barely video) on that machine, and the original data storage medium was cassette tapes. Stored at about 300 baud, or so. The output of the cassette port was about the same +5v / 0v range, and people used the same approach to store data on the tape (I think it's called Frequency Shift Keying, but I'm not sure).
The TRS-80 cassette schematics can be seen here. Unlike the PC speaker output which is a simple square wave (bilevel), the TRS-80 cassette output was trilevel - default was 1V, with 0V and 2V pulses individually generated.
Data output to the cassette was generated as a series of positive and negative pulses approximating a sinewave; from memory, there was a clocking pulse-pair followed by another pulse-pair for "1" or nothing for "0". (I may have misremembered this; there were several utilities that increased the data density on the cassette, and I may be remembering one of these instead.)
Audio sound was generated by manually generating the cassette pulses at given frequencies. Some bright sparks also figured out that you could generate two-voice music by using positive pulses for one voice, and negative pulses for the other. Very neat!
Yes it was supported. Try using the "Covox Speech Thing" or "Disney Sound Source" drivers. They're all simple DACs that used the Dx lines on the parallel port for the data. ISA sound cards worked on the same principle, but were accessed directly on the bus.
I built one of these and it was sweet. It also worked under Windows 3.x.
A Linux driver would be simple as well, if it hasn't already been done.
From the article:
"Suppose that you want to publish a Phd thesis on how to wash clothes using your brand of washing machine. You'd write a sequence of steps starting from:
1) Insert the power cord into the wall socket and switch on the power"
Now, if you happened to be writing a PhD thesis, wouldn't you make 'insert the power cord into the wall socket' and 'switch on the power' two separate methods, possibly expounding for at least half a page as to the meaning of 'switch on the power', which is rather vague - is that the circuit breaker, or is there some power switch on the washer that I haven't seen yet? (hint: there isn't). Granted, a graduate thesis doesn't need to state the obvious as often as undergrad work, but it sure doesn't hurt. Of course, why someone would write a PhD thesis about the operation (rather than the design) of a new washing machine is beyond me... that might be better covered in the patent;-)
--
--
"It's tough to be bilingual when you get hit in the head."
Re:Excellent Books from guess who
by
selectspec
·
· Score: 3
Both have sections "anticipating 2.4" which give you an idea of where to look for changes. The real problem is going to be with the next major revision, where jiffies might get tossed, the I/O api gets a new face. However, for someone without a clue on how to write a kernel driver, both books are a good start.
--
Someone you trust is one of us.
Excellent Books from guess who
by
selectspec
·
· Score: 5
There are 2 awesome books on kernel and driver development from our friends at O'Reilly.
Understanding the Linux Kernel
and
Linux Device Drivers
--
Someone you trust is one of us.
Re:Excellent Books from guess who
by
campgod
·
· Score: 3
If you can wait a (few) month(s), "the second edition (due in June) covers Kernel 2.4 and adds discussions of symmetric multiprocessing (SMP), Universal Service Bus (USB), and some new platforms." (from http://www.oreilly.com/catalog/linuxdrive2/)
No, I don't work for them, but found the book very helpful in writing a driver for the PLX 9050. It gets my newbie seal of approval.
Re:PC Speaker driver...
by
13013dobbs
·
· Score: 4
RIAA found out and sued over it.
--
No replies made to AC posts. Please log in.
Re:The kernel will tell you if anything went wrong
by
andy@petdance.com
·
· Score: 3
well...that's one way of telling you something went wrong....
It's nature's way of telling you in a song. --
Re:Not that there's anything wrong with it...
by
The+Night+Watchman
·
· Score: 5
Are you kidding? There's a HUGE market for PC speaker drivers! Personally, I'm waiting for Linux drivers for (1) dot matrix printers, (2) lightpens, (3) Laserdisc players, and (4) the human appendix. Come on, programmers, let's get coding!:-)
/* Steve */
-- "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of"-TMBG
The kernel will tell you if anything went wrong...
by
djocyko
·
· Score: 4
"The kernel will tell you if anything went wrong. In many cases, it'll reboot the system for you."
well...that's one way of telling you something went wrong....
Why do they think it's about the speaker?
by
Spinality
·
· Score: 5
Quite a few comments below seem to think this article was cited because of providing information about the speaker as a device. Sheesh! Obviously, it was instead seen as interesting because it was a simple example of driver implementation issues, without all the gory complexity of BitBlts or nasty interrupts or odd data structures. It's a simple example, using a hardware component every user already knows.
I at least was happy to see it listed here. I like simple examples.
/rant
-- -- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
Re:He's in India; hardware limited
by
markom
·
· Score: 5
Living in a economically disturbed environment when salaries often range around the price of a decent sound card (or equally fun device) teaches you one rather important lesson in life. Being a young engineer coming from an environment like that (Belgrade, Yugoslavia), taught me to do my best to solve the problems with the only thing I had - my brains. Not my wallet. When I moved out to one economically rather different and technically advanced place (Iceland), my hard time in doing so payed off.
Effort to make working PC speaker kernel driver is not a waste, although it can be solved with a little bit of cash more eleganlty.
Marko.
the sound of a lone keyboard clicking away
by
Cephas+Keken
·
· Score: 3
I am waiting for some genius in the linux community to write a/bin/writekerneldriver alias to vim that types everything in for me and then builds the make files, compiles and installs it, just it time for it to core and take down the system
great... how many ways do we need of sending "beep"?
I remember that I used to have this app for an 8088 that played the complete tonal "William Tell Overture" out of the PC speaker... I wonder what happened to it?
Hiyo Silver... AWAY!!!!
"Titanic was 3hr and 17min long. They could have lost 3hr and 17min from that."
--
IBM had PL/1, with syntax worse than JOSS, And everywhere the language went, it was a total loss...
Re:Not that there's anything wrong with it...
by
RareHeintz
·
· Score: 5
Well, there's always the fact that when you're writing a how-to for a novice audience (and many seasoned programmers would be novices when approaching the task of writing a kernel driver), you write an example that covers the necessary material, and as little else as possible. Doing an AWE64 or a 3Com 10/100 network card or a USB gadget driver might be a neat project, but would also involve a lot of particulars about the manufacturer's hardware that wouldn't have anything to do with what he's trying to teach.
Anyway, it seems a fine approach to me. Between the knowledge in the article, available source code, and appropriate hardware specs, I imagine a determined hacker could start writing his first real device driver with this article as a starting point.
If only my college instructors had taken the time
by
Gruneun
·
· Score: 5
I'd be interested to see this guy as a teacher in a university. To tackle subjects like audio, hardware, and device drivers in one, relatively short article is impressive. To make it sound simple and easy-to-follow is astounding.
If we had more instructors take the time to explain this way, we would have more people stay and graduate in Engineering and Computer Science. This would result in more capable new hires, fewer unfilled positions, less demand for tech people -- Hey, wait a minute! -- get that article down! Where's the/. effect when you need it?
Currently intrested in finding a Linux driver for my Furby... My Tux doll is lonely and needs something new and annoying to kill...
--- My Karma is bigger than your...
------ This sentence no verb
Re:The kernel will tell you if anything went wrong
by
Professor+J+Frink
·
· Score: 3
I recently had a linux box auto-reboot. It was while testing DRI Rage128 acceleration. In the middle of running FlightGear the screen blanked, then it appeared the machine had quietly and cleanly rebooted.
At first I found this amazing, then annoying, then ultimately quite useful.
There's no doubt that eventually I would have crashed X, or the kernel. It might have taken some time, and a lot of effort, and not a little swearing along the way. At least this way I achieved the same success in a minimum of time. I never even had to reach for the reset button.
A good portion of his article was over-riding the Scheduler interrupt vector to give control to his driver > 100HZ. Is there any better way to do this, since it seems like this method is a little suspect (And multiple drivers using this technique might not work together.)
I'm developing a driver for a bit of cheap hardware that unloads a high-frequency counter onto the host processor and needs to be serviced at about 30kHZ.
This
There was no audio (hell, there was barely video) on that machine, and the original data storage medium was cassette tapes. Stored at about 300 baud, or so. The output of the cassette port was about the same +5v / 0v range, and people used the same approach to store data on the tape (I think it's called Frequency Shift Keying, but I'm not sure).
Anyway, people also realized early on that you could hook an audio amplifier to the output, and do some rudimentary sound effects. People played with it more, got some very nicely done 'drivers' (as it were) that were easy to call from BASIC, and, volia!, you've added laserbeam sound effects to your Android Nim program.
Then someone really got good with sound (I think it was Leo Christopherson's Ride of the Valkyries program, but it might have been Dancing Demon, too), with a lot more advanced and cool-sounding effects. Then it got really out of hand when someone figured out how to to speech synthesis. Still, to this day, some of the best speech I've heard from a computer.
And this, ladies and gentlemen, was on a 1.77 MHz Z-80.
This is yet another example of how, with all the advanced hardware we've got today, we've lost sight of how to "do more with less." Everyone could learn from this...
Come on, Savolainen can't be that hard to type... You could even cut'n'paste these days.
Also there has already been one pcspeaker patch for ages - it would've been nice if that had been mentioned.
Other than that, nice article.
-- v --
Yes it was supported. Try using the "Covox Speech Thing" or "Disney Sound Source" drivers. They're all simple DACs that used the Dx lines on the parallel port for the data. ISA sound cards worked on the same principle, but were accessed directly on the bus.
I built one of these and it was sweet. It also worked under Windows 3.x.
A Linux driver would be simple as well, if it hasn't already been done.
From the article:
;-)
"Suppose that you want to publish a Phd thesis on how to wash clothes using your brand of washing machine. You'd write a sequence of steps starting from:
1) Insert the power cord into the wall socket and switch on the power"
Now, if you happened to be writing a PhD thesis, wouldn't you make 'insert the power cord into the wall socket' and 'switch on the power' two separate methods, possibly expounding for at least half a page as to the meaning of 'switch on the power', which is rather vague - is that the circuit breaker, or is there some power switch on the washer that I haven't seen yet? (hint: there isn't). Granted, a graduate thesis doesn't need to state the obvious as often as undergrad work, but it sure doesn't hurt. Of course, why someone would write a PhD thesis about the operation (rather than the design) of a new washing machine is beyond me... that might be better covered in the patent
--
"It's tough to be bilingual when you get hit in the head."
Both have sections "anticipating 2.4" which give you an idea of where to look for changes. The real problem is going to be with the next major revision, where jiffies might get tossed, the I/O api gets a new face. However, for someone without a clue on how to write a kernel driver, both books are a good start.
Someone you trust is one of us.
There are 2 awesome books on kernel and driver development from our friends at O'Reilly.
Understanding the Linux Kernel
and
Linux Device Drivers
Someone you trust is one of us.
RIAA found out and sued over it.
No replies made to AC posts. Please log in.
It's nature's way of telling you in a song.
--
Are you kidding? There's a HUGE market for PC speaker drivers! Personally, I'm waiting for Linux drivers for (1) dot matrix printers, (2) lightpens, (3) Laserdisc players, and (4) the human appendix. Come on, programmers, let's get coding! :-)
/* Steve */
"Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of"-TMBG
well...that's one way of telling you something went wrong....
Quite a few comments below seem to think this article was cited because of providing information about the speaker as a device. Sheesh! Obviously, it was instead seen as interesting because it was a simple example of driver implementation issues, without all the gory complexity of BitBlts or nasty interrupts or odd data structures. It's a simple example, using a hardware component every user already knows.
I at least was happy to see it listed here. I like simple examples.
/rant
-- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
Living in a economically disturbed environment when salaries often range around the price of a decent sound card (or equally fun device) teaches you one rather important lesson in life. Being a young engineer coming from an environment like that (Belgrade, Yugoslavia), taught me to do my best to solve the problems with the only thing I had - my brains. Not my wallet. When I moved out to one economically rather different and technically advanced place (Iceland), my hard time in doing so payed off.
Effort to make working PC speaker kernel driver is not a waste, although it can be solved with a little bit of cash more eleganlty.
Marko.
I am waiting for some genius in the linux community to write a /bin/writekerneldriver alias to vim that types everything in for me and then builds the make files, compiles and installs it, just it time for it to core and take down the system
Guttermouth is a really good band.
great... how many ways do we need of sending "beep"?
I remember that I used to have this app for an 8088 that played the complete tonal "William Tell Overture" out of the PC speaker... I wonder what happened to it?
Hiyo Silver... AWAY!!!!
"Titanic was 3hr and 17min long. They could have lost 3hr and 17min from that."
IBM had PL/1, with syntax worse than JOSS,
And everywhere the language went, it was a total loss...
Anyway, it seems a fine approach to me. Between the knowledge in the article, available source code, and appropriate hardware specs, I imagine a determined hacker could start writing his first real device driver with this article as a starting point.
OK,
- B
--
http://www.bradheintz.com/
- updated
I'd be interested to see this guy as a teacher in a university. To tackle subjects like audio, hardware, and device drivers in one, relatively short article is impressive. To make it sound simple and easy-to-follow is astounding.
/. effect when you need it?
If we had more instructors take the time to explain this way, we would have more people stay and graduate in Engineering and Computer Science. This would result in more capable new hires, fewer unfilled positions, less demand for tech people -- Hey, wait a minute! -- get that article down! Where's the
Currently intrested in finding a Linux driver for my Furby... My Tux doll is lonely and needs something new and annoying to kill...
--- My Karma is bigger than your...
------ This sentence no verb
At first I found this amazing, then annoying, then ultimately quite useful.
There's no doubt that eventually I would have crashed X, or the kernel. It might have taken some time, and a lot of effort, and not a little swearing along the way. At least this way I achieved the same success in a minimum of time. I never even had to reach for the reset button.
A new feature for 2.5 perhaps...
"Don't get mad, get a monkey!"