[BACK]Return to dev.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / aucat

Annotation of src/usr.bin/aucat/dev.h, Revision 1.33

1.33    ! ratchov     1: /*     $OpenBSD: dev.h,v 1.32 2011/11/20 22:54:51 ratchov Exp $        */
1.1       ratchov     2: /*
                      3:  * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
                     17: #ifndef DEV_H
                     18: #define DEV_H
                     19:
1.27      ratchov    20: #include "aparams.h"
                     21:
1.2       ratchov    22: struct aproc;
                     23: struct abuf;
1.1       ratchov    24:
1.24      ratchov    25: struct dev {
                     26:        struct dev *next;
                     27:
                     28:        /*
                     29:         * desired parameters
                     30:         */
                     31:        unsigned reqmode;                       /* mode */
                     32:        struct aparams reqipar, reqopar;        /* parameters */
                     33:        unsigned reqbufsz;                      /* buffer size */
                     34:        unsigned reqround;                      /* block size */
                     35:        unsigned hold;                          /* hold the device open ? */
1.28      ratchov    36:        unsigned autovol;                       /* auto adjust playvol ? */
1.30      ratchov    37:        unsigned autostart;                     /* don't wait for MMC start */
1.24      ratchov    38:        unsigned refcnt;                        /* number of openers */
1.31      ratchov    39: #define DEV_NMAX       16                      /* max number of devices */
                     40:        unsigned num;                           /* serial number */
1.24      ratchov    41: #define DEV_CLOSED     0                       /* closed */
                     42: #define DEV_INIT       1                       /* stopped */
                     43: #define DEV_START      2                       /* ready to start */
                     44: #define DEV_RUN                3                       /* started */
                     45:        unsigned pstate;                        /* on of DEV_xxx */
                     46:        char *path;                             /* sio path */
                     47:
                     48:        /*
                     49:         * actual parameters and runtime state (i.e. once opened)
                     50:         */
                     51:        unsigned mode;                          /* bitmap of MODE_xxx */
                     52:        unsigned bufsz, round, rate;
                     53:        struct aparams ipar, opar;
                     54:        struct aproc *mix, *sub, *submon;
                     55:        struct aproc *rec, *play, *mon;
                     56:        struct aproc *midi;
1.29      ratchov    57:        struct devctl {
                     58:                struct devctl *next;
                     59:                unsigned mode;
                     60:                char *path;
                     61:        } *ctl_list;
1.32      ratchov    62:
                     63:        /* volume control and MMC/MTC */
                     64: #define CTL_NSLOT      8
                     65: #define CTL_NAMEMAX    8
                     66:        unsigned serial;
                     67:        struct ctl_slot {
                     68:                struct ctl_ops {
                     69:                        void (*vol)(void *, unsigned);
                     70:                        void (*start)(void *);
                     71:                        void (*stop)(void *);
                     72:                        void (*loc)(void *, unsigned);
                     73:                        void (*quit)(void *);
                     74:                } *ops;
                     75:                void *arg;
                     76:                unsigned unit;
                     77:                char name[CTL_NAMEMAX];
                     78:                unsigned serial;
                     79:                unsigned vol;
                     80:                unsigned tstate;
                     81:        } slot[CTL_NSLOT];
                     82: #define CTL_OFF                0                       /* ignore MMC messages */
                     83: #define CTL_STOP       1                       /* stopped, can't start */
                     84: #define CTL_START      2                       /* attempting to start */
                     85: #define CTL_RUN                3                       /* started */
                     86:        unsigned tstate;                        /* one of above */
                     87:        unsigned origin;                        /* MTC start time */
1.24      ratchov    88: };
                     89:
                     90: extern struct dev *dev_list;
                     91:
1.31      ratchov    92: void dev_dbg(struct dev *);
1.30      ratchov    93: int  dev_init(struct dev *);
1.24      ratchov    94: int  dev_run(struct dev *);
                     95: int  dev_ref(struct dev *);
                     96: void dev_unref(struct dev *);
                     97: void dev_del(struct dev *);
                     98: void dev_wakeup(struct dev *);
1.26      ratchov    99: void dev_drain(struct dev *);
1.30      ratchov   100: struct dev *dev_new(char *, unsigned, unsigned, unsigned, unsigned, unsigned);
                    101: void dev_adjpar(struct dev *, unsigned, struct aparams *, struct aparams *);
1.29      ratchov   102: int  devctl_add(struct dev *, char *, unsigned);
1.24      ratchov   103: void dev_midiattach(struct dev *, struct abuf *, struct abuf *);
                    104: unsigned dev_roundof(struct dev *, unsigned);
                    105: int dev_getpos(struct dev *);
                    106: void dev_attach(struct dev *, char *, unsigned,
1.21      ratchov   107:     struct abuf *, struct aparams *, unsigned,
                    108:     struct abuf *, struct aparams *, unsigned,
                    109:     unsigned, int);
1.24      ratchov   110: void dev_setvol(struct dev *, struct abuf *, int);
1.32      ratchov   111:
                    112: void dev_slotdbg(struct dev *, int);
                    113: int  dev_slotnew(struct dev *, char *, struct ctl_ops *, void *, int);
                    114: void dev_slotdel(struct dev *, int);
                    115: void dev_slotvol(struct dev *, int, unsigned);
                    116:
                    117: int  dev_slotstart(struct dev *, int);
                    118: void dev_slotstop(struct dev *, int);
                    119: void dev_mmcstart(struct dev *);
                    120: void dev_mmcstop(struct dev *);
                    121: void dev_loc(struct dev *, unsigned);
                    122: int  dev_idle(struct dev *);
1.1       ratchov   123:
                    124: #endif /* !define(DEV_H) */