~ubuntu-branches/ubuntu/maverick/linux-backports-modules-2.6.32/maverick

« back to all changes in this revision

Viewing changes to updates/alsa-driver/utils/alsa-info.sh

  • Committer: Bazaar Package Importer
  • Author(s): Andy Whitcroft, Andy Whitcroft
  • Date: 2010-02-04 23:15:51 UTC
  • Revision ID: james.westby@ubuntu.com-20100204231551-vjz5pkvxclukjxm1
Tags: 2.6.32-12.1
[ Andy Whitcroft ]

* initial LBM for lucid
* drop generated files
* printchanges -- rebase tree does not have stable tags use changelog
* printenv -- add revisions to printenv output
* formally rename compat-wireless to linux-backports-modules-wireless
* Update to compat-wireless-2.6.33-rc5
* update nouveau to mainline 2.6.33-rc4
* add new LBM package for nouveau
* nouveau -- fix major numbers and proc entry names
* fix up firmware installs for -wireless
* clean up UPDATE-NOVEAU
* update Nouveau to v2.6.33-rc6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
SCRIPT_VERSION=0.4.58
 
4
CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog"
 
5
 
 
6
#################################################################################
 
7
#Copyright (C) 2007 Free Software Foundation.
 
8
 
 
9
#This program is free software; you can redistribute it and/or modify
 
10
#it under the terms of the GNU General Public License as published by
 
11
#the Free Software Foundation; either version 2 of the License, or
 
12
#(at your option) any later version.
 
13
 
 
14
#This program is distributed in the hope that it will be useful,
 
15
#but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#GNU General Public License for more details.
 
18
 
 
19
#You should have received a copy of the GNU General Public License
 
20
#along with this program; if not, write to the Free Software
 
21
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
22
 
 
23
##################################################################################
 
24
 
 
25
#The script was written for 2 main reasons:
 
26
# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user.
 
27
# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them.
 
28
 
 
29
#Set the locale (this may or may not be a good idea.. let me know)
 
30
export LC_ALL=C
 
31
 
 
32
#Change the PATH variable, so we can run lspci (needed for some distros)
 
33
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
 
34
BGTITLE="ALSA-Info v $SCRIPT_VERSION"
 
35
PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
 
36
#Define some simple functions
 
