home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / audiopdd.zip / cs40.h < prev    next >
C/C++ Source or Header  |  1999-02-27  |  25KB  |  693 lines

  1. //
  2. // cs40.h
  3. // 25-Jan-99
  4. //
  5.  
  6. #ifndef CS40_INCL
  7.  
  8. //xx #define NO_INT3   // define to change int3() into a nop
  9.  
  10. #define  INCL_BASE
  11. #define  INCL_NOPMAPI
  12.  
  13. #include <os2.h>
  14. #include <os2medef.h>
  15. #include <meerror.h>
  16. #include <ssm.h>
  17. #include <shdd.h>
  18. #include <audio.h>
  19.  
  20. #include "wdevhelp.h"
  21. #include "whelper.h"
  22. #include "include.h"
  23. #include "traceid.h"
  24.  
  25. #define DRIVER_VERSION 0x01000001  // 1.0 build 0001 (MMmmBBBB) returned in audio init ioctl
  26.  
  27.  
  28.  
  29. // -------------------------------------
  30. // structures, types, defines
  31. // -------------------------------------
  32.  
  33. typedef struct _REQPACK {
  34.  UCHAR   length;                // 00 request packet length
  35.  UCHAR   unit;                  // 01 unit code for block DD only
  36.  UCHAR   command;               // 02 command code
  37.  USHORT  status;                // 03 status word
  38.  UCHAR   rsv5[4];               // 05 reserved bytes
  39.  ULONG   qLink;                 // 09 queue linkage
  40.  union {                        //    command-specific data
  41.   UCHAR  avail[19];             // 13 available space, in 32-byte packet
  42.  
  43.   struct {                      //    INIT Packet (one for entry, one for exit)
  44.    UCHAR  units;                // 13 number of units
  45.    union {
  46.     struct {
  47.      PFN Device_Help;           // 14 used at entry
  48.     };
  49.     struct {
  50.      USHORT sizeCS;             // 14 final code offset (used at exit)
  51.      USHORT sizeDS;             // 16 final data offset
  52.     };
  53.    };
  54.    UCHAR  __far *argsPtr;       // 18 -> args
  55.    UCHAR  drive;                // 22 drive number
  56.   } init;
  57.  
  58.   struct {                      //    OPEN/CLOSE
  59.    USHORT SFN;                  // 13 sfn
  60.   } open;
  61.  
  62.   struct {                      //    IOCTL
  63.    UCHAR  category;             // 13 category code
  64.    UCHAR  function;             // 14 function code
  65.    VOID __far *parmPtr;         // 15 -> parm data
  66.    VOID __far *dataPtr;         // 19 -> data
  67.    USHORT SFN;                  // 23 from kernel, pass back in Audio_Init
  68.    USHORT parmBuffLen;          // 25
  69.    USHORT dataBuffLen;          // 27
  70.   } ioctl;
  71.  }; // unnamed (was s;)
  72. } REQPACK;
  73.  
  74.  
  75. // ------------------------------------
  76. // header.c, structures, defines, types
  77.  
  78. #define RPDONE    0x0100         // return successful, must be set
  79. #define RPBUSY    0x0200         // device is busy (or has no data to return)
  80. #define RPDEV     0x4000         // user-defined error
  81. #define RPERR     0x8000         // return error
  82.  
  83. // List of error codes, from chapter 8 of PDD reference
  84. #define RPNOTREADY  0x0002
  85. #define RPBADCMD    0x0003
  86. #define RPGENFAIL   0x000c
  87. #define RPDEVINUSE  0x0014
  88. #define RPINITFAIL  0x0015
  89.  
  90. // list of Strategy commands from PDD reference
  91. // Note this is only the list of commands audio device drivers care about
  92.  
  93. #define STRATEGY_INIT          0x00
  94. #define STRATEGY_OPEN          0x0D
  95. #define STRATEGY_CLOSE         0x0E
  96. #define STRATEGY_GENIOCTL      0x10
  97. #define STRATEGY_DEINSTALL     0x14
  98. #define STRATEGY_INITCOMPLETE  0x1F
  99.  
  100. #define DA_CHAR         0x8000   // Character PDD
  101. #define DA_IDCSET       0x4000   // IDC entry point set
  102. #define DA_BLOCK        0x2000   // Block device driver
  103. #define DA_SHARED       0x1000   // Shared device (filesystem share-aware)
  104. #define DA_NEEDOPEN     0x800    // Open/Close required
  105.  
  106. #define DA_OS2DRVR      0x0080   // Standard OS/2 driver
  107. #define DA_IOCTL2       0x0100   // Supports IOCTL2
  108. #define DA_USESCAP      0x0180   // Uses Capabilities bits
  109.  
  110. #define DA_CLOCK        8        // Clock device
  111. #define DA_NULL         4        // NULL device
  112. #define DA_STDOUT       2        // STDOUT device
  113. #define DA_STDIN        1        // STDIN device
  114.  
  115. #define DC_INITCPLT     0x10     // Supports Init Complete
  116. #define DC_ADD          8        // ADD driver
  117. #define DC_PARALLEL     4        // Supports parallel ports
  118. #define DC_32BIT        2        // Supports 32-bit addressing (rather than 24-bit)
  119. #define DC_IOCTL2       1        // Supports DosDevIOCtl2 and Shutdown (1C)
  120.  
  121. typedef VOID (__near *PFNENTRY)(VOID);  // strat/IDC entry cc
  122.  
  123. #pragma pack(1); // not needed
  124.  
  125. typedef struct _DEV_HEADER {
  126.  ULONG nextDD;
  127.  USHORT attr;
  128.  PFNENTRY pfnStrategy;
  129.  PFNENTRY pfnIDC;
  130.  CHAR name[8];
  131.  ULONG reserved[2];
  132.  ULONG caps;
  133. } DEV_HEADER;
  134.  
  135. #pragma pack();
  136.  
  137. // pseudo-variable that points to device header
  138. //#define phdr ((DEV_HEADER *) 0)
  139.  
  140.  
  141. // -------------------------------------
  142. // chipset.c, structures, types, defines
  143.  
  144.  
  145. // ---------------------------------
  146. // dma.c, structures, types, defines
  147. //
  148.  
  149. #define DMA_TYPE_PLAY      0x0000  // (dma-read)
  150. #define DMA_TYPE_CAPTURE   0x0001  // (dma-write)
  151. #define DMA_TYPE_DIRECTION 0x0001  // used to AND with PLAY/CAPTURE types
  152. #define DMA_TYPE_WORD_SZ   0x0006
  153. #define DMA_TYPE_8BIT      0x0000  // 8 bit DMA channel
  154. #define DMA_TYPE_16BIT     0x0002  // 16 bit DMA channel
  155. #define DMA_TYPE_ISA       0x0008  // DMA Channel of an 8237A
  156. #define DMA_TYPE_DDMA      0x0010  // Distributed DMA Channel
  157. #define DMA_TYPE_FTYPE     0x0100  // hardware supports F type DMA (demand mode for the 8237)
  158.  
  159. //#define DMA_IO_WAIT 2    // IO wait time between IO DMA regs (2 * 500ns = 1us) (just use WAIT_1US)
  160.  
  161. typedef struct _DMACHANNEL_INFO {
  162.  USHORT portAddr;       //  0
  163.  USHORT portCount;      //  2
  164.  USHORT portPage;       //  4
  165.  USHORT portMask;       //  6
  166.  USHORT portMode;       //  8
  167.  USHORT portFlipFlop;   // 10
  168.  USHORT portStatus;     // 12
  169.  UCHAR  maskStatus;     // 14
  170.  UCHAR  maskEnable;     // 15
  171.  UCHAR  maskDisable;    // 16
  172.  UCHAR  typeFdma;       // 17
  173.  USHORT rsv18;          // 18
  174. } DMACHANNEL_INFO;      // 20 bytes
  175.  
  176. typedef struct _DMACHANNEL {
  177.  USHORT status;         //  0
  178.  USHORT ch;             //  2 0-3, 5-7
  179.  USHORT type;           //  4 DMA_TYPE_*
  180.  UCHAR  mode;           //  6 data for DMA mode register
  181.  UCHAR  page;           //  7
  182.  UCHAR  addrHi;         //  8
  183.  UCHAR  addrLo;         //  9
  184.  UCHAR  countHi;        // 10
  185.  UCHAR  countLo;        // 11
  186.  DMACHANNEL_INFO chInfo;// 12 setup data (20 bytes)
  187.  ULONG  audioBufferSize;// 32 set to AUDIOBUFFER.bufferSize at dmaInit()
  188.  ULONG  lastPosition;   // 36
  189. } DMACHANNEL;           // 40 bytes
  190.  
  191.  
  192. // --------------------------------------
  193. // audiobuf.c, structures, types, defines
  194.  
  195. // values for the buffer mode
  196.  
  197. #define AUDIOBUFFER_READ  0             // the device is doing a record
  198. #define AUDIOBUFFER_WRITE 1             // the device is doing a playback
  199. //#define AUDIOBUFFER_BAD_INIT -1         // Error during constructor
  200.  
  201. #define AUDIOBUFFER_ALIGN_PAGE 0x01     // the buffer Must be ailgned on a page
  202. #define AUDIOBUFFER_CROSS_PAGE 0x02     // the buffer May cross a page boundary
  203. #define AUDIOBUFFER_NO_PAGE    0x04     // the buffer has no page requirements
  204. #define AUDIOBUFFER_ISA_DMA8   0x08     // the buffer will be used by an 8 bit DMA
  205. #define AUDIOBUFFER_ISA_DMA16  0x10     // the buffer will be used by a 16 bit DMA
  206. #define AUDIOBUFFER_DDMA       0x20     // Distributed DMA Buffer
  207.  
  208.  
  209. typedef struct _AUDIOBUFFER {
  210.  USHORT mode;                // 00 status mode (success or not)
  211.  SEL    sel;                 // 02 selector from Phys->GDT
  212.  UCHAR __far *bufferPtr;     // 04 16:16 GDT pointer to buffer (MAKEP() on the Phys->GDT selector:0
  213.  ULONG  bufferPhysAddrRaw;   // 08 unaligned base address (used to free it)
  214.  ULONG  bufferPhysAddr;      // 12 aligned base address (actually used)
  215.  ULONG  bufferSize;          // 16 size of DMA buffer currently using (logical size, <= max size)
  216.  ULONG  bufferSizeMax;       // 20 MAX size of DMA buffer (original allocation)
  217.  ULONG  deviceBytes;         // 24 bytes consumed or produced by device
  218.  ULONG  bufferBytes;         // 28 bytes read or written from buffer
  219.  DMACHANNEL dmaCh;           // 32 dma channel (40 bytes)
  220. } AUDIOBUFFER;               // 72 bytes
  221.  
  222.  
  223. // --------------------------------------
  224. // audiohw.c, structures, types, defines
  225.  
  226. #define AUDIOHW_INVALID_DEVICE     0xFFFF  // audio hardware device types (was ULONG)
  227. #define AUDIOHW_READ_DEVICE        0x0000
  228. #define AUDIOHW_WRITE_DEVICE       0x0001
  229. #define AUDIOHW_WAVE_CAPTURE       0x0010
  230. #define AUDIOHW_WAVE_PLAY          0x0011
  231. #define AUDIOHW_FMSYNTH_CAPTURE    0x0020
  232. #define AUDIOHW_FMSYNTH_PLAY       0x0021
  233. #define AUDIOHW_MPU401_CAPTURE     0x0040
  234. #define AUDIOHW_MPU401_PLAY        0x0041
  235. #define AUDIOHW_TIMER              0x0080
  236.  
  237. // regarding lDev: MMPM/2 will not send requests for two like devices to
  238. // the same driver, but it can be "fooled" into thinking there are two drivers,
  239. // each capable of one of the said devices.. (pft!)
  240.  
  241. typedef struct _AUDIOHW_T2DLIST {
  242.  USHORT devType;        // 00 device type (audiohw.c device type, that is (see above))
  243.  USHORT lDev;           // 02 strategy entry that this request came from
  244.  USHORT dataType;       // 04 data type from MMPM/2 (see audio/h/os2medef.h)
  245.  USHORT opType;         // 06 the operation type (see audio.h AUDIO_INIT.ulOperation)
  246. } AUDIOHW_T2DLIST;      //  8 bytes
  247.  
  248.  
  249. // ----------------------------------
  250. // init.c, structures, types, defines
  251.  
  252.  
  253. // -----------------------------------
  254. // ioctl.c, structures, types, defines
  255.  
  256.  
  257. // ---------------------------------
  258. // irq.c, structures, types, defines
  259.  
  260.  
  261. // ------------------------------------
  262. // strat.c, structures, types, defines
  263. // see traceid.h include above
  264.  
  265.  
  266. // ------------------------------------
  267. // stream.c, structures, types, defines
  268.  
  269. #define STREAM_RW_MODE  (STREAM_WRITE | STREAM_READ)  // STREAM_WRITE = 1, STREAM_READ = 0
  270.  
  271. typedef ULONG (__far __cdecl *T_PFNSHD)(VOID __far *);
  272.  
  273. // the point of this is to map a stream type to a hardware type (double-plus good)
  274. // so use the STREAM_* define in stream-related searches and the AUDIOHW_* define if hw related
  275.  
  276. #define STREAM_READ             AUDIOHW_READ_DEVICE
  277. #define STREAM_WRITE            AUDIOHW_WRITE_DEVICE
  278. #define STREAM_WAVE_CAPTURE     AUDIOHW_WAVE_CAPTURE
  279. #define STREAM_WAVE_PLAY        AUDIOHW_WAVE_PLAY
  280. #define STREAM_FMSYNTH_CAPTURE  AUDIOHW_FMSYNTH_CAPTURE
  281. #define STREAM_FMSYNTH_PLAY     AUDIOHW_FMSYNTH_PLAY
  282. #define STREAM_MPU401_CAPTURE   AUDIOHW_MPU401_CAPTURE
  283. #define STREAM_MPU401_PLAY      AUDIOHW_MPU401_PLAY
  284.  
  285. #define STREAM_STOPPED     0x00   // stream states (originally was ULONG)
  286. #define STREAM_STREAMING   0x01
  287. #define STREAM_PAUSED      0x02
  288. #define STREAM_IDLE        0x04
  289. #define STREAM_NOT_IDLE    0xFB
  290.  
  291. typedef struct _STREAM_BUFFER {
  292.  struct _STREAM_BUFFER *nextPtr;// 00
  293.  USHORT rsv2;                   // 02
  294.  UCHAR __far *bufferPtr;        // 04 -> stream buffer
  295.  ULONG bufferSize;              // 08 size of stream buffer (-not- dma related)
  296.  ULONG bufferCurrPos;           // 12 current position
  297.  ULONG bufferDonePos;           // 16 position at which buffer can be returned
  298. } STREAM_BUFFER;                // 20 bytes
  299. typedef STREAM_BUFFER *PSTREAM_BUFFER;
  300.  
  301. typedef struct _STREAM_BUFFER_ANCHOR { // was "STREAM_BUFFER_HEAD" but anchor makes more sense
  302.  STREAM_BUFFER *headPtr;
  303.  STREAM_BUFFER *tailPtr;
  304. } STREAM_BUFFER_ANCHOR;
  305. typedef STREAM_BUFFER_ANCHOR *PSTREAM_BUFFER_ANCHOR;
  306.  
  307. typedef struct _STREAM {
  308.  struct _STREAM *nextPtr;       // 00 next stream on queue
  309.  USHORT rsv2;                   // 02
  310.  HSTREAM streamH;               // 04
  311.  T_PFNSHD pfnSHD;               // 08 is "typedef ULONG (__far __cdecl *PFN_SHD)(VOID __far *)"
  312.  USHORT SFN;                    // 12
  313.  USHORT rsv14;                  // 14 reserved (SFN is 16-bit value down here, in reqpack too)
  314.  STREAM_BUFFER_ANCHOR sbaProc;  // 16 head for STREAM_BUFFER in-process queue anchor (2 x 2 bytes)
  315.  STREAM_BUFFER_ANCHOR sbaDone;  // 20 head for STREAM_BUFFER done queue anchor
  316.  STREAM_BUFFER_ANCHOR sbaEvent; // 24 head for STREAM_BUFFER event queue anchor
  317.  USHORT streamType;             // 28 eg,STREAM_WAVE_CAPTURE (==AUDIOHW_WAVE_CAPTURE)(org ULONG)
  318.  UCHAR  streamState;            // 30
  319.  UCHAR  counterIncFlag;         // 31 true if current time should be inc'ed every tick
  320.  ULONG  currentTime;            // 32 current time...
  321.  struct _WAVESTREAM *wsParentPtr;//36 pointer to parent wavestream (1-Feb-99, see below[1])
  322. } STREAM;                       // 38 bytes
  323. typedef STREAM *PSTREAM;
  324. // [1] need this link to the parent (*wsParentPtr) since stream.c calls to
  325. // wavestreamGetCurrentTime() which needs WAVESTREAM, not STREAM, pointer ... simple enough
  326. // -- this is also the only place to track wavestream pointers...since not stored anywhere else
  327. // see wavestreamInit() for more
  328.  
  329. typedef struct _STREAM_ANCHOR { // was "STREAM_HEAD" but anchor makes more sense
  330.  STREAM *headPtr;
  331.  STREAM *tailPtr;
  332. } STREAM_ANCHOR;
  333. typedef STREAM_ANCHOR *PSTREAM_ANCHOR;
  334.  
  335.  
  336. // --------------------------------------
  337. // wavaudio.c, structures, types, defines
  338.  
  339. #define DMA_BUFFER_SIZE ((ULONG)0xF000) // physical DMA buffer size (always 60KB)
  340.  
  341. // cs4232 specific defines
  342.  
  343. #define FORMAT_BIT0     0x40
  344. #define CL_BIT          0x20
  345. #define STEREO_BIT      0x10
  346.  
  347. typedef struct _WAVECONFIG {
  348.  USHORT sampleRate;     // 00 I:sample rate (was ULONG)
  349.  USHORT silence;        // 02 I:data for silence
  350.  UCHAR  bitsPerSample;  // 04 I:bits per sample (was ULONG)
  351.  UCHAR  channels;       // 05 I:channels (was ULONG)
  352.  USHORT dataType;       // 06 I:data type (PCM, muLaw...) (was ULONG)
  353.  ULONG  consumeRate;    // 08 O:bytes consumed/produced each sec
  354.  ULONG  bytesPerIRQ;    // 12 O:bytes consumed/produced per IRQ
  355. } WAVECONFIG;           // 16 bytes
  356. typedef WAVECONFIG *PWAVECONFIGINFO;
  357.  
  358. #define FLAGS_WAVEAUDIO_FULLDUPLEX  1   // can do full-duplex (has separate DMA for play/rec)
  359. #define FLAGS_WAVEAUDIO_DMA16       2   // dma channel is 16-bit
  360. #define FLAGS_WAVEAUDIO_FTYPEDMA    4   // hardware support demand-mode dma
  361.  
  362. // WAVEAUDIO has just about everything needed for a device
  363. // (one WAVEAUDIO for a PLAY device, another for a RECORD device)
  364. // removed dmaCh/dmaChSec since don't really need them (dmaCh is already in AUDIOBUFFER *abPtr)
  365. // and since that makes the code just more hardware specific
  366.  
  367. // AUDIOHW *ahwPtr;       // 02 has devType, and function pointers (xx bytes)
  368. // AUDIOBUFFER *abPtr;    // 08 yup, -> ab structure  (72 bytes) alloc in waSetup()
  369.  
  370. typedef struct _WAVEAUDIO {
  371.  USHORT flags;          // 00 see FLAGS_* above
  372.  USHORT devType;        // 02 AUDIOHW_* device type (was  AUDIOHW *ahwPtr;)
  373.  USHORT irq;            // 04 irq level
  374.  NPFN irqHandlerPtr;    // 06 irq handler function pointer (uses offset only, always CS-relative)
  375.  UCHAR  clockSelectData;// 08 hardware-specific clock select data (ix8)
  376.  UCHAR  formatData;     // 09 hardware-specific format data (ix8/28)
  377.  USHORT countData;      // 10 hardware-specific count data (ix14-15/30-31)
  378.  AUDIOBUFFER ab;        // 12 (72 bytes) (was  AUDIOBUFFER *abPtr, once allocated in waSetup()
  379. } WAVEAUDIO;            // 84 bytes
  380. typedef WAVEAUDIO *PWAVEAUDIO;
  381.  
  382.  
  383. // --------------------------------------
  384. // wavestrm.c, structures, types, defines
  385.  
  386. #define ALIGN_FILL_PLAY    0xFFFFFC00   // original was 0xFFFFFFFC
  387. #define ALIGN_FILL_CAPTURE 0xFFFFFC00   // original was 0xFFFFFFFC
  388.  
  389. typedef struct _WAVESTREAM {    // streamPtr->wsParentPtr is only way to find this
  390.  STREAM *streamPtr;             // 00
  391.  WAVEAUDIO *waPtr;              // 02
  392.  WAVECONFIG waveConfig;         // 04 (16 bytes)
  393.  USHORT audioBufferSize;        // 20 logical DMA buffer size for THIS wavestream! (tbi)
  394.  USHORT audioBufferInts;        // 22 interrupts per buffer (def=0, which is two per buffer)
  395.  ULONG  bytesProcessed;         // 24
  396.  ULONG  timeBase;               // 28 in ms, MMPM/2 send for stream time...
  397. } WAVESTREAM;                   // 32 bytes
  398. typedef WAVESTREAM *PWAVESTREAM;
  399.  
  400.  
  401. // --------------------------------------
  402. // waveplay.c, structures, types, defines
  403.  
  404. extern WAVEAUDIO wap;
  405.  
  406.  
  407. // -------------------------------------
  408. // waverec.c, structures, types, defines
  409.  
  410. extern WAVEAUDIO war;
  411.  
  412.  
  413. // -------------------------------------
  414. // protos
  415. // -------------------------------------
  416.  
  417.  
  418. // -----------------
  419. // audiobuf.c protos
  420.  
  421. VOID   abReset(USHORT mode, AUDIOBUFFER *audioBufferPtr);
  422. ULONG  abSpace(AUDIOBUFFER *audioBufferPtr);
  423. ULONG  abBytes(AUDIOBUFFER *audioBufferPtr);
  424. ULONG  abUpdate(USHORT flags, AUDIOBUFFER *audioBufferPtr);
  425. ULONG  abWrite(UCHAR __far *dataPtr, ULONG dataSize, AUDIOBUFFER *audioBufferPtr);
  426. ULONG  abRead(UCHAR __far *dataPtr, ULONG dataSize, AUDIOBUFFER *audioBufferPtr);
  427. VOID   abFill(USHORT fillWith, AUDIOBUFFER *audioBufferPtr);
  428. VOID   abDeinit(AUDIOBUFFER *audioBufferPtr);
  429. USHORT abInit(ULONG bufferSize, ULONG pageSize, USHORT dmaChannel, AUDIOBUFFER *audioBufferPtr);
  430.  
  431.  
  432. // ----------------
  433. // audiohw.c protos
  434.  
  435. USHORT   hwGetType(USHORT dataType, USHORT opType, USHORT lDev);
  436. USHORT   hwSetType(USHORT devType, USHORT dataType, USHORT opType, USHORT lDev);
  437.  
  438.  
  439. // ----------------
  440. // chipset.c protos
  441.  
  442. UCHAR  chipsetGET(USHORT type, USHORT reg);  // upper-case GET to spot from chipsetSet
  443. VOID   chipsetSet(USHORT type, USHORT reg, UCHAR data);
  444. VOID   chipsetMCE(USHORT mode);
  445. USHORT chipsetSetDTM(USHORT dtmFlag);
  446. USHORT chipsetInit(USHORT bp, USHORT cp, USHORT mode, USHORT make);
  447. USHORT chipsetIntPending(USHORT type);
  448. VOID   chipsetIntReset(USHORT type);
  449. UCHAR  chipsetWaitInit(VOID);
  450. UCHAR  chipsetWaitACI(VOID);
  451.  
  452.  
  453. // ------------
  454. // dma.c protos
  455.  
  456. ULONG  dmaQueryDelta(AUDIOBUFFER *audioBufferPtr);
  457. VOID   dmaWaitForChannel(USHORT count, AUDIOBUFFER *audioBufferPtr);
  458. VOID   dmaStart(AUDIOBUFFER *audioBufferPtr);
  459. VOID   dmaStop(AUDIOBUFFER *audioBufferPtr);
  460. USHORT dmaSetModeType(AUDIOBUFFER *audioBufferPtr, USHORT mode);
  461. USHORT dmaInit(USHORT dmaChannel, USHORT dmaType, AUDIOBUFFER *audioBufferPtr);
  462. USHORT dmaDeinit(AUDIOBUFFER *audioBufferPtr);
  463.  
  464.  
  465. // -------------
  466. // init.c protos
  467.  
  468. USHORT stratMode2Init(REQPACK __far *rpPtr);
  469.  
  470.  
  471. // ---------------
  472. // ioctl.c protos
  473.  
  474. VOID ioctlStrat(REQPACK __far *rpPtr, USHORT lDev);
  475.  
  476.  
  477. // ------------
  478. // irq.c protos
  479.  
  480. VOID __far __loadds irqHandler(VOID);
  481. USHORT irqEnable(USHORT irqNo);
  482. USHORT irqDisable(USHORT irqNo);
  483.  
  484.  
  485. // --------------
  486. // strat.c protos
  487.  
  488. ULONG tracePerf(USHORT minor, ULONG data);
  489. VOID  traceCalibrate(VOID);
  490.  
  491. VOID __far stratMode2(REQPACK __far *rpPtr);
  492.  
  493.  
  494. // ----------------
  495. // ssm_idc.c protos
  496.  
  497. ULONG __far __loadds __cdecl idcDDCMD(DDCMDCOMMON __far *commonPtr);
  498.  
  499.  
  500. // ---------------
  501. // stream.c protos
  502.  
  503. VOID    streamReturnBuffer(STREAM *streamPtr);
  504. VOID    streamReturnBuffers(STREAM *streamPtr);
  505. USHORT  streamPauseTime(STREAM *streamPtr);
  506. USHORT  streamResumeTime(STREAM *streamPtr);
  507. USHORT  streamRegister(DDCMDREGISTER __far *cmdPtr, STREAM *streamPtr);
  508. VOID    streamDeregister(STREAM *streamPtr);
  509. USHORT  streamRead(UCHAR __far *bufferPtr, ULONG length, STREAM *streamPtr);
  510. USHORT  streamWrite(UCHAR __far *bufferPtr, ULONG length, STREAM *streamPtr);
  511. USHORT  streamInit(USHORT streamType, STREAM *streamPtr);
  512. USHORT  streamDeinit(STREAM *streamPtr);
  513. STREAM *streamFindActive(USHORT streamType);
  514. STREAM *streamFindStreamSFN(USHORT SFN);
  515. STREAM *streamFindStreamHandle(HSTREAM streamH);
  516.  
  517. STREAM_BUFFER *sbHead(STREAM_BUFFER_ANCHOR *sbaPtr);  // stream buffer queue support
  518. STREAM_BUFFER *sbTail(STREAM_BUFFER_ANCHOR *sbaPtr);
  519. VOID           sbPushOnHead(STREAM_BUFFER *sbPtr, STREAM_BUFFER_ANCHOR *sbaPtr);
  520. VOID           sbPushOnTail(STREAM_BUFFER *sbPtr, STREAM_BUFFER_ANCHOR *sbaPtr);
  521. STREAM_BUFFER *sbPopHead(STREAM_BUFFER_ANCHOR *sbaPtr);
  522. STREAM_BUFFER *sbPopTail(STREAM_BUFFER_ANCHOR *sbaPtr);
  523. USHORT         sbDestroyElement(STREAM_BUFFER *sbPtr, STREAM_BUFFER_ANCHOR *sbaPtr);
  524. STREAM_BUFFER *sbPopElement(STREAM_BUFFER *match_sbPtr, STREAM_BUFFER_ANCHOR *sbaPtr);
  525. USHORT         sbNotEmpty(STREAM_BUFFER_ANCHOR *sbaPtr);
  526.  
  527. STREAM *streamHead(VOID);  // stream queue support
  528. STREAM *streamTail(VOID);
  529. VOID    streamPushOnHead(STREAM *sPtr);
  530. VOID    streamPushOnTail(STREAM *sPtr);
  531. STREAM *streamPopHead(VOID);
  532. STREAM *streamPopTail(VOID);
  533. USHORT  streamDestroyElement(STREAM *sPtr);     // doesn't seem to be used
  534. STREAM *streamPopElement(STREAM *match_sPtr);
  535. USHORT  streamNotEmpty(VOID);                   // doesn't seem to be used
  536.  
  537. // not yet done in stream.c are several event routines...these are temporary stubs
  538.  
  539. VOID streamProcessEvents(STREAM *streamPtr) ;
  540. VOID streamEnableEvent(DDCMDCONTROL __far *ddcmdPtr, STREAM *streamPtr);
  541. VOID streamDisableEvent(DDCMDCONTROL __far *ddcmdPtr, STREAM *streamPtr);
  542. VOID streamSetNextEvent(STREAM *streamPtr);
  543.  
  544.  
  545. // -----------------
  546. // wavaudio.c protos
  547.  
  548. VOID   waDevCaps(MCI_AUDIO_CAPS __far *devCapsPtr);
  549. VOID   waConfigDev(WAVESTREAM *wsPtr);
  550. USHORT waPause(VOID);
  551. USHORT waResume(VOID);
  552. USHORT waSetup(USHORT dmaChannel, WAVEAUDIO *waPtr);
  553.  
  554.  
  555. // -----------------
  556. // wavestrm.c protos
  557.  
  558. VOID    wavestreamProcess(WAVESTREAM *wsPtr);
  559. ULONG   wavestreamGetCurrentTime(WAVESTREAM *wsPtr);
  560. VOID    wavestreamSetCurrentTime(ULONG time, WAVESTREAM *wsPtr);
  561. USHORT  wavestreamStart(WAVESTREAM *wsPtr);
  562. USHORT  wavestreamStop(WAVESTREAM *wsPtr);
  563. USHORT  wavestreamPause(WAVESTREAM *wsPtr);
  564. USHORT  wavestreamResume(WAVESTREAM *wsPtr);
  565. STREAM *wavestreamInit(USHORT streamType, MCI_AUDIO_INIT __far *mciInitPtr, WAVESTREAM *wsPtr);
  566. USHORT  wavestreamDeinit(WAVESTREAM *wsPtr);
  567.  
  568.  
  569. // -----------------
  570. // waveplay.c protos
  571.  
  572. USHORT waveplayStart(WAVESTREAM *wsPtr);
  573. USHORT waveplayStop(WAVESTREAM *wsPtr);
  574. USHORT waveplayEnable(WAVESTREAM *wsPtr);
  575. USHORT waveplayInit(USHORT dmaChannel, USHORT flags, USHORT irq);
  576.  
  577.  
  578. // ----------------
  579. // waverec.c protos
  580.  
  581. USHORT waverecStart(WAVESTREAM *wsPtr);
  582. USHORT waverecStop(WAVESTREAM *wsPtr);
  583. USHORT waverecEnable(WAVESTREAM *wsPtr);
  584. USHORT waverecInit(USHORT dmaChannel, USHORT flags, USHORT irq);
  585.  
  586.  
  587. // -----------------
  588. // ddprintf.c protos
  589. // Note: if "%s" then string pointer in the ,... section must be a FAR POINTER!
  590. //       eg, ddprintf(dest,"%s",(char __far *)"a string")  see ras40 source for more
  591.  
  592. VOID __cdecl ddprintf (char far *St , ...);  // max buffer output is (probably) set to 260 bytes
  593. //VOID ddputstring (char far *St);
  594.  
  595.  
  596. // -----------------
  597. // malloc.c protos
  598.  
  599. VOID _near *malloc(USHORT bytes);
  600. VOID        free(VOID __near *ptr);
  601. VOID _near *realloc(VOID __near *ptr, USHORT bytes);
  602. unsigned    _msize(VOID __near *ptr);
  603. unsigned    _memfree(VOID);
  604. unsigned    HeapInit(USHORT);
  605. void        dumpheap(VOID);
  606.  
  607.  
  608. // ----------------
  609. // segments.asm
  610.  
  611. VOID iodelay(USHORT count);
  612. #pragma aux iodelay parm nomemory [cx] modify nomemory exact [ax cx];
  613.  
  614.  
  615.  
  616. // -------------------------
  617. // hw/chip defines/constants
  618.  
  619. #define WAIT_1US              2  // 500 ns waits for 1 us
  620. #define WAIT_10US            20  // 500 ns waits for 10 us
  621. #define WAIT_1MS           2000  // 500 ns waits for 1 ms
  622. #define WAIT_2MS           4000  // 500 ns waits for 1 ms
  623. #define WAIT_5MS          10000  // 500 ns waits for 5 ms
  624.  
  625. #define DMA_WAIT 362
  626.  
  627. #define ADDRESS_MASK    0xE0
  628. #define IREG_MASK       0x1F
  629. #define MCE_BIT         0x40
  630. #define MCE_ON          MCE_BIT
  631. #define MCE_OFF         ~(MCE_ON)
  632. #define INIT_BIT        0x80
  633. #define ACI_BIT         0x20
  634.  
  635. #define CALIBRATE_NONE       0x00
  636. #define CALIBRATE_CONVERTERS 0x08
  637. #define CALIBRATE_DACS       0x10
  638. #define CALIBRATE_ALL        0x18
  639.  
  640. #define PLAY_INTERRUPT       0x10
  641. #define CAPTURE_INTERRUPT    0x20
  642. #define TIMER_INTERRUPT      0x40
  643. #define ALL_INTERRUPTS       0x70
  644. #define CLEAR_PI             0x6F
  645. #define CLEAR_CI             0x5F
  646. #define CLEAR_TI             0x3F
  647.  
  648. #define ADDRESS_REG     0
  649. #define DATA_REG        1
  650. #define STATUS_REG      2
  651.  
  652. #define LEFT_ADC_INPUT_CONTROL   0x00
  653. #define RIGHT_ADC_INPUT_CONTROL  0x01
  654. #define LEFT_AUX1_INPUT_CONTROL  0x02
  655. #define RIGHT_AUX1_INPUT_CONTROL 0x03
  656. #define LEFT_AUX2_INPUT_CONTROL  0x04
  657. #define RIGHT_AUX2_INPUT_CONTROL 0x05
  658. #define LEFT_DAC_OUTPUT_CONTROL  0x06
  659. #define RIGHT_DAC_OUTPUT_CONTROL 0x07
  660. #define PLAYBACK_DATA_FORMAT_REG 0x08
  661. #define INTERFACE_CONFIG_REG     0x09
  662. #define PIN_CONTROL_REG          0x0A
  663. #define ERROR_STATUS_INIT_REG    0x0B
  664. #define MODE_AND_ID_REG          0x0C
  665. #define LOOPBACK_CONTROL_REG     0x0D
  666. #define UPPER_PLAYBACK_COUNT     0x0E
  667. #define LOWER_PLAYBACK_COUNT     0x0F
  668. #define ALT_FEATURE_ENABLE_1     0x10
  669. #define ALT_FEATURE_ENABLE_2     0x11
  670. #define LEFT_LINE_INPUT_CONTROL  0x12
  671. #define RIGHT_LINE_INPUT_CONTROL 0x13
  672. #define LOWER_TIMER_COUNT        0x14
  673. #define UPPER_TIMER_COUNT        0x15
  674. #define ALT_SAMPLE_FREQ_SELECT   0x16
  675. #define ALT_FEATURE_ENABLE_3     0x17
  676. #define ALT_FEATURE_STATUS       0x18
  677. #define VERSION_ID_REG           0x19
  678. #define MONO_IO_CONTROL          0x1A
  679. #define LEFT_OUTPUT_CONTROL      0x1B
  680. #define CAPTURE_DATA_FORMAT_REG  0x1C
  681. #define RIGHT_OUTPUT_CONTROL     0x1D
  682. #define UPPER_CAPTURE_COUNT      0x1E
  683. #define LOWER_CAPTURE_COUNT      0x1F
  684.  
  685.  
  686. #define CS40_INCL
  687. #endif
  688.  
  689.  
  690.  
  691.  
  692.  
  693.