-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathfeatures.h
More file actions
executable file
·303 lines (275 loc) · 10.9 KB
/
features.h
File metadata and controls
executable file
·303 lines (275 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/* -*- mode: c; tab-width: 4; c-basic-offset: 4 -*- */
/*
* features.h
*
* Created on: 2011-02-11
* Author: Roger E Critchlow Jr, AD5DZ
*/
#ifndef FEATURES_H_
#define FEATURES_H_
#include <stdint.h>
//
// each feature index defines a feature set
//
// to add a new feature set:
// 1) insert the feature index name into the feature_index_t enumeration;
// 2) insert the feature index name string into the FEATURE_INDEX_NAMES define;
// 3) insert the feature end marker value into the feature_values_t enumeration;
// 4) insert the feature end marker name into the FEATURE_VALUE_NAMES define.
// 5) insert macros to test the feature
// 6) insert test for default being set by Makefile
// 7) insert the feature in all configurations in Makefile at project root
//
typedef enum {
feature_major_index = 0, // major version number = feature_end_index
feature_minor_index, // minor version number = feature_end_values
feature_board_index, // board identifier
feature_image_index, // image to boot
feature_in_index, // keep or swap left/right channels on input
feature_out_index, // keep or swap left/right channels on output
feature_adc_index, // adc identifier
feature_dac_index, // dac identifier
feature_lcd_index, // lcd display type
feature_log_index, // startup log display timing
feature_filter_index, // setting of filter
feature_quirk_index, // setting of various quirks
feature_msb_vol_L, // left volume control, msb of usb value
feature_lsb_vol_L, // left volume control, lsb
feature_msb_vol_R, // right volume control, msb
feature_lsb_vol_R, // right volume control, lsb
feature_end_index // end marker, used to size arrays
} feature_index_t;
#define FEATURE_INDEX_NAMES "major", \
"minor", \
"board", \
"image", \
"in", \
"out", \
"adc", \
"dac", \
"lcd", \
"log", \
"filter", \
"quirk", \
"msb_vol_L", \
"lsb_vol_L", \
"msb_vol_R", \
"lsb_vol_R", \
"end"
//
// the features are enumerated as single group
// which allows a single table of name strings
//
// some of these are probably wrong and will
// need to be adjusted.
//
// to add another value to an existing feature set:
// 1) add its name to the feature_values_t enumeration;
// 2) add its string name to the FEATURE_VALUE_NAMES define;
// 3) add a macro to test for the feature's value below
//
// so, for instance, if Alex wants to add a test image:
// 1) insert feature_image_alex_test before feature_end_image;
// 2) insert "alex_test" into the FEATURE_VALUE_NAMES;
// 2) #define FEATURE_IMAGE_ALEX_TEST
//
typedef enum {
feature_board_none = 0, // board selection
feature_board_widget,
feature_board_usbi2s,
feature_board_usbdac,
feature_end_board,
feature_image_uac1_audio, // UAC2 only: retained for buffer compatibility for now
// feature_image_uac1_dg8saq,
feature_image_uac2_audio,
// feature_image_uac2_dg8saq,
// feature_image_hpsdr,
// feature_image_test,
feature_end_image,
feature_in_normal, // input channel
feature_in_swapped,
feature_end_in,
feature_out_normal, // output channel
feature_out_swapped,
feature_end_out,
feature_adc_none, // adc
feature_adc_ak5394a,
feature_end_adc,
feature_dac_none, // dac
feature_dac_cs4344,
feature_dac_generic,
feature_end_dac,
feature_lcd_none, // lcd
feature_lcd_hd44780, /* normal hd44780 lcd controller */
feature_lcd_ks0073, /* ks0073 almost hd44780 compatible */
feature_end_lcd,
feature_log_none, // log
feature_log_500ms,
feature_log_1sec,
feature_log_2sec,
feature_end_log,
feature_filter_fir, // filter select
feature_filter_iir,
feature_end_filter,
feature_quirk_linux, // Linux_quirk select
feature_quirk_ptest, // Production test quirk
feature_quirk_none, // No quirks, normal operation
feature_quirk_fb_Hstupid, // BSB 20131101 emaulate stupid feedback system at Host
feature_quirk_fb_Hdead, // BSB 20131101 emaulate stupid feedback system at Host
feature_quirk_fb_noskip, // BSB 20131101 disable (future) skip/insert system
feature_end_quirk, // BSB 20131101 renamed "lquirk" to "quirk"
feature_end_values // end
} feature_values_t;
#define FEATURE_VALUE_NAMES \
"none", \
"widget", \
"usbi2s", \
"usbdac", \
"end", \
"uac1_audio", \
"uac2_audio", \
"end", \
"normal", \
"swapped", \
"end", \
"normal", \
"swapped", \
"end", \
"none", \
"ak5394a", \
"end", \
"none", \
"cs4344", \
"generic", \
"end", \
"none", \
"hd44780", \
"ks0073", \
"end", \
"none", \
"500ms", \
"1sec", \
"2sec", \
"end", \
"fir", \
"iir", \
"end", \
"quirk_linux", \
"quirk_ptest", \
"quirk_none", \
"quirk_fb_Hstupid", \
"quirk_fb_Hdead", \
"quirk_fb_noskip", \
"end", \
"end"
typedef uint8_t features_t[feature_end_index];
extern features_t features_nvram, features;
extern const features_t features_default;
//
// test for the values of features with these macros
// if a feature is unconditionally off, then the macro
// will expand to a constant 0 and the dead code will
// be eliminated.
//
#define FEATURE_MAJOR (features[feature_major_index])
#define FEATURE_MAJOR_NVRAM (features_nvram[feature_major_index])
#define FEATURE_MINOR (features[feature_minor_index])
#define FEATURE_MINOR_NVRAM (features_nvram[feature_minor_index])
#define FEATURE_BOARD_NONE (features[feature_board_index] == (uint8_t)feature_board_none)
#define FEATURE_BOARD_WIDGET (features[feature_board_index] == (uint8_t)feature_board_widget)
#define FEATURE_BOARD_USBI2S (features[feature_board_index] == (uint8_t)feature_board_usbi2s)
#define FEATURE_BOARD_USBDAC (features[feature_board_index] == (uint8_t)feature_board_usbdac)
// #define FEATURE_IMAGE_UAC1_AUDIO (features[feature_image_index] == (uint8_t)feature_image_uac1_audio)
#define FEATURE_IMAGE_UAC2_AUDIO (features[feature_image_index] == (uint8_t)feature_image_uac2_audio)
#define FEATURE_IN_NORMAL (features[feature_in_index] == (uint8_t)feature_in_normal)
#define FEATURE_IN_SWAPPED (features[feature_in_index] == (uint8_t)feature_in_swapped)
#define FEATURE_OUT_NORMAL (features[feature_out_index] == (uint8_t)feature_out_normal)
#define FEATURE_OUT_SWAPPED (features[feature_out_index] == (uint8_t)feature_out_swapped)
#define FEATURE_DAC_NONE (features[feature_dac_index] == (uint8_t)feature_dac_none)
#define FEATURE_DAC_CS4344 (features[feature_dac_index] == (uint8_t)feature_dac_cs4344)
#define FEATURE_DAC_GENERIC (features[feature_dac_index] == (uint8_t)feature_dac_generic)
#define FEATURE_LCD_NONE (features[feature_lcd_index] == (uint8_t)feature_lcd_none)
#define FEATURE_LCD_HD44780 (features[feature_lcd_index] == (uint8_t)feature_lcd_hd44780)
#define FEATURE_LCD_KS0073 (features[feature_lcd_index] == (uint8_t)feature_lcd_ks0073)
#define FEATURE_LOG_NONE (features[feature_log_index] == (uint8_t)feature_log_none)
#define FEATURE_LOG_500MS (features[feature_log_index] == (uint8_t)feature_log_500ms)
#define FEATURE_LOG_1SEC (features[feature_log_index] == (uint8_t)feature_log_1sec)
#define FEATURE_LOG_2SEC (features[feature_log_index] == (uint8_t)feature_log_2sec)
#define FEATURE_FILTER_FIR (features[feature_filter_index] == (uint8_t)feature_filter_fir)
#define FEATURE_FILTER_IIR (features[feature_filter_index] == (uint8_t)feature_filter_iir)
#define FEATURE_LINUX_QUIRK_ON (features[feature_quirk_index] == (uint8_t)feature_quirk_linux)
#define FEATURE_LINUX_QUIRK_OFF (features[feature_quirk_index] != (uint8_t)feature_quirk_linux)
#define FEATURE_PROD_TEST_ON (features[feature_quirk_index] == (uint8_t)feature_quirk_ptest)
#define FEATURE_PROD_TEST_OFF (features[feature_quirk_index] != (uint8_t)feature_quirk_ptest)
#define FEATURE_NOSKIP_ON (features[feature_quirk_index] == (uint8_t)feature_quirk_fb_noskip)
#define FEATURE_NOSKIP_OFF (features[feature_quirk_index] != (uint8_t)feature_quirk_fb_noskip)
//
// the version in the features specifies
// the number of feature indexes and the number of feature values
// which should change anytime someone alters the list
// if there is a feature_major or feature_minor mismatch, then
// the initial values in the build are copied into nvram
//
#define FEATURE_MAJOR_DEFAULT feature_end_index
#define FEATURE_MINOR_DEFAULT feature_end_values
//
// Check the defaults for this build
//
// BSB 20120409 edited after Roger's mail
#ifndef FEATURE_BOARD_DEFAULT
#error "FEATURE_BOARD_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_IMAGE_DEFAULT
#error "FEATURE_IMAGE_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_IN_DEFAULT
#error "FEATURE_IN_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_OUT_DEFAULT
#error "FEATURE_OUT_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_DAC_DEFAULT
#error "FEATURE_DAC_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_LCD_DEFAULT
#error "FEATURE_LCD_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_LOG_DEFAULT
#error "FEATURE_LOG_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_FILTER_DEFAULT
#error "FEATURE_FILTER_DEFAULT must be defined by the Makefile"
#endif
#ifndef FEATURE_QUIRK_DEFAULT
#error "FEATURE_QUIRK_DEFAULT must be defined by the Makefile"
#endif
#define FEATURES_DEFAULT FEATURE_MAJOR_DEFAULT, \
FEATURE_MINOR_DEFAULT, \
FEATURE_BOARD_DEFAULT, \
FEATURE_IMAGE_DEFAULT, \
FEATURE_IN_DEFAULT, \
FEATURE_OUT_DEFAULT, \
FEATURE_ADC_DEFAULT, \
FEATURE_DAC_DEFAULT, \
FEATURE_LCD_DEFAULT, \
FEATURE_LOG_DEFAULT, \
FEATURE_FILTER_DEFAULT, \
FEATURE_QUIRK_DEFAULT
extern const char * const feature_value_names[];
extern const char * const feature_index_names[];
extern uint8_t feature_set(uint8_t index, uint8_t value);
extern uint8_t feature_get(uint8_t index);
extern uint8_t feature_set_nvram(uint8_t index, uint8_t value);
extern uint8_t feature_get_nvram(uint8_t index);
extern uint8_t feature_get_default(uint8_t index);
extern void feature_factory_reset(void);
extern void feature_find_first_and_last_value(uint8_t index, uint8_t *first, uint8_t *last);
#define FEATURE_DG8SAQ_COMMAND 0x71
#define FEATURE_DG8SAQ_SET_NVRAM 3
#define FEATURE_DG8SAQ_GET_NVRAM 4
#define FEATURE_DG8SAQ_SET_RAM 5
#define FEATURE_DG8SAQ_GET_RAM 6
#define FEATURE_DG8SAQ_GET_INDEX_NAME 7
#define FEATURE_DG8SAQ_GET_VALUE_NAME 8
#define FEATURE_DG8SAQ_GET_DEFAULT 9
#endif /* FEATURES_H_ */