37
 
 
38
pbcheck(){
 
39
        [[ $UPLOAD = "no" ]] && return
 
40
 
 
41
        if [[ -z $PASTEBIN ]]; then
 
42
                [[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
 
43
        else
 
44
                [[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
 
45
        fi
 
46
}
 
47
 
 
48
update() {
 
49
        SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1
 
50
        wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1
 
51
        REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'`
 
52
        if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
 
53
                if [[ -n $DIALOG ]]
 
54
                then
 
55
                        OVERWRITE=
 
56
                        if [ -w $0 ]; then
 
57
                                dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to install it?\nNOTICE: The original file $0 will be overwritten!" 0 0
 
58
                                DIALOG_EXIT_CODE=$?
 
59
                                if [[ $DIALOG_EXIT_CODE = 0 ]]; then
 
60
                                  OVERWRITE=yes
 
61
                                fi
 
62
                        fi
 
63
                        if [ -z "$OVERWRITE" ]; then
 
64
                                dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to download it?" 0 0
 
65
                                DIALOG_EXIT_CODE=$?
 
66
                        fi
 
67
                        if [[ $DIALOG_EXIT_CODE = 0 ]]
 
68
                        then
 
69
                                echo "Newer version detected: $REMOTE_VERSION"
 
70
                                echo "To view the ChangeLog, please visit $CHANGELOG"
 
71
                                if [ "$OVERWRITE" = "yes" ]; then
 
72
                                        cp $SHFILE $0
 
73
                                        echo "ALSA-Info script has been updated to v $REMOTE_VERSION"
 
74
                                        echo "Please re-run the script"
 
75
                                        rm $SHFILE 2>/dev/null
 
76
                                else
 
77
                                        echo "ALSA-Info script has been downloaded as $SHFILE."
 
78
                                        echo "Please re-run the script from new location."
 
79
                                fi
 
80
                                exit
 
81
                        else
 
82
                                rm $SHFILE 2>/dev/null
 
83
                        fi
 
84
                else
 
85
                        echo "Newer version detected: $REMOTE_VERSION"
 
86
                        echo "To view the ChangeLog, please visit $CHANGELOG"
 
87
                        if [ -w $0 ]; then
 
88
                                echo "The original file $0 will be overwritten!"
 
89
                                echo -n "If you do not like to proceed, press Ctrl-C now.." ; read inp
 
90
                                cp $SHFILE $0
 
91
                                echo "ALSA-Info script has been updated. Please re-run it."
 
92
                                rm $SHFILE 2>/dev/null
 
93
                        else
 
94
                                echo "ALSA-Info script has been downloaded $SHFILE."
 
95
                                echo "Please, re-run it from new location."
 
96
                        fi
 
97
                        exit
 
98
                fi
 
99
        else
 
100
                rm $SHFILE 2>/dev/null
 
101
        fi
 
102
}
 
103
 
 
104
cleanup() {
 
105
        if [ -n "$TEMPDIR" -a "$KEEP_FILES" != "yes" ]; then
 
106
                rm -rf "$TEMPDIR" 2>/dev/null
 
107
        fi
 
108
        test -n "$KEEP_OUTPUT" || rm -f "$NFILE"
 
109
}
 
110
 
 
111
 
 
112
withaplay() {
 
113
        echo "!!Aplay/Arecord output" >> $FILE
 
114
        echo "!!------------" >> $FILE
 
115
        echo "" >> $FILE
 
116
        echo "APLAY" >> $FILE
 
117
        echo "" >> $FILE 
 
118
        aplay -l >> $FILE 2>&1
 
119
        echo "" >> $FILE
 
120
        echo "ARECORD" >> $FILE
 
121
        echo "" >> $FILE
 
122
        arecord -l >> $FILE 2>&1
 
123
        echo "" >> $FILE
 
124
}
 
125
 
 
126
withlsmod() {
 
127
        echo "!!All Loaded Modules" >> $FILE
 
128
        echo "!!------------------" >> $FILE
 
129
        echo "" >> $FILE
 
130
        lsmod |awk {'print $1'} >> $FILE
 
131
        echo "" >> $FILE
 
132
        echo "" >> $FILE
 
133
}
 
134
 
 
135
withamixer() {
 
136
        echo "!!Amixer output" >> $FILE
 
137
        echo "!!-------------" >> $FILE
 
138
        echo "" >> $FILE
 
139
        for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do
 
140
        CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}`
 
141
        echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
 
142
        echo "" >>$FILE
 
143
        amixer -c$i info>> $FILE 2>&1
 
144
        amixer -c$i>> $FILE 2>&1
 
145
        echo "" >> $FILE
 
146
        done
 
147
        echo "" >> $FILE
 
148
}
 
149
 
 
150
withalsactl() {
 
151
        echo "!!Alsactl output" >> $FILE
 
152
        echo "!!-------------" >> $FILE
 
153
        echo "" >> $FILE
 
154
        exe=""
 
155
        if [ -x /usr/sbin/alsactl ]; then
 
156
                exe="/usr/sbin/alsactl"
 
157
        fi
 
158
        if [ -x /usr/local/sbin/alsactl ]; then
 
159
                exe="/usr/local/sbin/alsactl"
 
160
        fi
 
161
        if [ -z "$exe" ]; then
 
162
                exe=`whereis alsactl | cut -d ' ' -f 2`
 
163
        fi
 
164
        $exe -f $TEMPDIR/alsactl.tmp store
 
165
        echo "--startcollapse--" >> $FILE
 
166
        cat $TEMPDIR/alsactl.tmp >> $FILE
 
167
        echo "--endcollapse--" >> $FILE
 
168
        echo "" >> $FILE
 
169
        echo "" >> $FILE
 
170
}
 
171
 
 
172
withdevices() {
 
173
        echo "!!ALSA Device nodes" >> $FILE
 
174
        echo "!!-----------------" >> $FILE
 
175
        echo "" >> $FILE
 
176
        ls -la /dev/snd/* >> $FILE
 
177
        echo "" >> $FILE
 
178
        echo "" >> $FILE
 
179
}
 
180
 
 
181
withconfigs() {
 
182
if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]
 
183
then
 
184
        echo "!!ALSA configuration files" >> $FILE
 
185
        echo "!!------------------------" >> $FILE
 
186
        echo "" >> $FILE
 
187
 
 
188
        #Check for ~/.asoundrc
 
189
        if [[ -e $HOME/.asoundrc ]]
 
190
        then
 
191
                echo "!!User specific config file (~/.asoundrc)" >> $FILE
 
192
                echo "" >> $FILE
 
193
                cat $HOME/.asoundrc >> $FILE
 
194
                echo "" >> $FILE
 
195
                echo "" >> $FILE
 
196
        fi
 
197
        #Check for .asoundrc.asoundconf (seems to be Ubuntu specific)
 
198
        if [[ -e $HOME/.asoundrc.asoundconf ]]
 
199
        then
 
200
                echo "!!asoundconf-generated config file" >> $FILE
 
201
                echo "" >> $FILE
 
202
                cat $HOME/.asoundrc.asoundconf >> $FILE
 
203
                echo "" >> $FILE
 
204
                echo "" >> $FILE
 
205
        fi
 
206
        #Check for /etc/asound.conf
 
207
        if [[ -e /etc/asound.conf ]]
 
208
        then
 
209
                echo "!!System wide config file (/etc/asound.conf)" >> $FILE
 
210
                echo "" >> $FILE
 
211
                cat /etc/asound.conf >> $FILE
 
212
                echo "" >> $FILE
 
213
                echo "" >> $FILE
 
214
        fi
 
215
fi
 
216
}
 
217
 
 
218
withsysfs() {
 
219
    local i f
 
220
    local printed=""
 
221
    for i in /sys/class/sound/*; do
 
222
        case "$i" in
 
223
            */hwC?D?)
 
224
                if [ -f $i/init_pin_configs ]; then
 
225
                    if [ -z "$printed" ]; then
 
226
                        echo "!!Sysfs Files" >> $FILE
 
227
                        echo "!!-----------" >> $FILE
 
228
                        echo "" >> $FILE
 
229
                    fi
 
230
                    for f in init_pin_configs driver_pin_configs user_pin_configs init_verbs; do
 
231
                        echo "$i/$f:" >> $FILE
 
232
                        cat $i/$f >> $FILE
 
233
                        echo >> $FILE
 
234
                    done
 
235
                    printed=yes
 
236
                fi
 
237
                ;;
 
238
            esac
 
239
    done
 
240
    if [ -n "$printed" ]; then
 
241
        echo "" >> $FILE
 
242
    fi
 
243
}
 
244
 
 
245
withdmesg() {
 
246
        echo "!!ALSA/HDA dmesg" >> $FILE
 
247
        echo "!!------------------" >> $FILE
 
248
        echo "" >> $FILE
 
249
        dmesg | grep -C1 -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' >> $FILE
 
250
        echo "" >> $FILE
 
251
        echo "" >> $FILE
 
252
}
 
253
 
 
254
withall() {
 
255
        withdevices
 
256
        withconfigs
 
257
        withaplay
 
258
        withamixer
 
259
        withalsactl
 
260
        withlsmod
 
261
        withsysfs
 
262
        withdmesg
 
263
}
 
264
 
 
265
get_alsa_library_version() {
 
266
        ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'`
 
267
 
 
268
        if [ -z "$ALSA_LIB_VERSION" ]; then
 
269
                if [ -f /etc/lsb-release ]; then
 
270
                        . /etc/lsb-release
 
271
                        case "$DISTRIB_ID" in
 
272
                                Ubuntu)
 
273
                                        if which dpkg > /dev/null ; then
 
274
                                                ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
 
275
                                        fi
 
276
 
 
277
                                        if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
 
278
                                                ALSA_LIB_VERSION=""
 
279
                                        fi
 
280
                                        return
 
281
                                        ;;
 
282
                                *)
 
283
                                        return
 
284
                                        ;;
 
285
                        esac
 
286
                elif [ -f /etc/debian_version ]; then
 
287
                        if which dpkg > /dev/null ; then
 
288
                                ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
 
289
                        fi
 
290
 
 
291
                        if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
 
292
                                ALSA_LIB_VERSION=""
 
293
                        fi
 
294
                        return
 
295
                fi
 
296
        fi
 
297
}
 
298
 
 
299
 
 
300
#Run checks to make sure the programs we need are installed.
 
301
LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
 
302
TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
 
303
DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null);
 
