Skip to content

Commit 4edb21a

Browse files
committed
[core] Update AICA command iface header.
Also fix AICA_CMDSTR_CHANNEL alignment.
1 parent cf9993a commit 4edb21a

File tree

1 file changed

+115
-88
lines changed

1 file changed

+115
-88
lines changed

include/drivers/aica_cmd_iface.h

Lines changed: 115 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
aica_cmd_iface.h
44
Copyright (C) 2000-2002 Dan Potter
5-
Copyright (C) 2009-2014 SWAT
5+
Copyright (C) 2009-2014, 2025 SWAT
66
77
Definitions for the SH-4/AICA interface. This file is meant to be
88
included from both the ARM and SH-4 sides of the fence.
@@ -16,48 +16,54 @@ typedef unsigned long uint8;
1616
typedef unsigned long uint32;
1717
#endif
1818

19-
/* Command queue; one of these for passing data from the SH-4 to the
20-
AICA, and another for the other direction. If a command is written
21-
to the queue and it is longer than the amount of space between the
22-
head point and the queue size, the command will wrap around to
23-
the beginning (i.e., queue commands _can_ be split up). */
19+
/** \brief SH4-to-AICA command queue
20+
21+
Command queue; one of these for passing data from the SH-4 to the
22+
AICA, and another for the other direction. If a command is written
23+
to the queue and it is longer than the amount of space between the
24+
head point and the queue size, the command will wrap around to
25+
the beginning (i.e., queue commands _can_ be split up).
26+
*/
2427
typedef struct aica_queue {
25-
uint32 head; /* Insertion point offset (in bytes) */
26-
uint32 tail; /* Removal point offset (in bytes) */
27-
uint32 size; /* Queue size (in bytes) */
28-
uint32 valid; /* 1 if the queue structs are valid */
29-
uint32 process_ok; /* 1 if it's ok to process the data */
30-
uint32 data; /* Pointer to queue data buffer */
28+
uint32 head; /**< \brief Insertion point offset (in bytes) */
29+
uint32 tail; /**< \brief Removal point offset (in bytes) */
30+
uint32 size; /**< \brief Queue size (in bytes) */
31+
uint32 valid; /**< \brief 1 if the queue structs are valid */
32+
uint32 process_ok; /**< \brief 1 if it's ok to process the data */
33+
uint32 data; /**< \brief Pointer to queue data buffer */
3134
} aica_queue_t;
3235

33-
/* Command queue struct for commanding the AICA from the SH-4 */
36+
/** \brief Command queue struct for commanding the AICA from the SH-4 */
3437
typedef struct aica_cmd {
35-
uint32 size; /* Command data size in dwords */
36-
uint32 cmd; /* Command ID */
37-
uint32 timestamp; /* When to execute the command (0 == now) */
38-
uint32 cmd_id; /* Command ID, for cmd/response pairs, or channel id */
39-
uint32 misc[4]; /* Misc Parameters / Padding */
40-
uint8 cmd_data[0]; /* Command data */
38+
uint32 size; /**< \brief Command data size in dwords */
39+
uint32 cmd; /**< \brief Command ID */
40+
uint32 timestamp; /**< \brief When to execute the command (0 == now) */
41+
uint32 cmd_id; /**< \brief CmdID, for cmd/resp pairs, or chn id */
42+
uint32 misc[4]; /**< \brief Misc Parameters / Padding */
43+
uint8 cmd_data[]; /**< \brief Command data */
4144
} aica_cmd_t;
4245

43-
/* Maximum command size -- 256 dwords */
44-
#define AICA_CMD_MAX_SIZE 256
46+
/** \brief Maximum command size -- 256 dwords */
47+
#define AICA_CMD_MAX_SIZE 256
48+
49+
/** \brief AICA command payload data for AICA_CMD_CHAN
4550
46-
/* This is the cmd_data for AICA_CMD_CHAN. Make this 16 dwords long
47-
for two aica bus queues. */
51+
This is the aica_cmd_t::cmd_data for AICA_CMD_CHAN.
52+
Make this 16 dwords long for two aica bus queues.
53+
*/
4854
typedef struct aica_channel {
49-
uint32 cmd; /* Command ID */
50-
uint32 base; /* Sample base in RAM */
51-
uint32 type; /* (8/16bit/ADPCM) */
52-
uint32 length; /* Sample length */
53-
uint32 loop; /* Sample looping */
54-
uint32 loopstart; /* Sample loop start */
55-
uint32 loopend; /* Sample loop end */
56-
uint32 freq; /* Frequency */
57-
uint32 vol; /* Volume 0-255 */
58-
uint32 pan; /* Pan 0-255 */
59-
uint32 pos; /* Sample playback pos */
60-
uint32 pad[5]; /* Padding */
55+
uint32 cmd; /**< \brief Command ID */
56+
uint32 base; /**< \brief Sample base in RAM */
57+
uint32 type; /**< \brief (8/16bit/ADPCM) */
58+
uint32 length; /**< \brief Sample length */
59+
uint32 loop; /**< \brief Sample looping */
60+
uint32 loopstart; /**< \brief Sample loop start */
61+
uint32 loopend; /**< \brief Sample loop end */
62+
uint32 freq; /**< \brief Frequency */
63+
uint32 vol; /**< \brief Volume 0-255 */
64+
uint32 pan; /**< \brief Pan 0-255 */
65+
uint32 pos; /**< \brief Sample playback pos */
66+
uint32 pad[5]; /**< \brief Padding */
6167
} aica_channel_t;
6268

