Deleted Added
full compact
sound.h (169319) sound.h (170161)
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * Copyright by Hannu Savolainen 1995
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:

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

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 *
1/*-
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
3 * Copyright by Hannu Savolainen 1995
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:

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

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * $FreeBSD: head/sys/dev/sound/pcm/sound.h 169319 2007-05-06 16:46:23Z ariff $
27 * $FreeBSD: head/sys/dev/sound/pcm/sound.h 170161 2007-05-31 18:43:33Z ariff $
28 */
29
30/*
31 * first, include kernel header files.
32 */
33
34#ifndef _OS_H_
35#define _OS_H_

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

90struct snd_dbuf;
91struct snd_mixer;
92
93#include <dev/sound/pcm/buffer.h>
94#include <dev/sound/pcm/channel.h>
95#include <dev/sound/pcm/feeder.h>
96#include <dev/sound/pcm/mixer.h>
97#include <dev/sound/pcm/dsp.h>
28 */
29
30/*
31 * first, include kernel header files.
32 */
33
34#ifndef _OS_H_
35#define _OS_H_

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

90struct snd_dbuf;
91struct snd_mixer;
92
93#include <dev/sound/pcm/buffer.h>
94#include <dev/sound/pcm/channel.h>
95#include <dev/sound/pcm/feeder.h>
96#include <dev/sound/pcm/mixer.h>
97#include <dev/sound/pcm/dsp.h>
98#include <dev/sound/clone.h>
99#include <dev/sound/unit.h>
98
99#define PCM_SOFTC_SIZE 512
100
101#define SND_STATUSLEN 64
102
103#define SOUND_MODVER 2
104
105#define SOUND_MINVER SOUND_MODVER
106#define SOUND_PREFVER SOUND_MODVER
107#define SOUND_MAXVER SOUND_MODVER
108
109/*
110 * We're abusing the fact that MAXMINOR still have enough room
100
101#define PCM_SOFTC_SIZE 512
102
103#define SND_STATUSLEN 64
104
105#define SOUND_MODVER 2
106
107#define SOUND_MINVER SOUND_MODVER
108#define SOUND_PREFVER SOUND_MODVER
109#define SOUND_MAXVER SOUND_MODVER
110
111/*
112 * We're abusing the fact that MAXMINOR still have enough room
111 * for our bit twiddling and nobody ever need 2048 unique soundcards,
112 * 32 unique device types and 256 unique cloneable devices for the
113 * next 100 years... or until the NextPCM.
114 *
115 * MAXMINOR 0xffff00ff
116 * | |
117 * | +--- PCMMAXCHAN
118 * |
119 * +-------- ((PCMMAXUNIT << 5) | PCMMAXDEV) << 16
113 * for our bit twiddling and nobody ever need 512 unique soundcards,
114 * 32 unique device types and 1024 unique cloneable devices for the
115 * next 100 years...
120 */
121
116 */
117
122#define PCMMAXCHAN 0xff
123#define PCMMAXDEV 0x1f
124#define PCMMAXUNIT 0x7ff
125#define PCMMINOR(x) minor(x)
126#define PCMCHAN(x) (PCMMINOR(x) & PCMMAXCHAN)
127#define PCMUNIT(x) ((PCMMINOR(x) >> 21) & PCMMAXUNIT)
128#define PCMDEV(x) ((PCMMINOR(x) >> 16) & PCMMAXDEV)
129#define PCMMKMINOR(u, d, c) ((((u) & PCMMAXUNIT) << 21) | \
130 (((d) & PCMMAXDEV) << 16) | ((c) & PCMMAXCHAN))
118#define PCMMAXUNIT (snd_max_u())
119#define PCMMAXDEV (snd_max_d())
120#define PCMMAXCHAN (snd_max_c())
131
121
122#define PCMMAXCLONE PCMMAXCHAN
123
124#define PCMUNIT(x) (snd_unit2u(dev2unit(x)))
125#define PCMDEV(x) (snd_unit2d(dev2unit(x)))
126#define PCMCHAN(x) (snd_unit2c(dev2unit(x)))
127
128/*
129 * By design, limit possible channels for each direction.
130 */
131#define SND_MAXHWCHAN 256
132#define SND_MAXVCHANS SND_MAXHWCHAN
133
132#define SD_F_SIMPLEX 0x00000001
133#define SD_F_AUTOVCHAN 0x00000002
134#define SD_F_SOFTPCMVOL 0x00000004
135#define SD_F_PSWAPLR 0x00000008
136#define SD_F_RSWAPLR 0x00000010
134#define SD_F_SIMPLEX 0x00000001
135#define SD_F_AUTOVCHAN 0x00000002
136#define SD_F_SOFTPCMVOL 0x00000004
137#define SD_F_PSWAPLR 0x00000008
138#define SD_F_RSWAPLR 0x00000010
139#define SD_F_DYING 0x00000020
140#define SD_F_SUICIDE 0x00000040
137#define SD_F_PRIO_RD 0x10000000
138#define SD_F_PRIO_WR 0x20000000
139#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR)
140#define SD_F_DIR_SET 0x40000000
141#define SD_F_TRANSIENT 0xf0000000
142
143/* many variables should be reduced to a range. Here define a macro */
144#define RANGE(var, low, high) (var) = \

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

