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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
/*
* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
* tfaContainer.h
*
* Created on: Sep 11, 2013
* Author: wim
*/
#ifndef TFACONTAINER_H_
#define TFACONTAINER_H_
/* static limits */
#define TFACONT_MAXDEVS (4) /* maximum nr of devices */
#define TFACONT_MAXPROFS (16) /* maximum nr of profiles */
#include "tfa98xx_parameters.h"
/**
* Check the container file and set module global
* @param cnt pointer to container file
* @param length the length of the container file
* @return tfa_error
*/
enum tfa_error tfa_load_cnt(void *cnt, int length);
/**
* Resets init variables
*/
void tfa_deinit(void);
/**
* Verify the calibration results from each channel
* @param handle the index of the device
*/
void individual_calibration_results(Tfa98xx_handle_t handle);
/**
* Return the descriptor string
* @param dsc pointer to nxpTfa descriptor
* @return descriptor string
*/
char *tfaContGetString(nxpTfaDescPtr_t *dsc); /* TODO */
/**
* Gets the string for the given command type number
* @param type number representing a command
* @return string of a command
*/
char *tfaContGetCommandString(uint32_t type);
/**
* get the device type from the patch in this devicelist
* - find the patch file for this devidx
* - return the devid from the patch or 0 if not found
* @param cnt pointer to container file
* @param dev_idx device index
* @return descriptor string
*/
int tfa_cnt_get_devid(nxpTfaContainer_t *cnt, int dev_idx) ;
/**
* Get the number of devices from the container
* @return number of devices
*/
int tfa98xx_cnt_max_device(void);
/**
* Set verbosity level
* @param level used as boolean
*/
void tfa_cnt_verbose(int level);
/**
* Return the pointer to the loaded container file
* @return pointer to container, NULL if not loaded.
*/
nxpTfaContainer_t *tfa98xx_get_cnt(void);
/**
* Lookup slave and return device index
* @param slave_addr address of the slave device
* @return device index
*/
int tfa98xx_cnt_slave2idx(int slave_addr);
/**
* Lookup slave and return device revid.
* @param slave_addr address of the slave device
* @return device revid
*/
int tfa98xx_cnt_slave2revid(int slave_addr);
/**
* Get the slave for the device if it exists.
* @param dev_idx the index of the device
* @param slave the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContGetSlave(int dev_idx, uint8_t *slave_addr);
/**
* Write reg and bitfield items in the devicelist to the target.
* @param device the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteRegsDev(int dev_idx);
/**
* Write reg and bitfield items in the profilelist to the target.
* @param device the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteRegsProf(int dev_idx, int prof_idx);
/**
* Write a patchfile in the devicelist to the target.
* @param dev_idx the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWritePatch(int dev_idx);
/**
* Write all param files in the devicelist to the target.
* @param dev_idx the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteFiles(int dev_idx);
/**
* Get sample rate from passed profile index
* @param dev_idx the index of the device
* @param prof_idx the index of the profile
* @return sample rate value
*/
unsigned int tfa98xx_get_profile_sr(int dev_idx, unsigned int prof_idx);
/**
* Open the specified device after looking up the target address.
* @param dev_idx the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContOpen(int dev_idx);
/**
* Close the device.
* @param dev_idx the index of the device
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContClose(int dev_idx);
/**
* Get the device name string
* @param dev_idx the index of the device
* @return device name string or error string if not found
*/
char *tfaContDeviceName(int dev_idx);
/**
* Get the application name from the container file application field
* @param name the input stringbuffer with size: sizeof(application field)+1
* @return actual string length
*/
int tfa_cnt_get_app_name(char *name);
/**
* Get profile index of the calibration profile
* @param dev_idx the index of the device
* @return profile index, -2 if no calibration profile is found or -1 on error
*/
int tfaContGetCalProfile(int dev_idx);
/**
* Is the profile a tap profile ?
* @param dev_idx the index of the device
* @param prof_idx the index of the profile
* @return 1 if the profile is a tap profile or 0 if not
*/
int tfaContIsTapProfile(int dev_idx, int prof_idx);
/**
* Get the name of the profile at certain index for a device in the container file
* @param dev_idx the index of the device
* @param prof_idx the index of the profile
* @return profile name string or error string if not found
*/
char *tfaContProfileName(int dev_idx, int prof_idx);
/**
* Get the number of profiles for a device
* @param dev_idx index of the device
* @return the profile count
*/
int tfaContMaxProfile(int dev_idx);
/**
* Process all items in the profilelist
* NOTE an error return during processing will leave the device muted
* @param dev_idx index of the device
* @param prof_idx index of the profile
* @param vstep_idx index of the vstep
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteProfile(int dev_idx, int prof_idx, int vstep_idx);
/**
* Specify the speaker configurations (cmd id) (Left, right, both, none)
* @param dev_idx index of the device
* @param configuration name string of the configuration
*/
void tfa98xx_set_spkr_select(Tfa98xx_handle_t dev_idx, char *configuration);
/**
* Set current vstep for a given channel
* @param vstep_idx index of the vstep
* @param channel index of the channel
*/
void tfaContSetCurrentVstep(int channel, int vstep_idx);
/**
* Get current vstep for a given channel
* @param channel index of the channel
*/
int tfaContGetCurrentVstep(int channel);
enum Tfa98xx_Error tfa_cont_write_filterbank(int dev_idx, nxpTfaFilter_t *filter);
/**
* Write all param files in the profilelist to the target
* this is used during startup when maybe ACS is set
* @param dev_idx the index of the device
* @param prof_idx the index of the profile
* @param vstep_idx the index of the vstep
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteFilesProf(int dev_idx, int prof_idx, int vstep_idx);
enum Tfa98xx_Error tfaContWriteFilesVstep(int dev_idx, int prof_idx, int vstep_idx);
enum Tfa98xx_Error tfaContWriteDrcFile(int dev_idx, int size, uint8_t data[]);
/**
* Get the device list dsc from the tfaContainer
* @param cont pointer to the tfaContainer
* @param dev_idx the index of the device
* @return device list pointer
*/
nxpTfaDeviceList_t *tfaContGetDevList(nxpTfaContainer_t *cont, int dev_idx);
/**
* Get the Nth profile for the Nth device
* @param cont pointer to the tfaContainer
* @param dev_idx the index of the device
* @param prof_idx the index of the profile
* @return profile list pointer
*/
nxpTfaProfileList_t *tfaContGetDevProfList(nxpTfaContainer_t *cont, int dev_idx, int prof_idx);
/**
* Get the Nth livedata for the Nth device
* @param cont pointer to the tfaContainer
* @param dev_idx the index of the device
* @param livedata_idx the index of the livedata
* @return livedata list pointer
*/
nxpTfaLiveDataList_t *tfaContGetDevLiveDataList(nxpTfaContainer_t *cont, int dev_idx, int livedata_idx);
/**
* Check CRC for container
* @param cont pointer to the tfaContainer
* @return error value 0 on error
*/
int tfaContCrcCheckContainer(nxpTfaContainer_t *cont);
/**
* Get the device list pointer
* @param dev_idx the index of the device
* @return pointer to device list
*/
nxpTfaDeviceList_t *tfaContDevice(int dev_idx);
/**
* Return the pointer to the profile in a list
* @param dev_idx the index of the device
* @param prof_ipx the index of the profile
* @return profile list pointer
*/
nxpTfaProfileList_t *tfaContProfile(int dev_idx, int prof_ipx);
/**
* Return the pointer to the first profile in a list from the tfaContainer
* @param cont pointer to the tfaContainer
* @return pointer to first profile in profile list
*/
nxpTfaProfileList_t *tfaContGet1stProfList(nxpTfaContainer_t *cont);
/**
* Return the pointer to the next profile in a list
* @param prof is the pointer to the profile list
* @return profile list pointer
*/
nxpTfaProfileList_t *tfaContNextProfile(nxpTfaProfileList_t *prof);
/**
* Return the pointer to the first livedata in a list from the tfaContainer
* @param cont pointer to the tfaContainer
* @return pointer to first livedata in profile list
*/
nxpTfaLiveDataList_t *tfaContGet1stLiveDataList(nxpTfaContainer_t *cont);
/**
* Return the pointer to the next livedata in a list
* @param livedata_idx is the pointer to the livedata list
* @return livedata list pointer
*/
nxpTfaLiveDataList_t *tfaContNextLiveData(nxpTfaLiveDataList_t *livedata_idx);
/**
* Write a bit field
* @param dev_idx device index
* @param bf bitfield to write
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaRunWriteBitfield(Tfa98xx_handle_t dev_idx, nxpTfaBitfield_t bf);/* TODO move to run core */
/**
* Write a parameter file to the device
* @param dev_idx device index
* @param file filedescriptor pointer
* @param vstep_idx index to vstep
* @param vstep_msg_idx index to vstep message
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaContWriteFile(int dev_idx, nxpTfaFileDsc_t *file, int vstep_idx, int vstep_msg_idx);
/**
* Get the max volume step associated with Nth profile for the Nth device
* @param dev_idx device index
* @param prof_idx profile index
* @return the number of vsteps
*/
int tfacont_get_max_vstep(int dev_idx, int prof_idx);
/**
* Get the file contents associated with the device or profile
* Search within the device tree, if not found, search within the profile
* tree. There can only be one type of file within profile or device.
* @param dev_idx I2C device index
* @param prof_idx I2C profile index in the device
* @param type file type
* @return 0 NULL if file type is not found
* @return 1 file contents
*/
nxpTfaFileDsc_t *tfacont_getfiledata(int dev_idx, int prof_idx, enum nxpTfaHeaderType type);
/**
* Dump the contents of the file header
* @param hdr pointer to file header data
*/
void tfaContShowHeader(nxpTfaHeader_t *hdr);
/**
* Read a bit field
* @param dev_idx device index
* @param bf bitfield to read out
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfaRunReadBitfield(Tfa98xx_handle_t dev_idx, nxpTfaBitfield_t *bf);
/**
* Get hw feature bits from container file
* @param dev_idx device index
* @param hw_feature_register pointer to where hw features are stored
*/
void get_hw_features_from_cnt(Tfa98xx_handle_t dev_idx, int *hw_feature_register);
/**
* Get sw feature bits from container file
* @param dev_idx device index
* @param sw_feature_register pointer to where sw features are stored
*/
void get_sw_features_from_cnt(Tfa98xx_handle_t dev_idx, int sw_feature_register[2]);
/**
* Factory trimming for the Boost converter
* check if there is a correction needed
* @param dev_idx device index
*/
void tfa_factory_trimmer(Tfa98xx_handle_t dev_idx);
/**
* Search for filters settings and if found then write them to the device
* @param dev_idx device index
* @param prof_idx profile to look in
* @return Tfa98xx_Error
*/
enum Tfa98xx_Error tfa_set_filters(int dev_idx, int prof_idx);
#endif /* TFACONTAINER_H_ */
|