KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Typedefs | Functions
spu.h File Reference

Functions related to sound. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <dc/g2bus.h>

Go to the source code of this file.

Typedefs

typedef g2_dma_callback_t spu_dma_callback_t
 SPU DMA callback type. More...
 

Functions

void spu_write_wait ()
 Waits for the sound FIFO to empty. More...
 
void spu_memload (uint32 to, void *from, int length)
 Copy a block of data to sound RAM. More...
 
void spu_memread (void *to, uint32 from, int length)
 Copy a block of data from sound RAM. More...
 
void spu_memset (uint32 to, uint32 what, int length)
 Set a block of sound RAM to the specified value. More...
 
int spu_dma_transfer (void *from, uint32 dest, uint32 length, int block, spu_dma_callback_t callback, ptr_t cbdata)
 Copy a block of data from SH4 RAM to sound RAM via DMA. More...
 
void spu_enable ()
 Enable the SPU. More...
 
void spu_disable ()
 Disable the SPU. More...
 
void spu_cdda_volume (int left_volume, int right_volume)
 Set CDDA volume. More...
 
void spu_cdda_pan (int left_pan, int right_pan)
 Set CDDA panning. More...
 
void spu_master_mixer (int volume, int stereo)
 Set master mixer settings. More...
 
int spu_init ()
 Initialize the SPU. More...
 
int spu_shutdown ()
 Shutdown the SPU. More...
 
int spu_dma_init ()
 Initialize SPU DMA support. More...
 
void spu_dma_shutdown ()
 Shutdown SPU DMA support. More...
 

Detailed Description

Functions related to sound.

This file deals with memory transfers and the like for the sound hardware.

Author
Dan Potter

Typedef Documentation

SPU DMA callback type.

Function Documentation

void spu_cdda_pan ( int  left_pan,
int  right_pan 
)

Set CDDA panning.

Valid values are from 0-31. 16 is centered.

Parameters
left_panPan of the left channel.
right_panPan of the right channel.
void spu_cdda_volume ( int  left_volume,
int  right_volume 
)

Set CDDA volume.

Valid volume values are 0-15.

Parameters
left_volumeVolume of the left channel.
right_volumeVolume of the right channel.
void spu_disable ( )

Disable the SPU.

This function resets all sound channels and puts the ARM in a reset state.

int spu_dma_init ( )

Initialize SPU DMA support.

This function sets up the DMA support for transfers to the sound RAM area.

Return values
0On success (no error conditions defined).
void spu_dma_shutdown ( )

Shutdown SPU DMA support.

int spu_dma_transfer ( void *  from,
uint32  dest,
uint32  length,
int  block,
spu_dma_callback_t  callback,
ptr_t  cbdata 
)

Copy a block of data from SH4 RAM to sound RAM via DMA.

This function sets up a DMA transfer from main RAM to the sound RAM with G2 DMA.

Parameters
fromA pointer in main RAM to transfer from. Must be 32-byte aligned.
destOffset in sound RAM to transfer to. Do not include the 0xA0800000 part, its implied. Must be 32-byte aligned.
lengthNumber of bytes to copy. Must be a multiple of 32.
block1 if you want to wait for the transfer to complete, 0 otherwise (use the callback for this case).
callbackFunction to call when the DMA completes. Can be NULL if you don't want to have a callback. This will be called in an interrupt context, so keep that in mind when writing the function.
cbdataData to pass to the callback function.
Return values
-1On failure. Sets errno as appropriate.
0On success.
Error Conditions:
EINVAL - Invalid channel
EFAULT - from or dest is not aligned
EIO - I/O error
void spu_enable ( )

Enable the SPU.

This function resets all sound channels and lets the ARM out of reset.

int spu_init ( )

Initialize the SPU.

This function will reset the SPU, clear the sound RAM, reinit the CDDA support and run an infinite loop on the ARM.

Return values
0On success (no error conditions defined).
void spu_master_mixer ( int  volume,
int  stereo 
)

Set master mixer settings.

This function sets the master mixer volume and mono/stereo setting.

Parameters
volumeThe volume to set (0-15).
stereo1 for stereo output, 0 for mono.
void spu_memload ( uint32  to,
void *  from,
int  length 
)

Copy a block of data to sound RAM.

This function acts much like memcpy() but copies to the sound RAM area.

Parameters
toThe offset in sound RAM to copy to. Do not include the 0xA0800000 part, it is implied.
fromA pointer to copy from.
lengthThe number of bytes to copy. Automatically rounded up to be a multiple of 4.
void spu_memread ( void *  to,
uint32  from,
int  length 
)

Copy a block of data from sound RAM.

This function acts much like memcpy() but copies from the sound RAM area.

Parameters
toA pointer to copy to.
fromThe offset in sound RAM to copy from. Do not include the 0xA0800000 part, it is implied.
lengthThe number of bytes to copy. Automatically rounded up to be a multiple of 4.
void spu_memset ( uint32  to,
uint32  what,
int  length 
)

Set a block of sound RAM to the specified value.

This function acts like memset4(), setting the specified block of sound RAM to the given 32-bit value.

Parameters
toThe offset in sound RAM to set at. Do not include the 0xA0800000 part, it is implied.
whatThe value to set.
lengthThe number of bytes to copy. Automatically rounded up to be a multiple of 4.
int spu_shutdown ( )

Shutdown the SPU.

This function disables the SPU and clears sound RAM.

Return values
0On success (no error conditions defined).
void spu_write_wait ( )

Waits for the sound FIFO to empty.