PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
libsd.c File Reference
#include <irx_imports.h>
#include <iop_mmio_hwport.h>
#include <spu2_mmio_hwport.h>
#include <libsd.h>
#include <stdarg.h>
+ Include dependency graph for libsd.c:

Go to the source code of this file.

Data Structures

struct  mode_data_struct
 
struct  IntrData
 
struct  BlockHandlerIntrData_
 
struct  CleanRegionBufferElement_
 
struct  CleanRegionBuffer_
 

Macros

#define SD_DMA_CS   (1 << 9)
 
#define SD_DMA_START   (1 << 24)
 
#define SD_DMA_DIR_SPU2IOP   0
 
#define SD_DMA_DIR_IOP2SPU   1
 

Typedefs

typedef struct BlockHandlerIntrData_ BlockHandlerIntrData_t
 
typedef struct CleanRegionBufferElement_ CleanRegionBufferElement_t
 
typedef struct CleanRegionBuffer_ CleanRegionBuffer_t
 
typedef int(* SdCleanHandler) (int core)
 

Functions

 IRX_ID ("Sound_Device_Library", 3, 3)
 
static int GetEEA (int core)
 
static void InitSpu2_Inner (void)
 
static void libsd_do_busyloop (int count)
 
static u32 DmaStartStop (int mainarg, void *vararg2, u32 vararg3)
 
static u32 VoiceTrans_Write_IOMode (const u16 *iopaddr, u32 size, int core)
 
static u32 BlockTransWriteFrom (u8 *iopaddr, u32 size, int core, int mode, u8 *startaddr)
 
static u32 BlockTransRead (u8 *iopaddr, u32 size, int core, u16 mode)
 
static void reset_vars (void)
 
static const u32 g_ClearEffectData[256] __attribute__ ((__aligned__(16)))
 
int _start (int ac, char **av)
 
static void SetEffectRegisterPair (spu2_u16pair_t *pair, u32 val)
 
static void SetEffectData (int core, const struct mode_data_struct *mode_data)
 
int sceSdClearEffectWorkArea (int core, int channel, int effect_mode)
 
static int CleanHandler (int core)
 
int sceSdCleanEffectWorkArea (int core, int channel, int effect_mode)
 
void sceSdGetEffectAttr (int core, sceSdEffectAttr *attr)
 
int sceSdSetEffectAttr (int core, const sceSdEffectAttr *attr)
 
int sceSdSetEffectMode (int core, const sceSdEffectAttr *param)
 
int sceSdSetEffectModeParams (int core, const sceSdEffectAttr *attr)
 
static void InitSpu2 (void)
 
static void InitCoreVolume (int flag)
 
int sceSdVoiceTrans (s16 chan, u16 mode, u8 *iopaddr, u32 *spuaddr, u32 size)
 
u32 sceSdVoiceTransStatus (s16 channel, s16 flag)
 
int sceSdStopTrans (int channel)
 
int sceSdBlockTrans (s16 chan, u16 mode, u8 *iopaddr, u32 size,...)
 
u32 sceSdBlockTransStatus (s16 channel, s16 flag)
 
static int InitSpdif ()
 
static void SetDmaWrite (int chan)
 
static void SetDmaRead (int chan)
 
static void __attribute__ ((optimize("no-unroll-loops")))
 
static void do_finish_block_clean_xfer (int core)
 
static int TransInterrupt (IntrData *intr)
 
static int SifDmaBatch (void *ee_addr, void *iop_addr, int size)
 
int sceSdProcBatch (const sceSdBatch *batch, u32 *rets, u32 num)
 
int sceSdProcBatchEx (const sceSdBatch *batch, u32 *rets, u32 num, u32 voice)
 
void sceSdSetParam (u16 entry, u16 value)
 
u16 sceSdGetParam (u16 entry)
 
void sceSdSetSwitch (u16 entry, u32 value)
 
u32 sceSdGetSwitch (u16 entry)
 
void sceSdSetAddr (u16 entry, u32 value)
 
u32 sceSdGetAddr (u16 entry)
 
u16 sceSdNote2Pitch (u16 center_note, u16 center_fine, u16 note, s16 fine)
 
u16 sceSdPitch2Note (u16 center_note, u16 center_fine, u16 pitch)
 
static int SetSpdifMode (int val)
 
void sceSdSetCoreAttr (u16 entry, u16 value)
 
u16 sceSdGetCoreAttr (u16 entry)
 
SdIntrCallback sceSdSetTransCallback (s32 core, SdIntrCallback cb)
 
