2 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
3 * Copyright (c) 1999 Cameron Grant <cg@FreeBSD.org>
4 * Copyright (c) 1995 Hannu Savolainen
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * $FreeBSD: head/sys/dev/sound/pcm/sound.h 274035 2014-11-03 11:11:45Z bapt $
32 * first, include kernel header files.
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/ioccom.h>
42 #include <sys/filio.h>
43 #include <sys/sockio.h>
44 #include <sys/fcntl.h>
46 #include <sys/kernel.h> /* for DATA_SET */
47 #include <sys/module.h>
51 #include <sys/syslog.h>
52 #include <sys/errno.h>
53 #include <sys/malloc.h>
56 #include <sys/limits.h>
60 #include <sys/soundcard.h>
61 #include <sys/sysctl.h>
67 #include <sys/mplock2.h>
68 #include <sys/mutex.h>
69 #include <sys/condvar.h>
70 #include <sys/taskqueue.h>
72 #ifndef KOBJMETHOD_END
73 #define KOBJMETHOD_END { NULL, NULL }
81 #include <dev/sound/pcm/buffer.h>
82 #include <dev/sound/pcm/matrix.h>
83 #include <dev/sound/pcm/matrix_map.h>
84 #include <dev/sound/pcm/channel.h>
85 #include <dev/sound/pcm/feeder.h>
86 #include <dev/sound/pcm/mixer.h>
87 #include <dev/sound/pcm/dsp.h>
88 #include <dev/sound/clone.h>
89 #include <dev/sound/unit.h>
91 #define PCM_SOFTC_SIZE (sizeof(struct snddev_info))
93 #define SND_STATUSLEN 64
95 #define SOUND_MODVER 5
97 #define SOUND_MINVER SOUND_MODVER
98 #define SOUND_PREFVER SOUND_MODVER
99 #define SOUND_MAXVER SOUND_MODVER
102 * Minor number encoding: 0xFFFF00FF
108 #define SND_U_MASK 0x000000FF
109 #define SND_C_MASK 0x07FF0000
110 #define SND_D_MASK 0xF8000000
112 #define PCMMAXUNIT 255
114 #define PCMMAXCHAN 2047
115 #define PCMMAXCLONE PCMMAXCHAN
120 #define PCMUNIT(x) (minor(x) & 0x00FF)
121 #define PCMSUBUNIT(x) ((minor(x) >> 16) & 0x07FF)
122 #define PCMDEV(x) ((minor(x) >> 27) & 0x001F)
124 #define PCMUNIT_DEFAULT 0x00FF
126 #define PCMMKMINOR(u, d, sub) (snd_u2unit(u) | snd_c2unit(sub) | snd_d2unit(d))
128 #define snd_unit2u(m) ((m) & 0x00FF)
129 #define snd_unit2c(m) (((m) >> 16) & 0x07FF)
130 #define snd_unit2d(m) (((m) >> 27) & 0x001F)
132 #define snd_u2unit(u) ((u) & 0x00FF)
133 #define snd_c2unit(c) (((c) & 0x07FF) << 16)
134 #define snd_d2unit(d) (((d) & 0x001F) << 27)
136 #define snd_mkunit(u, d, c) (snd_u2unit(u) | snd_d2unit(d) | snd_c2unit(c))
139 * By design, limit possible channels for each direction.
141 #define SND_MAXHWCHAN 256
142 #define SND_MAXVCHANS SND_MAXHWCHAN
144 #define SD_F_SIMPLEX 0x00000001
145 #define SD_F_AUTOVCHAN 0x00000002
146 #define SD_F_SOFTPCMVOL 0x00000004
148 * Obsolete due to better matrixing
151 #define SD_F_PSWAPLR 0x00000008
152 #define SD_F_RSWAPLR 0x00000010
154 #define SD_F_DYING 0x00000008
155 #define SD_F_SUICIDE 0x00000010
156 #define SD_F_BUSY 0x00000020
157 #define SD_F_MPSAFE 0x00000040
158 #define SD_F_REGISTERED 0x00000080
159 #define SD_F_BITPERFECT 0x00000100
160 #define SD_F_VPC 0x00000200 /* volume-per-channel */
161 #define SD_F_EQ 0x00000400 /* EQ */
162 #define SD_F_EQ_ENABLED 0x00000800 /* EQ enabled */
163 #define SD_F_EQ_BYPASSED 0x00001000 /* EQ bypassed */
164 #define SD_F_EQ_PC 0x00002000 /* EQ per-channel */
166 #define SD_F_EQ_DEFAULT (SD_F_EQ | SD_F_EQ_ENABLED)
167 #define SD_F_EQ_MASK (SD_F_EQ | SD_F_EQ_ENABLED | \
168 SD_F_EQ_BYPASSED | SD_F_EQ_PC)
170 #define SD_F_PRIO_RD 0x10000000
171 #define SD_F_PRIO_WR 0x20000000
172 #define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR)
173 #define SD_F_DIR_SET 0x40000000
174 #define SD_F_TRANSIENT 0xf0000000
176 #define SD_F_BITS "\020" \
195 #define PCM_ALIVE(x) ((x) != NULL && (x)->lock != NULL && \
196 !((x)->flags & SD_F_DYING))
197 #define PCM_REGISTERED(x) (PCM_ALIVE(x) && \
198 ((x)->flags & SD_F_REGISTERED))
200 /* many variables should be reduced to a range. Here define a macro */
201 #define RANGE(var, low, high) (var) = \
202 (((var)<(low))? (low) : ((var)>(high))? (high) : (var))
203 #define DSP_BUFFSIZE (8192)
205 /* make figuring out what a format is easier. got AFMT_STEREO already */
206 #define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
207 #define AFMT_24BIT (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE)
208 #define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
209 #define AFMT_G711 (AFMT_MU_LAW | AFMT_A_LAW)
210 #define AFMT_8BIT (AFMT_G711 | AFMT_U8 | AFMT_S8)
211 #define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
212 AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
213 #define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
214 AFMT_S16_BE | AFMT_U16_BE)
216 #define AFMT_CONVERTIBLE (AFMT_8BIT | AFMT_16BIT | AFMT_24BIT | \
219 /* Supported vchan mixing formats */
220 #define AFMT_VCHAN (AFMT_CONVERTIBLE & ~AFMT_G711)
222 #define AFMT_PASSTHROUGH AFMT_AC3
223 #define AFMT_PASSTHROUGH_RATE 48000
224 #define AFMT_PASSTHROUGH_CHANNEL 2
225 #define AFMT_PASSTHROUGH_EXTCHANNEL 0
228 * We're simply using unused, contiguous bits from various AFMT_ definitions.
231 #define AFMT_ENCODING_MASK 0xf00fffff
232 #define AFMT_CHANNEL_MASK 0x01f00000
233 #define AFMT_CHANNEL_SHIFT 20
234 #define AFMT_EXTCHANNEL_MASK 0x0e000000
235 #define AFMT_EXTCHANNEL_SHIFT 25
237 #define AFMT_ENCODING(v) ((v) & AFMT_ENCODING_MASK)
239 #define AFMT_EXTCHANNEL(v) (((v) & AFMT_EXTCHANNEL_MASK) >> \
240 AFMT_EXTCHANNEL_SHIFT)
242 #define AFMT_CHANNEL(v) (((v) & AFMT_CHANNEL_MASK) >> \
245 #define AFMT_BIT(v) (((v) & AFMT_32BIT) ? 32 : \
246 (((v) & AFMT_24BIT) ? 24 : \
247 ((((v) & AFMT_16BIT) || \
248 ((v) & AFMT_PASSTHROUGH)) ? 16 : 8)))
250 #define AFMT_BPS(v) (AFMT_BIT(v) >> 3)
251 #define AFMT_ALIGN(v) (AFMT_BPS(v) * AFMT_CHANNEL(v))
253 #define SND_FORMAT(f, c, e) (AFMT_ENCODING(f) | \
254 (((c) << AFMT_CHANNEL_SHIFT) & \
255 AFMT_CHANNEL_MASK) | \
256 (((e) << AFMT_EXTCHANNEL_SHIFT) & \
257 AFMT_EXTCHANNEL_MASK))
259 #define AFMT_U8_NE AFMT_U8
260 #define AFMT_S8_NE AFMT_S8
262 #define AFMT_SIGNED_NE (AFMT_S8_NE | AFMT_S16_NE | AFMT_S24_NE | AFMT_S32_NE)
264 #define AFMT_NE (AFMT_SIGNED_NE | AFMT_U8_NE | AFMT_U16_NE | \
265 AFMT_U24_NE | AFMT_U32_NE)
268 * Minor numbers for the sound driver.
270 * Unfortunately Creative called the codec chip of SB as a DSP. For this
271 * reason the /dev/dsp is reserved for digitized audio use. There is a
272 * device for true DSP processors but it will be called something else.
273 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
276 #define SND_DEV_CTL 0 /* Control port /dev/mixer */
277 #define SND_DEV_SEQ 1 /* Sequencer /dev/sequencer */
278 #define SND_DEV_MIDIN 2 /* Raw midi access */
279 #define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
280 #define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
281 #define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
282 #define SND_DEV_STATUS 6 /* /dev/sndstat */
283 /* #7 not in use now. */
284 #define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
285 #define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
286 #define SND_DEV_PSS SND_DEV_SNDPROC /* ? */
287 #define SND_DEV_NORESET 10
289 #define SND_DEV_DSPHW_PLAY 11 /* specific playback channel */
290 #define SND_DEV_DSPHW_VPLAY 12 /* specific virtual playback channel */
291 #define SND_DEV_DSPHW_REC 13 /* specific record channel */
292 #define SND_DEV_DSPHW_VREC 14 /* specific virtual record channel */
294 #define SND_DEV_DSPHW_CD 15 /* s16le/stereo 44100Hz CD */
297 * OSSv4 compatible device. For now, it serve no purpose and
298 * the cloning itself will forward the request to ordinary /dev/dsp
301 #define SND_DEV_DSP_MMAP 16 /* /dev/dsp_mmap */
302 #define SND_DEV_DSP_AC3 17 /* /dev/dsp_ac3 */
303 #define SND_DEV_DSP_MULTICH 18 /* /dev/dsp_multich */
304 #define SND_DEV_DSP_SPDIFOUT 19 /* /dev/dsp_spdifout */
305 #define SND_DEV_DSP_SPDIFIN 20 /* /dev/dsp_spdifin */
307 #define SND_DEV_LAST SND_DEV_DSP_SPDIFIN
308 #define SND_DEV_MAX PCMMAXDEV
310 #define DSP_DEFAULT_SPEED 8000
315 extern int pcm_veto_load
;
317 extern int snd_maxautovchans
;
318 extern int snd_verbose
;
319 extern devclass_t pcm_devclass
;
320 extern struct unrhdr
*pcmsg_unrhdr
;
323 * some macros for debugging purposes
324 * DDB/DEB to enable/disable debugging stuff
325 * BVDDB to enable debugging when bootverbose
327 #define BVDDB(x) if (bootverbose) x
333 SYSCTL_DECL(_hw_snd
);
335 int pcm_setvchans(struct snddev_info
*d
, int direction
, int newcnt
, int num
);
336 int pcm_chnalloc(struct snddev_info
*d
, struct pcm_channel
**ch
, int direction
,
337 pid_t pid
, char *comm
, int devunit
);
338 int pcm_chnrelease(struct pcm_channel
*c
);
339 int pcm_chnref(struct pcm_channel
*c
, int ref
);
340 int pcm_inprog(struct snddev_info
*d
, int delta
);
342 struct pcm_channel
*pcm_chn_create(struct snddev_info
*d
, struct pcm_channel
*parent
, kobj_class_t cls
, int dir
, int num
, void *devinfo
);
343 int pcm_chn_destroy(struct pcm_channel
*ch
);
344 int pcm_chn_add(struct snddev_info
*d
, struct pcm_channel
*ch
);
345 int pcm_chn_remove(struct snddev_info
*d
, struct pcm_channel
*ch
);
347 int pcm_addchan(device_t dev
, int dir
, kobj_class_t cls
, void *devinfo
);
348 unsigned int pcm_getbuffersize(device_t dev
, unsigned int minbufsz
, unsigned int deflt
, unsigned int maxbufsz
);
349 int pcm_register(device_t dev
, void *devinfo
, int numplay
, int numrec
);
350 int pcm_unregister(device_t dev
);
351 int pcm_setstatus(device_t dev
, char *str
);
352 u_int32_t
pcm_getflags(device_t dev
);
353 void pcm_setflags(device_t dev
, u_int32_t val
);
354 void *pcm_getdevinfo(device_t dev
);
357 int snd_setup_intr(device_t dev
, struct resource
*res
, int flags
,
358 driver_intr_t hand
, void *param
, void **cookiep
);
360 void *snd_mtxcreate(const char *desc
, const char *type
);
361 void snd_mtxfree(void *m
);
362 void snd_mtxassert(void *m
);
363 #define snd_mtxlock(m) lockmgr(m, LK_EXCLUSIVE)
364 #define snd_mtxunlock(m) lockmgr(m, LK_RELEASE)
366 typedef int (*sndstat_handler
)(struct sbuf
*s
, device_t dev
, int verbose
);
367 int sndstat_acquire(struct thread
*td
);
368 int sndstat_release(struct thread
*td
);
369 int sndstat_register(device_t dev
, char *str
, sndstat_handler handler
);
370 int sndstat_registerfile(char *str
);
371 int sndstat_unregister(device_t dev
);
372 int sndstat_unregisterfile(char *str
);
374 #define SND_DECLARE_FILE(version) \
375 _SND_DECLARE_FILE(__LINE__, version)
377 #define _SND_DECLARE_FILE(uniq, version) \
378 __SND_DECLARE_FILE(uniq, version)
380 #define __SND_DECLARE_FILE(uniq, version) \
381 static char sndstat_vinfo[] = version; \
382 SYSINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_registerfile, sndstat_vinfo); \
383 SYSUNINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_unregisterfile, sndstat_vinfo);
385 /* usage of flags in device config entry (config file) */
386 #define DV_F_DRQ_MASK 0x00000007 /* mask for secondary drq */
387 #define DV_F_DUAL_DMA 0x00000010 /* set to use secondary dma channel */
389 /* ought to be made obsolete but still used by mss */
390 #define DV_F_DEV_MASK 0x0000ff00 /* force device type/class */
391 #define DV_F_DEV_SHIFT 8 /* force device type/class */
394 * this is rather kludgey- we need to duplicate these struct def'ns from sound.c
395 * so that the macro versions of pcm_{,un}lock can dereference them.
396 * we also have to do this now makedev() has gone away.
402 SLIST_HEAD(, pcm_channel
) head
;
404 SLIST_HEAD(, pcm_channel
) head
;
407 SLIST_HEAD(, pcm_channel
) head
;
411 TAILQ_HEAD(dsp_cdevinfo_linkhead
, dsp_cdevinfo
) dsp_cdevinfo_pool
;
412 struct snd_clone
*clones
;
413 unsigned devcount
, playcount
, reccount
, pvchancount
, rvchancount
;
419 char status
[SND_STATUSLEN
];
421 struct cdev
*mixer_dev
;
422 struct cdev
*dsp_clonedev
;
423 uint32_t pvchanrate
, pvchanformat
;
424 uint32_t rvchanrate
, rvchanformat
;
426 struct sysctl_ctx_list play_sysctl_ctx
, rec_sysctl_ctx
;
427 struct sysctl_oid
*play_sysctl_tree
, *rec_sysctl_tree
;
431 void sound_oss_sysinfo(oss_sysinfo
*);
432 int sound_oss_card_info(oss_card_info
*);
434 #define PCM_LOCKOWNED(d) (lockstatus((d)->lock, curthread) == LK_EXCLUSIVE)
435 #define PCM_LOCK(d) lockmgr((d)->lock, LK_EXCLUSIVE)
436 #define PCM_UNLOCK(d) lockmgr((d)->lock, LK_RELEASE)
437 #define PCM_TRYLOCK(d) lockmgr((d)->lock, LK_EXCLUSIVE|LK_NOWAIT)
438 #define PCM_LOCKASSERT(d) KKASSERT(lockstatus((d)->lock, curthread) == LK_EXCLUSIVE)
439 #define PCM_UNLOCKASSERT(d) KKASSERT(lockstatus((d)->lock, curthread) != LK_EXCLUSIVE)
442 * For PCM_[WAIT | ACQUIRE | RELEASE], be sure to surround these
443 * with PCM_LOCK/UNLOCK() sequence, or I'll come to gnaw upon you!
445 #ifdef SND_DIAGNOSTIC
446 #define PCM_WAIT(x) do { \
447 if (!PCM_LOCKOWNED(x)) \
448 panic("%s(%d): [PCM WAIT] Mutex not owned!", \
449 __func__, __LINE__); \
450 while ((x)->flags & SD_F_BUSY) { \
451 if (snd_verbose > 3) \
452 device_printf((x)->dev, \
453 "%s(%d): [PCM WAIT] calling cv_wait().\n", \
454 __func__, __LINE__); \
455 cv_wait(&(x)->cv, (x)->lock); \
459 #define PCM_ACQUIRE(x) do { \
460 if (!PCM_LOCKOWNED(x)) \
461 panic("%s(%d): [PCM ACQUIRE] Mutex not owned!", \
462 __func__, __LINE__); \
463 if ((x)->flags & SD_F_BUSY) \
464 panic("%s(%d): [PCM ACQUIRE] " \
465 "Trying to acquire BUSY cv!", __func__, __LINE__); \
466 (x)->flags |= SD_F_BUSY; \
469 #define PCM_RELEASE(x) do { \
470 if (!PCM_LOCKOWNED(x)) \
471 panic("%s(%d): [PCM RELEASE] Mutex not owned!", \
472 __func__, __LINE__); \
473 if ((x)->flags & SD_F_BUSY) { \
474 (x)->flags &= ~SD_F_BUSY; \
475 if ((x)->cv.cv_waiters != 0) { \
476 if ((x)->cv.cv_waiters > 1 && snd_verbose > 3) \
477 device_printf((x)->dev, \
478 "%s(%d): [PCM RELEASE] " \
479 "cv_waiters=%d > 1!\n", \
480 __func__, __LINE__, \
481 (x)->cv.cv_waiters); \
482 cv_broadcast(&(x)->cv); \
485 panic("%s(%d): [PCM RELEASE] Releasing non-BUSY cv!", \
486 __func__, __LINE__); \
489 /* Quick version, for shorter path. */
490 #define PCM_ACQUIRE_QUICK(x) do { \
491 if (PCM_LOCKOWNED(x)) \
492 panic("%s(%d): [PCM ACQUIRE QUICK] Mutex owned!", \
493 __func__, __LINE__); \
500 #define PCM_RELEASE_QUICK(x) do { \
501 if (PCM_LOCKOWNED(x)) \
502 panic("%s(%d): [PCM RELEASE QUICK] Mutex owned!", \
503 __func__, __LINE__); \
509 #define PCM_BUSYASSERT(x) do { \
510 if (!((x) != NULL && ((x)->flags & SD_F_BUSY))) \
511 panic("%s(%d): [PCM BUSYASSERT] " \
512 "Failed, snddev_info=%p", __func__, __LINE__, x); \
515 #define PCM_GIANT_ENTER(x) do { \
516 int _pcm_giant = 0; \
517 if (PCM_LOCKOWNED(x)) \
518 panic("%s(%d): [GIANT ENTER] PCM lock owned!", \
519 __func__, __LINE__); \
520 if (mtx_owned(&Giant) != 0 && snd_verbose > 3) \
521 device_printf((x)->dev, \
522 "%s(%d): [GIANT ENTER] Giant owned!\n", \
523 __func__, __LINE__); \
524 if (!((x)->flags & SD_F_MPSAFE) && mtx_owned(&Giant) == 0) \
530 #define PCM_GIANT_EXIT(x) do { \
531 if (PCM_LOCKOWNED(x)) \
532 panic("%s(%d): [GIANT EXIT] PCM lock owned!", \
533 __func__, __LINE__); \
534 if (!(_pcm_giant == 0 || _pcm_giant == 1)) \
535 panic("%s(%d): [GIANT EXIT] _pcm_giant screwed!", \
536 __func__, __LINE__); \
537 if ((x)->flags & SD_F_MPSAFE) { \
538 if (_pcm_giant == 1) \
539 panic("%s(%d): [GIANT EXIT] MPSAFE Giant?", \
540 __func__, __LINE__); \
541 if (mtx_owned(&Giant) != 0 && snd_verbose > 3) \
542 device_printf((x)->dev, \
543 "%s(%d): [GIANT EXIT] Giant owned!\n", \
544 __func__, __LINE__); \
546 if (_pcm_giant != 0) { \
547 if (mtx_owned(&Giant) == 0) \
548 panic("%s(%d): [GIANT EXIT] Giant not owned!", \
549 __func__, __LINE__); \
551 mtx_unlock(&Giant); \
554 #else /* SND_DIAGNOSTIC */
555 #define PCM_WAIT(x) do { \
557 while ((x)->flags & SD_F_BUSY) \
558 cv_wait(&(x)->cv, (x)->lock); \
561 #define PCM_ACQUIRE(x) do { \
563 KASSERT(!((x)->flags & SD_F_BUSY), \
564 ("%s(%d): [PCM ACQUIRE] Trying to acquire BUSY cv!", \
565 __func__, __LINE__)); \
566 (x)->flags |= SD_F_BUSY; \
569 #define PCM_RELEASE(x) do { \
571 KASSERT((x)->flags & SD_F_BUSY, \
572 ("%s(%d): [PCM RELEASE] Releasing non-BUSY cv!", \
573 __func__, __LINE__)); \
574 (x)->flags &= ~SD_F_BUSY; \
575 if ((x)->cv.cv_waiters != 0) \
576 cv_broadcast(&(x)->cv); \
579 /* Quick version, for shorter path. */
580 #define PCM_ACQUIRE_QUICK(x) do { \
581 PCM_UNLOCKASSERT(x); \
588 #define PCM_RELEASE_QUICK(x) do { \
589 PCM_UNLOCKASSERT(x); \
595 #define PCM_BUSYASSERT(x) KASSERT(x != NULL && \
596 ((x)->flags & SD_F_BUSY), \
597 ("%s(%d): [PCM BUSYASSERT] " \
598 "Failed, snddev_info=%p", \
599 __func__, __LINE__, x))
601 #define PCM_GIANT_ENTER(x) do { \
602 if (!((x)->flags & SD_F_MPSAFE)) \
606 #define PCM_GIANT_EXIT(x) do { \
607 if (!((x)->flags & SD_F_MPSAFE)) \
610 #endif /* !SND_DIAGNOSTIC */
612 #define PCM_GIANT_LEAVE(x) PCM_GIANT_EXIT(x)
615 #define PCM_KLDSTRING(a) ("kld " # a)
617 #define PCM_KLDSTRING(a) ""