1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #define HW_SAMPR_CAPS SAMPR_CAP_44 /* if not defined, default to 44100 */
29 /* These must be macros for comparison with SAMPR_CAP_* flags by the
30 preprocessor. Add samplerate index in descending order renumbering
31 the ones later in the list if any */
44 #define SAMPR_NUM_FREQ 12
46 /* sample rate values in HZ */
47 #define SAMPR_96 96000
48 #define SAMPR_88 88200
49 #define SAMPR_64 64000
50 #define SAMPR_48 48000
51 #define SAMPR_44 44100
52 #define SAMPR_32 32000
53 #define SAMPR_24 24000
54 #define SAMPR_22 22050
55 #define SAMPR_16 16000
56 #define SAMPR_12 12000
57 #define SAMPR_11 11025
60 /* sample rate capability bits */
61 #define SAMPR_CAP_96 (1 << FREQ_96)
62 #define SAMPR_CAP_88 (1 << FREQ_88)
63 #define SAMPR_CAP_64 (1 << FREQ_64)
64 #define SAMPR_CAP_48 (1 << FREQ_48)
65 #define SAMPR_CAP_44 (1 << FREQ_44)
66 #define SAMPR_CAP_32 (1 << FREQ_32)
67 #define SAMPR_CAP_24 (1 << FREQ_24)
68 #define SAMPR_CAP_22 (1 << FREQ_22)
69 #define SAMPR_CAP_16 (1 << FREQ_16)
70 #define SAMPR_CAP_12 (1 << FREQ_12)
71 #define SAMPR_CAP_11 (1 << FREQ_11)
72 #define SAMPR_CAP_8 (1 << FREQ_8)
73 #define SAMPR_CAP_ALL (SAMPR_CAP_96 | SAMPR_CAP_88 | SAMPR_CAP_64 | \
74 SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \
75 SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \
76 SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
78 /* Master list of all "standard" rates supported. */
79 extern const unsigned long audio_master_sampr_list
[SAMPR_NUM_FREQ
];
81 /** Hardware sample rates **/
83 /* Enumeration of supported frequencies where 0 is the highest rate
84 supported and REC_NUM_FREQUENCIES is the number available */
87 __HW_FREQ_START_INDEX
= -1, /* Make sure first in list is 0 */
90 #if (HW_SAMPR_CAPS & SAMPR_CAP_96) /* Macros and enums for each FREQ: */
91 HW_FREQ_96
, /* Index in enumeration */
92 #define HW_HAVE_96 /* Defined if this FREQ is defined */
93 #define HW_HAVE_96_(...) __VA_ARGS__ /* Output its parameters for this FREQ */
95 #define HW_HAVE_96_(...) /* Discards its parameters for this FREQ */
98 #if (HW_SAMPR_CAPS & SAMPR_CAP_88)
101 #define HW_HAVE_88_(...) __VA_ARGS__
103 #define HW_HAVE_88_(...)
106 #if (HW_SAMPR_CAPS & SAMPR_CAP_64)
109 #define HW_HAVE_64_(...) __VA_ARGS__
111 #define HW_HAVE_64_(...)
114 #if (HW_SAMPR_CAPS & SAMPR_CAP_48)
117 #define HW_HAVE_48_(...) __VA_ARGS__
119 #define HW_HAVE_48_(...)
122 #if (HW_SAMPR_CAPS & SAMPR_CAP_44)
125 #define HW_HAVE_44_(...) __VA_ARGS__
127 #define HW_HAVE_44_(...)
130 #if (HW_SAMPR_CAPS & SAMPR_CAP_32)
133 #define HW_HAVE_32_(...) __VA_ARGS__
135 #define HW_HAVE_32_(...)
138 #if (HW_SAMPR_CAPS & SAMPR_CAP_24)
141 #define HW_HAVE_24_(...) __VA_ARGS__
143 #define HW_HAVE_24_(...)
146 #if (HW_SAMPR_CAPS & SAMPR_CAP_22)
149 #define HW_HAVE_22_(...) __VA_ARGS__
151 #define HW_HAVE_22_(...)
154 #if (HW_SAMPR_CAPS & SAMPR_CAP_16)
157 #define HW_HAVE_16_(...) __VA_ARGS__
159 #define HW_HAVE_16_(...)
162 #if (HW_SAMPR_CAPS & SAMPR_CAP_12)
165 #define HW_HAVE_12_(...) __VA_ARGS__
167 #define HW_HAVE_12_(...)
170 #if (HW_SAMPR_CAPS & SAMPR_CAP_11)
173 #define HW_HAVE_11_(...) __VA_ARGS__
175 #define HW_HAVE_11_(...)
178 #if (HW_SAMPR_CAPS & SAMPR_CAP_8 )
181 #define HW_HAVE_8_(...) __VA_ARGS__
183 #define HW_HAVE_8_(...)
186 HW_FREQ_DEFAULT
= HW_FREQ_44
,
187 HW_SAMPR_DEFAULT
= SAMPR_44
,
188 }; /* enum hw_freq_indexes */
190 /* list of hardware sample rates */
191 extern const unsigned long hw_freq_sampr
[HW_NUM_FREQ
];
193 #ifdef HAVE_RECORDING
194 /* Enumeration of supported frequencies where 0 is the highest rate
195 supported and REC_NUM_FREQUENCIES is the number available */
196 enum rec_freq_indexes
198 __REC_FREQ_START_INDEX
= -1, /* Make sure first in list is 0 */
201 #if (REC_SAMPR_CAPS & SAMPR_CAP_96) /* Macros and enums for each FREQ: */
202 REC_FREQ_96
, /* Index in enumeration */
203 #define REC_HAVE_96 /* Defined if this FREQ is defined */
204 #define REC_HAVE_96_(...) __VA_ARGS__ /* Output its parameters for this FREQ */
206 #define REC_HAVE_96_(...) /* Discards its parameters for this FREQ */
209 #if (REC_SAMPR_CAPS & SAMPR_CAP_88)
212 #define REC_HAVE_88_(...) __VA_ARGS__
214 #define REC_HAVE_88_(...)
217 #if (REC_SAMPR_CAPS & SAMPR_CAP_64)
220 #define REC_HAVE_64_(...) __VA_ARGS__
222 #define REC_HAVE_64_(...)
225 #if (REC_SAMPR_CAPS & SAMPR_CAP_48)
228 #define REC_HAVE_48_(...) __VA_ARGS__
230 #define REC_HAVE_48_(...)
233 #if (REC_SAMPR_CAPS & SAMPR_CAP_44)
236 #define REC_HAVE_44_(...) __VA_ARGS__
238 #define REC_HAVE_44_(...)
241 #if (REC_SAMPR_CAPS & SAMPR_CAP_32)
244 #define REC_HAVE_32_(...) __VA_ARGS__
246 #define REC_HAVE_32_(...)
249 #if (REC_SAMPR_CAPS & SAMPR_CAP_24)
252 #define REC_HAVE_24_(...) __VA_ARGS__
254 #define REC_HAVE_24_(...)
257 #if (REC_SAMPR_CAPS & SAMPR_CAP_22)
260 #define REC_HAVE_22_(...) __VA_ARGS__
262 #define REC_HAVE_22_(...)
265 #if (REC_SAMPR_CAPS & SAMPR_CAP_16)
268 #define REC_HAVE_16_(...) __VA_ARGS__
270 #define REC_HAVE_16_(...)
273 #if (REC_SAMPR_CAPS & SAMPR_CAP_12)
276 #define REC_HAVE_12_(...) __VA_ARGS__
278 #define REC_HAVE_12_(...)
281 #if (REC_SAMPR_CAPS & SAMPR_CAP_11)
284 #define REC_HAVE_11_(...) __VA_ARGS__
286 #define REC_HAVE_11_(...)
289 #if (REC_SAMPR_CAPS & SAMPR_CAP_8 )
292 #define REC_HAVE_8_(...) __VA_ARGS__
294 #define REC_HAVE_8_(...)
297 }; /* enum rec_freq_indexes */
299 /* Default to 44.1kHz if not otherwise specified */
300 #ifndef REC_FREQ_DEFAULT
301 #define REC_FREQ_DEFAULT REC_FREQ_44
304 #ifndef REC_SAMPR_DEFAULT
305 #define REC_SAMPR_DEFAULT SAMPR_44
308 #define HW_SAMPR_RESET 0
310 #define REC_FREQ_CFG_VAL_LIST &REC_HAVE_96_(",96") REC_HAVE_88_(",88") \
311 REC_HAVE_64_(",64") REC_HAVE_48_(",48") \
312 REC_HAVE_44_(",44") REC_HAVE_32_(",32") \
313 REC_HAVE_24_(",24") REC_HAVE_22_(",22") \
314 REC_HAVE_16_(",16") REC_HAVE_12_(",12") \
315 REC_HAVE_11_(",11") REC_HAVE_8_(",8")[1]
317 /* List of recording supported sample rates (set or subset of master list) */
318 extern const unsigned long rec_freq_sampr
[REC_NUM_FREQ
];
319 #endif /* HAVE_RECORDING */
321 #ifdef CONFIG_SAMPR_TYPES
323 #define SAMPR_TYPE_MASK (0xff << 24)
324 #define SAMPR_TYPE_PLAY (0x00 << 24)
325 #ifdef HAVE_RECORDING
326 #define SAMPR_TYPE_REC (0x01 << 24)
329 unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate
,
332 #else /* ndef CONFIG_SAMPR_TYPES */
334 /* Types are ignored and == 0 */
335 #define SAMPR_TYPE_PLAY 0
336 #ifdef HAVE_RECORDING
337 #define SAMPR_TYPE_REC 0
340 #endif /* CONFIG_SAMPR_TYPES */
342 #endif /* PCM_SAMPR_H */