sceSdTransIntrHandler sceSdSetTransIntrHandler (int channel, sceSdTransIntrHandler func, void *arg)
 
void * sceSdGetTransIntrHandlerArgument (int arg)
 
SdIntrCallback sceSdSetIRQCallback (SdIntrCallback cb)
 
sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler (sceSdSpu2IntrHandler func, void *arg)
 
void * sceSdGetSpu2IntrHandlerArgument ()
 
static int Spu2Interrupt (void *data)
 
static int InitVoices (void)
 
static int Reset (int flag)
 
int sceSdInit (int flag)
 
int sceSdQuit ()
 

Variables

struct irx_export_table _exp_libsd
 
static vu16 *const g_ParamRegList []
 
static const u32 g_EffectSizes []
 
static const struct mode_data_struct g_EffectParams []
 
static const u16 g_NotePitchTable []
 
static const u16 g_CoreAttrShifts []
 
static const u16 g_VoiceDataInit []
 
static int g_VoiceTransStatus [2]
 
static int g_VoiceTransIoMode [2]
 
static int g_SpdifSettings
 
static sceSdEffectAttr g_EffectAttr [2]
 
static int g_VoiceTransCompleteBool [2]
 
static int g_VoiceTransCompleteEf [2]
 
static int g_vars_inited
 
static SdIntrCallback g_Spu2IrqCallback
 
static sceSdSpu2IntrHandler g_Spu2IntrHandler
 
static void * g_Spu2IntrHandlerData
 
static sceSdTransIntrHandler g_TransIntrHandlers [2]
 
static BlockHandlerIntrData_t g_BlockHandlerIntrData [2]
 
static SdCleanHandler g_CleanHandlers [2]
 
static IntrData g_TransIntrData [2]
 
static u32 g_CleanRegionMax [2]
 
static u32 g_CleanRegionCur [2]
 
static CleanRegionBuffer_t g_CleanRegionBuffer [2]
 
static u32 g_BlockTransBuff [2]
 
static u8 * g_BlockTransAddr [2]
 
static u32 g_BlockTransSize [2]
 
static SdIntrCallback g_TransIntrCallbacks [2]
 
static u32 g_EffectAddr [2]
 

Detailed Description

Part of the IOP Sound Driver

Definition in file libsd.c.


Data Structure Documentation

◆ mode_data_struct

struct mode_data_struct

Definition at line 33 of file libsd.c.

Data Fields
u32 m_mode_flags
u16 m_d_apf1_size
u16 m_d_apf2_size
u16 m_d_iir_vol
u16 m_d_comb1_vol
u16 m_d_comb2_vol
u16 m_d_comb3_vol
u16 m_d_comb4_vol
u16 m_d_wall_vol
u16 m_d_apf1_vol
u16 m_d_apf2_vol
u16 m_d_same_l_dst
u16 m_d_same_r_dst
u16 m_d_comb1_l_src
u16 m_d_comb1_r_src
u16 m_d_comb2_l_src
u16 m_d_comb2_r_src
u16 m_d_same_l_src
u16 m_d_same_r_src
u16 m_d_diff_l_dst
u16 m_d_diff_r_dst
u16 m_d_comb3_l_src
u16 m_d_comb3_r_src
u16 m_d_comb4_l_src
u16 m_d_comb4_r_src
u16 m_d_diff_l_src
u16 m_d_diff_r_src
u16 m_d_apf1_l_dst
u16 m_d_apf1_r_dst
u16 m_d_apf2_l_dst
u16 m_d_apf2_r_dst
u16 m_d_in_coef_l
u16 m_d_in_coef_r

◆ IntrData

struct IntrData

Definition at line 6 of file freesd.h.

Data Fields
u32 mode
void * data
u32 m_mode
void * m_data

◆ BlockHandlerIntrData_

struct BlockHandlerIntrData_

Definition at line 76 of file libsd.c.

Data Fields
sceSdBlockTransHandler m_cb
void * m_userdata

◆ CleanRegionBufferElement_

struct CleanRegionBufferElement_

Definition at line 82 of file libsd.c.

Data Fields
u32 * m_spuaddr
u32 m_size

◆ CleanRegionBuffer_

struct CleanRegionBuffer_

Definition at line 88 of file libsd.c.

+ Collaboration diagram for CleanRegionBuffer_:
Data Fields
CleanRegionBufferElement_t m_elements[97]

Macro Definition Documentation

◆ SD_DMA_CS

#define SD_DMA_CS   (1 << 9)

