Dale Wick's Thinkpad under Linux page

I own an IBM Thinkpad 755cx, and I've been using it under Linux for a very short time. I use Linux at work for my day to day job, and it is necessary for me to have on my Laptop when I travel.

So far, I've got the the Win98 initialization of the Sound (8-bit SB 2.0 mode) and DOS initialization of 800x600x256 video mode to work, and I use LOADLIN to carry that over to Linux. But what I really want is to port all of those DOS/Win utilities to Linux. Also, I'd really like to have my MWave modem work again (I used to use it under OS/2).

Progress so far

Update Mar 5, 2001 Exciting news! IBM's GPLed MWave modem support for Linux is published. I've downloaded it finally (I was told about it a couple of weeks ago. A mirror site is:
http://www.freenetpages.co.uk/hp/mjbou/mwave.html
maintained by Michael Bouckley.

Update Mar 14, 2000 Just a general update, I've had my life turned upside down by moving and a busy time at work. Nathan Hand sent me some promising initialization code that doesn't depend on 32-bit BIOS calls (only 16-bit calls work which isn't sufficient when using power management). I haven't heard from IBM concerning their soft modem support of Thinkpads on Linux, but I'm still hopeful that they'll beat me to the punch. I will post Nathan's code for you to look over and try.

Update Oct 4: I've now migrated all of my code out of apm.c, and I'm moving it into a seperate module (which will make testing faster). I've also been contacted by Thomas Hood concerning hist tpctl utility. If you haven't seen it, check it out. I have a feeling that it will be a good place for me to go next, code wise. I've downloaded it, but not installed it yet.

Update Oct 1: Here is a list of the documentation I've been given so far (see MWave Haven in the links section at the bottom):

Updated todo list.

Update Sept 30: Sorry for the long gap between updates. I've been working hard on the documentation that I downloaded. I've also been in contact with Helge Behmann and Nathan Hand. Nathan supplied a patch that enables the MWave without using PS2.EXE. I've also starting working on adding MWave code to Linux's Advanced Power Management support.

Update Sept 14: I now have all of the toolkits from MWave Haven Website (no longer online) to try, and I'll post my progress. Check out the How MWave Works section below for my design so far.

I've visited the Mwave Project for Linux page, and various other Thinkpad pages to get XFree86 to work reasonably well, at 800x600, but in only 8 bit color using the 2.2.6 kernel and XF86 version 3.3.3's SVGA driver. I needed to add a hack which put the video in a properly positioned 800x600x256c mode called: PS2.EXE MODE3X ON which is in my DOS autoexec.bat. Then it calls LOADLIN.EXE with my kernel.

I've written device drivers for OS/2 and embedded designs (and the Coleco Adam too), and I've wanted a meaningful project to do a little Linux kernel hacking. My first attempt is to read the settings of the Mwave DSP. So far it detects it and that is all. View the mwave.c (version 0.1) source or download mwave-0.1.tar.gz.

If you want to download it and look it over, please send me your comments. Extract the source with: tar -xzvf mwave-0.1.tar.gz To compile, simply type: make To test it, you need to become root: su and invoke it with the -v (verbose) option: ./mwave -v It will show you what it is doing. It detected the baseio on my Thinkpad, and detects no Mwave on my generic clone (which doesn't have Mwave), so I consider it safe. WARNING: The code to read mwave registers 3, 5, 16 outputs random values, and may be unsafe. Ideally swap hard disk drives before testing (although I just make sure I have a backup).

You can also try: ./mwave --help for my somewhat ambitious dreams of what version 1.0 can do.

Please send your test results to me, and a patch with what the correct code should be to initialize the Mwave register reading code properly.

Todo

How MWave works

The MWave DSP is a digital signal processor which runs a self-contained real-time OS, and can be used to provide stereo 8-bit sound using sound balster emulation, and telephony (fax/modem/voice). The modem speed maxes out at 28.8kbps for use with audio and 33.6kbps for use without sound card emulation. Each of the functions can be preloaded into the MWave DSP, but the telephony functions need extra support from the main CPU. From what I understand so far, the FAX, Voice mail and modem functions won't all fit in the DSP at once, and so need to be paged in as appropriate by the CPU. Also it appears that the modem AT command set is interpreted by the dos TSR or Windows device driver (VXD/DLL/DRV/etc). To create a device driver for Linux, I need to be able to:

Initialize the DSP

  1. Load and boot up the MWave realtime OS
  2. Load and run the MWave SB emulation code
  3. Load and run the MWave modem DSP code
At this point, the MWave sound blaster emulation will function normally. To get the modem code working, I need to additionally:
  1. Create a serial device (called /dev/ttyMW0 for instance) which executes some device driver code which accepts input for an application (like pppd or minicom), debounces the input, looking for modem commands and sends them to the modem code running inside the DSP.
  2. A daemon running (called mwmodemd maybe), which looks for incoming data like incoming calls, or simply incoming data, and buffers/translates it as appropriate through communication with the device.
  3. The daemon needs to potientially load and unload code to handle FAX/modem/voice based on requests from software applications.

Kernel Patches

setup.S patch for initializing the MWave DSP

Nathan Hand supplied to me this mini patch. It is to be applied to your kernel source (usually /usr/src/linux) in the file arch/i386/boot/setup.S which is executed before switching to protected mode, but after the Linux kernel is decompressed.

It calls the BIOS call for advanced power management [ APM v1.1 -- the standard is available on Intel's ftp server as apmv11.doc (Word 2.0 format (?!)), or v1.2 is available on Microsoft's site as apmv12.pdf). [ BTW, Adobe's Acrobat Reader for Linux (including a Netscape plug-in) is vastly superior to ghostview, xpdf or any other PDF viewers I've tried on Linux. ] ]

The standard permits an OEM (IBM) to make a special extension for custom needs. In their case, they chose to make an extension. Thanks to Helge Bahmann I've learned that that extension can be called via INT 15h with AX=5380h, BX=6000h and CX=1101h. Initially Nathan and I tried adding that code to the 32 bit protected APM code in Linux, but it didn't work. So, I read that 16/32 bit protected mode. Nathan figureed out where to put the real mode call and here it is.

Now, there is a disadvantage to this patch. On both Linux and NT after the OS boots, you aren't allowed to make real mode BIOS calls, and the MWave DSP doesn't resume from suspend automatically. Under NT, IBM recommends that you disable suspend if you want to use sound or the MWave modem. Nathan is working on some magic code that will work based on the actual BIOS code.

Here is the actual patch:

--- setup.S.orig        Sat Sep 25 00:01:32 1999
+++ setup.S     Fri Sep 24 23:53:15 1999
@@ -382,6 +382,15 @@
        mov     [0x1ff],#0xaa   ! device present
 no_psmouse:
 
+!
+! Let's try and enable thinkpad dsp
+!
+
+       mov     ax,#0x05380
+       mov     bx,#0x06000
+       mov     cx,#0x01101
+       int     0x15
+
 ! check for APM BIOS
                ! NOTE: DS is pointing to the boot sector

--IS0zKkzwUGydFO0o--

To apply this patch, you need to install the Linux kernel sources. Nathan is working from 2.2.12 source. I am currently working from 2.2.6 but I'll probably move to a more recent kernel soon. This should work with either.

I'll add more detailed patch application documentation, once we have some more substantial patches. In the mean time, if you can figure it out yourself, simply compile your kernel (make bzImage), copy the freshly compiled kernel from arch/i386/boot/bzImage to some place mentioned in lilo.conf (like /bzImage.mwave), re-run lilo. NOTE: don't make an experimental kernel your only kernel. Either have a backup known-good kernel on a boot floppy, or another entry in lilo.conf with a known-good kernel (like /bzImage.stock for example). That way, at boot time you can choose your kernel.

You know that the patched kernel works by running my mwave manager tool as root (on Nathan's Thinkpad 765):


    jabba:~# ~nathanh/coding/mwave-0.1/mwave  -v
    Mwave settings manager for IBM Thinkpad (*)
    probing for mwave base
    base 1 (0xce30): 0xffff
    base 2 (0x8e30): 0xffff
    base 3 (0x4e30): 0xa839
    MWave base detected at: 0x4e30
    Reg 3=0x7b8b
    Reg 4=0x2896
    Reg 16=0x4c06
    jabba:~#

I get similar output on my Thinkpad 755cx.

apm.c (Advanced Power Management) patches

These aren't ready to distribute yet. So far, I've added some entries to /proc (/proc/mwave/iobase and other MWave status information). I'll post something on my next web site update.

Other sites of interest


Last updated 2001 03 05

Send questions to: dalew@opengraphics.com.
Dale Wick's Home Page | AdamCon.org Home