Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions common/include/libsd-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
#define SD_BATCH_WRITEIOP 0x5
#define SD_BATCH_WRITEEE 0x6
#define SD_BATCH_EERETURN 0x7
#define SD_BATCH_GETPARAM 0x10
#define SD_BATCH_GETPARAM 0x11
#define SD_BATCH_GETSWITCH 0x12
#define SD_BATCH_GETADDR 0x13
#define SD_BATCH_GETCORE 0x14
Expand Down Expand Up @@ -147,6 +147,7 @@ typedef struct
typedef int (*sceSdSpu2IntrHandler)(int, void *);
typedef int (*sceSdTransIntrHandler)(int, void *);
typedef int (*SdIntrCallback)(void *data);
typedef int (*sceSdBlockTransHandler)(int channel, void *userdata, void **addr, int *size);

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

extern int sceSdSetEffectAttr(int core, sceSdEffectAttr *attr);
extern int sceSdSetEffectAttr(int core, const sceSdEffectAttr *attr);
extern void sceSdGetEffectAttr(int core, sceSdEffectAttr *attr);

extern int sceSdProcBatch(sceSdBatch *batch, u32 *rets, u32 num);
extern int sceSdProcBatchEx(sceSdBatch *batch, u32 *rets, u32 num, u32 voice);
extern int sceSdProcBatch(const sceSdBatch *batch, u32 *rets, u32 num);
extern int sceSdProcBatchEx(const sceSdBatch *batch, u32 *rets, u32 num, u32 voice);

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

extern void *sceSdGetTransIntrHandlerArgument(int arg);
extern void *sceSdGetSpu2IntrHandlerArgument();

// The following was added in module version 3.1, export version 1.5, SDK 2.4.2
extern int sceSdStopTrans(int channel);
// The following was added in module version 3.3, export version 1.5, SDK 2.5
extern int sceSdCleanEffectWorkArea(int core, int channel, int effect_mode);
extern int sceSdSetEffectMode(int core, sceSdEffectAttr *param);
extern int sceSdSetEffectModeParams(int core, sceSdEffectAttr *attr);
extern int sceSdSetEffectMode(int core, const sceSdEffectAttr *param);
extern int sceSdSetEffectModeParams(int core, const sceSdEffectAttr *attr);

#ifdef __cplusplus
}
Expand Down
162 changes: 162 additions & 0 deletions common/include/spu2_mmio_hwport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
* @file
* Definitions for memory-mapped I/O for SPU2.
*/

#ifndef __SPU2_MMIO_HWPORT__
#define __SPU2_MMIO_HWPORT__

typedef struct spu2_u16pair_
{
vu16 m_pair[2];
} spu2_u16pair_t;

typedef struct spu2_voice_params_
{
vu16 m_voll;
vu16 m_volr;
vu16 m_pitch;
vu16 m_adsr1;
vu16 m_adsr2;
vu16 m_envx;
vu16 m_volxl;
vu16 m_volxr;
} spu2_voice_params_t;

typedef struct spu2_voice_address_
{
spu2_u16pair_t m_ssa;
spu2_u16pair_t m_lsax;
spu2_u16pair_t m_nax;
} spu2_voice_address_t;

