File: snddevices.in

package info (click to toggle)
alsadriver 0.4.1i-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,256 kB
  • ctags: 15,024
  • sloc: ansic: 96,846; makefile: 1,232; sh: 1,051; perl: 54
file content (144 lines) | stat: -rwxr-xr-x 3,102 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh

MAJOR=116
OSSMAJOR=14
MAX_CARDS=4
PERM=666
STATIC=0
OWNER=root.root

if [ "`grep -w -E "^audio" /etc/group`x" != x ]; then
  PERM=660
  OWNER=root.audio
fi

function create_odevice () {
  rm -f $1
  echo -n "Creating $1..."
  mknod -m $PERM $1 c $OSSMAJOR $2
  chown $OWNER $1
  echo " done"
}

function create_odevices () {
  tmp=0
  tmp1=0
  rm -f $1 $1?
  echo -n "Creating $1?..."
  while [ $tmp1 -lt $MAX_CARDS ]; do
    minor=$[ $2 + $tmp ]
    mknod -m $PERM $1$tmp1 c $OSSMAJOR $minor
    chown $OWNER $1$tmp1
    tmp=$[ $tmp + 16 ]
    tmp1=$[ $tmp1 + 1 ]
  done
  echo " done"
}

function create_device1 () {
  rm -f $1
  minor=$2
  echo -n "Creating $1..."
  mknod -m $PERM $1 c $MAJOR $minor
  chown $OWNER $1
  echo " done"
}

function create_devices () {
  tmp=0
  rm -f $1 $1?
  echo -n "Creating $1?..."
  while [ $tmp -lt $MAX_CARDS ]; do
    minor=$[ $tmp * 32 ]
    minor=$[ $2 + $minor ]
    mknod -m $PERM "${1}C${tmp}" c $MAJOR $minor
    chown $OWNER "${1}C${tmp}"
    tmp=$[ $tmp + 1 ]
  done
  echo " done"
}

function create_devices2 () {
  tmp=0
  rm -f $1 $1?
  echo -n "Creating $1??..."
  while [ $tmp -lt $MAX_CARDS ]; do
    tmp1=0
    while [ $tmp1 -lt $3 ]; do
      minor=$[ $tmp * 32 ]
      minor=$[ $2 + $minor + $tmp1 ]
      mknod -m $PERM "${1}C${tmp}D${tmp1}" c $MAJOR $minor
      chown $OWNER "${1}C${tmp}D${tmp1}"
      tmp1=$[ $tmp1 + 1 ]
    done
    tmp=$[ $tmp + 1 ]
  done
  echo " done"
}

if test "$1" = "-?" || test "$1" = "-h" || test "$1" = "--help"; then
  echo "Usage: snddevices [max]"
  exit
fi

if test "$1" = "max"; then
  DSP_MINOR=19
fi

# OSS (Lite) compatible devices...

if test $OSSMAJOR -eq 14; then
  create_odevices /dev/mixer		0
  create_odevice /dev/sequencer		1
  create_odevices /dev/midi		2
  create_odevices /dev/dsp		3
  create_odevices /dev/audio		4
  create_odevice /dev/sndstat		6
  create_odevice /dev/music		8
  create_odevices /dev/dmmidi		9
  create_odevices /dev/dmfm		10
  create_odevices /dev/adsp		12	# alternate dsp
  create_odevices /dev/amidi		13	# alternate midi
  create_odevices /dev/admmidi		14	# alternate direct midi
  # create symlinks
  ln -svf /dev/mixer0 /dev/mixer
  ln -svf /dev/midi0 /dev/midi
  ln -svf /dev/dsp0 /dev/dsp
  ln -svf /dev/audio0 /dev/audio
  ln -svf /dev/music /dev/sequencer2
  ln -svf /dev/adsp0 /dev/adsp
  ln -svf /dev/amidi0 /dev/amidi
fi

# New devices (obsolete now)...

mv -f /dev/sndstat /dev/1sndstat
rm -f /dev/snd*
mv -f /dev/1sndstat /dev/sndstat
if [ -d /dev/snd ]; then
  rm -f /dev/snd/*
  rmdir /dev/snd
fi
if [ $STATIC -gt 0 ]; then
  mkdir -p /dev/snd
  create_devices  /dev/snd/control	0
  create_device1  /dev/snd/seq		1
  create_devices2 /dev/snd/hw		2	4
  create_devices2 /dev/snd/mixer	6	2
  create_devices2 /dev/snd/pcm		16	16
  create_devices2 /dev/snd/midi		8	4
fi

# New dynamic sound device filesystem

if [ $STATIC -le 0 ]; then
  echo "ALSA dynamic sound device filesystem"
  ln -sfv /proc/asound/dev /dev/snd
fi

# Loader devices

echo "ALSA loader devices"
rm -f /dev/aload*
create_devices  /dev/aload		0
create_device1  /dev/aloadSEQ		1