⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alsaconf.in

📁 alsa-utils-1.0.14编译声卡驱动所需要的一些文件源码
💻 IN
📖 第 1 页 / 共 3 页
字号:
# Exit functionacex() {  cleanup  clear  exit $1}## search for alsasound init script#if [ "$distribution" = "debian" ]; then    rcalsasound=/etc/init.d/alsaelif [ -x /etc/init.d/alsasound ]; then    rcalsasound=/etc/init.d/alsasoundelif [ -x /usr/sbin/rcalsasound ]; then    rcalsasound=/usr/sbin/rcalsasoundelif [ -x /sbin/rcalsasound ]; then    rcalsasound=/sbin/rcalsasoundelif [ -x /etc/rc.d/init.d/alsasound ]; then    rcalsasound=/etc/rc.d/init.d/alsasoundelif [ -x /etc/init.d/alsa ]; then    rcalsasound=/etc/init.d/alsaelse    rcalsasound=rcalsasoundfi    # MAINif [ -d $PROCFS/asound ]; then  $rcalsasound stop >/dev/null 2>&1  $rcalsasound unload >/dev/null 2>&1  /sbin/rmmod dmasound dmasound_awacs 2>/dev/nullficleanup () {    killall -9 aplay arecord >/dev/null 2>&1    /sbin/modprobe -r isapnp >/dev/null 2>&1    /sbin/modprobe -r isa-pnp >/dev/null 2>&1    rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP"}trap cleanup 0 TMP=`mktemp -q /tmp/alsaconf.XXXXXX`if [ $? -ne 0 ]; then	xecho "Can't create temp file, exiting..."        exit 1fiaddcfg=`mktemp -q /tmp/alsaconf.XXXXXX`if [ $? -ne 0 ]; then	xecho "Can't create temp file, exiting..."        exit 1fiFOUND=`mktemp -q /tmp/alsaconf.XXXXXX`if [ $? -ne 0 ]; then	xecho "Can't create temp file, exiting..."        exit 1fiDUMP=`mktemp -q /tmp/alsaconf.XXXXXX`if [ $? -ne 0 ]; then	xecho "Can't create temp file, exiting..."        exit 1fi# convert ISA PnP id number to string 'ABC'convert_isapnp_id () {    if [ -z "$1" ]; then	echo "XXXX"	return    fi    let a='('$1'>>2) & 0x3f'    let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)'    let c='('$1'>> 8) & 0x1f'    strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ'    echo ${strs:$a:1}${strs:$b:1}${strs:$c:1}}# swap high & low bytesswap_number () {    if [ -z "$1" ]; then	echo "0000"	return    fi    let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)'    printf "%04x" $v}# build card database# build_card_db filenamebuild_card_db () {    MODDIR=/lib/modules/`uname -r`    last_driver=""    echo -n > $1    # list pci cards    while read driver vendor device dummy; do	if expr $driver : 'snd-.*' >/dev/null ; then	    if [ "$last_driver" != "$driver" ]; then		echo $driver.o		last_driver=$driver	    fi	    id1=`printf '0x%04x' $vendor`	    id2=`printf '0x%04x' $device`	    echo "PCI: $id1=$id2"	fi    done < $MODDIR/modules.pcimap >> $1    # list isapnp cards    while read driver cardvendor carddevice data vendor func; do	if expr $driver : 'snd-.*' >/dev/null ; then	    if [ "$last_driver" != "$driver" ]; then		echo $driver.o		last_driver=$driver	    fi	    id1=`convert_isapnp_id $cardvendor`	    dev1=`swap_number $carddevice`	    id2=`convert_isapnp_id $vendor`	    dev2=`swap_number $func`	    echo "ISAPNP: $id1$dev1=$id2$dev2"	fi    done < $MODDIR/modules.isapnpmap >> $1}## probe cards#probe_cards () {    found="0"    test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1    test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1    if [ -r $PROCFS/isapnp ]; then	cat $PROCFS/isapnp >"$DUMP"	found="1"    elif [ -d $SYSFS/bus/pnp/devices ]; then	# use 2.6 kernel's sysfs output	# fake the isapnp dump	index=0	bindex=0	for d1 in $SYSFS/devices/pnp* ; do	  for d2 in $d1/*:* ; do	    if [ -r $d2/card_id ]; then	      id=`cat $d2/card_id`	      name=`cat $d2/name`	      echo "Card $index '$id:$name' " >> "$DUMP"	      index=$[$index+1]	      found="1"	    else if [ -r $d2/id ]; then	      # FIXME: multiple id might be present (separated with new-line)	      id=`head -n 1 $d2/id`	      echo "BIOS $bindex '$id' " >> "$DUMP"	      bindex=$[$bindex+1]	      found="1"	    fi	    fi	  done	done    fi    if [ "$found" = "0" ]; then      echo -n >"$DUMP"    fi     CARDID_DB=/var/tmp/alsaconf.cards    if [ ! -r $CARDID_DB ]; then        use_modinfo_db=1    fi    if [ $use_modinfo_db != 1 ]; then	if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then	    use_modinfo_db=1	fi    fi    if [ $use_modinfo_db = 1 ]; then	xecho "Building card database.."	build_card_db $CARDID_DB    fi    if [ ! -r $CARDID_DB ]; then	xecho "No card database is found.."	exit 1    fi    ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w`    msg=$(gettext "Searching sound cards")    awk 'BEGIN {	format="%-40s %s\n";	ncards='"$ncards"';	idx=0;}/^snd-.*\.o$/{	sub(/.o$/, "");	driver=$0;	perc=(idx * 100) / (ncards + 1);	print int(perc);	idx++;}/^[<literal space><literal tab>]*PCI: /{	gsub(/0x/, "");	gsub(/=/, ":");	x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2);	if (system (x) == 0)		printf "%s %s\n", $2, driver >>"'"$FOUND"'"}/^[<literal space><literal tab>]*ISAPNP: /{	id2 = substr($0, index($0, "=")+1);	gsub(/=.*/, "");	x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2);	if (system (x) == 0)		printf "%s %s\n", $2, driver >>"'"$FOUND"'"	else if (index($2, "ffff") > 0) {		x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2);		if (system (x) == 0)			printf "%s %s\n", id2, driver >>"'"$FOUND"'"	}}' < $CARDID_DB |\    $DIALOG --gauge "$msg" 6 40 0    #    # PowerMac    #    if grep -q MacRISC $PROCFS/cpuinfo; then	MODDIR=/lib/modules/`uname -r`	find $MODDIR -name 'snd-powermac*' -print | \	while read i; do	    i=${i##*/}	    i=${i%%.o}	    i=${i%%.ko}	    echo "PowerMac $i" >> $FOUND	done    fi    #    # Sparc    #    if grep -q Sparc $PROCFS/cpuinfo; then	test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1	# Check for an "audio" device	audio=	compat=	if test -r $PROCFS/openprom; then	    audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print`	fi	if test -n "$audio"; then	    compat=`cat $audio/compatible`	    compat=${compat#\'}	    compat=${compat%\'}	    compat=${compat#SUNW,}	fi	# Go through all cards we have	MODDIR=/lib/modules/`uname -r`	find $MODDIR -name 'snd-sun-*' -print | \	while read i; do	    i=${i##*/}	    i=${i%%.o}	    i=${i%%.ko}	    sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"`	    if test "$sdev" = "$compat"; then		echo "$sdev $i" >> $FOUND	    elif test -r $PROCFS/openprom; then		find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \		    -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND	    else		echo "$sdev $i" >> $FOUND	    fi	done    fi}## look for a descriptive device name from the given device id#find_device_name () {    if expr "$1" : '[0-9a-f][0-9a-f][0-9a-f][0-9a-f]:[0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then	$lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g'	return    elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then	cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'`	echo $cardname    else	echo $1    fi}# get hwcfg file type from the given driver nameget_hwcfg_type () {    while read dev driver; do	if [ "$driver" = "$1" ]; then	    case "$dev" in	    *:*)		# FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?)		devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'`		case "$devid" in		*:*:*.*) ;;		*) devid="0000:$devid" ;;		esac		echo bus-pci-$devid		;;	    *)		echo $driver		;;	    esac	    break	fi    done}# clean up all hwcfg-* files containing ALSA modules# alsaconf sets up exclusivelycleanup_hwcfg () {    for i in /etc/sysconfig/hardware/hwcfg-*; do	grep -q "MODULE='snd-" $i && rm -f $i    done}## set up /etc/sysconfig/hardware/hwcfg-* stuff#setup_hwcfg () {    card=$1    cleanup_hwcfg    cfg=`echo "$devs_olist" | get_hwcfg_type $card`    echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg    echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg}## configure and try test sound#ac_config_card () {    CARD_DRIVER=snd-$1    CARD_OPTS="${*:2}"    if [ -n "$cfgout" ]; then	msg=$(xmsg "Configuring %sDo you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile)        $DIALOG --yesno "$msg" 8 50 || acex 0    else	msg=$(xmsg "Configuring %sDo you want to modify %s?" $CARD_DRIVER $cfgfile)        $DIALOG --yesno "$msg" 8 50 || acex 0    fi    clear    # Copy conf.modules and make changes.    ACB="# --- BEGIN: Generated by ALSACONF, do not edit. ---"    ACE="# --- END: Generated by ALSACONF, do not edit. ---"    # Detect 2.2.X kernel    KVER=`uname -r | tr ".-" "  "`    KVER1=`echo $KVER | cut -d" " -f1`    KVER2=`echo $KVER | cut -d" " -f2`    if [ $KVER1 -ge 2 ] && [ $KVER2 -ge 2 ]; then	SOUND_CORE="soundcore"    else	SOUND_CORE="snd"    fi    if [ -r $cfgfile ] ; then        if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then            remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP        else	    remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP        fi    fi    if [ -z "$have_alias" -a "$kernel" = "new" ]; then	if grep -q char-major-116 /lib/modules/`uname -r`/modules.alias; then	    have_alias="yes"	fi    fi    if [ -z "$have_alias" ]; thenecho "alias char-major-116 sndalias char-major-14 $SOUND_COREalias sound-service-0-0 snd-mixer-ossalias sound-service-0-1 snd-seq-ossalias sound-service-0-3 snd-pcm-ossalias sound-service-0-8 snd-seq-ossalias sound-service-0-12 snd-pcm-oss" >> $addcfg    fi    if [ -n "$alsa_device_opts" ]; then	echo "options snd $alsa_device_opts" >> $addcfg    fiecho "alias snd-card-0 $CARD_DRIVERalias sound-slot-0 $CARD_DRIVER" >> $addcfg    if [ -n "$CARD_OPTS" ]; then	echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg    fi    if [ -n "$cfgout" ]; then	[ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"	cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout"    else	echo "$ACB# --- ALSACONF version $version ---" >> $TMP        cat "$addcfg" >> "$TMP"	echo "$ACE" >> $TMP        cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile"    fi    /sbin/depmod -a 2>/dev/null    # remove yast2 entries (- only for suse distro)    if [ -f /var/lib/YaST/unique.inf ]; then	awk 'BEGIN { in_sound=0; }/^\[sound\]$/ { print; in_sound=1; next; }/^\[.+\]$/ { print; in_sound=0; next; }{ if (in_sound == 0) { print; } }' < /var/lib/YaST/unique.inf > $TMP	cp -f $TMP /var/lib/YaST/unique.inf    fi    # set up /etc/sysconfig/hardware/*    if [ "$distribution" = "suse" ]; then	case "$suse_version" in	10.*|10)	    setup_hwcfg $CARD_DRIVER	    ;;	esac    fi    farewell    clear    if [ "$distribution" = "gentoo" ]; then      xecho "Running modules-update..."      modules-update    elif [ "$distribution" = "debian" ]; then      xecho "Running update-modules..."      update-modules    fi    if [ -x $rcalsasound ] ; then      echo Loading driver...      $rcalsasound restart    fi    echo Setting default volumes...    if [ -x $bindir/set_default_volume ]; then	$bindir/set_default_volume -f    else	set_mixers    fi    if [ -f $TESTSOUND ]; then      msg=$(gettext "       The mixer is set up now for for playing.       Shall I try to play a sound sample now?                           NOTE:If you have a big amplifier, lower your volumes or say no.    Otherwise check that your speaker volume is open,          and look if you can hear test sound.")      if $DIALOG --yesno "$msg" 13 65       then          clear	  echo	  aplay -N $TESTSOUND      fi    fi    if [ ! -r /etc/asound.state ]; then	xecho "Saving the mixer setup used for this in /etc/asound.state."	$sbindir/alsactl store    fi    clear    xecho "=============================================================================== Now ALSA is ready to use. For adjustment of volumes, use your favorite mixer. Have a lot of fun!"}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -