[PARPORT] Parallel Port Midi driver?

From: (saxboy@unisoft.co.kr)
Date: Mon Jan 14 2002 - 20:37:50 EST

  • Next message: Tom Perkins: "Re: [PARPORT] Parallel Port Midi driver?"

    I am trying to write my own device driver for Egosys miditerminal 4140,
    which is an midi interface via parallel port.
    As I'm really newbie in programming in kernel mode and writing device
    drivers, the first step I could imagine was
    to make a working userland drivers.
    According to the manual, it needs ECP or EPP mode to work and finds out
    its own IRQ. I looked up in the M$ windows control panel
    to see what DMA, io addr, IRQ it uses -- no tab in its driver section.
    The first stuff I could imagine was to load the parport.o anyway. I
    read /usr/src/linux/Documentation/parport.txt and followed the steps.
    After loading, I could see no device probed in /proc/sys/dev/parport*

    Ooops, I'm stuck. So I did write a sample (& simple ) userland program
    to read raw parport devices. The code follows.

    --- < snip > -----------------

    #include <stdio.h>
    #include <linux/ppdev.h>
    #include <linux/parport.h>
    #include <sys/types.h>
    #include <fcntl.h>
    #include <sys/stat.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>

    main(int argc, char **argv)

           int fd, mode;
            int negotiate_first=0;
            struct pollfd pfd;
            int pollret=0;
            char rchar=0;
            int nread=0;

            if ( argc!=2 ) {
                    printf("Usage: %s [dev]\n", argv[0]);

           fd = open (argv[1], O_RDONLY | O_NOCTTY);
           if ( fd < 0 ) {
           if ( ioctl (fd, PPCLAIM) ) {
           mode = IEEE1284_MODE_ECP;
           if (negotiate_first ) {
             if (ioctl (fd, PPNEGOT, &mode) ) {
             /* no need for PPSETMODE */
           } else {
             if ( ioctl (fd, PPSETMODE, &mode) ) {

           for ( ; ;) {
                    struct pollfd pfd;
                    pfd.fd = fd;
                    pfd.events = POLLIN;

                    if ( poll(&pfd, 1, 1000 ) > 0 ) {
                                   while ( (nread=read(fd, &rchar, 1)) > 0 )
                                    printf("%x ", rchar);

           /* Okay, finished */
           ioctl (fd, PPRELEASE);
           close (fd);

    --- < snip > -----------------

    OK. I ran the program as root, tried EPP and ECP for all the devices (
    parport{0,1,2,3} ) while sending some midi input signals through my
    keyboard. All I could see was just <dot>s ! Nothing was coming in to
    the raw device.

    Ooops, I'm really stuck. I have no idea what to try next. I'm really
    wondering what's going on. Please help me.
    And if you have any idea of what parallel-port midi device should look
    like, It'll be great!

    Thanks in advance.

    -- To unsubscribe, send mail to: linux-parport-request@torque.net --
    -- with the single word "unsubscribe" in the body of the message. --

    This archive was generated by hypermail 2b29 : Mon Jan 14 2002 - 20:57:46 EST