<?xml version='1.0'?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
                         "http://www.oasis-open.org/committees/docbook/xml/4.2/docbookx.dtd">

<article class="techreport">
  <articleinfo>
    <title>GNU/Linux on the IBM ThinkPad 760XL</title>

    <author>
      <firstname>Simon</firstname>
      <surname>South</surname>
      <affiliation>
	<address><email>ssouth@slowcomputing.org</email></address>
      </affiliation>
    </author>

    <copyright>
      <year>2003</year>
      <year>2004</year>
      <holder>Simon South</holder>
    </copyright>

    <pubdate>2004-2-23</pubdate>

    <legalnotice>
      <para>Verbatim copying and distribution of this material is
permitted in any medium, provided this notice is preserved.</para>
    </legalnotice>

    <abstract>
      <para>The IBM ThinkPad 760XL is an older laptop well-suited for
use with GNU/Linux, but little information exists regarding its
compatibility with recent kernels.  This article is a work-in-progress
describing my experience getting <quote>modern</quote> Linux features
and GNU/Linux software running on the 760XL.</para>
    </abstract>
  </articleinfo>

  <section>
    <title>Installing GNU/Linux</title>

    <para>Installing a GNU/Linux distribution on the ThinkPad 760XL is
complicated by the fact that the computer does not support booting
from a CD-ROM.  You'll need to boot from a floppy disk first and then,
at an opportune moment, swap out the floppy drive for the CD-ROM
drive, insert the distribution CD, and continue the
installation.</para>

    <para>Note that, contrary to conventional wisdom, drives on the
760XL <emphasis>are</emphasis> hot-swappable and the procedure
described above is perfectly safe for the computer.  The trick,
though, is timing the swap correctly: it needs to happen after the
installer has finished booting from the floppy, but before it tries to
detect CD-ROM drives.</para>

<!--
    <para>Installing a GNU/Linux distribution on the ThinkPad 760XL is
complicated, as the machine cannot boot from the CD-ROM drive and has
no built-in Ethernet hardware.  Furthermore, due to limited PCMCIA
support in the 2.4 kernel (see below), a network installation may not
be possible even if a PCMCIA network card is available.</para>

    <para>I wound up doing the following:</para>

    <itemizedlist>
      <listitem><para>Installing Red Hat 7.0 on the 760XL from floppy
and CD-ROM</para></listitem>

      <listitem><para>Building an LFS 5.0 operating system image on my
desktop PC</para></listitem>

      <listitem><para>Compiling a 2.2.25 kernel on the laptop with
support for initrd and root-on-NFS, then creating an initrd image with
PCMCIA drivers using the <command>pcinitrd</command> tool included
with the Card Services package.</para></listitem>

      <listitem><para>Net-booting the laptop using the LFS install as
its root directory, then reformatting its hard drive and copying the
entire root directory (less <filename
class="directory">/mnt</filename> and <filename
class="directory">/proc</filename>) onto it</para></listitem>
    </itemizedlist>

    <para>This gave me a complete, running installation of GNU/Linux
with kernel 2.4.22.</para>
-->
  </section>

  <section>
    <title>Hardware Support</title>
    <section>
      <title>PCMCIA</title>

      <para>To enable support for PCMCIA cards, build and install the
2.4 kernel <emphasis>without</emphasis> support for PCMCIA devices,
then build and install David Hinds' <ulink
url="http://pcmcia-cs.sourceforge.net/">PCMCIA Card Services for
Linux</ulink> package.  This configuration is necessary because the
PCMCIA host bridge driver supplied by the kernel,
<filename>yenta_socket.o</filename>, does not support ISA interrupt
routing for PCMCIA devices.  This is the only mechanism provided by
the 760XL's hardware, and is supported only by the
<filename>i82365.o</filename> driver from the Card Services
package.</para>

      <note>The PCMCIA subsystem in the 2.6 kernels also doesn't
      support the ISA interrupt routing of the 760XL, and using the
      Card Services drivers with these kernels is not an option.
      Consequently, there appears to be no PCMCIA support for the
      ThinkPad 760XL with kernel 2.6.0 and higher (although every
      other function of the computer appears to be supported).</note>

      <para>To prevent the card manager from assigning interrupts
already in use by on-board devices, which can result in PCMCIA cards
appearing to <quote>hang</quote> during operation, make sure your
<filename>/etc/pcmcia/config.opts</filename> contains these
lines:</para>

<screen>
# Resources we should not use, even if they appear to be available
# These are specific to the IBM ThinkPad 760XL