304
 
 
305
#Check to see if sysfs is enabled in the kernel. We'll need this later on
 
306
SYSFS=$(mount |grep sysfs|awk {'print $3'});
 
307
 
 
308
#Check modprobe config files for sound related options
 
309
SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p')
 
310
 
 
311
KEEP_OUTPUT=
 
312
NFILE=""
 
313
 
 
314
PASTEBIN=""
 
315
WWWSERVICE="www.alsa-project.org"
 
316
WELCOME="yes"
 
317
PROCEED="yes"
 
318
UPLOAD="ask"
 
319
REPEAT=""
 
320
while [ -z "$REPEAT" ]; do
 
321
REPEAT="no"
 
322
case "$1" in
 
323
        --update|--help|--about)
 
324
                WELCOME="no"
 
325
                PROCEED="no"
 
326
                ;;
 
327
        --upload)
 
328
                UPLOAD="yes"
 
329
                WELCOME="no"
 
330
                ;;
 
331
        --no-upload)
 
332
                UPLOAD="no"
 
333
                WELCOME="no"
 
334
                ;;
 
335
        --pastebin)
 
336
                PASTEBIN="yes"
 
337
                WWWSERVICE="pastebin"
 
338
                ;;
 
339
        --no-dialog)
 
340
                DIALOG=""
 
341
                REPEAT=""
 
342
                shift
 
343
                ;;
 
344
        --stdout)
 
345
                DIALOG=""
 
346
                UPLOAD="no"
 
347
                WELCOME="no"
 
