Running X on a Logitech G19 LCD

From Gentoo Wiki
Jump to: navigation, search

The Logitech G19 keyboard is a gaming keyboard that has extra keys and a built-in LCD color display. Its display is small and its resolution is rather low (320x240 pixels), but it's enough to do a lot of useful and cool things, considering it's connected with USB 2.0.

The following instructions describe the installation of the kernel driver and the setup of a secondary X server. While it should be possible to use your existing X server to handle the G19 LCD in addition to your screen(s), there are advantages on using a separate X server. For example, you can start/stop/restart the G19 X while your main X is running.

Kernel Preparation

The official linux kernel does not have support for the G19 yet. However, you can get a working driver from github:

But before installing it you must make sure your kernel has CONFIG_FB_DEFERRED_IO set. If it's already set for you, you may skip this part.

user $grep CONFIG_FB_DEFERRED_IO /usr/src/linux/.config
CONFIG_FB_DEFERRED_IO=y

There isn't a way to directly set this from the kernel makemenu, but I did manage to enable it by enabling something that selects it:

KERNEL
Device Drivers --->  
    HID Devices (HID_SUPPORT [=y]) --->  
       Special HID drivers --->
          <M> PicoLCD (graphic version)

Please note this driver isn't really needed, it's just a hackish way to select CONFIG_FB_DEFERRED_IO through makemenu. If you know of a better way, please add it here.

Now you will need to compile the new kernel image and install it. Making just the modules isn't enough as you have changed CONFIG_FB_DEFERRED_IO. Don't reboot yet.

Installing the lg4l driver

user $cd lg4l
user $make
user $su -c "make install"

If you haven't set CONFIG_FB_DEFERRED_IO as described above, you will get an error while compiling. If everything is ok, move on.

Installing fbdev

You will also need fbdev to run X later:

root #emerge -uav xf86-video-fbdev

You may now reboot.

After rebooting

As per the lg4l README, you may:

root #modprobe hid-g19

but the device will still be grabbed by the generic driver. You must run

root #./rebind

located in the lg4l source tree to put the new module in control of the device (you may want to automate this).

Secondary X server

The following method is based on the DisplayLink wiki page. In it, it says you need x11-drivers/xf86-input-void to make it work but I haven't installed it and it all works fine. If it doesn't work for you, follow the instructions on the DisplayLink page.

If you need to switch keyboard/mouse focus to the LCD screen, you will need x2x. If you know what you are doing and plan to just open apps in the G19 LCD, then you won't need x2x.

root #emerge -uav x11-misc/x2x

xorg.conf.g19

Create this file in /etc/X11/ and name it xorg.conf.g19:

FILE /etc/X11/xorg.conf.g19
Section "Device"
    Identifier     "g19lcd"
    Driver         "fbdev"
    VendorName     "Logitech"
    BusID          "USB"
    Option         "fbdev" "/dev/fb0"
    Screen         0
EndSection

Section "Monitor"
    Identifier     "G19monitor"
    VendorName     "Logitech"
    ModelName      "Logitech G19"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "g19lcd"
    Monitor        "G19monitor"
    DefaultDepth   16
    SubSection     "Display"
        Depth      16
        Modes      "320x240"
    EndSubSection
EndSection

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    Option "AllowMouseOpenFail" "True"
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "Mouse0" "CorePointer"
EndSection

Section "ServerFlags"
    Option "AllowEmptyInput" "false"
    Option "AutoAddDevices" "false"
    Option "AutoEnableDevices" "false"
EndSection

Section "InputDevice"
    Identifier "Keyboard0"
    Driver "void"
EndSection

Section "InputDevice"
    Identifier "Mouse0"
    Driver "void"
EndSection

.xinitrc2

Next we create the ~/.initrc2 for our G19 display. Create and customize the file to your needs, here is an example:

FILE ~/.xinitrc2
# run profile to set $PATH and other env vars correctly
. ${HOME}/.bash_profile

## turn on display
xset dpms force on

## disable sleep modes etc.
xset -dpms

## disable screensaver
xset s off

## turn off beep
xset -b

xset r rate 250 30

## activate zapping (ctrl+alt+Bksp killall X)
setxkbmap -option terminate:ctrl_alt_bksp

# run initial programs
uxterm -ls -geometry 200x62+0+162 -fg white -bg black &
exec icewm || exec xterm -fg red

Please note the commands there will only affect your G19 display, not your main X.

g19lcd.sh

This is the actual script that starts the second instance of xorg-server. Make it executeable and save it somewhere in your home folder, in this example we save it to ~/.g19lcd.sh

FILE ~/.g19lcd.sh
#!/bin/sh
xinit ~/.xinitrc2 -- /usr/bin/X :1 -xf86config xorg.conf.g19 -novtswitch -sharevts -audit 0 vt12 &
sleep 5
x2x -west -from :0 -to :1 &