Definition at line 26 of file libsd.c.

◆ SD_DMA_START

#define SD_DMA_START   (1 << 24)

Definition at line 27 of file libsd.c.

◆ SD_DMA_DIR_SPU2IOP

#define SD_DMA_DIR_SPU2IOP   0

Definition at line 28 of file libsd.c.

◆ SD_DMA_DIR_IOP2SPU

#define SD_DMA_DIR_IOP2SPU   1

Definition at line 29 of file libsd.c.

Typedef Documentation

◆ SdCleanHandler

typedef int(* SdCleanHandler) (int core)

Definition at line 93 of file libsd.c.

Function Documentation

◆ GetEEA()

static int GetEEA ( int  core)
static

Definition at line 1078 of file libsd.c.

◆ InitSpu2_Inner()

static void InitSpu2_Inner ( void  )
static

Definition at line 1169 of file libsd.c.

◆ libsd_do_busyloop()

static void libsd_do_busyloop ( int  count)
static

Definition at line 1525 of file libsd.c.

◆ DmaStartStop()

static u32 DmaStartStop ( int  mainarg,
void *  vararg2,
u32  vararg3 
)
static

Definition at line 1533 of file libsd.c.

◆ VoiceTrans_Write_IOMode()

static u32 VoiceTrans_Write_IOMode ( const u16 *  iopaddr,
u32  size,
int  core 
)
static

Definition at line 1637 of file libsd.c.

◆ BlockTransWriteFrom()

static u32 BlockTransWriteFrom ( u8 *  iopaddr,
u32  size,
int  core,
int  mode,
u8 *  startaddr 
)
static

Definition at line 1793 of file libsd.c.

◆ BlockTransRead()

static u32 BlockTransRead ( u8 *  iopaddr,
u32  size,
int  core,
u16  mode 
)
static

Definition at line 1851 of file libsd.c.

◆ reset_vars()

static void reset_vars ( void  )
static

Definition at line 2509 of file libsd.c.

◆ _start()

int _start ( int  ac,
char **  av 
)

Definition at line 734 of file libsd.c.

◆ SetEffectRegisterPair()

static void SetEffectRegisterPair ( spu2_u16pair_t pair,
u32  val 
)
static

Definition at line 751 of file libsd.c.

◆ SetEffectData()

static void SetEffectData ( int  core,
const struct mode_data_struct mode_data 
)
static

Definition at line 759 of file libsd.c.

◆ sceSdClearEffectWorkArea()

int sceSdClearEffectWorkArea ( int  core,
int  channel,
int  effect_mode 
)

Definition at line 842 of file libsd.c.

◆ CleanHandler()

static int CleanHandler ( int  core)
static

Definition at line 915 of file libsd.c.

◆ sceSdCleanEffectWorkArea()

int sceSdCleanEffectWorkArea ( int  core,
int  channel,
int  effect_mode 
)

Definition at line 928 of file libsd.c.

◆ sceSdGetEffectAttr()

void sceSdGetEffectAttr ( int  core,
sceSdEffectAttr attr 
)

Definition at line 976 of file libsd.c.

◆ sceSdSetEffectAttr()

int sceSdSetEffectAttr ( int  core,
const sceSdEffectAttr attr 
)

Definition at line 988 of file libsd.c.

◆ sceSdSetEffectMode()

int sceSdSetEffectMode ( int  core,
const sceSdEffectAttr param 
)

Definition at line 1085 of file libsd.c.

◆ sceSdSetEffectModeParams()

int sceSdSetEffectModeParams ( int  core,
const sceSdEffectAttr attr 
)

Definition at line 1129 of file libsd.c.

◆ InitSpu2()

static void InitSpu2 ( void  )
static

Definition at line 1184 of file libsd.c.

◆ InitCoreVolume()

static void InitCoreVolume ( int  flag)
static

Definition at line 1195 of file libsd.c.

◆ sceSdVoiceTrans()

int sceSdVoiceTrans ( s16  chan,
u16  mode,
u8 *  iopaddr,
u32 *  spuaddr,
u32  size 
)

Definition at line 1246 of file libsd.c.

◆ sceSdVoiceTransStatus()

u32 sceSdVoiceTransStatus ( s16  channel,
s16  flag 
)

Definition at line 1293 of file libsd.c.

◆ sceSdStopTrans()

int sceSdStopTrans ( int  channel)

Definition at line 1323 of file libsd.c.

◆ sceSdBlockTrans()

