Deleted Added
full compact
sound.c (160439) sound.c (162588)
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * (C) 1997 Luigi Rizzo (luigi@iet.unipi.it)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <dev/sound/pcm/sound.h>
29#include <dev/sound/pcm/vchan.h>
30#include <dev/sound/pcm/dsp.h>
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * (C) 1997 Luigi Rizzo (luigi@iet.unipi.it)
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <dev/sound/pcm/sound.h>
29#include <dev/sound/pcm/vchan.h>
30#include <dev/sound/pcm/dsp.h>
31#include <sys/limits.h>
31#include <sys/sysctl.h>
32
33#include "feeder_if.h"
34
32#include <sys/sysctl.h>
33
34#include "feeder_if.h"
35
35SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/sound.c 160439 2006-07-17 17:43:06Z netchild $");
36SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/sound.c 162588 2006-09-23 20:45:47Z netchild $");
36
37devclass_t pcm_devclass;
38
39int pcm_veto_load = 1;
40
41#ifdef USING_DEVFS
42int snd_unit = 0;
43TUNABLE_INT("hw.snd.default_unit", &snd_unit);
44#endif
45
46int snd_maxautovchans = 4;
47/* XXX: a tunable implies that we may need more than one sound channel before
48 the system can change a sysctl (/etc/sysctl.conf), do we really need
49 this? */
50TUNABLE_INT("hw.snd.maxautovchans", &snd_maxautovchans);
51
52SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver");
53
37
38devclass_t pcm_devclass;
39
40int pcm_veto_load = 1;
41
42#ifdef USING_DEVFS
43int snd_unit = 0;
44TUNABLE_INT("hw.snd.default_unit", &snd_unit);
45#endif
46
47int snd_maxautovchans = 4;
48/* XXX: a tunable implies that we may need more than one sound channel before
49 the system can change a sysctl (/etc/sysctl.conf), do we really need
50 this? */
51TUNABLE_INT("hw.snd.maxautovchans", &snd_maxautovchans);
52
53SYSCTL_NODE(_hw, OID_AUTO, snd, CTLFLAG_RD, 0, "Sound driver");
54
55/**
56 * @brief Unit number allocator for syncgroup IDs
57 */
58struct unrhdr *pcmsg_unrhdr = NULL;
59
54static int sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose);
55
56struct sysctl_ctx_list *
57snd_sysctl_tree(device_t dev)
58{
59 struct snddev_info *d = device_get_softc(dev);
60
61 return &d->sysctl_tree;

--- 1059 unchanged lines hidden (view full) ---

1121 err = pcm_setvchans(d, newcnt);
1122
1123 return err;
1124}
1125#endif
1126
1127/************************************************************************/
1128
60static int sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose);
61
62struct sysctl_ctx_list *
63snd_sysctl_tree(device_t dev)
64{
65 struct snddev_info *d = device_get_softc(dev);
66
67 return &d->sysctl_tree;

--- 1059 unchanged lines hidden (view full) ---

1127 err = pcm_setvchans(d, newcnt);
1128
1129 return err;
1130}
1131#endif
1132
1133/************************************************************************/
1134
1135/**
1136 * @brief Handle OSSv4 SNDCTL_SYSINFO ioctl.
1137 *
1138 * @param si Pointer to oss_sysinfo struct where information about the
1139 * sound subsystem will be written/copied.
1140 *
1141 * This routine returns information about the sound system, such as the
1142 * current OSS version, number of audio, MIDI, and mixer drivers, etc.
1143 * Also includes a bitmask showing which of the above types of devices
1144 * are open (busy).
1145 *
1146 * @note
1147 * Calling threads must not hold any snddev_info or pcm_channel locks.
1148 *
1149 * @author Ryan Beasley <ryanb@FreeBSD.org>
1150 */
1151void
1152sound_oss_sysinfo(oss_sysinfo *si)
1153{
1154 static char si_product[] = "FreeBSD native OSS ABI";
1155 static char si_version[] = __XSTRING(__FreeBSD_version);
1156 static int intnbits = sizeof(int) * 8; /* Better suited as macro?
1157 Must pester a C guru. */
1158
1159 struct snddev_channel *sce;
1160 struct snddev_info *d;
1161 struct pcm_channel *c;
1162 int i, j, ncards;
1163
1164 ncards = 0;
1165
1166 strlcpy(si->product, si_product, sizeof(si->product));
1167 strlcpy(si->version, si_version, sizeof(si->version));
1168 si->versionnum = SOUND_VERSION;
1169
1170 /*
1171 * Iterate over PCM devices and their channels, gathering up data
1172 * for the numaudios, ncards, and openedaudio fields.
1173 */
1174 si->numaudios = 0;
1175 bzero((void *)&si->openedaudio, sizeof(si->openedaudio));
1176
1177 if (pcm_devclass != NULL) {
1178 j = 0;
1179
1180 for (i = 0; i < devclass_get_maxunit(pcm_devclass); i++) {
1181 d = devclass_get_softc(pcm_devclass, i);
1182 if (!d)
1183 continue;
1184
1185 /* See note in function's docblock */
1186 mtx_assert(d->lock, MA_NOTOWNED);
1187 /* Increment device's "operations in progress" */
1188 pcm_inprog(d, 1);
1189 pcm_lock(d);
1190
1191 si->numaudios += d->devcount;
1192 ++ncards;
1193
1194 SLIST_FOREACH(sce, &d->channels, link) {
1195 c = sce->channel;
1196 mtx_assert(c->lock, MA_NOTOWNED);
1197 CHN_LOCK(c);
1198 if (c->flags & CHN_F_BUSY)
1199 si->openedaudio[j / intnbits] |=
1200 (1 << (j % intnbits));
1201 CHN_UNLOCK(c);
1202 j++;
1203 }
1204
1205 pcm_unlock(d);
1206 pcm_inprog(d, -1);
1207 }
1208 }
1209
1210 si->numsynths = 0; /* OSSv4 docs: this field is obsolete */
1211 /**
1212 * @todo Collect num{midis,timers}.
1213 *
1214 * Need access to sound/midi/midi.c::midistat_lock in order
1215 * to safely touch midi_devices and get a head count of, well,
1216 * MIDI devices. midistat_lock is a global static (i.e., local to
1217 * midi.c), but midi_devices is a regular global; should the mutex
1218 * be publicized, or is there another way to get this information?
1219 *
1220 * NB: MIDI/sequencer stuff is currently on hold.
1221 */
1222 si->nummidis = 0;
1223 si->numtimers = 0;
1224 si->nummixers = mixer_count;
1225 si->numcards = ncards;
1226 /* OSSv4 docs: Intended only for test apps; API doesn't
1227 really have much of a concept of cards. Shouldn't be
1228 used by applications. */
1229
1230 /**
1231 * @todo Fill in "busy devices" fields.
1232 *
1233 * si->openedmidi = " MIDI devices
1234 */
1235 bzero((void *)&si->openedmidi, sizeof(si->openedmidi));
1236
1237 /*
1238 * Si->filler is a reserved array, but according to docs each
1239 * element should be set to -1.
1240 */
1241 for (i = 0; i < sizeof(si->filler)/sizeof(si->filler[0]); i++)
1242 si->filler[i] = -1;
1243}
1244
1245/************************************************************************/
1246
1129static int
1130sound_modevent(module_t mod, int type, void *data)
1131{
1247static int
1248sound_modevent(module_t mod, int type, void *data)
1249{
1250 int ret;
1132#if 0
1133 return (midi_modevent(mod, type, data));
1134#else
1251#if 0
1252 return (midi_modevent(mod, type, data));
1253#else
1135 return 0;
1254 ret = 0;
1255
1256 switch(type) {
1257 case MOD_LOAD:
1258 pcmsg_unrhdr = new_unrhdr(1, INT_MAX, NULL);
1259 break;
1260 case MOD_UNLOAD:
1261 case MOD_SHUTDOWN:
1262 if (pcmsg_unrhdr != NULL) {
1263 delete_unrhdr(pcmsg_unrhdr);
1264 pcmsg_unrhdr = NULL;
1265 }
1266 break;
1267 default:
1268 ret = EOPNOTSUPP;
1269 }
1270
1271 return ret;
1136#endif
1137}
1138
1139DEV_MODULE(sound, sound_modevent, NULL);
1140MODULE_VERSION(sound, SOUND_MODVER);
1272#endif
1273}
1274
1275DEV_MODULE(sound, sound_modevent, NULL);
1276MODULE_VERSION(sound, SOUND_MODVER);