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
3 changes: 2 additions & 1 deletion iop/sound/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SUBDIRS = \
libsnd2 \
libspu2 \
ps2snd \
rspu2drv
rspu2drv \
sdrdrv

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/Rules.make
23 changes: 23 additions & 0 deletions iop/sound/sdrdrv/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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.

IOP_IMPORT_INCS += \
sound/libsd \
system/intrman \
system/loadcore \
system/sifcmd \
system/sysclib \
system/sysmem \
system/threadman

IOP_OBJS = sdd_main.o sdd_com.o sdd_cb.o imports.o exports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
include $(PS2SDKSRC)/iop/Rules.make
include $(PS2SDKSRC)/iop/Rules.release
15 changes: 15 additions & 0 deletions iop/sound/sdrdrv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Sound Device Remote Library

This module is a IOP-side SIF RPC server for accessing libsd functions.

## Configurations

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

* `sdrdrv` -> 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.
25 changes: 25 additions & 0 deletions iop/sound/sdrdrv/include/sdrdrv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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.
*/

#ifndef _SDRDRV_H
#define _SDRDRV_H

typedef int (*sceSdrUserCommandFunction)(unsigned int command, void *data, int size);

extern int sceSdrChangeThreadPriority(int priority_main, int priority_cb);
extern sceSdrUserCommandFunction sceSdrSetUserCommandFunction(int command, sceSdrUserCommandFunction func);

#define sdrdrv_IMPORTS_start DECLARE_IMPORT_TABLE(sdrdrv, 1, 1)
#define sdrdrv_IMPORTS_end END_IMPORT_TABLE

#define I_sceSdrChangeThreadPriority DECLARE_IMPORT(4, sceSdrChangeThreadPriority)
#define I_sceSdrSetUserCommandFunction DECLARE_IMPORT(5, sceSdrSetUserCommandFunction)

#endif
11 changes: 11 additions & 0 deletions iop/sound/sdrdrv/src/exports.tab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

DECLARE_EXPORT_TABLE(sdrdrv, 1, 1)
DECLARE_EXPORT(_start)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(_retonly)
DECLARE_EXPORT(sceSdrChangeThreadPriority)
DECLARE_EXPORT(sceSdrSetUserCommandFunction)
END_EXPORT_TABLE

void _retonly() {}
77 changes: 77 additions & 0 deletions iop/sound/sdrdrv/src/imports.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

libsd_IMPORTS_start
I_sceSdInit
I_sceSdSetParam
I_sceSdGetParam
I_sceSdSetSwitch
I_sceSdGetSwitch
I_sceSdSetAddr
I_sceSdGetAddr
I_sceSdSetCoreAttr
I_sceSdGetCoreAttr
I_sceSdNote2Pitch
I_sceSdPitch2Note
I_sceSdProcBatch
I_sceSdProcBatchEx
I_sceSdVoiceTrans
I_sceSdBlockTrans
I_sceSdVoiceTransStatus
I_sceSdBlockTransStatus
I_sceSdSetEffectAttr
I_sceSdGetEffectAttr
I_sceSdClearEffectWorkArea
I_sceSdSetTransIntrHandler
I_sceSdSetSpu2IntrHandler
I_sceSdStopTrans
I_sceSdCleanEffectWorkArea
I_sceSdSetEffectMode
I_sceSdSetEffectModeParams
I_sceSdSetIRQCallback
I_sceSdSetTransCallback
libsd_IMPORTS_end

sysmem_IMPORTS_start
I_Kprintf
sysmem_IMPORTS_end

intrman_IMPORTS_start
I_CpuSuspendIntr
I_CpuResumeIntr
intrman_IMPORTS_end

loadcore_IMPORTS_start
I_RegisterLibraryEntries
I_ReleaseLibraryEntries
loadcore_IMPORTS_end

sifcmd_IMPORTS_start
I_sceSifInitRpc
I_sceSifBindRpc
I_sceSifCallRpc
I_sceSifRegisterRpc
I_sceSifSetRpcQueue
I_sceSifRpcLoop
I_sceSifRemoveRpc
I_sceSifRemoveRpcQueue
sifcmd_IMPORTS_end

sysclib_IMPORTS_start
I_look_ctype_table
I_strncmp
I_strtol
I_memset
I_memcpy
sysclib_IMPORTS_end

thbase_IMPORTS_start
I_CreateThread
I_DeleteThread
I_StartThread
I_TerminateThread
I_ChangeThreadPriority
I_GetThreadId
I_ReferThreadStatus
I_SleepThread
I_iWakeupThread
I_iCancelWakeupThread
thbase_IMPORTS_end
27 changes: 27 additions & 0 deletions iop/sound/sdrdrv/src/irx_imports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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.
#
# Defines all IRX imports.
*/

#ifndef IOP_IRX_IMPORTS_H
#define IOP_IRX_IMPORTS_H

#include <irx.h>

/* Please keep these in alphabetical order! */
#include <intrman.h>
#include <libsd.h>
#include <loadcore.h>
#include <sifcmd.h>
#include <sysclib.h>
#include <sysmem.h>
#include <thbase.h>