int sceSdBlockTrans ( s16  chan,
u16  mode,
u8 *  iopaddr,
u32  size,
  ... 
)

Definition at line 1334 of file libsd.c.

◆ sceSdBlockTransStatus()

u32 sceSdBlockTransStatus ( s16  channel,
s16  flag 
)

Definition at line 1426 of file libsd.c.

◆ InitSpdif()

static int InitSpdif ( )
static

Definition at line 1442 of file libsd.c.

◆ SetDmaWrite()

static void SetDmaWrite ( int  chan)
static

Definition at line 1494 of file libsd.c.

◆ SetDmaRead()

static void SetDmaRead ( int  chan)
static

Definition at line 1503 of file libsd.c.

◆ __attribute__()

static void __attribute__ ( (optimize("no-unroll-loops"))  )
static

Definition at line 1512 of file libsd.c.

◆ do_finish_block_clean_xfer()

static void do_finish_block_clean_xfer ( int  core)
static

Definition at line 1670 of file libsd.c.

◆ TransInterrupt()

static int TransInterrupt ( IntrData intr)
static

Definition at line 1678 of file libsd.c.

◆ SifDmaBatch()

static int SifDmaBatch ( void *  ee_addr,
void *  iop_addr,
int  size 
)
static

Definition at line 1881 of file libsd.c.

◆ sceSdProcBatch()

int sceSdProcBatch ( const sceSdBatch batch,
u32 *  rets,
u32  num 
)

Definition at line 1907 of file libsd.c.

◆ sceSdProcBatchEx()

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

Definition at line 1961 of file libsd.c.

◆ sceSdSetParam()

void sceSdSetParam ( u16  entry,
u16  value 
)

Definition at line 2073 of file libsd.c.

◆ sceSdGetParam()

u16 sceSdGetParam ( u16  entry)

Definition at line 2080 of file libsd.c.

◆ sceSdSetSwitch()

void sceSdSetSwitch ( u16  entry,
u32  value 
)

Definition at line 2087 of file libsd.c.

◆ sceSdGetSwitch()

u32 sceSdGetSwitch ( u16  entry)

Definition at line 2096 of file libsd.c.

◆ sceSdSetAddr()

void sceSdSetAddr ( u16  entry,
u32  value 
)

Definition at line 2104 of file libsd.c.

◆ sceSdGetAddr()

u32 sceSdGetAddr ( u16  entry)

Definition at line 2114 of file libsd.c.

◆ sceSdNote2Pitch()

u16 sceSdNote2Pitch ( u16  center_note,
u16  center_fine,
u16  note,
s16  fine 
)

Definition at line 2137 of file libsd.c.

◆ sceSdPitch2Note()

u16 sceSdPitch2Note ( u16  center_note,
u16  center_fine,
u16  pitch 
)

Definition at line 2170 of file libsd.c.

◆ SetSpdifMode()

static int SetSpdifMode ( int  val)
static

Definition at line 2201 of file libsd.c.

◆ sceSdSetCoreAttr()

void sceSdSetCoreAttr ( u16  entry,
u16  value 
)

Definition at line 2248 of file libsd.c.

◆ sceSdGetCoreAttr()

u16 sceSdGetCoreAttr ( u16  entry)

Definition at line 2276 of file libsd.c.

◆ sceSdSetTransCallback()

SdIntrCallback sceSdSetTransCallback ( s32  core,
SdIntrCallback  cb 
)

Definition at line 2299 of file libsd.c.

◆ sceSdSetTransIntrHandler()

sceSdTransIntrHandler sceSdSetTransIntrHandler ( int  channel,
sceSdTransIntrHandler  func,
void *  arg 
)

Definition at line 2310 of file libsd.c.

◆ sceSdGetTransIntrHandlerArgument()

void * sceSdGetTransIntrHandlerArgument ( int  arg)

Definition at line 2323 of file libsd.c.

◆ sceSdSetIRQCallback()

SdIntrCallback sceSdSetIRQCallback ( SdIntrCallback  cb)

Definition at line 2328 of file libsd.c.

◆ sceSdSetSpu2IntrHandler()

sceSdSpu2IntrHandler sceSdSetSpu2IntrHandler ( sceSdSpu2IntrHandler  func,
void *  arg 
)

Definition at line 2337 of file libsd.c.

◆ sceSdGetSpu2IntrHandlerArgument()

void * sceSdGetSpu2IntrHandlerArgument ( )

Definition at line 2347 of file libsd.c.

◆ Spu2Interrupt()

static int Spu2Interrupt ( void *  data)
static

