Script for configuring the CS4239 sound chip in PnP mode

From ThinkWiki
Revision as of 23:20, 22 January 2006 by Mkarcher (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To configure the CS4239 sound chip via PnP, use the following script. 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


# Sound-via-pnp-script for Thinkpad 600E and possibly other computers with onboard
# CS4239/CS4610 that to 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/*
  grep CSC0100 $dev/id > /dev/null && WSSDEV=$dev
  grep CSC0110 $dev/id > /dev/null && CTLDEV=$dev

# 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 ]
   # PnPBIOS: usual order
   # ACPI: mixed-up order
 } < $WSSDEV/resources

{ read
 read bla 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

Use these lines in 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/bin/soundcard-on

--Mkarcher 23:20, 22 January 2006 (CET)