Discussion:
Serial MIDI driver for PL011 - as found on BCM2835 hardware
Kim Taylor
2014-10-20 23:40:59 UTC
Permalink
Hi,

I've written a driver for raw MIDI using the PL011. It is obviously
based on the snd-serial-u16550 module, with a couple of improvements:

- I've implemented a drain() callback.

- I've also implemented a half duplex mode based on a timer callback
which was necessary for reliable communication with my eMagic Unitor 8
hardware. (Testing with a serial link to other hardware shows that the
full duplex mode is also working.)

It can be found here:
https://github.com/kmtaylor/rpi_patches/blob/master/serial-pl011.c

If you think it should be included in the ALSA repository, please let me
know what to do next.

Regards,

Kim
Kim Taylor
2014-10-20 23:30:35 UTC
Permalink
Hi,

I've written a driver for raw MIDI using the PL011. It is obviously
based on the snd-serial-u16550 module, with a couple of improvements:

- I've implemented a drain() callback.

- I've also implemented a half duplex mode based on a timer callback
which was necessary for reliable communication with my eMagic Unitor 8
hardware. (Testing with a serial link to other hardware shows that the
full duplex mode is also working.)

It can be found here:
https://github.com/kmtaylor/rpi_patches/blob/master/serial-pl011.c

If you think it should be included in the ALSA repository, please let me
know what to do next.

Regards,

Kim
Daniel Mack
2014-10-21 07:20:16 UTC
Permalink
Hi,

Thanks for sharing this!
Post by Kim Taylor
I've written a driver for raw MIDI using the PL011. It is obviously
- I've implemented a drain() callback.
- I've also implemented a half duplex mode based on a timer callback
which was necessary for reliable communication with my eMagic Unitor 8
hardware. (Testing with a serial link to other hardware shows that the
full duplex mode is also working.)
So I guess you could patch the existing driver to make it work for your
use case, right? I haven't looked at the code in detail, but from what
you describe, that should be possible.
Post by Kim Taylor
https://github.com/kmtaylor/rpi_patches/blob/master/serial-pl011.c
If you think it should be included in the ALSA repository, please let me
know what to do next.
Clone this repository:

git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

and integrate your changes there, then send patches to this mailing
list. Especially if you're doing it for the first time,
Documentation/SubmittingPatches is a good read to omit some typical
pitfalls.


Best regards,
Daniel
Kim Taylor
2014-10-21 22:24:35 UTC
Permalink
Post by Daniel Mack
Hi,
Thanks for sharing this!
Post by Kim Taylor
I've written a driver for raw MIDI using the PL011. It is obviously
- I've implemented a drain() callback.
- I've also implemented a half duplex mode based on a timer callback
which was necessary for reliable communication with my eMagic Unitor 8
hardware. (Testing with a serial link to other hardware shows that the
full duplex mode is also working.)
So I guess you could patch the existing driver to make it work for your
use case, right? I haven't looked at the code in detail, but from what
you describe, that should be possible.
I'm not sure about that. As it uses a different UART chip, there is a
new probe() function, it uses memory mapped I/O, instead of i386
inb/outb, it gathers information from the ARM AMBA bus...

The only things that would remain unchanged are the output_trigger() and
output_write() functions. One possibility might be to abstract out all
read/write operations using function pointers, however, I believe that
the new driver is different enough to constitute a new module.

Or maybe there should be a third module (for example snd-serial-core,
containing any common functions, exporting them to both
snd-serial-u16550 and snd-serial-pl011?
Post by Daniel Mack
Post by Kim Taylor
https://github.com/kmtaylor/rpi_patches/blob/master/serial-pl011.c
If you think it should be included in the ALSA repository, please let me
know what to do next.
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
and integrate your changes there, then send patches to this mailing
list. Especially if you're doing it for the first time,
Documentation/SubmittingPatches is a good read to omit some typical
pitfalls.
Will do. Thanks.
Takashi Iwai
2014-10-22 06:51:38 UTC
Permalink
At Wed, 22 Oct 2014 09:24:35 +1100,
Post by Kim Taylor
Post by Daniel Mack
Hi,
Thanks for sharing this!
Post by Kim Taylor
I've written a driver for raw MIDI using the PL011. It is obviously
- I've implemented a drain() callback.
- I've also implemented a half duplex mode based on a timer callback
which was necessary for reliable communication with my eMagic Unitor 8
hardware. (Testing with a serial link to other hardware shows that the
full duplex mode is also working.)
So I guess you could patch the existing driver to make it work for your
use case, right? I haven't looked at the code in detail, but from what
you describe, that should be possible.
I'm not sure about that. As it uses a different UART chip, there is a
new probe() function, it uses memory mapped I/O, instead of i386
inb/outb, it gathers information from the ARM AMBA bus...
The only things that would remain unchanged are the output_trigger() and
output_write() functions. One possibility might be to abstract out all
read/write operations using function pointers, however, I believe that
the new driver is different enough to constitute a new module.
Or maybe there should be a third module (for example snd-serial-core,
containing any common functions, exporting them to both
snd-serial-u16550 and snd-serial-pl011?
Yes, that sounds good. Of course, it depends on the volume they can
share. If there are so few, no big merit to split to modules. Let's
see.


Takashi

Loading...