348
                TOSTDOUT="yes"
 
349
                ;;
 
350
esac
 
351
done
 
352
 
 
353
 
 
354
#Script header output.
 
355
if [ "$WELCOME" = "yes" ]; then
 
356
greeting_message="\
 
357
 
 
358
This script visits the following commands/files to collect diagnostic
 
359
information about your ALSA installation and sound related hardware.
 
360
 
 
361
  dmesg
 
362
  lspci
 
363
  lsmod
 
364
  aplay
 
365
  amixer
 
366
  alsactl
 
367
  /proc/asound/
 
368
  /sys/class/sound/
 
369
  ~/.asoundrc (etc.)
 
370
 
 
371
See '$0 --help' for command line options.
 
372
"
 
373
if [[ -n "$DIALOG" ]]; then
 
374
        dialog  --backtitle "$BGTITLE" \
 
375
                --title "ALSA-Info script v $SCRIPT_VERSION" \
 
376
                --msgbox "$greeting_message" 20 80
 
377
else
 
378
        echo "ALSA Information Script v $SCRIPT_VERSION"
 
379
        echo "--------------------------------"
 
380
        echo "$greeting_message"
 
381
fi # dialog
 
382
fi # WELCOME
 
383
 
 
384
#Set the output file
 
385
TEMPDIR=`mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1
 
386
FILE="$TEMPDIR/alsa-info.txt"
 
387
if [ -z "$NFILE" ]; then
 
388
        NFILE=`mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1
 
389
fi
 
390
 
 
391
trap cleanup 0
 
392
 
 
393
if [ "$PROCEED" = "yes" ]; then
 
394
 
 
395
if [[ -z "$LSPCI" ]] 
 
396
then
 
397
        echo "This script requires lspci. Please install it, and re-run this script."
 
398
        exit 0
 
399
fi
 
400
 
 
401
#Fetch the info and store in temp files/variables
 
402
DISTRO=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}`
 
403
KERNEL_VERSION=`uname -r`
 
404
KERNEL_PROCESSOR=`uname -p`
 
405
KERNEL_MACHINE=`uname -m`
 
406
KERNEL_OS=`uname -o`
 
407
[[ `uname -v |grep SMP`  ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" 
 
408
ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'`
 
409
get_alsa_library_version
 
410
ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}`
 
411
VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp`
 
