Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 35695 - ALSA init script from alsa-utils fails to fully init the snd-emu10k1 driver for my Live sound card.
Summary: ALSA init script from alsa-utils fails to fully init the snd-emu10k1 driver f...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Jeremy Huddleston (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-12 19:23 UTC by Timothy Weiand
Modified: 2004-02-16 10:25 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timothy Weiand 2003-12-12 19:23:54 UTC
After emerging an correctly setting up alsa-driver and alsa-util I tried to used the /etc/init.d/alsasound in the boot runlevel.  All ALSA drivers where correctly loaded for my audio card (SB Live) but the snd-emu10k1 (and maybe the sequencers after it).

Reproducible: Always
Steps to Reproduce:
1. Have correct hw installed.
2. emerge alsa-driver and alsa-utils
3. modules-update with correct config
4. rc-update add alsasound boot
5. restart, view startup logs

Actual Results:  
Failed to load correct module for my soundcard.  Below is the alsasound that I
have setup for debug that I use.  This works on my machine.

Expected Results:  
#!/sbin/runscript
# $Header: /home/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsasound,v 1.5
2003/12/04 16:38:42 vapier Exp $
#
# Gentoo users: add this script to 'boot' run level.
# ==================================================
#
# alsasound     	This shell script takes care of starting and stopping
#               	the ALSA sound driver.
#
# This script requires /usr/sbin/alsactl and /usr/bin/aconnect programs
# from the alsa-utils package.
#
# Copyright (c) by Jaroslav Kysela <perex@suse.cz> 
#
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

#	Edited to support Linux kernel 2.5 and above as well as 2.4
#	John Mylchreest <johnm@gentoo.org>
#	July 29, 2003 

alsactl=/usr/sbin/alsactl
asoundcfg=/etc/asound.state
aconnect=/usr/bin/aconnect
alsascrdir=/etc/alsa.d

depend() {
	need bootmisc localmount
	before modules
	after isapnp
	provide alsa-modules
}

start() {
	if [ -d /proc/asound ] && [ -z "$(grep ' no soundcards ' /proc/asound/cards)" ]
; then
		ebegin "ALSA Detected (Doing nothing)"
	else
		ebegin "Loading ALSA drivers -- DEBUG SCRIPT -- "
		
		# I really dislike this and would like to tidy it up.
		# Anyone running 2.4 + alsa-driver willing to help me?
		
		DRIVERS="$(modprobe -c | grep snd.* | grep pci: | awk '{ print $3 }' | uniq)"
		if [ -z "${DRIVERS}" ] ; then
			# Fallback on older modprobe syntax
			ewarn "* Using Old Modprobe"
			DRIVERS="$(/sbin/modprobe -c | grep -E
"^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | awk '{print $3}')"
		fi
		
		[ -z "${DRIVERS}" ] && eerror "Unable to find any ALSA drivers. Have you
compiled alsa-drivers correctly?"

		ewarn "     Starting OSS"
		OSS="$(modprobe -l | grep "snd.*oss" | sed -e "s:\/.*\/::" -e "s:\..*::")"
		for i in ${OSS}
		do
			DRIVERS="${i} ${DRIVERS}"
		done
		
		ewarn "     Starting Card Drivers"
		for DRIVER in ${DRIVERS}
		do
			if [ ! "${DRIVER}" = off ] ; then
				if [ -z "$(echo ${DRIVER} | grep -i ^snd-)" ] ; then
					ewarn "     -->Loading: snd-${DRIVER}"
					/sbin/modprobe snd-${DRIVER}
				fi
				if [ -z "$(echo ${DRIVER} | grep -vi ^snd-)" ] ; then
					ewarn "     -->Loading: ${DRIVER}"
					/sbin/modprobe ${DRIVER}
				fi
			fi
		done
		
		sleep 1
		
		ewarn "     Starting Sequencers"
		if [ -f /proc/asound/seq/drivers ] ; then
			SEQUENCERS="$(cut -d"," -f1 /proc/asound/seq/drivers)"
			for SEQUENCER in ${SEQUENCERS}
			do
				ewarn "     -->Loading sequencer: ${SEQUENCER}"
				[ -n "${SEQUENCER}" ] && /sbin/modprobe ${SEQUENCER}
			done
		fi
		
		ewarn "     Running card-dependent scripts"
		for DRIVER in ${DRIVERS}
		do
			TMP=${DRIVER##snd-}
			[ -x "${alsascrdir}/${TMP}" ] && ${alsascrdir}/${TMP}
		done
		
		[ ! -d /proc/asound ] && eerror "ERROR: Failed to load necessary drivers"
	fi
	
	einfo "Restoring Mixer Levels"
	if [ ! -r $asoundcfg ]; then
		ewarn "No mixer config in $asoundcfg, you have to unmute your card!"
		eend 1
	elif [ -x $alsactl ]; then
		CARDS="$(cat /proc/asound/cards | awk '/: / { print $1 }')"
		for CARDNUM in ${CARDS}
		do
			$alsactl -f $asoundcfg restore ${CARDNUM}
		done
	else
		eerror -e "ERROR: Cannot find alsactl, did you forget to install
media-sound/alsa-utils?"
		eend 1
	fi
	eend 0
}

stop() {
	if [ ! -d /proc/asound ] ; then
		eerror "ALSA is not loaded"
		return 0
	fi
	
	ebegin "Unloading ALSA"
	terminate
	einfo "Storing ALSA Mixer Levels"
	if [ -x $alsactl ]; then
		$alsactl -f $asoundcfg store
	else
		eerror -e "ERROR: Cannot find alsactl, did you forget to install
media-sound/alsa-utils?"
		eend 1
	fi

	LOADED_MODULES="$(/sbin/lsmod | grep -E "^snd" | awk '{print $1}')"
	einfo "Unloading modules"
	for MODULE in ${LOADED_MODULES}
	do
		/sbin/rmmod ${MODULE} 2> /dev/null
	done
	/sbin/rmmod soundcore 2> /dev/null
	/sbin/rmmod gameport 2> /dev/null	
	eend 0
}

terminate() {
	#
	# Kill processes holding open sound devices
	#
	# DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls
-dils | grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*`
	ossdevs="/dev/admmidi? /dev/adsp? /dev/amidi? /dev/audio* /dev/dmfm* \
			/dev/dmmidi? /dev/dsp* /dev/dspW* /dev/midi0? /dev/mixer? /dev/music \
			/dev/patmgr? /dev/sequencer* /dev/sndstat"
	alsadevs="/proc/asound/dev/*"
	fuser -k $ossdevs $alsadevs 2> /dev/null 1>/dev/null
	
	#
	# remove all sequencer connections if any
	#
	[ -f /proc/asound/seq/clients -a -x $aconnect ] && $aconnect --removeall
}


Portage 2.0.49-r15 (default-x86-1.4, gcc-3.2.3, glibc-2.3.2-r3, 2.4.20-gentoo-r9)
=================================================================
System uname: 2.4.20-gentoo-r9 i686 Intel(R) Pentium(R) 4 CPU 2.40GHz
Gentoo Base System version 1.4.3.10
ACCEPT_KEYWORDS="x86"           
AUTOCLEAN="yes"                 
CFLAGS="-O3 -march=pentium4 -fPIC -msse2 -mmmx -msse -mfpmath=sse,387
-funroll-loops -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"       
COMPILER="gcc3"                 
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config
/usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O3 -march=pentium4 -fPIC -msse2 -mmmx -msse -mfpmath=sse,387
-funroll-loops -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="sandbox ccache autoaddcvs"
GENTOO_MIRRORS="http://128.213.5.34/gentoo/ http://cudlug.cudenver.edu/gentoo/
http://gentoo.noved.org/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="x86 oss apm avi crypt cups encode foomaticdb gif gtk2 imlib jpeg libg++ mad
mikmod motif mpeg ncurses pdflib png quicktime spell truetype xml2 xmms xv zlib
gdbm berkdb slang readline tetex svga X sdl gpm tcpd pam libwww ssl perl python
oggvorbis gtk qt opengl mozilla aalib acpi acpi4linux alsa directfb doc dvd
ethereal etwin faad fbcon fbdev flexresp freetype gmtsuppl gmttria javascript
joystick maildir mmx moznoirc moznomail offensive oscar parse-clocks radeon
samba skey sse tiff transcode usb vim-with-x xchattext xine xml -arts -kde
-gnome -nls video_cards_radeon"
Comment 1 Jeremy Huddleston (RETIRED) gentoo-dev 2004-02-15 05:50:37 UTC
try the new init script located here: /usr/portage/media-sound/alsa-utils/files/alsasound

No need to re-emerge the package just for the init script.

Also, please provide your /etc/modules.d/alsa file
Comment 2 Timothy Weiand 2004-02-16 10:25:40 UTC
Error was in /etc/modules.d/alsa.  I had emu10k1 instead of snd-emu10k1.  Sorry for the trouble!


When using /usr/portage/media-sound/alsa-utils/files/alsasound:
---------------------------------------------------------------
 * Loading ALSA drivers...
 * Using ALSA OSS emulation
 * Loading: snd-seq-oss
 * Loading: snd-pcm-oss
 * Loading: emu10k1
modprobe: Can't locate module emu10k1
 * Running card-dependent scripts
 * Restoring Mixer Levels  

After this there is no snd-emu10k1 in lsmod.

Whole /etc/modules.d/alsa file:
-------------------------------
# Alsa 0.9.X kernel modules' configuration file.
# $Header: /home/cvsroot/gentoo-x86/media-sound/alsa-utils/files/alsa-modules.conf-rc,v 1.1 2003/08/05 21:07:55 johnm Exp $

# ALSA portion
alias char-major-116 snd
# OSS/Free portion
alias char-major-14 soundcore

##
## IMPORTANT:
## You need to customise this section for your specific sound card(s)
## and then run `update-modules' command.
## Read alsa-driver's INSTALL file in /usr/share/doc for more info.
##
##  ALSA portion
alias snd-card-0 emu10k1
## alias snd-card-1 snd-ens1371
##  OSS/Free portion
alias sound-slot-0 snd-card-0
## alias sound-slot-1 snd-card-1
##

# OSS/Free portion - card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
##  OSS/Free portion - card #2
## alias sound-service-1-0 snd-mixer-oss
## alias sound-service-1-3 snd-pcm-oss
## alias sound-service-1-12 snd-pcm-oss

alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/midi snd-seq-oss

# Set this to the correct number of cards.
options snd cards_limit=1