6#ifndef __LIBSD_COMMON_H__
7#define __LIBSD_COMMON_H__
11#define SD_VOICE(_core, _v) ((_core) | ((_v) << 1))
14#define SD_ADSR_AR_LINEARi 0
15#define SD_ADSR_AR_EXPi 1
16#define SD_ADSR_SR_LINEARi 0
17#define SD_ADSR_SR_LINEARd 2
18#define SD_ADSR_SR_EXPi 4
19#define SD_ADSR_SR_EXPd 6
20#define SD_ADSR_RR_LINEARd 0
21#define SD_ADSR_RR_EXPd 1
22#define SD_SET_ADSR1(_arm, _ar, _dr, _sl) ((((_arm)&1) << 15) | (((_ar)&0x7f) << 8) | (((_dr)&0xf) << 4) | ((_sl)&0xf))
23#define SD_SET_ADSR2(_srm, _sr, _rrm, _rr) ((((_srm)&7) << 13) | (((_sr)&0x7f) << 6) | (((_rrm)&1) << 5) | ((_rr)&0x1f))
26#define SD_VPARAM_VOLL (0x00 << 8)
27#define SD_VPARAM_VOLR (0x01 << 8)
28#define SD_VPARAM_PITCH (0x02 << 8)
29#define SD_VPARAM_ADSR1 (0x03 << 8)
30#define SD_VPARAM_ADSR2 (0x04 << 8)
31#define SD_VPARAM_ENVX (0x05 << 8)
32#define SD_VPARAM_VOLXL (0x06 << 8)
33#define SD_VPARAM_VOLXR (0x07 << 8)
34#define SD_PARAM_MMIX (0x08 << 8)
35#define SD_PARAM_MVOLL ((0x09 << 8) | 0x80)
36#define SD_PARAM_MVOLR ((0x0A << 8) | 0x80)
37#define SD_PARAM_EVOLL ((0x0B << 8) | 0x80)
38#define SD_PARAM_EVOLR ((0x0C << 8) | 0x80)
39#define SD_PARAM_AVOLL ((0x0D << 8) | 0x80)
40#define SD_PARAM_AVOLR ((0x0E << 8) | 0x80)
41#define SD_PARAM_BVOLL ((0x0F << 8) | 0x80)
42#define SD_PARAM_BVOLR ((0x10 << 8) | 0x80)
43#define SD_PARAM_MVOLXL ((0x11 << 8) | 0x80)
44#define SD_PARAM_MVOLXR ((0x12 << 8) | 0x80)
47#define SD_TRANS_WRITE 0
48#define SD_TRANS_READ 1
49#define SD_TRANS_STOP 2
50#define SD_TRANS_WRITE_FROM 3
51#define SD_TRANS_LOOP 0x10
52#define SD_TRANS_MODE_DMA 0
53#define SD_TRANS_MODE_IO 8
56#define SD_EFFECT_MODE_OFF 0x0
57#define SD_EFFECT_MODE_ROOM 0x1
58#define SD_EFFECT_MODE_STUDIO_1 0x2
59#define SD_EFFECT_MODE_STUDIO_2 0x3
60#define SD_EFFECT_MODE_STUDIO_3 0x4
61#define SD_EFFECT_MODE_HALL 0x5
62#define SD_EFFECT_MODE_SPACE 0x6
63#define SD_EFFECT_MODE_ECHO 0x7
64#define SD_EFFECT_MODE_DELAY 0x8
65#define SD_EFFECT_MODE_PIPE 0x9
66#define SD_EFFECT_MODE_CLEAR 0x100
69#define SD_CORE_EFFECT_ENABLE 0x2
70#define SD_CORE_IRQ_ENABLE 0x4
71#define SD_CORE_MUTE_ENABLE 0x6
72#define SD_CORE_NOISE_CLK 0x8
73#define SD_CORE_SPDIF_MODE 0xA
76#define SD_SWITCH_PMON (0x13 << 8)
77#define SD_SWITCH_NON (0x14 << 8)
78#define SD_SWITCH_KON (0x15 << 8)
79#define SD_SWITCH_KEYDOWN SD_SWITCH_KON
80#define SD_SWITCH_KOFF (0x16 << 8)
81#define SD_SWITCH_KEYUP SD_SWITCH_KOFF
82#define SD_SWITCH_ENDX (0x17 << 8)
83#define SD_SWITCH_VMIXL (0x18 << 8)
84#define SD_SWITCH_VMIXEL (0x19 << 8)
85#define SD_SWITCH_VMIXR (0x1A << 8)
86#define SD_SWITCH_VMIXER (0x1B << 8)
89#define SD_ADDR_ESA (0x1C << 8)
90#define SD_ADDR_EEA (0x1D << 8)
91#define SD_ADDR_TSA (0x1E << 8)
92#define SD_ADDR_IRQA (0x1F << 8)
93#define SD_VADDR_SSA (0x20 << 8)
94#define SD_VADDR_LSAX (0x21 << 8)
95#define SD_VADDR_NAX (0x22 << 8)
98#define SD_SPU2_ON (1 << 15)
99#define SD_MUTE (1 << 14)
100#define SD_NOISE_CLOCK(c) ((c & 0x1F) << 8)
101#define SD_ENABLE_EFFECTS (1 << 7)
102#define SD_ENABLE_IRQ (1 << 6)
103#define SD_DMA_IO (1 << 4)
104#define SD_DMA_WRITE (2 << 4)
105#define SD_DMA_READ (3 << 4)
106#define SD_DMA_IN_PROCESS (3 << 4)
107#define SD_CORE_DMA (3 << 4)
108#define SD_ENABLE_EX_INPUT (1 << 0)
111#define SD_IO_IN_PROCESS (1 << 10)
114#define SD_BATCH_SETPARAM 0x1
115#define SD_BATCH_SETSWITCH 0x2
116#define SD_BATCH_SETADDR 0x3
117#define SD_BATCH_SETCORE 0x4
118#define SD_BATCH_WRITEIOP 0x5
119#define SD_BATCH_WRITEEE 0x6
120#define SD_BATCH_EERETURN 0x7
121#define SD_BATCH_GETPARAM 0x11
122#define SD_BATCH_GETSWITCH 0x12
123#define SD_BATCH_GETADDR 0x13
124#define SD_BATCH_GETCORE 0x14
126#define ADPCM_LOOP_START 4
128#define ADPCM_LOOP_END 1
147typedef int (*sceSdSpu2IntrHandler)(int,
void *);
148typedef int (*sceSdTransIntrHandler)(int,
void *);
149typedef int (*SdIntrCallback)(
void *data);
150typedef int (*sceSdBlockTransHandler)(
int channel,
void *userdata,
void **addr,
int *size);
156extern int sceSdQuit();
157extern int sceSdInit(
int flag);
158extern SdIntrCallback sceSdSetIRQCallback(SdIntrCallback cb);
159extern SdIntrCallback sceSdSetTransCallback(s32 core, SdIntrCallback cb);
161extern void sceSdSetParam(u16 entry, u16 value);
162extern u16 sceSdGetParam(u16 entry);
164extern void sceSdSetCoreAttr(u16 entry, u16 value);
165extern u16 sceSdGetCoreAttr(u16 entry);
166extern int sceSdClearEffectWorkArea(
int core,
int channel,
int effect_mode);
168extern void sceSdSetAddr(u16 entry, u32 value);
169extern u32 sceSdGetAddr(u16 entry);
171extern void sceSdSetSwitch(u16 entry, u32 value);
172extern u32 sceSdGetSwitch(u16 entry);
174extern u16 sceSdNote2Pitch(u16 center_note, u16 center_fine, u16 note, s16 fine);
175extern u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch);
180extern int sceSdProcBatch(
const sceSdBatch *batch, u32 *rets, u32 num);
181extern int sceSdProcBatchEx(
const sceSdBatch *batch, u32 *rets, u32 num, u32 voice);
183extern int sceSdVoiceTrans(s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size);
184extern int sceSdBlockTrans(s16 chan, u16 mode, u8 *iopaddr, u32 size, ...);
185extern u32 sceSdVoiceTransStatus(s16 channel, s16 flag);
186extern u32 sceSdBlockTransStatus(s16 channel, s16 flag);
188extern sceSdTransIntrHandler sceSdSetTransIntrHandler(
int channel, sceSdTransIntrHandler func,
void *arg);
189extern sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler(sceSdSpu2IntrHandler func,
void *arg);
191extern void *sceSdGetTransIntrHandlerArgument(
int arg);
192extern void *sceSdGetSpu2IntrHandlerArgument();
195extern int sceSdStopTrans(
int channel);
197extern int sceSdCleanEffectWorkArea(
int core,
int channel,
int effect_mode);
199extern int sceSdSetEffectModeParams(
int core,
const sceSdEffectAttr *attr);
206#define BATCH_SETPARAM SD_BATCH_SETPARAM
207#define BATCH_SETSWITCH SD_BATCH_SETSWITCH
208#define BATCH_SETADDR SD_BATCH_SETADDR
209#define BATCH_SETCORE SD_BATCH_SETCORE
210#define BATCH_WRITEIOP SD_BATCH_WRITEIOP
211#define BATCH_WRITEEE SD_BATCH_WRITEEE
212#define BATCH_EERETURN SD_BATCH_EERETURN
213#define BATCH_GETPARAM SD_BATCH_GETPARAM
214#define BATCH_GETSWITCH SD_BATCH_GETSWITCH
215#define BATCH_GETADDR SD_BATCH_GETADDR
216#define BATCH_GETCORE SD_BATCH_GETCORE
218#define SD_BLOCK_TRANS_WRITE SD_TRANS_WRITE
219#define SD_BLOCK_TRANS_READ SD_TRANS_READ
220#define SD_BLOCK_TRANS_STOP SD_TRANS_STOP
221#define SD_BLOCK_TRANS_WRITE_FROM SD_TRANS_WRITE_FROM
222#define SD_BLOCK_TRANS_LOOP SD_TRANS_LOOP
224#define SD_VOICE_TRANS_WRITE SD_TRANS_WRITE
225#define SD_VOICE_TRANS_READ SD_TRANS_READ
226#define SD_VOICE_TRANS_STOP SD_TRANS_STOP
227#define SD_VOICE_TRANS_MODE_DMA SD_TRANS_MODE_DMA
228#define SD_VOICE_TRANS_MODE_IO SD_TRANS_MODE_IO
230#define SdBatch sceSdBatch
231#define SdEffectAttr sceSdEffectAttr
232#define SdSpu2IntrHandler sceSdSpu2IntrHandler
233#define SdTransIntrHandler sceSdTransIntrHandler
234#define IntrCallback SdIntrCallback
236#define SdQuit sceSdQuit
237#define SdInit sceSdInit
238#define SdSetIRQCallback sceSdSetIRQCallback
239#define SdSetTransCallback sceSdSetTransCallback
240#define SdSetParam sceSdSetParam
241#define SdGetParam sceSdGetParam
242#define SdSetCoreAttr sceSdSetCoreAttr
243#define SdGetCoreAttr sceSdGetCoreAttr
244#define SdClearEffectWorkArea sceSdClearEffectWorkArea
245#define SdSetAddr sceSdSetAddr
246#define SdGetAddr sceSdGetAddr
247#define SdSetSwitch sceSdSetSwitch
248#define SdGetSwitch sceSdGetSwitch
249#define SdNote2Pitch sceSdNote2Pitch
250#define SdPitch2Note sceSdPitch2Note
251#define SdSetEffectAttr sceSdSetEffectAttr
252#define SdGetEffectAttr sceSdGetEffectAttr
253#define SdProcBatch sceSdProcBatch
254#define SdProcBatchEx sceSdProcBatchEx
255#define SdVoiceTrans sceSdVoiceTrans
256#define SdBlockTrans sceSdBlockTrans
257#define SdVoiceTransStatus sceSdVoiceTransStatus
258#define SdBlockTransStatus sceSdBlockTransStatus
259#define SdSetTransIntrHandler sceSdSetTransIntrHandler
260#define SdSetSpu2IntrHandler sceSdSetSpu2IntrHandler
261#define SdGetTransIntrHandlerArgument sceSdGetTransIntrHandlerArgument
262#define SdGetSpu2IntrHandlerArgument sceSdGetSpu2IntrHandlerArgument
263#define SdStopTrans sceSdStopTrans
264#define SdCleanEffectWorkArea sceSdCleanEffectWorkArea
265#define SdSetEffectMode sceSdSetEffectMode
266#define SdSetEffectModeParams sceSdSetEffectModeParams