412
DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >$TEMPDIR/device_id.tmp`
 
413
LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 ))
 
414
 
 
415
ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
 
416
PAINST=$(which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
 
417
ARTSINST=$(which artsd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
 
418
JACKINST=$(which jackd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
 
419
DMIDECODE=$(which dmidecode 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
 
420
 
 
421
#Check for DMI data
 
422
if [ -d /sys/class/dmi/id ]; then
 
423
    # No root privileges are required when using sysfs method
 
424
    DMI_SYSTEM_MANUFACTURER=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null)
 
425
    DMI_SYSTEM_PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
 
426
elif [ -x $DMIDECODE ]; then
 
427
    DMI_SYSTEM_MANUFACTURER=$($DMIDECODE -s system-manufacturer 2>/dev/null)
 
428
    DMI_SYSTEM_PRODUCT_NAME=$($DMIDECODE -s system-product-name 2>/dev/null)
 
429
fi
 
430
 
 
431
cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp
 
432
cat /proc/asound/cards >$TEMPDIR/alsacards.tmp
 
433
lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp
 
434
 
 
435
#Check for HDA-Intel cards codec#*
 
436
cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null
 
437
 
 
438
#Check for AC97 cards codec
 
439
cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null
 
440
cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null
 
441
 
 
442
#Fetch the info, and put it in $FILE in a nice readable format.
 
443
if [[ -z $PASTEBIN ]]; then
 
444
echo "upload=true&script=true&cardinfo=" > $FILE
 
445
else
 
446
echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE
 
447
fi
 
448
echo "!!################################" >> $FILE
 
449
echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE
 
450
echo "!!################################" >> $FILE
 
451
echo "" >> $FILE
 
452
echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE
 
453
echo "" >> $FILE
 
454
echo "" >> $FILE
 
455
echo "!!Linux Distribution" >> $FILE
 
456
echo "!!------------------" >> $FILE
 
457
echo "" >> $FILE
 
458
echo $DISTRO >> $FILE
 
459
echo "" >> $FILE
 
460
echo "" >> $FILE
 
461
echo "!!DMI Information" >> $FILE
 
462
echo "!!---------------" >> $FILE
 
463
echo "" >> $FILE
 
464
echo "Manufacturer:      $DMI_SYSTEM_MANUFACTURER" >> $FILE
 
465
echo "Product Name:      $DMI_SYSTEM_PRODUCT_NAME" >> $FILE
 
466
echo "" >> $FILE
 
467
echo "" >> $FILE
 
468
echo "!!Kernel Information" >> $FILE
 
469
echo "!!------------------" >> $FILE
 
470
echo "" >> $FILE
 
471
echo "Kernel release:    $KERNEL_VERSION" >> $FILE
 
472
echo "Operating System:  $KERNEL_OS" >> $FILE
 
473
echo "Architecture:      $KERNEL_MACHINE" >> $FILE
 
474
echo "Processor:         $KERNEL_PROCESSOR" >> $FILE
 
475
echo "SMP Enabled:       $KERNEL_SMP" >> $FILE
 
476
echo "" >> $FILE
 
477
echo "" >> $FILE
 
478
echo "!!ALSA Version" >> $FILE
 
479
echo "!!------------" >> $FILE
 
480
echo "" >> $FILE
 
481
echo "Driver version:     $ALSA_DRIVER_VERSION" >> $FILE
 
482
echo "Library version:    $ALSA_LIB_VERSION" >> $FILE
 
483
echo "Utilities version:  $ALSA_UTILS_VERSION" >> $FILE
 
484
echo "" >> $FILE
 
485
echo "" >> $FILE
 
486
echo "!!Loaded ALSA modules" >> $FILE
 
487
echo "!!-------------------" >> $FILE
 
488
echo "" >> $FILE
 
489
cat $TEMPDIR/alsamodules.tmp >> $FILE
 
490
echo "" >> $FILE
 
491
echo "" >> $FILE
 
492
echo "!!Sound Servers on this system" >> $FILE
 
493
echo "!!----------------------------" >> $FILE
 
494
echo "" >> $FILE
 
495
if [[ -n $PAINST ]];then
 
496
[[ `pgrep '^(.*/)?pulseaudio$'` ]] && PARUNNING="Yes" || PARUNNING="No"
 
497
echo "Pulseaudio:" >> $FILE
 
498
echo "      Installed - Yes ($PAINST)" >> $FILE
 
499
echo "      Running - $PARUNNING" >> $FILE
 
500
echo "" >> $FILE
 
501
fi
 
502
if [[ -n $ESDINST ]];then
 
503
[[ `pgrep '^(.*/)?esd$'` ]] && ESDRUNNING="Yes" || ESDRUNNING="No"
 
504
echo "ESound Daemon:" >> $FILE
 
505
echo "      Installed - Yes ($ESDINST)" >> $FILE
 
506
echo "      Running - $ESDRUNNING" >> $FILE
 
507
echo "" >> $FILE
 
508
fi
 
509
if [[ -n $ARTSINST ]];then
 
510
[[ `pgrep '^(.*/)?artsd$'` ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No"
 
511
echo "aRts:" >> $FILE
 
512
echo "      Installed - Yes ($ARTSINST)" >> $FILE
 
513
echo "      Running - $ARTSRUNNING" >> $FILE
 
514
echo "" >> $FILE
 
515
fi
 
516
if [[ -n $JACKINST ]];then
 
517
[[ `pgrep '^(.*/)?jackd$'` ]] && JACKRUNNING="Yes" || JACKRUNNING="No"
 
518
echo "Jack:" >> $FILE
 
519
echo "      Installed - Yes ($JACKINST)" >> $FILE
 
520
echo "      Running - $JACKRUNNING" >> $FILE
 
521
echo "" >> $FILE
 
522
fi
 
523
if [[ -z "$PAINST" && -z "$ESDINST" && -z "$ARTSINST" && -z "$JACKINST" ]];then
 
524
echo "No sound servers found." >> $FILE
 
525
echo "" >> $FILE
 
526
fi
 
527
echo "" >> $FILE
 
528
echo "!!Soundcards recognised by ALSA" >> $FILE
 
529
echo "!!-----------------------------" >> $FILE
 
530
echo "" >> $FILE
 
531
cat $TEMPDIR/alsacards.tmp >> $FILE
 
532
echo "" >> $FILE
 
533
echo "" >> $FILE
 
534
echo "!!PCI Soundcards installed in the system" >> $FILE
 
535
echo "!!--------------------------------------" >> $FILE
 
536
echo "" >> $FILE
 
537
cat $TEMPDIR/lspci.tmp >> $FILE
 
538
echo "" >> $FILE
 
539
echo "" >> $FILE
 
540
echo "!!Advanced information - PCI Vendor/Device/Susbsystem ID's" >> $FILE
 
541
echo "!!--------------------------------------------------------" >> $FILE
 
542
echo "" >> $FILE
 
543
lspci -vvn |grep -A1 040[1-3] >> $FILE
 
544
echo "" >> $FILE
 
545
echo "" >> $FILE
 
546
 
 
547
if [ "$SNDOPTIONS" ]
 
548
then
 
549
echo "!!Modprobe options (Sound related)" >> $FILE
 
550
echo "!!--------------------------------" >> $FILE
 
551
echo "" >> $FILE
 
552
modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE
 
553
echo "" >> $FILE
 
554
echo "" >> $FILE
 
555
fi
 
556
 
 
557
if [ -d "$SYSFS" ]
 
558
then
 
559
echo "!!Loaded sound module options" >> $FILE
 
560
echo "!!--------------------------" >> $FILE
 
561
echo "" >> $FILE
 
562
for mod in `cat /proc/asound/modules|awk {'print $2'}`;do
 
563
echo "!!Module: $mod" >> $FILE
 
564
for params in `echo $SYSFS/module/$mod/parameters/*`; do
 
565
        echo -ne "\t";
 
566
        echo "$params : `cat $params`" | sed 's:.*/::';
 
