Makefile: Add atusb to 'all'
[linux-libre-firmware.git] / aica / arm / aica_cmd_iface.h
1 /* KallistiOS ##version##
2
3    aica_cmd_iface.h
4    (c)2000-2002 Dan Potter
5
6    Definitions for the SH-4/AICA interface. This file is meant to be
7    included from both the ARM and SH-4 sides of the fence.
8 */
9
10 #ifndef __ARM_AICA_CMD_IFACE_H
11 #define __ARM_AICA_CMD_IFACE_H
12
13 #ifndef __ARCH_TYPES_H
14 typedef unsigned long uint8;
15 typedef unsigned long uint32;
16 #endif
17
18 /* Command queue; one of these for passing data from the SH-4 to the
19    AICA, and another for the other direction. If a command is written
20    to the queue and it is longer than the amount of space between the
21    head point and the queue size, the command will wrap around to
22    the beginning (i.e., queue commands _can_ be split up). */
23 typedef struct aica_queue {
24     uint32      head;       /* Insertion point offset (in bytes) */
25     uint32      tail;       /* Removal point offset (in bytes) */
26     uint32      size;       /* Queue size (in bytes) */
27     uint32      valid;      /* 1 if the queue structs are valid */
28     uint32      process_ok; /* 1 if it's ok to process the data */
29     uint32      data;       /* Pointer to queue data buffer */
30 } aica_queue_t;
31
32 /* Command queue struct for commanding the AICA from the SH-4 */
33 typedef struct aica_cmd {
34     uint32      size;       /* Command data size in dwords */
35     uint32      cmd;        /* Command ID */
36     uint32      timestamp;  /* When to execute the command (0 == now) */
37     uint32      cmd_id;     /* Command ID, for cmd/response pairs, or channel id */
38     uint32      misc[4];    /* Misc Parameters / Padding */
39     uint8       cmd_data[]; /* Command data */
40 } aica_cmd_t;
41
42 /* Maximum command size -- 256 dwords */
43 #define AICA_CMD_MAX_SIZE   256
44
45 /* This is the cmd_data for AICA_CMD_CHAN. Make this 16 dwords long
46    for two aica bus queues. */
47 typedef struct aica_channel {
48     uint32      cmd;        /* Command ID */
49     uint32      base;       /* Sample base in RAM */
50     uint32      type;       /* (8/16bit/ADPCM) */
51     uint32      length;     /* Sample length */
52     uint32      loop;       /* Sample looping */
53     uint32      loopstart;  /* Sample loop start */
54     uint32      loopend;    /* Sample loop end */
55     uint32      freq;       /* Frequency */
56     uint32      vol;        /* Volume 0-255 */
57     uint32      pan;        /* Pan 0-255 */
58     uint32      pos;        /* Sample playback pos */
59     uint32      pad[5];     /* Padding */
60 } aica_channel_t;
61
62 /* Declare an aica_cmd_t big enough to hold an aica_channel_t
63    using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR */
64 #define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
65     uint8   T[sizeof(aica_cmd_t) + sizeof(aica_channel_t)]; \
66     aica_cmd_t  * CMDR = (aica_cmd_t *)T; \
67     aica_channel_t  * CHANR = (aica_channel_t *)(CMDR->cmd_data);
68 #define AICA_CMDSTR_CHANNEL_SIZE    ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
69
70 /* Command values (for aica_cmd_t) */
71 #define AICA_CMD_NONE       0x00000000  /* No command (dummy packet)    */
72 #define AICA_CMD_PING       0x00000001  /* Check for signs of life  */
73 #define AICA_CMD_CHAN       0x00000002  /* Perform a wavetable action   */
74 #define AICA_CMD_SYNC_CLOCK 0x00000003  /* Reset the millisecond clock  */
75
76 /* Response values (for aica_cmd_t) */
77 #define AICA_RESP_NONE      0x00000000
78 #define AICA_RESP_PONG      0x00000001  /* Response to CMD_PING             */
79 #define AICA_RESP_DBGPRINT  0x00000002  /* Entire payload is a null-terminated string   */
80
81 /* Command values (for aica_channel_t commands) */
82 #define AICA_CH_CMD_MASK    0x0000000f
83
84 #define AICA_CH_CMD_NONE    0x00000000
85 #define AICA_CH_CMD_START   0x00000001
86 #define AICA_CH_CMD_STOP    0x00000002
87 #define AICA_CH_CMD_UPDATE  0x00000003
88
89 /* Start values */
90 #define AICA_CH_START_MASK  0x00300000
91
92 #define AICA_CH_START_DELAY 0x00100000 /* Set params, but delay key-on */
93 #define AICA_CH_START_SYNC  0x00200000 /* Set key-on for all selected channels */
94
95 /* Update values */
96 #define AICA_CH_UPDATE_MASK 0x000ff000
97
98 #define AICA_CH_UPDATE_SET_FREQ 0x00001000 /* frequency     */
99 #define AICA_CH_UPDATE_SET_VOL  0x00002000 /* volume        */
100 #define AICA_CH_UPDATE_SET_PAN  0x00004000 /* panning       */
101
102 /* Sample types */
103 #define AICA_SM_8BIT    1
104 #define AICA_SM_16BIT   0
105 #define AICA_SM_ADPCM   2
106
107
108 /* This is where our SH-4/AICA comm variables go... */
109
110 /* 0x000000 - 0x010000 are reserved for the program */
111
112 /* Location of the SH-4 to AICA queue; commands from here will be
113    periodically processed by the AICA and then removed from the queue. */
114 #define AICA_MEM_CMD_QUEUE  0x010000    /* 32K */
115
116 /* Location of the AICA to SH-4 queue; commands from here will be
117    periodically processed by the SH-4 and then removed from the queue. */
118 #define AICA_MEM_RESP_QUEUE 0x018000    /* 32K */
119
120 /* This is the channel base, which holds status structs for all the
121    channels. This is READ-ONLY from the SH-4 side. */
122 #define AICA_MEM_CHANNELS   0x020000    /* 64 * 16*4 = 4K */
123
124 /* The clock value (in milliseconds) */
125 #define AICA_MEM_CLOCK      0x021000    /* 4 bytes */
126
127 /* 0x021004 - 0x030000 are reserved for future expansion */
128
129 /* Open ram for sample data */
130 #define AICA_RAM_START      0x030000
131 #define AICA_RAM_END        0x200000
132
133 /* Quick access to the AICA channels */
134 #define AICA_CHANNEL(x)     (AICA_MEM_CHANNELS + (x) * sizeof(aica_channel_t))
135
136 #endif  /* __ARM_AICA_CMD_IFACE_H */