home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / sound / sounddriver.h < prev    next >
Text File  |  1992-02-06  |  5KB  |  127 lines

  1. /*
  2.  *    sounddriver.h - functional sound/dsp driver interface.
  3.  *    Copyright 1988-90 NeXT, Inc.
  4.  *
  5.  */
  6.  
  7. #import <mach/mach.h>
  8. #import <mach/mach_init.h>
  9. #import <mach/message.h>
  10. #import <bsd/sys/types.h>
  11.  
  12. /*
  13.  * Valid sources and destination codes for stream setup
  14.  */
  15.  
  16. #define SNDDRIVER_STREAM_FROM_SNDIN            (1)
  17. #define SNDDRIVER_STREAM_TO_SNDOUT_22            (2)
  18. #define SNDDRIVER_STREAM_TO_SNDOUT_44            (3)
  19. #define SNDDRIVER_STREAM_FROM_DSP            (4)
  20. #define SNDDRIVER_STREAM_TO_DSP                (5)
  21. #define SNDDRIVER_STREAM_SNDIN_TO_DSP            (6)
  22. #define SNDDRIVER_STREAM_DSP_TO_SNDOUT_22        (7)
  23. #define SNDDRIVER_STREAM_DSP_TO_SNDOUT_44        (8)
  24. #define SNDDRIVER_STREAM_FROM_SNDIN_THROUGH_DSP        (9)
  25. #define SNDDRIVER_STREAM_THROUGH_DSP_TO_SNDOUT_22    (10)
  26. #define SNDDRIVER_STREAM_THROUGH_DSP_TO_SNDOUT_44    (11)
  27. /* New for 2.0 */
  28. #define SNDDRIVER_DMA_STREAM_TO_DSP            (12)
  29. #define SNDDRIVER_DMA_STREAM_FROM_DSP            (13)
  30. #define SNDDRIVER_DMA_STREAM_THROUGH_DSP_TO_SNDOUT_22    (14)
  31. #define SNDDRIVER_DMA_STREAM_THROUGH_DSP_TO_SNDOUT_44    (15)
  32.  
  33. /*
  34.  * Protocol options for the dsp (subset of <nextdev/snd_msgs.h> protocols)
  35.  */
  36. #define SNDDRIVER_DSP_PROTO_DSPERR    0x1    // DSP error messages enabled
  37. #define SNDDRIVER_DSP_PROTO_C_DMA    0x2    // Complex DMA mode
  38. #define SNDDRIVER_DSP_PROTO_S_DMA    0x4    // Simple DMA mode
  39. /* New for 2.0 */
  40. #define SNDDRIVER_DSP_PROTO_HFABORT    0x80    // Enable DSP abort on HF2&HF3
  41. #define SNDDRIVER_DSP_PROTO_DSPMSG    0x100    // DSP messages enabled
  42. #define SNDDRIVER_DSP_PROTO_RAW     0x200    // Enable raw DSP mode
  43.  
  44. /*
  45.  * DSP Host Commands used with protocol SNDDRIVER_DSP_PROTO_C_DMA.
  46.  * See on-line programming examples for usage.
  47.  */
  48. #define SNDDRIVER_DSP_HC_HOST_RD    (0x24>>1)     // Host Read Done
  49. #define SNDDRIVER_DSP_HC_HOST_WD    (0x28>>1)    // Host Write Done
  50. #define SNDDRIVER_DSP_HC_SYS_CALL    (0x2C>>1)    // System Call
  51.  
  52. /*
  53.  * Control codes for streams
  54.  */
  55. #define SNDDRIVER_AWAIT_STREAM        (0x1)
  56. #define SNDDRIVER_ABORT_STREAM        (0x2BSWefine SNDDRIVER_PAUSE_STREAM        (0x4)
  57. #define SNDDRIVER_RESUME_STREAM        (0x8)
  58.  
  59. /*
  60.  * Driver message priorities
  61.  */
  62. #define SNDDRIVER_LOW_PRIORITY        (2)
  63. #define SNDDRIVER_MED_PRIORITY        (1)
  64. #define SNDDRIVER_HIGH_PRIORITY        (0)
  65.  
  66. /*
  67.  * DSP Host Interface Bits
  68.  */
  69. #define SNDDRIVER_ICR_INIT      (0x80000000)    // settable
  70. #define SNDDRIVER_ICR_HM1       (0x40000000)    // settable mode bit
  71. #define SNDDRIVER_ICR_HM0       (0x20000000)    // settable mode bit
  72. #define SNDDRIVER_ICR_HF1       (0x10000000)    // settable host flag
  73. #define SNDDRIVER_ICR_HF0       (0x08000000)    // settable host flag
  74. #define SNDDRIVER_ICR_TREQ      (0x02000000)    // read-only, set by protocol
  75. #define SNDDRIVER_ICR_RREQ      (0x01000000)    // read-only, set by protocol
  76.  
  77. #define SNDDRIVER_CVR_HC        (0x00800000)    // read-only, set by host cmd
  78. #define SNDDRIVER_CVR_HV_MASK   (0x001F0000)    // read-only, set by host cmd
  79.  
  80. #define SNDDRIVER_ISR_HREQ      (0x00008000)    // readable host request flag
  81. #define SNDDRIVER_ISR_DMA       (0x00004000)    // readable dma-mode flag
  82. #define SNDDRIVER_ISR_HF3       (0x00001000)    // readable host flag
  83. #define SNDDRIVER_ISR_HF2       (0x00000800)    // readable host flag
  84. #define SNDDRIVER_ISR_TRDY      (0x00000400)    // readable status bit
  85. #define SNDDRIVER_ISR_TXDE      (0x00000200)    // readable status bit
  86. #define SNDDRIVER_ISR_RXDF      (0x00000100)    // readable status bit
  87.  
  88.  
  89. #include "snddriver_client.h"
  90.  
  91. /*
  92.  * Asynchronous return message parsing and callout (the reply server).
  93.  *
  94.  * The snddriver_reply_server implementation takes a pointer to a message 
  95.  * and a pointer to a structure containing the dispatch functions for
  96.  * each type of message. It parses the message and calls the
  97.  * appropriate procedure, and handles the reply message (if any).
  98.  */
  99.  
  100. typedef void (*sndreply_tagged_t)(void *arg, int tag);
  101. typedef void (*sndreply_recorded_data_t)(void *arg, int tag, 
  102.                      void *data, int size);
  103. typedef void (*sndreply_dsp_cond_true_t)(void *arg, u_int mask, 
  104.                      u_int flags, u_int regs);
  105. typedef void (*sndreply_dsp_msg_t)(void *arg, int *data, int size);
  106.  
  107. typedef struct snddriver_handlers {
  108.     void *            arg;
  109.     int                timeout;
  110.     sndreply_tagged_t        started;
  111.     sndreply_tagged_t        completed;
  112.     sndreply_tagged_t        aborted;
  113.     sndreply_tagged_t        paused;
  114.     sndreply_tagged_t        resumed;
  115.  BSXndreply_tagged_t        overflow;
  116.     sndreply_recorded_data_t    recorded_data;
  117.     sndreply_dsp_cond_true_t    condition_true;
  118.     sndreply_dsp_msg_t        dsp_message;
  119.     sndreply_dsp_msg_t        dsp_error;
  120.  } snddriver_handlers_t;
  121.  
  122. kern_return_t snddriver_reply_handler(
  123.     msg_header_t        *msg,        // message to parse
  124.     snddriver_handlers_t    *handlers);    // table of callout procs
  125.  
  126.  
  127.