Annotation of src/usr.bin/aucat/dev.h, Revision 1.36
1.36 ! ratchov 1: /* $OpenBSD: dev.h,v 1.35 2012/03/23 11:59:54 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: */
1.36 ! ratchov 31: unsigned int reqmode; /* mode */
1.24 ratchov 32: struct aparams reqipar, reqopar; /* parameters */
1.36 ! ratchov 33: unsigned int reqbufsz; /* buffer size */
! 34: unsigned int reqround; /* block size */
! 35: unsigned int hold; /* hold the device open ? */
! 36: unsigned int autovol; /* auto adjust playvol ? */
! 37: unsigned int autostart; /* don't wait for MMC start */
! 38: unsigned int refcnt; /* number of openers */
1.31 ratchov 39: #define DEV_NMAX 16 /* max number of devices */
1.36 ! ratchov 40: unsigned int 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 */
1.36 ! ratchov 45: unsigned int pstate; /* on of DEV_xxx */
1.24 ratchov 46: char *path; /* sio path */
47:
48: /*
49: * actual parameters and runtime state (i.e. once opened)
50: */
1.36 ! ratchov 51: unsigned int mode; /* bitmap of MODE_xxx */
! 52: unsigned int bufsz, round, rate;
1.24 ratchov 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;
1.36 ! ratchov 59: unsigned int mode;
1.29 ratchov 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
1.36 ! ratchov 66: unsigned int serial;
1.32 ratchov 67: struct ctl_slot {
68: struct ctl_ops {
1.36 ! ratchov 69: void (*vol)(void *, unsigned int);
1.32 ratchov 70: void (*start)(void *);
71: void (*stop)(void *);
1.36 ! ratchov 72: void (*loc)(void *, unsigned int);
1.32 ratchov 73: void (*quit)(void *);
74: } *ops;
75: void *arg;
1.36 ! ratchov 76: unsigned int unit;
1.32 ratchov 77: char name[CTL_NAMEMAX];
1.36 ! ratchov 78: unsigned int serial;
! 79: unsigned int vol;
! 80: unsigned int tstate;
1.32 ratchov 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 */
1.36 ! ratchov 86: unsigned int tstate; /* one of above */
! 87: unsigned int origin; /* MTC start time */
! 88: unsigned int master; /* master volume controller */
1.24 ratchov 89: };
90:
91: extern struct dev *dev_list;
92:
1.31 ratchov 93: void dev_dbg(struct dev *);
1.30 ratchov 94: int dev_init(struct dev *);
1.24 ratchov 95: int dev_run(struct dev *);
96: int dev_ref(struct dev *);
97: void dev_unref(struct dev *);
98: void dev_del(struct dev *);
99: void dev_wakeup(struct dev *);
1.26 ratchov 100: void dev_drain(struct dev *);
1.36 ! ratchov 101: struct dev *dev_new(char *, unsigned int, unsigned int,
! 102: unsigned int, unsigned int, unsigned int);
! 103: void dev_adjpar(struct dev *, unsigned int,
! 104: struct aparams *, struct aparams *);
! 105: int devctl_add(struct dev *, char *, unsigned int);
1.24 ratchov 106: void dev_midiattach(struct dev *, struct abuf *, struct abuf *);
1.36 ! ratchov 107: unsigned int dev_roundof(struct dev *, unsigned int);
1.24 ratchov 108: int dev_getpos(struct dev *);
1.36 ! ratchov 109: void dev_attach(struct dev *, char *, unsigned int,
! 110: struct abuf *, struct aparams *, unsigned int,
! 111: struct abuf *, struct aparams *, unsigned int,
! 112: unsigned int, int);
1.24 ratchov 113: void dev_setvol(struct dev *, struct abuf *, int);
1.32 ratchov 114:
115: void dev_slotdbg(struct dev *, int);
116: int dev_slotnew(struct dev *, char *, struct ctl_ops *, void *, int);
117: void dev_slotdel(struct dev *, int);
1.36 ! ratchov 118: void dev_slotvol(struct dev *, int, unsigned int);
1.32 ratchov 119:
120: int dev_slotstart(struct dev *, int);
121: void dev_slotstop(struct dev *, int);
122: void dev_mmcstart(struct dev *);
123: void dev_mmcstop(struct dev *);
1.36 ! ratchov 124: void dev_loc(struct dev *, unsigned int);
! 125: void dev_master(struct dev *, unsigned int);
1.1 ratchov 126:
127: #endif /* !define(DEV_H) */