# Built-in audio (ES1688)
exclude irq 3
exclude irq 5

# Serial port
exclude irq 4

# Parallel port
exclude irq 7
</screen>

      <para>For GNU/Linux installations using System V-style init
scripts, including <ulink
ulink="http://www.linuxfromscratch.org/">Linux From Scratch</ulink>
and distributions from <ulink url="http://www.redhat.com/">Red
Hat</ulink>, Card Services will have installed the
<filename>pcmcia</filename> init script in <filename
class="directory">/etc/rc.d/init.d/</filename>.  Then, to activate
PCMCIA support, type:</para>

<screen>
bash $ <command>/etc/rc.d/init.d/pcmcia start</command>
</screen>

      <para>This will load the appropriate driver modules and start
the card manager.  You should hear a high-pitched beep as the PCMCIA
host bridge is detected and enabled.  If you have a supported PCMCIA
card already in the slot, you should hear another high-pitched beep,
indicating the driver for that card loaded successfully.</para>
    </section>

    <section>
      <title>Ethernet</title>
      
      <para>I use a <ulink
url="http://www.intel.com/network/connectivity/products/xirrbe100btx.htm">Xircom 
RBE-100</ulink> PCMCIA Ethernet card, supported by Card Services'
<filename>tulip_cb.o</filename> driver. With PCMCIA support properly
configured and running, the card is auto-detected and configured upon
insertion.  I then issue <command>dhcpc eth0</command>, and my 760XL
is on our home network. (No doubt the last step can be automated,
using <filename>/etc/pcmcia/network</filename> or similar.)</para>

      <para>Any PCMCIA network card supported by Card Services should
work fine with the 760XL.  A complete <ulink
url="http://pcmcia-cs.sourceforge.net/ftp/SUPPORTED.CARDS">list of
supported cards</ulink> is available on-line.</para>
    </section>

    <section>
      <title>Framebuffer</title>

      <para>The on-board <ulink
url="http://www.tridentmicro.com/">Trident Microsystems</ulink> Cyber
9385 video controller isn't supported by the Trident framebuffer
driver, neither the version included with Linux 2.4.22 nor <ulink
url="http://sourceforge.net/projects/tridentfb/">the more recent
version</ulink> available from SourceForge.  Both give only a
scrambled display.  This isn't surprising, as they're based on an
older version of the XFree86 Trident driver, which is known not to
work with the 760XL's on-board video (see <xref
	  linkend="app_support/xfree86"/>, below).</para>

      <para>It may be possible to patch the framebuffer driver with
whatever changes have recently been made to the XFree86 driver to
allow it to work properly with the 760XL.  I'll look into this
later.</para>
    </section>

    <section>
      <title>Audio</title>

      <para>The 760XL's built-in audio is provided by an <ulink
url="http://www.esstech.com/">ESS Technology</ulink> ES1688 CODEC,
fully supported by current <ulink
url="http://www.alsa-project.org/">Advanced Linux Sound
Architecture</ulink> (ALSA) drivers.  Download the ALSA drivers
package and install it like this:</para>

<screen>
bash # <command>tar -xjf alsa-drivers-0.9.8.tar.bz2</command>
bash # <command>cd alsa-drivers-0.9.8</command>
bash # <command>./configure --with-oss --with-sequencer --with-cards=es1688</command>
bash # <command>make</command>
bash # <command>make install</command>
</screen>

      <para>This installs support for legacy Open Sound System (OSS)
applications,  support for MIDI applications, and only the drivers
needed to use the 760XL's built-in audio system (including the MPU-401
UART and FM synthesizer).  You'll need to also download and install
the ALSA libraries and utilities packages.  If you want to use the
built-in FM synthesizer for MIDI playback, download the ALSA tools
package and install the <command>sbiload</command> utility (in
<filename class="directory">seq/sbiload/</filename>) and see <xref
	  linkend="app_support/midi"/> below.</para>

      <para>Your <filename>/etc/modules.conf</filename> should contain
the following:</para>

<screen>
# Built-in audio (ALSA)
alias char-major-116 snd
alias snd-card-0 snd-es1688
options snd-es1688 port=0x220 mpu_port=0x330 irq=5 mpu_irq=3 dma8=1

# OSS/Free compatibility
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
</screen>

      <para>Now, to activate the internal audio, type:</para>

<screen>
bash $ <command>/etc/rc.d/init.d/alsasound start</command>
</screen>

  <para>This will load and configure the drivers built above.  You may
