summaryrefslogtreecommitdiff
path: root/firmware/export/pcm_sampr.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/pcm_sampr.h')
-rw-r--r--firmware/export/pcm_sampr.h310
1 files changed, 310 insertions, 0 deletions
diff --git a/firmware/export/pcm_sampr.h b/firmware/export/pcm_sampr.h
new file mode 100644
index 0000000000..c4a399b62f
--- /dev/null
+++ b/firmware/export/pcm_sampr.h
@@ -0,0 +1,310 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef PCM_SAMPR_H
21#define PCM_SAMPR_H
22
23/* These must be macros for comparison with SAMPR_CAP_* flags by the
24 preprocessor. Add samplerate index in descending order renumbering
25 the ones later in the list if any */
26#define FREQ_96 0
27#define FREQ_88 1
28#define FREQ_64 2
29#define FREQ_48 3
30#define FREQ_44 4
31#define FREQ_32 5
32#define FREQ_24 6
33#define FREQ_22 7
34#define FREQ_16 8
35#define FREQ_12 9
36#define FREQ_11 10
37#define FREQ_8 11
38#define SAMPR_NUM_FREQ 12
39
40/* sample rate values in HZ */
41#define SAMPR_96 96000
42#define SAMPR_88 88200
43#define SAMPR_64 64000
44#define SAMPR_48 48000
45#define SAMPR_44 44100
46#define SAMPR_32 32000
47#define SAMPR_24 24000
48#define SAMPR_22 22050
49#define SAMPR_16 16000
50#define SAMPR_12 12000
51#define SAMPR_11 11025
52#define SAMPR_8 8000
53
54/* sample rate capability bits */
55#define SAMPR_CAP_96 (1 << FREQ_96)
56#define SAMPR_CAP_88 (1 << FREQ_88)
57#define SAMPR_CAP_64 (1 << FREQ_64)
58#define SAMPR_CAP_48 (1 << FREQ_48)
59#define SAMPR_CAP_44 (1 << FREQ_44)
60#define SAMPR_CAP_32 (1 << FREQ_32)
61#define SAMPR_CAP_24 (1 << FREQ_24)
62#define SAMPR_CAP_22 (1 << FREQ_22)
63#define SAMPR_CAP_16 (1 << FREQ_16)
64#define SAMPR_CAP_12 (1 << FREQ_12)
65#define SAMPR_CAP_11 (1 << FREQ_11)
66#define SAMPR_CAP_8 (1 << FREQ_8)
67#define SAMPR_CAP_ALL (SAMPR_CAP_96 | SAMPR_CAP_88 | SAMPR_CAP_64 | \
68 SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
69 SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
70 SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
71
72/* Master list of all "standard" rates supported. */
73extern const unsigned long audio_master_sampr_list[SAMPR_NUM_FREQ];
74
75/** Hardware sample rates **/
76
77/* Enumeration of supported frequencies where 0 is the highest rate
78 supported and REC_NUM_FREQUENCIES is the number available */
79enum hw_freq_indexes
80{
81 __HW_FREQ_START_INDEX = -1, /* Make sure first in list is 0 */
82
83/* 96000 */
84#if (HW_SAMPR_CAPS & SAMPR_CAP_96) /* Macros and enums for each FREQ: */
85 HW_FREQ_96, /* Index in enumeration */
86#define HW_HAVE_96 /* Defined if this FREQ is defined */
87#define HW_HAVE_96_(...) __VA_ARGS__ /* Output its parameters for this FREQ */
88#else
89#define HW_HAVE_96_(...) /* Discards its parameters for this FREQ */
90#endif
91/* 88200 */
92#if (HW_SAMPR_CAPS & SAMPR_CAP_88)
93 HW_FREQ_88,
94#define HW_HAVE_88
95#define HW_HAVE_88_(...) __VA_ARGS__
96#else
97#define HW_HAVE_88_(...)
98#endif
99/* 64000 */
100#if (HW_SAMPR_CAPS & SAMPR_CAP_64)
101 HW_FREQ_64,
102#define HW_HAVE_64
103#define HW_HAVE_64_(...) __VA_ARGS__
104#else
105#define HW_HAVE_64_(...)
106#endif
107/* 48000 */
108#if (HW_SAMPR_CAPS & SAMPR_CAP_48)
109 HW_FREQ_48,
110#define HW_HAVE_48
111#define HW_HAVE_48_(...) __VA_ARGS__
112#else
113#define HW_HAVE_48_(...)
114#endif
115/* 44100 */
116 HW_FREQ_44,
117#define HW_HAVE_44
118#define HW_HAVE_44_(...) __VA_ARGS__
119/* 32000 */
120#if (HW_SAMPR_CAPS & SAMPR_CAP_32)
121 HW_FREQ_32,
122#define HW_HAVE_32
123#define HW_HAVE_32_(...) __VA_ARGS__
124#else
125#define HW_HAVE_32_(...)
126#endif
127/* 24000 */
128#if (HW_SAMPR_CAPS & SAMPR_CAP_24)
129 HW_FREQ_24,
130#define HW_HAVE_24
131#define HW_HAVE_24_(...) __VA_ARGS__
132#else
133#define HW_HAVE_24_(...)
134#endif
135/* 22050 */
136#if (HW_SAMPR_CAPS & SAMPR_CAP_22)
137 HW_FREQ_22,
138#define HW_HAVE_22
139#define HW_HAVE_22_(...) __VA_ARGS__
140#else
141#define HW_HAVE_22_(...)
142#endif
143/* 16000 */
144#if (HW_SAMPR_CAPS & SAMPR_CAP_16)
145 HW_FREQ_16,
146#define HW_HAVE_16
147#define HW_HAVE_16_(...) __VA_ARGS__
148#else
149#define HW_HAVE_16_(...)
150#endif
151/* 12000 */
152#if (HW_SAMPR_CAPS & SAMPR_CAP_12)
153 HW_FREQ_12,
154#define HW_HAVE_12
155#define HW_HAVE_12_(...) __VA_ARGS__
156#else
157#define HW_HAVE_12_(...)
158#endif
159/* 11025 */
160#if (HW_SAMPR_CAPS & SAMPR_CAP_11)
161 HW_FREQ_11,
162#define HW_HAVE_11
163#define HW_HAVE_11_(...) __VA_ARGS__
164#else
165#define HW_HAVE_11_(...)
166#endif
167/* 8000 */
168#if (HW_SAMPR_CAPS & SAMPR_CAP_8 )
169 HW_FREQ_8,
170#define HW_HAVE_8
171#define HW_HAVE_8_(...) __VA_ARGS__
172#else
173#define HW_HAVE_8_(...)
174#endif
175 HW_NUM_FREQ,
176 HW_FREQ_DEFAULT = HW_FREQ_44,
177 HW_SAMPR_DEFAULT = SAMPR_44,
178}; /* enum hw_freq_indexes */
179
180/* list of hardware sample rates */
181extern const unsigned long hw_freq_sampr[HW_NUM_FREQ];
182
183#ifdef HAVE_RECORDING
184/* Enumeration of supported frequencies where 0 is the highest rate
185 supported and REC_NUM_FREQUENCIES is the number available */
186enum rec_freq_indexes
187{
188 __REC_FREQ_START_INDEX = -1, /* Make sure first in list is 0 */
189
190/* 96000 */
191#if (REC_SAMPR_CAPS & SAMPR_CAP_96) /* Macros and enums for each FREQ: */
192 REC_FREQ_96, /* Index in enumeration */
193#define REC_HAVE_96 /* Defined if this FREQ is defined */
194#define REC_HAVE_96_(...) __VA_ARGS__ /* Output its parameters for this FREQ */
195#else
196#define REC_HAVE_96_(...) /* Discards its parameters for this FREQ */
197#endif
198/* 88200 */
199#if (REC_SAMPR_CAPS & SAMPR_CAP_88)
200 REC_FREQ_88,
201#define REC_HAVE_88
202#define REC_HAVE_88_(...) __VA_ARGS__
203#else
204#define REC_HAVE_88_(...)
205#endif
206/* 64000 */
207#if (REC_SAMPR_CAPS & SAMPR_CAP_64)
208 REC_FREQ_64,
209#define REC_HAVE_64
210#define REC_HAVE_64_(...) __VA_ARGS__
211#else
212#define REC_HAVE_64_(...)
213#endif
214/* 48000 */
215#if (REC_SAMPR_CAPS & SAMPR_CAP_48)
216 REC_FREQ_48,
217#define REC_HAVE_48
218#define REC_HAVE_48_(...) __VA_ARGS__
219#else
220#define REC_HAVE_48_(...)
221#endif
222/* 44100 */
223#if (REC_SAMPR_CAPS & SAMPR_CAP_44)
224 REC_FREQ_44,
225#define REC_HAVE_44
226#define REC_HAVE_44_(...) __VA_ARGS__
227#else
228#define REC_HAVE_44_(...)
229#endif
230/* 32000 */
231#if (REC_SAMPR_CAPS & SAMPR_CAP_32)
232 REC_FREQ_32,
233#define REC_HAVE_32
234#define REC_HAVE_32_(...) __VA_ARGS__
235#else
236#define REC_HAVE_32_(...)
237#endif
238/* 24000 */
239#if (REC_SAMPR_CAPS & SAMPR_CAP_24)
240 REC_FREQ_24,
241#define REC_HAVE_24
242#define REC_HAVE_24_(...) __VA_ARGS__
243#else
244#define REC_HAVE_24_(...)
245#endif
246/* 22050 */
247#if (REC_SAMPR_CAPS & SAMPR_CAP_22)
248 REC_FREQ_22,
249#define REC_HAVE_22
250#define REC_HAVE_22_(...) __VA_ARGS__
251#else
252#define REC_HAVE_22_(...)
253#endif
254/* 16000 */
255#if (REC_SAMPR_CAPS & SAMPR_CAP_16)
256 REC_FREQ_16,
257#define REC_HAVE_16
258#define REC_HAVE_16_(...) __VA_ARGS__
259#else
260#define REC_HAVE_16_(...)
261#endif
262/* 12000 */
263#if (REC_SAMPR_CAPS & SAMPR_CAP_12)
264 REC_FREQ_12,
265#define REC_HAVE_12
266#define REC_HAVE_12_(...) __VA_ARGS__
267#else
268#define REC_HAVE_12_(...)
269#endif
270/* 11025 */
271#if (REC_SAMPR_CAPS & SAMPR_CAP_11)
272 REC_FREQ_11,
273#define REC_HAVE_11
274#define REC_HAVE_11_(...) __VA_ARGS__
275#else
276#define REC_HAVE_11_(...)
277#endif
278/* 8000 */
279#if (REC_SAMPR_CAPS & SAMPR_CAP_8 )
280 REC_FREQ_8,
281#define REC_HAVE_8
282#define REC_HAVE_8_(...) __VA_ARGS__
283#else
284#define REC_HAVE_8_(...)
285#endif
286 REC_NUM_FREQ,
287 /* This should always come out I reckon */
288 REC_FREQ_DEFAULT = REC_FREQ_44,
289 /* Get the minimum bitcount needed to save the range of values */
290 REC_FREQ_CFG_NUM_BITS = (REC_NUM_FREQ > 8 ?
291 4 : (REC_NUM_FREQ > 4 ?
292 3 : (REC_NUM_FREQ > 2 ?
293 2 : 1
294 )
295 )
296 ),
297}; /* enum rec_freq_indexes */
298
299#define REC_FREQ_CFG_VAL_LIST &REC_HAVE_96_(",96") REC_HAVE_88_(",88") \
300 REC_HAVE_64_(",64") REC_HAVE_48_(",48") \
301 REC_HAVE_44_(",44") REC_HAVE_32_(",32") \
302 REC_HAVE_24_(",24") REC_HAVE_22_(",22") \
303 REC_HAVE_16_(",16") REC_HAVE_12_(",12") \
304 REC_HAVE_11_(",11") REC_HAVE_8_(",8")[1]
305
306/* List of recording supported sample rates (set or subset of master list) */
307extern const unsigned long rec_freq_sampr[REC_NUM_FREQ];
308#endif /* HAVE_RECORDING */
309
310#endif /* PCM_SAMPR_H */