revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Device / device.h
blob50cdb99c9201e88a3c2ea670f6ec74a63a0be194
1 /*
2 AHI - Hardware independent audio subsystem
3 Copyright (C) 2017 The AROS Dev Team
4 Copyright (C) 1996-2005 Martin Blom <martin@blom.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
19 MA 02139, USA.
22 #ifndef ahi_device_h
23 #define ahi_device_h
25 #include <exec/types.h>
26 #include <dos/dos.h>
28 struct AHIRequest;
29 struct AHIBase;
31 /*** New Style Device definitions ***/
33 #define NSCMD_DEVICEQUERY 0x4000
35 #define NSDEVTYPE_UNKNOWN 0 /* No suitable category, anything */
36 #define NSDEVTYPE_GAMEPORT 1 /* like gameport.device */
37 #define NSDEVTYPE_TIMER 2 /* like timer.device */
38 #define NSDEVTYPE_KEYBOARD 3 /* like keyboard.device */
39 #define NSDEVTYPE_INPUT 4 /* like input.device */
40 #define NSDEVTYPE_TRACKDISK 5 /* like trackdisk.device */
41 #define NSDEVTYPE_CONSOLE 6 /* like console.device */
42 #define NSDEVTYPE_SANA2 7 /* A >=SANA2R2 networking device */
43 #define NSDEVTYPE_AUDIOARD 8 /* like audio.device */
44 #define NSDEVTYPE_CLIPBOARD 9 /* like clipboard.device */
45 #define NSDEVTYPE_PRINTER 10 /* like printer.device */
46 #define NSDEVTYPE_SERIAL 11 /* like serial.device */
47 #define NSDEVTYPE_PARALLEL 12 /* like parallel.device */
49 struct NSDeviceQueryResult
52 ** Standard information
54 ULONG DevQueryFormat; /* this is type 0 */
55 ULONG SizeAvailable; /* bytes available */
58 ** Common information (READ ONLY!)
60 UWORD DeviceType; /* what the device does */
61 UWORD DeviceSubType; /* depends on the main type */
62 UWORD *SupportedCommands; /* 0 terminated list of cmd's */
64 /* May be extended in the future! Check SizeAvailable! */
67 #define DRIVE_NEWSTYLE (0x4E535459L) /* 'NSTY' */
68 #define NSCMD_TD_READ64 0xc000
69 #define NSCMD_TD_WRITE64 0xc001
70 #define NSCMD_TD_SEEK64 0xc002
71 #define NSCMD_TD_FORMAT64 0xc003
74 /*** My own stuff ***/
76 #define AHI_PRI 50 /* Priority for the device process */
78 #define PLAYERFREQ 100 /* How often the PlayerFunc is called */
80 #define AHICMD_END CMD_NONSTD
82 #define AHICMD_WRITTEN (0x8000 | CMD_WRITE)
84 #define ahir_Extras ahir_Private[0]
85 #define GetExtras(req) ((struct Extras *) req->ahir_Private[0])
86 #define NOCHANNEL 65535
88 struct Extras
90 UWORD Channel;
91 UWORD Sound;
92 Fixed VolumeScale;
95 /* Voice->Flags definitions */
97 /* Set by the interrupt when a new sound has been started */
98 #define VB_STARTED 0
99 #define VF_STARTED (1<<0)
101 struct Voice
103 UWORD NextSound;
104 UBYTE Flags;
105 UBYTE Pad;
106 Fixed NextVolume;
107 Fixed NextPan;
108 ULONG NextFrequency;
109 ULONG NextOffset;
110 ULONG NextLength;
111 struct AHIRequest *NextRequest;
113 struct AHIRequest *QueuedRequest;
114 struct AHIRequest *PlayingRequest;
117 /* Special Offset values */
119 #define FREE -1 /* Channel is not playing anything */
120 #define MUTE -2 /* Channel will be muted when current sound is finished */
121 #define PLAY -3 /* Channel will play more when current sound is finished */
123 #define MAXSOUNDS 128
124 #define SOUND_FREE 0
125 #define SOUND_IN_USE 1
127 struct AHIDevUnit
129 struct Unit Unit;
130 UBYTE UnitNum;
131 BYTE PlaySignal;
132 BYTE RecordSignal;
133 BYTE SampleSignal;
134 struct Process *Process;
135 BYTE SyncSignal;
136 struct Process *Master;
137 struct Hook PlayerHook;
138 struct Hook RecordHook;
139 struct Hook SoundHook;
140 struct Hook ChannelInfoHook;
142 struct AHIEffChannelInfo *ChannelInfoStruct;
144 WORD RecordOffDelay;
145 WORD *RecordBuffer;
146 ULONG RecordSize;
148 BOOL IsPlaying; // Currently playing (or want to)
149 BOOL IsRecording; // Currently recording
150 BOOL ValidRecord; // The record buffer contains valid data
151 BOOL FullDuplex; // Mode is full duplex
152 BOOL PseudoStereo; // Mode is Paula-like stereo
153 UWORD StopCnt; // CMD_STOP count
155 /* Lock is used to serialize access to StopCnt, ReadList, PlayingList,
156 SilentList, WaitingList and RequestQueue */
158 struct SignalSemaphore Lock;
160 struct MinList ReadList;
161 struct MinList PlayingList;
162 struct MinList SilentList;
163 struct MinList WaitingList;
165 struct MinList RequestQueue;
167 struct Voice *Voices;
169 struct AHIAudioCtrl *AudioCtrl;
170 IPTR AudioMode;
171 IPTR Frequency;
172 UWORD Channels;
173 UWORD Pad;
174 Fixed MonitorVolume;
175 Fixed InputGain;
176 Fixed OutputVolume;
177 IPTR Input;
178 IPTR Output;
180 UBYTE Sounds[MAXSOUNDS];
183 ULONG
184 _DevOpen ( struct AHIRequest* ioreq,
185 ULONG unit,
186 ULONG flags,
187 struct AHIBase* AHIBase );
189 BPTR
190 _DevClose ( struct AHIRequest* ioreq,
191 struct AHIBase* AHIBase );
193 BOOL
194 ReadConfig ( struct AHIDevUnit *iounit,
195 struct AHIBase *AHIBase );
197 BOOL
198 AllocHardware ( struct AHIDevUnit *iounit,
199 struct AHIBase *AHIBase );
201 void
202 FreeHardware ( struct AHIDevUnit *iounit,
203 struct AHIBase *AHIBase );
205 void
206 DevProc( void );
208 #endif /* ahi_device_h */