Skip to content

Commit 76fc7b9

Browse files
authored
Merge pull request #718 from uyjulian/libsd_feature_update
libsd feature update
2 parents 443ea8a + b33694e commit 76fc7b9

File tree

17 files changed

+2816
-1938
lines changed

17 files changed

+2816
-1938
lines changed

common/include/libsd-common.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
#define SD_BATCH_WRITEIOP 0x5
119119
#define SD_BATCH_WRITEEE 0x6
120120
#define SD_BATCH_EERETURN 0x7
121-
#define SD_BATCH_GETPARAM 0x10
121+
#define SD_BATCH_GETPARAM 0x11
122122
#define SD_BATCH_GETSWITCH 0x12
123123
#define SD_BATCH_GETADDR 0x13
124124
#define SD_BATCH_GETCORE 0x14
@@ -147,6 +147,7 @@ typedef struct
147147
typedef int (*sceSdSpu2IntrHandler)(int, void *);
148148
typedef int (*sceSdTransIntrHandler)(int, void *);
149149
typedef int (*SdIntrCallback)(void *data);
150+
typedef int (*sceSdBlockTransHandler)(int channel, void *userdata, void **addr, int *size);
150151

151152
#ifdef __cplusplus
152153
extern "C" {
@@ -173,11 +174,11 @@ extern u32 sceSdGetSwitch(u16 entry);
173174
extern u16 sceSdNote2Pitch(u16 center_note, u16 center_fine, u16 note, s16 fine);
174175
extern u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch);
175176

176-
extern int sceSdSetEffectAttr(int core, sceSdEffectAttr *attr);
177+
extern int sceSdSetEffectAttr(int core, const sceSdEffectAttr *attr);
177178
extern void sceSdGetEffectAttr(int core, sceSdEffectAttr *attr);
178179

179-
extern int sceSdProcBatch(sceSdBatch *batch, u32 *rets, u32 num);
180-
extern int sceSdProcBatchEx(sceSdBatch *batch, u32 *rets, u32 num, u32 voice);
180+
extern int sceSdProcBatch(const sceSdBatch *batch, u32 *rets, u32 num);
181+
extern int sceSdProcBatchEx(const sceSdBatch *batch, u32 *rets, u32 num, u32 voice);
181182

182183
extern int sceSdVoiceTrans(s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size);
183184
extern int sceSdBlockTrans(s16 chan, u16 mode, u8 *iopaddr, u32 size, ...);
@@ -189,10 +190,13 @@ extern sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler(sceSdSpu2IntrHandler func, v
189190

190191
extern void *sceSdGetTransIntrHandlerArgument(int arg);
191192
extern void *sceSdGetSpu2IntrHandlerArgument();
193+
194+
// The following was added in module version 3.1, export version 1.5, SDK 2.4.2
192195
extern int sceSdStopTrans(int channel);
196+
// The following was added in module version 3.3, export version 1.5, SDK 2.5
193197
extern int sceSdCleanEffectWorkArea(int core, int channel, int effect_mode);
194-
extern int sceSdSetEffectMode(int core, sceSdEffectAttr *param);
195-
extern int sceSdSetEffectModeParams(int core, sceSdEffectAttr *attr);
198+
extern int sceSdSetEffectMode(int core, const sceSdEffectAttr *param);
199+
extern int sceSdSetEffectModeParams(int core, const sceSdEffectAttr *attr);
196200

197201
#ifdef __cplusplus
198202
}

