xref: /haiku/headers/private/audio/audio_driver.h (revision c1071005c964468324a2ba33ffee74a2c2e8bb83)
1 /* audio_driver.h */
2 /* Jon Watte 19971223 */
3 /* Interface to drivers found in /dev/audio */
4 /* Devices found in /dev/audio/old follow a different API! */
5 
6 /*
7 	Copyright 1999, Be Incorporated.   All Rights Reserved.
8 	This file may be used under the terms of the Be Sample Code License.
9 */
10 
11 #if !defined(_AUDIO_DRIVER_H)
12 #define _AUDIO_DRIVER_H
13 
14 #if !defined(_SUPPORT_DEFS_H)
15 #include <SupportDefs.h>
16 #endif /* _SUPPORT_DEFS_H */
17 #if !defined(_DRIVERS_H)
18 #include <Drivers.h>
19 #endif /* _DRIVERS_H */
20 
21 enum {
22 	/* arg = ptr to struct audio_format */
23 	B_AUDIO_GET_AUDIO_FORMAT = B_AUDIO_DRIVER_BASE,
24 	B_AUDIO_SET_AUDIO_FORMAT,
25 	/* arg = ptr to float[4] */
26 	B_AUDIO_GET_PREFERRED_SAMPLE_RATES,
27 	/* arg = ptr to struct audio_routing_cmd */
28 	B_ROUTING_GET_VALUES,
29 	B_ROUTING_SET_VALUES,
30 	/* arg = ptr to struct audio_routing_cmd */
31 	B_MIXER_GET_VALUES,
32 	B_MIXER_SET_VALUES,
33 	/* arg = ptr to struct audio_timing */
34 	B_AUDIO_GET_TIMING		/* used to be SV_SECRET_HANDSHAKE (10100) */
35 };
36 
37 /* this is the definition of what the audio driver can do for you */
38 typedef struct audio_format {
39     float       sample_rate;    /* ~4000 - ~48000, maybe more */
40     int32       channels;       /* 1 or 2 */
41     int32       format;         /* 0x11 (uchar), 0x2 (short) or 0x24 (float) */
42     int32       big_endian;    /* 0 for little endian, 1 for big endian */
43     size_t      buf_header;     /* typically 0 or 16 */
44 	size_t      play_buf_size;	/* size of playback buffer (latency) */
45 	size_t		rec_buf_size;	/* size of record buffer (latency) */
46 } audio_format;
47 
48 /* when buffer header is in effect, this is what gets read before data */
49 typedef struct audio_buf_header {
50     bigtime_t   capture_time;
51     uint32      capture_size;
52     float       sample_rate;
53 } audio_buf_header;
54 
55 /* the mux devices use these records */
56 typedef struct audio_routing {
57 	int32 selector;	/* for GET, these need to be filled in! */
58 	int32 value;
59 } audio_routing;
60 
61 /* this is the argument for ioctl() */
62 typedef struct audio_routing_cmd {
63 	int32 count;
64 	audio_routing* data;
65 } audio_routing_cmd;
66 
67 typedef struct {
68     bigtime_t   wr_time;
69 	bigtime_t   rd_time;
70 	uint32      wr_skipped;
71 	uint32      rd_skipped;
72 	uint64      wr_total;
73 	uint64      rd_total;
74 	uint32      _reserved_[6];
75 } audio_timing;
76 
77 
78 enum {	/* selectors for routing */
79 	B_AUDIO_INPUT_SELECT,
80 	B_AUDIO_MIC_BOOST,
81 	B_AUDIO_MIDI_OUTPUT_TO_SYNTH,
82 	B_AUDIO_MIDI_INPUT_TO_SYNTH,
83 	B_AUDIO_MIDI_OUTPUT_TO_PORT,
84 	B_AUDIO_PCM_OUT_POST_3D,
85 	B_AUDIO_STEREO_ENHANCEMENT,
86 	B_AUDIO_3D_STEREO_ENHANCEMENT,
87 	B_AUDIO_BASS_BOOST,
88 	B_AUDIO_LOCAL_LOOPBACK,
89 	B_AUDIO_REMOTE_LOOPBACK,
90 	B_AUDIO_MONO_OUTPUT_FROM_MIC,
91 	B_AUDIO_ALTERNATE_MIC,
92 	B_AUDIO_ADC_DAC_LOOPBACK
93 };
94 
95 enum {	/* input MUX source values */
96 	B_AUDIO_INPUT_DAC = 1,	/* (not in AC97) */
97 	B_AUDIO_INPUT_LINE_IN,
98 	B_AUDIO_INPUT_CD,
99 	B_AUDIO_INPUT_VIDEO,
100 	B_AUDIO_INPUT_AUX1,		/* synth */
101 	B_AUDIO_INPUT_AUX2,		/* (not in AC97) */
102 	B_AUDIO_INPUT_PHONE,
103 	B_AUDIO_INPUT_MIC,
104 	B_AUDIO_INPUT_MIX_OUT,	/* sum of all outputs */
105 	B_AUDIO_INPUT_MONO_OUT
106 };
107 
108 /* the mixer devices use these records */
109 typedef struct audio_level {
110 	int32 selector;	/* for GET, this still needs to be filled in! */
111 	uint32 flags;
112 	float value;	/* in dB */
113 } audio_level;
114 
115 /* this is the arg to ioctl() */
116 typedef struct audio_level_cmd {
117 	int32 count;
118 	audio_level* data;
119 } audio_level_cmd;
120 
121 /* bitmask for the flags */
122 #define B_AUDIO_LEVEL_MUTED 1
123 
124 enum {	/* selectors for levels */
125   B_AUDIO_MIX_ADC_LEFT,
126   B_AUDIO_MIX_ADC_RIGHT,
127   B_AUDIO_MIX_DAC_LEFT,
128   B_AUDIO_MIX_DAC_RIGHT,
129   B_AUDIO_MIX_LINE_IN_LEFT,
130   B_AUDIO_MIX_LINE_IN_RIGHT,
131   B_AUDIO_MIX_CD_LEFT,
132   B_AUDIO_MIX_CD_RIGHT,
133   B_AUDIO_MIX_VIDEO_LEFT,
134   B_AUDIO_MIX_VIDEO_RIGHT,
135   B_AUDIO_MIX_SYNTH_LEFT,
136   B_AUDIO_MIX_SYNTH_RIGHT,
137   B_AUDIO_MIX_AUX_LEFT,			/* (not in AC97) */
138   B_AUDIO_MIX_AUX_RIGHT,		/* (not in AC97) */
139   B_AUDIO_MIX_PC_BEEP,
140   B_AUDIO_MIX_PHONE,
141   B_AUDIO_MIX_MIC,
142   B_AUDIO_MIX_LINE_OUT_LEFT,
143   B_AUDIO_MIX_LINE_OUT_RIGHT,
144   B_AUDIO_MIX_HEADPHONE_OUT_LEFT,
145   B_AUDIO_MIX_HEADPHONE_OUT_RIGHT,
146   B_AUDIO_MIX_MONO_OUT,
147   B_AUDIO_MIX_LOOPBACK_LEVEL	/* (not in AC97) */
148 };
149 
150 #endif /* _AUDIO_DRIVER_H */
151 
152