BLINKENmini driver
------------------

bmdrv is a kernel module for Linux 2.4 and 2.6 that provides support for the BLINKENmini device. If you do not know what the BLINKENmini device is take a look at http://blinkenmini.schuermans.info/.

bmdrv provides two charcater devices, one for output and one for input. The major device number is 0xB0 (176) and the minor numbers are 0 for the output device and 1 for the input device. The communication with the real BLINKENmini device uses the parallel port. When loading the module, the IO and IRQ settings can be specified.



Compiling (Linux 2.4)
---------------------

Since you are reading this, you already unpacked the archive into a directory. If you have a symbolic link at /usr/src/linux to your current kernel source, you should be able to compile the module:

  make

This should create a file named bmdrv.o. If you get some errors, check the include directories in Makefile. You can copy the file to your module directory if you want:

  su
  mkdir /lib/modules/<kernel-version>/bmdrv
  cp bmdrv.o /lib/modules/<kernel-version>/bmdrv/
  chmod 644 /lib/modules/<kernel-version>/bmdrv/bmdrv.o
  exit



Compiling (Linux 2.6)
---------------------

Since you are reading this, you already unpacked the archive into a directory. If you have a symbolic link at /usr/src/linux to your current kernel source, you should be able to compile the module:

  su
  ./build26
  mkdir /lib/modules/<kernel-version>/bmdrv
  cp bmdrv.ko /lib/modules/<kernel-version>/bmdrv/
  chmod 644 /lib/modules/<kernel-version>/bmdrv/bmdrv.o
  exit



Creating the Devices
--------------------

Now you'll have to create the devices in /dev/:

  su
  cd /dev
  mknod bmdrv.out c 176 0
  mknod bmdrv.in c 176 1
  chmod 666 bmdrv.*
  exit



Loading and Unloading the Driver
--------------------------------

To load the driver you have to find out what the IO and IRQ settings are for your parallel port. On most systems, the first parallel port has got the settings IO=0x378 IRQ=7 and the second one IO=0x278 IRQ=5. You also have to ensure that no other device is using theese resources. (This can be checked with "cat /proc/ioports" and "cat /proc/interrupts".)
Then you can load the module:

  su
  insmod bmdrv.o io=<io-port> irq=<irq-number>
  exit

You can look at your kernel-messages to view the output of bmdrv.

Now you can use the driver, e.g. copy a binary movie to it or dump the pressed keys.

  cp my_movie.bmbm /dev/bmdrv.out

  hexdump /dev/bmdrv.in

To unload the driver just remove the module:

  su
  rmmod bmdrv
  exit



Output Device
-------------

When writing data to /dev/bmdrv.out, the data is expected to be in the bmbm-format. This format consists of one or more frames directly behind each other. A frame has got the following format:

<frame> = <size-x><size-y><row>...<row><delay> //size-y times row <row>
<row> = <pixel>...<pixel> //size-x times <pixel>
<size-x> = the width of the frame in pixels as unsigned char
<size-y> = the height of the frame in pixels as unsigned char
<pixel> = the greyscale value of that pixel as unsigned char, 0x00 dark, 0xFF full on
<delay> = the time to hold execution after displaying this frame in steps of 5ms as unsigned char

When reading from /dev/bmdrv.out, the read-function returns always 0.



Input Device
------------

When writing to /dev/bmdrv.in, all data is written and disappears (like writing to /dev/null).

When reading from /dev/bmdrv.in the function never blocks, if no data is availible 0 is returned by the read-function. The data read consists of 4-byte blocks, each block corresponds to a key-press or a key-release, but it is not ensured that only complete blocks are read.

<block>=<sync><press><controller><key>
<sync>=0xFF as unsigned char
<press>=0x00 is key was released or 0x01 if key was pressed as unsigned char
<controller>=number of the controller as unsigned char
<key>=number of the key as unsigned char

