KDE, GNOME/Nautilus, OpenWindows, WINE, etc. -- plenty of GUIs make it easier for users to access the power and elegance of Linux applications. What component can be added to this mix to insinuate Linux even more firmly into the consumer device arena? A touchscreen. With a touchscreen, a Linux device can become a controller for a slew of devices such as a digital video recorder, a TiVo-like personal video recorder, a media center, a smart-house system, or even a control interface to a toaster. The possibilities are boundless.
Touchscreens come in a variety of pre-packaged and separately packaged solutions. They have been around almost as long as CRTs and now show up in LCDs as well. In some cases, the touchscreen is already integrated into the display unit. In others (as discussed in this article), they are separate units that must be matched in size and intended function.
This article gives you an overview of the steps to prepare to install and configure the LCD (the image screen), the modeline (a configuration line that tells the server how to drive the monitor), and the touchscreen (for input). It also gives you some resources to answer other questions that might come up when you start to integrate a touchscreen.
Installing the LCD
The touchscreen is for input only; therefore, you need something behind it to display an image. Besides displaying the user interface, the display is used for calibration, which can be done in these two main ways:
- The easier route is to acquire an LCD screen from any of various vendors and hook it up to a PC system. Just ensure the connections will work with your video card, either directly or with an adapter.
- The more difficult route, and the one described in this article, is to acquire a PSOne LCD for a fairly small price. This will require some soldering and cable splicing, which is not overly difficult if you follow one of the guides available for this modification (see Resources). Going this route and using a PSOne LCD will require a video card with a CSYNC (composite sync) signal -- most ATI and Matrox cards have this. You can build a circuit that generates a CSYNC signal for cards that don't do this already (see Resources), but it is generally easier to just purchase a card that already generates it.
Connecting the power
The LCD needs power to function and backlight the display. Just as with the LCD installation, there is an easy way and a hard way:
- The easy way is to purchase an LCD that can be plugged into a wall outlet or car adapter, depending on your needs. Plugging into a wall outlet is simple, since the PC generally requires wall power also.
- The difficult way (and the way I chose) is to purchase a car power adapter from eBay. It uses 12 volts, which is a voltage also provided inside an ordinary computer case via the power supply. I simply followed the guide "Hooking up a Neon Light," since they are functionally the same (see Resources). After making the changes, it will plug directly into a PC power supply. Again, you'll have to do some cable splicing and soldering, but in the end you avoid having to use an additional wall outlet.
Now for the modeline.
Remind me: What's a modeline?
A modeline is a configuration line in a configuration file that provides information to the server about a connected computer monitor and how to drive it at a specified display resolution. (Originally it was XF86Config in XFree86.) Now, in many Linux/UNIX® versions, modelines are no longer needed since the server calculates the configuration at startup based on other factors, such as:
- Generic and intuitive settings in the server configuration file
- Monitor capabilities acquired via an EDID query
EDID (Extended Display Identification Data) is a VESA standard data format that contains basic information about a monitor and its capabilities, including vendor information, maximum image size, color characteristics, factory pre-set timings, frequency range limits, and character strings for the monitor name and serial number. The information is stored in the display and is used to communicate with the system through a Display Data Channel (DDC), which rests between the monitor and the PC graphics adapter. The latest version of EDID can be used in CRT displays, LCD displays, and future display types because EDID offers general descriptions of almost all display parameters.
An individual modeline has 10 parameters, beginning with a label for the resolution being specified. The second parameter specifies the rate of the pixel clock in megahertz. Following are two groups of four numbers. The first group specifies the x-resolution (width) and related parameters; the second specifies the y-resolution (height). For options, extra parameters for controlling horizontal and vertical synchronization can be added, and there are also options for interlaced and doublescan modes.
So why bother with modelines? For obsolete, unusual, or insufficiently finely tuned display hardware, manually setting modelines may be the only available solution.
Determining the proper modeline
If you took the easy route for hooking up the LCD, your screen may be recognized automatically when the Linux OS boots; if so, you are ready to set up the touchscreen. If you took the more difficult route, or if your LCD wasn't automatically recognized, you may need to build a custom modeline. Various modelines may be gathered by querying Google, by checking manufacturers' specifications, or by trying various included ones in the proper configuration file. If you are installing a PSOne LCD, the easiest way to arrive at a proper modeline is to use a Windows based-PC and the PowerStrip tool (which provides advanced, multi-display, programmable hardware support to a wide range of video cards; see Resources).
If you know the native resolution for the LCD, you should start with that. For the PSOne LCD, you should start with 640x480i (Arcade). From there, you may need to adjust the scan rate (a setting that the PowerStrip tool allows you to modify) until you get a stable picture.
Table 1 lists appropriate modelines for various video cards for a PSOne LCD -- I found these by searching the Internet. I do not have access to all these various cards, so the only one I can vouch for is the ATI 9600XT that I use. If you find these in error or would like to contribute to this list, please send me an e-mail.
|Matrox Mystique||NTSC||"640x480" 12.954 640 680 744 816 480 496 504 528 interlace +hsync +vsync|
|Matrox Millenium G200||NTSC||"640x480" 13.193 640 688 752 832 480 492 500 524 interlace -hsync -vsync|
|Matrox Millenium G200||PAL||"720x576" 14.875 720 736 800 896 576 602 606 668 interlace +hsync +vsync|
|ATI 7000||NTSC||"640x480" 12.175 640 664 720 784 480 486 493 524 interlace +hsync +vsync|
|ATI 7000||PAL||"720x576" 14.950 720 763 859 920 576 580 584 588 interlace +hsync +vsync|
|ATI 9600XT||NTSC||"640x480" 13.582 640 704 768 864 480 486 493 524 interlace -hsync -vsync|
|ATI 9700||PAL||"720x576" 14.881 720 781 829 960 576 606 610 646 interlace +hsync +vsync|
|EPIA 800||NTSC||"640x480" 13.678 640 672 736 800 480 486 494 524 interlace composite|
Placement of the modeline
Now that you've determined the right modeline, there are two places that this information needs to go. The first place is in the xorg.conf config file, and the second is in the boot parameters. Let's look at both.
The xorg.conf config file
Listing 1 is an example of an xorg.conf config file. You could easily modify this to a dual-head display setup by adding another Monitor/Screen identifier. Also, notice the
ForceMinDotClock option. The ATI 9600XT reports its minimum dot clock as 20M, but it can really go lower. This option allows you to set the dot clock lower in the modeline. The PSOne LCD requires a lower dot clock (in the range or 12M-15M) to drive the display. You may or may not have to include this setting depending on the LCD you are using.
This listing also contains the necessary information for the touchkit. The device and driver were taken from the installation manual for the touchkit I used. It may be different depending on the manufacturer of the touchscreen you decide to use.
Listing 1. An xorg.conf config file
# Xorg configuration created by system-config-display Section "ServerLayout" Identifier "Single head configuration" Screen 0 "Screen0" Absolute 0 0 # Screen 1 "Screen1" Absolute 640 0 InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" InputDevice "TKPANEL" "SendCoreEvents" Option "AllowMouseOpenFail" "true" EndSection Section "Files" RgbPath "/usr/X11R6/lib/X11/rgb" FontPath "unix/:7100" EndSection Section "Module" Load "dbe" Load "extmod" Load "fbdevhw" Load "glx" Load "record" Load "freetype" Load "type1" Load "dri" Load "v4l" EndSection Section "InputDevice" Identifier "Keyboard0" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "us" EndSection Section "InputDevice" Identifier "Mouse0" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mice" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "yes" EndSection Section "InputDevice" Identifier "TKPANEL" Driver "touchkit" Option "Device" "/dev/tkdat0" Option "DebugLevel" "0" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "LCD Panel 640x480i" HorizSync 15.720 Option "dpms" Modeline "640x480" 13.582 640 704 768 864 480 486 493 524 interlace -hsync -vsync EndSection Section "Device" Identifier "Videocard0" Driver "radeon" VendorName "Videocard vendor" BoardName "ATI Radeon 9600" Option "ForceMinDotClock" "13M" EndSection Section "Screen" Identifier "Screen0" Device "Videocard0" Monitor "Monitor0" DefaultDepth 16 SubSection "Display" Viewport 0 0 Depth 16 Modes "640x480" EndSubSection EndSection Section "DRI" Group 0 Mode 0666 EndSection
Kernel boot options
The second place to include these options is during boot so that the kernel can correctly display the information. The best place to determine what options to supply is to use Section 18 of the Framebuffer Howto (see Resources). Using the xorg.conf file in Listing 1 and Section 18 of the Framebuffer Howto, find the following (correct) video boot parameter:
Listing 2. Kernel boot options
kernel /vmlinuz-2.6.11-1.27_FC3 ro root=/dev/VGROOT/LVROOT rhgb quiet vga=0x301 video=radeonfb:xres:640,yres:480,depth:16,left:96,right:64,hslen:64,upper:31, lower:6,vslen:7,pixclock:13582
You need to add this video option to the appropriate boot config file (menu.lst for GRUB or lilo.conf for LILO). The video option doesn't really kick in until the rhgb (Red Hat Graphical Boot) starts.
vga=0x301 sets up the graphics as 640x480 (see Section 5.3 of the Howto). It doesn't quite get you what you need for the PSOne screen, but it does make it somewhat more viewable for the text that comes up before rhgb.
Setting up the touchscreen
The first thing is to install the appropriate touchscreen software. For the touchscreen I used, download the software from eGalax (see Resources). I am using the FC3 distribution, so I downloaded the FC3 image. The only modification I had to make was to point the build process to the x86_64 include files for the X server. I did this by putting
-I/usr/X11R6/lib64/Server/include in the makefile for the touchkit_drv.o file. The installation is set up for a 32-bit system, so you would need to do this only if you have a strict 64-bit system.
Listing 3 shows two lines from the xorg.conf config file. The first line tells the X server to send all the core events to the TKPANEL device as well as the mouse (so both can be used simultaneously). The second says that if no mouse is present, continue to bring up the X display. This way, the touchscreen can be used without a mouse connected to the system.
Listing 3. Two important lines in the xorg.conf file
InputDevice "TKPANEL" "SendCoreEvents" Option "AllowMouseOpenFail" "true"
You may need to configure the touchscreen with the touchcfg configuration utility (or whatever utility is appropriate for your touchscreen). Figure 1 is a screenshot of the touchcfg utility.
Figure 1. The touchcfg config utility
From this utility, you can do the calibrations that tell the touchscreen where the edges of your display are. A finer-point calibration (25pt instead of 4pt) will give you better approximation of screen locations. This utility also lets you perform a simple drawing test and set the double-click speed and area. Other touchscreen configuration utilities may have more or fewer features.
When this is complete, you are done. When the machine is rebooted, the touchscreen will now function just like a regular mouse. You can select text and icons by putting your finger on the text. Hold your finger down for a right mouse-click. Figures 2 and 3 show some bootup screens for the LCD.
Figure 2. The rhgb screen
Figure 3. Booting into KDE
- Modifying a PSOne LCD
- StarFox shows how to hack a Sony PSOne LCD to work on a standard VGA input.
- Go the extra mile and fit a graphic PSOne LCD display just on your desktop.
- These instructions for PSOne LCD modifications are truly step by step.
- The article Hooking up a Neon Light explains how to modify a 12-volt car adapter for use in a PC -- perfect instructions for hooking up the LCD screen.
- The FBdev home page contains some information about the frame buffer drivers.
- The Framebuffer HOWTO contains more information about the frambuffer drivers. Section 5.3 is on available VESA modes and Section 18 is on converting XFree86 modelines into framebuffer device timings.
- The Linux Touch Screen HOWTO has some information on some touchscreens.
- The eGalax Web site contains the drivers and manuals you will need for their screens. There is also a Touchkit USB mini-HowTo with information on the eGalax touchscreens.
- "The cranky user: Macro viruses" (developerWorks, August 2002) explains the modeline option in early versions of the UNIX editor vi.
- Touchscreens Hardware Checkpoint 1.3, from the IBM Accessibility Center, offers an alternative input method for touchscreens or touch-operated controls.
- Put a penguin in your pocket: read "Running Linux on an iPAQ" (developerWorks, September 2004), and use Linux to breathe new life into an old system (with a touchscreen).
- In "New body art" (developerWorks, January 2002), see how wearable computers are perfect for touchscreens.
- "Linux system development on an embedded device" (developerWorks, March 2002) covers framebuffer drivers.
- "Multimodal Application Design Issues" (developerWorks, December 2003) details special considerations when designing a multimodal application.
- In the developerWorks Linux zone, find more resources for Linux developers.
- Stay current with developerWorks technical events and Webcasts.
Get products and technologies
- The PowerStrip tool can help you determine the modeline.
- The SurePOS 500 system provides an innovative infrared touchscreen interface that is designed to withstand the harsh food service and retail environments.
- Get a 5-inch LCD (when they're in stock!) at Geeks.com.
- You can use the 12-volt Thermaltake Cigarette Lighter for providing 12v power, although this is a more difficult power solution to hide.
- With IBM trial software, available for download directly from developerWorks, build your next development project on Linux.
- The bit-tech forums and the mp3car forums are both good sources of information for device programmers.
- Participate in developerWorks blogs and get involved in the developerWorks community.
Dig deeper into Linux on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.