Script for configuring the CS4239 sound chip in PnP mode

From ThinkWiki
Jump to navigation Jump to search

To configure the CS4239 sound chip via PnP, use the following script1 (Tested on a ThinkPad 600E). It is meant to be used as install script with modprobe. An example modprobe.conf snippet follows.

Save this script as /usr/local/sbin/soundcard-on. Don't forget to make it executable.

The Script

This page contains a large amount of code. The actual code should be moved to a dedicated code article, to make easier to download and edit.

<bash>

#!/bin/bash

# Sound-via-pnp-script for Thinkpad 600E and possibly other computers with onboard
# CS4239/CS4610 that do not work with the PCI driver and are not recognized by the
# PnP code of snd-cs4236

# search sound card pnp device

for dev in /sys/bus/pnp/devices/*
do
  grep CSC0100 $dev/id > /dev/null && WSSDEV=$dev
  grep CSC0110 $dev/id > /dev/null && CTLDEV=$dev
done

# activate devices (Thinkpad boots with devices disabled unless "fast boot" is turned off)

echo activate > $WSSDEV/resources
echo activate > $CTLDEV/resources

# parse resource settings

{ read
 read bla port1
 read bla port2
 read bla port3
 read bla irq
 read bla dma1
 read bla dma2
 # Hack: with PnPBIOS: ports are: port1: WSS, port2: OPL, port3: sb (unneeded)
 #       with ACPI-PnP:ports are: port1: OPL, port2: sb, port3: WSS
 # (ACPI bios seems to be wrong here, the PnP-card-code in snd-cs4236.c uses the
 #  PnPBIOS port order)
 # Detect port order using the fixed OPL port as reference
 if [ ${port2%%-*} = 0x388 ]
 then
   # PnPBIOS: usual order
   port=${port1%%-*}
   oplport=${port2%%-*}
 else
   # ACPI: mixed-up order
   port=${port3%%-*}
   oplport=${port1%%-*}
 fi
 } < $WSSDEV/resources

{ read
 read bla port1
 cport=${port1%%-*}
} < $CTLDEV/resources

# load the module

modprobe --ignore-install snd-cs4236 port=$port cport=$cport fm_port=$oplport irq=$irq dma1=$dma1 dma2=$dma2 isapnp=0 index=0 && /lib/alsa/modprobe-post-install snd-cs4236

</bash>

modprobe Configuration

Add these lines to /etc/modprobe.conf or /etc/modprobe.d/cs4236pnp:

# Kill any attempts from hotplug or discover to load the PCI driver
install snd-cs46xx /bin/true
# Set up PnP before loading ISA driver
install snd-cs4236 /usr/local/sbin/soundcard-on

FOOTNOTES [Δ]
  1. provided by Mkarcher 23:20, 22 January 2006 (CET)