common/include/spu2_mmio_hwport.h

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
/**
12+
* @file
13+
* Definitions for memory-mapped I/O for SPU2.
14+
*/
15+
16+
#ifndef __SPU2_MMIO_HWPORT__
17+
#define __SPU2_MMIO_HWPORT__
18+
19+
typedef struct spu2_u16pair_
20+
{
21+
vu16 m_pair[2];
22+
} spu2_u16pair_t;
23+
24+
typedef struct spu2_voice_params_
25+
{
26+
vu16 m_voll;
27+
vu16 m_volr;
28+
vu16 m_pitch;
29+
vu16 m_adsr1;
30+
vu16 m_adsr2;
31+
vu16 m_envx;
32+
vu16 m_volxl;
33+
vu16 m_volxr;
34+
} spu2_voice_params_t;
35+
36+
typedef struct spu2_voice_address_
37+
{
38+
spu2_u16pair_t m_ssa;
39+
spu2_u16pair_t m_lsax;
40+
spu2_u16pair_t m_nax;
41+
} spu2_voice_address_t;
42+
43+
typedef struct spu2_core_regs_
44+
{
45+
spu2_voice_params_t m_voice_params[24]; /* 0x000 */
46+
spu2_u16pair_t m_pmon; /* 0x180 */
47+
spu2_u16pair_t m_non; /* 0x184 */
48+
spu2_u16pair_t m_vmixl; /* 0x188 */
49+
spu2_u16pair_t m_vmixel; /* 0x18c */
50+
spu2_u16pair_t m_vmixr; /* 0x190 */
51+
spu2_u16pair_t m_vmixer; /* 0x194 */
52+
vu16 m_mmix; /* 0x198 */
53+
vu16 m_attr; /* 0x19a */
54+
spu2_u16pair_t m_irqa; /* 0x19c */
55+
spu2_u16pair_t m_kon; /* 0x1a0 */
56+
spu2_u16pair_t m_koff; /* 0x1a4 */
57+
spu2_u16pair_t m_tsa; /* 0x1a8 */
58+
vu16 m_xferdata; /* 0x1ac */
59+
vu16 m_unk1ae; /* 0x1ae */
60+
vu16 m_admas; /* 0x1b0 */
61+
vu16 unk1b2[7]; /* 0x1b2 */
62+
spu2_voice_address_t m_voice_address[24]; /* 0x1c0 */
63+
spu2_u16pair_t m_esa; /* 0x2e0 */
64+
spu2_u16pair_t m_apf1_size; /* 0x2e4 */
65+
spu2_u16pair_t m_apf2_size; /* 0x2e8 */
66+
spu2_u16pair_t m_same_l_dst; /* 0x2EC */
67+
spu2_u16pair_t m_same_r_dst; /* 0x2F0 */
68+
spu2_u16pair_t m_comb1_l_src; /* 0x2F4 */
69+
spu2_u16pair_t m_comb1_r_src; /* 0x2F8 */
70+
spu2_u16pair_t m_comb2_l_src; /* 0x2FC */
71+
spu2_u16pair_t m_comb2_r_src; /* 0x300 */
72+
spu2_u16pair_t m_same_l_src; /* 0x304 */
73+
spu2_u16pair_t m_same_r_src; /* 0x308 */
74+
spu2_u16pair_t m_diff_l_dst; /* 0x30C */
75+
spu2_u16pair_t m_diff_r_dst; /* 0x310 */
76+
spu2_u16pair_t m_comb3_l_src; /* 0x314 */
77+
spu2_u16pair_t m_comb3_r_src; /* 0x318 */
78+
spu2_u16pair_t m_comb4_l_src; /* 0x31C */
79+
spu2_u16pair_t m_comb4_r_src; /* 0x320 */
80+
spu2_u16pair_t m_diff_l_src; /* 0x324 */
81+
spu2_u16pair_t m_diff_r_src; /* 0x328 */
82+
spu2_u16pair_t m_apf1_l_dst; /* 0x32C */
83+
spu2_u16pair_t m_apf1_r_dst; /* 0x330 */
84+
spu2_u16pair_t m_apf2_l_dst; /* 0x334 */
85+
spu2_u16pair_t m_apf2_r_dst; /* 0x338 */
86+
vu16 m_eea; /* 0x33C */
87+
vu16 unk33e; /* 0x33E */
88+
spu2_u16pair_t m_endx; /* 0x340 */
89+
vu16 m_statx; /* 0x344 */
90+
vu16 unk346[13]; /* 0x346 */
91+
} spu2_core_regs_t;
92+
93+
typedef struct spu2_different_regs_
94+
{
95+
vu16 m_mvoll; /* 0x760 */
96+
vu16 m_mvolr; /* 0x762 */
97+
vu16 m_evoll; /* 0x764 */
98+
vu16 m_evolr; /* 0x766 */
99+
vu16 m_avoll; /* 0x768 */
100+
vu16 m_avolr; /* 0x76A */
101+
vu16 m_bvoll; /* 0x76C */
102+
vu16 m_bvolr; /* 0x76E */
103+
vu16 m_mvolxl; /* 0x770 */
104+
vu16 m_mvolxr; /* 0x772 */
105+
vu16 m_iir_vol; /* 0x774 */
106+
vu16 m_comb1_vol; /* 0x776 */
107+
vu16 m_comb2_vol; /* 0x778 */
108+
vu16 m_comb3_vol; /* 0x77A */
109+
vu16 m_comb4_vol; /* 0x77C */
110+
vu16 m_wall_vol; /* 0x77E */
111+
vu16 m_apf1_vol; /* 0x780 */
112+
vu16 m_apf2_vol; /* 0x782 */
113+
vu16 m_in_coef_l; /* 0x784 */
114+
vu16 m_in_coef_r; /* 0x786 */
115+
} spu2_different_regs_t;
116+
117+
typedef struct spu2_core_regs_padded_
118+
{
119+
spu2_core_regs_t m_cregs;
120+
vu16 padding[80];
121+
} spu2_core_regs_padded_t;
122+
123+
typedef struct spu2_regs_main_
124+
{
125+
spu2_core_regs_padded_t m_core_regs[2];
126+
} spu2_regs_main_t;
127+
128+
typedef struct spu2_regs_extra_
129+
{
130+
spu2_core_regs_t core0_regs;
131+
vu16 padding346[80];
132+
spu2_core_regs_t core1_regs; /* 0x400 */
133+
spu2_different_regs_t m_different_regs[2];
134+
vu16 unk7b0[8];
135+
vu16 m_spdif_out; /* 0x7c0 */
136+
vu16 m_spdif_irqinfo; /* 0x7c2 */
137+
vu16 unk7c4; /* 0x7c4 */
138+
vu16 m_spdif_mode; /* 0x7c6 */
139+
vu16 m_spdif_media; /* 0x7c8 */
140+
vu16 m_unknown7ca; /* 0x7ca */
141+
vu16 m_spdif_protect; /* 0x7cc */
142+
vu16 unk7ce[25];
143+
} spu2_regs_extra_t;
144+
145+
typedef struct spu2_mmio_hwport_ /* base => 0xBF900000 */
146+
{
147+
union spu2_regs_union_
148+
{
149+
spu2_regs_main_t m_m;
150+
spu2_regs_extra_t m_e;
151+
} m_u;
152+
} spu2_mmio_hwport_t;
153+
154+
#if !defined(USE_SPU2_MMIO_HWPORT) && defined(_IOP)
155+
// cppcheck-suppress-macro constVariablePointer
156+
#define USE_SPU2_MMIO_HWPORT() spu2_mmio_hwport_t *const spu2_mmio_hwport = (spu2_mmio_hwport_t *)0xBF900000
157+
#endif
158+
#if !defined(USE_SPU2_MMIO_HWPORT)
159+
#define USE_SPU2_MMIO_HWPORT()
160+
#endif
161+
162+
#endif /* __SPU2_MMIO_HWPORT__ */