typedef struct spu2_core_regs_
{
spu2_voice_params_t m_voice_params[24]; /* 0x000 */
spu2_u16pair_t m_pmon; /* 0x180 */
spu2_u16pair_t m_non; /* 0x184 */
spu2_u16pair_t m_vmixl; /* 0x188 */
spu2_u16pair_t m_vmixel; /* 0x18c */
spu2_u16pair_t m_vmixr; /* 0x190 */
spu2_u16pair_t m_vmixer; /* 0x194 */
vu16 m_mmix; /* 0x198 */
vu16 m_attr; /* 0x19a */
spu2_u16pair_t m_irqa; /* 0x19c */
spu2_u16pair_t m_kon; /* 0x1a0 */
spu2_u16pair_t m_koff; /* 0x1a4 */
spu2_u16pair_t m_tsa; /* 0x1a8 */
vu16 m_xferdata; /* 0x1ac */
vu16 m_unk1ae; /* 0x1ae */
vu16 m_admas; /* 0x1b0 */
vu16 unk1b2[7]; /* 0x1b2 */
spu2_voice_address_t m_voice_address[24]; /* 0x1c0 */
spu2_u16pair_t m_esa; /* 0x2e0 */
spu2_u16pair_t m_apf1_size; /* 0x2e4 */
spu2_u16pair_t m_apf2_size; /* 0x2e8 */
spu2_u16pair_t m_same_l_dst; /* 0x2EC */
spu2_u16pair_t m_same_r_dst; /* 0x2F0 */
spu2_u16pair_t m_comb1_l_src; /* 0x2F4 */
spu2_u16pair_t m_comb1_r_src; /* 0x2F8 */
spu2_u16pair_t m_comb2_l_src; /* 0x2FC */
spu2_u16pair_t m_comb2_r_src; /* 0x300 */
spu2_u16pair_t m_same_l_src; /* 0x304 */
spu2_u16pair_t m_same_r_src; /* 0x308 */
spu2_u16pair_t m_diff_l_dst; /* 0x30C */
spu2_u16pair_t m_diff_r_dst; /* 0x310 */
spu2_u16pair_t m_comb3_l_src; /* 0x314 */
spu2_u16pair_t m_comb3_r_src; /* 0x318 */
spu2_u16pair_t m_comb4_l_src; /* 0x31C */
spu2_u16pair_t m_comb4_r_src; /* 0x320 */
spu2_u16pair_t m_diff_l_src; /* 0x324 */
spu2_u16pair_t m_diff_r_src; /* 0x328 */
spu2_u16pair_t m_apf1_l_dst; /* 0x32C */
spu2_u16pair_t m_apf1_r_dst; /* 0x330 */
spu2_u16pair_t m_apf2_l_dst; /* 0x334 */
spu2_u16pair_t m_apf2_r_dst; /* 0x338 */
vu16 m_eea; /* 0x33C */
vu16 unk33e; /* 0x33E */
spu2_u16pair_t m_endx; /* 0x340 */
vu16 m_statx; /* 0x344 */
vu16 unk346[13]; /* 0x346 */
} spu2_core_regs_t;

typedef struct spu2_different_regs_
{
vu16 m_mvoll; /* 0x760 */
vu16 m_mvolr; /* 0x762 */
vu16 m_evoll; /* 0x764 */
vu16 m_evolr; /* 0x766 */
vu16 m_avoll; /* 0x768 */
vu16 m_avolr; /* 0x76A */
vu16 m_bvoll; /* 0x76C */
vu16 m_bvolr; /* 0x76E */
vu16 m_mvolxl; /* 0x770 */
vu16 m_mvolxr; /* 0x772 */
vu16 m_iir_vol; /* 0x774 */
vu16 m_comb1_vol; /* 0x776 */
vu16 m_comb2_vol; /* 0x778 */
vu16 m_comb3_vol; /* 0x77A */
vu16 m_comb4_vol; /* 0x77C */
vu16 m_wall_vol; /* 0x77E */
vu16 m_apf1_vol; /* 0x780 */
vu16 m_apf2_vol; /* 0x782 */
vu16 m_in_coef_l; /* 0x784 */
vu16 m_in_coef_r; /* 0x786 */
} spu2_different_regs_t;

typedef struct spu2_core_regs_padded_
{
spu2_core_regs_t m_cregs;
vu16 padding[80];
} spu2_core_regs_padded_t;

typedef struct spu2_regs_main_
{
spu2_core_regs_padded_t m_core_regs[2];
} spu2_regs_main_t;

typedef struct spu2_regs_extra_
{
spu2_core_regs_t core0_regs;
vu16 padding346[80];
spu2_core_regs_t core1_regs; /* 0x400 */
spu2_different_regs_t m_different_regs[2];
vu16 unk7b0[8];
vu16 m_spdif_out; /* 0x7c0 */
vu16 m_spdif_irqinfo; /* 0x7c2 */
vu16 unk7c4; /* 0x7c4 */
vu16 m_spdif_mode; /* 0x7c6 */
vu16 m_spdif_media; /* 0x7c8 */
vu16 m_unknown7ca; /* 0x7ca */
vu16 m_spdif_protect; /* 0x7cc */
vu16 unk7ce[25];
} spu2_regs_extra_t;

typedef struct spu2_mmio_hwport_ /* base => 0xBF900000 */
{
union spu2_regs_union_
{
spu2_regs_main_t m_m;
spu2_regs_extra_t m_e;
} m_u;
} spu2_mmio_hwport_t;