567
done >> $FILE
 
568
echo "" >> $FILE
 
569
done
 
570
echo "" >> $FILE
 
571
fi
 
572
 
 
573
if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ] 
 
574
then
 
575
        echo "!!HDA-Intel Codec information" >> $FILE
 
576
        echo "!!---------------------------" >> $FILE
 
577
        echo "--startcollapse--" >> $FILE
 
578
        echo "" >> $FILE
 
579
        cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE
 
580
        echo "--endcollapse--" >> $FILE
 
581
        echo "" >> $FILE
 
582
        echo "" >> $FILE
 
583
fi
 
584
 
 
585
if [ -s "$TEMPDIR/alsa-ac97.tmp" ]
 
586
then
 
587
        echo "!!AC97 Codec information" >> $FILE
 
588
        echo "!!---------------------------" >> $FILE
 
589
        echo "--startcollapse--" >> $FILE
 
590
        echo "" >> $FILE
 
591
        cat $TEMPDIR/alsa-ac97.tmp >> $FILE
 
592
        echo "" >> $FILE
 
593
        cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE
 
594
        echo "--endcollapse--" >> $FILE
 
595
        echo "" >> $FILE
 
596
        echo "" >> $FILE
 
597
fi
 
598
 
 
599
 
 
600
#If no command line options are specified, then run as though --with-all was specified
 
601
if [[ -z "$1" ]]
 
602
then
 
603
        update
 
604
        withall
 
605
        pbcheck 
 
606
fi
 
607
 
 
608
fi # proceed
 
609
 
 
610
#loop through command line arguments, until none are left.
 
611
if [[ -n "$1" ]]
 
612
then
 
613
        until [ -z "$1" ]
 
614
        do
 
615
        case "$1" in
 
616
                --pastebin)
 
617
                        update
 
618
                        withall
 
619
                        pbcheck
 
620
                        ;;
 
621
                --update)
 
622
                        update
 
623
                        exit
 
624
                        ;;
 
625
                --upload)
 
626
                        UPLOAD="yes"
 
627
                        withall
 
628
                        ;;
 
629
                --no-upload)
 
630
                        UPLOAD="no"
 
631
                        withall
 
632
                        ;;
 
633
                --output)
 
634
                        shift
 
635
                        NFILE="$1"
 
636
                        KEEP_OUTPUT="yes"
 
637
                        ;;
 
638
                --debug)
 
639
                        echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted"
 
640
                        KEEP_FILES="yes"
 
641
                        echo ""
 
642
                        withall
 
643
                        ;;
 
644
                --with-all)
 
645
                        withall
 
646
                        ;;
 
647
                --with-aplay)
 
648
                        withaplay
 
649
                        ;;
 
650
                --with-amixer)
 
651
                        withamixer
 
652
                        ;;
 
653
                --with-alsactl)
 
654
                        withalsactl
 
655
                        ;;
 
656
                --with-devices)
 
657
                        withdevices
 
658
                        ;;
 
659
                --with-dmesg)
 
660
                        withdmesg
 
661
                        ;;
 
662
                --with-configs)
 
663
                        if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]]
 
664
                        then
 
665
                                echo "!!ALSA configuration files" >> $FILE
 
666
                                echo "!!------------------------" >> $FILE
 
667
                                echo "" >> $FILE
 
668
 
 
669
                                #Check for ~/.asoundrc
 
670
                                if [[ -e $HOME/.asoundrc ]]
 
671
                                then
 
672
                                        echo "!!User specific config file ($HOME/.asoundrc)" >> $FILE
 
673
                                        echo "" >> $FILE
 
674
                                        cat $HOME/.asoundrc >> $FILE
 
675
                                        echo "" >> $FILE
 
676
                                        echo "" >> $FILE
 
677
                                fi
 
678
 
 
679
                                #Check for /etc/asound.conf
 
680
                                if [[ -e /etc/asound.conf ]]
 
681
                                then
 
682
                                        echo "!!System wide config file (/etc/asound.conf)" >> $FILE
 
