RetroArch
Macros | Functions | Variables
audio.c File Reference
#include <stdlib.h>
#include "asm.h"
#include "processor.h"
#include "irq.h"
#include "audio.h"
#include "lwp_watchdog.h"
Include dependency graph for audio.c:

Macros

#define STACKSIZE   16384
 
#define DSPCR_DSPRESET   0x0800
 
#define DSPCR_DSPDMA   0x0200
 
#define DSPCR_DSPINTMSK   0x0100
 
#define DSPCR_DSPINT   0x0080
 
#define DSPCR_ARINTMSK   0x0040
 
#define DSPCR_ARINT   0x0020
 
#define DSPCR_AIINTMSK   0x0010
 
#define DSPCR_AIINT   0x0008
 
#define DSPCR_HALT   0x0004
 
#define DSPCR_PIINT   0x0002
 
#define DSPCR_RES   0x0001
 
#define AI_CONTROL   0
 
#define AI_STREAM_VOL   1
 
#define AI_SAMPLE_COUNT   2
 
#define AI_INT_TIMING   3
 
#define AI_PSTAT   0x01
 
#define AI_AISFR   0x02
 
#define AI_AIINTMSK   0x04
 
#define AI_AIINT   0x08
 
#define AI_AIINTVLD   0x10
 
#define AI_SCRESET   0x20
 
#define AI_DMAFR   0x40
 
#define _SHIFTL(v, s, w)   ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
 
#define _SHIFTR(v, s, w)   ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
 

Functions

static u8 *__CallbackStack __attribute__ ((used))
 
static void __AICallbackStackSwitch (AIDCallback handler)
 
static void __AIDHandler (u32 nIrq, void *pCtx)
 
static void __AISRCINIT ()
 
void AUDIO_Init (u8 *stack)
 Initialize the AUDIO subsystem. More...
 
AIDCallback AUDIO_RegisterDMACallback (AIDCallback callback)
 Register a user callback function for the audio DMA interface. More...
 
void AUDIO_InitDMA (u32 startaddr, u32 len)
 Initialize an audio DMA transfer. More...
 
u16 AUDIO_GetDMAEnableFlag ()
 Get the audio DMA flag. More...
 
void AUDIO_StartDMA ()
 Start the audio DMA operation. More...
 
void AUDIO_StopDMA ()
 Stop the previously started audio DMA operation. More...
 
u32 AUDIO_GetDMABytesLeft ()
 Get the count of bytes, left to play, from the audio DMA interface. More...
 
u32 AUDIO_GetDMAStartAddr ()
 Get the main memory address for the DMA operation. More...
 
u32 AUDIO_GetDMALength ()
 Get the DMA transfer length configured in the audio DMA interface. More...
 
void AUDIO_SetDSPSampleRate (u8 rate)
 Set the sampling rate for the DSP interface. More...
 
u32 AUDIO_GetDSPSampleRate ()
 Get the sampling rate for the DSP interface. More...
 

Variables

static vu16 *const _dspReg = (u16*)0xCC005000
 
static u32 __AIInitFlag = 0
 
static u32 __AIActive = 0
 
static u64 bound_32KHz
 
static u64 bound_48KHz
 
static u64 min_wait
 
static u64 max_wait
 
static u64 buffer
 
static AIDCallback __AID_Callback
 

Macro Definition Documentation

◆ _SHIFTL

#define _SHIFTL (   v,
  s,
  w 
)    ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))

◆ _SHIFTR

#define _SHIFTR (   v,
  s,
  w 
)    ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))

◆ AI_AIINT

#define AI_AIINT   0x08

◆ AI_AIINTMSK

#define AI_AIINTMSK   0x04

◆ AI_AIINTVLD

#define AI_AIINTVLD   0x10

◆ AI_AISFR

#define AI_AISFR   0x02

◆ AI_CONTROL

#define AI_CONTROL   0

◆ AI_DMAFR

#define AI_DMAFR   0x40

◆ AI_INT_TIMING

#define AI_INT_TIMING   3

◆ AI_PSTAT

#define AI_PSTAT   0x01

◆ AI_SAMPLE_COUNT

#define AI_SAMPLE_COUNT   2

◆ AI_SCRESET

#define AI_SCRESET   0x20

◆ AI_STREAM_VOL

#define AI_STREAM_VOL   1

◆ DSPCR_AIINT

#define DSPCR_AIINT   0x0008

◆ DSPCR_AIINTMSK

#define DSPCR_AIINTMSK   0x0010

◆ DSPCR_ARINT

#define DSPCR_ARINT   0x0020

◆ DSPCR_ARINTMSK

#define DSPCR_ARINTMSK   0x0040