#if !defined(USE_SPU2_MMIO_HWPORT) && defined(_IOP)
// cppcheck-suppress-macro constVariablePointer
#define USE_SPU2_MMIO_HWPORT() spu2_mmio_hwport_t *const spu2_mmio_hwport = (spu2_mmio_hwport_t *)0xBF900000
#endif
#if !defined(USE_SPU2_MMIO_HWPORT)
#define USE_SPU2_MMIO_HWPORT()
#endif

#endif /* __SPU2_MMIO_HWPORT__ */
6 changes: 3 additions & 3 deletions ee/rpc/ps2snd/src/ps2snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ u16 sceSdPitch2Note(u16 center_note, u16 center_fine, u16 pitch)
return(0);
}

int sceSdProcBatch(sceSdBatch* batch, u32 returns[], u32 num)
int sceSdProcBatch(const sceSdBatch* batch, u32 returns[], u32 num)
{
(void)batch;
(void)returns;
Expand All @@ -140,7 +140,7 @@ int sceSdProcBatch(sceSdBatch* batch, u32 returns[], u32 num)
return(-1);
}

int sceSdProcBatchEx(sceSdBatch* batch, u32 returns[], u32 num, u32 voice)
int sceSdProcBatchEx(const sceSdBatch* batch, u32 returns[], u32 num, u32 voice)
{
(void)batch;
(void)returns;
Expand Down Expand Up @@ -198,7 +198,7 @@ u32 sceSdBlockTransStatus (s16 channel, s16 flag)
//void* sceSdSetTransCallback (u16 channel, void SD_TRANS_CBProc(void *) );
//void *sceSdSetIRQCallback( void SD_IRQ_CBProc(void *) );

int sceSdSetEffectAttr (int core, sceSdEffectAttr *attr)
int sceSdSetEffectAttr (int core, const sceSdEffectAttr *attr)
{
s32 buf[1+((sizeof(sceSdEffectAttr)+3)/4)] ALIGNED(64);
buf[0] = core;
Expand Down
7 changes: 4 additions & 3 deletions iop/sound/libsd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

Expand All @@ -13,9 +13,10 @@ IOP_INCS += \
-I$(PS2SDKSRC)/iop/system/loadcore/include \
-I$(PS2SDKSRC)/iop/system/sifman/include \
-I$(PS2SDKSRC)/iop/system/stdio/include \
-I$(PS2SDKSRC)/iop/system/sysclib/include
-I$(PS2SDKSRC)/iop/system/sysclib/include \
-I$(PS2SDKSRC)/iop/system/threadman/include

IOP_OBJS = freesd.o batch.o block.o effect.o voice.o exports.o imports.o
IOP_OBJS = libsd.o imports.o exports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
Expand Down
17 changes: 0 additions & 17 deletions iop/sound/libsd/README

This file was deleted.

24 changes: 24 additions & 0 deletions iop/sound/libsd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Sound Device Library

This module is an abstraction layer for the SPU2 interface used for audio mixing and analog and digital audio output.

## Configurations

There are multiple configurations of this library, allowing the choice of
balancing between size, speed, and features.

* `libsd` -> The recommended version.

## How to use this module in your program

In order to use this module in your program, use `LoadModule` or \
`LoadModuleBuffer` with no arguments.

## Credits

Original FREESD 1.0 developer: TyRaNiD <mailto:tiraniddo@hotmail.com>\
Original FREESD 1.0 developer: Lukasz Bruun <mailto:ps2@lukasz.dk>\
Neill Corlett <mailto:neill@neillcorlett.com> for very valuable information on sound registers.\
\[RO]man <mailto:roman_ps2dev@hotmail.com> for register information.\
adresd <mailto:adresd_ps2dev@yahoo.com>, Nicholas Van Veen <mailto:nickvv@xtra.co.nz>, Vzzrzzn,
MrHTFord <mailto:mrhtford_ps2dev@hotmail.com> for their work with libsd and thereby providing test data.
4 changes: 2 additions & 2 deletions iop/sound/libsd/include/libsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/
Expand All @@ -20,7 +20,7 @@
#include <irx.h>
#include <libsd-common.h>

#define libsd_IMPORTS_start DECLARE_IMPORT_TABLE(libsd, 1, 4)
#define libsd_IMPORTS_start DECLARE_IMPORT_TABLE(libsd, 1, 5)
#define libsd_IMPORTS_end END_IMPORT_TABLE

#define I_sceSdQuit DECLARE_IMPORT(2, sceSdQuit);
Expand Down
Loading
Loading