683
                                        echo "" >> $FILE
 
684
                                        cat /etc/asound.conf >> $FILE
 
685
                                        echo "" >> $FILE
 
686
                                        echo "" >> $FILE
 
687
                                fi
 
688
                        fi
 
689
                        ;;
 
690
                --stdout)
 
691
                        UPLOAD="no"
 
692
                        withall
 
693
                        cat $FILE
 
694
                        rm $FILE
 
695
                        ;;
 
696
                --about)
 
697
                        echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
 
698
                        echo ""
 
699
                        echo "  wishie - Script author and developer / Testing"
 
700
                        echo "  crimsun - Various script ideas / Testing"
 
701
                        echo "  gnubien - Various script ideas / Testing"
 
702
                        echo "  GrueMaster - HDA Intel specific items / Testing"
 
703
                        echo "  olegfink - Script update function"
 
704
                        echo "  TheMuso - display to stdout functionality"
 
705
                        exit 0
 
706
                        ;;
 
707
                *)
 
708
                        echo "alsa-info.sh version $SCRIPT_VERSION"
 
709
                        echo ""
 
710
                        echo "Available options:"
 
711
                        echo "  --with-aplay (includes the output of aplay -l)"
 
712
                        echo "  --with-amixer (includes the output of amixer)"
 
713
                        echo "  --with-alsactl (includes the output of alsactl)"
 
714
                        echo "  --with-configs (includes the output of ~/.asoundrc and"
 
715
                        echo "      /etc/asound.conf if they exist)" 
 
716
                        echo "  --with-devices (shows the device nodes in /dev/snd/)"
 
717
                        echo "  --with-dmesg (shows the ALSA/HDA kernel messages)"
 
718
                        echo ""
 
719
                        echo "  --output FILE (specify the file to output for no-upload mode)"
 
720
                        echo "  --update (check server for script updates)"
 
721
                        echo "  --upload (upload contents to remote server)"
 
722
                        echo "  --no-upload (do not upload contents to remote server)"
 
723
                        echo "  --pastebin (use http://pastebin.ca) as remote server"
 
724
                        echo "      instead www.alsa-project.org"
 
725
                        echo "  --stdout (print alsa information to standard output"
 
726
                        echo "      instead of a file)"
 
727
                        echo "  --about (show some information about the script)"
 
728
                        echo "  --debug (will run the script as normal, but will not"
 
729
                        echo "       delete $FILE)"
 
730
                        exit 0
 
731
                        ;;
 
732
        esac
 
733
        shift 1
 
734
        done
 
735
fi
 
736
 
 
737
if [ "$PROCEED" = "no" ]; then
 
738
        exit 1
 
739
fi
 
740
 
 
741
if [ "$UPLOAD" = "ask" ]; then
 
742
        if [[ -n "$DIALOG" ]]; then
 
743
                dialog --backtitle "$BGTITLE" --title "Information collected" --yes-label " UPLOAD / SHARE " --no-label " SAVE LOCALLY " --defaultno --yesno "\n\nAutomatically upload ALSA information to $WWWSERVICE?" 10 80
 
744
                DIALOG_EXIT_CODE=$?
 
745
                if [ $DIALOG_EXIT_CODE != 0 ]; then
 
746
                        UPLOAD="no"
 
747
                else
 
748
                        UPLOAD="yes"
 
749
                fi
 
750
        else
 
751
                echo -n "Automatically upload ALSA information to $WWWSERVICE? [y/N] : "
 
752
                read -e CONFIRM
 
753
                if [ "$CONFIRM" != "y" ]; then
 
754
                        UPLOAD="no"
 
755
                else
 
756
                        UPLOAD="yes"
 
757
                fi
 
758
        fi
 
759
 
 
760
fi
 
761
 
 
762
if [ "$UPLOAD" = "no" ]; then
 
763
 
 
764
        if [ -z "$TOSTDOUT" ]; then
 
765
                mv -f $FILE $NFILE || exit 1
 
766
                KEEP_OUTPUT="yes"
 
767
        fi
 
768
 
 
769
        if [[ -n $DIALOG ]]
 
770
        then
 
771
                if [[ -n $PBERROR ]]; then
 
772
                        dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occurred while contacting the $WWWSERVICE.\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE" 10 100
 
773
                else
 
774
                        dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60
 
775
                fi
 
776
        else
 
777
                echo
 
778
 
 
779
                if [[ -n $PBERROR ]]; then
 
780
                        echo "An error occurred while contacting the $WWWSERVICE."
 
781
                        echo "Your information was NOT automatically uploaded."
 
782
                        echo ""
 
783
                        echo "Your ALSA information is in $NFILE"
 
784
                        echo ""
 
785
                else
 
786
                        if [ -z "$TOSTDOUT" ]; then
 
