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 $
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
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
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
120 */
121
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))
131
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
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
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
460#define SND_DEV_DSPHW 11 /* specific channel request */
461
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);
488int pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, int chnum);
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
493struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, 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);
520int sndstat_acquire(void);
521int sndstat_release(void);
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
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 {
565 SLIST_HEAD(, snddev_channel) channels;
566 struct pcm_channel *fakechan;
567 unsigned devcount, playcount, reccount, vchancount;
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;
576
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 ---
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 $
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
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
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
120 */
121
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))
131
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
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
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
460#define SND_DEV_DSPHW 11 /* specific channel request */
461
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);
488int pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, int chnum);
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
493struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, 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);
520int sndstat_acquire(void);
521int sndstat_release(void);
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
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 {
565 SLIST_HEAD(, snddev_channel) channels;
566 struct pcm_channel *fakechan;
567 unsigned devcount, playcount, reccount, vchancount;
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;
576
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 ---