6369
typedef struct aica_decoder {
@@ -70,26 +76,32 @@ typedef struct aica_decoder {
7076
uint32 pad[10];
7177
} aica_decoder_t;
7278

73-
/* Declare an aica_cmd_t big enough to hold an aica_channel_t
74-
using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR */
75-
#define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
76-
uint8 T[sizeof(aica_cmd_t) + sizeof(aica_channel_t)]; \
77-
aica_cmd_t * CMDR = (aica_cmd_t *)T; \
78-
aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
79-
#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
79+
/** \brief Macro for declaring an aica channel command
8080
81+
Declare an aica_cmd_t big enough to hold an aica_channel_t
82+
using temp name T, aica_cmd_t name CMDR, and aica_channel_t name CHANR
8183
82-
#define AICA_CMDSTR_DECODER(T, CMDR, DECR) \
83-
uint8 T[sizeof(aica_cmd_t) + sizeof(aica_decoder_t)]; \
84-
aica_cmd_t * CMDR = (aica_cmd_t *)T; \
85-
aica_decoder_t * DECR = (aica_decoder_t *)(CMDR->cmd_data);
86-
#define AICA_CMDSTR_DECODER_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_decoder_t))/4)
84+
\param T Buffer name
85+
\param CMDR aica_cmd_t pointer name
86+
\param CHANR aica_channel_t pointer name
87+
*/
88+
#define AICA_CMDSTR_CHANNEL(T, CMDR, CHANR) \
89+
uint32 T[(sizeof(aica_cmd_t) + sizeof(aica_channel_t)) / 4]; \
90+
aica_cmd_t * CMDR = (aica_cmd_t *)T; \
91+
aica_channel_t * CHANR = (aica_channel_t *)(CMDR->cmd_data);
92+
93+
/** \brief Size of an AICA channel command in words */
94+
#define AICA_CMDSTR_CHANNEL_SIZE ((sizeof(aica_cmd_t) + sizeof(aica_channel_t))/4)
8795

88-
/* Command values (for aica_cmd_t) */
89-
#define AICA_CMD_NONE 0x00000000 /* No command (dummy packet) */
90-
#define AICA_CMD_PING 0x00000001 /* Check for signs of life */
91-
#define AICA_CMD_CHAN 0x00000002 /* Perform a wavetable action */
92-
#define AICA_CMD_SYNC_CLOCK 0x00000003 /* Reset the millisecond clock */
96+
/** \defgroup audio_aica_cmd Commands
97+
\brief Values of commands for aica_cmd_t
98+
@{
99+
*/
100+
#define AICA_CMD_NONE 0x00000000 /**< \brief No command (dummy packet) */
101+
#define AICA_CMD_PING 0x00000001 /**< \brief Check for signs of life */
102+
#define AICA_CMD_CHAN 0x00000002 /**< \brief Perform a wavetable action */
103+
#define AICA_CMD_SYNC_CLOCK 0x00000003 /**< \brief Reset the millisecond clock */
104+
/** @} */
93105

94106
#define AICA_CMD_CPU_CLOCK 0x00000004 /* */
95107
#define AICA_CMD_DECODER 0x00000005
@@ -103,40 +115,57 @@ typedef struct aica_decoder {
103115
#define AICA_CODEC_MP3 0x00000001
104116
#define AICA_CODEC_AAC 0x00000002
105117

106-
#define AICA_DECODER_CMD_MASK 0x0000000f
107-
108-
/* Response values (for aica_cmd_t) */
109-
#define AICA_RESP_NONE 0x00000000
110-
#define AICA_RESP_PONG 0x00000001 /* Response to CMD_PING */
111-
#define AICA_RESP_DBGPRINT 0x00000002 /* Entire payload is a null-terminated string */
112-
113-
/* Command values (for aica_channel_t commands) */
114-
#define AICA_CH_CMD_MASK 0x0000000f
115-
116-
#define AICA_CH_CMD_NONE 0x00000000
117-
#define AICA_CH_CMD_START 0x00000001
118-
#define AICA_CH_CMD_STOP 0x00000002
119-
#define AICA_CH_CMD_UPDATE 0x00000003
120-
121-
/* Start values */
122-
#define AICA_CH_START_MASK 0x00300000
123-
124-
#define AICA_CH_START_DELAY 0x00100000 /* Set params, but delay key-on */
125-
#define AICA_CH_START_SYNC 0x00200000 /* Set key-on for all selected channels */
126-
127-
/* Update values */
128-
#define AICA_CH_UPDATE_MASK 0x000ff000
129-
130-
#define AICA_CH_UPDATE_SET_FREQ 0x00001000 /* frequency */
131-
#define AICA_CH_UPDATE_SET_VOL 0x00002000 /* volume */
132-
#define AICA_CH_UPDATE_SET_PAN 0x00004000 /* panning */
133-
134-
/* Sample types */
135-
#define AICA_SM_8BIT 1
136-
#define AICA_SM_16BIT 0
137-
#define AICA_SM_ADPCM 2
138-
139-
118+
/** \defgroup audio_aica_resp Responses
119+
\brief Values of responses to aica_cmd_t commands
120+
@{
121+
*/
122+
#define AICA_RESP_NONE 0x00000000 /**< \brief No response */
123+
#define AICA_RESP_PONG 0x00000001 /**< \brief Response to CMD_PING */
124+
#define AICA_RESP_DBGPRINT 0x00000002 /**< \brief Payload is a C string */
125+
/** @} */
126+
127+
/** \defgroup audio_aica_ch_cmd Channel Commands
128+
\brief Command values (for aica_channel_t commands)
129+
@{
130+
*/
131+
#define AICA_CH_CMD_MASK 0x0000000f /**< \brief Mask for commands */
132+
133+
#define AICA_CH_CMD_NONE 0x00000000 /**< \brief No command */
134+
#define AICA_CH_CMD_START 0x00000001 /**< \brief Start command */
135+
#define AICA_CH_CMD_STOP 0x00000002 /**< \brief Stop command */
136+
#define AICA_CH_CMD_UPDATE 0x00000003 /**< \brief Update command */
137+
/** @} */
138+
139+
/** \defgroup audio_aica_ch_start Channel Start Values
140+
\brief Start values for AICA channels
141+
@{
142+
*/
143+
#define AICA_CH_START_MASK 0x00300000 /**< \brief Mask for start values */
144+
145+
#define AICA_CH_START_DELAY 0x00100000 /**< \brief Set params, but delay key-on */
146+
#define AICA_CH_START_SYNC 0x00200000 /**< \brief Set key-on for all selected channels */
147+
/** @} */
148+
149+
/** \defgroup audio_aica_ch_update Channel Update Values
150+
\brief Update values for AICA channels
151+
@{
152+
*/
153+
#define AICA_CH_UPDATE_MASK 0x000ff000 /**< \brief Mask for update values */
154+
155+
#define AICA_CH_UPDATE_SET_FREQ 0x00001000 /**< \brief frequency */
156+
#define AICA_CH_UPDATE_SET_VOL 0x00002000 /**< \brief volume*/
157+
#define AICA_CH_UPDATE_SET_PAN 0x00004000 /**< \brief panning */
158+
/** @} */
159+
160+
/** \defgroup audio_aica_samples Sample Types
161+
\brief Types of samples used by the AICA
162+
@{
163+
*/
164+
#define AICA_SM_16BIT 0 /* Linear PCM 16-bit */
165+
#define AICA_SM_8BIT 1 /* Linear PCM 8-bit */
166+
#define AICA_SM_ADPCM 2 /* Yamaha ADPCM 4-bit */
167+
#define AICA_SM_ADPCM_LS 3 /* Long stream ADPCM 4-bit */
168+
/** @} */
140169

141170
/* This is where our SH-4/AICA comm variables go... */
142171

@@ -163,8 +192,6 @@ typedef struct aica_decoder {
163192
#define AICA_RAM_START 0x040000
164193
#define AICA_RAM_END 0x200000
165194

166-
167-
168195
/* Quick access to the AICA channels */
169196
#define AICA_CHANNEL(x) (AICA_MEM_CHANNELS + (x) * sizeof(aica_channel_t))
170197

0 commit comments

Comments
 (0)