Display Panel Device Driver


In this lab, you will extend the memory driver discussed in the class and write a device driver called panel_driver.c for a virtual LED Display Panel device. Download the LED Panel device for your experiments.


Virtual LED Display Panel

No description has been provided for this image

LED Panel has 10 virtual pins

  • Pins 1 to 6 set the colour of the display.
    Pins 1, 2 set the red colour in four levels
    Pins 3, 4 set the green colour in four levels
    Pins 5, 6 set the blue colour in four levels
  • Pins 7, 8 control the speed of the display in four speeds
  • Pin 9 controls the direction of movement: 0 for R-L and 1 for L-R
  • Pin 10 indicates if the message has changed and needs updating the display
These values are set by writing the appropriate bit sequence into the device. For example, LED Panel will display message in yellow colour moving from L-R with a speed of 3 when the bit sequence written into the device is 1111001011. Keep the Bit 10 as 1 for all the cases in this experiment.

The device also has a buffer of 80 bytes into which the message to be displayed is written. This message can contain any alpha-numberic character (A-Z, a-z, 0-9) and a few other punctuations and symbols (. , ? ! : - '). Write the message into the device after writing the bits to set the pins as desired.


Device Driver

The device driver for the Virtual LED Panel (VLED Panel) follows the same lines as the memory driver done in class. After downloading this file, rename it as panel_driver.c. This link contains code with gaps that you need to fill correctly.

Use this excellent link on Writing device drivers in Lunux: A brief tutorial along with the code given for you to write the necessary driver for the VLED Panel. Remember that you need to work with a buffer of 80 Bytes and not 1 Byte as in the example.

  1. Write the driver functions
    • panel_init()
    • panel_release()
    • panel_open()
    • panel_close()
    • panel_read()
    • panel_write()
  2. Link these functions correctly to the Linux kernel interfaces as discussed in the class using the file_operations structure.
Do not mix kernel and user space variables without understanding their visibilities, i.e. whether they can be accessed at that line in your code.

Compiling and Creating the Device Driver

Follow the steps below to compile your device driver. Once you get it compiled without any errors, please call your TAs or the instructor for testing your device driver.
  1. Open a new terminal.
  2. Login to your file server by typing
    ssh -X 10.5.0.90
  3. List the devices in the /dev directory. You will see the led_panel device.
  4. Use the /dev/led_panel device already created for you. You don't need to use the mknod command to create a new device.
  5. Set the device major number correctly in your device driver code.
  6. Download this Makefile and compile your code typing make. Make sure there are no errors and that a .ko file has been created.
Call your nearest TA or the instructor and take their help in testing your device driver. Note that there will be a few designated machines for testing your code and the demo will be done on those machines.

Testing the Device Driver

Do the following to test the device driver.

  1. Launch the VLED Panel device by typing
    python led_panel.py /dev/led_panel &
    to run it in the background.
  2. Set the VLED Panel to display messages in light PINK colour, (i.e. bright Red + slightly less blue and green colours), at a speed of 2 and from Right-to-Left.
  3. Display the Message Advanced Operating Systems on the VLED Panel.

You are free to try the different options and messages to see how long a message may be displayed or any other tests you can think of.


HAVE FUN!!