428#define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
429 AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
430#define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
431 AFMT_S16_BE | AFMT_U16_BE)
432
433struct pcm_channel *fkchan_setup(device_t dev);
434int fkchan_kill(struct pcm_channel *c);
435
141#define SD_F_PRIO_RD 0x10000000
142#define SD_F_PRIO_WR 0x20000000
143#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR)
144#define SD_F_DIR_SET 0x40000000
145#define SD_F_TRANSIENT 0xf0000000
146
147/* many variables should be reduced to a range. Here define a macro */
148#define RANGE(var, low, high) (var) = \

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

432#define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
433 AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
434#define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
435 AFMT_S16_BE | AFMT_U16_BE)
436
437struct pcm_channel *fkchan_setup(device_t dev);
438int fkchan_kill(struct pcm_channel *c);
439
436/* XXX Flawed definition. I'll fix it someday. */
437#define SND_MAXVCHANS PCMMAXCHAN
438
439/*
440 * Minor numbers for the sound driver.
441 *
442 * Unfortunately Creative called the codec chip of SB as a DSP. For this
443 * reason the /dev/dsp is reserved for digitized audio use. There is a
444 * device for true DSP processors but it will be called something else.
445 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
446 */

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

452#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
453#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
454#define SND_DEV_STATUS 6 /* /dev/sndstat */
455 /* #7 not in use now. */
456#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
457#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
458#define SND_DEV_PSS SND_DEV_SNDPROC /* ? */
459#define SND_DEV_NORESET 10
440/*
441 * Minor numbers for the sound driver.
442 *
443 * Unfortunately Creative called the codec chip of SB as a DSP. For this
444 * reason the /dev/dsp is reserved for digitized audio use. There is a
445 * device for true DSP processors but it will be called something else.
446 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
447 */

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

453#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
454#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
455#define SND_DEV_STATUS 6 /* /dev/sndstat */
456 /* #7 not in use now. */
457#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
458#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
459#define SND_DEV_PSS SND_DEV_SNDPROC /* ? */
460#define SND_DEV_NORESET 10
460#define SND_DEV_DSPHW 11 /* specific channel request */
461
461
462#define SND_DEV_DSPHW_PLAY 11 /* specific playback channel */
463#define SND_DEV_DSPHW_VPLAY 12 /* specific virtual playback channel */
464#define SND_DEV_DSPHW_REC 13 /* specific record channel */
465#define SND_DEV_DSPHW_VREC 14 /* specific virtual record channel */
466
462#define DSP_DEFAULT_SPEED 8000
463
464#define ON 1
465#define OFF 0
466
467extern int pcm_veto_load;
468extern int snd_unit;
469extern int snd_maxautovchans;

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

480
481#ifndef DEB
482#define DEB(x)
483#endif
484
485SYSCTL_DECL(_hw_snd);
486
487struct pcm_channel *pcm_getfakechan(struct snddev_info *d);
467#define DSP_DEFAULT_SPEED 8000
468
469#define ON 1
470#define OFF 0
471
472extern int pcm_veto_load;
473extern int snd_unit;
474extern int snd_maxautovchans;

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

485
486#ifndef DEB
487#define DEB(x)
488#endif
489
490SYSCTL_DECL(_hw_snd);
491
492struct pcm_channel *pcm_getfakechan(struct snddev_info *d);
488int pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, int chnum);
493int pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, int devunit);
489int pcm_chnrelease(struct pcm_channel *c);
490int pcm_chnref(struct pcm_channel *c, int ref);
491int pcm_inprog(struct snddev_info *d, int delta);
492
494int pcm_chnrelease(struct pcm_channel *c);
495int pcm_chnref(struct pcm_channel *c, int ref);
496int pcm_inprog(struct snddev_info *d, int delta);
497
493struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo);
498struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, int num, void *devinfo);
494int pcm_chn_destroy(struct pcm_channel *ch);
495int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch);
496int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch);
497
498int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo);
499unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz);
500int pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
501int pcm_unregister(device_t dev);

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