ee/rpc/ps2snd/src/ps2snd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch)
130130
return(0);
131131
}
132132

133-
int sceSdProcBatch(sceSdBatch* batch, u32 returns[], u32 num)
133+
int sceSdProcBatch(const sceSdBatch* batch, u32 returns[], u32 num)
134134
{
135135
(void)batch;
136136
(void)returns;
@@ -140,7 +140,7 @@ int sceSdProcBatch(sceSdBatch* batch, u32 returns[], u32 num)
140140
return(-1);
141141
}
142142

143-
int sceSdProcBatchEx(sceSdBatch* batch, u32 returns[], u32 num, u32 voice)
143+
int sceSdProcBatchEx(const sceSdBatch* batch, u32 returns[], u32 num, u32 voice)
144144
{
145145
(void)batch;
146146
(void)returns;
@@ -198,7 +198,7 @@ u32 sceSdBlockTransStatus (s16 channel, s16 flag)
198198
//void* sceSdSetTransCallback (u16 channel, void SD_TRANS_CBProc(void *) );
199199
//void *sceSdSetIRQCallback( void SD_IRQ_CBProc(void *) );
200200

201-
int sceSdSetEffectAttr (int core, sceSdEffectAttr *attr)
201+
int sceSdSetEffectAttr (int core, const sceSdEffectAttr *attr)
202202
{
203203
s32 buf[1+((sizeof(sceSdEffectAttr)+3)/4)] ALIGNED(64);
204204
buf[0] = core;

iop/sound/libsd/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ____| | ____| | | |____|
33
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
44
#-----------------------------------------------------------------------
5-
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
5+
# Copyright ps2dev - http://www.ps2dev.org
66
# Licenced under Academic Free License version 2.0
77
# Review ps2sdk README & LICENSE files for further details.
88

@@ -13,9 +13,10 @@ IOP_INCS += \
1313
-I$(PS2SDKSRC)/iop/system/loadcore/include \
1414
-I$(PS2SDKSRC)/iop/system/sifman/include \
1515
-I$(PS2SDKSRC)/iop/system/stdio/include \
16-
-I$(PS2SDKSRC)/iop/system/sysclib/include
16+
-I$(PS2SDKSRC)/iop/system/sysclib/include \
17+
-I$(PS2SDKSRC)/iop/system/threadman/include
1718

18-
IOP_OBJS = freesd.o batch.o block.o effect.o voice.o exports.o imports.o
19+
IOP_OBJS = libsd.o imports.o exports.o
1920

2021
include $(PS2SDKSRC)/Defs.make
2122
include $(PS2SDKSRC)/iop/Rules.bin.make

iop/sound/libsd/README

Lines changed: 0 additions & 17 deletions
This file was deleted.

iop/sound/libsd/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Sound Device Library
2+
3+
This module is an abstraction layer for the SPU2 interface used for audio mixing and analog and digital audio output.
4+
5+
## Configurations
6+
7+
There are multiple configurations of this library, allowing the choice of
8+
balancing between size, speed, and features.
9+
10+
* `libsd` -> The recommended version.
11+
12+
## How to use this module in your program
13+
14+
In order to use this module in your program, use `LoadModule` or \
15+
`LoadModuleBuffer` with no arguments.
16+
17+
## Credits
18+
19+
Original FREESD 1.0 developer: TyRaNiD <mailto:[email protected]>\
20+
Original FREESD 1.0 developer: Lukasz Bruun <mailto:[email protected]>\
21+
Neill Corlett <mailto:[email protected]> for very valuable information on sound registers.\
22+
\[RO]man <mailto:[email protected]> for register information.\
23+
adresd <mailto:[email protected]>, Nicholas Van Veen <mailto:[email protected]>, Vzzrzzn,
24+
MrHTFord <mailto:[email protected]> for their work with libsd and thereby providing test data.

iop/sound/libsd/include/libsd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ____| | ____| | | |____|
44
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
55
#-----------------------------------------------------------------------
6-
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
6+
# Copyright ps2dev - http://www.ps2dev.org
77
# Licenced under Academic Free License version 2.0
88
# Review ps2sdk README & LICENSE files for further details.
99
*/
@@ -20,7 +20,7 @@
2020
#include <irx.h>
2121
#include <libsd-common.h>
2222

23-
#define libsd_IMPORTS_start DECLARE_IMPORT_TABLE(libsd, 1, 4)
23+
#define libsd_IMPORTS_start DECLARE_IMPORT_TABLE(libsd, 1, 5)
2424
#define libsd_IMPORTS_end END_IMPORT_TABLE
2525

2626
#define I_sceSdQuit DECLARE_IMPORT(2, sceSdQuit);

0 commit comments

Comments
 (0)