also need to run <command>alsamixer</command> to raise the volume
levels before you hear anything from audio applications.</para>
    </section>
  </section>

  <section>
    <title>Application Support</title>

    <section id="app_support/xfree86">
      <title>XFree86</title>

      <para>To use <ulink
url="http://www.xfree86.org/">XFree86</ulink> with the 760XL, you'll
need the latest driver for <ulink
url="http://www.tridentmicro.com/">Trident Microsystems</ulink>
chipsets.  The drivers included with XFree86 versions 4.0.0 through
4.3.0 don't work properly with the 760XL's on-board video, giving only
a scrambled display.</para>

      <para>To get XFree86 with the latest driver, you can</para>

      <orderedlist>
	<listitem><para>Download and install a recent <ulink
url="http://www.xfree86.org/develsnaps/">experimental source
snapshot</ulink> of XFree86,</para></listitem>
	<listitem><para>Download and install the latest development
version of XFree86 from <ulink
url="http://www.xfree86.org/cvs/">CVS</ulink>, or</para></listitem>
	<listitem><para>Download and install the current stable
version of XFree86, <ulink
url="http://www.xfree86.org/rel430.html">4.3.0</ulink>, and then
download an up-to-date executable and Trident driver from the XFree86
<ulink url="http://www.xfree86.org/~alanh/">Independent Driver
Releases</ulink> page</para></listitem>
      </orderedlist>

      <para>I took the third approach: I downloaded, built and
installed XFree86 4.3.0 as normal; then downloaded the updated <ulink
url="http://www.xfree86.org/~alanh/drivers/x86/XFree86"><filename>XFree86</filename></ulink>
executable and <ulink
url="http://www.xfree86.org/~alanh/drivers/x86/trident_drv.o"><filename>trident_drv.o</filename></ulink>
module and copied them to <filename
class="directory">/usr/X11R6/bin/</filename> and <filename
class="directory">/usr/X11R6/lib/modules/drivers/</filename>,
respectively.</para>

      <para>The 760XL has only 1 024 KiB of video RAM, and can provide
either 8-bit accelerated video or 16-bit non-accelerated video at
800x600 on the built-in display.  To use 16-bit video at 800x600, you
need to explicitly disable video acceleration in your
<filename>/etc/X11/XF86Config</filename> file; otherwise, X will
insist on starting up at 640x480 resolution.</para>

    </section>

    <section id="app_support/midi">
      <title>MIDI</title>

      <para>To use the built-in FM synthesizer for MIDI playback,
you'll need to install the <command>sbiload</command> utility from the
ALSA tools package and use it to load the synthesizer chip with
instrument sounds, like this:</para>

      <screen>
bash $ <command>sbiload -p 65:0 -4 std.o3 drums.o3</command>
</screen>

      <para>The command-line parameters tell
<command>sbiload</command> to use the four-operator (OPL3-compatible)
FM synthesizer at ALSA client 65, port 0.  This corresponds to the
synthesizer built into the 760XL.  The <filename>sb.03</filename> and
<filename>drums.o3</filename> instrument definition files are missing
from the latest ALSA tools release, but you can download them from
<ulink
url="http://cvs.sourceforge.net/viewcvs.py/alsa/alsa-tools/seq/sbiload/">CVS</ulink>.</para>

      <para>You can then play MIDI files using <ulink
url="http://www.parabola.demon.co.uk/alsa/pmidi.html"><command>pmidi</command></ulink>, 
for example, by specifying port 65:0 as the destination for MIDI
data:</para>

      <screen>
bash $ <command>pmidi -p 65:0 filename.mid</command>
</screen>

      <para>The capabilities of the built-in synthesizer are very
limited, however.  A more sophisticated (but CPU-intensive) approach
would be to install and configure the <ulink
url="http://www.onicos.com/staff/iz/timidity/">TiMidity++</ulink>
software synthesizer as an ALSA MIDI device.  See this <ulink
url="http://www.djcj.org/LAU/guide/TiMidity-howto.html">TiMidity
HOWTO</ulink> for instructions.</para>

      <para>The 760XL's sound hardware is capable of controlling
external MIDI devices, but the laptop itself has no joystick port to
which the needed MIDI adapter could be connected.  Only the 760ED and
760XD <quote>enhanced video</quote> models include a joystick/MIDI
port. To use physical MIDI devices with the 760XL, then, you'll need a
serial port or PCMCIA MIDI adapter.</para>
    </section>
  </section>
</article>
