Debian Codegraph @

soundcard-on.sh

raw symbols SCIP
1 #!/bin/bash
2 # soundcard-on.sh
3
4 # Script author: Mkarcher
5 # http://www.thinkwiki.org/wiki ...
6 # /Script_for_configuring_the_CS4239_sound_chip_in_PnP_mode
7 # ABS Guide author made minor changes and added comments.
8 # Couldn't contact script author to ask for permission to use, but ...
9 #+ the script was released under the FDL,
10 #+ so its use here should be both legal and ethical.
11
12 # Sound-via-pnp-script for Thinkpad 600E
13 #+ and possibly other computers with onboard CS4239/CS4610
14 #+ that do not work with the PCI driver
15 #+ and are not recognized by the PnP code of snd-cs4236.
16 # Also for some 770-series Thinkpads, such as the 770x.
17 # Run as root user, of course.
18 #
19 # These are old and very obsolete laptop computers,
20 #+ but this particular script is very instructive,
21 #+ as it shows how to set up and hack device files.
22
23
24
25 # Search for sound card pnp device:
26
27 for dev in /sys/bus/pnp/devices/*
28 do
29 grep CSC0100 $dev/id > /dev/null && WSSDEV=$dev
30 grep CSC0110 $dev/id > /dev/null && CTLDEV=$dev
31 done
32 # On 770x:
33 # WSSDEV = /sys/bus/pnp/devices/00:07
34 # CTLDEV = /sys/bus/pnp/devices/00:06
35 # These are symbolic links to /sys/devices/pnp0/ ...
36
37
38 # Activate devices:
39 # Thinkpad boots with devices disabled unless "fast boot" is turned off
40 #+ (in BIOS).
41
42 echo activate > $WSSDEV/resources
43 echo activate > $CTLDEV/resources
44
45
46 # Parse resource settings.
47
48 { read # Discard "state = active" (see below).
49 read bla port1
50 read bla port2
51 read bla port3
52 read bla irq
53 read bla dma1
54 read bla dma2
55 # The "bla's" are labels in the first field: "io," "state," etc.
56 # These are discarded.
57
58 # Hack: with PnPBIOS: ports are: port1: WSS, port2:
59 #+ OPL, port3: sb (unneeded)
60 # with ACPI-PnP:ports are: port1: OPL, port2: sb, port3: WSS
61 # (ACPI bios seems to be wrong here, the PnP-card-code in snd-cs4236.c
62 #+ uses the PnPBIOS port order)
63 # Detect port order using the fixed OPL port as reference.
64 if [ ${port2%%-*} = 0x388 ]
65 # ^^^^ Strip out everything following hyphen in port address.
66 # So, if port1 is 0x530-0x537
67 #+ we're left with 0x530 -- the start address of the port.
68 then
69 # PnPBIOS: usual order
70 port=${port1%%-*}
71 oplport=${port2%%-*}
72 else
73 # ACPI: mixed-up order
74 port=${port3%%-*}
75 oplport=${port1%%-*}
76 fi
77 } < $WSSDEV/resources
78 # To see what's going on here:
79 # ---------------------------
80 # cat /sys/devices/pnp0/00:07/resources
81 #
82 # state = active
83 # io 0x530-0x537
84 # io 0x388-0x38b
85 # io 0x220-0x233
86 # irq 5
87 # dma 1
88 # dma 0
89 # ^^^ "bla" labels in first field (discarded).
90
91
92 { read # Discard first line, as above.
93 read bla port1
94 cport=${port1%%-*}
95 # ^^^^
96 # Just want _start_ address of port.
97 } < $CTLDEV/resources
98
99
100 # Load the module:
101
102 modprobe --ignore-install snd-cs4236 port=$port cport=$cport\
103 fm_port=$oplport irq=$irq dma1=$dma1 dma2=$dma2 isapnp=0 index=0
104 # See the modprobe manpage.
105
106 exit $?