787
                                echo ""
 
788
                                echo "Your ALSA information is in $NFILE"
 
789
                                echo ""
 
790
                        fi
 
791
                fi
 
792
        fi
 
793
 
 
794
        exit
 
795
 
 
796
fi # UPLOAD
 
797
 
 
798
#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. 
 
799
if
 
800
WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
 
801
then
 
802
 
 
803
if [[ -n $DIALOG ]]
 
804
then
 
805
 
 
806
if [[ -z $PASTEBIN ]]; then
 
807
        wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
 
808
        { for i in 10 20 30 40 50 60 70 80 90; do
 
809
                echo $i
 
810
                sleep 0.2
 
811
        done
 
812
        echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.alsa-project.org ..." 6 70 0
 
813
else
 
814
        wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
 
815
        { for i in 10 20 30 40 50 60 70 80 90; do
 
816
                echo $i
 
817
                sleep 0.2
 
818
        done
 
819
        echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
 
820
fi
 
821
 
 
822
dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 
 
823
DIALOG_EXIT_CODE=$?
 
824
if [ $DIALOG_EXIT_CODE = 0 ]; then
 
825
        grep -v "alsa-info.txt" $FILE >$TEMPDIR/uploaded.txt
 
826
        dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0
 
827
fi
 
828
 
 
829
clear
 
830
 
 
831
# no dialog
 
832
else
 
833
 
 
834
if [[ -z $PASTEBIN ]]; then
 
835
        echo -n "Uploading information to www.alsa-project.org ... " 
 
836
        wget -O - --tries=5 --timeout=60 --post-file=$FILE http://www.alsa-project.org/cardinfo-db/ &>$TEMPDIR/wget.tmp &
 
837
else
 
838
        echo -n "Uploading information to www.pastebin.ca ... " 
 
839
        wget -O - --tries=5 --timeout=60 --post-file=$FILE http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp &
 
840
fi
 
841
 
 
842
#Progess spinner for wget transfer.
 
843
i=1
 
844
sp="/-\|"
 
845
echo -n ' '
 
846
while pgrep wget &>/dev/null
 
847
do
 
848
        echo -en "\b${sp:i++%${#sp}:1}"
 
849
done
 
850
 
 
851
echo -e "\b Done!"
 
852
echo ""
 
853
 
 
854
fi #dialog
 
855
 
 
856
#See if tput is available, and use it if it is. 
 
857
if [[ -n "$TPUT" ]]
 
858
then
 
859
        if [[ -z $PASTEBIN ]]; then
 
860
                FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0`
 
861
        else
 
862
                FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
 
863
        fi
 
864
else
 
865
        if [[ -z $PASTEBIN ]]; then
 
866
                FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2`
 
867
        else
 
868
                FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
 
869
        fi
 
870
fi
 
871
 
 
872
#Output the URL of the uploaded file.   
 
873
echo "Your ALSA information is located at $FINAL_URL"
 
874
echo "Please inform the person helping you."
 
875
echo ""
 
876
 
 
877
#We couldnt find a suitable wget, so tell the user to upload manually.
 
878
else
 
879
        mv -f $FILE $NFILE || exit 1
 
880
        KEEP_OUTPUT="yes"
 
881
        if [[ -z $DIALOG ]]
 
882
        then
 
883
                if [[ -z $PASTEBIN ]]; then
 
884
                echo ""
 
885
                echo "Could not automatically upload output to http://www.alsa-project.org"
 
886
                echo "Possible reasons are:"
 
887
                echo "    1. Couldnt find 'wget' in your PATH"
 
888
                echo "    2. Your version of wget is less than 1.8.2"
 
889
                echo ""
 
890
                echo "Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
 
891
                echo ""
 
892
                else
 
893
                echo ""
 
894
                echo "Could not automatically upload output to http://www.pastebin.ca"
 
895
                echo "Possible reasons are:"
 
896
                echo "    1. Couldnt find 'wget' in your PATH"
 
897
                echo "    2. Your version of wget is less than 1.8.2"
 
898
                echo ""
 
899
                echo "Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post."
 
900
                echo ""
 
901
                fi
 
902
        else
 
903
                if [[ -z $PASTEBIN ]]; then
 
904
                        dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.alsa-project.org.\nPossible reasons are:\n\n    1. Couldn't find 'wget' in your PATH\n    2. Your version of wget is less than 1.8.2\n\nPlease manually upload $NFILE to http://www.alsa-project,org/cardinfo-db/ and submit your post." 25 100
 
905
                else
 
906
                        dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.pastebin.ca.\nPossible reasons are:\n\n    1. Couldn't find 'wget' in your PATH\n    2. Your version of wget is less than 1.8.2\n\nPlease manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post." 25 100
 
907
                fi
 
908
        fi
 
909
fi
 
910
 
 
911