#endif /* IOP_IRX_IMPORTS_H */
183 changes: 183 additions & 0 deletions iop/sound/sdrdrv/src/sdd_cb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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.
*/

#include <sdr_i.h>

// Unofficial: argument
static void sceSifCmdLoop2(SifRpcClientData_t *cd, SdrEECBInfo *cbi)
{
while ( 1 )
{
int state;
// Unofficial: make local variable
SdrEECBData eeCBDataSend;

while ( !cbi->m_eeCBData.mode )
SleepThread();
CpuSuspendIntr(&state);
// Unofficial: was inlined
memcpy(&eeCBDataSend, &cbi->m_eeCBData, sizeof(eeCBDataSend));
CpuResumeIntr(state);
#if SDRDRV_EECB_COMPAT
if ( eeCBDataSend.mode )
{
int mode_tmp;
int mode_cur;

mode_tmp = eeCBDataSend.mode;
mode_cur = mode_tmp;
while ( 1 )
{
// Only the obsolete DMA0/DMA1/IRQ funcs (not implemented in libsdr 4.0.1) clashes
if ( mode_cur & (1 << 0) )
{
mode_cur &= ~(1 << 0);
eeCBDataSend.mode = 1;
}
else if ( mode_cur & (1 << 1) )
{
mode_cur &= ~(1 << 1);
eeCBDataSend.mode = 2;
}
else if ( mode_cur & (1 << 2) )
{
mode_cur &= ~(1 << 2);
eeCBDataSend.mode = 3;
}
else if ( mode_cur & (1 << 8) )
{
mode_cur &= ~(1 << 8);
eeCBDataSend.mode = 11;
}
else if ( mode_cur & (1 << 9) )
{
mode_cur &= ~(1 << 9);
eeCBDataSend.mode = 12;
}
else if ( mode_cur & (1 << 10) )
{
mode_cur &= ~(1 << 10);
eeCBDataSend.mode = 13;
}
else
{
break;
}
sceSifCallRpc(cd, 0, 0, &eeCBDataSend, sizeof(eeCBDataSend), 0, 0, 0, 0);
}
eeCBDataSend.mode = mode_tmp;
}
// Set the high bit to make libsdr 2.0.0 and lower not process it
eeCBDataSend.mode |= ((u32)1 << 31);
#endif
sceSifCallRpc(cd, 0, 0, &eeCBDataSend, sizeof(eeCBDataSend), 0, 0, 0, 0);
#if SDRDRV_EECB_COMPAT
eeCBDataSend.mode &= ~((u32)1 << 31);
#endif
CpuSuspendIntr(&state);
if ( cbi->m_eeCBData.mode == eeCBDataSend.mode )
{
cbi->m_eeCBData.mode = 0;
iCancelWakeupThread(0);
CpuResumeIntr(state);
break;
}
cbi->m_eeCBData.mode &= ~eeCBDataSend.mode;
CpuResumeIntr(state);
}
}

#if SDRDRV_OBSOLETE_FUNCS
int _sce_sdrDMA0CallBackProc(void *data)
{
(void)data;

g_eeCBInfo.m_eeCBData.mode |= (1 << 0);
iWakeupThread(g_eeCBInfo.m_thid_cb);
return 1;
}

int _sce_sdrDMA1CallBackProc(void *data)
{
(void)data;

g_eeCBInfo.m_eeCBData.mode |= (1 << 1);
iWakeupThread(g_eeCBInfo.m_thid_cb);
return 1;
}

int _sce_sdrIRQCallBackProc(void *data)
{
(void)data;

g_eeCBInfo.m_eeCBData.mode |= (1 << 2);
iWakeupThread(g_eeCBInfo.m_thid_cb);
return 1;
}
#endif

int _sce_sdrDMA0IntrHandler(int core, void *common)
{
SdrEECBInfo *cbi;

(void)core;

cbi = (SdrEECBInfo *)common;
cbi->m_eeCBData.mode |= (1 << 8);
iWakeupThread(cbi->m_thid_cb);
return 0;
}

int _sce_sdrDMA1IntrHandler(int core, void *common)
{
SdrEECBInfo *cbi;

(void)core;

cbi = (SdrEECBInfo *)common;
cbi->m_eeCBData.mode |= (1 << 9);
iWakeupThread(cbi->m_thid_cb);
return 0;
}

int _sce_sdrSpu2IntrHandler(int core_bit, void *common)
{
SdrEECBInfo *cbi;

(void)core_bit;

cbi = (SdrEECBInfo *)common;
cbi->m_eeCBData.mode |= (1 << 10);
cbi->m_eeCBData.voice_bit = core_bit;
iWakeupThread(cbi->m_thid_cb);
return 0;
}

void sce_sdrcb_loop(void *arg)
{
SdrEECBInfo *cbi;
// Unofficial: make local
SifRpcClientData_t cd;

cbi = (SdrEECBInfo *)arg;
cbi->m_eeCBData.mode = 0;
while ( sceSifBindRpc(&cd, 0x80000704, 0) >= 0 )
{
int i;

for ( i = 0; i < 10000; i += 1 )
;
if ( cd.server )
sceSifCmdLoop2(&cd, cbi);
}
Kprintf("error \n");
while ( 1 )
;
}
Loading