Definition at line 2352 of file libsd.c.

◆ InitVoices()

static int InitVoices ( void  )
static

Definition at line 2375 of file libsd.c.

◆ Reset()

static int Reset ( int  flag)
static

Definition at line 2447 of file libsd.c.

◆ sceSdInit()

int sceSdInit ( int  flag)

Definition at line 2519 of file libsd.c.

◆ sceSdQuit()

int sceSdQuit ( )

Definition at line 2539 of file libsd.c.

Variable Documentation

◆ g_ParamRegList

vu16* const g_ParamRegList[]
static

Definition at line 105 of file libsd.c.

◆ g_EffectSizes

const u32 g_EffectSizes[]
static
Initial value:
=
{
0x2,
0x4d8,
0x3e8,
0x908,
0xdfc,
0x15bc,
0x1ed8,
0x3008,
0x3008,
0x780,
}

Definition at line 154 of file libsd.c.

◆ g_EffectParams

const struct mode_data_struct g_EffectParams[]
static

Definition at line 167 of file libsd.c.

◆ g_NotePitchTable

const u16 g_NotePitchTable[]
static

Definition at line 530 of file libsd.c.

◆ g_CoreAttrShifts

const u16 g_CoreAttrShifts[]
static
Initial value:
=
{
0x7,
0x6,
0xe,
0x8,
}

Definition at line 674 of file libsd.c.

◆ g_VoiceDataInit

const u16 g_VoiceDataInit[]
static
Initial value:
=
{
0x700,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
}

Definition at line 681 of file libsd.c.

◆ g_VoiceTransStatus

int g_VoiceTransStatus[2]
static

Definition at line 697 of file libsd.c.

◆ g_VoiceTransIoMode

int g_VoiceTransIoMode[2]
static

Definition at line 699 of file libsd.c.

◆ g_SpdifSettings

int g_SpdifSettings
static

Definition at line 701 of file libsd.c.

◆ g_EffectAttr

sceSdEffectAttr g_EffectAttr[2]
static

Definition at line 703 of file libsd.c.

◆ g_VoiceTransCompleteBool

int g_VoiceTransCompleteBool[2]
static

Definition at line 705 of file libsd.c.

◆ g_VoiceTransCompleteEf

int g_VoiceTransCompleteEf[2]
static

Definition at line 707 of file libsd.c.

◆ g_vars_inited

int g_vars_inited
static

Definition at line 709 of file libsd.c.

◆ g_Spu2IrqCallback

SdIntrCallback g_Spu2IrqCallback
static

Definition at line 711 of file libsd.c.

◆ g_Spu2IntrHandler

sceSdSpu2IntrHandler g_Spu2IntrHandler
static

Definition at line 713 of file libsd.c.

◆ g_Spu2IntrHandlerData

void* g_Spu2IntrHandlerData
static

Definition at line 715 of file libsd.c.

◆ g_TransIntrHandlers

sceSdTransIntrHandler g_TransIntrHandlers[2]
static

Definition at line 717 of file libsd.c.

◆ g_BlockHandlerIntrData

BlockHandlerIntrData_t g_BlockHandlerIntrData[2]
static

Definition at line 719 of file libsd.c.

◆ g_CleanHandlers

SdCleanHandler g_CleanHandlers[2]
static

Definition at line 721 of file libsd.c.

◆ g_TransIntrData

IntrData g_TransIntrData[2]
static

Definition at line 723 of file libsd.c.

◆ g_CleanRegionMax

u32 g_CleanRegionMax[2]
static

Definition at line 724 of file libsd.c.

◆ g_CleanRegionCur

u32 g_CleanRegionCur[2]
static

Definition at line 725 of file libsd.c.

◆ g_CleanRegionBuffer

CleanRegionBuffer_t g_CleanRegionBuffer[2]
static

Definition at line 726 of file libsd.c.

◆ g_BlockTransBuff

u32 g_BlockTransBuff[2]
static

Definition at line 727 of file libsd.c.

◆ g_BlockTransAddr

u8* g_BlockTransAddr[2]
static

Definition at line 728 of file libsd.c.

◆ g_BlockTransSize

u32 g_BlockTransSize[2]
static

Definition at line 729 of file libsd.c.

◆ g_TransIntrCallbacks

SdIntrCallback g_TransIntrCallbacks[2]
static

Definition at line 731 of file libsd.c.

◆ g_EffectAddr

u32 g_EffectAddr[2]
static

Definition at line 732 of file libsd.c.