1 / 9

Implementing 'show' and 'hide' for SiS 315 hardware cursor

Learn how to implement 'show' and 'hide' functionality for the SiS 315 hardware cursor using Linux device-driver source code and ioctl commands.

deloresg
Download Presentation

Implementing 'show' and 'hide' for SiS 315 hardware cursor

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Notes for Lab 10 On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor

  2. The GPU resources • The SiS 315 graphics processing units in our workstations are each equipped with 32-megabytes of video display memory (designated as PCI resource 0) • These graphics adapters also implement a set of memory-mapped registers known as the 2D graphics engine (and designated as PCI resource 1)

  3. ‘pci_resource_start()’ • Device-drivers can use this Linux kernel function to discover the physical address where resource 0, or resource 1, resides struct pci_dev *devp = NULL: devp = pci_find_device( VEN, DEV, devp ); vram = pci_resource_start( devp, 0 ); mmio = pci_resource_start( devp, 1 );

  4. SiS 315 information • Programming manual for the SiS 315 GPU is not usually made available to the public • But some information can be derived from reading Linux device-driver source-code • Examples are: • The ‘/usr/src/linux/drivers/video/sis’ directory • Also download the ‘svgalib-1.9.17’ package

  5. Graphics Cursor 31 30 0 cursor-image source-offset 0x8500 cursor visibility control bit: 0=hide, 1=show cursor starting command bit: 0=no, 1=yes cursor-image horizontal coordinate 0x850C cursor-image vertical coordinate 0x8510

  6. Algorithm to hide cursor • Map physical page containing the registers to a virtual address (with ‘ioremap()’) • Read current values of these registers • Clear bit #30 (to make cursor invisible) • Set bit #31 (to initiate a new command) • Write these adjusted register values • Undo the mapping (with ‘iounmap()’)

  7. Algorithm to show cursor • Map physical page containing the registers to a virtual address (with ‘ioremap()’) • Read current values of these registers • Set bit #30 (to make cursor visible) • Set bit #31 (to initiate a new command) • Write these adjusted register values • Undo the mapping (with ‘iounmap()’)

  8. The ‘ioctl.c’ module • These techniques are demonstrated in this device-driver module’s ‘ioctl()’ function • Two IOCTL commands are implemented • #define CURSOR_HIDE 0 • #define CURSOR_SHOW 1 • Applications can open the device-file, then use an ioctl-command; for example: int fd = open( “/dev/vram”, O_RDWR ); ioctl( fd, CURSOR_HIDE);

  9. In-class exercise: • Try adding new IOCTL commands to the ‘ioctl.c’ driver which lets applications find or move the cursor’s screen-position; #define CURSOR_FIND 2 #define CURSOR_MOVE 3 struct { long x, y; } location; ioctl( fd, CURSOR_FIND, &location ); location.x += 40; location.y += 40; ioctl( fd, CURSOR_MOVE, &location );

More Related