Much of this week was spent trying to read up on ALSA. But the
documentation is not that good.
* Added prescaling via another ioctl() call. This will now allow us to
obtain really slow PWM signals. Prescaling allows division of the
input clock by powers of 2 i.e. from 2 to 256. This seems like a very
* The PWM10/11 can be optionally controlled using an FCLK of 13K Hz.
This gives more granularity. This has also been setup as an ioctl()
* I was hoping to have something working wrt ALSA by now but haven't
been able to come up with anything. I am still looking for some sample
plugin which I could use as the base and build forward from that.
There is not much in the way of documentation when it comes to writing
external plugins. I am going to need some help with this.
Not ideal, but in addition to the pc speaker ALSA driver, you can
also look at the bluetooth ALSA drivers. The PC speaker ones live
in the kernel and the bluetooth ones live in userland. Both would
be workable examples of how you get the sample data and what you
have to do to push them out to the PWM driver. The drawback with
doing this in userland is you will get degradation if the system
is loaded unless you play games with real time
I would suggest going the taking a stab at the pc speaker driver.
The PC Speaker is basically a PWM driver. Main difference between
what you are doing and what it is doing is that the PWM for the
pcsp driver is done on the Linux system whereas in your case it
is done by the PWM hardware on the OMAP. High level overview -
1. Set up a high resolution timer using the PC timer chip.
2. Set speaker output to high
3. Calculate duty cycle by looking at sample data. Set timer call
back based on duty cycle.
4. On timer callback Set speaker output to low
5. Use the previous info to setup a timer callback
6. ON timer callback, goto 2
What you need to do is -
1. Configure the PWM hardware for a base clock of something like
256*Sample rate. Let's use 8KHz as that is a common one used in
telephony. So that would be 2.048MHz.
2. Look at sample data; let's assume unsigned 8 bit data. Set
hardware PWM trigger (i.e timer capture count) to sample data.
3. Sleep til PWM cycle expires, i.e. 256 counts of of the base
4. Goto 2.
If you look at pcsp_lib.c, it is basically doing the above. The
main "tricky" part is stripping out the PC specific stuff and
massaging Kconfig to compile for the OMAP.