KallistiOS
2.0.0
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
kernel
arch
dreamcast
include
dc
spu.h
Go to the documentation of this file.
1
/* KallistiOS 2.0.0
2
3
dc/spu.h
4
Copyright (C) 2000-2001 Dan Potter
5
6
*/
7
8
/** \file dc/spu.h
9
\brief Functions related to sound.
10
11
This file deals with memory transfers and the like for the sound hardware.
12
13
\author Dan Potter
14
*/
15
16
#ifndef __DC_SPU_H
17
#define __DC_SPU_H
18
19
#include <sys/cdefs.h>
20
__BEGIN_DECLS
21
22
#include <
arch/types.h
>
23
#include <
dc/g2bus.h
>
24
25
/** \brief Waits for the sound FIFO to empty. */
26
void
spu_write_wait
();
27
28
/** \brief Copy a block of data to sound RAM.
29
30
This function acts much like memcpy() but copies to the sound RAM area.
31
32
\param to The offset in sound RAM to copy to. Do not include
33
the 0xA0800000 part, it is implied.
34
\param from A pointer to copy from.
35
\param length The number of bytes to copy. Automatically rounded
36
up to be a multiple of 4.
37
*/
38
void
spu_memload
(
uint32
to,
void
*from,
int
length);
39
40
/** \brief Copy a block of data from sound RAM.
41
42
This function acts much like memcpy() but copies from the sound RAM area.
43
44
\param to A pointer to copy to.
45
\param from The offset in sound RAM to copy from. Do not include
46
the 0xA0800000 part, it is implied.
47
\param length The number of bytes to copy. Automatically rounded
48
up to be a multiple of 4.
49
*/
50
void
spu_memread
(
void
*to,
uint32
from,
int
length);
51
52
/** \brief Set a block of sound RAM to the specified value.
53
54
This function acts like memset4(), setting the specified block of sound RAM
55
to the given 32-bit value.
56
57
\param to The offset in sound RAM to set at. Do not include
58
the 0xA0800000 part, it is implied.
59
\param what The value to set.
60
\param length The number of bytes to copy. Automatically rounded
61
up to be a multiple of 4.
62
*/
63
void
spu_memset
(
uint32
to,
uint32
what,
int
length);
64
65
/* DMA copy from SH-4 RAM to SPU RAM; length must be a multiple of 32,
66
and the source and destination addresses must be aligned on 32-byte
67
boundaries. If block is non-zero, this function won't return until
68
the transfer is complete. If callback is non-NULL, it will be called
69
upon completion (in an interrupt context!). Returns <0 on error. */
70
71
/** \brief SPU DMA callback type. */
72
typedef
g2_dma_callback_t
spu_dma_callback_t
;
73
74
/** \brief Copy a block of data from SH4 RAM to sound RAM via DMA.
75
76
This function sets up a DMA transfer from main RAM to the sound RAM with G2
77
DMA.
78
79
\param from A pointer in main RAM to transfer from. Must be
80
32-byte aligned.
81
\param dest Offset in sound RAM to transfer to. Do not include
82
the 0xA0800000 part, its implied. Must be 32-byte
83
aligned.
84
\param length Number of bytes to copy. Must be a multiple of 32.
85
\param block 1 if you want to wait for the transfer to complete,
86
0 otherwise (use the callback for this case).
87
\param callback Function to call when the DMA completes. Can be NULL
88
if you don't want to have a callback. This will be
89
called in an interrupt context, so keep that in mind
90
when writing the function.
91
\param cbdata Data to pass to the callback function.
92
\retval -1 On failure. Sets errno as appropriate.
93
\retval 0 On success.
94
95
\par Error Conditions:
96
\em EINVAL - Invalid channel \n
97
\em EFAULT - from or dest is not aligned \n
98
\em EIO - I/O error
99
*/
100
int
spu_dma_transfer
(
void
* from,
uint32
dest,
uint32
length,
int
block,
101
spu_dma_callback_t
callback,
ptr_t
cbdata);
102
103
/** \brief Enable the SPU.
104
105
This function resets all sound channels and lets the ARM out of reset.
106
*/
107
void
spu_enable
();
108
109
/** \brief Disable the SPU.
110
111
This function resets all sound channels and puts the ARM in a reset state.
112
*/
113
void
spu_disable
();
114
115
/** \brief Set CDDA volume.
116
117
Valid volume values are 0-15.
118
119
\param left_volume Volume of the left channel.
120
\param right_volume Volume of the right channel.
121
*/
122
void
spu_cdda_volume
(
int
left_volume,
int
right_volume);
123
124
/** \brief Set CDDA panning.
125
126
Valid values are from 0-31. 16 is centered.
127
128
\param left_pan Pan of the left channel.
129
\param right_pan Pan of the right channel.
130
*/
131
void
spu_cdda_pan
(
int
left_pan,
int
right_pan);
132
133
/** \brief Set master mixer settings.
134
135
This function sets the master mixer volume and mono/stereo setting.
136
137
\param volume The volume to set (0-15).
138
\param stereo 1 for stereo output, 0 for mono.
139
*/
140
void
spu_master_mixer
(
int
volume,
int
stereo);
141
142
/** \brief Initialize the SPU.
143
144
This function will reset the SPU, clear the sound RAM, reinit the CDDA
145
support and run an infinite loop on the ARM.
146
147
\retval 0 On success (no error conditions defined).
148
*/
149
int
spu_init
();
150
151
/** \brief Shutdown the SPU.
152
153
This function disables the SPU and clears sound RAM.
154
155
\retval 0 On success (no error conditions defined).
156
*/
157
int
spu_shutdown
();
158
159
/** \brief Initialize SPU DMA support.
160
161
This function sets up the DMA support for transfers to the sound RAM area.
162
163
\retval 0 On success (no error conditions defined).
164
*/
165
int
spu_dma_init
();
166
167
/** \brief Shutdown SPU DMA support. */
168
void
spu_dma_shutdown
();
169
170
__END_DECLS
171
172
#endif
/* __DC_SPU_H */
173
Generated by
1.8.1.1