◆ DSPCR_DSPDMA

#define DSPCR_DSPDMA   0x0200

◆ DSPCR_DSPINT

#define DSPCR_DSPINT   0x0080

◆ DSPCR_DSPINTMSK

#define DSPCR_DSPINTMSK   0x0100

◆ DSPCR_DSPRESET

#define DSPCR_DSPRESET   0x0800

◆ DSPCR_HALT

#define DSPCR_HALT   0x0004

◆ DSPCR_PIINT

#define DSPCR_PIINT   0x0002

◆ DSPCR_RES

#define DSPCR_RES   0x0001

◆ STACKSIZE

#define STACKSIZE   16384

Function Documentation

◆ __AICallbackStackSwitch()

static void __AICallbackStackSwitch ( AIDCallback  handler)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __AIDHandler()

static void __AIDHandler ( u32  nIrq,
void pCtx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __AISRCINIT()

static void __AISRCINIT ( )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __attribute__()

static u8* __CallbackStack __attribute__ ( (used)  )
static
Here is the call graph for this function:

◆ AUDIO_GetDMABytesLeft()

u32 AUDIO_GetDMABytesLeft ( )

Get the count of bytes, left to play, from the audio DMA interface.

Returns
count of bytes left to play.

◆ AUDIO_GetDMAEnableFlag()

u16 AUDIO_GetDMAEnableFlag ( )

Get the audio DMA flag.

Returns
state of the current DMA operation.

◆ AUDIO_GetDMALength()

u32 AUDIO_GetDMALength ( )

Get the DMA transfer length configured in the audio DMA interface.

Returns
length of data loaded into the audio DMA interface.

◆ AUDIO_GetDMAStartAddr()

u32 AUDIO_GetDMAStartAddr ( )

Get the main memory address for the DMA operation.

Returns
start address of mainmemory loaded into the audio DMA interface.

◆ AUDIO_GetDSPSampleRate()

u32 AUDIO_GetDSPSampleRate ( )

Get the sampling rate for the DSP interface.

Returns
DSP sampling rate (AI_SAMPLERATE_32KHZ,AI_SAMPLERATE_48KHZ)
Here is the caller graph for this function:

◆ AUDIO_Init()

void AUDIO_Init ( u8 stack)

Initialize the AUDIO subsystem.

Parameters
[in]stackpointer to a memory area to work as stack when calling the callbacks. May be NULL
Returns
none
Here is the call graph for this function:

◆ AUDIO_InitDMA()

void AUDIO_InitDMA ( u32  startaddr,
u32  len 
)

Initialize an audio DMA transfer.

Parameters
[in]startaddrstart address of the memory region to load into the audio DMA. NOTE: Has to be aligned on a 32byte boundery!
[in]lenlenght of data to load into the audio DMA. NOTE: Should be a multiple of 32
Returns
none

◆ AUDIO_RegisterDMACallback()

AIDCallback AUDIO_RegisterDMACallback ( AIDCallback  callback)

Register a user callback function for the audio DMA interface.

   This callback will be called whenever the audio DMA requests new data.<br>
   Internally the DMA buffers are double buffered.
Parameters
[in]callbackpointer to the function which to call when AID interrupt has triggered.
Returns
pointer to old callback function or NULL respectively.
Here is the call graph for this function:

◆ AUDIO_SetDSPSampleRate()

void AUDIO_SetDSPSampleRate ( u8  rate)

Set the sampling rate for the DSP interface.

Parameters
[in]ratesampling rate to set for the DSP (AI_SAMPLERATE_32KHZ,AI_SAMPLERATE_48KHZ)
Returns
none
Here is the call graph for this function:

◆ AUDIO_StartDMA()

void AUDIO_StartDMA ( )

Start the audio DMA operation.

   Starts to transfer the data from main memory to the audio interface thru DMA.<br>
   This call should follow the call to AUDIO_InitDMA() which is used to initialize DMA transfers.
Returns
none

◆ AUDIO_StopDMA()

void AUDIO_StopDMA ( )

Stop the previously started audio DMA operation.

Returns
none

Variable Documentation

◆ __AIActive

u32 __AIActive = 0
static

◆ __AID_Callback

AIDCallback __AID_Callback
static

◆ __AIInitFlag

u32 __AIInitFlag = 0
static

◆ _dspReg

vu16* const _dspReg = (u16*)0xCC005000
static

◆ bound_32KHz

u64 bound_32KHz
static

◆ bound_48KHz

u64 bound_48KHz
static

◆ buffer

u64 buffer
static

◆ max_wait

u64 max_wait
static

◆ min_wait

u64 min_wait
static