Porting alsa-info to sysfs -- for ARM platforms

Takashi Iwai tiwai at suse.de
Wed Apr 11 10:27:42 EDT 2012


At Mon, 9 Apr 2012 17:35:52 -0400,
Martin Langhoff wrote:
> 
> Hi Jaroslav, Takashi,
> 
> I am addressing you, because you seem to be the alsa-info maintainers. I am
> part of OLPC's dev team, and our latest XO laptop model is based on a very
> power-efficient ARM CPU.
> 
> One of the oddities of the ARM platform is that it doesn't have a PCI bus,
> so alsa works fine, but the PCI bus isn't there. More practically, lspci
> isn't there so alsa-info doesn't want to play ball.
> 
> The same info can be obtained from sysfs on modern linuxen. Are there any
> plans to port (or fall back) to reading sysfs? Or maybe a better way?

Better to fix alsa-info.sh to be runnable without lspci, yes.
Does the patch below suffice?


thanks,

Takashi

---
diff --git a/utils/alsa-info.sh b/utils/alsa-info.sh
index fd7df96..30c55ca 100755
--- a/utils/alsa-info.sh
+++ b/utils/alsa-info.sh
@@ -392,12 +392,6 @@ trap cleanup 0
 
 if [ "$PROCEED" = "yes" ]; then
 
-if [[ -z "$LSPCI" ]] 
-then
-	echo "This script requires lspci. Please install it, and re-run this script."
-	exit 0
-fi
-
 #Fetch the info and store in temp files/variables
 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}`
 KERNEL_VERSION=`uname -r`
@@ -408,8 +402,6 @@ KERNEL_OS=`uname -o`
 ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'`
 get_alsa_library_version
 ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}`
-VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp`
-DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >$TEMPDIR/device_id.tmp`
 LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 ))
 
 ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
@@ -432,7 +424,9 @@ fi
 
 cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp
 cat /proc/asound/cards >$TEMPDIR/alsacards.tmp
-lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp
+if [[ -n "$LSPCI" ]]; then
+    lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp
+fi
 
 #Check for HDA-Intel cards codec#*
 cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null
@@ -537,6 +531,7 @@ echo "" >> $FILE
 cat $TEMPDIR/alsacards.tmp >> $FILE
 echo "" >> $FILE
 echo "" >> $FILE
+if [[ -n "$LSPCI" ]]; then
 echo "!!PCI Soundcards installed in the system" >> $FILE
 echo "!!--------------------------------------" >> $FILE
 echo "" >> $FILE
@@ -549,6 +544,7 @@ echo "" >> $FILE
 lspci -vvn |grep -A1 040[1-3] >> $FILE
 echo "" >> $FILE
 echo "" >> $FILE
+endif
 
 if [ "$SNDOPTIONS" ]
 then


More information about the Devel mailing list