The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/sound/pcm/sound.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    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:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   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: src/sys/dev/sound/pcm/sound.h,v 1.63.2.3 2007/05/13 20:53:39 ariff Exp $
   28  */
   29 
   30 /*
   31  * first, include kernel header files.
   32  */
   33 
   34 #ifndef _OS_H_
   35 #define _OS_H_
   36 
   37 #ifdef _KERNEL
   38 #include <sys/param.h>
   39 #include <sys/systm.h>
   40 #include <sys/filio.h>
   41 #include <sys/sockio.h>
   42 #include <sys/fcntl.h>
   43 #include <sys/tty.h>
   44 #include <sys/proc.h>
   45 #include <sys/kernel.h> /* for DATA_SET */
   46 #include <sys/module.h>
   47 #include <sys/conf.h>
   48 #include <sys/file.h>
   49 #include <sys/uio.h>
   50 #include <sys/syslog.h>
   51 #include <sys/errno.h>
   52 #include <sys/malloc.h>
   53 #include <sys/bus.h>
   54 #include <sys/buf.h>
   55 #include <machine/clock.h>      /* for DELAY */
   56 #include <sys/resource.h>
   57 #include <sys/rman.h>
   58 #include <sys/mman.h>
   59 #include <sys/poll.h>
   60 #include <sys/sbuf.h>
   61 #include <sys/soundcard.h>
   62 #include <sys/sysctl.h>
   63 #include <sys/kobj.h>
   64 #include <sys/thread2.h>
   65 #include <sys/taskqueue.h>
   66 
   67 #include <vm/vm.h>
   68 #include <vm/pmap.h>
   69 
   70 #undef  USING_MUTEX
   71 #undef  USING_DEVFS
   72 
   73 #include <sys/lock.h>           /* lockmgr locks */
   74 typedef struct lock *sndlock_t; /* opaque lock structure */
   75 
   76 #define USING_MUTEX
   77 #define INTR_TYPE_AV    0
   78 
   79 #define SND_DYNSYSCTL
   80 
   81 struct pcm_channel;
   82 struct pcm_feeder;
   83 struct snd_dbuf;
   84 struct snd_mixer;
   85 
   86 #include <dev/sound/pcm/buffer.h>
   87 #include <dev/sound/pcm/channel.h>
   88 #include <dev/sound/pcm/feeder.h>
   89 #include <dev/sound/pcm/mixer.h>
   90 
   91 #define PCM_SOFTC_SIZE  512
   92 
   93 #define SND_STATUSLEN   64
   94 
   95 #define SOUND_MODVER    1
   96 
   97 #define SOUND_MINVER    1
   98 #define SOUND_PREFVER   SOUND_MODVER
   99 #define SOUND_MAXVER    1
  100 
  101 /*
  102 minor = (channel << 16) + unit
  103 
  104 nomenclature:
  105         /dev/sndtat
  106         /dev/mixerX
  107         /dev/dspX
  108         /dev/dspX.Y (cloned channels)
  109 */
  110 
  111 #define PCMMAXCHAN              0xffff
  112 #define PCMMAXUNIT              0xff
  113 #define PCMMINOR(x)             (minor(x))
  114 #define PCMCHAN(x)              ((PCMMINOR(x) >> 16) & PCMMAXCHAN)
  115 #define PCMUNIT(x)              (PCMMINOR(x) & PCMMAXUNIT)
  116 #define PCMMKMINOR(u, c)        ((((c) & PCMMAXCHAN) << 16) | ((u) & PCMMAXUNIT))
  117 
  118 #define SD_F_SIMPLEX            0x00000001
  119 #define SD_F_AUTOVCHAN          0x00000002
  120 #define SD_F_SOFTPCMVOL         0x00000004
  121 #define SD_F_PRIO_RD            0x10000000
  122 #define SD_F_PRIO_WR            0x20000000
  123 #define SD_F_PRIO_SET           (SD_F_PRIO_RD | SD_F_PRIO_WR)
  124 #define SD_F_DIR_SET            0x40000000
  125 #define SD_F_TRANSIENT          0xf0000000
  126 
  127 /* many variables should be reduced to a range. Here define a macro */
  128 #define RANGE(var, low, high) (var) = \
  129         (((var)<(low))? (low) : ((var)>(high))? (high) : (var))
  130 #define DSP_BUFFSIZE (8192)
  131 
  132 /* make figuring out what a format is easier. got AFMT_STEREO already */
  133 #define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
  134 #define AFMT_24BIT (AFMT_S24_LE | AFMT_S24_BE | AFMT_U24_LE | AFMT_U24_BE)
  135 #define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
  136 #define AFMT_8BIT (AFMT_MU_LAW | AFMT_A_LAW | AFMT_U8 | AFMT_S8)
  137 #define AFMT_SIGNED (AFMT_S32_LE | AFMT_S32_BE | AFMT_S24_LE | AFMT_S24_BE | \
  138                         AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
  139 #define AFMT_BIGENDIAN (AFMT_S32_BE | AFMT_U32_BE | AFMT_S24_BE | AFMT_U24_BE | \
  140                         AFMT_S16_BE | AFMT_U16_BE)
  141 
  142 struct pcm_channel *fkchan_setup(device_t dev);
  143 int fkchan_kill(struct pcm_channel *c);
  144 
  145 /* XXX Flawed definition. I'll fix it someday. */
  146 #define SND_MAXVCHANS   PCMMAXCHAN
  147 
  148 /*
  149  * Minor numbers for the sound driver.
  150  *
  151  * Unfortunately Creative called the codec chip of SB as a DSP. For this
  152  * reason the /dev/dsp is reserved for digitized audio use. There is a
  153  * device for true DSP processors but it will be called something else.
  154  * In v3.0 it's /dev/sndproc but this could be a temporary solution.
  155  */
  156 
  157 #define SND_DEV_CTL     0       /* Control port /dev/mixer */
  158 #define SND_DEV_SEQ     1       /* Sequencer /dev/sequencer */
  159 #define SND_DEV_MIDIN   2       /* Raw midi access */
  160 #define SND_DEV_DSP     3       /* Digitized voice /dev/dsp */
  161 #define SND_DEV_STATUS  6       /* /dev/sndstat */
  162                                 /* #7 not in use now. */
  163 #define SND_DEV_SEQ2    8       /* /dev/sequencer, level 2 interface */
  164 #define SND_DEV_SNDPROC 9       /* /dev/sndproc for programmable devices */
  165 #define SND_DEV_PSS     SND_DEV_SNDPROC /* ? */
  166 #define SND_DEV_NORESET 10
  167 #define SND_DEV_DSPREC  11      /* recording channels */
  168 
  169 #define DSP_DEFAULT_SPEED       8000
  170 
  171 #define ON              1
  172 #define OFF             0
  173 
  174 extern int pcm_veto_load;
  175 extern int snd_maxautovchans;
  176 extern devclass_t pcm_devclass;
  177 
  178 /*
  179  * some macros for debugging purposes
  180  * DDB/DEB to enable/disable debugging stuff
  181  * BVDDB   to enable debugging when bootverbose
  182  */
  183 #define BVDDB(x) if (bootverbose) x
  184 
  185 #ifndef DEB
  186 #define DEB(x)
  187 #endif
  188 
  189 SYSCTL_DECL(_hw_snd);
  190 
  191 struct sysctl_ctx_list *snd_sysctl_tree(device_t dev);
  192 struct sysctl_oid *snd_sysctl_tree_top(device_t dev);
  193 
  194 struct pcm_channel *pcm_getfakechan(struct snddev_info *d);
  195 int pcm_setvchans(struct snddev_info *d, int newcnt);
  196 int pcm_chnalloc(struct snddev_info *d, struct pcm_channel **ch, int direction, pid_t pid, int chnum);
  197 int pcm_chnrelease(struct pcm_channel *c);
  198 int pcm_chnref(struct pcm_channel *c, int ref);
  199 int pcm_inprog(struct snddev_info *d, int delta);
  200 
  201 struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo);
  202 struct pcm_channel *pcm_chn_iterate(struct snddev_info *d, void **cookie);
  203 int pcm_chn_destroy(struct pcm_channel *ch);
  204 int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch);
  205 int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch);
  206 
  207 int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo);
  208 unsigned int pcm_getbuffersize(device_t dev, unsigned int min, unsigned int deflt, unsigned int max);
  209 int pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
  210 int pcm_unregister(device_t dev);
  211 int pcm_setstatus(device_t dev, char *str);
  212 u_int32_t pcm_getflags(device_t dev);
  213 void pcm_setflags(device_t dev, u_int32_t val);
  214 void *pcm_getdevinfo(device_t dev);
  215 
  216 
  217 int snd_setup_intr(device_t dev, struct resource *res, int flags,
  218                    driver_intr_t hand, void *param, void **cookiep);
  219 
  220 void *snd_mtxcreate(const char *desc, const char *type);
  221 void snd_mtxfree(void *m);
  222 void snd_mtxassert(void *m);
  223 void snd_mtxlock(void *m);
  224 void snd_mtxunlock(void *m);
  225 int snd_mtxsleep(void *, sndlock_t, int, const char *, int);
  226 
  227 int sysctl_hw_snd_vchans(SYSCTL_HANDLER_ARGS);
  228 
  229 typedef int (*sndstat_handler)(struct sbuf *s, device_t dev, int verbose);
  230 int sndstat_acquire(void);
  231 int sndstat_release(void);
  232 int sndstat_register(device_t dev, char *str, sndstat_handler handler);
  233 int sndstat_registerfile(char *str);
  234 int sndstat_unregister(device_t dev);
  235 int sndstat_unregisterfile(char *str);
  236 
  237 #define SND_DECLARE_FILE(version) \
  238         _SND_DECLARE_FILE(__LINE__, version)
  239 
  240 #define _SND_DECLARE_FILE(uniq, version) \
  241         __SND_DECLARE_FILE(uniq, version)
  242 
  243 #define __SND_DECLARE_FILE(uniq, version) \
  244         static char sndstat_vinfo[] = version; \
  245         SYSINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_registerfile, sndstat_vinfo); \
  246         SYSUNINIT(sdf_ ## uniq, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, sndstat_unregisterfile, sndstat_vinfo);
  247 
  248 /* usage of flags in device config entry (config file) */
  249 #define DV_F_DRQ_MASK   0x00000007      /* mask for secondary drq */
  250 #define DV_F_DUAL_DMA   0x00000010      /* set to use secondary dma channel */
  251 
  252 #define PCM_DEBUG_MTX
  253 
  254 /*
  255  * this is rather kludgey- we need to duplicate these struct def'ns from sound.c
  256  * so that the macro versions of pcm_{,un}lock can dereference them.
  257  * we also have to do this now makedev() has gone away.
  258  */
  259 
  260 struct snddev_channel {
  261         SLIST_ENTRY(snddev_channel) link;
  262         struct pcm_channel *channel;
  263         int chan_num;
  264         struct cdev *dsp_dev;
  265         int open;
  266 };
  267 
  268 struct snddev_info {
  269         SLIST_HEAD(, snddev_channel) channels;
  270         struct pcm_channel *fakechan;
  271         unsigned devcount, playcount, reccount, vchancount;
  272         unsigned flags;
  273         int inprog;
  274         unsigned int bufsz;
  275         void *devinfo;
  276         device_t dev;
  277         char status[SND_STATUSLEN];
  278         struct sysctl_ctx_list sysctl_tree;
  279         struct sysctl_oid *sysctl_tree_top;
  280         sndlock_t       lock;
  281         struct cdev *mixer_dev;
  282         struct cdev *dsp_clonedev;
  283 };
  284 
  285 #ifdef  PCM_DEBUG_MTX
  286 #define pcm_lock(d) snd_mtxlock(((struct snddev_info *)(d))->lock)
  287 #define pcm_unlock(d) snd_mtxunlock(((struct snddev_info *)(d))->lock)
  288 #else
  289 void pcm_lock(struct snddev_info *d);
  290 void pcm_unlock(struct snddev_info *d);
  291 #endif
  292 
  293 #ifdef KLD_MODULE
  294 #define PCM_KLDSTRING(a) ("kld " # a)
  295 #else
  296 #define PCM_KLDSTRING(a) ""
  297 #endif
  298 
  299 #endif /* _KERNEL */
  300 
  301 #endif  /* _OS_H_ */

Cache object: 07c4a0249ef3239df5d8b589aab3908a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.