1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - dspcomponents - include - dsp
3 File: audio.h
4
5 Copyright 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-25#$
14 $Rev: 8651 $
15 $Author: yosizaki $
16 *---------------------------------------------------------------------------*/
17 #ifndef TWLSDK_DSP_AUDIO_H__
18 #define TWLSDK_DSP_AUDIO_H__
19
20
21 #include <twl/dsp/common/byteaccess.h>
22
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /*---------------------------------------------------------------------------*/
29 /* Declarations */
30
31 // Audio component structures
32 typedef struct DSPAudioCodecCommand
33 {
34 DSPByte32 ctrl;
35 DSPAddrInARM src;
36 DSPAddrInARM dst;
37 DSPByte32 len;
38 }
39 DSPAudioCodecCommand;
40
41 typedef struct DSPAudioDriverCommand
42 {
43 DSPByte32 ctrl;
44 DSPAddrInARM buf;
45 DSPByte32 len;
46 DSPByte32 opt;
47 }
48 DSPAudioDriverCommand;
49
50 typedef struct DSPAudioDriverResponse
51 {
52 DSPByte32 ctrl;
53 DSPByte32 result;
54 }
55 DSPAudioDriverResponse;
56
57
58 /*---------------------------------------------------------------------------*/
59 /* Constants */
60
61 // G.711 codec types
62 typedef DSPByte32 DSPAudioCodecMode;
63 #define DSP_AUDIO_CODEC_TYPE_MASK (DSPAudioCodecMode)0x0F00
64 #define DSP_AUDIO_CODEC_MODE_MASK (DSPAudioCodecMode)0x00FF
65 #define DSP_AUDIO_CODEC_TYPE_ENCODE (DSPAudioCodecMode)0x0100
66 #define DSP_AUDIO_CODEC_TYPE_DECODE (DSPAudioCodecMode)0x0200
67 #define DSP_AUDIO_CODEC_MODE_G711_ALAW (DSPAudioCodecMode)0x0001
68 #define DSP_AUDIO_CODEC_MODE_G711_ULAW (DSPAudioCodecMode)0x0002
69
70 // Driver control commands
71 #define DSP_AUDIO_DRIVER_TARGET_MASK (DSPByte32)0xF000
72 #define DSP_AUDIO_DRIVER_CONTROL_MASK (DSPByte32)0x0F00
73 #define DSP_AUDIO_DRIVER_MODE_MASK (DSPByte32)0x00FF
74 #define DSP_AUDIO_DRIVER_TARGET_OUTPUT (DSPByte32)0x1000
75 #define DSP_AUDIO_DRIVER_TARGET_INPUT (DSPByte32)0x2000
76 #define DSP_AUDIO_DRIVER_TARGET_CACHE (DSPByte32)0x3000
77 #define DSP_AUDIO_DRIVER_CONTROL_START (DSPByte32)0x0100
78 #define DSP_AUDIO_DRIVER_CONTROL_STOP (DSPByte32)0x0200
79 #define DSP_AUDIO_DRIVER_CONTROL_LOAD (DSPByte32)0x0300
80 #define DSP_AUDIO_DRIVER_CONTROL_STORE (DSPByte32)0x0400
81 #define DSP_AUDIO_DRIVER_MODE_MONAURAL (DSPByte32)0x0000
82 #define DSP_AUDIO_DRIVER_MODE_STEREO (DSPByte32)0x0001
83 #define DSP_AUDIO_DRIVER_MODE_HALFVOL (DSPByte32)0x0002
84
85
86 /*---------------------------------------------------------------------------*/
87 /* Functions */
88
89 #ifdef SDK_TWL
90
91 /*---------------------------------------------------------------------------*
92 * Internal core functions placed on LTDMAIN
93 *---------------------------------------------------------------------------*/
94
95 void DSPi_OpenStaticComponentAudioCore(FSFile *file);
96 BOOL DSPi_LoadAudioCore(FSFile *file, int slotB, int slotC);
97 void DSPi_UnloadAudioCore(void);
98
99 /*---------------------------------------------------------------------------*
100 Name: DSP_OpenStaticComponentAudio
101
102 Description: Opens the memory file for an audio component.
103 Although you will no longer have to make file system preparations in advance, this will be linked as static memory and thus increase the program size.
104
105
106 Arguments: file: The FSFile structure to open the memory file.
107
108 Returns: None.
109 *---------------------------------------------------------------------------*/
DSP_OpenStaticComponentAudio(FSFile * file)110 SDK_INLINE void DSP_OpenStaticComponentAudio(FSFile *file)
111 {
112 if (OS_IsRunOnTwl())
113 {
114 DSPi_OpenStaticComponentAudioCore(file);
115 }
116 }
117
118 /*---------------------------------------------------------------------------*
119 Name: DSP_LoadAudio
120
121 Description: Loads an audio component into the DSP.
122
123 Arguments: file: The audio component file.
124 slotB: WRAM-B that was allowed to be used for code memory.
125 slotC: WRAM-C that was allowed to be used for data memory.
126
127 Returns: TRUE if the audio component is loaded properly in the DSP.
128 *---------------------------------------------------------------------------*/
DSP_LoadAudio(FSFile * file,int slotB,int slotC)129 SDK_INLINE BOOL DSP_LoadAudio(FSFile *file, int slotB, int slotC)
130 {
131 if (OS_IsRunOnTwl())
132 {
133 return DSPi_LoadAudioCore(file, slotB, slotC);
134 }
135 return FALSE;
136 }
137
138 /*---------------------------------------------------------------------------*
139 Name: DSP_UnloadAudio
140
141 Description: Unloads the audio component from the DSP.
142
143 Arguments: None.
144
145 Returns: None.
146 *---------------------------------------------------------------------------*/
DSP_UnloadAudio(void)147 SDK_INLINE void DSP_UnloadAudio(void)
148 {
149 if (OS_IsRunOnTwl())
150 {
151 DSPi_UnloadAudioCore();
152 }
153 }
154
155
156 #else
157
158
159 #endif // SDK_TWL
160
161
162 #ifdef __cplusplus
163 }
164 #endif
165
166
167 #endif // TWLSDK_DSP_AUDIO_H__
168