512void snd_mtxfree(void *m);
513void snd_mtxassert(void *m);
514#define snd_mtxlock(m) mtx_lock(m)
515#define snd_mtxunlock(m) mtx_unlock(m)
516
517int sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS);
518
519typedef int (*sndstat_handler)(struct sbuf *s, device_t dev, int verbose);
499int pcm_chn_destroy(struct pcm_channel *ch);
500int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch);
501int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch);
502
503int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo);
504unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz);
505int pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
506int pcm_unregister(device_t dev);

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

517void snd_mtxfree(void *m);
518void snd_mtxassert(void *m);
519#define snd_mtxlock(m) mtx_lock(m)
520#define snd_mtxunlock(m) mtx_unlock(m)
521
522int sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS);
523
524typedef int (*sndstat_handler)(struct sbuf *s, device_t dev, int verbose);
520int sndstat_acquire(void);
521int sndstat_release(void);
525int sndstat_acquire(struct thread *td);
526int sndstat_release(struct thread *td);
522int sndstat_register(device_t dev, char *str, sndstat_handler handler);
523int sndstat_registerfile(char *str);
524int sndstat_unregister(device_t dev);
525int sndstat_unregisterfile(char *str);
526
527#define SND_DECLARE_FILE(version) \
528 _SND_DECLARE_FILE(__LINE__, version)
529

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

546#define PCM_DEBUG_MTX
547
548/*
549 * this is rather kludgey- we need to duplicate these struct def'ns from sound.c
550 * so that the macro versions of pcm_{,un}lock can dereference them.
551 * we also have to do this now makedev() has gone away.
552 */
553
527int sndstat_register(device_t dev, char *str, sndstat_handler handler);
528int sndstat_registerfile(char *str);
529int sndstat_unregister(device_t dev);
530int sndstat_unregisterfile(char *str);
531
532#define SND_DECLARE_FILE(version) \
533 _SND_DECLARE_FILE(__LINE__, version)
534

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

551#define PCM_DEBUG_MTX
552
553/*
554 * this is rather kludgey- we need to duplicate these struct def'ns from sound.c
555 * so that the macro versions of pcm_{,un}lock can dereference them.
556 * we also have to do this now makedev() has gone away.
557 */
558
554struct snddev_channel {
555 SLIST_ENTRY(snddev_channel) link;
556 struct pcm_channel *channel;
557 int chan_num;
558 struct cdev *dsp_devt;
559 struct cdev *dspW_devt;
560 struct cdev *audio_devt;
561 struct cdev *dspHW_devt;
562};
563
564struct snddev_info {
559struct snddev_info {
565 SLIST_HEAD(, snddev_channel) channels;
560 struct {
561 struct {
562 SLIST_HEAD(, pcm_channel) head;
563 struct {
564 SLIST_HEAD(, pcm_channel) head;
565 } busy;
566 } pcm;
567 } channels;
568 struct snd_clone *clones;
566 struct pcm_channel *fakechan;
569 struct pcm_channel *fakechan;
567 unsigned devcount, playcount, reccount, vchancount;
570 unsigned devcount, playcount, reccount, pvchancount, rvchancount ;
568 unsigned flags;
569 int inprog;
570 unsigned int bufsz;
571 void *devinfo;
572 device_t dev;
573 char status[SND_STATUSLEN];
574 struct mtx *lock;
575 struct cdev *mixer_dev;
571 unsigned flags;
572 int inprog;
573 unsigned int bufsz;
574 void *devinfo;
575 device_t dev;
576 char status[SND_STATUSLEN];
577 struct mtx *lock;
578 struct cdev *mixer_dev;
576
579 uint32_t pvchanrate, pvchanformat;
580 uint32_t rvchanrate, rvchanformat;
581 struct sysctl_ctx_list play_sysctl_ctx, rec_sysctl_ctx;
582 struct sysctl_oid *play_sysctl_tree, *rec_sysctl_tree;
577};
578
579void sound_oss_sysinfo(oss_sysinfo *);
580
581#ifdef PCM_DEBUG_MTX
582#define pcm_lock(d) mtx_lock(((struct snddev_info *)(d))->lock)
583#define pcm_unlock(d) mtx_unlock(((struct snddev_info *)(d))->lock)
584#else

--- 13 unchanged lines hidden ---
583};
584
585void sound_oss_sysinfo(oss_sysinfo *);
586
587#ifdef PCM_DEBUG_MTX
588#define pcm_lock(d) mtx_lock(((struct snddev_info *)(d))->lock)
589#define pcm_unlock(d) mtx_unlock(((struct snddev_info *)(d))->lock)
590#else

--- 13 unchanged lines hidden ---