Blame SOURCES/alsa-utils-1.0.28-post.patch

55d01a
diff --git a/Makefile.am b/Makefile.am
55d01a
index f25eee2..248eb11 100644
55d01a
--- a/Makefile.am
55d01a
+++ b/Makefile.am
55d01a
@@ -1,6 +1,6 @@
55d01a
 AM_CPPFLAGS=-I$(top_srcdir)/include
55d01a
 
55d01a
-SUBDIRS = include alsactl alsaucm utils m4 po
55d01a
+SUBDIRS = include alsactl alsaucm utils m4 po alsa-info
55d01a
 if ALSAMIXER
55d01a
 SUBDIRS += alsamixer
55d01a
 endif
55d01a
diff --git a/alsa-info/Makefile.am b/alsa-info/Makefile.am
55d01a
new file mode 100644
55d01a
index 0000000..1a47e60
55d01a
--- /dev/null
55d01a
+++ b/alsa-info/Makefile.am
55d01a
@@ -0,0 +1 @@
55d01a
+sbin_SCRIPTS = alsa-info.sh
55d01a
diff --git a/alsa-info/alsa-info.sh b/alsa-info/alsa-info.sh
55d01a
new file mode 100755
55d01a
index 0000000..acd8495
55d01a
--- /dev/null
55d01a
+++ b/alsa-info/alsa-info.sh
55d01a
@@ -0,0 +1,943 @@
55d01a
+#!/bin/bash
55d01a
+
55d01a
+SCRIPT_VERSION=0.4.64
55d01a
+CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog"
55d01a
+
55d01a
+#################################################################################
55d01a
+#Copyright (C) 2007 Free Software Foundation.
55d01a
+
55d01a
+#This program is free software; you can redistribute it and/or modify
55d01a
+#it under the terms of the GNU General Public License as published by
55d01a
+#the Free Software Foundation; either version 2 of the License, or
55d01a
+#(at your option) any later version.
55d01a
+
55d01a
+#This program is distributed in the hope that it will be useful,
55d01a
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
55d01a
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55d01a
+#GNU General Public License for more details.
55d01a
+
55d01a
+#You should have received a copy of the GNU General Public License
55d01a
+#along with this program; if not, write to the Free Software
55d01a
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
55d01a
+
55d01a
+##################################################################################
55d01a
+
55d01a
+#The script was written for 2 main reasons:
55d01a
+# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user.
55d01a
+# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them.
55d01a
+
55d01a
+#Set the locale (this may or may not be a good idea.. let me know)
55d01a
+export LC_ALL=C
55d01a
+
55d01a
+#Change the PATH variable, so we can run lspci (needed for some distros)
55d01a
+PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
55d01a
+BGTITLE="ALSA-Info v $SCRIPT_VERSION"
55d01a
+PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
55d01a
+#Define some simple functions
55d01a
+
55d01a
+pbcheck(){
55d01a
+	[[ $UPLOAD = "no" ]] && return
55d01a
+
55d01a
+	if [[ -z $PASTEBIN ]]; then
55d01a
+		[[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
55d01a
+	else
55d01a
+		[[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
55d01a
+	fi
55d01a
+}
55d01a
+
55d01a
+update() {
55d01a
+	SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1
55d01a
+	wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1
55d01a
+	REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'`
55d01a
+	if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
55d01a
+		if [[ -n $DIALOG ]]
55d01a
+		then
55d01a
+			OVERWRITE=
55d01a
+			if [ -w $0 ]; then
55d01a
+				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
55d01a
+				DIALOG_EXIT_CODE=$?
55d01a
+				if [[ $DIALOG_EXIT_CODE = 0 ]]; then
55d01a
+				  OVERWRITE=yes
55d01a
+				fi
55d01a
+			fi
55d01a
+			if [ -z "$OVERWRITE" ]; then
55d01a
+				dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to download it?" 0 0
55d01a
+				DIALOG_EXIT_CODE=$?
55d01a
+			fi
55d01a
+			if [[ $DIALOG_EXIT_CODE = 0 ]]
55d01a
+			then
55d01a
+				echo "Newer version detected: $REMOTE_VERSION"
55d01a
+				echo "To view the ChangeLog, please visit $CHANGELOG"
55d01a
+				if [ "$OVERWRITE" = "yes" ]; then
55d01a
+					cp $SHFILE $0
55d01a
+					echo "ALSA-Info script has been updated to v $REMOTE_VERSION"
55d01a
+					echo "Please re-run the script"
55d01a
+					rm $SHFILE 2>/dev/null
55d01a
+				else
55d01a
+					echo "ALSA-Info script has been downloaded as $SHFILE."
55d01a
+					echo "Please re-run the script from new location."
55d01a
+				fi
55d01a
+				exit
55d01a
+			else
55d01a
+				rm $SHFILE 2>/dev/null
55d01a
+			fi
55d01a
+		else
55d01a
+			echo "Newer version detected: $REMOTE_VERSION"
55d01a
+			echo "To view the ChangeLog, please visit $CHANGELOG"
55d01a
+			if [ -w $0 ]; then
55d01a
+				echo "The original file $0 will be overwritten!"
55d01a
+				echo -n "If you do not like to proceed, press Ctrl-C now.." ; read inp
55d01a
+				cp $SHFILE $0
55d01a
+				echo "ALSA-Info script has been updated. Please re-run it."
55d01a
+				rm $SHFILE 2>/dev/null
55d01a
+			else
55d01a
+				echo "ALSA-Info script has been downloaded $SHFILE."
55d01a
+				echo "Please, re-run it from new location."
55d01a
+			fi
55d01a
+			exit
55d01a
+		fi
55d01a
+	else
55d01a
+		rm $SHFILE 2>/dev/null
55d01a
+	fi
55d01a
+}
55d01a
+
55d01a
+cleanup() {
55d01a
+	if [ -n "$TEMPDIR" -a "$KEEP_FILES" != "yes" ]; then
55d01a
+		rm -rf "$TEMPDIR" 2>/dev/null
55d01a
+	fi
55d01a
+	test -n "$KEEP_OUTPUT" || rm -f "$NFILE"
55d01a
+}
55d01a
+
55d01a
+
55d01a
+withaplay() {
55d01a
+        echo "!!Aplay/Arecord output" >> $FILE
55d01a
+        echo "!!--------------------" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+       	echo "APLAY" >> $FILE
55d01a
+	echo "" >> $FILE 
55d01a
+	aplay -l >> $FILE 2>&1
55d01a
+        echo "" >> $FILE
55d01a
+       	echo "ARECORD" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	arecord -l >> $FILE 2>&1
55d01a
+	echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withlsmod() {
55d01a
+	echo "!!All Loaded Modules" >> $FILE
55d01a
+	echo "!!------------------" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	lsmod |awk {'print $1'} >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withamixer() {
55d01a
+        echo "!!Amixer output" >> $FILE
55d01a
+        echo "!!-------------" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+	for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do
55d01a
+	CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}`
55d01a
+	echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
55d01a
+	echo "" >>$FILE
55d01a
+	amixer -c$i info>> $FILE 2>&1
55d01a
+	amixer -c$i>> $FILE 2>&1
55d01a
+        echo "" >> $FILE
55d01a
+	done
55d01a
+	echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withalsactl() {
55d01a
+	echo "!!Alsactl output" >> $FILE
55d01a
+        echo "!!--------------" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        exe=""
55d01a
+        if [ -x /usr/sbin/alsactl ]; then
55d01a
+        	exe="/usr/sbin/alsactl"
55d01a
+        fi
55d01a
+        if [ -x /usr/local/sbin/alsactl ]; then
55d01a
+        	exe="/usr/local/sbin/alsactl"
55d01a
+        fi
55d01a
+        if [ -z "$exe" ]; then
55d01a
+        	exe=`whereis alsactl | cut -d ' ' -f 2`
55d01a
+        fi
55d01a
+	$exe -f $TEMPDIR/alsactl.tmp store
55d01a
+	echo "--startcollapse--" >> $FILE
55d01a
+	cat $TEMPDIR/alsactl.tmp >> $FILE
55d01a
+	echo "--endcollapse--" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withdevices() {
55d01a
+        echo "!!ALSA Device nodes" >> $FILE
55d01a
+        echo "!!-----------------" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        ls -la /dev/snd/* >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withconfigs() {
55d01a
+if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]
55d01a
+then
55d01a
+        echo "!!ALSA configuration files" >> $FILE
55d01a
+        echo "!!------------------------" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+
55d01a
+        #Check for ~/.asoundrc
55d01a
+        if [[ -e $HOME/.asoundrc ]]
55d01a
+        then
55d01a
+                echo "!!User specific config file (~/.asoundrc)" >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+                cat $HOME/.asoundrc >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+        fi
55d01a
+	#Check for .asoundrc.asoundconf (seems to be Ubuntu specific)
55d01a
+	if [[ -e $HOME/.asoundrc.asoundconf ]]
55d01a
+	then
55d01a
+		echo "!!asoundconf-generated config file" >> $FILE
55d01a
+		echo "" >> $FILE
55d01a
+		cat $HOME/.asoundrc.asoundconf >> $FILE
55d01a
+		echo "" >> $FILE
55d01a
+		echo "" >> $FILE
55d01a
+	fi
55d01a
+        #Check for /etc/asound.conf
55d01a
+        if [[ -e /etc/asound.conf ]]
55d01a
+        then
55d01a
+                echo "!!System wide config file (/etc/asound.conf)" >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+                cat /etc/asound.conf >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+                echo "" >> $FILE
55d01a
+        fi
55d01a
+fi
55d01a
+}
55d01a
+
55d01a
+withsysfs() {
55d01a
+    local i f
55d01a
+    local printed=""
55d01a
+    for i in /sys/class/sound/*; do
55d01a
+	case "$i" in
55d01a
+	    */hwC?D?)
55d01a
+		if [ -f $i/init_pin_configs ]; then
55d01a
+		    if [ -z "$printed" ]; then
55d01a
+			echo "!!Sysfs Files" >> $FILE
55d01a
+			echo "!!-----------" >> $FILE
55d01a
+			echo "" >> $FILE
55d01a
+		    fi
55d01a
+		    for f in init_pin_configs driver_pin_configs user_pin_configs init_verbs hints; do
55d01a
+			echo "$i/$f:" >> $FILE
55d01a
+			cat $i/$f >> $FILE
55d01a
+			echo >> $FILE
55d01a
+		    done
55d01a
+		    printed=yes
55d01a
+		fi
55d01a
+		;;
55d01a
+	    esac
55d01a
+    done
55d01a
+    if [ -n "$printed" ]; then
55d01a
+	echo "" >> $FILE
55d01a
+    fi
55d01a
+}
55d01a
+
55d01a
+withdmesg() {
55d01a
+	echo "!!ALSA/HDA dmesg" >> $FILE
55d01a
+	echo "!!--------------" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	dmesg | grep -C1 -E 'ALSA|HDA|HDMI|snd[_-]|sound|hda.codec|hda.intel' >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+}
55d01a
+
55d01a
+withall() {
55d01a
+	withdevices
55d01a
+	withconfigs
55d01a
+	withaplay
55d01a
+	withamixer
55d01a
+	withalsactl
55d01a
+	withlsmod
55d01a
+	withsysfs
55d01a
+	withdmesg
55d01a
+	WITHALL="no"
55d01a
+}
55d01a
+
55d01a
+get_alsa_library_version() {
55d01a
+	ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'`
55d01a
+
55d01a
+	if [ -z "$ALSA_LIB_VERSION" ]; then
55d01a
+		if [ -f /etc/lsb-release ]; then
55d01a
+			. /etc/lsb-release
55d01a
+			case "$DISTRIB_ID" in
55d01a
+				Ubuntu)
55d01a
+					if which dpkg > /dev/null ; then
55d01a
+						ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
55d01a
+					fi
55d01a
+
55d01a
+					if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
55d01a
+						ALSA_LIB_VERSION=""
55d01a
+					fi
55d01a
+					return
55d01a
+					;;
55d01a
+				*)
55d01a
+					return
55d01a
+					;;
55d01a
+			esac
55d01a
+		elif [ -f /etc/debian_version ]; then
55d01a
+			if which dpkg > /dev/null ; then
55d01a
+				ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
55d01a
+			fi
55d01a
+
55d01a
+			if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
55d01a
+				ALSA_LIB_VERSION=""
55d01a
+			fi
55d01a
+			return
55d01a
+		fi
55d01a
+	fi
55d01a
+}
55d01a
+
55d01a
+
55d01a
+#Run checks to make sure the programs we need are installed.
55d01a
+LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
55d01a
+TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
55d01a
+DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null);
55d01a
+
55d01a
+#Check to see if sysfs is enabled in the kernel. We'll need this later on
55d01a
+SYSFS=$(mount |grep sysfs|awk {'print $3'});
55d01a
+
55d01a
+#Check modprobe config files for sound related options
55d01a
+SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p')
55d01a
+
55d01a
+KEEP_OUTPUT=
55d01a
+NFILE=""
55d01a
+
55d01a
+PASTEBIN=""
55d01a
+WWWSERVICE="www.alsa-project.org"
55d01a
+WELCOME="yes"
55d01a
+PROCEED="yes"
55d01a
+UPLOAD="ask"
55d01a
+REPEAT=""
55d01a
+while [ -z "$REPEAT" ]; do
55d01a
+REPEAT="no"
55d01a
+case "$1" in
55d01a
+	--update|--help|--about)
55d01a
+		WELCOME="no"
55d01a
+		PROCEED="no"
55d01a
+		;;
55d01a
+	--upload)
55d01a
+		UPLOAD="yes"
55d01a
+		WELCOME="no"
55d01a
+		;;
55d01a
+	--no-upload)
55d01a
+		UPLOAD="no"
55d01a
+		WELCOME="no"
55d01a
+		;;
55d01a
+	--pastebin)
55d01a
+		PASTEBIN="yes"
55d01a
+		WWWSERVICE="pastebin"
55d01a
+		;;
55d01a
+	--no-dialog)
55d01a
+		DIALOG=""
55d01a
+		REPEAT=""
55d01a
+		shift
55d01a
+		;;
55d01a
+	--stdout)
55d01a
+		DIALOG=""
55d01a
+		UPLOAD="no"
55d01a
+		WELCOME="no"
55d01a
+		TOSTDOUT="yes"
55d01a
+		;;
55d01a
+esac
55d01a
+done
55d01a
+
55d01a
+
55d01a
+#Script header output.
55d01a
+if [ "$WELCOME" = "yes" ]; then
55d01a
+greeting_message="\
55d01a
+
55d01a
+This script visits the following commands/files to collect diagnostic
55d01a
+information about your ALSA installation and sound related hardware.
55d01a
+
55d01a
+  dmesg
55d01a
+  lspci
55d01a
+  lsmod
55d01a
+  aplay
55d01a
+  amixer
55d01a
+  alsactl
55d01a
+  /proc/asound/
55d01a
+  /sys/class/sound/
55d01a
+  ~/.asoundrc (etc.)
55d01a
+
55d01a
+See '$0 --help' for command line options.
55d01a
+"
55d01a
+if [ -n "$DIALOG" ]; then
55d01a
+	dialog  --backtitle "$BGTITLE" \
55d01a
+		--title "ALSA-Info script v $SCRIPT_VERSION" \
55d01a
+		--msgbox "$greeting_message" 20 80
55d01a
+else
55d01a
+	echo "ALSA Information Script v $SCRIPT_VERSION"
55d01a
+	echo "--------------------------------"
55d01a
+	echo "$greeting_message"
55d01a
+fi # dialog
55d01a
+fi # WELCOME
55d01a
+
55d01a
+#Set the output file
55d01a
+TEMPDIR=`mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1
55d01a
+FILE="$TEMPDIR/alsa-info.txt"
55d01a
+if [ -z "$NFILE" ]; then
55d01a
+	NFILE=`mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1
55d01a
+fi
55d01a
+
55d01a
+trap cleanup 0
55d01a
+
55d01a
+if [ "$PROCEED" = "yes" ]; then
55d01a
+
55d01a
+if [ -z "$LSPCI" ]; then
55d01a
+	if [ -d /sys/bus/pci ]; then
55d01a
+		echo "This script requires lspci. Please install it, and re-run this script."
55d01a
+		exit 0
55d01a
+	fi
55d01a
+fi
55d01a
+
55d01a
+#Fetch the info and store in temp files/variables
55d01a
+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}`
55d01a
+KERNEL_VERSION=`uname -r`
55d01a
+KERNEL_PROCESSOR=`uname -p`
55d01a
+KERNEL_MACHINE=`uname -m`
55d01a
+KERNEL_OS=`uname -o`
55d01a
+[[ `uname -v | grep SMP`  ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" 
55d01a
+ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'`
55d01a
+get_alsa_library_version
55d01a
+ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}`
55d01a
+LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 ))
55d01a
+
55d01a
+ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+PAINST=$(which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+ARTSINST=$(which artsd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+JACKINST=$(which jackd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+ROARINST=$(which roard 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+DMIDECODE=$(which dmidecode 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
55d01a
+
55d01a
+#Check for DMI data
55d01a
+if [ -d /sys/class/dmi/id ]; then
55d01a
+    # No root privileges are required when using sysfs method
55d01a
+    DMI_SYSTEM_MANUFACTURER=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null)
55d01a
+    DMI_SYSTEM_PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
55d01a
+    DMI_SYSTEM_PRODUCT_VERSION=$(cat /sys/class/dmi/id/product_version 2>/dev/null)
55d01a
+    DMI_SYSTEM_FIRMWARE_VERSION=$(cat /sys/class/dmi/id/bios_version 2>/dev/null)
55d01a
+elif [ -x $DMIDECODE ]; then
55d01a
+    DMI_SYSTEM_MANUFACTURER=$($DMIDECODE -s system-manufacturer 2>/dev/null)
55d01a
+    DMI_SYSTEM_PRODUCT_NAME=$($DMIDECODE -s system-product-name 2>/dev/null)
55d01a
+    DMI_SYSTEM_PRODUCT_VERSION=$($DMIDECODE -s system-version 2>/dev/null)
55d01a
+    DMI_SYSTEM_FIRMWARE_VERSION=$($DMIDECODE -s bios-version 2>/dev/null)
55d01a
+fi
55d01a
+
55d01a
+cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp
55d01a
+cat /proc/asound/cards >$TEMPDIR/alsacards.tmp
55d01a
+if [[ ! -z "$LSPCI" ]]; then
55d01a
+lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp
55d01a
+fi
55d01a
+
55d01a
+#Check for HDA-Intel cards codec#*
55d01a
+cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null
55d01a
+
55d01a
+#Check for AC97 cards codec
55d01a
+cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null
55d01a
+cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null
55d01a
+
55d01a
+#Check for USB mixer setup
55d01a
+cat /proc/asound/card*/usbmixer > $TEMPDIR/alsa-usbmixer.tmp 2> /dev/null
55d01a
+
55d01a
+#Fetch the info, and put it in $FILE in a nice readable format.
55d01a
+if [[ -z $PASTEBIN ]]; then
55d01a
+echo "upload=true&script=true&cardinfo=" > $FILE
55d01a
+else
55d01a
+echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE
55d01a
+fi
55d01a
+echo "!!################################" >> $FILE
55d01a
+echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE
55d01a
+echo "!!################################" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Linux Distribution" >> $FILE
55d01a
+echo "!!------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo $DISTRO >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!DMI Information" >> $FILE
55d01a
+echo "!!---------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "Manufacturer:      $DMI_SYSTEM_MANUFACTURER" >> $FILE
55d01a
+echo "Product Name:      $DMI_SYSTEM_PRODUCT_NAME" >> $FILE
55d01a
+echo "Product Version:   $DMI_SYSTEM_PRODUCT_VERSION" >> $FILE
55d01a
+echo "Firmware Version:  $DMI_SYSTEM_FIRMWARE_VERSION" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Kernel Information" >> $FILE
55d01a
+echo "!!------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "Kernel release:    $KERNEL_VERSION" >> $FILE
55d01a
+echo "Operating System:  $KERNEL_OS" >> $FILE
55d01a
+echo "Architecture:      $KERNEL_MACHINE" >> $FILE
55d01a
+echo "Processor:         $KERNEL_PROCESSOR" >> $FILE
55d01a
+echo "SMP Enabled:       $KERNEL_SMP" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!ALSA Version" >> $FILE
55d01a
+echo "!!------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "Driver version:     $ALSA_DRIVER_VERSION" >> $FILE
55d01a
+echo "Library version:    $ALSA_LIB_VERSION" >> $FILE
55d01a
+echo "Utilities version:  $ALSA_UTILS_VERSION" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Loaded ALSA modules" >> $FILE
55d01a
+echo "!!-------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+cat $TEMPDIR/alsamodules.tmp >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Sound Servers on this system" >> $FILE
55d01a
+echo "!!----------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+if [[ -n $PAINST ]];then
55d01a
+[[ `pgrep '^(.*/)?pulseaudio$'` ]] && PARUNNING="Yes" || PARUNNING="No"
55d01a
+echo "Pulseaudio:" >> $FILE
55d01a
+echo "      Installed - Yes ($PAINST)" >> $FILE
55d01a
+echo "      Running - $PARUNNING" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+if [[ -n $ESDINST ]];then
55d01a
+[[ `pgrep '^(.*/)?esd$'` ]] && ESDRUNNING="Yes" || ESDRUNNING="No"
55d01a
+echo "ESound Daemon:" >> $FILE
55d01a
+echo "      Installed - Yes ($ESDINST)" >> $FILE
55d01a
+echo "      Running - $ESDRUNNING" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+if [[ -n $ARTSINST ]];then
55d01a
+[[ `pgrep '^(.*/)?artsd$'` ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No"
55d01a
+echo "aRts:" >> $FILE
55d01a
+echo "      Installed - Yes ($ARTSINST)" >> $FILE
55d01a
+echo "      Running - $ARTSRUNNING" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+if [[ -n $JACKINST ]];then
55d01a
+[[ `pgrep '^(.*/)?jackd$'` ]] && JACKRUNNING="Yes" || JACKRUNNING="No"
55d01a
+echo "Jack:" >> $FILE
55d01a
+echo "      Installed - Yes ($JACKINST)" >> $FILE
55d01a
+echo "      Running - $JACKRUNNING" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+if [[ -n $ROARINST ]];then
55d01a
+[[ `pgrep '^(.*/)?roard$'` ]] && ROARRUNNING="Yes" || ROARRUNNING="No"
55d01a
+echo "RoarAudio:" >> $FILE
55d01a
+echo "      Installed - Yes ($ROARINST)" >> $FILE
55d01a
+echo "      Running - $ROARRUNNING" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+if [[ -z "$PAINST" && -z "$ESDINST" && -z "$ARTSINST" && -z "$JACKINST" && -z "$ROARINST" ]];then
55d01a
+echo "No sound servers found." >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Soundcards recognised by ALSA" >> $FILE
55d01a
+echo "!!-----------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+cat $TEMPDIR/alsacards.tmp >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+
55d01a
+if [[ ! -z "$LSPCI" ]]; then
55d01a
+echo "!!PCI Soundcards installed in the system" >> $FILE
55d01a
+echo "!!--------------------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+cat $TEMPDIR/lspci.tmp >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "!!Advanced information - PCI Vendor/Device/Subsystem ID's" >> $FILE
55d01a
+echo "!!-------------------------------------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+lspci -vvn |grep -A1 040[1-3] >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+if [ "$SNDOPTIONS" ]
55d01a
+then
55d01a
+echo "!!Modprobe options (Sound related)" >> $FILE
55d01a
+echo "!!--------------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+if [ -d "$SYSFS" ]
55d01a
+then
55d01a
+echo "!!Loaded sound module options" >> $FILE
55d01a
+echo "!!---------------------------" >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+for mod in `cat /proc/asound/modules|awk {'print $2'}`;do
55d01a
+echo "!!Module: $mod" >> $FILE
55d01a
+for params in `echo $SYSFS/module/$mod/parameters/*`; do
55d01a
+	echo -ne "\t";
55d01a
+	echo "$params : `cat $params`" | sed 's:.*/::';
55d01a
+done >> $FILE
55d01a
+echo "" >> $FILE
55d01a
+done
55d01a
+echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ]; then
55d01a
+	echo "!!HDA-Intel Codec information" >> $FILE
55d01a
+	echo "!!---------------------------" >> $FILE
55d01a
+	echo "--startcollapse--" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE
55d01a
+	echo "--endcollapse--" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+if [ -s "$TEMPDIR/alsa-ac97.tmp" ]; then
55d01a
+        echo "!!AC97 Codec information" >> $FILE
55d01a
+        echo "!!----------------------" >> $FILE
55d01a
+        echo "--startcollapse--" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        cat $TEMPDIR/alsa-ac97.tmp >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE
55d01a
+        echo "--endcollapse--" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+if [ -s "$TEMPDIR/alsa-usbmixer.tmp" ]; then
55d01a
+        echo "!!USB Mixer information" >> $FILE
55d01a
+        echo "!!---------------------" >> $FILE
55d01a
+        echo "--startcollapse--" >> $FILE
55d01a
+        echo "" >> $FILE
55d01a
+        cat $TEMPDIR/alsa-usbmixer.tmp >> $FILE
55d01a
+        echo "--endcollapse--" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+	echo "" >> $FILE
55d01a
+fi
55d01a
+
55d01a
+#If no command line options are specified, then run as though --with-all was specified
55d01a
+if [ -z "$1" ]; then
55d01a
+	update
55d01a
+	pbcheck	
55d01a
+fi
55d01a
+
55d01a
+fi # proceed
55d01a
+
55d01a
+#loop through command line arguments, until none are left.
55d01a
+if [ -n "$1" ]; then
55d01a
+	until [ -z "$1" ]
55d01a
+	do
55d01a
+	case "$1" in
55d01a
+		--pastebin)
55d01a
+		        update
55d01a
+        		pbcheck
55d01a
+			;;
55d01a
+		--update)
55d01a
+			update
55d01a
+			exit
55d01a
+			;;
55d01a
+		--upload)
55d01a
+			UPLOAD="yes"
55d01a
+			;;
55d01a
+		--no-upload)
55d01a
+			UPLOAD="no"
55d01a
+			;;
55d01a
+		--output)
55d01a
+			shift
55d01a
+			NFILE="$1"
55d01a
+			KEEP_OUTPUT="yes"
55d01a
+			;;
55d01a
+		--debug)
55d01a
+			echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted"
55d01a
+			KEEP_FILES="yes"
55d01a
+			echo ""
55d01a
+			;;
55d01a
+		--with-all)
55d01a
+			withall
55d01a
+			;;
55d01a
+		--with-aplay)
55d01a
+			withaplay
55d01a
+			WITHALL="no"
55d01a
+			;;
55d01a
+		--with-amixer)
55d01a
+			withamixer
55d01a
+			WITHALL="no"
55d01a
+			;;
55d01a
+		--with-alsactl)
55d01a
+			withalsactl
55d01a
+			WITHALL="no"
55d01a
+			;;
55d01a
+		--with-devices)
55d01a
+			withdevices
55d01a
+			WITHALL="no"
55d01a
+			;;
55d01a
+		--with-dmesg)
55d01a
+			withdmesg
55d01a
+			WITHALL="no"
55d01a
+			;;
55d01a
+		--with-configs)
55d01a
+			WITHALL="no"
55d01a
+			if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]]
55d01a
+			then
55d01a
+				echo "!!ALSA configuration files" >> $FILE
55d01a
+				echo "!!------------------------" >> $FILE
55d01a
+				echo "" >> $FILE
55d01a
+
55d01a
+				#Check for ~/.asoundrc
55d01a
+				if [[ -e $HOME/.asoundrc ]]
55d01a
+				then
55d01a
+					echo "!!User specific config file ($HOME/.asoundrc)" >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+					cat $HOME/.asoundrc >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+				fi
55d01a
+
55d01a
+				#Check for /etc/asound.conf
55d01a
+				if [[ -e /etc/asound.conf ]]
55d01a
+				then
55d01a
+					echo "!!System wide config file (/etc/asound.conf)" >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+					cat /etc/asound.conf >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+					echo "" >> $FILE
55d01a
+				fi
55d01a
+			fi
55d01a
+			;;
55d01a
+		--stdout)
55d01a
+			UPLOAD="no"
55d01a
+			if [ -z "$WITHALL" ]; then
55d01a
+				withall
55d01a
+			fi
55d01a
+			cat $FILE
55d01a
+			rm $FILE
55d01a
+			;;
55d01a
+		--about)
55d01a
+			echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
55d01a
+			echo ""
55d01a
+			echo "	wishie - Script author and developer / Testing"
55d01a
+			echo "	crimsun - Various script ideas / Testing"
55d01a
+			echo "	gnubien - Various script ideas / Testing"
55d01a
+			echo "	GrueMaster - HDA Intel specific items / Testing"
55d01a
+			echo "	olegfink - Script update function"
55d01a
+			echo "  TheMuso - display to stdout functionality"
55d01a
+			exit 0
55d01a
+			;;
55d01a
+		*)
55d01a
+			echo "alsa-info.sh version $SCRIPT_VERSION"
55d01a
+			echo ""
55d01a
+			echo "Available options:"
55d01a
+			echo "	--with-aplay (includes the output of aplay -l)"
55d01a
+			echo "	--with-amixer (includes the output of amixer)"
55d01a
+			echo "	--with-alsactl (includes the output of alsactl)"
55d01a
+			echo "	--with-configs (includes the output of ~/.asoundrc and"
55d01a
+			echo "	    /etc/asound.conf if they exist)" 
55d01a
+			echo "	--with-devices (shows the device nodes in /dev/snd/)"
55d01a
+			echo "	--with-dmesg (shows the ALSA/HDA kernel messages)"
55d01a
+			echo ""
55d01a
+			echo "	--output FILE (specify the file to output for no-upload mode)"
55d01a
+			echo "	--update (check server for script updates)"
55d01a
+			echo "	--upload (upload contents to remote server)"
55d01a
+			echo "	--no-upload (do not upload contents to remote server)"
55d01a
+			echo "	--pastebin (use http://pastebin.ca) as remote server"
55d01a
+			echo "	    instead www.alsa-project.org"
55d01a
+			echo "	--stdout (print alsa information to standard output"
55d01a
+			echo "	    instead of a file)"
55d01a
+			echo "	--about (show some information about the script)"
55d01a
+			echo "	--debug (will run the script as normal, but will not"
55d01a
+			echo "	     delete $FILE)"
55d01a
+			exit 0
55d01a
+			;;
55d01a
+	esac
55d01a
+	shift 1
55d01a
+	done
55d01a
+fi
55d01a
+
55d01a
+if [ "$PROCEED" = "no" ]; then
55d01a
+	exit 1
55d01a
+fi
55d01a
+
55d01a
+if [ -z "$WITHALL" ]; then
55d01a
+	withall
55d01a
+fi
55d01a
+
55d01a
+if [ "$UPLOAD" = "ask" ]; then
55d01a
+	if [ -n "$DIALOG" ]; then
55d01a
+		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
55d01a
+		DIALOG_EXIT_CODE=$?
55d01a
+		if [ $DIALOG_EXIT_CODE != 0 ]; then
55d01a
+			UPLOAD="no"
55d01a
+		else
55d01a
+			UPLOAD="yes"
55d01a
+		fi
55d01a
+	else
55d01a
+		echo -n "Automatically upload ALSA information to $WWWSERVICE? [y/N] : "
55d01a
+		read -e CONFIRM
55d01a
+		if [ "$CONFIRM" != "y" ]; then
55d01a
+			UPLOAD="no"
55d01a
+		else
55d01a
+			UPLOAD="yes"
55d01a
+		fi
55d01a
+	fi
55d01a
+
55d01a
+fi
55d01a
+
55d01a
+if [ "$UPLOAD" = "no" ]; then
55d01a
+
55d01a
+	if [ -z "$TOSTDOUT" ]; then
55d01a
+		mv -f $FILE $NFILE || exit 1
55d01a
+		KEEP_OUTPUT="yes"
55d01a
+	fi
55d01a
+
55d01a
+	if [[ -n $DIALOG ]]
55d01a
+	then
55d01a
+		if [[ -n $PBERROR ]]; then
55d01a
+			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
55d01a
+		else
55d01a
+			dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60
55d01a
+		fi
55d01a
+	else
55d01a
+		echo
55d01a
+
55d01a
+		if [[ -n $PBERROR ]]; then
55d01a
+			echo "An error occurred while contacting the $WWWSERVICE."
55d01a
+			echo "Your information was NOT automatically uploaded."
55d01a
+			echo ""
55d01a
+			echo "Your ALSA information is in $NFILE"
55d01a
+			echo ""
55d01a
+		else
55d01a
+			if [ -z "$TOSTDOUT" ]; then
55d01a
+				echo ""
55d01a
+				echo "Your ALSA information is in $NFILE"
55d01a
+				echo ""
55d01a
+			fi
55d01a
+		fi
55d01a
+	fi
55d01a
+
55d01a
+	exit
55d01a
+
55d01a
+fi # UPLOAD
55d01a
+
55d01a
+#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. 
55d01a
+if
55d01a
+WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
55d01a
+then
55d01a
+
55d01a
+if [[ -n $DIALOG ]]
55d01a
+then
55d01a
+
55d01a
+if [[ -z $PASTEBIN ]]; then
55d01a
+	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
55d01a
+	{ for i in 10 20 30 40 50 60 70 80 90; do
55d01a
+		echo $i
55d01a
+		sleep 0.2
55d01a
+	done
55d01a
+	echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.alsa-project.org ..." 6 70 0
55d01a
+else
55d01a
+	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"
55d01a
+	{ for i in 10 20 30 40 50 60 70 80 90; do
55d01a
+		echo $i
55d01a
+		sleep 0.2
55d01a
+	done
55d01a
+	echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
55d01a
+fi
55d01a
+
55d01a
+dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 
55d01a
+DIALOG_EXIT_CODE=$?
55d01a
+if [ $DIALOG_EXIT_CODE = 0 ]; then
55d01a
+	grep -v "alsa-info.txt" $FILE >$TEMPDIR/uploaded.txt
55d01a
+	dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0
55d01a
+fi
55d01a
+
55d01a
+clear
55d01a
+
55d01a
+# no dialog
55d01a
+else
55d01a
+
55d01a
+if [[ -z $PASTEBIN ]]; then
55d01a
+	echo -n "Uploading information to www.alsa-project.org ... " 
55d01a
+	wget -O - --tries=5 --timeout=60 --post-file=$FILE http://www.alsa-project.org/cardinfo-db/ &>$TEMPDIR/wget.tmp &
55d01a
+else
55d01a
+	echo -n "Uploading information to www.pastebin.ca ... " 
55d01a
+	wget -O - --tries=5 --timeout=60 --post-file=$FILE http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp &
55d01a
+fi
55d01a
+
55d01a
+#Progess spinner for wget transfer.
55d01a
+i=1
55d01a
+sp="/-\|"
55d01a
+echo -n ' '
55d01a
+while pgrep wget &>/dev/null
55d01a
+do
55d01a
+	echo -en "\b${sp:i++%${#sp}:1}"
55d01a
+done
55d01a
+
55d01a
+echo -e "\b Done!"
55d01a
+echo ""
55d01a
+
55d01a
+fi #dialog
55d01a
+
55d01a
+#See if tput is available, and use it if it is.	
55d01a
+if [ -n "$TPUT" ]; then
55d01a
+	if [[ -z $PASTEBIN ]]; then
55d01a
+		FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0`
55d01a
+	else
55d01a
+		FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
55d01a
+	fi
55d01a
+else
55d01a
+	if [[ -z $PASTEBIN ]]; then
55d01a
+		FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2`
55d01a
+	else
55d01a
+		FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
55d01a
+	fi
55d01a
+fi
55d01a
+
55d01a
+# Output the URL of the uploaded file.	
55d01a
+echo "Your ALSA information is located at $FINAL_URL"
55d01a
+echo "Please inform the person helping you."
55d01a
+echo ""
55d01a
+
55d01a
+# We couldnt find a suitable wget, so tell the user to upload manually.
55d01a
+else
55d01a
+	mv -f $FILE $NFILE || exit 1
55d01a
+	KEEP_OUTPUT="yes"
55d01a
+	if [[ -z $DIALOG ]]
55d01a
+	then
55d01a
+		if [[ -z $PASTEBIN ]]; then
55d01a
+		echo ""
55d01a
+		echo "Could not automatically upload output to http://www.alsa-project.org"
55d01a
+		echo "Possible reasons are:"
55d01a
+		echo "    1. Couldnt find 'wget' in your PATH"
55d01a
+		echo "    2. Your version of wget is less than 1.8.2"
55d01a
+		echo ""
55d01a
+		echo "Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
55d01a
+		echo ""
55d01a
+		else
55d01a
+		echo ""
55d01a
+		echo "Could not automatically upload output to http://www.pastebin.ca"
55d01a
+		echo "Possible reasons are:"
55d01a
+		echo "    1. Couldnt find 'wget' in your PATH"
55d01a
+		echo "    2. Your version of wget is less than 1.8.2"
55d01a
+		echo ""
55d01a
+		echo "Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post."
55d01a
+		echo ""
55d01a
+		fi
55d01a
+	else
55d01a
+		if [[ -z $PASTEBIN ]]; then
55d01a
+			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
55d01a
+		else
55d01a
+			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
55d01a
+		fi
55d01a
+	fi
55d01a
+fi
55d01a
diff --git a/alsactl/state.c b/alsactl/state.c
55d01a
index c33f501..e0c6f2e 100644
55d01a
--- a/alsactl/state.c
55d01a
+++ b/alsactl/state.c
55d01a
@@ -1626,7 +1626,7 @@ int save_state(const char *file, const char *cardname)
55d01a
 	snd_output_close(out);
55d01a
 	if (err < 0) {
55d01a
 		error("snd_config_save: %s", snd_strerror(err));
55d01a
-	} else {
55d01a
+	} else if (nfile) {
55d01a
 		err = rename(nfile, file);
55d01a
 		if (err < 0)
55d01a
 			error("rename failed: %s (%s)", strerror(-err), file);
55d01a
diff --git a/alsamixer/mainloop.c b/alsamixer/mainloop.c
55d01a
index 351f57f..79d81a9 100644
55d01a
--- a/alsamixer/mainloop.c
55d01a
+++ b/alsamixer/mainloop.c
55d01a
@@ -29,6 +29,7 @@
55d01a
 #include "widget.h"
55d01a
 #include "mixer_widget.h"
55d01a
 #include "mixer_display.h"
55d01a
+#include "mixer_controls.h"
55d01a
 #include "mainloop.h"
55d01a
 
55d01a
 static WINDOW *curses_initialized;
55d01a
diff --git a/configure.ac b/configure.ac
55d01a
index a4d2db3..3c7032b 100644
55d01a
--- a/configure.ac
55d01a
+++ b/configure.ac
55d01a
@@ -360,4 +360,4 @@ AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
55d01a
 	  utils/alsa-utils.spec seq/Makefile seq/aconnect/Makefile \
55d01a
 	  seq/aplaymidi/Makefile seq/aseqdump/Makefile seq/aseqnet/Makefile \
55d01a
 	  speaker-test/Makefile speaker-test/samples/Makefile \
55d01a
-	  alsaloop/Makefile)
55d01a
+	  alsaloop/Makefile alsa-info/Makefile)
55d01a
From 1363f852e92c1c913474fc015f9da12d1e93d750 Mon Sep 17 00:00:00 2001
55d01a
From: Jaroslav Kysela <perex@perex.cz>
55d01a
Date: Wed, 24 Sep 2014 10:35:53 +0200
55d01a
Subject: [PATCH] alsactl: Fix the file locking routines (for the state
55d01a
 management)
55d01a
55d01a
---
55d01a
 alsactl/alsactl.h |  3 ++-
55d01a
 alsactl/lock.c    | 41 +++++++++++++++++++++++++++++++----------
55d01a
 alsactl/state.c   | 22 +++++++++++++---------
55d01a
 3 files changed, 46 insertions(+), 20 deletions(-)
55d01a
55d01a
diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h
55d01a
index 76e8c36..bd9bf23 100644
55d01a
--- a/alsactl/alsactl.h
55d01a
+++ b/alsactl/alsactl.h
55d01a
@@ -25,7 +25,8 @@ void dbg_(const char *fcn, long line, const char *fmt, ...);
55d01a
 #endif	
55d01a
 
55d01a
 int init(const char *file, const char *cardname);
55d01a
-int state_lock(const char *file, int lock, int timeout);
55d01a
+int state_lock(const char *file, int timeout);
55d01a
+int state_unlock(int fd, const char *file);
55d01a
 int save_state(const char *file, const char *cardname);
55d01a
 int load_state(const char *file, const char *initfile, const char *cardname,
55d01a
 	       int do_init);
55d01a
diff --git a/alsactl/lock.c b/alsactl/lock.c
55d01a
index 6f85f20..9d7efcc 100644
55d01a
--- a/alsactl/lock.c
55d01a
+++ b/alsactl/lock.c
55d01a
@@ -30,7 +30,7 @@
55d01a
 #include <sys/stat.h>
55d01a
 #include "alsactl.h"
55d01a
 
55d01a
-static int state_lock_(const char *file, int lock, int timeout)
55d01a
+static int state_lock_(const char *file, int lock, int timeout, int _fd)
55d01a
 {
55d01a
 	int fd = -1, err = 0;
55d01a
 	struct flock lck;
55d01a
@@ -50,9 +50,14 @@ static int state_lock_(const char *file, int lock, int timeout)
55d01a
 		snprintf(lcktxt, sizeof(lcktxt), "%10li\n", (long)getpid());
55d01a
 	} else {
55d01a
 		snprintf(lcktxt, sizeof(lcktxt), "%10s\n", "");
55d01a
+		fd = _fd;
55d01a
 	}
55d01a
 	while (fd < 0 && timeout-- > 0) {
55d01a
 		fd = open(nfile, O_RDWR);
55d01a
+		if (!lock && fd < 0) {
55d01a
+			err = -EIO;
55d01a
+			goto out;
55d01a
+		}
55d01a
 		if (fd < 0) {
55d01a
 			fd = open(nfile, O_RDWR|O_CREAT|O_EXCL, 0644);
55d01a
 			if (fd < 0) {
55d01a
@@ -74,12 +79,12 @@ static int state_lock_(const char *file, int lock, int timeout)
55d01a
 		err = -errno;
55d01a
 		goto out;
55d01a
 	}
55d01a
-	if (st.st_size != 11) {
55d01a
+	if (st.st_size != 11 || !lock) {
55d01a
 		if (write(fd, lcktxt, 11) != 11) {
55d01a
 			err = -EIO;
55d01a
 			goto out;
55d01a
 		}
55d01a
-		if (lseek(fd, 0, SEEK_SET)) {
55d01a
+		if (lock && lseek(fd, 0, SEEK_SET)) {
55d01a
 			err = -errno;
55d01a
 			goto out;
55d01a
 		}
55d01a
@@ -96,21 +101,37 @@ static int state_lock_(const char *file, int lock, int timeout)
55d01a
 		err = -EBUSY;
55d01a
 		goto out;
55d01a
 	}
55d01a
-	if (write(fd, lcktxt, 11) != 11) {
55d01a
-		err = -EIO;
55d01a
-		goto out;
55d01a
+	if (lock) {
55d01a
+		if (write(fd, lcktxt, 11) != 11) {
55d01a
+			err = -EIO;
55d01a
+			goto out;
55d01a
+		}
55d01a
+		return fd;
55d01a
 	}
55d01a
+	err = 0;
55d01a
+
55d01a
 out:
55d01a
+	if (fd >= 0)
55d01a
+		close(fd);
55d01a
+	return err;
55d01a
+}
55d01a
+
55d01a
+int state_lock(const char *file, int timeout)
55d01a
+{
55d01a
+	int err;
55d01a
+
55d01a
+	err = state_lock_(file, 1, timeout, -1);
55d01a
+	if (err < 0)
55d01a
+		error("file %s lock error: %s", file, strerror(-err));
55d01a
 	return err;
55d01a
 }
55d01a
 
55d01a
-int state_lock(const char *file, int lock, int timeout)
55d01a
+int state_unlock(int _fd, const char *file)
55d01a
 {
55d01a
 	int err;
55d01a
 
55d01a
-	err = state_lock_(file, lock, timeout);
55d01a
+	err = state_lock_(file, 0, 10, _fd);
55d01a
 	if (err < 0)
55d01a
-		error("file %s %slock error: %s", file,
55d01a
-				lock ? "" : "un", strerror(-err));
55d01a
+		error("file %s unlock error: %s", file, strerror(-err));
55d01a
 	return err;
55d01a
 }
55d01a
diff --git a/alsactl/state.c b/alsactl/state.c
55d01a
index e0c6f2e..0c89703 100644
55d01a
--- a/alsactl/state.c
55d01a
+++ b/alsactl/state.c
55d01a
@@ -1544,6 +1544,7 @@ int save_state(const char *file, const char *cardname)
55d01a
 	snd_output_t *out;
55d01a
 	int stdio;
55d01a
 	char *nfile = NULL;
55d01a
+	int lock_fd = -EINVAL;
55d01a
 
55d01a
 	err = snd_config_top(&config);
55d01a
 	if (err < 0) {
55d01a
@@ -1555,12 +1556,16 @@ int save_state(const char *file, const char *cardname)
55d01a
 		nfile = malloc(strlen(file) + 5);
55d01a
 		if (nfile == NULL) {
55d01a
 			error("No enough memory...");
55d01a
+			err = -ENOMEM;
55d01a
 			goto out;
55d01a
 		}
55d01a
 		strcpy(nfile, file);
55d01a
 		strcat(nfile, ".new");
55d01a
-		if (state_lock(file, 1, 10) != 0)
55d01a
+		lock_fd = state_lock(file, 10);
55d01a
+		if (lock_fd < 0) {
55d01a
+			err = lock_fd;
55d01a
 			goto out;
55d01a
+		}
55d01a
 	}
55d01a
 	if (!stdio && (err = snd_input_stdio_open(&in, file, "r")) >= 0) {
55d01a
 		err = snd_config_load(config, in);
55d01a
@@ -1632,8 +1637,8 @@ int save_state(const char *file, const char *cardname)
55d01a
 			error("rename failed: %s (%s)", strerror(-err), file);
55d01a
 	}
55d01a
 out:
55d01a
-	if (!stdio)
55d01a
-		state_lock(file, 0, 10);
55d01a
+	if (!stdio && lock_fd >= 0)
55d01a
+		state_unlock(lock_fd, file);
55d01a
 	free(nfile);
55d01a
 	snd_config_delete(config);
55d01a
 	snd_config_update_free_global();
55d01a
@@ -1646,7 +1651,7 @@ int load_state(const char *file, const char *initfile, const char *cardname,
55d01a
 	int err, finalerr = 0;
55d01a
 	snd_config_t *config;
55d01a
 	snd_input_t *in;
55d01a
-	int stdio, locked = 0;
55d01a
+	int stdio, lock_fd = -EINVAL;
55d01a
 
55d01a
 	err = snd_config_top(&config);
55d01a
 	if (err < 0) {
55d01a
@@ -1657,15 +1662,14 @@ int load_state(const char *file, const char *initfile, const char *cardname,
55d01a
 	if (stdio) {
55d01a
 		err = snd_input_stdio_attach(&in, stdin, 0);
55d01a
 	} else {
55d01a
-		err = state_lock(file, 1, 10);
55d01a
-		locked = err >= 0;
55d01a
-		err = err >= 0 ? snd_input_stdio_open(&in, file, "r") : err;
55d01a
+		lock_fd = state_lock(file, 10);
55d01a
+		err = lock_fd >= 0 ? snd_input_stdio_open(&in, file, "r") : lock_fd;
55d01a
 	}
55d01a
 	if (err >= 0) {
55d01a
 		err = snd_config_load(config, in);
55d01a
 		snd_input_close(in);
55d01a
-		if (locked)
55d01a
-			state_lock(file, 0, 10);
55d01a
+		if (lock_fd >= 0)
55d01a
+			state_unlock(lock_fd, file);
55d01a
 		if (err < 0) {
55d01a
 			error("snd_config_load error: %s", snd_strerror(err));
55d01a
 			goto out;
55d01a
-- 
55d01a
1.9.3
55d01a
55d01a
From 74e5d57c999f8afed4f87046dcac84f6709b9196 Mon Sep 17 00:00:00 2001
55d01a
From: Jaroslav Kysela <perex@perex.cz>
55d01a
Date: Wed, 24 Sep 2014 10:46:02 +0200
55d01a
Subject: [PATCH 1/2] alsactl: aded missing monitor() prototype
55d01a
55d01a
---
55d01a
 alsactl/alsactl.h | 1 +
55d01a
 1 file changed, 1 insertion(+)
55d01a
55d01a
diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h
55d01a
index bd9bf23..4f969ec 100644
55d01a
--- a/alsactl/alsactl.h
55d01a
+++ b/alsactl/alsactl.h
55d01a
@@ -31,6 +31,7 @@ int save_state(const char *file, const char *cardname);
55d01a
 int load_state(const char *file, const char *initfile, const char *cardname,
55d01a
 	       int do_init);
55d01a
 int power(const char *argv[], int argc);
55d01a
+int monitor(const char *name);
55d01a
 int state_daemon(const char *file, const char *cardname, int period,
55d01a
 		 const char *pidfile);
55d01a
 int state_daemon_kill(const char *pidfile, const char *cmd);
55d01a
-- 
55d01a
1.9.3
55d01a
55d01a
55d01a
From da7a2f91de1c2089bf2b4ba247807cb716f30424 Mon Sep 17 00:00:00 2001
55d01a
From: Jaroslav Kysela <perex@perex.cz>
55d01a
Date: Wed, 24 Sep 2014 10:47:48 +0200
55d01a
Subject: [PATCH 2/2] speaker-text: fix simple signess assignment warning
55d01a
55d01a
---
55d01a
 speaker-test/speaker-test.c | 2 +-
55d01a
 1 file changed, 1 insertion(+), 1 deletion(-)
55d01a
55d01a
diff --git a/speaker-test/speaker-test.c b/speaker-test/speaker-test.c
55d01a
index 362efa7..ccf2671 100644
55d01a
--- a/speaker-test/speaker-test.c
55d01a
+++ b/speaker-test/speaker-test.c
55d01a
@@ -113,7 +113,7 @@ static snd_pcm_t *pcm_handle = NULL;
55d01a
 #ifdef CONFIG_SUPPORT_CHMAP
55d01a
 static snd_pcm_chmap_t *channel_map;
55d01a
 static int channel_map_set;
55d01a
-static unsigned int *ordered_channels;
55d01a
+static int *ordered_channels;
55d01a
 #endif
55d01a
 
55d01a
 static const char *const channel_name[MAX_CHANNELS] = {
55d01a
-- 
55d01a
1.9.3
55d01a
55d01a
From 17d4a5dd35e3e72a194ca295da98e62060a180a8 Mon Sep 17 00:00:00 2001
55d01a
From: Jaroslav Kysela <perex@perex.cz>
55d01a
Date: Wed, 24 Sep 2014 10:50:54 +0200
55d01a
Subject: [PATCH 1/2] monitor: fix clang warning - Declared variable-length
55d01a
 array (VLA) has zero size
55d01a
55d01a
---
55d01a
 alsactl/monitor.c | 4 ++--
55d01a
 1 file changed, 2 insertions(+), 2 deletions(-)
55d01a
55d01a
diff --git a/alsactl/monitor.c b/alsactl/monitor.c
55d01a
index 536176d..29379ad 100644
55d01a
--- a/alsactl/monitor.c
55d01a
+++ b/alsactl/monitor.c
55d01a
@@ -91,7 +91,7 @@ int monitor(const char *name)
55d01a
 	snd_ctl_t *ctls[MAX_CARDS];
55d01a
 	int ncards = 0;
55d01a
 	int show_cards;
55d01a
-	int i, err;
55d01a
+	int i, err = 0;
55d01a
 
55d01a
 	if (!name) {
55d01a
 		int card = -1;
55d01a
@@ -117,7 +117,7 @@ int monitor(const char *name)
55d01a
 		show_cards = 0;
55d01a
 	}
55d01a
 
55d01a
-	for (;;) {
55d01a
+	for (;ncards > 0;) {
55d01a
 		struct pollfd fds[ncards];
55d01a
 
55d01a
 		for (i = 0; i < ncards; i++)
55d01a
-- 
55d01a
1.9.3
55d01a
55d01a
55d01a
From 89a4f490bd974e454d82942100f241bb1a2270f3 Mon Sep 17 00:00:00 2001
55d01a
From: Jaroslav Kysela <perex@perex.cz>
55d01a
Date: Wed, 24 Sep 2014 10:52:17 +0200
55d01a
Subject: [PATCH 2/2] =?UTF-8?q?alsactl:=20coverity=20-=20missing=5Fva=5Fen?=
55d01a
 =?UTF-8?q?d=20=E2=80=93=20va=5Fend=20was=20not=20called=20for=20"ap"?=
55d01a
MIME-Version: 1.0
55d01a
Content-Type: text/plain; charset=UTF-8
55d01a
Content-Transfer-Encoding: 8bit
55d01a
55d01a
---
55d01a
 alsactl/utils.c | 4 ++--
55d01a
 1 file changed, 2 insertions(+), 2 deletions(-)
55d01a
55d01a
diff --git a/alsactl/utils.c b/alsactl/utils.c
55d01a
index b5d183c..304df7c 100644
55d01a
--- a/alsactl/utils.c
55d01a
+++ b/alsactl/utils.c
55d01a
@@ -157,8 +157,8 @@ void cerror_(const char *fcn, long line, int cond, const char *fmt, ...)
55d01a
 		fprintf(stderr, "%s: %s:%ld: ", command, fcn, line);
55d01a
 		vfprintf(stderr, fmt, ap);
55d01a
 		putc('\n', stderr);
55d01a
-		va_end(ap);
55d01a
 	}
55d01a
+	va_end(ap);
55d01a
 }
55d01a
 
55d01a
 void dbg_(const char *fcn, long line, const char *fmt, ...)
55d01a
@@ -174,6 +174,6 @@ void dbg_(const char *fcn, long line, const char *fmt, ...)
55d01a
 		fprintf(stderr, "%s: %s:%ld: ", command, fcn, line);
55d01a
 		vfprintf(stderr, fmt, ap);
55d01a
 		putc('\n', stderr);
55d01a
-		va_end(ap);
55d01a
 	}
55d01a
+	va_end(ap);
55d01a
 }
55d01a
-- 
55d01a
1.9.3
55d01a