00001 #ifndef __MK__MachMessages_H___
00002 #define __MK__MachMessages_H___
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #import <mach/mach_types.h>
00023 #import <mach/message.h>
00024
00025
00026
00027
00028 typedef struct {
00029 int typeType;
00030 unsigned int type;
00031 #define SND_MT_PLAY_DATA 0 // data to be played (with size)
00032 #define SND_MT_RECORD_DATA 1 // number of bytes to record
00033 #define SND_MT_OPTIONS 2 // high/low water and dma size options
00034 #define SND_MT_CONTROL 3 // await/abort/pause/continue
00035 #define SND_MT_NDMA 4 // number of dma descs in stream.
00036 } snd_msg_type_t;
00037
00038
00039
00040
00041
00042
00043
00044
00045 typedef struct {
00046 mach_msg_header_t header;
00047 int data_tagType;
00048 int data_tag;
00049 int dataType;
00050 pointer_t recorded_data;
00051 } snd_recorded_data_t;
00052
00053 typedef struct {
00054 mach_msg_header_t header;
00055 int data_tagType;
00056 int data_tag;
00057 } snd_taged_reply_t;
00058
00059 typedef struct {
00060 mach_msg_header_t header;
00061 int dataType;
00062 int nsamples;
00063 } snd_ret_samples_t;
00064
00065 typedef struct {
00066 mach_msg_header_t header;
00067 int dataType;
00068 unsigned int parms;
00069 #define SND_PARM_LOWPASS 0x1
00070 #define SND_PARM_SPEAKER 0x2
00071 #define SND_PARM_ZEROFILL 0x4
00072 } snd_ret_parms_t;
00073
00074 typedef struct {
00075 mach_msg_header_t header;
00076 int dataType;
00077 unsigned int volume;
00078 #define SND_VOLUME_RCHAN_MASK 0xff
00079 #define SND_VOLUME_RCHAN_SHIFT 0
00080 #define SND_VOLUME_LCHAN_MASK 0xff00
00081 #define SND_VOLUME_LCHAN_SHIFT 8
00082 } snd_ret_volume_t;
00083
00084 typedef struct {
00085 mach_msg_header_t header;
00086 int dataType;
00087 int dsp_regs;
00088 } snd_ret_dsp_regs_t;
00089
00090 typedef struct {
00091 mach_msg_header_t header;
00092 int dataType;
00093 unsigned int ill_msgid;
00094 unsigned int ill_error;
00095 #define SND_NO_ERROR 100 // non-error ack.
00096 #define SND_BAD_PORT 101 // message sent to wrong port
00097 #define SND_BAD_MSG 102 // unknown message id
00098 #define SND_BAD_PARM 103 // bad parameter list in message
00099 #define SND_NO_MEMORY 104 // can't allocate memory (record)
00100 #define SND_PORT_BUSY 105 // access req'd to existing excl access port
00101 #define SND_NOT_OWNER 106 // must be owner to do this
00102 #define SND_BAD_CHAN 107 // dsp channel hasn't been inited
00103 #define SND_SEARCH 108 // couldn't find requested resource
00104 #define SND_NODATA 109 // can't send data commands to dsp in this mode
00105 #define SND_NOPAGER 110 // can't allocate from external pager (record).
00106 #define SND_NOTALIGNED 111 // bad data alignment.
00107 #define SND_BAD_HOST_PRIV 112 // bad host privilege port passed.
00108 #define SND_BAD_PROTO 113 // can't do requested operation given protocol
00109 } snd_illegal_msg_t;
00110
00111 typedef struct {mach_msg_header_t header;} snd_ret_mach_port_t;
00112
00113 typedef struct {
00114 mach_msg_header_t header;
00115 int dataType;
00116 unsigned int mask;
00117 unsigned int flags;
00118 unsigned int value;
00119 } snd_dsp_cond_true_t;
00120
00121
00122
00123
00124 typedef struct {
00125 mach_msg_header_t header;
00126 int Type;
00127 unsigned int stream;
00128 int ownerType;
00129 mach_port_t owner;
00130 } snd_get_stream_t;
00131
00132 #define SND_GD_CHAN_MASK 0x7f
00133 #define SND_GD_CHAN_SHIFT 0
00134 #define SND_GD_DEVICE_MASK 0x80
00135 #define SND_GD_DEVICE_SHIFT 7
00136
00137 #define snd_gd_bitmap(chan, device) \
00138 (((chan)<<SND_GD_CHAN_SHIFT) | ((device)<<SND_GD_DEVICE_SHIFT))
00139
00140 #define snd_gd_isdevice(bitmap) ((bitmap)&SND_GD_DEVICE_MASK)
00141 #define snd_gd_chan(bitmap) ((bitmap)&SND_GD_CHAN_MASK)
00142
00143 #define SND_GD_SOUT_44 snd_gd_bitmap(0, TRUE)
00144 #define SND_GD_SOUT_22 snd_gd_bitmap(1, TRUE)
00145 #define SND_GD_SIN snd_gd_bitmap(2, TRUE)
00146 #define SND_GD_DSP_OUT snd_gd_bitmap(DSP_SO_CHAN, FALSE) // sound out from dsp
00147 #define SND_GD_DSP_IN snd_gd_bitmap(DSP_SI_CHAN, FALSE) // sound in to dsp
00148
00149 typedef struct {
00150 mach_msg_header_t header;
00151 int Type;
00152 unsigned int parms;
00153 } snd_set_parms_t;
00154
00155 typedef struct {
00156 mach_msg_header_t header;
00157 int Type;
00158 unsigned int volume;
00159 } snd_set_volume_t;
00160
00161 typedef struct {
00162 mach_msg_header_t header;
00163 int Type;
00164 unsigned int proto;
00165 int ownerType;
00166 mach_port_t owner;
00167 } snd_dsp_proto_t;
00168
00169 #define SND_DSP_PROTO_DSPERR 0x1 // DSP error messages enabled
00170 #define SND_DSP_PROTO_C_DMA 0x2 // complex dma mode
00171 #define SND_DSP_PROTO_S_DMA 0x4 // simple dma mode
00172 #define SND_DSP_PROTO_LINKOUT 0x8 // link directly to sound out
00173 #define SND_DSP_PROTO_LINKIN 0x10 // link directly to sound out
00174 #define SND_DSP_PROTO_SOUNDDATA 0x20 // all data to dsp is sound samples
00175 #define SND_DSP_PROTO_HIGH 0x40 // 44khz sound out
00176 #define SND_DSP_PROTO_HFABORT 0x80 // DSP abort indicated by HF2 & HF3
00177 #define SND_DSP_PROTO_DSPMSG 0x100 // DSP messages enabled
00178 #define SND_DSP_PROTO_RAW 0x200 // DSP messages enabled
00179 #define SND_DSP_PROTO_TXD 0x400 // DSP txd interrupt enable (040 only)
00180
00181 typedef mach_msg_header_t snd_get_parms_t;
00182 typedef mach_msg_header_t snd_get_volume_t;
00183
00184 typedef struct {
00185 mach_msg_header_t header;
00186 int ownerType;
00187 mach_port_t owner;
00188 } snd_get_dsp_cmd_mach_port_t;
00189
00190 typedef struct {
00191 mach_msg_header_t header;
00192 int negType;
00193 mach_port_t negotiation;
00194 int ownerType;
00195 mach_port_t owner;
00196 } snd_set_owner_t;
00197
00198 typedef struct {
00199 mach_msg_header_t header;
00200 int old_ownerType;
00201 mach_port_t old_owner;
00202 int new_ownerType;
00203 mach_port_t new_owner;
00204 int new_negotiationType;
00205 mach_port_t new_negotiation;
00206 } snd_reset_owner_t;
00207
00208 typedef struct {
00209 mach_msg_header_t header;
00210 int privType;
00211 mach_port_t priv;
00212 } snd_new_device_t;
00213
00214 typedef struct {
00215 mach_msg_header_t header;
00216 int dataType;
00217 #define DSP_DEF_BUFSIZE 512 // default #words in each buf
00218 unsigned int data[DSP_DEF_BUFSIZE];
00219 } snd_dsp_msg_t;
00220
00221 typedef struct {
00222 mach_msg_header_t header;
00223 int dataType;
00224 #define DSP_DEF_EBUFSIZE 32 // default #words in each buf
00225 unsigned int data[DSP_DEF_EBUFSIZE];
00226 } snd_dsp_err_t;
00227
00228
00229
00230
00231
00232
00233 typedef struct snd_stream_msg {
00234 mach_msg_header_t header;
00235 int data_tagType;
00236 int data_tag;
00237 } snd_stream_msg_t;
00238
00239 typedef struct {
00240 snd_msg_type_t msgtype;
00241 int optionsType;
00242 unsigned int options;
00243 #define SND_DM_STARTED_MSG 0x01
00244 #define SND_DM_COMPLETED_MSG 0x02
00245 #define SND_DM_ABORTED_MSG 0x04
00246 #define SND_DM_PAUSED_MSG 0x08
00247 #define SND_DM_RESUMED_MSG 0x10
00248 #define SND_DM_OVERFLOW_MSG 0x20
00249 #define SND_DM_PREEMPT 0x40
00250 int reg_portType;
00251 mach_port_t reg_port;
00252 int dataType;
00253 pointer_t data;
00254 } snd_stream_play_data_t;
00255
00256 typedef struct {
00257 snd_msg_type_t msgtype;
00258 int optionsType;
00259 unsigned int options;
00260 int nbytes;
00261 int reg_portType;
00262 mach_port_t reg_port;
00263 int filenameType;
00264 } snd_stream_record_data_t;
00265
00266 typedef struct {
00267 snd_msg_type_t msgtype;
00268 int controlType;
00269 unsigned int snd_control;
00270 #define SND_DC_AWAIT 0x1
00271 #define SND_DC_ABORT 0x2
00272 #define SND_DC_PAUSE 0x4
00273 #define SND_DC_RESUME 0x8
00274 } snd_stream_control_t;
00275
00276 typedef struct {
00277 snd_msg_type_t msg_type;
00278 int optionsType;
00279 unsigned int high_water;
00280 unsigned int low_water;
00281 unsigned int dma_size;
00282 } snd_stream_options_t;
00283
00284
00285
00286
00287 typedef struct {
00288 snd_msg_type_t msg_type;
00289 int ndmaType;
00290 unsigned int ndma;
00291 } snd_stream_ndma_t;
00292
00293
00294
00295
00296 typedef struct {
00297 mach_msg_header_t header;
00298 } snd_stream_nsamples_t;
00299
00300
00301
00302
00303 typedef struct {
00304 mach_msg_header_t header;
00305 int reg_maskType;
00306 unsigned int mask;
00307 unsigned int flags;
00308 int ret_portType;
00309 mach_port_t ret_port;
00310 int ret_msgType;
00311
00312
00313
00314
00315 mach_msg_header_t ret_msg;
00316 } snd_dspcmd_event_t;
00317
00318 typedef struct {
00319 mach_msg_header_t header;
00320 int dataType;
00321 int addr;
00322 int size;
00323 int skip;
00324 #define DSP_SKIP_0 1
00325 #define DSP_SKIP_CONTIG DSP_SKIP_0
00326 #define DSP_SKIP_1 2
00327 #define DSP_SKIP_2 3
00328 #define DSP_SKIP_3 4
00329 #define DSP_SKIP_4 5
00330 int space;
00331 #define DSP_SPACE_X 1
00332 #define DSP_SPACE_Y 2
00333 #define DSP_SPACE_L 3
00334 #define DSP_SPACE_P 4
00335 int mode;
00336 #define DSP_MODE8 1
00337 #define DSP_MODE16 2
00338 #define DSP_MODE24 3
00339 #define DSP_MODE32 4
00340 #define DSP_MODE2416 5
00341 #define SND_MODE_MIN 1
00342 #define SND_MODE_MAX 5
00343 int chan;
00344 #define DSP_USER_REQ_CHAN 0 // for user-requested dma's
00345 #define DSP_SO_CHAN 1 // for sound-out dma's.
00346 #define DSP_SI_CHAN 2 // for sound-in dma's
00347 #define DSP_USER_CHAN 3 // first user chan
00348
00349 #define DSP_N_USER_CHAN 16 // 0..15 for user dma.
00350 } snd_dspcmd_chandata_t;
00351
00352 typedef struct {
00353 mach_msg_header_t header;
00354 int chandataType;
00355 int addr;
00356 int size;
00357 int skip;
00358 int space;
00359 int mode;
00360 int dataType;
00361 pointer_t data;
00362 } snd_dspcmd_dma_t;
00363
00364 typedef mach_msg_header_t snd_dspcmd_abortdma_t;
00365 typedef mach_msg_header_t snd_dspcmd_req_err_t;
00366 typedef mach_msg_header_t snd_dspcmd_req_msg_t;
00367
00368
00369
00370
00371
00372
00373
00374 typedef struct {
00375 int typeType;
00376 unsigned int type;
00377 #define SND_DSP_MT_DATA 1 // 1, 2, or 4 byte data
00378 #define SND_DSP_MT_HOST_COMMAND 2 // host command
00379 #define SND_DSP_MT_HOST_FLAG 3 // host flag(s) to set
00380 #define SND_DSP_MT_RET_MSG 4 // (simple) message to send
00381 #define SND_DSP_MT_RESET 5 // hard reset the DSP
00382 #define SND_DSP_MT_GET_REGS 6 // return DSP host I/F registers
00383 #define SND_DSP_MT_CONDITION 7 // wait for condition (return msg)
00384 #define SND_DSP_MT_RDATA 8 // read 1, 2, or 4 byte data
00385 #define SND_DSP_MT_PROTO 9 // DSP protocol
00386 } snd_dsp_type_t;
00387
00388 typedef struct {
00389 mach_msg_header_t header;
00390 int priType;
00391 int pri;
00392 #define DSP_MSG_HIGH 0
00393 #define DSP_MSG_MED 1
00394 #define DSP_MSG_LOW 2
00395 boolean_t atomic;
00396 } snd_dspcmd_msg_t;
00397
00398 typedef struct {
00399 snd_dsp_type_t msgtype;
00400 int conditionType;
00401 unsigned int mask;
00402 unsigned int flags;
00403 int reply_portType;
00404 mach_port_t reply_port;
00405 } snd_dsp_condition_t;
00406
00407 typedef struct {
00408 snd_dsp_type_t msgtype;
00409 int dataType;
00410 pointer_t data;
00411 } snd_dsp_data_t;
00412
00413 typedef struct {
00414 snd_dsp_type_t msgtype;
00415 int hcType;
00416 unsigned int hc;
00417 } snd_dsp_host_command_t;
00418
00419 typedef struct {
00420 snd_dsp_type_t msgtype;
00421 int protoType;
00422 unsigned int proto;
00423 } snd_dsp_mt_proto_t;
00424
00425 typedef struct {
00426 snd_dsp_type_t msgtype;
00427 int hfType;
00428 unsigned int mask;
00429 unsigned int flags;
00430 } snd_dsp_host_flag_t;
00431
00432 typedef struct {
00433 snd_dsp_type_t msgtype;
00434 int ret_portType;
00435 mach_port_t ret_port;
00436 int ret_msgType;
00437
00438
00439
00440
00441 mach_msg_header_t ret_msg;
00442 } snd_dsp_ret_msg_t;
00443
00444 typedef struct {
00445 snd_dsp_type_t msgtype;
00446 } snd_dsp_reset_t, snd_dsp_get_regs_t;
00447
00448
00449
00450
00451 #define SND_MSG_BASE 0
00452
00453
00454
00455
00456 #define SND_MSG_STREAM_BASE SND_MSG_BASE+0
00457 #define SND_MSG_STREAM_MSG SND_MSG_STREAM_BASE+0
00458 #define SND_MSG_STREAM_NSAMPLES SND_MSG_STREAM_BASE+1
00459
00460
00461
00462
00463 #define SND_MSG_DEVICE_BASE SND_MSG_BASE+100
00464 #define SND_MSG_GET_STREAM SND_MSG_DEVICE_BASE+0
00465 #define SND_MSG_SET_PARMS SND_MSG_DEVICE_BASE+1
00466 #define SND_MSG_GET_PARMS SND_MSG_DEVICE_BASE+2
00467 #define SND_MSG_SET_VOLUME SND_MSG_DEVICE_BASE+3
00468 #define SND_MSG_GET_VOLUME SND_MSG_DEVICE_BASE+4
00469 #define SND_MSG_SET_DSPOWNER SND_MSG_DEVICE_BASE+5
00470 #define SND_MSG_SET_SNDINOWNER SND_MSG_DEVICE_BASE+6
00471 #define SND_MSG_SET_SNDOUTOWNER SND_MSG_DEVICE_BASE+7
00472 #define SND_MSG_DSP_PROTO SND_MSG_DEVICE_BASE+8
00473 #define SND_MSG_GET_DSP_CMD_PORT SND_MSG_DEVICE_BASE+9
00474 #define SND_MSG_NEW_DEVICE_PORT SND_MSG_DEVICE_BASE+10
00475 #define SND_MSG_RESET_DSPOWNER SND_MSG_DEVICE_BASE+11
00476 #define SND_MSG_RESET_SNDINOWNER SND_MSG_DEVICE_BASE+12
00477 #define SND_MSG_RESET_SNDOUTOWNER SND_MSG_DEVICE_BASE+13
00478 #define SND_MSG_SET_RAMP SND_MSG_DEVICE_BASE+14
00479
00480
00481
00482 #define SND_PARM_RAMPUP 0x1
00483 #define SND_PARM_RAMPDOWN 0x2
00484
00485
00486
00487
00488 #define SND_MSG_DSP_BASE SND_MSG_BASE+200
00489 #define SND_MSG_DSP_MSG SND_MSG_DSP_BASE+0
00490 #define SND_MSG_DSP_EVENT SND_MSG_DSP_BASE+1
00491 #define SND_MSG_DSP_CHANDATA SND_MSG_DSP_BASE+2
00492 #define SND_MSG_DSP_DMAOUT SND_MSG_DSP_BASE+3
00493 #define SND_MSG_DSP_DMAIN SND_MSG_DSP_BASE+4
00494 #define SND_MSG_DSP_ABORTDMA SND_MSG_DSP_BASE+5
00495 #define SND_MSG_DSP_REQ_MSG SND_MSG_DSP_BASE+6
00496 #define SND_MSG_DSP_REQ_ERR SND_MSG_DSP_BASE+7
00497
00498
00499
00500
00501 #define SND_MSG_KERN_BASE SND_MSG_BASE+300
00502 #define SND_MSG_RECORDED_DATA SND_MSG_KERN_BASE+0
00503 #define SND_MSG_TIMED_OUT SND_MSG_KERN_BASE+1
00504 #define SND_MSG_RET_SAMPLES SND_MSG_KERN_BASE+2
00505 #define SND_MSG_RET_DEVICE SND_MSG_KERN_BASE+3
00506 #define SND_MSG_RET_STREAM SND_MSG_KERN_BASE+4
00507 #define SND_MSG_RET_PARMS SND_MSG_KERN_BASE+5
00508 #define SND_MSG_RET_VOLUME SND_MSG_KERN_BASE+6
00509 #define SND_MSG_OVERFLOW SND_MSG_KERN_BASE+7
00510 #define SND_MSG_STARTED SND_MSG_KERN_BASE+9
00511 #define SND_MSG_COMPLETED SND_MSG_KERN_BASE+10
00512 #define SND_MSG_ABORTED SND_MSG_KERN_BASE+11
00513 #define SND_MSG_PAUSED SND_MSG_KERN_BASE+12
00514 #define SND_MSG_RESUMED SND_MSG_KERN_BASE+13
00515 #define SND_MSG_ILLEGAL_MSG SND_MSG_KERN_BASE+14
00516 #define SND_MSG_RET_DSP_ERR SND_MSG_KERN_BASE+15
00517 #define SND_MSG_RET_DSP_MSG SND_MSG_KERN_BASE+16
00518 #define SND_MSG_RET_CMD SND_MSG_KERN_BASE+17
00519 #define SND_MSG_DSP_REGS SND_MSG_KERN_BASE+18
00520 #define SND_MSG_DSP_COND_TRUE SND_MSG_KERN_BASE+19
00521
00522
00523
00524
00525 #ifdef _IO
00526 #define SOUNDIOCDEVPORT _IO('A', 8)
00527 #endif _IO
00528
00529
00530
00531
00532 #if KERNEL
00533 kern_return_t snd_reply_recorded_data (
00534 mach_port_t remote_port,
00535 int data_tag,
00536 pointer_t data,
00537 int nbytes,
00538 int in_line);
00539 kern_return_t snd_reply_timed_out (
00540 mach_port_t remote_port,
00541 int data_tag);
00542 kern_return_t snd_reply_ret_samples (
00543 mach_port_t remote_port,
00544 int nsamples);
00545 kern_return_t snd_reply_ret_device (
00546 mach_port_t remote_port,
00547 mach_port_t device_port);
00548 kern_return_t snd_reply_ret_stream (
00549 mach_port_t remote_port,
00550 mach_port_t stream_port);
00551 kern_return_t snd_reply_ret_parms (
00552 mach_port_t remote_port,
00553 unsigned int parms);
00554 kern_return_t snd_reply_ret_volume (
00555 mach_port_t remote_port,
00556 unsigned int volume);
00557 kern_return_t snd_reply_overflow (
00558 mach_port_t remote_port,
00559 int data_tag);
00560 kern_return_t snd_reply_started (
00561 mach_port_t remote_port,
00562 int data_tag);
00563 kern_return_t snd_reply_completed (
00564 mach_port_t remote_port,
00565 int data_tag);
00566 kern_return_t snd_reply_aborted (
00567 mach_port_t remote_port,
00568 int data_tag);
00569 kern_return_t snd_reply_paused (
00570 mach_port_t remote_port,
00571 int data_tag);
00572 kern_return_t snd_reply_resumed (
00573 mach_port_t remote_port,
00574 int data_tag);
00575 kern_return_t snd_reply_illegal_msg (
00576 mach_port_t local_port,
00577 mach_port_t remote_port,
00578 int msgh_id,
00579 int error);
00580 kern_return_t snd_reply_dsp_err (
00581 mach_port_t remote_port);
00582 kern_return_t snd_reply_dsp_msg (
00583 mach_port_t remote_port);
00584 kern_return_t snd_reply_dsp_cmd_port(
00585 mach_port_t cmd_port,
00586 mach_port_t remote_port);
00587 kern_return_t snd_reply_dsp_regs (
00588 int regs);
00589 kern_return_t snd_reply_dsp_cond_true (
00590 vm_address_t ret_cond);
00591 #endif KERNEL
00592
00593 #endif