1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - include - snd - common
3 File: capture.h
4
5 Copyright 2004-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-09-17#$
14 $Rev: 8556 $
15 $Author: okubata_ryoma $
16 *---------------------------------------------------------------------------*/
17
18 #ifndef NITRO_SND_COMMON_CAPTURE_H_
19 #define NITRO_SND_COMMON_CAPTURE_H_
20
21 #include <nitro/types.h>
22
23 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
24 #ifdef SDK_ARM7
25 #include <nitro/hw/ARM7/ioreg_SND.h>
26 #ifdef SDK_NITRO
27 #include <nitro/hw/ARM7/mmap_global.h>
28 #else //SDK_TWL
29 #include <twl/hw/ARM7/mmap_global.h>
30 #endif
31 #endif /* SDK_ARM7 */
32 #endif /* SDK_FROM_TOOL */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 /******************************************************************************
39 macro definition
40 ******************************************************************************/
41
42 #define SND_CAPTURE_NUM 2
43
44 #ifndef SDK_TEG
45
46 #define SND_CAPTURE_0_OUT_CHANNEL 1
47 #define SND_CAPTURE_1_OUT_CHANNEL 3
48
49 #define SND_CAPTURE_0_IN_CHANNEL 0
50 #define SND_CAPTURE_1_IN_CHANNEL 2
51
52 #define SND_CAPTURE_LEN_MAX 0xffff
53
54 #else
55
56 #define SND_CAPTURE_0_OUT_CHANNEL 3
57 #define SND_CAPTURE_1_OUT_CHANNEL 1
58
59 #define SND_CAPTURE_0_IN_CHANNEL 2
60 #define SND_CAPTURE_1_IN_CHANNEL 0
61
62 #define SND_CAPTURE_LEN_MAX 0x0fff
63
64 #endif
65
66 #define SND_CAPTURE_DAD_MASK 0x07fffffc
67
68 #define SND_CAPTURE_REG_OFFSET 0x8
69
70 /******************************************************************************
71 enum definition
72 ******************************************************************************/
73
74 #ifndef SDK_TEG
75 typedef enum
76 {
77 SND_CAPTURE_0,
78 SND_CAPTURE_1
79 }
80 SNDCapture;
81 #else
82 typedef enum
83 {
84 SND_CAPTURE_1,
85 SND_CAPTURE_0
86 }
87 SNDCapture;
88 #endif
89
90 typedef enum
91 {
92 SND_CAPTURE_FORMAT_PCM16,
93 SND_CAPTURE_FORMAT_PCM8
94 }
95 SNDCaptureFormat;
96
97 typedef enum
98 {
99 SND_CAPTURE_REPEAT_YES,
100 SND_CAPTURE_REPEAT_NO
101 }
102 SNDCaptureRepeat;
103
104 typedef enum
105 {
106 SND_CAPTURE_IN_MIXER,
107 SND_CAPTURE_IN_CHANNEL,
108
109 SND_CAPTURE_IN_MIXER_L = SND_CAPTURE_IN_MIXER,
110 SND_CAPTURE_IN_MIXER_R = SND_CAPTURE_IN_MIXER,
111 SND_CAPTURE_IN_CHANNEL0 = SND_CAPTURE_IN_CHANNEL,
112 SND_CAPTURE_IN_CHANNEL2 = SND_CAPTURE_IN_CHANNEL
113 }
114 SNDCaptureIn;
115
116 typedef enum
117 {
118 SND_CAPTURE_OUT_NORMAL,
119 SND_CAPTURE_OUT_CHANNEL_MIX,
120
121 SND_CAPTURE_OUT_CHANNEL0_MIX = SND_CAPTURE_OUT_CHANNEL_MIX,
122 SND_CAPTURE_OUT_CHANNEL2_MIX = SND_CAPTURE_OUT_CHANNEL_MIX
123 }
124 SNDCaptureOut;
125
126 /******************************************************************************
127 inline function
128 ******************************************************************************/
129
130 #ifdef SDK_ARM7
131 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
132
133 /*---------------------------------------------------------------------------*
134 Name: SND_StartCapture
135
136 Description: Start capture
137
138 Arguments: capture : target capture
139
140 Returns: None
141 *---------------------------------------------------------------------------*/
SND_StartCapture(SNDCapture capture)142 static inline void SND_StartCapture(SNDCapture capture)
143 {
144 REGType8v *reg = (REGType8v *)(REG_SNDCAP0CNT_ADDR + capture);
145
146 *reg |= REG_SND_SNDCAP0CNT_E_MASK;
147 }
148
149 /*---------------------------------------------------------------------------*
150 Name: SND_StartCaptureBoth
151
152 Description: Start capture
153
154 Arguments: None
155
156 Returns: None
157 *---------------------------------------------------------------------------*/
SND_StartCaptureBoth(void)158 static inline void SND_StartCaptureBoth(void)
159 {
160 reg_SND_SNDCAPCNT |= REG_SND_SNDCAPCNT_CAP0_E_MASK | REG_SND_SNDCAPCNT_CAP1_E_MASK;
161 }
162
163 /*---------------------------------------------------------------------------*
164 Name: SND_StopCapture
165
166 Description: Stop capture
167
168 Arguments: capture : target capture
169
170 Returns: None
171 *---------------------------------------------------------------------------*/
SND_StopCapture(SNDCapture capture)172 static inline void SND_StopCapture(SNDCapture capture)
173 {
174 (*(REGType8v *)(REG_SNDCAP0CNT_ADDR + capture)) = 0;
175 }
176
177 #else
178
179 void SND_StartCapture(SNDCapture capture);
180 void SND_StartCaptureBoth(void);
181 void SND_StopCapture(SNDCapture capture);
182
183 #endif /* SDK_FROM_TOOL */
184
185 #endif /* SDK_ARM7 */
186
187 /******************************************************************************
188 public function declaration
189 ******************************************************************************/
190
191 #ifdef SDK_ARM7
192
193 void SND_SetupCapture(SNDCapture capture,
194 SNDCaptureFormat format,
195 void *buffer_addr,
196 int length, BOOL repeat, SNDCaptureIn in, SNDCaptureOut out);
197
198 BOOL SND_IsCaptureActive(SNDCapture capture);
199
200 #endif /* SDK_ARM7 */
201
202 #ifdef __cplusplus
203 } /* extern "C" */
204 #endif
205
206 #endif /* NITRO_SND_COMMON_CAPTURE_H_ */
207