Display Panel Device Driver


In this lab, you will extend the memory driver discussed in the class and write a device driver 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. While the earlier driver used only 1 byte of storage, the current driver needs 80 bytes. Name this device driver VLED_Panel drive.

  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 and find a suitable major number for the VLED_Panel device.
  4. Set the device major number correctly in your device driver code.
  5. Download this Makefile; edit the first line to your device driver file name 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.

Do the following once you are given a terminal in which you have super user access.

  1. Create the device interface in the same directory as your code using mknod command. Note that this is different from what was done in the class. We are NOT creating the device in /dev directory.
  2. Change the device permissions and make it writable for all users.
  3. Test your device driver by doing the following
    • insmod <your .ko file name>
    • cat > <your device file name>
      Hello, World!
      ^d
    • more <your device file name>
    You should be able to see the phrase, Hello, World! displayed on the screen.
    If you don't see it, there is an error in your device driver or the device file name. Check everything, if necessary go back to your computer, edit and recompile your source code and try again.
Once everything is OK, or the TAs tell you to go ahead, move to the next section.

Testing the Device Driver

Do the following to test the device driver.

  1. Launch the VLED Panel device by typing
    python3 led_panel.py <device file name> &
    to run it in the background.
  2. Set the VLED Panel to display messages in MAGENTA colour, (i.e. bright Red + bright Blue), at a speed of 2 and from Right-to-Left. Write this data into the device before going to the next step.
  3. Turn the device ON. You will not see anything right now.
  4. Write the Message Lab - V from 6 Nov 2025 into the device.
  5. Display the Message on the VLED Panel by turning the panel OFF and then ON again..

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!!