[alsaconf] fix probing, option clean up.

- Fixed the probing brokenness by my last change.
- Fixed long options.
- Now -L option requires the logfile argument.
- Corrected manpage.
This commit is contained in:
Takashi Iwai 2004-08-31 16:27:25 +00:00
parent 398713e136
commit dfec58eb7e
2 changed files with 45 additions and 25 deletions

View file

@ -24,41 +24,55 @@ on your system and writes a suitable configuration file for ALSA. It will try
to guess what GNU/Linux distribution you're running, and will act accordingly to guess what GNU/Linux distribution you're running, and will act accordingly
to the standards of that distribution, if specific support is available. to the standards of that distribution, if specific support is available.
.PP .PP
Alsaconf will write a modutils snippet which can be then used by modutils Alsaconf will write a module-init-tools (or modutils) snippet which can be then used by module-init-tools (or modutils)
to load the correct parameters for your sound card. to load the correct parameters for your sound card.
.SH OPTIONS .SH OPTIONS
Alsaconf accepts the following options: Alsaconf accepts the following options:
.TP .TP
.B \-l, \-\-legacy .B \-l, \-\-legacy
Check only for legacy non-isapnp cards Check only for legacy non-isapnp cards.
.TP .TP
.B \-m, \-\-modinfo .B \-m, \-\-modinfo
Read module descriptions instead of reading a card database. Read module descriptions instead of reading a card database.
.TP .TP
.B \-s, \-\-sound\-wav\-file .B \-s, \-\-sound\-wav\-file
Use the specified wav file as a test sound Use the specified wav file as a test sound.
.TP .TP
.B \-u, \-\-uid uid .B \-u, \-\-uid uid
Set the uid for the ALSA devices (default = 0) Set the uid for the ALSA devices (default = 0).
This option is obsolete in the recent ALSA version.
.TP .TP
.B \-g, \-\-gid gid .B \-g, \-\-gid gid
Set the gid for the ALSA devices (default = 0) Set the gid for the ALSA devices (default = 0).
This option is obsolete in the recent ALSA version.
.TP .TP
.B \-d, \-\-devmode mode .B \-d, \-\-devmode mode
Set the device mode for the ALSA devices (default = 0666) Set the device mode for the ALSA devices (default = 0666).
This option is obsolete in the recent ALSA version.
.TP .TP
.B \-r, \-\-strict .B \-r, \-\-strict
Set strict device mode (equiv. with -g 17 -d 0660) Set strict device mode (equiv. with -g 17 -d 0660).
This option is obsolete in the recent ALSA version.
.TP .TP
.B \-L, \-\-log .B \-L, \-\-log file
Logging on /tmp/alsaconf.log Logging on the given file. The log is appended to the file.
This option is for debugging purpose only.
.TP .TP
.B \-p, \-\-probe card-name .B \-p, \-\-probe card-name
Probe a legacy non-isapnp card and print module options Probe a legacy non-isapnp card and print module options.
.TP
.B \-P, \-\-listprobe
List the supported legacy card modules.
.TP
.B \-c, \-\-config file
Specify the module config file.
As default,
.B alsaconf
probes the available config file automatically.
.TP .TP
.B \-h, \-\-help .B \-h, \-\-help
Displays this help text Displays this help text.
.SH DEBIAN SPECIFIC .SH DEBIAN SPECIFIC
In Debian, the default gid of the device files is 29 (corresponding to the In Debian, the default gid of the device files is 29 (corresponding to the

View file

@ -59,26 +59,26 @@ usage() {
echo " -d|--devmode mode" echo " -d|--devmode mode"
echo " set the permission for ALSA devices (default = 0666) [obs.]" echo " set the permission for ALSA devices (default = 0666) [obs.]"
echo " -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]" echo " -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted]"
echo " -L|--log logging on $LOGFILE" echo " -L|--log file logging on the specified file (for debugging purpose only)"
echo " -p|--probe card-name" echo " -p|--probe card-name"
echo " probe a legacy non-isapnp card and print module options" echo " probe a legacy non-isapnp card and print module options"
echo " -P|--listprobe list the supported legacy card modules" echo " -P|--listprobe list the supported legacy card modules"
echo " -c|--config specify the module config file" echo " -c|--config file"
echo " specify the module config file"
echo " -h|--help what you're reading" echo " -h|--help what you're reading"
exit 1 exit 1
} }
OPTS=`getopt -o lmLhp:Pu:g:d:rs:c: --long legacy,modinfo,log,help,probe,listprobe,uid,gid,devmode,strict,sound,config -n alsaconf -- "$@"` || exit 1 OPTS=`getopt -o lmL:hp:Pu:g:d:rs:c: --long legacy,modinfo,log:,help,probe:,listprobe,uid:,gid:,devmode:,strict,sound:,config: -n alsaconf -- "$@"` || exit 1
eval set -- "$OPTS" eval set -- "$OPTS"
do_legacy_only=0 do_legacy_only=0
use_modinfo_db=0 use_modinfo_db=0
do_logging=0
alsa_uid=0 alsa_uid=0
alsa_gid=0 alsa_gid=0
alsa_mode=0666 alsa_mode=0666
legacy_probe_card="" legacy_probe_card=""
LOGFILE="/tmp/alsaconf.log" LOGFILE=""
TESTSOUND="@TESTSOUND@" TESTSOUND="@TESTSOUND@"
try_all_combination=0 try_all_combination=0
@ -96,7 +96,7 @@ while true ; do
-h|--help) -h|--help)
usage; exit 1 ;; usage; exit 1 ;;
-L|--log) -L|--log)
do_logging=1; rm -f $LOGFILE; shift;; LOGFILE="$2"; shift 2;;
-p|--probe) -p|--probe)
legacy_probe_card="$2"; shift 2;; legacy_probe_card="$2"; shift 2;;
-P|--listprobe) -P|--listprobe)
@ -511,7 +511,7 @@ BEGIN {
/^[<literal space><literal tab>]*PCI: /{ /^[<literal space><literal tab>]*PCI: /{
gsub(/0x/, ""); gsub(/0x/, "");
gsub(/=/, ":"); gsub(/=/, ":");
x = sprintf ("'$lspci' -n 2>/dev/null| grep '"'Class 040?'"' | grep %s", $2); x = sprintf ("'$lspci' -n 2>/dev/null| grep '"'Class 040.'"' | grep %s", $2);
if (system (x) == 0) if (system (x) == 0)
printf "%s %s\n", $2, driver >>"'"$FOUND"'" printf "%s %s\n", $2, driver >>"'"$FOUND"'"
} }
@ -738,7 +738,7 @@ check_irq_avail () {
# check playback # check playback
# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem) # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
ac_try_load () { ac_try_load () {
test $do_logging = 1 && echo "$1 ${*:2}" >> $LOGFILE test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
/sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1 /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1
if $lsmod | grep -E '^(snd-|snd_)'$1' ' >/dev/null 2>&1; then if $lsmod | grep -E '^(snd-|snd_)'$1' ' >/dev/null 2>&1; then
: ; : ;
@ -764,11 +764,11 @@ ac_try_load () {
/sbin/modprobe -r snd-$1 >/dev/null 2>&1 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
if [ $st = 0 ]; then if [ $st = 0 ]; then
# irq problem? # irq problem?
test $do_logging = 1 && echo "no playback return" >> $LOGFILE test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE"
return 2 return 2
else else
# seems ok! # seems ok!
test $do_logging = 1 && echo "playback OK" >> $LOGFILE test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE"
return 0 return 0
fi fi
} }
@ -777,7 +777,7 @@ ac_try_load () {
# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem) # return 0 - OK, 1 - NG, 2 - not working (irq/dma problem)
# ac_try_capture card duplex opts # ac_try_capture card duplex opts
ac_try_capture () { ac_try_capture () {
test $do_logging = 1 && echo "$1 ${*:2}" >> $LOGFILE test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE"
/sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1 /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1
if $lsmod | grep -E '^(snd-|snd_)'$1' ' >/dev/null 2>&1; then if $lsmod | grep -E '^(snd-|snd_)'$1' ' >/dev/null 2>&1; then
: ; : ;
@ -809,10 +809,10 @@ ac_try_capture () {
test $play_pid != 0 && kill -9 $play_pid test $play_pid != 0 && kill -9 $play_pid
/sbin/modprobe -r snd-$1 >/dev/null 2>&1 /sbin/modprobe -r snd-$1 >/dev/null 2>&1
if [ $st = 0 ]; then if [ $st = 0 ]; then
test $do_logging = 1 && echo "capture no return" >> $LOGFILE test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE"
return 2 return 2
else else
test $do_logging = 1 && echo "capture OK" >> $LOGFILE test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE"
return 0 return 0
fi fi
} }
@ -882,7 +882,7 @@ ac_try_dmas () {
return 1 return 1
fi fi
elif [ $result = 0 ]; then elif [ $result = 0 ]; then
test $do_logging = 1 && echo "Now checking capture..." >> $LOGFILE test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE"
ac_opts="$opts" ac_opts="$opts"
ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0 ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0
for d in yes no; do for d in yes no; do
@ -1096,6 +1096,12 @@ ac_config_legacy () {
# main part continued.. # main part continued..
# #
if test -n "$LOGFILE" ; then
touch "$LOGFILE"
echo -n "Starting alsaconf: " >> "$LOGFILE"
date >> "$LOGFILE"
fi
if [ x"$legacy_probe_card" != x ]; then if [ x"$legacy_probe_card" != x ]; then
ac_opts="" ac_opts=""
if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then