1c72fcc34Sopenharmony_ci#!/bin/bash 2c72fcc34Sopenharmony_ci# 3c72fcc34Sopenharmony_ci# ALSA Configurator 4c72fcc34Sopenharmony_ci# 5c72fcc34Sopenharmony_ci# Copyright (c) 1999-2002 SuSE GmbH 6c72fcc34Sopenharmony_ci# Jan ONDREJ 7c72fcc34Sopenharmony_ci# 8c72fcc34Sopenharmony_ci# written by Takashi Iwai <tiwai@suse.de> 9c72fcc34Sopenharmony_ci# Bernd Kaindl <bk@suse.de> 10c72fcc34Sopenharmony_ci# Jan ONDREJ (SAL) <ondrejj@salstar.sk> 11c72fcc34Sopenharmony_ci# 12c72fcc34Sopenharmony_ci# based on the original version of Jan ONDREJ's alsaconf for ALSA 0.4. 13c72fcc34Sopenharmony_ci# 14c72fcc34Sopenharmony_ci# This program is free software; you can redistribute it and/or modify 15c72fcc34Sopenharmony_ci# it under the terms of the GNU General Public License as published by 16c72fcc34Sopenharmony_ci# the Free Software Foundation; either version 2 of the License, or 17c72fcc34Sopenharmony_ci# (at your option) any later version. 18c72fcc34Sopenharmony_ci# 19c72fcc34Sopenharmony_ci 20c72fcc34Sopenharmony_ciexport TEXTDOMAIN=alsaconf 21c72fcc34Sopenharmony_ci 22c72fcc34Sopenharmony_ciprefix=@prefix@ 23c72fcc34Sopenharmony_ciexec_prefix=@exec_prefix@ 24c72fcc34Sopenharmony_cibindir=@bindir@ 25c72fcc34Sopenharmony_cisbindir=@sbindir@ 26c72fcc34Sopenharmony_civersion=@VERSION@ 27c72fcc34Sopenharmony_ciUSE_NLS=@USE_NLS@ 28c72fcc34Sopenharmony_ci 29c72fcc34Sopenharmony_ci# Useful for debugging 30c72fcc34Sopenharmony_ciPROCFS="/proc" 31c72fcc34Sopenharmony_ciSYSFS="/sys" 32c72fcc34Sopenharmony_ci 33c72fcc34Sopenharmony_ci# i18n stuff 34c72fcc34Sopenharmony_ciif test "$USE_NLS" = "yes" && type -p gettext > /dev/null; then 35c72fcc34Sopenharmony_ci xecho() { 36c72fcc34Sopenharmony_ci gettext -s "$*" 37c72fcc34Sopenharmony_ci } 38c72fcc34Sopenharmony_cielse 39c72fcc34Sopenharmony_ci xecho() { 40c72fcc34Sopenharmony_ci echo "$*" 41c72fcc34Sopenharmony_ci } 42c72fcc34Sopenharmony_ci gettext() { 43c72fcc34Sopenharmony_ci echo -n "$*" 44c72fcc34Sopenharmony_ci } 45c72fcc34Sopenharmony_cifi 46c72fcc34Sopenharmony_cixmsg() { 47c72fcc34Sopenharmony_ci msg=$(gettext "$1") 48c72fcc34Sopenharmony_ci shift 49c72fcc34Sopenharmony_ci printf "$msg" $* 50c72fcc34Sopenharmony_ci} 51c72fcc34Sopenharmony_ci 52c72fcc34Sopenharmony_ci# Check for GNU/Linux distributions 53c72fcc34Sopenharmony_ciif [ -f /etc/SuSE-release ]; then 54c72fcc34Sopenharmony_ci distribution="suse" 55c72fcc34Sopenharmony_ci suse_version=$(grep 'VERSION = ' /etc/SuSE-release | sed -e s/'VERSION = '//) 56c72fcc34Sopenharmony_cielif [ -f /etc/UnitedLinux-release ]; then 57c72fcc34Sopenharmony_ci distribution="suse" 58c72fcc34Sopenharmony_cielif [ -f /etc/gentoo-release ]; then 59c72fcc34Sopenharmony_ci distribution="gentoo" 60c72fcc34Sopenharmony_cielif [ -f /etc/debian_version ]; then 61c72fcc34Sopenharmony_ci distribution="debian" 62c72fcc34Sopenharmony_cielif [ -f /etc/mandrake-release ]; then 63c72fcc34Sopenharmony_ci distribution="mandrake" 64c72fcc34Sopenharmony_cielif test -f /etc/redhat-release && grep -q "Red Hat" /etc/redhat-release; then 65c72fcc34Sopenharmony_ci distribution="redhat" 66c72fcc34Sopenharmony_cielif test -f /etc/fedora-release && grep -q "Fedora" /etc/fedora-release; then 67c72fcc34Sopenharmony_ci distribution="fedora" 68c72fcc34Sopenharmony_cielif [ -f /etc/slackware-version -o -f /etc/slamd64-version ]; then 69c72fcc34Sopenharmony_ci distribution="slackware" 70c72fcc34Sopenharmony_cielse 71c72fcc34Sopenharmony_ci distribution="unknown" 72c72fcc34Sopenharmony_cifi 73c72fcc34Sopenharmony_ci 74c72fcc34Sopenharmony_cifor prog in lspci lsmod; do 75c72fcc34Sopenharmony_ci for path in /sbin /usr/sbin /bin /usr/bin;do 76c72fcc34Sopenharmony_ci test -x $path/$prog && eval $prog=$path/$prog 77c72fcc34Sopenharmony_ci done 78c72fcc34Sopenharmony_cidone 79c72fcc34Sopenharmony_ciunset prog path 80c72fcc34Sopenharmony_ci 81c72fcc34Sopenharmony_ciusage() { 82c72fcc34Sopenharmony_ci xecho "ALSA configurator" 83c72fcc34Sopenharmony_ci echo " version $version" 84c72fcc34Sopenharmony_ci xecho "usage: alsaconf [options] 85c72fcc34Sopenharmony_ci -l|--legacy check only legacy non-isapnp cards 86c72fcc34Sopenharmony_ci -m|--modinfo read module descriptions instead of reading card db 87c72fcc34Sopenharmony_ci -s|--sound wav-file 88c72fcc34Sopenharmony_ci use the specified wav file as a test sound 89c72fcc34Sopenharmony_ci -u|--uid uid set the uid for the ALSA devices (default = 0) [obsoleted] 90c72fcc34Sopenharmony_ci -g|--gid gid set the gid for the ALSA devices (default = 0) [obsoleted] 91c72fcc34Sopenharmony_ci -d|--devmode mode 92c72fcc34Sopenharmony_ci set the permission for ALSA devices (default = 0666) [obs.] 93c72fcc34Sopenharmony_ci -r|--strict set strict device mode (equiv. with -g 17 -d 0660) [obsoleted] 94c72fcc34Sopenharmony_ci -L|--log file logging on the specified file (for debugging purpose only) 95c72fcc34Sopenharmony_ci -p|--probe card-name 96c72fcc34Sopenharmony_ci probe a legacy non-isapnp card and print module options 97c72fcc34Sopenharmony_ci -P|--listprobe list the supported legacy card modules 98c72fcc34Sopenharmony_ci -c|--config file 99c72fcc34Sopenharmony_ci specify the module config file 100c72fcc34Sopenharmony_ci -R|--resources list available DMA and IRQ resources with debug for legacy 101c72fcc34Sopenharmony_ci -h|--help what you're reading" 102c72fcc34Sopenharmony_ci} 103c72fcc34Sopenharmony_ci 104c72fcc34Sopenharmony_ciOPTS=`getopt -o lmL:hp:Pu:g:d:rs:c:R --long legacy,modinfo,log:,help,probe:,listprobe,uid:,gid:,devmode:,strict,sound:,config:,resources -n alsaconf -- "$@"` || exit 1 105c72fcc34Sopenharmony_cieval set -- "$OPTS" 106c72fcc34Sopenharmony_ci 107c72fcc34Sopenharmony_cido_legacy_only=0 108c72fcc34Sopenharmony_ciuse_modinfo_db=0 109c72fcc34Sopenharmony_cialsa_uid=0 110c72fcc34Sopenharmony_cialsa_gid=0 111c72fcc34Sopenharmony_cialsa_mode=0666 112c72fcc34Sopenharmony_cilegacy_probe_card="" 113c72fcc34Sopenharmony_ciLOGFILE="" 114c72fcc34Sopenharmony_ciTESTSOUND="@TESTSOUND@" 115c72fcc34Sopenharmony_citry_all_combination=0 116c72fcc34Sopenharmony_ciresources="false" 117c72fcc34Sopenharmony_ci 118c72fcc34Sopenharmony_ci# legacy support 119c72fcc34Sopenharmony_ciLEGACY_CARDS="opl3sa2 cs4236 cs4232 cs4231 es18xx es1688 sb16 sb8" 120c72fcc34Sopenharmony_ci 121c72fcc34Sopenharmony_ciwhile true ; do 122c72fcc34Sopenharmony_ci case "$1" in 123c72fcc34Sopenharmony_ci -l|--legacy) 124c72fcc34Sopenharmony_ci do_legacy_only=1; shift ;; 125c72fcc34Sopenharmony_ci -m|--modinfo) 126c72fcc34Sopenharmony_ci use_modinfo_db=1; shift ;; 127c72fcc34Sopenharmony_ci -s|--sound) 128c72fcc34Sopenharmony_ci TESTSOUND=$2; shift 2;; 129c72fcc34Sopenharmony_ci -h|--help) 130c72fcc34Sopenharmony_ci usage; exit 0 ;; 131c72fcc34Sopenharmony_ci -L|--log) 132c72fcc34Sopenharmony_ci LOGFILE="$2"; shift 2;; 133c72fcc34Sopenharmony_ci -p|--probe) 134c72fcc34Sopenharmony_ci legacy_probe_card="$2"; shift 2;; 135c72fcc34Sopenharmony_ci -P|--listprobe) 136c72fcc34Sopenharmony_ci echo "$LEGACY_CARDS"; exit 0;; 137c72fcc34Sopenharmony_ci -u|--uid) 138c72fcc34Sopenharmony_ci alsa_uid="$2"; shift 2;; 139c72fcc34Sopenharmony_ci -g|--gid) 140c72fcc34Sopenharmony_ci alsa_gid="$2"; shift 2;; 141c72fcc34Sopenharmony_ci -d|--devmode) 142c72fcc34Sopenharmony_ci alsa_mode="$2"; shift 2;; 143c72fcc34Sopenharmony_ci -r|--strict) 144c72fcc34Sopenharmony_ci alsa_uid=0; alsa_gid=17; alsa_mode=0660; shift;; 145c72fcc34Sopenharmony_ci -c|--config) 146c72fcc34Sopenharmony_ci cfgfile="$2"; shift 2;; 147c72fcc34Sopenharmony_ci -R|--resources) 148c72fcc34Sopenharmony_ci resources="true"; shift;; 149c72fcc34Sopenharmony_ci --) shift ; break ;; 150c72fcc34Sopenharmony_ci *) usage ; exit 1 ;; 151c72fcc34Sopenharmony_ci esac 152c72fcc34Sopenharmony_cidone 153c72fcc34Sopenharmony_ci 154c72fcc34Sopenharmony_ci# 155c72fcc34Sopenharmony_ci# probe legacy ISA cards 156c72fcc34Sopenharmony_ci# 157c72fcc34Sopenharmony_ci 158c72fcc34Sopenharmony_cicheck_dma_avail () { 159c72fcc34Sopenharmony_ci list="" 160c72fcc34Sopenharmony_ci if [ -d $SYSFS/bus/pnp/devices ]; then 161c72fcc34Sopenharmony_ci for dma in $*; do 162c72fcc34Sopenharmony_ci ok="true" 163c72fcc34Sopenharmony_ci for i in $SYSFS/bus/pnp/devices/??:* ; do 164c72fcc34Sopenharmony_ci if grep -q "state = active" $i/resources ; then 165c72fcc34Sopenharmony_ci if grep -q '^dma '$dma'$' $i/resources; then 166c72fcc34Sopenharmony_ci ok="false" 167c72fcc34Sopenharmony_ci fi 168c72fcc34Sopenharmony_ci fi 169c72fcc34Sopenharmony_ci done 170c72fcc34Sopenharmony_ci if [ -r $PROCFS/dma ]; then 171c72fcc34Sopenharmony_ci if grep -q '^ *'$dma': ' $PROCFS/dma ; then 172c72fcc34Sopenharmony_ci ok="false" 173c72fcc34Sopenharmony_ci fi 174c72fcc34Sopenharmony_ci fi 175c72fcc34Sopenharmony_ci if [ "$ok" = "true" ]; then 176c72fcc34Sopenharmony_ci list="$list $dma" 177c72fcc34Sopenharmony_ci fi 178c72fcc34Sopenharmony_ci done 179c72fcc34Sopenharmony_ci else 180c72fcc34Sopenharmony_ci if [ -r $PROCFS/dma ]; then 181c72fcc34Sopenharmony_ci for dma in $*; do 182c72fcc34Sopenharmony_ci grep -q '^ *'$dma': ' $PROCFS/dma || list="$list $dma" 183c72fcc34Sopenharmony_ci done 184c72fcc34Sopenharmony_ci fi 185c72fcc34Sopenharmony_ci fi 186c72fcc34Sopenharmony_ci if [ ! -z "$list" ]; then 187c72fcc34Sopenharmony_ci echo $list 188c72fcc34Sopenharmony_ci fi 189c72fcc34Sopenharmony_ci} 190c72fcc34Sopenharmony_ci 191c72fcc34Sopenharmony_cicheck_irq_avail () { 192c72fcc34Sopenharmony_ci list="" 193c72fcc34Sopenharmony_ci if [ -d $SYSFS/bus/pnp/devices ]; then 194c72fcc34Sopenharmony_ci for irq in $*; do 195c72fcc34Sopenharmony_ci ok="true" 196c72fcc34Sopenharmony_ci for i in $SYSFS/bus/pnp/devices/??:* ; do 197c72fcc34Sopenharmony_ci if grep -q "state = active" $i/resources ; then 198c72fcc34Sopenharmony_ci if grep -q '^irq '$irq'$' $i/resources; then 199c72fcc34Sopenharmony_ci ok="false" 200c72fcc34Sopenharmony_ci fi 201c72fcc34Sopenharmony_ci fi 202c72fcc34Sopenharmony_ci done 203c72fcc34Sopenharmony_ci if [ -r $PROCFS/interrupts ]; then 204c72fcc34Sopenharmony_ci if grep -q '^ *'$irq': ' $PROCFS/interrupts ; then 205c72fcc34Sopenharmony_ci ok="false" 206c72fcc34Sopenharmony_ci fi 207c72fcc34Sopenharmony_ci fi 208c72fcc34Sopenharmony_ci if [ "$ok" = "true" ]; then 209c72fcc34Sopenharmony_ci list="$list $irq" 210c72fcc34Sopenharmony_ci fi 211c72fcc34Sopenharmony_ci done 212c72fcc34Sopenharmony_ci else 213c72fcc34Sopenharmony_ci if [ -r $PROCFS/interrupts ]; then 214c72fcc34Sopenharmony_ci for irq in $*; do 215c72fcc34Sopenharmony_ci grep -q '^ *'$irq': ' $PROCFS/interrupts || list="$list $irq" 216c72fcc34Sopenharmony_ci done 217c72fcc34Sopenharmony_ci fi 218c72fcc34Sopenharmony_ci fi 219c72fcc34Sopenharmony_ci if [ ! -z "$list" ]; then 220c72fcc34Sopenharmony_ci echo $list 221c72fcc34Sopenharmony_ci fi 222c72fcc34Sopenharmony_ci} 223c72fcc34Sopenharmony_ci 224c72fcc34Sopenharmony_ci# 225c72fcc34Sopenharmony_ci# 226c72fcc34Sopenharmony_ci# 227c72fcc34Sopenharmony_ci 228c72fcc34Sopenharmony_ciif [ "$resources" = "true" ]; then 229c72fcc34Sopenharmony_ci if [ -d $SYSFS/bus/pnp/devices ]; then 230c72fcc34Sopenharmony_ci for i in $SYSFS/bus/pnp/devices/??:* ; do 231c72fcc34Sopenharmony_ci if [ "$resources" = "true" ]; then 232c72fcc34Sopenharmony_ci echo ">>>>> PnP file: $i/resources" 233c72fcc34Sopenharmony_ci cat $i/resources 234c72fcc34Sopenharmony_ci fi 235c72fcc34Sopenharmony_ci done 236c72fcc34Sopenharmony_ci fi 237c72fcc34Sopenharmony_ci if [ -r $PROCFS/dma ]; then 238c72fcc34Sopenharmony_ci echo ">>>>> Allocated dma channels:" 239c72fcc34Sopenharmony_ci cat $PROCFS/dma 240c72fcc34Sopenharmony_ci fi 241c72fcc34Sopenharmony_ci if [ -r $PROCFS/interrupts ]; then 242c72fcc34Sopenharmony_ci echo ">>>>> Allocated interrupt channels:" 243c72fcc34Sopenharmony_ci cat $PROCFS/interrupts 244c72fcc34Sopenharmony_ci fi 245c72fcc34Sopenharmony_ci echo -n "Valid DMA channels: " 246c72fcc34Sopenharmony_ci check_dma_avail 0 1 2 3 4 5 6 7 247c72fcc34Sopenharmony_ci echo -n "Valid IRQ channels: " 248c72fcc34Sopenharmony_ci check_irq_avail 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 249c72fcc34Sopenharmony_ci exit 0 250c72fcc34Sopenharmony_cifi 251c72fcc34Sopenharmony_ci 252c72fcc34Sopenharmony_ci# Check for root privileges 253c72fcc34Sopenharmony_ciif [ `id -u` -ne 0 ]; then 254c72fcc34Sopenharmony_ci xecho "You must be root to use this script." 255c72fcc34Sopenharmony_ci exit 1 256c72fcc34Sopenharmony_cifi 257c72fcc34Sopenharmony_ci 258c72fcc34Sopenharmony_ci# 259c72fcc34Sopenharmony_ci# check the snd_ prefix for ALSA module options 260c72fcc34Sopenharmony_ci# snd_ prefix is obsoleted since 0.9.0rc4. 261c72fcc34Sopenharmony_ci# 262c72fcc34Sopenharmony_ciif /sbin/modinfo -p snd | grep -q snd_ ; then 263c72fcc34Sopenharmony_ci mpfx="snd_" 264c72fcc34Sopenharmony_cielse 265c72fcc34Sopenharmony_ci mpfx="" 266c72fcc34Sopenharmony_cifi 267c72fcc34Sopenharmony_ci 268c72fcc34Sopenharmony_cialsa_device_opts="" 269c72fcc34Sopenharmony_ciif /sbin/modinfo -p snd | grep -q uid ; then 270c72fcc34Sopenharmony_ci if [ x"$alsa_uid" != x0 ]; then 271c72fcc34Sopenharmony_ci alsa_device_opts="$alsa_device_opts ${mpfx}device_uid=$alsa_uid" 272c72fcc34Sopenharmony_ci fi 273c72fcc34Sopenharmony_ci if [ x"$alsa_gid" != x0 ]; then 274c72fcc34Sopenharmony_ci alsa_device_opts="$alsa_device_opts ${mpfx}device_gid=$alsa_gid" 275c72fcc34Sopenharmony_ci fi 276c72fcc34Sopenharmony_cifi 277c72fcc34Sopenharmony_ciif /sbin/modinfo -p snd | grep -q device_mode ; then 278c72fcc34Sopenharmony_ci if [ x"$alsa_mode" != x0 ]; then 279c72fcc34Sopenharmony_ci alsa_device_opts="$alsa_device_opts ${mpfx}device_mode=$alsa_mode" 280c72fcc34Sopenharmony_ci fi 281c72fcc34Sopenharmony_cifi 282c72fcc34Sopenharmony_ci 283c72fcc34Sopenharmony_cicase `uname -r` in 284c72fcc34Sopenharmony_ci2.6.*) 285c72fcc34Sopenharmony_ci kernel="new" 286c72fcc34Sopenharmony_ci ;; 287c72fcc34Sopenharmony_ci*) 288c72fcc34Sopenharmony_ci kernel="old" 289c72fcc34Sopenharmony_ci ;; 290c72fcc34Sopenharmony_ciesac 291c72fcc34Sopenharmony_ci 292c72fcc34Sopenharmony_ci# cfgfile = base config file to remove/update the sound setting 293c72fcc34Sopenharmony_ci# cfgout = new config file to write the sound setting (if different from $cfgfile) 294c72fcc34Sopenharmony_cicfgout="" 295c72fcc34Sopenharmony_cicfgoldout="" 296c72fcc34Sopenharmony_ciif [ -n "$cfgfile" ]; then 297c72fcc34Sopenharmony_ci if [ ! -r "$cfgfile" ]; then 298c72fcc34Sopenharmony_ci xecho "ERROR: The config file doesn't exist: " 299c72fcc34Sopenharmony_ci echo $cfgfile 300c72fcc34Sopenharmony_ci exit 1 301c72fcc34Sopenharmony_ci fi 302c72fcc34Sopenharmony_cielse 303c72fcc34Sopenharmony_ciif [ "$kernel" = "new" ]; then 304c72fcc34Sopenharmony_ci cfgfile="/etc/modprobe.conf" 305c72fcc34Sopenharmony_ci if [ -d /etc/modprobe.d ]; then 306c72fcc34Sopenharmony_ci cfgout="/etc/modprobe.d/50-sound.conf" 307c72fcc34Sopenharmony_ci cfgoldout="/etc/modprobe.d/sound" 308c72fcc34Sopenharmony_ci if [ ! -f $cfgout ]; then 309c72fcc34Sopenharmony_ci case "$(modprobe -V)" in 310c72fcc34Sopenharmony_ci "module-init-tools version "3.[789]*|\ 311c72fcc34Sopenharmony_ci "module-init-tools version "3.1[0-9]*) 312c72fcc34Sopenharmony_ci ;; 313c72fcc34Sopenharmony_ci "kmod version "*) 314c72fcc34Sopenharmony_ci ;; 315c72fcc34Sopenharmony_ci *) 316c72fcc34Sopenharmony_ci cfgout="/etc/modprobe.d/sound" 317c72fcc34Sopenharmony_ci cfgoldout="" 318c72fcc34Sopenharmony_ci ;; 319c72fcc34Sopenharmony_ci esac 320c72fcc34Sopenharmony_ci fi 321c72fcc34Sopenharmony_ci fi 322c72fcc34Sopenharmony_cielif [ "$distribution" = "debian" ]; then 323c72fcc34Sopenharmony_ci cfgfile="/etc/modutils/sound" 324c72fcc34Sopenharmony_cielif [ -e /etc/modules.conf ]; then 325c72fcc34Sopenharmony_ci cfgfile="/etc/modules.conf" 326c72fcc34Sopenharmony_cielif [ -e /etc/conf.modules ]; then 327c72fcc34Sopenharmony_ci cfgfile="/etc/conf.modules" 328c72fcc34Sopenharmony_cielse 329c72fcc34Sopenharmony_ci cfgfile="/etc/modules.conf" 330c72fcc34Sopenharmony_ci touch /etc/modules.conf 331c72fcc34Sopenharmony_cifi 332c72fcc34Sopenharmony_cifi 333c72fcc34Sopenharmony_ci 334c72fcc34Sopenharmony_ci# Check for dialog, whiptail, gdialog, awk, ... ? 335c72fcc34Sopenharmony_ciif type -p dialog > /dev/null; then 336c72fcc34Sopenharmony_ci DIALOG=dialog 337c72fcc34Sopenharmony_cielse 338c72fcc34Sopenharmony_ci if type -p whiptail > /dev/null; then 339c72fcc34Sopenharmony_ci whiptail_wrapper() { 340c72fcc34Sopenharmony_ci X1="$1" 341c72fcc34Sopenharmony_ci X2="$2" 342c72fcc34Sopenharmony_ci if [ $1 = --yesno ]; then 343c72fcc34Sopenharmony_ci X3=`expr $3 + 2` 344c72fcc34Sopenharmony_ci else 345c72fcc34Sopenharmony_ci X3=$3 346c72fcc34Sopenharmony_ci fi 347c72fcc34Sopenharmony_ci shift 3 348c72fcc34Sopenharmony_ci whiptail "$X1" "$X2" $X3 "$@" 349c72fcc34Sopenharmony_ci } 350c72fcc34Sopenharmony_ci DIALOG=whiptail_wrapper 351c72fcc34Sopenharmony_ci else 352c72fcc34Sopenharmony_ci xecho "Error, dialog or whiptail not found." 353c72fcc34Sopenharmony_ci exit 1 354c72fcc34Sopenharmony_ci fi 355c72fcc34Sopenharmony_cifi 356c72fcc34Sopenharmony_ciif type -p awk > /dev/null; then : 357c72fcc34Sopenharmony_cielse 358c72fcc34Sopenharmony_ci xecho "Error, awk not found. Can't continue." 359c72fcc34Sopenharmony_ci exit 1 360c72fcc34Sopenharmony_cifi 361c72fcc34Sopenharmony_ci 362c72fcc34Sopenharmony_ci# 363c72fcc34Sopenharmony_ci# remove entries by yast2 sound configurator 364c72fcc34Sopenharmony_ci# 365c72fcc34Sopenharmony_ciremove_y2_block() { 366c72fcc34Sopenharmony_ci awk ' 367c72fcc34Sopenharmony_ci /^alias sound-slot-[0-9]/ { next } 368c72fcc34Sopenharmony_ci /^alias char-major-116 / { next } 369c72fcc34Sopenharmony_ci /^alias char-major-14 / { next } 370c72fcc34Sopenharmony_ci /^alias snd-card-[0-9] / { next } 371c72fcc34Sopenharmony_ci /^options snd / { next } 372c72fcc34Sopenharmony_ci /^options snd-/ { next } 373c72fcc34Sopenharmony_ci /^options off / { next } 374c72fcc34Sopenharmony_ci /^alias sound-service-[0-9]/ { next } 375c72fcc34Sopenharmony_ci /^# YaST2: sound / { next } 376c72fcc34Sopenharmony_ci { print }' 377c72fcc34Sopenharmony_ci} 378c72fcc34Sopenharmony_ci 379c72fcc34Sopenharmony_ci# 380c72fcc34Sopenharmony_ci# remove entries by sndconfig sound configurator 381c72fcc34Sopenharmony_ci# 382c72fcc34Sopenharmony_ci# found strings to search for in WriteConfModules, 383c72fcc34Sopenharmony_ci# from sndconfig 0.68-4 (rawhide version) 384c72fcc34Sopenharmony_ci 385c72fcc34Sopenharmony_ciremove_sndconfig_block() { 386c72fcc34Sopenharmony_ci awk ' 387c72fcc34Sopenharmony_ci /^alias sound-slot-0/ { modulename = $3 ; next } 388c72fcc34Sopenharmony_ci /^alias sound-slot-[0-9]/ { next } 389c72fcc34Sopenharmony_ci /^post-install sound-slot-[0-9] / { next } 390c72fcc34Sopenharmony_ci /^pre-remove sound-slot-[0-9] / { next } 391c72fcc34Sopenharmony_ci /^options sound / { next } 392c72fcc34Sopenharmony_ci /^alias synth0 opl3/ { next } 393c72fcc34Sopenharmony_ci /^options opl3 / { next } 394c72fcc34Sopenharmony_ci /^alias midi / { mididev = $3 ; next } 395c72fcc34Sopenharmony_ci /^options / { if ($2 == mididev) next } 396c72fcc34Sopenharmony_ci /^pre-install / { if ($2 == mididev) next } 397c72fcc34Sopenharmony_ci /^alias synth0 / { synth = $3 ; next } 398c72fcc34Sopenharmony_ci /^post-install / { if ($2 == synth) next } 399c72fcc34Sopenharmony_ci /^options sb / { next } 400c72fcc34Sopenharmony_ci /^post-install .+ \/bin\/modprobe "aci"/ { if ($2 == modulename) next } 401c72fcc34Sopenharmony_ci /^options adlib_card / { next } 402c72fcc34Sopenharmony_ci /^options .+ isapnp=1/ { if ($2 == modulename) next } 403c72fcc34Sopenharmony_ci /^options i810_audio / { next } 404c72fcc34Sopenharmony_ci /^options / {if ($2 == modulename) next } 405c72fcc34Sopenharmony_ci { print }' 406c72fcc34Sopenharmony_ci} 407c72fcc34Sopenharmony_ci 408c72fcc34Sopenharmony_ci# 409c72fcc34Sopenharmony_ci# remove the previous configuration by alsaconf 410c72fcc34Sopenharmony_ci# 411c72fcc34Sopenharmony_ciremove_ac_block() { 412c72fcc34Sopenharmony_ci awk '/^'"$ACB"'$/,/^'"$ACE"'$/ { next } { print }' 413c72fcc34Sopenharmony_ci} 414c72fcc34Sopenharmony_ci 415c72fcc34Sopenharmony_ci# 416c72fcc34Sopenharmony_ci# set default mixer volumes 417c72fcc34Sopenharmony_ci# 418c72fcc34Sopenharmony_ciset_mixers() { 419c72fcc34Sopenharmony_ci amixer -s -q <<EOF 420c72fcc34Sopenharmony_ciset Master 75% unmute 421c72fcc34Sopenharmony_ciset Master -12dB 422c72fcc34Sopenharmony_ciset 'Master Mono' 75% unmute 423c72fcc34Sopenharmony_ciset 'Master Mono' -12dB 424c72fcc34Sopenharmony_ciset Front 75% unmute 425c72fcc34Sopenharmony_ciset Front -12dB 426c72fcc34Sopenharmony_ciset PCM 90% unmute 427c72fcc34Sopenharmony_ciset PCM 0dB 428c72fcc34Sopenharmony_cimixer Synth 90% unmute 429c72fcc34Sopenharmony_cimixer Synth 0dB 430c72fcc34Sopenharmony_cimixer CD 90% unmute 431c72fcc34Sopenharmony_cimixer CD 0dB 432c72fcc34Sopenharmony_ci# mute mic 433c72fcc34Sopenharmony_ciset Mic 0% mute 434c72fcc34Sopenharmony_ci# ESS 1969 chipset has 2 PCM channels 435c72fcc34Sopenharmony_ciset PCM,1 90% unmute 436c72fcc34Sopenharmony_ciset PCM,1 0dB 437c72fcc34Sopenharmony_ci# Trident/YMFPCI/emu10k1 438c72fcc34Sopenharmony_ciset Wave 100% unmute 439c72fcc34Sopenharmony_ciset Music 100% unmute 440c72fcc34Sopenharmony_ciset AC97 100% unmute 441c72fcc34Sopenharmony_ci# CS4237B chipset: 442c72fcc34Sopenharmony_ciset 'Master Digital' 75% unmute 443c72fcc34Sopenharmony_ci# Envy24 chips with analog outs 444c72fcc34Sopenharmony_ciset DAC 90% unmute 445c72fcc34Sopenharmony_ciset DAC -12dB 446c72fcc34Sopenharmony_ciset DAC,0 90% unmute 447c72fcc34Sopenharmony_ciset DAC,0 -12dB 448c72fcc34Sopenharmony_ciset DAC,1 90% unmute 449c72fcc34Sopenharmony_ciset DAC,1 -12dB 450c72fcc34Sopenharmony_ci# some notebooks use headphone instead of master 451c72fcc34Sopenharmony_ciset Headphone 75% unmute 452c72fcc34Sopenharmony_ciset Headphone -12dB 453c72fcc34Sopenharmony_ciset Playback 100% unmute 454c72fcc34Sopenharmony_ci# turn off digital switches 455c72fcc34Sopenharmony_ciset "SB Live Analog/Digital Output Jack" off 456c72fcc34Sopenharmony_ciset "Audigy Analog/Digital Output Jack" off 457c72fcc34Sopenharmony_ciEOF 458c72fcc34Sopenharmony_ci} 459c72fcc34Sopenharmony_ci 460c72fcc34Sopenharmony_ci 461c72fcc34Sopenharmony_ci# INTRO 462c72fcc34Sopenharmony_ciintro() { 463c72fcc34Sopenharmony_ci local msg=$(xmsg " 464c72fcc34Sopenharmony_ci ALSA CONFIGURATOR 465c72fcc34Sopenharmony_ci version %s 466c72fcc34Sopenharmony_ci 467c72fcc34Sopenharmony_ci This script is a configurator for 468c72fcc34Sopenharmony_ci Advanced Linux Sound Architecture (ALSA) driver. 469c72fcc34Sopenharmony_ci 470c72fcc34Sopenharmony_ci 471c72fcc34Sopenharmony_ci If ALSA is already running, you should close all sound 472c72fcc34Sopenharmony_ci apps now and stop the sound driver. 473c72fcc34Sopenharmony_ci alsaconf will try to do this, but it's not 100%% sure." $version) 474c72fcc34Sopenharmony_ci $DIALOG --msgbox "$msg" 20 63 || acex 0 475c72fcc34Sopenharmony_ci} 476c72fcc34Sopenharmony_ci 477c72fcc34Sopenharmony_ci# FAREWELL 478c72fcc34Sopenharmony_cifarewell() { 479c72fcc34Sopenharmony_ci local msg=$(gettext " 480c72fcc34Sopenharmony_ci 481c72fcc34Sopenharmony_ci OK, sound driver is configured. 482c72fcc34Sopenharmony_ci 483c72fcc34Sopenharmony_ci ALSA CONFIGURATOR 484c72fcc34Sopenharmony_ci 485c72fcc34Sopenharmony_ci will prepare the card for playing now. 486c72fcc34Sopenharmony_ci 487c72fcc34Sopenharmony_ci Now I'll run alsasound init script, then I'll use 488c72fcc34Sopenharmony_ci amixer to raise the default volumes. 489c72fcc34Sopenharmony_ci You can change the volume later via a mixer 490c72fcc34Sopenharmony_ci program such as alsamixer or gamix. 491c72fcc34Sopenharmony_ci 492c72fcc34Sopenharmony_ci ") 493c72fcc34Sopenharmony_ci $DIALOG --msgbox "$msg" 17 60 || acex 0 494c72fcc34Sopenharmony_ci} 495c72fcc34Sopenharmony_ci 496c72fcc34Sopenharmony_ci# Exit function 497c72fcc34Sopenharmony_ciacex() { 498c72fcc34Sopenharmony_ci cleanup 499c72fcc34Sopenharmony_ci clear 500c72fcc34Sopenharmony_ci exit $1 501c72fcc34Sopenharmony_ci} 502c72fcc34Sopenharmony_ci 503c72fcc34Sopenharmony_ci# 504c72fcc34Sopenharmony_ci# search for alsasound init script 505c72fcc34Sopenharmony_ci# 506c72fcc34Sopenharmony_ci 507c72fcc34Sopenharmony_ciif [ "$distribution" = "debian" ]; then 508c72fcc34Sopenharmony_ci rcalsasound=/etc/init.d/alsa 509c72fcc34Sopenharmony_cielif [ -x /etc/rc.d/rc.alsa ]; then 510c72fcc34Sopenharmony_ci rcalsasound=/etc/rc.d/rc.alsa 511c72fcc34Sopenharmony_cielif [ -x /etc/init.d/alsasound ]; then 512c72fcc34Sopenharmony_ci rcalsasound=/etc/init.d/alsasound 513c72fcc34Sopenharmony_cielif [ -x /usr/sbin/rcalsasound ]; then 514c72fcc34Sopenharmony_ci rcalsasound=/usr/sbin/rcalsasound 515c72fcc34Sopenharmony_cielif [ -x /sbin/rcalsasound ]; then 516c72fcc34Sopenharmony_ci rcalsasound=/sbin/rcalsasound 517c72fcc34Sopenharmony_cielif [ -x /etc/rc.d/init.d/alsasound ]; then 518c72fcc34Sopenharmony_ci rcalsasound=/etc/rc.d/init.d/alsasound 519c72fcc34Sopenharmony_cielif [ -x /etc/init.d/alsa ]; then 520c72fcc34Sopenharmony_ci rcalsasound=/etc/init.d/alsa 521c72fcc34Sopenharmony_cielse 522c72fcc34Sopenharmony_ci rcalsasound=rcalsasound 523c72fcc34Sopenharmony_cifi 524c72fcc34Sopenharmony_ci 525c72fcc34Sopenharmony_ci 526c72fcc34Sopenharmony_ci# MAIN 527c72fcc34Sopenharmony_ciif [ -d $PROCFS/asound ]; then 528c72fcc34Sopenharmony_ci $rcalsasound stop >/dev/null 2>&1 529c72fcc34Sopenharmony_ci $rcalsasound unload >/dev/null 2>&1 530c72fcc34Sopenharmony_ci /sbin/rmmod dmasound dmasound_awacs 2>/dev/null 531c72fcc34Sopenharmony_cifi 532c72fcc34Sopenharmony_ci 533c72fcc34Sopenharmony_ci 534c72fcc34Sopenharmony_cicleanup () { 535c72fcc34Sopenharmony_ci killall -9 aplay arecord >/dev/null 2>&1 536c72fcc34Sopenharmony_ci /sbin/modprobe -r isapnp >/dev/null 2>&1 537c72fcc34Sopenharmony_ci /sbin/modprobe -r isa-pnp >/dev/null 2>&1 538c72fcc34Sopenharmony_ci rm -f "$TMP" "$addcfg" "$FOUND" "$DUMP" 539c72fcc34Sopenharmony_ci} 540c72fcc34Sopenharmony_citrap cleanup 0 541c72fcc34Sopenharmony_ci 542c72fcc34Sopenharmony_ciTMP=`mktemp -q /tmp/alsaconf.XXXXXX` 543c72fcc34Sopenharmony_ciif [ $? -ne 0 ]; then 544c72fcc34Sopenharmony_ci xecho "Can't create temp file, exiting..." 545c72fcc34Sopenharmony_ci exit 1 546c72fcc34Sopenharmony_cifi 547c72fcc34Sopenharmony_ciaddcfg=`mktemp -q /tmp/alsaconf.XXXXXX` 548c72fcc34Sopenharmony_ciif [ $? -ne 0 ]; then 549c72fcc34Sopenharmony_ci xecho "Can't create temp file, exiting..." 550c72fcc34Sopenharmony_ci exit 1 551c72fcc34Sopenharmony_cifi 552c72fcc34Sopenharmony_ciFOUND=`mktemp -q /tmp/alsaconf.XXXXXX` 553c72fcc34Sopenharmony_ciif [ $? -ne 0 ]; then 554c72fcc34Sopenharmony_ci xecho "Can't create temp file, exiting..." 555c72fcc34Sopenharmony_ci exit 1 556c72fcc34Sopenharmony_cifi 557c72fcc34Sopenharmony_ciDUMP=`mktemp -q /tmp/alsaconf.XXXXXX` 558c72fcc34Sopenharmony_ciif [ $? -ne 0 ]; then 559c72fcc34Sopenharmony_ci xecho "Can't create temp file, exiting..." 560c72fcc34Sopenharmony_ci exit 1 561c72fcc34Sopenharmony_cifi 562c72fcc34Sopenharmony_ci 563c72fcc34Sopenharmony_ci# convert ISA PnP id number to string 'ABC' 564c72fcc34Sopenharmony_ciconvert_isapnp_id () { 565c72fcc34Sopenharmony_ci if [ -z "$1" ]; then 566c72fcc34Sopenharmony_ci echo "XXXX" 567c72fcc34Sopenharmony_ci return 568c72fcc34Sopenharmony_ci fi 569c72fcc34Sopenharmony_ci let a='('$1'>>2) & 0x3f' 570c72fcc34Sopenharmony_ci let b='(('$1' & 0x03) << 3) | (('$1' >> 13) & 0x07)' 571c72fcc34Sopenharmony_ci let c='('$1'>> 8) & 0x1f' 572c72fcc34Sopenharmony_ci strs='@ABCDEFGHIJKLMNOPQRSTUVWXYZ' 573c72fcc34Sopenharmony_ci echo ${strs:$a:1}${strs:$b:1}${strs:$c:1} 574c72fcc34Sopenharmony_ci} 575c72fcc34Sopenharmony_ci 576c72fcc34Sopenharmony_ci# swap high & low bytes 577c72fcc34Sopenharmony_ciswap_number () { 578c72fcc34Sopenharmony_ci if [ -z "$1" ]; then 579c72fcc34Sopenharmony_ci echo "0000" 580c72fcc34Sopenharmony_ci return 581c72fcc34Sopenharmony_ci fi 582c72fcc34Sopenharmony_ci let v='(('$1'>>8)&0xff)|(('$1'&0xff)<<8)' 583c72fcc34Sopenharmony_ci printf "%04x" $v 584c72fcc34Sopenharmony_ci} 585c72fcc34Sopenharmony_ci 586c72fcc34Sopenharmony_ci# build card database 587c72fcc34Sopenharmony_ci# build_card_db filename 588c72fcc34Sopenharmony_cibuild_card_db () { 589c72fcc34Sopenharmony_ci MODDIR=/lib/modules/`uname -r` 590c72fcc34Sopenharmony_ci last_driver="" 591c72fcc34Sopenharmony_ci echo -n > $1 592c72fcc34Sopenharmony_ci 593c72fcc34Sopenharmony_ci # list pci cards 594c72fcc34Sopenharmony_ci while read driver vendor device dummy; do 595c72fcc34Sopenharmony_ci if expr $driver : 'snd-.*' >/dev/null ; then 596c72fcc34Sopenharmony_ci if [ "$last_driver" != "$driver" ]; then 597c72fcc34Sopenharmony_ci echo $driver.o 598c72fcc34Sopenharmony_ci last_driver=$driver 599c72fcc34Sopenharmony_ci fi 600c72fcc34Sopenharmony_ci id1=`printf '0x%04x' $vendor` 601c72fcc34Sopenharmony_ci id2=`printf '0x%04x' $device` 602c72fcc34Sopenharmony_ci echo "PCI: $id1=$id2" 603c72fcc34Sopenharmony_ci fi 604c72fcc34Sopenharmony_ci done < $MODDIR/modules.pcimap >> $1 605c72fcc34Sopenharmony_ci 606c72fcc34Sopenharmony_ci # list isapnp cards 607c72fcc34Sopenharmony_ci while read driver cardvendor carddevice data vendor func; do 608c72fcc34Sopenharmony_ci if expr $driver : 'snd-.*' >/dev/null ; then 609c72fcc34Sopenharmony_ci if [ "$last_driver" != "$driver" ]; then 610c72fcc34Sopenharmony_ci echo $driver.o 611c72fcc34Sopenharmony_ci last_driver=$driver 612c72fcc34Sopenharmony_ci fi 613c72fcc34Sopenharmony_ci id1=`convert_isapnp_id $cardvendor` 614c72fcc34Sopenharmony_ci dev1=`swap_number $carddevice` 615c72fcc34Sopenharmony_ci id2=`convert_isapnp_id $vendor` 616c72fcc34Sopenharmony_ci dev2=`swap_number $func` 617c72fcc34Sopenharmony_ci echo "ISAPNP: $id1$dev1=$id2$dev2" 618c72fcc34Sopenharmony_ci fi 619c72fcc34Sopenharmony_ci done < $MODDIR/modules.isapnpmap >> $1 620c72fcc34Sopenharmony_ci} 621c72fcc34Sopenharmony_ci 622c72fcc34Sopenharmony_ci# 623c72fcc34Sopenharmony_ci# probe cards 624c72fcc34Sopenharmony_ci# 625c72fcc34Sopenharmony_ciprobe_cards () { 626c72fcc34Sopenharmony_ci found="0" 627c72fcc34Sopenharmony_ci test -r $PROCFS/isapnp || /sbin/modprobe isapnp >/dev/null 2>&1 628c72fcc34Sopenharmony_ci test -r $PROCFS/isapnp || /sbin/modprobe isa-pnp >/dev/null 2>&1 629c72fcc34Sopenharmony_ci if [ -r $PROCFS/isapnp ]; then 630c72fcc34Sopenharmony_ci cat $PROCFS/isapnp >"$DUMP" 631c72fcc34Sopenharmony_ci found="1" 632c72fcc34Sopenharmony_ci elif [ -d $SYSFS/bus/pnp/devices ]; then 633c72fcc34Sopenharmony_ci # use 2.6 kernel's sysfs output 634c72fcc34Sopenharmony_ci # fake the isapnp dump 635c72fcc34Sopenharmony_ci index=0 636c72fcc34Sopenharmony_ci bindex=0 637c72fcc34Sopenharmony_ci for d1 in $SYSFS/devices/pnp* ; do 638c72fcc34Sopenharmony_ci for d2 in $d1/*:* ; do 639c72fcc34Sopenharmony_ci if [ -r $d2/card_id ]; then 640c72fcc34Sopenharmony_ci id=`cat $d2/card_id` 641c72fcc34Sopenharmony_ci name=`cat $d2/name` 642c72fcc34Sopenharmony_ci echo "Card $index '$id:$name' " >> "$DUMP" 643c72fcc34Sopenharmony_ci index=$[$index+1] 644c72fcc34Sopenharmony_ci found="1" 645c72fcc34Sopenharmony_ci else if [ -r $d2/id ]; then 646c72fcc34Sopenharmony_ci # FIXME: multiple id might be present (separated with new-line) 647c72fcc34Sopenharmony_ci id=`head -n 1 $d2/id` 648c72fcc34Sopenharmony_ci echo "BIOS $bindex '$id' " >> "$DUMP" 649c72fcc34Sopenharmony_ci bindex=$[$bindex+1] 650c72fcc34Sopenharmony_ci found="1" 651c72fcc34Sopenharmony_ci fi 652c72fcc34Sopenharmony_ci fi 653c72fcc34Sopenharmony_ci done 654c72fcc34Sopenharmony_ci done 655c72fcc34Sopenharmony_ci fi 656c72fcc34Sopenharmony_ci if [ "$found" = "0" ]; then 657c72fcc34Sopenharmony_ci echo -n >"$DUMP" 658c72fcc34Sopenharmony_ci fi 659c72fcc34Sopenharmony_ci CARDID_DB=/var/tmp/alsaconf.cards 660c72fcc34Sopenharmony_ci if [ ! -r $CARDID_DB ]; then 661c72fcc34Sopenharmony_ci use_modinfo_db=1 662c72fcc34Sopenharmony_ci fi 663c72fcc34Sopenharmony_ci if [ $use_modinfo_db != 1 ]; then 664c72fcc34Sopenharmony_ci if [ $CARDID_DB -ot /lib/modules/`uname -r`/modules.dep ]; then 665c72fcc34Sopenharmony_ci use_modinfo_db=1 666c72fcc34Sopenharmony_ci fi 667c72fcc34Sopenharmony_ci fi 668c72fcc34Sopenharmony_ci if [ $use_modinfo_db = 1 ]; then 669c72fcc34Sopenharmony_ci xecho "Building card database.." 670c72fcc34Sopenharmony_ci build_card_db $CARDID_DB 671c72fcc34Sopenharmony_ci fi 672c72fcc34Sopenharmony_ci if [ ! -r $CARDID_DB ]; then 673c72fcc34Sopenharmony_ci xecho "No card database is found.." 674c72fcc34Sopenharmony_ci exit 1 675c72fcc34Sopenharmony_ci fi 676c72fcc34Sopenharmony_ci ncards=`grep '^snd-.*\.o$' $CARDID_DB | wc -w` 677c72fcc34Sopenharmony_ci 678c72fcc34Sopenharmony_ci msg=$(gettext "Searching sound cards") 679c72fcc34Sopenharmony_ci awk ' 680c72fcc34Sopenharmony_ciBEGIN { 681c72fcc34Sopenharmony_ci format="%-40s %s\n"; 682c72fcc34Sopenharmony_ci ncards='"$ncards"'; 683c72fcc34Sopenharmony_ci idx=0; 684c72fcc34Sopenharmony_ci} 685c72fcc34Sopenharmony_ci/^snd-.*\.o$/{ 686c72fcc34Sopenharmony_ci sub(/.o$/, ""); 687c72fcc34Sopenharmony_ci driver=$0; 688c72fcc34Sopenharmony_ci perc=(idx * 100) / (ncards + 1); 689c72fcc34Sopenharmony_ci print int(perc); 690c72fcc34Sopenharmony_ci idx++; 691c72fcc34Sopenharmony_ci} 692c72fcc34Sopenharmony_ci/^[<literal space><literal tab>]*PCI: /{ 693c72fcc34Sopenharmony_ci gsub(/0x/, ""); 694c72fcc34Sopenharmony_ci gsub(/=/, ":"); 695c72fcc34Sopenharmony_ci x = sprintf ("'$lspci' -n 2>/dev/null| grep '"' 04..: '"' | grep %s", $2); 696c72fcc34Sopenharmony_ci if (system (x) == 0) 697c72fcc34Sopenharmony_ci printf "%s %s\n", $2, driver >>"'"$FOUND"'" 698c72fcc34Sopenharmony_ci} 699c72fcc34Sopenharmony_ci/^[<literal space><literal tab>]*ISAPNP: /{ 700c72fcc34Sopenharmony_ci id2 = substr($0, index($0, "=")+1); 701c72fcc34Sopenharmony_ci gsub(/=.*/, ""); 702c72fcc34Sopenharmony_ci x = sprintf ("grep '\''^Card [0-9] .%s:'\'' '"$DUMP"'", $2); 703c72fcc34Sopenharmony_ci if (system (x) == 0) 704c72fcc34Sopenharmony_ci printf "%s %s\n", $2, driver >>"'"$FOUND"'" 705c72fcc34Sopenharmony_ci else if (index($2, "ffff") > 0) { 706c72fcc34Sopenharmony_ci x = sprintf ("grep '\''^BIOS [0-9]* .%s.'\'' '"$DUMP"'", id2); 707c72fcc34Sopenharmony_ci if (system (x) == 0) 708c72fcc34Sopenharmony_ci printf "%s %s\n", id2, driver >>"'"$FOUND"'" 709c72fcc34Sopenharmony_ci } 710c72fcc34Sopenharmony_ci}' < $CARDID_DB |\ 711c72fcc34Sopenharmony_ci $DIALOG --gauge "$msg" 6 40 0 712c72fcc34Sopenharmony_ci 713c72fcc34Sopenharmony_ci # 714c72fcc34Sopenharmony_ci # PowerMac 715c72fcc34Sopenharmony_ci # 716c72fcc34Sopenharmony_ci if grep -q MacRISC $PROCFS/cpuinfo; then 717c72fcc34Sopenharmony_ci MODDIR=/lib/modules/`uname -r` 718c72fcc34Sopenharmony_ci find $MODDIR -name 'snd-powermac*' -print | \ 719c72fcc34Sopenharmony_ci while read i; do 720c72fcc34Sopenharmony_ci i=${i##*/} 721c72fcc34Sopenharmony_ci i=${i%%.o} 722c72fcc34Sopenharmony_ci i=${i%%.ko} 723c72fcc34Sopenharmony_ci echo "PowerMac $i" >> $FOUND 724c72fcc34Sopenharmony_ci done 725c72fcc34Sopenharmony_ci fi 726c72fcc34Sopenharmony_ci 727c72fcc34Sopenharmony_ci # 728c72fcc34Sopenharmony_ci # Sparc 729c72fcc34Sopenharmony_ci # 730c72fcc34Sopenharmony_ci if grep -q Sparc $PROCFS/cpuinfo; then 731c72fcc34Sopenharmony_ci test -r $PROCFS/openprom/name || /bin/mount -t openpromfs none $PROCFS/openprom >/dev/null 2>&1 732c72fcc34Sopenharmony_ci # Check for an "audio" device 733c72fcc34Sopenharmony_ci audio= 734c72fcc34Sopenharmony_ci compat= 735c72fcc34Sopenharmony_ci if test -r $PROCFS/openprom; then 736c72fcc34Sopenharmony_ci audio=`find $PROCFS/openprom -follow -type d -name "audio*" -print` 737c72fcc34Sopenharmony_ci fi 738c72fcc34Sopenharmony_ci if test -n "$audio"; then 739c72fcc34Sopenharmony_ci compat=`cat $audio/compatible` 740c72fcc34Sopenharmony_ci compat=${compat#\'} 741c72fcc34Sopenharmony_ci compat=${compat%\'} 742c72fcc34Sopenharmony_ci compat=${compat#SUNW,} 743c72fcc34Sopenharmony_ci fi 744c72fcc34Sopenharmony_ci # Go through all cards we have 745c72fcc34Sopenharmony_ci MODDIR=/lib/modules/`uname -r` 746c72fcc34Sopenharmony_ci find $MODDIR -name 'snd-sun-*' -print | \ 747c72fcc34Sopenharmony_ci while read i; do 748c72fcc34Sopenharmony_ci i=${i##*/} 749c72fcc34Sopenharmony_ci i=${i%%.o} 750c72fcc34Sopenharmony_ci i=${i%%.ko} 751c72fcc34Sopenharmony_ci sdev=`echo ${i#snd-sun-} | tr "[a-z]" "[A-Z]"` 752c72fcc34Sopenharmony_ci 753c72fcc34Sopenharmony_ci if test "$sdev" = "$compat"; then 754c72fcc34Sopenharmony_ci echo "$sdev $i" >> $FOUND 755c72fcc34Sopenharmony_ci elif test -r $PROCFS/openprom; then 756c72fcc34Sopenharmony_ci find $PROCFS/openprom -follow -type d -name "SUNW,${sdev}*" \ 757c72fcc34Sopenharmony_ci -exec echo "$sdev $i" \; 2>/dev/null >> $FOUND 758c72fcc34Sopenharmony_ci else 759c72fcc34Sopenharmony_ci echo "$sdev $i" >> $FOUND 760c72fcc34Sopenharmony_ci fi 761c72fcc34Sopenharmony_ci done 762c72fcc34Sopenharmony_ci fi 763c72fcc34Sopenharmony_ci} 764c72fcc34Sopenharmony_ci 765c72fcc34Sopenharmony_ci# 766c72fcc34Sopenharmony_ci# look for a descriptive device name from the given device id 767c72fcc34Sopenharmony_ci# 768c72fcc34Sopenharmony_cifind_device_name () { 769c72fcc34Sopenharmony_ci 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 770c72fcc34Sopenharmony_ci $lspci -d $1 2>/dev/null| sed -e 's/^.*:..\.. [^:]*: //g' 771c72fcc34Sopenharmony_ci return 772c72fcc34Sopenharmony_ci elif expr "$1" : '[A-Z@][A-Z@][A-Z@][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' >/dev/null; then 773c72fcc34Sopenharmony_ci cardname=`grep '^Card [0-9]\+ .'$1':' $DUMP | head -n 1 | sed -e 's/^Card [0-9]\+ '\''.*:\(.*\)'\'' .*$/\1/'` 774c72fcc34Sopenharmony_ci echo $cardname 775c72fcc34Sopenharmony_ci else 776c72fcc34Sopenharmony_ci echo $1 777c72fcc34Sopenharmony_ci fi 778c72fcc34Sopenharmony_ci} 779c72fcc34Sopenharmony_ci 780c72fcc34Sopenharmony_ci# get hwcfg file type from the given driver name 781c72fcc34Sopenharmony_ciget_hwcfg_type () { 782c72fcc34Sopenharmony_ci while read dev driver; do 783c72fcc34Sopenharmony_ci if [ "$driver" = "$1" ]; then 784c72fcc34Sopenharmony_ci case "$dev" in 785c72fcc34Sopenharmony_ci *:*) 786c72fcc34Sopenharmony_ci # FIXME: need to look around /sys/bus/pci/* (or use vpid-* ?) 787c72fcc34Sopenharmony_ci devid=`$lspci -d "$dev" | head -n 1 | sed -e 's/ .*$//'` 788c72fcc34Sopenharmony_ci case "$devid" in 789c72fcc34Sopenharmony_ci *:*:*.*) ;; 790c72fcc34Sopenharmony_ci *) devid="0000:$devid" ;; 791c72fcc34Sopenharmony_ci esac 792c72fcc34Sopenharmony_ci echo bus-pci-$devid 793c72fcc34Sopenharmony_ci ;; 794c72fcc34Sopenharmony_ci *) 795c72fcc34Sopenharmony_ci echo $driver 796c72fcc34Sopenharmony_ci ;; 797c72fcc34Sopenharmony_ci esac 798c72fcc34Sopenharmony_ci break 799c72fcc34Sopenharmony_ci fi 800c72fcc34Sopenharmony_ci done 801c72fcc34Sopenharmony_ci} 802c72fcc34Sopenharmony_ci 803c72fcc34Sopenharmony_ci# clean up all hwcfg-* files containing ALSA modules 804c72fcc34Sopenharmony_ci# alsaconf sets up exclusively 805c72fcc34Sopenharmony_cicleanup_hwcfg () { 806c72fcc34Sopenharmony_ci for i in /etc/sysconfig/hardware/hwcfg-*; do 807c72fcc34Sopenharmony_ci grep -q "MODULE='snd-" $i && rm -f $i 808c72fcc34Sopenharmony_ci done 809c72fcc34Sopenharmony_ci} 810c72fcc34Sopenharmony_ci 811c72fcc34Sopenharmony_ci# 812c72fcc34Sopenharmony_ci# set up /etc/sysconfig/hardware/hwcfg-* stuff 813c72fcc34Sopenharmony_ci# 814c72fcc34Sopenharmony_cisetup_hwcfg () { 815c72fcc34Sopenharmony_ci card=$1 816c72fcc34Sopenharmony_ci cleanup_hwcfg 817c72fcc34Sopenharmony_ci cfg=`echo "$devs_olist" | get_hwcfg_type $card` 818c72fcc34Sopenharmony_ci echo "MODULE='$card'" > /etc/sysconfig/hardware/hwcfg-$cfg 819c72fcc34Sopenharmony_ci echo "STARTMODE='auto'" >> /etc/sysconfig/hardware/hwcfg-$cfg 820c72fcc34Sopenharmony_ci} 821c72fcc34Sopenharmony_ci 822c72fcc34Sopenharmony_ci 823c72fcc34Sopenharmony_ci# 824c72fcc34Sopenharmony_ci# configure and try test sound 825c72fcc34Sopenharmony_ci# 826c72fcc34Sopenharmony_ciac_config_card () { 827c72fcc34Sopenharmony_ci 828c72fcc34Sopenharmony_ci CARD_DRIVER=snd-$1 829c72fcc34Sopenharmony_ci CARD_OPTS="${*:2}" 830c72fcc34Sopenharmony_ci 831c72fcc34Sopenharmony_ci if [ -n "$cfgout" ]; then 832c72fcc34Sopenharmony_ci msg=$(xmsg " 833c72fcc34Sopenharmony_ciConfiguring %s 834c72fcc34Sopenharmony_ciDo you want to modify %s (and %s if present)?" $CARD_DRIVER $cfgout $cfgfile) 835c72fcc34Sopenharmony_ci $DIALOG --yesno "$msg" 10 50 || acex 0 836c72fcc34Sopenharmony_ci else 837c72fcc34Sopenharmony_ci msg=$(xmsg " 838c72fcc34Sopenharmony_ciConfiguring %s 839c72fcc34Sopenharmony_ciDo you want to modify %s?" $CARD_DRIVER $cfgfile) 840c72fcc34Sopenharmony_ci $DIALOG --yesno "$msg" 8 50 || acex 0 841c72fcc34Sopenharmony_ci fi 842c72fcc34Sopenharmony_ci clear 843c72fcc34Sopenharmony_ci 844c72fcc34Sopenharmony_ci # Copy conf.modules and make changes. 845c72fcc34Sopenharmony_ci ACB="# --- BEGIN: Generated by ALSACONF, do not edit. ---" 846c72fcc34Sopenharmony_ci ACE="# --- END: Generated by ALSACONF, do not edit. ---" 847c72fcc34Sopenharmony_ci 848c72fcc34Sopenharmony_ci # Detect 2.2.X kernel 849c72fcc34Sopenharmony_ci KVER=`uname -r | tr ".-" " "` 850c72fcc34Sopenharmony_ci KVER1=`echo $KVER | cut -d" " -f1` 851c72fcc34Sopenharmony_ci KVER2=`echo $KVER | cut -d" " -f2` 852c72fcc34Sopenharmony_ci if [ $KVER1 -ge 2 ] && [ $KVER2 -ge 2 ]; then 853c72fcc34Sopenharmony_ci SOUND_CORE="soundcore" 854c72fcc34Sopenharmony_ci else 855c72fcc34Sopenharmony_ci SOUND_CORE="snd" 856c72fcc34Sopenharmony_ci fi 857c72fcc34Sopenharmony_ci 858c72fcc34Sopenharmony_ci if [ -r $cfgfile ] ; then 859c72fcc34Sopenharmony_ci if [ "$distribution" = "redhat" -o "$distribution" = "fedora" ] ; then 860c72fcc34Sopenharmony_ci remove_ac_block < $cfgfile | remove_sndconfig_block | uniq > $TMP 861c72fcc34Sopenharmony_ci else 862c72fcc34Sopenharmony_ci remove_ac_block < $cfgfile | remove_y2_block | uniq > $TMP 863c72fcc34Sopenharmony_ci fi 864c72fcc34Sopenharmony_ci fi 865c72fcc34Sopenharmony_ci 866c72fcc34Sopenharmony_ci if [ -z "$have_alias" -a "$kernel" = "new" ]; then 867c72fcc34Sopenharmony_ci if grep -q char-major-116 /lib/modules/`uname -r`/modules.alias; then 868c72fcc34Sopenharmony_ci have_alias="yes" 869c72fcc34Sopenharmony_ci fi 870c72fcc34Sopenharmony_ci fi 871c72fcc34Sopenharmony_ci if [ -z "$have_alias" ]; then 872c72fcc34Sopenharmony_ciecho "alias char-major-116 snd 873c72fcc34Sopenharmony_cialias char-major-14 $SOUND_CORE 874c72fcc34Sopenharmony_cialias sound-service-0-0 snd-mixer-oss 875c72fcc34Sopenharmony_cialias sound-service-0-1 snd-seq-oss 876c72fcc34Sopenharmony_cialias sound-service-0-3 snd-pcm-oss 877c72fcc34Sopenharmony_cialias sound-service-0-8 snd-seq-oss 878c72fcc34Sopenharmony_cialias sound-service-0-12 snd-pcm-oss" >> $addcfg 879c72fcc34Sopenharmony_ci fi 880c72fcc34Sopenharmony_ci if [ -n "$alsa_device_opts" ]; then 881c72fcc34Sopenharmony_ci echo "options snd $alsa_device_opts" >> $addcfg 882c72fcc34Sopenharmony_ci fi 883c72fcc34Sopenharmony_ciecho "alias snd-card-0 $CARD_DRIVER 884c72fcc34Sopenharmony_cialias sound-slot-0 $CARD_DRIVER" >> $addcfg 885c72fcc34Sopenharmony_ci if [ -n "$CARD_OPTS" ]; then 886c72fcc34Sopenharmony_ci echo "options $CARD_DRIVER $CARD_OPTS" >> $addcfg 887c72fcc34Sopenharmony_ci fi 888c72fcc34Sopenharmony_ci 889c72fcc34Sopenharmony_ci if [ -n "$cfgout" ]; then 890c72fcc34Sopenharmony_ci [ ! -r "$cfgfile" ] || cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile" 891c72fcc34Sopenharmony_ci cmp -s "$addcfg" "$cfgout" || cat "$addcfg" > "$cfgout" 892c72fcc34Sopenharmony_ci test -n "$cfgoldout" && rm -f "$cfgoldout" 893c72fcc34Sopenharmony_ci else 894c72fcc34Sopenharmony_ci echo "$ACB 895c72fcc34Sopenharmony_ci# --- ALSACONF version $version ---" >> $TMP 896c72fcc34Sopenharmony_ci cat "$addcfg" >> "$TMP" 897c72fcc34Sopenharmony_ci echo "$ACE 898c72fcc34Sopenharmony_ci" >> $TMP 899c72fcc34Sopenharmony_ci cmp -s "$TMP" "$cfgfile" || cat "$TMP" > "$cfgfile" 900c72fcc34Sopenharmony_ci fi 901c72fcc34Sopenharmony_ci 902c72fcc34Sopenharmony_ci /sbin/depmod -a 2>/dev/null 903c72fcc34Sopenharmony_ci 904c72fcc34Sopenharmony_ci # remove yast2 entries (- only for suse distro) 905c72fcc34Sopenharmony_ci if [ -f /var/lib/YaST/unique.inf ]; then 906c72fcc34Sopenharmony_ci awk ' 907c72fcc34Sopenharmony_ciBEGIN { in_sound=0; } 908c72fcc34Sopenharmony_ci/^\[sound\]$/ { print; in_sound=1; next; } 909c72fcc34Sopenharmony_ci/^\[.+\]$/ { print; in_sound=0; next; } 910c72fcc34Sopenharmony_ci{ if (in_sound == 0) { print; } } 911c72fcc34Sopenharmony_ci' < /var/lib/YaST/unique.inf > $TMP 912c72fcc34Sopenharmony_ci cp -f $TMP /var/lib/YaST/unique.inf 913c72fcc34Sopenharmony_ci fi 914c72fcc34Sopenharmony_ci 915c72fcc34Sopenharmony_ci # set up /etc/sysconfig/hardware/* 916c72fcc34Sopenharmony_ci if [ "$distribution" = "suse" ]; then 917c72fcc34Sopenharmony_ci case "$suse_version" in 918c72fcc34Sopenharmony_ci 10.[012]*|10) 919c72fcc34Sopenharmony_ci setup_hwcfg $CARD_DRIVER 920c72fcc34Sopenharmony_ci ;; 921c72fcc34Sopenharmony_ci esac 922c72fcc34Sopenharmony_ci fi 923c72fcc34Sopenharmony_ci 924c72fcc34Sopenharmony_ci farewell 925c72fcc34Sopenharmony_ci clear 926c72fcc34Sopenharmony_ci case "$distribution" in 927c72fcc34Sopenharmony_ci gentoo | debian) 928c72fcc34Sopenharmony_ci xecho "Running update-modules..." 929c72fcc34Sopenharmony_ci update-modules 930c72fcc34Sopenharmony_ci ;; 931c72fcc34Sopenharmony_ci esac 932c72fcc34Sopenharmony_ci if [ -x $rcalsasound ] ; then 933c72fcc34Sopenharmony_ci echo Loading driver... 934c72fcc34Sopenharmony_ci $rcalsasound restart 935c72fcc34Sopenharmony_ci fi 936c72fcc34Sopenharmony_ci echo Setting default volumes... 937c72fcc34Sopenharmony_ci if [ -x $bindir/set_default_volume ]; then 938c72fcc34Sopenharmony_ci $bindir/set_default_volume -f 939c72fcc34Sopenharmony_ci else 940c72fcc34Sopenharmony_ci set_mixers 941c72fcc34Sopenharmony_ci fi 942c72fcc34Sopenharmony_ci if [ -f $TESTSOUND ]; then 943c72fcc34Sopenharmony_ci msg=$(gettext " 944c72fcc34Sopenharmony_ci The mixer is set up now for for playing. 945c72fcc34Sopenharmony_ci Shall I try to play a sound sample now? 946c72fcc34Sopenharmony_ci 947c72fcc34Sopenharmony_ci NOTE: 948c72fcc34Sopenharmony_ciIf you have a big amplifier, lower your volumes or say no. 949c72fcc34Sopenharmony_ci Otherwise check that your speaker volume is open, 950c72fcc34Sopenharmony_ci and look if you can hear test sound. 951c72fcc34Sopenharmony_ci") 952c72fcc34Sopenharmony_ci if $DIALOG --yesno "$msg" 13 65 953c72fcc34Sopenharmony_ci then 954c72fcc34Sopenharmony_ci clear 955c72fcc34Sopenharmony_ci echo 956c72fcc34Sopenharmony_ci aplay -N $TESTSOUND 957c72fcc34Sopenharmony_ci fi 958c72fcc34Sopenharmony_ci fi 959c72fcc34Sopenharmony_ci mkdir -p -m 0755 @ASOUND_STATE_DIR@ 960c72fcc34Sopenharmony_ci if [ ! -r @ASOUND_STATE_DIR@/asound.state ]; then 961c72fcc34Sopenharmony_ci xecho "Saving the mixer setup used for this in @ASOUND_STATE_DIR@/asound.state." 962c72fcc34Sopenharmony_ci $sbindir/alsactl store 963c72fcc34Sopenharmony_ci fi 964c72fcc34Sopenharmony_ci clear 965c72fcc34Sopenharmony_ci xecho " 966c72fcc34Sopenharmony_ci=============================================================================== 967c72fcc34Sopenharmony_ci 968c72fcc34Sopenharmony_ci Now ALSA is ready to use. 969c72fcc34Sopenharmony_ci For adjustment of volumes, use your favorite mixer. 970c72fcc34Sopenharmony_ci 971c72fcc34Sopenharmony_ci Have a lot of fun! 972c72fcc34Sopenharmony_ci 973c72fcc34Sopenharmony_ci" 974c72fcc34Sopenharmony_ci} 975c72fcc34Sopenharmony_ci 976c72fcc34Sopenharmony_ci# check playback 977c72fcc34Sopenharmony_ci# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem) 978c72fcc34Sopenharmony_ciac_try_load () { 979c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE" 980c72fcc34Sopenharmony_ci /sbin/modprobe snd-$1 ${*:2} >/dev/null 2>&1 981c72fcc34Sopenharmony_ci if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then 982c72fcc34Sopenharmony_ci : ; 983c72fcc34Sopenharmony_ci else 984c72fcc34Sopenharmony_ci /sbin/modprobe -r snd-$1 >/dev/null 2>&1 985c72fcc34Sopenharmony_ci return 1 986c72fcc34Sopenharmony_ci fi 987c72fcc34Sopenharmony_ci 988c72fcc34Sopenharmony_ci # mute mixers 989c72fcc34Sopenharmony_ci amixer set Master 0% mute >/dev/null 2>&1 990c72fcc34Sopenharmony_ci amixer set PCM 0% mute >/dev/null 2>&1 991c72fcc34Sopenharmony_ci 992c72fcc34Sopenharmony_ci # output 0.5 sec 993c72fcc34Sopenharmony_ci head -c 4000 < /dev/zero | aplay -N -r8000 -fS16_LE -traw -c1 > /dev/null 2>&1 & 994c72fcc34Sopenharmony_ci # remember pid 995c72fcc34Sopenharmony_ci pp=$! 996c72fcc34Sopenharmony_ci # sleep for 2 seconds (to be sure -- 1 sec would be enough) 997c72fcc34Sopenharmony_ci sleep 2 998c72fcc34Sopenharmony_ci # kill the child process if still exists. 999c72fcc34Sopenharmony_ci kill -9 $pp > /dev/null 2>&1 1000c72fcc34Sopenharmony_ci st=$? 1001c72fcc34Sopenharmony_ci ac_cardname=`head -n 1 $PROCFS/asound/cards | sed -e 's/^[0-9].* - \(.*\)$/\1/'` 1002c72fcc34Sopenharmony_ci /sbin/modprobe -r snd-$1 >/dev/null 2>&1 1003c72fcc34Sopenharmony_ci if [ $st = 0 ]; then 1004c72fcc34Sopenharmony_ci # irq problem? 1005c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "no playback return" >> "$LOGFILE" 1006c72fcc34Sopenharmony_ci return 2 1007c72fcc34Sopenharmony_ci else 1008c72fcc34Sopenharmony_ci # seems ok! 1009c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "playback OK" >> "$LOGFILE" 1010c72fcc34Sopenharmony_ci return 0 1011c72fcc34Sopenharmony_ci fi 1012c72fcc34Sopenharmony_ci} 1013c72fcc34Sopenharmony_ci 1014c72fcc34Sopenharmony_ci# check capture 1015c72fcc34Sopenharmony_ci# return 0 - OK, 1 - NG, 2 - not working (irq/dma problem) 1016c72fcc34Sopenharmony_ci# ac_try_capture card duplex opts 1017c72fcc34Sopenharmony_ciac_try_capture () { 1018c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "$1 ${*:2}" >> "$LOGFILE" 1019c72fcc34Sopenharmony_ci /sbin/modprobe snd-$1 ${*:3} >/dev/null 2>&1 1020c72fcc34Sopenharmony_ci if $lsmod | grep -q -E '^(snd-|snd_)'$1' '; then 1021c72fcc34Sopenharmony_ci : ; 1022c72fcc34Sopenharmony_ci else 1023c72fcc34Sopenharmony_ci /sbin/modprobe -r snd-$1 >/dev/null 2>&1 1024c72fcc34Sopenharmony_ci return 1 1025c72fcc34Sopenharmony_ci fi 1026c72fcc34Sopenharmony_ci 1027c72fcc34Sopenharmony_ci # mute mixers 1028c72fcc34Sopenharmony_ci amixer set Master 0% mute >/dev/null 2>&1 1029c72fcc34Sopenharmony_ci amixer set PCM 0% mute >/dev/null 2>&1 1030c72fcc34Sopenharmony_ci 1031c72fcc34Sopenharmony_ci play_pid=0 1032c72fcc34Sopenharmony_ci if [ $2 = yes ]; then 1033c72fcc34Sopenharmony_ci # try duplex - start dummy playing 1034c72fcc34Sopenharmony_ci aplay -N -r8000 -fS16_LE -traw -c1 < /dev/zero > /dev/null 2>&1 & 1035c72fcc34Sopenharmony_ci play_pid=$! 1036c72fcc34Sopenharmony_ci fi 1037c72fcc34Sopenharmony_ci # record 1sec 1038c72fcc34Sopenharmony_ci arecord -N -d1 > /dev/null 2>&1 & 1039c72fcc34Sopenharmony_ci # remember pid 1040c72fcc34Sopenharmony_ci pp=$! 1041c72fcc34Sopenharmony_ci # sleep for 2 seconds 1042c72fcc34Sopenharmony_ci sleep 2 1043c72fcc34Sopenharmony_ci # kill the child process if still exists. 1044c72fcc34Sopenharmony_ci kill -9 $pp > /dev/null 2>&1 1045c72fcc34Sopenharmony_ci st=$? 1046c72fcc34Sopenharmony_ci # kill playback process if any 1047c72fcc34Sopenharmony_ci test $play_pid != 0 && kill -9 $play_pid 1048c72fcc34Sopenharmony_ci /sbin/modprobe -r snd-$1 >/dev/null 2>&1 1049c72fcc34Sopenharmony_ci if [ $st = 0 ]; then 1050c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "capture no return" >> "$LOGFILE" 1051c72fcc34Sopenharmony_ci return 2 1052c72fcc34Sopenharmony_ci else 1053c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "capture OK" >> "$LOGFILE" 1054c72fcc34Sopenharmony_ci return 0 1055c72fcc34Sopenharmony_ci fi 1056c72fcc34Sopenharmony_ci} 1057c72fcc34Sopenharmony_ci 1058c72fcc34Sopenharmony_ciget_dma_pair () { 1059c72fcc34Sopenharmony_ci case $1 in 1060c72fcc34Sopenharmony_ci 0) 1061c72fcc34Sopenharmony_ci echo 1 3 5;; 1062c72fcc34Sopenharmony_ci 1) 1063c72fcc34Sopenharmony_ci echo 0 3 5;; 1064c72fcc34Sopenharmony_ci 3) 1065c72fcc34Sopenharmony_ci echo 1 0 5;; 1066c72fcc34Sopenharmony_ci 5) 1067c72fcc34Sopenharmony_ci echo 3 1 0;; 1068c72fcc34Sopenharmony_ci esac 1069c72fcc34Sopenharmony_ci} 1070c72fcc34Sopenharmony_ci 1071c72fcc34Sopenharmony_ci# 1072c72fcc34Sopenharmony_ci# check playback on specified irqs 1073c72fcc34Sopenharmony_ci# 1074c72fcc34Sopenharmony_ci# ac_try_irq card opts irqs... 1075c72fcc34Sopenharmony_ci# return 0 - OK, 1 - NG, 2 - not working (dma problem?) 1076c72fcc34Sopenharmony_ci# 1077c72fcc34Sopenharmony_ciac_try_irq () { 1078c72fcc34Sopenharmony_ci card=$1 1079c72fcc34Sopenharmony_ci opts="$2 ${mpfx}irq=$3" 1080c72fcc34Sopenharmony_ci ac_try_load $card $opts >/dev/null 2>&1 1081c72fcc34Sopenharmony_ci result=$? 1082c72fcc34Sopenharmony_ci case $result in 1083c72fcc34Sopenharmony_ci 0) 1084c72fcc34Sopenharmony_ci ac_opts="$opts" 1085c72fcc34Sopenharmony_ci return 0 1086c72fcc34Sopenharmony_ci ;; 1087c72fcc34Sopenharmony_ci 2) 1088c72fcc34Sopenharmony_ci for irq in ${*:4}; do 1089c72fcc34Sopenharmony_ci opts="$2 ${mpfx}irq=$irq" 1090c72fcc34Sopenharmony_ci ac_try_load $card $opts >/dev/null 2>&1 1091c72fcc34Sopenharmony_ci if [ $? = 0 ]; then 1092c72fcc34Sopenharmony_ci ac_opts="$opts" 1093c72fcc34Sopenharmony_ci return 0 1094c72fcc34Sopenharmony_ci fi 1095c72fcc34Sopenharmony_ci done 1096c72fcc34Sopenharmony_ci return 2 1097c72fcc34Sopenharmony_ci ;; 1098c72fcc34Sopenharmony_ci esac 1099c72fcc34Sopenharmony_ci return 1 1100c72fcc34Sopenharmony_ci} 1101c72fcc34Sopenharmony_ci 1102c72fcc34Sopenharmony_ci# 1103c72fcc34Sopenharmony_ci# check playback/capture on dma1 & dma2 & specified irqs 1104c72fcc34Sopenharmony_ci# 1105c72fcc34Sopenharmony_ci# ac_try_dmas card opts irqs... 1106c72fcc34Sopenharmony_ci# return 0 - OK, 1 - NG 1107c72fcc34Sopenharmony_ci# 1108c72fcc34Sopenharmony_ciac_try_dmas () { 1109c72fcc34Sopenharmony_ci dma_list=`check_dma_avail 1 0 3 5` 1110c72fcc34Sopenharmony_ci for irq in ${*:3}; do 1111c72fcc34Sopenharmony_ci for dma1 in $dma_list; do 1112c72fcc34Sopenharmony_ci for dma2 in `get_dma_pair $dma1`; do 1113c72fcc34Sopenharmony_ci opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq" 1114c72fcc34Sopenharmony_ci ac_try_load $1 $opts >/dev/null 2>&1 1115c72fcc34Sopenharmony_ci result=$? 1116c72fcc34Sopenharmony_ci if [ $result = 1 ]; then 1117c72fcc34Sopenharmony_ci if [ $try_all_combination = 1 ]; then 1118c72fcc34Sopenharmony_ci continue 1119c72fcc34Sopenharmony_ci else 1120c72fcc34Sopenharmony_ci return 1 1121c72fcc34Sopenharmony_ci fi 1122c72fcc34Sopenharmony_ci elif [ $result = 0 ]; then 1123c72fcc34Sopenharmony_ci test -n "$LOGFILE" && echo "Now checking capture..." >> "$LOGFILE" 1124c72fcc34Sopenharmony_ci ac_opts="$opts" 1125c72fcc34Sopenharmony_ci ac_try_capture $1 yes $opts >/dev/null 2>&1 && return 0 1126c72fcc34Sopenharmony_ci for d in yes no; do 1127c72fcc34Sopenharmony_ci for dma2 in $dma_list; do 1128c72fcc34Sopenharmony_ci if [ $dma1 != $dma2 ]; then 1129c72fcc34Sopenharmony_ci opts="$2 ${mpfx}dma1=$dma1 ${mpfx}dma2=$dma2 ${mpfx}irq=$irq" 1130c72fcc34Sopenharmony_ci ac_opts="$opts" 1131c72fcc34Sopenharmony_ci ac_try_capture $1 $d $opts >/dev/null 2>&1 && return 0 1132c72fcc34Sopenharmony_ci fi 1133c72fcc34Sopenharmony_ci done 1134c72fcc34Sopenharmony_ci done 1135c72fcc34Sopenharmony_ci return 0 1136c72fcc34Sopenharmony_ci fi 1137c72fcc34Sopenharmony_ci done 1138c72fcc34Sopenharmony_ci done 1139c72fcc34Sopenharmony_ci done 1140c72fcc34Sopenharmony_ci return 1 1141c72fcc34Sopenharmony_ci} 1142c72fcc34Sopenharmony_ci 1143c72fcc34Sopenharmony_ci# check if the option $2 exists in card $1: set value $3 1144c72fcc34Sopenharmony_ciac_check_option () { 1145c72fcc34Sopenharmony_ci if /sbin/modinfo -p snd-$1 | grep -q $2; then 1146c72fcc34Sopenharmony_ci echo "$2=$3" 1147c72fcc34Sopenharmony_ci fi 1148c72fcc34Sopenharmony_ci} 1149c72fcc34Sopenharmony_ci 1150c72fcc34Sopenharmony_ciac_try_card_sb8 () { 1151c72fcc34Sopenharmony_ci card=sb8 1152c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 3 9 10 7` 1153c72fcc34Sopenharmony_ci for dma8 in `check_dma_avail 1 3`; do 1154c72fcc34Sopenharmony_ci opts="${mpfx}dma8=$dma8" 1155c72fcc34Sopenharmony_ci ac_try_irq $card "$opts" $irq_list && return 0 1156c72fcc34Sopenharmony_ci done 1157c72fcc34Sopenharmony_ci return 1 1158c72fcc34Sopenharmony_ci} 1159c72fcc34Sopenharmony_ci 1160c72fcc34Sopenharmony_ciac_try_card_sb16 () { 1161c72fcc34Sopenharmony_ci card=sb16 1162c72fcc34Sopenharmony_ci isapnp=`ac_check_option $card ${mpfx}isapnp 0` 1163c72fcc34Sopenharmony_ci opts="$isapnp" 1164c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 9 10 7 3` 1165c72fcc34Sopenharmony_ci dma_list=`check_dma_avail 0 1 3` 1166c72fcc34Sopenharmony_ci dma16_list=`check_dma_avail 5 6 7` 1167c72fcc34Sopenharmony_ci # at first try auto-probing by driver itself 1168c72fcc34Sopenharmony_ci ac_try_load $card $opts >/dev/null 2>&1 1169c72fcc34Sopenharmony_ci result=$? 1170c72fcc34Sopenharmony_ci case $result in 1171c72fcc34Sopenharmony_ci 0) 1172c72fcc34Sopenharmony_ci ac_opts="$opts" 1173c72fcc34Sopenharmony_ci ac_try_capture $card yes $opts >/dev/null 2>&1 && return 0 1174c72fcc34Sopenharmony_ci for d in yes no; do 1175c72fcc34Sopenharmony_ci for dma8 in $dma_list; do 1176c72fcc34Sopenharmony_ci for irq in $irq_list; do 1177c72fcc34Sopenharmony_ci opts="${mpfx}dma8=$dma8 ${mpfx}irq=$irq $isapnp" 1178c72fcc34Sopenharmony_ci ac_try_capture $card $d $opts >/dev/null 2>&1 && return 0 1179c72fcc34Sopenharmony_ci done 1180c72fcc34Sopenharmony_ci done 1181c72fcc34Sopenharmony_ci done 1182c72fcc34Sopenharmony_ci return 0 1183c72fcc34Sopenharmony_ci ;; 1184c72fcc34Sopenharmony_ci 2) 1185c72fcc34Sopenharmony_ci for dma16 in $dma16_list; do 1186c72fcc34Sopenharmony_ci opts="${mpfx}dma16=$dma16 $isapnp" 1187c72fcc34Sopenharmony_ci if ac_try_irq $card "$opts" $irq_list ; then 1188c72fcc34Sopenharmony_ci ac_try_capture $card yes $ac_opts >/dev/null 2>&1 && return 0 1189c72fcc34Sopenharmony_ci ac_opts_saved="$ac_opts" 1190c72fcc34Sopenharmony_ci for d in yes no; do 1191c72fcc34Sopenharmony_ci for dma8 in $dma_list; do 1192c72fcc34Sopenharmony_ci ac_opts="$ac_opts_saved ${mpfx}dma8=$dma8" 1193c72fcc34Sopenharmony_ci ac_try_capture $card $d $ac_opts >/dev/null 2>&1 && return 0 1194c72fcc34Sopenharmony_ci done 1195c72fcc34Sopenharmony_ci done 1196c72fcc34Sopenharmony_ci # return anyway here.. 1197c72fcc34Sopenharmony_ci return 0 1198c72fcc34Sopenharmony_ci fi 1199c72fcc34Sopenharmony_ci done 1200c72fcc34Sopenharmony_ci ;; 1201c72fcc34Sopenharmony_ci esac 1202c72fcc34Sopenharmony_ci return 1 1203c72fcc34Sopenharmony_ci} 1204c72fcc34Sopenharmony_ci 1205c72fcc34Sopenharmony_ciac_try_card_es1688 () { 1206c72fcc34Sopenharmony_ci card=es1688 1207c72fcc34Sopenharmony_ci opts="" 1208c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 9 10 7` 1209c72fcc34Sopenharmony_ci for dma8 in `check_dma_avail 1 3 0`; do 1210c72fcc34Sopenharmony_ci opts="${mpfx}dma8=$dma8 ${mpfx}mpu_irq=-1" 1211c72fcc34Sopenharmony_ci ac_try_irq $card "$opts" $irq_list && return 0 1212c72fcc34Sopenharmony_ci done 1213c72fcc34Sopenharmony_ci return 1 1214c72fcc34Sopenharmony_ci} 1215c72fcc34Sopenharmony_ci 1216c72fcc34Sopenharmony_ciac_try_card_es18xx () { 1217c72fcc34Sopenharmony_ci card=es18xx 1218c72fcc34Sopenharmony_ci opts=`ac_check_option $card ${mpfx}isapnp 0` 1219c72fcc34Sopenharmony_ci ac_try_dmas $card "$opts" `check_irq_avail 5 9 10 7` && return 0 1220c72fcc34Sopenharmony_ci return 1 1221c72fcc34Sopenharmony_ci} 1222c72fcc34Sopenharmony_ci 1223c72fcc34Sopenharmony_ciac_try_card_cs4236 () { 1224c72fcc34Sopenharmony_ci card=cs4236 1225c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 7 9 11 12 15` 1226c72fcc34Sopenharmony_ci isapnp=`ac_check_option $card ${mpfx}isapnp 0` 1227c72fcc34Sopenharmony_ci for cport in 0x538 0x210 0xf00; do 1228c72fcc34Sopenharmony_ci for port in 0x530 0x534; do 1229c72fcc34Sopenharmony_ci opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp" 1230c72fcc34Sopenharmony_ci ac_try_dmas $card "$opts" $irq_list && return 0 1231c72fcc34Sopenharmony_ci done 1232c72fcc34Sopenharmony_ci done 1233c72fcc34Sopenharmony_ci return 1 1234c72fcc34Sopenharmony_ci} 1235c72fcc34Sopenharmony_ci 1236c72fcc34Sopenharmony_ciac_try_card_cs4232 () { 1237c72fcc34Sopenharmony_ci card=cs4232 1238c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 7 9 11 12 15` 1239c72fcc34Sopenharmony_ci isapnp=`ac_check_option $card ${mpfx}isapnp 0` 1240c72fcc34Sopenharmony_ci for cport in 0x538 0x210 0xf00; do 1241c72fcc34Sopenharmony_ci for port in 0x530 0x534; do 1242c72fcc34Sopenharmony_ci opts="${mpfx}port=$port ${mpfx}cport=$cport $isapnp" 1243c72fcc34Sopenharmony_ci ac_try_dmas $card "$opts" $irq_list && return 0 1244c72fcc34Sopenharmony_ci done 1245c72fcc34Sopenharmony_ci done 1246c72fcc34Sopenharmony_ci return 1 1247c72fcc34Sopenharmony_ci} 1248c72fcc34Sopenharmony_ci 1249c72fcc34Sopenharmony_ciac_try_card_cs4231 () { 1250c72fcc34Sopenharmony_ci card=cs4231 1251c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 7 9 11 12 15` 1252c72fcc34Sopenharmony_ci for port in 0x530 0x534; do 1253c72fcc34Sopenharmony_ci opts="${mpfx}port=$port" 1254c72fcc34Sopenharmony_ci ac_try_dmas $card "$opts" $irq_list && return 0 1255c72fcc34Sopenharmony_ci done 1256c72fcc34Sopenharmony_ci return 1 1257c72fcc34Sopenharmony_ci} 1258c72fcc34Sopenharmony_ci 1259c72fcc34Sopenharmony_ciac_try_card_opl3sa2 () { 1260c72fcc34Sopenharmony_ci card=opl3sa2 1261c72fcc34Sopenharmony_ci irq_list=`check_irq_avail 5 9 3 1 11 12 15 0` 1262c72fcc34Sopenharmony_ci isapnp=`ac_check_option $card ${mpfx}isapnp 0` 1263c72fcc34Sopenharmony_ci for port in 0x370 0x538 0xf86 0x100; do 1264c72fcc34Sopenharmony_ci for wss_port in 0x530 0xe80 0xf40 0x604; do 1265c72fcc34Sopenharmony_ci opts="${mpfx}fm_port=-1 ${mpfx}midi_port=-1 ${mpfx}port=$port ${mpfx}wss_port=$wss_port $isapnp" 1266c72fcc34Sopenharmony_ci ac_try_dmas $card "$opts" $irq_list && return 0 1267c72fcc34Sopenharmony_ci done 1268c72fcc34Sopenharmony_ci done 1269c72fcc34Sopenharmony_ci return 1 1270c72fcc34Sopenharmony_ci} 1271c72fcc34Sopenharmony_ci 1272c72fcc34Sopenharmony_ciac_config_legacy () { 1273c72fcc34Sopenharmony_ci title=$(gettext "WARNING") 1274c72fcc34Sopenharmony_ci msg=$(gettext " 1275c72fcc34Sopenharmony_ci Probing legacy ISA cards might make 1276c72fcc34Sopenharmony_ci your system unstable. 1277c72fcc34Sopenharmony_ci 1278c72fcc34Sopenharmony_ci Do you want to proceed? 1279c72fcc34Sopenharmony_ci 1280c72fcc34Sopenharmony_ci") 1281c72fcc34Sopenharmony_ci $DIALOG --title "$title" --yesno "$msg" 10 50 || acex 0 1282c72fcc34Sopenharmony_ci 1283c72fcc34Sopenharmony_ci if [ x"$1" = x ]; then 1284c72fcc34Sopenharmony_ci probe_list="$LEGACY_CARDS" 1285c72fcc34Sopenharmony_ci else 1286c72fcc34Sopenharmony_ci probe_list=$* 1287c72fcc34Sopenharmony_ci fi 1288c72fcc34Sopenharmony_ci menu_args=() 1289c72fcc34Sopenharmony_ci 1290c72fcc34Sopenharmony_ci for card in $probe_list; do 1291c72fcc34Sopenharmony_ci cardname=`/sbin/modinfo -d snd-$card | sed -e 's/^\"\(.*\)\"$/\1/g'` 1292c72fcc34Sopenharmony_ci if [ x"$cardname" != x ]; then 1293c72fcc34Sopenharmony_ci menu_args=("${menu_args[@]}" "$card" "$cardname" "on") 1294c72fcc34Sopenharmony_ci fi 1295c72fcc34Sopenharmony_ci done 1296c72fcc34Sopenharmony_ci if [ x$menu_args = x ]; then 1297c72fcc34Sopenharmony_ci msg=$(gettext "No legacy drivers are available 1298c72fcc34Sopenharmony_ci for your machine") 1299c72fcc34Sopenharmony_ci $DIALOG --msgbox "$msg" 5 50 1300c72fcc34Sopenharmony_ci return 1 1301c72fcc34Sopenharmony_ci fi 1302c72fcc34Sopenharmony_ci title=$(gettext "Driver Selection") 1303c72fcc34Sopenharmony_ci msg=$(gettext " Probing legacy ISA cards 1304c72fcc34Sopenharmony_ci 1305c72fcc34Sopenharmony_ci Please select the drivers to probe:") 1306c72fcc34Sopenharmony_ci $DIALOG --title "$title" --checklist "$msg" \ 1307c72fcc34Sopenharmony_ci 17 64 8 "${menu_args[@]}" 2> $FOUND || acex 0 1308c72fcc34Sopenharmony_ci 1309c72fcc34Sopenharmony_ci if [ $try_all_combination != 1 ]; then 1310c72fcc34Sopenharmony_ci msg=$(gettext " 1311c72fcc34Sopenharmony_ci Shall I try all possible DMA and IRQ combinations? 1312c72fcc34Sopenharmony_ci With this option, some unconventional configuration 1313c72fcc34Sopenharmony_ci might be found, but it will take much longer time.") 1314c72fcc34Sopenharmony_ci if $DIALOG --yesno "$msg" 10 60 1315c72fcc34Sopenharmony_ci then 1316c72fcc34Sopenharmony_ci try_all_combination=1 1317c72fcc34Sopenharmony_ci fi 1318c72fcc34Sopenharmony_ci fi 1319c72fcc34Sopenharmony_ci 1320c72fcc34Sopenharmony_ci xecho "Probing legacy cards.. This may take a few minutes.." 1321c72fcc34Sopenharmony_ci echo -n $(gettext "Probing: ") 1322c72fcc34Sopenharmony_ci cards=`cat $FOUND | tr -d \"` 1323c72fcc34Sopenharmony_ci for card in $cards; do 1324c72fcc34Sopenharmony_ci echo -n " $card" 1325c72fcc34Sopenharmony_ci ac_opts="" 1326c72fcc34Sopenharmony_ci if eval ac_try_card_$card ; then 1327c72fcc34Sopenharmony_ci xecho " : FOUND!!" 1328c72fcc34Sopenharmony_ci ac_config_card $card $ac_opts 1329c72fcc34Sopenharmony_ci return 0 1330c72fcc34Sopenharmony_ci fi 1331c72fcc34Sopenharmony_ci done 1332c72fcc34Sopenharmony_ci echo 1333c72fcc34Sopenharmony_ci title=$(gettext "Result") 1334c72fcc34Sopenharmony_ci msg=$(gettext "No legacy cards found") 1335c72fcc34Sopenharmony_ci $DIALOG --title "$title" --msgbox "$msg" 5 50 1336c72fcc34Sopenharmony_ci return 1 1337c72fcc34Sopenharmony_ci} 1338c72fcc34Sopenharmony_ci 1339c72fcc34Sopenharmony_ci# 1340c72fcc34Sopenharmony_ci# main part continued.. 1341c72fcc34Sopenharmony_ci# 1342c72fcc34Sopenharmony_ci 1343c72fcc34Sopenharmony_ciif test -n "$LOGFILE" ; then 1344c72fcc34Sopenharmony_ci touch "$LOGFILE" 1345c72fcc34Sopenharmony_ci echo -n "Starting alsaconf: " >> "$LOGFILE" 1346c72fcc34Sopenharmony_ci date >> "$LOGFILE" 1347c72fcc34Sopenharmony_cifi 1348c72fcc34Sopenharmony_ci 1349c72fcc34Sopenharmony_ciif [ x"$legacy_probe_card" != x ]; then 1350c72fcc34Sopenharmony_ci ac_opts="" 1351c72fcc34Sopenharmony_ci if eval ac_try_card_$legacy_probe_card >/dev/null 2>&1; then 1352c72fcc34Sopenharmony_ci echo "$ac_opts" 1353c72fcc34Sopenharmony_ci echo "$ac_cardname" 1354c72fcc34Sopenharmony_ci exit 0 1355c72fcc34Sopenharmony_ci else 1356c72fcc34Sopenharmony_ci echo "FAILED" 1357c72fcc34Sopenharmony_ci exit 1 1358c72fcc34Sopenharmony_ci fi 1359c72fcc34Sopenharmony_cifi 1360c72fcc34Sopenharmony_ci 1361c72fcc34Sopenharmony_ciintro 1362c72fcc34Sopenharmony_ci 1363c72fcc34Sopenharmony_ciif [ $do_legacy_only = 1 ]; then 1364c72fcc34Sopenharmony_ci ac_config_legacy 1365c72fcc34Sopenharmony_ci exit 0 1366c72fcc34Sopenharmony_cifi 1367c72fcc34Sopenharmony_ci 1368c72fcc34Sopenharmony_ciprobe_cards 1369c72fcc34Sopenharmony_ci 1370c72fcc34Sopenharmony_cidevs_found=() 1371c72fcc34Sopenharmony_cidevs_olist="" 1372c72fcc34Sopenharmony_ci 1373c72fcc34Sopenharmony_ciif [ -s "$FOUND" ]; then 1374c72fcc34Sopenharmony_ci while read dev card ; do 1375c72fcc34Sopenharmony_ci MODDIR=/lib/modules/`uname -r` 1376c72fcc34Sopenharmony_ci find $MODDIR -type f | grep -q -E $card'\.(o|ko)' || continue 1377c72fcc34Sopenharmony_ci cardname=`find_device_name $dev | cut -c 1-64` 1378c72fcc34Sopenharmony_ci if [ -z "$cardname" ]; then 1379c72fcc34Sopenharmony_ci cardname="$card" 1380c72fcc34Sopenharmony_ci fi 1381c72fcc34Sopenharmony_ci card=${card##snd-} 1382c72fcc34Sopenharmony_ci devs_found=("${devs_found[@]}" "$card" "$cardname") 1383c72fcc34Sopenharmony_ci devs_devs=("${devs_devs[@]}" "$card" "$dev") 1384c72fcc34Sopenharmony_ci done <"$FOUND" 1385c72fcc34Sopenharmony_ci devs_olist=`cat $FOUND` 1386c72fcc34Sopenharmony_cifi 1387c72fcc34Sopenharmony_ciif [ x$devs_found != x ]; then 1388c72fcc34Sopenharmony_ci # 1389c72fcc34Sopenharmony_ci # check for TP600E 1390c72fcc34Sopenharmony_ci # 1391c72fcc34Sopenharmony_ci if [ ${devs_found[0]} = cs46xx ]; then 1392c72fcc34Sopenharmony_ci if $lspci -nv 2>/dev/null| grep -q "Subsystem: 1014:1010"; then 1393c72fcc34Sopenharmony_ci msg=$(gettext " 1394c72fcc34Sopenharmony_ci Looks like you having a Thinkpad 600E or 770 notebook. 1395c72fcc34Sopenharmony_ci On this notebook, CS4236 driver should be used 1396c72fcc34Sopenharmony_ci although CS46xx chip is detected. 1397c72fcc34Sopenharmony_ci 1398c72fcc34Sopenharmony_ci Shall I try to snd-cs4236 driver and probe 1399c72fcc34Sopenharmony_ci the legacy ISA configuration?") 1400c72fcc34Sopenharmony_ci if $DIALOG --yesno "$msg" 13 60 1401c72fcc34Sopenharmony_ci then 1402c72fcc34Sopenharmony_ci try_all_combination=1 1403c72fcc34Sopenharmony_ci ac_config_legacy cs4236 1404c72fcc34Sopenharmony_ci exit 0 1405c72fcc34Sopenharmony_ci fi 1406c72fcc34Sopenharmony_ci elif $lspci -nv 2>/dev/null| grep -q "Subsystem: 8086:8080"; then 1407c72fcc34Sopenharmony_ci msg=$(gettext " 1408c72fcc34Sopenharmony_ci Looks like you having a Dell Dimension machine. 1409c72fcc34Sopenharmony_ci On this machine, CS4232 driver should be used 1410c72fcc34Sopenharmony_ci although CS46xx chip is detected. 1411c72fcc34Sopenharmony_ci 1412c72fcc34Sopenharmony_ci Shall I try to snd-cs4232 driver and probe 1413c72fcc34Sopenharmony_ci the legacy ISA configuration?") 1414c72fcc34Sopenharmony_ci if $DIALOG --yesno "$msg" 13 60 1415c72fcc34Sopenharmony_ci then 1416c72fcc34Sopenharmony_ci try_all_combination=1 1417c72fcc34Sopenharmony_ci ac_config_legacy cs4232 1418c72fcc34Sopenharmony_ci exit 0 1419c72fcc34Sopenharmony_ci fi 1420c72fcc34Sopenharmony_ci fi 1421c72fcc34Sopenharmony_ci fi 1422c72fcc34Sopenharmony_ci 1423c72fcc34Sopenharmony_ci devs_found=("${devs_found[@]}" "legacy" "Probe legacy ISA (non-PnP) chips") 1424c72fcc34Sopenharmony_ci title=$(gettext "Soundcard Selection") 1425c72fcc34Sopenharmony_ci msg=$(gettext " 1426c72fcc34Sopenharmony_ci Following card(s) are found on your system. 1427c72fcc34Sopenharmony_ci Choose a soundcard to configure: 1428c72fcc34Sopenharmony_ci") 1429c72fcc34Sopenharmony_ci $DIALOG --title "$title" --menu "$msg" 17 76 8 "${devs_found[@]}" --output-fd 3 3> $FOUND || acex 0 1430c72fcc34Sopenharmony_ci card=`head -n 1 $FOUND` 1431c72fcc34Sopenharmony_ci if [ "$card" = "legacy" ]; then 1432c72fcc34Sopenharmony_ci ac_config_legacy 1433c72fcc34Sopenharmony_ci else 1434c72fcc34Sopenharmony_ci ac_config_card "$card" 1435c72fcc34Sopenharmony_ci fi 1436c72fcc34Sopenharmony_ci exit 0 1437c72fcc34Sopenharmony_cielse 1438c72fcc34Sopenharmony_ci msg=$(gettext " 1439c72fcc34Sopenharmony_ci No supported PnP or PCI card found. 1440c72fcc34Sopenharmony_ci 1441c72fcc34Sopenharmony_ci Would you like to probe legacy ISA sound cards/chips? 1442c72fcc34Sopenharmony_ci 1443c72fcc34Sopenharmony_ci") 1444c72fcc34Sopenharmony_ci if $DIALOG --yesno "$msg" 9 60 ; then 1445c72fcc34Sopenharmony_ci ac_config_legacy 1446c72fcc34Sopenharmony_ci exit 0 1447c72fcc34Sopenharmony_ci fi 1448c72fcc34Sopenharmony_cifi 1449c72fcc34Sopenharmony_ci 1450c72fcc34Sopenharmony_cirm -f "$FOUND" "$DUMP" 1451c72fcc34Sopenharmony_ciexit 0 1452