Dhanalakshmi Siddani | 01e94a3 | 2020-02-04 22:16:05 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2014 NXP Semiconductors, All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef TFA_SERVICE_H |
| 11 | #define TFA_SERVICE_H |
| 12 | |
| 13 | #ifdef __KERNEL__ |
| 14 | #include <linux/types.h> |
| 15 | #else |
| 16 | #include <stdint.h> |
| 17 | #endif |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #include "NXP_I2C.h" |
| 21 | #endif |
| 22 | |
| 23 | /* |
| 24 | * Linux kernel module defines TFA98XX_GIT_VERSIONS in the |
| 25 | * linux_driver/Makefile |
| 26 | */ |
| 27 | #ifdef TFA98XX_GIT_VERSIONS |
| 28 | #define TFA98XX_API_REV_STR "v6.6.3"/*TFA98XX_GIT_VERSIONS*/ |
| 29 | #else |
| 30 | #define TFA98XX_API_REV_STR "v6.6.3" |
| 31 | #endif |
| 32 | |
| 33 | #include "tfa_device.h" |
| 34 | |
| 35 | /* |
| 36 | * data previously defined in Tfa9888_dsp.h |
| 37 | */ |
| 38 | #define MEMTRACK_MAX_WORDS 150 |
| 39 | #define LSMODEL_MAX_WORDS 150 |
| 40 | #define TFA98XX_MAXTAG (150) |
| 41 | #define FW_VAR_API_VERSION (521) |
| 42 | |
| 43 | /* Indexes and scaling factors of GetLSmodel */ |
| 44 | #define tfa9888_fs_IDX 128 |
| 45 | #define tfa9888_leakageFactor_IDX 130 |
| 46 | #define tfa9888_ReCorrection_IDX 131 |
| 47 | #define tfa9888_Bl_IDX 132 |
| 48 | #define ReZ_IDX 147 |
| 49 | |
| 50 | #define tfa9872_leakageFactor_IDX 128 |
| 51 | #define tfa9872_ReCorrection_IDX 129 |
| 52 | #define tfa9872_Bl_IDX 130 |
| 53 | |
| 54 | #define fs_SCALE (double)1 |
| 55 | #define leakageFactor_SCALE (double)8388608 |
| 56 | #define ReCorrection_SCALE (double)8388608 |
| 57 | #define Bl_SCALE (double)2097152 |
| 58 | #define tCoef_SCALE (double)8388608 |
| 59 | |
| 60 | /* ---------------------------- Max1 ---------------------------- */ |
| 61 | /* Headroom applied to the main input signal */ |
| 62 | #define SPKRBST_HEADROOM 7 |
| 63 | /* Exponent used for AGC Gain related variables */ |
| 64 | #define SPKRBST_AGCGAIN_EXP SPKRBST_HEADROOM |
| 65 | #define SPKRBST_TEMPERATURE_EXP 9 |
| 66 | /* Exponent used for Gain Corection related variables */ |
| 67 | #define SPKRBST_LIMGAIN_EXP 4 |
| 68 | #define SPKRBST_TIMECTE_EXP 1 |
| 69 | #define DSP_MAX_GAIN_EXP 7 |
| 70 | /* -------------------------------------------------------------- */ |
| 71 | |
| 72 | /* speaker related parameters */ |
| 73 | #define TFA2_SPEAKERPARAMETER_LENGTH (3*151) /* MAX2=450 */ |
| 74 | #define TFA1_SPEAKERPARAMETER_LENGTH (3*141) /* MAX1=423 */ |
| 75 | |
| 76 | /* vstep related parameters */ |
| 77 | #define TFA2_ALGOPARAMETER_LENGTH (3*304) /* N1B = (304) 305 is including the cmd-id */ |
| 78 | #define TFA72_ALGOPARAMETER_LENGTH_MONO (3*183) |
| 79 | #define TFA72_ALGOPARAMETER_LENGTH_STEREO (3*356) |
| 80 | #define TFA2_MBDRCPARAMETER_LENGTH (3*152) /* 154 is including the cmd-id */ |
| 81 | #define TFA72_MBDRCPARAMETER_LENGTH (3*98) |
| 82 | #define TFA1_PRESET_LENGTH 87 |
| 83 | #define TFA1_DRC_LENGTH 381 /* 127 words */ |
| 84 | #define TFA2_FILTERCOEFSPARAMETER_LENGTH (3*168) /* 170 is including the cmd-id */ |
| 85 | #define TFA72_FILTERCOEFSPARAMETER_LENGTH (3*156) |
| 86 | |
| 87 | /* Maximum number of retries for DSP result |
| 88 | * Keep this value low! |
| 89 | * If certain calls require longer wait conditions, the |
| 90 | * application should poll, not the API |
| 91 | * The total wait time depends on device settings. Those |
| 92 | * are application specific. |
| 93 | */ |
| 94 | #define TFA98XX_WAITRESULT_NTRIES 40 |
| 95 | #define TFA98XX_WAITRESULT_NTRIES_LONG 2000 |
| 96 | |
| 97 | /* following lengths are in bytes */ |
| 98 | #define TFA98XX_PRESET_LENGTH 87 |
| 99 | #define TFA98XX_CONFIG_LENGTH 201 |
| 100 | #define TFA98XX_DRC_LENGTH 381 /* 127 words */ |
| 101 | |
| 102 | typedef unsigned char Tfa98xx_Config_t[TFA98XX_CONFIG_LENGTH]; |
| 103 | typedef unsigned char Tfa98xx_Preset_t[TFA98XX_PRESET_LENGTH]; |
| 104 | typedef unsigned char Tfa98xx_DrcParameters_t[TFA98XX_DRC_LENGTH]; |
| 105 | |
| 106 | /* Type containing all the possible errors that can occur */ |
| 107 | enum Tfa98xx_Error { |
| 108 | Tfa98xx_Error_Ok = 0, |
| 109 | Tfa98xx_Error_Device, /* 1. Currently only used to keep in sync with tfa_error */ |
| 110 | Tfa98xx_Error_Bad_Parameter, /* 2. */ |
| 111 | Tfa98xx_Error_Fail, /* 3. generic failure, avoid mislead message */ |
| 112 | Tfa98xx_Error_NoClock, /* 4. no clock detected */ |
| 113 | Tfa98xx_Error_StateTimedOut, /* 5. */ |
| 114 | Tfa98xx_Error_DSP_not_running, /* 6. communication with the DSP failed */ |
| 115 | Tfa98xx_Error_AmpOn, /* 7. amp is still running */ |
| 116 | Tfa98xx_Error_NotOpen, /* 8. the given handle is not open */ |
| 117 | Tfa98xx_Error_InUse, /* 9. too many handles */ |
| 118 | Tfa98xx_Error_Buffer_too_small, /* 10. if a buffer is too small */ |
| 119 | /* the expected response did not occur within the expected time */ |
| 120 | Tfa98xx_Error_RpcBase = 100, |
| 121 | Tfa98xx_Error_RpcBusy = 101, |
| 122 | Tfa98xx_Error_RpcModId = 102, |
| 123 | Tfa98xx_Error_RpcParamId = 103, |
| 124 | Tfa98xx_Error_RpcInvalidCC = 104, |
| 125 | Tfa98xx_Error_RpcInvalidSeq = 105, |
| 126 | Tfa98xx_Error_RpcInvalidParam = 106, |
| 127 | Tfa98xx_Error_RpcBufferOverflow = 107, |
| 128 | Tfa98xx_Error_RpcCalibBusy = 108, |
| 129 | Tfa98xx_Error_RpcCalibFailed = 109, |
| 130 | Tfa98xx_Error_Not_Implemented, |
| 131 | Tfa98xx_Error_Not_Supported, |
| 132 | Tfa98xx_Error_I2C_Fatal, /* Fatal I2C error occurred */ |
| 133 | /* Nonfatal I2C error, and retry count reached */ |
| 134 | Tfa98xx_Error_I2C_NonFatal, |
| 135 | Tfa98xx_Error_Other = 1000 |
| 136 | }; |
| 137 | |
| 138 | /* |
| 139 | * Type containing all the possible msg returns DSP can give |
| 140 | * //TODO move to tfa_dsp_fw.h |
| 141 | */ |
| 142 | enum Tfa98xx_Status_ID { |
| 143 | Tfa98xx_DSP_Not_Running = -1, /* No response from DSP */ |
| 144 | Tfa98xx_I2C_Req_Done = 0, /* Request executed correctly and result, if any, is available for download */ |
| 145 | Tfa98xx_I2C_Req_Busy = 1, /* Request is being processed, just wait for result */ |
| 146 | Tfa98xx_I2C_Req_Invalid_M_ID = 2, /* Provided M-ID does not fit in valid rang [0..2] */ |
| 147 | Tfa98xx_I2C_Req_Invalid_P_ID = 3, /* Provided P-ID isn�t valid in the given M-ID context */ |
| 148 | Tfa98xx_I2C_Req_Invalid_CC = 4, /* Invalid channel configuration bits (SC|DS|DP|DC) combination */ |
| 149 | Tfa98xx_I2C_Req_Invalid_Seq = 5, /* Invalid sequence of commands, in case the DSP expects some commands in a specific order */ |
| 150 | Tfa98xx_I2C_Req_Invalid_Param = 6, /* Generic error */ |
| 151 | Tfa98xx_I2C_Req_Buffer_Overflow = 7, /* I2C buffer has overflowed: host has sent too many parameters, memory integrity is not guaranteed */ |
| 152 | Tfa98xx_I2C_Req_Calib_Busy = 8, /* Calibration not finished */ |
| 153 | Tfa98xx_I2C_Req_Calib_Failed = 9 /* Calibration failed */ |
| 154 | }; |
| 155 | |
| 156 | /* |
| 157 | * speaker as microphone |
| 158 | */ |
| 159 | enum Tfa98xx_saam { |
| 160 | Tfa98xx_saam_none, /*< SAAM feature not available */ |
| 161 | Tfa98xx_saam /*< SAAM feature available */ |
| 162 | }; |
| 163 | |
| 164 | /* |
| 165 | * config file subtypes |
| 166 | */ |
| 167 | enum Tfa98xx_config_type { |
| 168 | Tfa98xx_config_generic, |
| 169 | Tfa98xx_config_sub1, |
| 170 | Tfa98xx_config_sub2, |
| 171 | Tfa98xx_config_sub3, |
| 172 | }; |
| 173 | |
| 174 | enum Tfa98xx_AmpInputSel { |
| 175 | Tfa98xx_AmpInputSel_I2SLeft, |
| 176 | Tfa98xx_AmpInputSel_I2SRight, |
| 177 | Tfa98xx_AmpInputSel_DSP |
| 178 | }; |
| 179 | |
| 180 | enum Tfa98xx_OutputSel { |
| 181 | Tfa98xx_I2SOutputSel_CurrentSense, |
| 182 | Tfa98xx_I2SOutputSel_DSP_Gain, |
| 183 | Tfa98xx_I2SOutputSel_DSP_AEC, |
| 184 | Tfa98xx_I2SOutputSel_Amp, |
| 185 | Tfa98xx_I2SOutputSel_DataI3R, |
| 186 | Tfa98xx_I2SOutputSel_DataI3L, |
| 187 | Tfa98xx_I2SOutputSel_DcdcFFwdCur, |
| 188 | }; |
| 189 | |
| 190 | enum Tfa98xx_StereoGainSel { |
| 191 | Tfa98xx_StereoGainSel_Left, |
| 192 | Tfa98xx_StereoGainSel_Right |
| 193 | }; |
| 194 | |
| 195 | #define TFA98XX_MAXPATCH_LENGTH (3*1024) |
| 196 | |
| 197 | /* the number of biquads supported */ |
| 198 | #define TFA98XX_BIQUAD_NUM 10 |
| 199 | |
| 200 | enum Tfa98xx_Channel { |
| 201 | Tfa98xx_Channel_L, |
| 202 | Tfa98xx_Channel_R, |
| 203 | Tfa98xx_Channel_L_R, |
| 204 | Tfa98xx_Channel_Stereo |
| 205 | }; |
| 206 | |
| 207 | enum Tfa98xx_Mode { |
| 208 | Tfa98xx_Mode_Normal = 0, |
| 209 | Tfa98xx_Mode_RCV |
| 210 | }; |
| 211 | |
| 212 | enum Tfa98xx_Mute { |
| 213 | Tfa98xx_Mute_Off, |
| 214 | Tfa98xx_Mute_Digital, |
| 215 | Tfa98xx_Mute_Amplifier |
| 216 | }; |
| 217 | |
| 218 | enum Tfa98xx_SpeakerBoostStatusFlags { |
| 219 | Tfa98xx_SpeakerBoost_Activity = 0, /* Input signal activity. */ |
| 220 | Tfa98xx_SpeakerBoost_S_Ctrl, /* S Control triggers the limiter */ |
| 221 | Tfa98xx_SpeakerBoost_Muted, /* 1 when signal is muted */ |
| 222 | Tfa98xx_SpeakerBoost_X_Ctrl, /* X Control triggers the limiter */ |
| 223 | Tfa98xx_SpeakerBoost_T_Ctrl, /* T Control triggers the limiter */ |
| 224 | Tfa98xx_SpeakerBoost_NewModel, /* New model is available */ |
| 225 | Tfa98xx_SpeakerBoost_VolumeRdy, /* 0:stable vol, 1:still smoothing */ |
| 226 | Tfa98xx_SpeakerBoost_Damaged, /* Speaker Damage detected */ |
| 227 | Tfa98xx_SpeakerBoost_SignalClipping /* input clipping detected */ |
| 228 | }; |
| 229 | |
| 230 | struct Tfa98xx_DrcStateInfo { |
| 231 | float GRhighDrc1[2]; |
| 232 | float GRhighDrc2[2]; |
| 233 | float GRmidDrc1[2]; |
| 234 | float GRmidDrc2[2]; |
| 235 | float GRlowDrc1[2]; |
| 236 | float GRlowDrc2[2]; |
| 237 | float GRpostDrc1[2]; |
| 238 | float GRpostDrc2[2]; |
| 239 | float GRblDrc[2]; |
| 240 | }; |
| 241 | struct Tfa98xx_StateInfo { |
| 242 | /* SpeakerBoost State */ |
| 243 | float agcGain; /* Current AGC Gain value */ |
| 244 | float limGain; /* Current Limiter Gain value */ |
| 245 | float sMax; /* Current Clip/Lim threshold */ |
| 246 | int T; /* Current Speaker Temperature value */ |
| 247 | int statusFlag; /* Masked bit word */ |
| 248 | float X1; /* estimated excursion caused by Spkrboost gain ctrl */ |
| 249 | float X2; /* estimated excursion caused by manual gain setting */ |
| 250 | float Re; /* Loudspeaker blocked resistance */ |
| 251 | /* Framework state */ |
| 252 | /* increments each time a MIPS problem is detected on the DSP */ |
| 253 | int shortOnMips; |
| 254 | struct Tfa98xx_DrcStateInfo drcState; /* DRC state, when enabled */ |
| 255 | }; |
| 256 | |
| 257 | typedef struct nxpTfaMsg { |
| 258 | uint8_t msg_size; |
| 259 | unsigned char cmdId[3]; |
| 260 | int data[9]; |
| 261 | } nxpTfaMsg_t; |
| 262 | |
| 263 | typedef struct nxp_vstep_msg { |
| 264 | int fw_version; |
| 265 | uint8_t no_of_vsteps; |
| 266 | uint16_t reg_no; |
| 267 | uint8_t *msg_reg; |
| 268 | uint8_t msg_no; |
| 269 | uint32_t algo_param_length; |
| 270 | uint8_t *msg_algo_param; |
| 271 | uint32_t filter_coef_length; |
| 272 | uint8_t *msg_filter_coef; |
| 273 | uint32_t mbdrc_length; |
| 274 | uint8_t *msg_mbdrc; |
| 275 | } nxp_vstep_msg_t; |
| 276 | |
| 277 | typedef struct nxpTfaGroup { |
| 278 | uint8_t msg_size; |
| 279 | uint8_t profileId[64]; |
| 280 | } nxpTfaGroup_t; |
| 281 | |
| 282 | |
| 283 | struct nxpTfa98xx_Memtrack_data { |
| 284 | int length; |
| 285 | float mValues[MEMTRACK_MAX_WORDS]; |
| 286 | int mAdresses[MEMTRACK_MAX_WORDS]; |
| 287 | int trackers[MEMTRACK_MAX_WORDS]; |
| 288 | int scalingFactor[MEMTRACK_MAX_WORDS]; |
| 289 | }; |
| 290 | |
| 291 | /* possible memory values for DMEM in CF_CONTROLs */ |
| 292 | enum Tfa98xx_DMEM { |
| 293 | Tfa98xx_DMEM_ERR = -1, |
| 294 | Tfa98xx_DMEM_PMEM = 0, |
| 295 | Tfa98xx_DMEM_XMEM = 1, |
| 296 | Tfa98xx_DMEM_YMEM = 2, |
| 297 | Tfa98xx_DMEM_IOMEM = 3, |
| 298 | }; |
| 299 | |
| 300 | /** |
| 301 | * lookup the device type and return the family type |
| 302 | */ |
| 303 | int tfa98xx_dev2family(int dev_type); |
| 304 | |
| 305 | /** |
| 306 | * register definition structure |
| 307 | */ |
| 308 | struct regdef { |
| 309 | unsigned char offset; /**< subaddress offset */ |
| 310 | unsigned short pwronDefault; /**< register contents after poweron */ |
| 311 | unsigned short pwronTestmask; /**< mask of bits not test */ |
| 312 | char *name; /**< short register name */ |
| 313 | }; |
| 314 | |
| 315 | enum Tfa98xx_DMEM tfa98xx_filter_mem(struct tfa_device *tfa, int filter_index, unsigned short *address, int channel); |
| 316 | |
| 317 | /** |
| 318 | * Load the default HW settings in the device |
| 319 | * @param tfa the device struct pointer |
| 320 | */ |
| 321 | enum Tfa98xx_Error tfa98xx_init(struct tfa_device *tfa); |
| 322 | |
| 323 | /** |
| 324 | * If needed, this function can be used to get a text version of the status ID code |
| 325 | * @param status the given status ID code |
| 326 | * @return the I2C status ID string |
| 327 | */ |
| 328 | const char *tfa98xx_get_i2c_status_id_string(int status); |
| 329 | |
| 330 | /* control the powerdown bit |
| 331 | * @param tfa the device struct pointer |
| 332 | * @param powerdown must be 1 or 0 |
| 333 | */ |
| 334 | enum Tfa98xx_Error tfa98xx_powerdown(struct tfa_device *tfa, int powerdown); |
| 335 | |
| 336 | /* indicates on which channel of DATAI2 the gain from the IC is set |
| 337 | * @param tfa the device struct pointer |
| 338 | * @param gain_sel, see Tfa98xx_StereoGainSel_t |
| 339 | */ |
| 340 | enum Tfa98xx_Error tfa98xx_select_stereo_gain_channel(struct tfa_device *tfa, |
| 341 | enum Tfa98xx_StereoGainSel gain_sel); |
| 342 | |
| 343 | /** |
| 344 | * set the mtp with user controllable values |
| 345 | * @param tfa the device struct pointer |
| 346 | * @param value to be written |
| 347 | * @param mask to be applied toi the bits affected |
| 348 | */ |
| 349 | enum Tfa98xx_Error tfa98xx_set_mtp(struct tfa_device *tfa, uint16_t value, uint16_t mask); |
| 350 | enum Tfa98xx_Error tfa98xx_get_mtp(struct tfa_device *tfa, uint16_t *value); |
| 351 | |
| 352 | /** |
| 353 | * lock or unlock KEY2 |
| 354 | * lock = 1 will lock |
| 355 | * lock = 0 will unlock |
| 356 | * note that on return all the hidden key will be off |
| 357 | */ |
| 358 | void tfa98xx_key2(struct tfa_device *tfa, int lock); |
| 359 | |
| 360 | int tfa_calibrate(struct tfa_device *tfa) ; |
| 361 | void tfa98xx_set_exttemp(struct tfa_device *tfa, short ext_temp); |
| 362 | short tfa98xx_get_exttemp(struct tfa_device *tfa); |
| 363 | |
| 364 | /* control the volume of the DSP |
| 365 | * @param vol volume in bit field. It must be between 0 and 255 |
| 366 | */ |
| 367 | enum Tfa98xx_Error tfa98xx_set_volume_level(struct tfa_device *tfa, |
| 368 | unsigned short vol); |
| 369 | |
| 370 | /* set the input channel to use |
| 371 | * @param channel see Tfa98xx_Channel_t enumeration |
| 372 | */ |
| 373 | enum Tfa98xx_Error tfa98xx_select_channel(struct tfa_device *tfa, |
| 374 | enum Tfa98xx_Channel channel); |
| 375 | |
| 376 | /* set the mode for normal or receiver mode |
| 377 | * @param mode see Tfa98xx_Mode enumeration |
| 378 | */ |
| 379 | enum Tfa98xx_Error tfa98xx_select_mode(struct tfa_device *tfa, enum Tfa98xx_Mode mode); |
| 380 | |
| 381 | /* mute/unmute the audio |
| 382 | * @param mute see Tfa98xx_Mute_t enumeration |
| 383 | */ |
| 384 | enum Tfa98xx_Error tfa98xx_set_mute(struct tfa_device *tfa, |
| 385 | enum Tfa98xx_Mute mute); |
| 386 | |
| 387 | /* |
| 388 | * tfa_supported_speakers - required for SmartStudio initialization |
| 389 | * returns the number of the supported speaker count |
| 390 | */ |
| 391 | enum Tfa98xx_Error tfa_supported_speakers(struct tfa_device *tfa, int *spkr_count); |
| 392 | |
| 393 | /** |
| 394 | * Return the tfa revision |
| 395 | */ |
| 396 | void tfa98xx_rev(int *major, int *minor, int *revision); |
| 397 | |
| 398 | /* |
| 399 | * Return the feature bits from MTP and cnt file for comparison |
| 400 | */ |
| 401 | enum Tfa98xx_Error |
| 402 | tfa98xx_compare_features(struct tfa_device *tfa, int features_from_MTP[3], int features_from_cnt[3]); |
| 403 | |
| 404 | /* |
| 405 | * return feature bits |
| 406 | */ |
| 407 | enum Tfa98xx_Error |
| 408 | tfa98xx_dsp_get_sw_feature_bits(struct tfa_device *tfa, int features[2]); |
| 409 | enum Tfa98xx_Error |
| 410 | tfa98xx_dsp_get_hw_feature_bits(struct tfa_device *tfa, int *features); |
| 411 | |
| 412 | /* |
| 413 | * tfa98xx_supported_saam |
| 414 | * returns the speaker as microphone feature |
| 415 | * @param saam enum pointer |
| 416 | * @return error code |
| 417 | */ |
| 418 | enum Tfa98xx_Error tfa98xx_supported_saam(struct tfa_device *tfa, enum Tfa98xx_saam *saam); |
| 419 | |
| 420 | /* load the tables to the DSP |
| 421 | * called after patch load is done |
| 422 | * @return error code |
| 423 | */ |
| 424 | enum Tfa98xx_Error tfa98xx_dsp_write_tables(struct tfa_device *tfa, int sample_rate); |
| 425 | |
| 426 | |
| 427 | /* set or clear DSP reset signal |
| 428 | * @param new state |
| 429 | * @return error code |
| 430 | */ |
| 431 | enum Tfa98xx_Error tfa98xx_dsp_reset(struct tfa_device *tfa, int state); |
| 432 | |
| 433 | /* check the state of the DSP subsystem |
| 434 | * return ready = 1 when clocks are stable to allow safe DSP subsystem access |
| 435 | * @param tfa the device struct pointer |
| 436 | * @param ready pointer to state flag, non-zero if clocks are not stable |
| 437 | * @return error code |
| 438 | */ |
| 439 | enum Tfa98xx_Error tfa98xx_dsp_system_stable(struct tfa_device *tfa, int *ready); |
| 440 | |
| 441 | enum Tfa98xx_Error tfa98xx_auto_copy_mtp_to_iic(struct tfa_device *tfa); |
| 442 | |
| 443 | /** |
| 444 | * check the state of the DSP coolflux |
| 445 | * @param tfa the device struct pointer |
| 446 | * @return the value of CFE |
| 447 | */ |
| 448 | int tfa_cf_enabled(struct tfa_device *tfa); |
| 449 | |
| 450 | /* The following functions can only be called when the DSP is running |
| 451 | * - I2S clock must be active, |
| 452 | * - IC must be in operating mode |
| 453 | */ |
| 454 | |
| 455 | /** |
| 456 | * patch the ROM code of the DSP |
| 457 | * @param tfa the device struct pointer |
| 458 | * @param patchLength the number of bytes of patchBytes |
| 459 | * @param patchBytes pointer to the bytes to patch |
| 460 | */ |
| 461 | enum Tfa98xx_Error tfa_dsp_patch(struct tfa_device *tfa, |
| 462 | int patchLength, |
| 463 | const unsigned char *patchBytes); |
| 464 | |
| 465 | /** |
| 466 | * load explicitly the speaker parameters in case of free speaker, |
| 467 | * or when using a saved speaker model |
| 468 | */ |
| 469 | enum Tfa98xx_Error tfa98xx_dsp_write_speaker_parameters( |
| 470 | struct tfa_device *tfa, |
| 471 | int length, |
| 472 | const unsigned char *pSpeakerBytes); |
| 473 | |
| 474 | /** |
| 475 | * read the speaker parameters as used by the SpeakerBoost processing |
| 476 | */ |
| 477 | enum Tfa98xx_Error tfa98xx_dsp_read_speaker_parameters( |
| 478 | struct tfa_device *tfa, |
| 479 | int length, |
| 480 | unsigned char *pSpeakerBytes); |
| 481 | |
| 482 | /** |
| 483 | * read the current status of the DSP, typically used for development, |
| 484 | * not essential to be used in a product |
| 485 | */ |
| 486 | enum Tfa98xx_Error tfa98xx_dsp_get_state_info( |
| 487 | struct tfa_device *tfa, |
| 488 | unsigned char bytes[], |
| 489 | unsigned int *statesize); |
| 490 | |
| 491 | /** |
| 492 | * Check whether the DSP supports DRC |
| 493 | * pbSupportDrc=1 when DSP supports DRC, |
| 494 | * pbSupportDrc=0 when DSP doesn't support it |
| 495 | */ |
| 496 | enum Tfa98xx_Error tfa98xx_dsp_support_drc(struct tfa_device *tfa, |
| 497 | int *pbSupportDrc); |
| 498 | |
| 499 | enum Tfa98xx_Error |
| 500 | tfa98xx_dsp_support_framework(struct tfa_device *tfa, int *pbSupportFramework); |
| 501 | |
| 502 | /** |
| 503 | * read the speaker excursion model as used by SpeakerBoost processing |
| 504 | */ |
| 505 | enum Tfa98xx_Error tfa98xx_dsp_read_excursion_model( |
| 506 | struct tfa_device *tfa, |
| 507 | int length, |
| 508 | unsigned char *pSpeakerBytes); |
| 509 | |
| 510 | /** |
| 511 | * load all the parameters for a preset from a file |
| 512 | */ |
| 513 | enum Tfa98xx_Error tfa98xx_dsp_write_preset(struct tfa_device *tfa, |
| 514 | int length, const unsigned char |
| 515 | *pPresetBytes); |
| 516 | |
| 517 | /** |
| 518 | * wrapper for dsp_msg that adds opcode and only writes |
| 519 | */ |
| 520 | enum Tfa98xx_Error tfa_dsp_cmd_id_write(struct tfa_device *tfa, |
| 521 | unsigned char module_id, |
| 522 | unsigned char param_id, int num_bytes, |
| 523 | const unsigned char data[]); |
| 524 | |
| 525 | /** |
| 526 | * wrapper for dsp_msg that writes opcode and reads back the data |
| 527 | */ |
| 528 | enum Tfa98xx_Error tfa_dsp_cmd_id_write_read(struct tfa_device *tfa, |
| 529 | unsigned char module_id, |
| 530 | unsigned char param_id, int num_bytes, |
| 531 | unsigned char data[]); |
| 532 | |
| 533 | /** |
| 534 | * wrapper for dsp_msg that adds opcode and 3 bytes required for coefs |
| 535 | */ |
| 536 | enum Tfa98xx_Error tfa_dsp_cmd_id_coefs(struct tfa_device *tfa, |
| 537 | unsigned char module_id, |
| 538 | unsigned char param_id, int num_bytes, |
| 539 | unsigned char data[]); |
| 540 | |
| 541 | /** |
| 542 | * wrapper for dsp_msg that adds opcode and 3 bytes required for MBDrcDynamics |
| 543 | */ |
| 544 | enum Tfa98xx_Error tfa_dsp_cmd_id_MBDrc_dynamics(struct tfa_device *tfa, |
| 545 | unsigned char module_id, |
| 546 | unsigned char param_id, int index_subband, |
| 547 | int num_bytes, unsigned char data[]); |
| 548 | |
| 549 | /** |
| 550 | * Disable a certain biquad. |
| 551 | * @param tfa the device struct pointer |
| 552 | * @param biquad_index: 1-10 of the biquad that needs to be adressed |
| 553 | */ |
| 554 | enum Tfa98xx_Error Tfa98xx_DspBiquad_Disable(struct tfa_device *tfa, |
| 555 | int biquad_index); |
| 556 | |
| 557 | /** |
| 558 | * fill the calibration value as milli ohms in the struct |
| 559 | * assume that the device has been calibrated |
| 560 | */ |
| 561 | enum Tfa98xx_Error |
| 562 | tfa_dsp_get_calibration_impedance(struct tfa_device *tfa); |
| 563 | |
| 564 | /* |
| 565 | * return the mohm value |
| 566 | */ |
| 567 | int tfa_get_calibration_info(struct tfa_device *tfa, int channel); |
| 568 | |
| 569 | /* |
| 570 | * return sign extended tap pattern |
| 571 | */ |
| 572 | int tfa_get_tap_pattern(struct tfa_device *tfa); |
| 573 | |
| 574 | /** |
| 575 | * Reads a number of words from dsp memory |
| 576 | * @param tfa the device struct pointer |
| 577 | * @param subaddress write address to set in address register |
| 578 | * @param pValue pointer to read data |
| 579 | */ |
| 580 | enum Tfa98xx_Error tfa98xx_read_register16(struct tfa_device *tfa, |
| 581 | unsigned char subaddress, |
| 582 | unsigned short *pValue); |
| 583 | |
| 584 | /** |
| 585 | * Reads a number of words from dsp memory |
| 586 | * @param tfa the device struct pointer |
| 587 | * @param subaddress write address to set in address register |
| 588 | * @param value value to write int the memory |
| 589 | */ |
| 590 | enum Tfa98xx_Error tfa98xx_write_register16(struct tfa_device *tfa, |
| 591 | unsigned char subaddress, |
| 592 | unsigned short value); |
| 593 | |
| 594 | /** |
| 595 | * Intialise the dsp |
| 596 | * @param tfa the device struct pointer |
| 597 | * @return tfa error enum |
| 598 | */ |
| 599 | enum Tfa98xx_Error |
| 600 | tfa98xx_init_dsp(struct tfa_device *tfa); |
| 601 | |
| 602 | /** |
| 603 | * Get the status of the external DSP |
| 604 | * @param tfa the device struct pointer |
| 605 | * @return status |
| 606 | */ |
| 607 | int tfa98xx_get_dsp_status(struct tfa_device *tfa); |
| 608 | |
| 609 | /** |
| 610 | * Write a command message (RPC) to the dsp |
| 611 | * @param tfa the device struct pointer |
| 612 | * @param num_bytes command buffer size in bytes |
| 613 | * @param command_buffer |
| 614 | * @return tfa error enum |
| 615 | */ |
| 616 | enum Tfa98xx_Error |
| 617 | tfa98xx_write_dsp(struct tfa_device *tfa, int num_bytes, const char *command_buffer); |
| 618 | |
| 619 | /** |
| 620 | * Read the result from the last message from the dsp |
| 621 | * @param tfa the device struct pointer |
| 622 | * @param num_bytes result buffer size in bytes |
| 623 | * @param result_buffer |
| 624 | * @return tfa error enum |
| 625 | */ |
| 626 | enum Tfa98xx_Error |
| 627 | tfa98xx_read_dsp(struct tfa_device *tfa, int num_bytes, unsigned char *result_buffer); |
| 628 | |
| 629 | /** |
| 630 | * Write a command message (RPC) to the dsp and return the result |
| 631 | * @param tfa the device struct pointer |
| 632 | * @param command_length command buffer size in bytes |
| 633 | * @param command_buffer command buffer |
| 634 | * @param result_length result buffer size in bytes |
| 635 | * @param result_buffer result buffer |
| 636 | * @return tfa error enum |
| 637 | */ |
| 638 | enum Tfa98xx_Error |
| 639 | tfa98xx_writeread_dsp(struct tfa_device *tfa, int command_length, void *command_buffer, |
| 640 | int result_length, void *result_buffer); |
| 641 | |
| 642 | /** |
| 643 | * Reads a number of words from dsp memory |
| 644 | * @param tfa the device struct pointer |
| 645 | * @param start_offset offset from where to start reading |
| 646 | * @param num_words number of words to read |
| 647 | * @param pValues pointer to read data |
| 648 | */ |
| 649 | enum Tfa98xx_Error tfa98xx_dsp_read_mem(struct tfa_device *tfa, |
| 650 | unsigned int start_offset, |
| 651 | int num_words, int *pValues); |
| 652 | /** |
| 653 | * Write a value to dsp memory |
| 654 | * @param tfa the device struct pointer |
| 655 | * @param address write address to set in address register |
| 656 | * @param value value to write int the memory |
| 657 | * @param memtype type of memory to write to |
| 658 | */ |
| 659 | enum Tfa98xx_Error tfa98xx_dsp_write_mem_word(struct tfa_device *tfa, |
| 660 | unsigned short address, int value, int memtype); |
| 661 | |
| 662 | /** |
| 663 | * Read data from dsp memory |
| 664 | * @param tfa the device struct pointer |
| 665 | * @param subaddress write address to set in address register |
| 666 | * @param num_bytes number of bytes to read from dsp |
| 667 | * @param data the unsigned char buffer to read data into |
| 668 | */ |
| 669 | enum Tfa98xx_Error tfa98xx_read_data(struct tfa_device *tfa, |
| 670 | unsigned char subaddress, |
| 671 | int num_bytes, unsigned char data[]); |
| 672 | |
| 673 | /** |
| 674 | * Write all the bytes specified by num_bytes and data to dsp memory |
| 675 | * @param tfa the device struct pointer |
| 676 | * @param subaddress the subaddress to write to |
| 677 | * @param num_bytes number of bytes to write |
| 678 | * @param data actual data to write |
| 679 | */ |
| 680 | enum Tfa98xx_Error tfa98xx_write_data(struct tfa_device *tfa, |
| 681 | unsigned char subaddress, |
| 682 | int num_bytes, |
| 683 | const unsigned char data[]); |
| 684 | |
| 685 | enum Tfa98xx_Error tfa98xx_write_raw(struct tfa_device *tfa, |
| 686 | int num_bytes, |
| 687 | const unsigned char data[]); |
| 688 | |
| 689 | /* support for converting error codes into text */ |
| 690 | const char *tfa98xx_get_error_string(enum Tfa98xx_Error error); |
| 691 | |
| 692 | /** |
| 693 | * convert signed 24 bit integers to 32bit aligned bytes |
| 694 | * input: data contains "num_bytes/3" int24 elements |
| 695 | * output: bytes contains "num_bytes" byte elements |
| 696 | * @param num_data length of the input data array |
| 697 | * @param data input data as integer array |
| 698 | * @param bytes output data as unsigned char array |
| 699 | */ |
| 700 | void tfa98xx_convert_data2bytes(int num_data, const int data[], |
| 701 | unsigned char bytes[]); |
| 702 | |
| 703 | /** |
| 704 | * convert memory bytes to signed 24 bit integers |
| 705 | * input: bytes contains "num_bytes" byte elements |
| 706 | * output: data contains "num_bytes/3" int24 elements |
| 707 | * @param num_bytes length of the input data array |
| 708 | * @param bytes input data as unsigned char array |
| 709 | * @param data output data as integer array |
| 710 | */ |
| 711 | void tfa98xx_convert_bytes2data(int num_bytes, const unsigned char bytes[], |
| 712 | int data[]); |
| 713 | |
| 714 | /** |
| 715 | * Read a part of the dsp memory |
| 716 | * @param tfa the device struct pointer |
| 717 | * @param memoryType indicator to the memory type |
| 718 | * @param offset from where to start reading |
| 719 | * @param length the number of bytes to read |
| 720 | * @param bytes output data as unsigned char array |
| 721 | */ |
| 722 | enum Tfa98xx_Error tfa98xx_dsp_get_memory(struct tfa_device *tfa, |
| 723 | int memoryType, int offset, int length, |
| 724 | unsigned char bytes[]); |
| 725 | |
| 726 | /** |
| 727 | * Write a value to the dsp memory |
| 728 | * @param tfa the device struct pointer |
| 729 | * @param memoryType indicator to the memory type |
| 730 | * @param offset from where to start writing |
| 731 | * @param length the number of bytes to write |
| 732 | * @param value the value to write to the dsp |
| 733 | */ |
| 734 | enum Tfa98xx_Error tfa98xx_dsp_set_memory(struct tfa_device *tfa, |
| 735 | int memoryType, int offset, |
| 736 | int length, int value); |
| 737 | |
| 738 | enum Tfa98xx_Error tfa98xx_dsp_write_config(struct tfa_device *tfa, int length, |
| 739 | const unsigned char *p_config_bytes); |
| 740 | enum Tfa98xx_Error tfa98xx_dsp_write_drc(struct tfa_device *tfa, int length, |
| 741 | const unsigned char *p_drc_bytes); |
| 742 | |
| 743 | /** |
| 744 | * write/read raw msg functions : |
| 745 | * the buffer is provided in little endian format, each word occupying 3 bytes, length is in bytes |
| 746 | * The functions will return immediately and do not not wait for DSP response |
| 747 | * @param tfa the device struct pointer |
| 748 | * @param length length of the character buffer to write |
| 749 | * @param buf character buffer to write |
| 750 | */ |
| 751 | enum Tfa98xx_Error tfa_dsp_msg(struct tfa_device *tfa, int length, const char *buf); |
| 752 | |
| 753 | |
| 754 | /** |
| 755 | * The wrapper functions to call the dsp msg, register and memory function for tfa or probus |
| 756 | */ |
| 757 | enum Tfa98xx_Error dsp_msg(struct tfa_device *tfa, int length, const char *buf); |
| 758 | enum Tfa98xx_Error dsp_msg_read(struct tfa_device *tfa, int length, unsigned char *bytes); |
| 759 | enum Tfa98xx_Error reg_write(struct tfa_device *tfa, unsigned char subaddress, unsigned short value); |
| 760 | enum Tfa98xx_Error reg_read(struct tfa_device *tfa, unsigned char subaddress, unsigned short *value); |
| 761 | enum Tfa98xx_Error mem_write(struct tfa_device *tfa, unsigned short address, int value, int memtype); |
| 762 | enum Tfa98xx_Error mem_read(struct tfa_device *tfa, unsigned int start_offset, int num_words, int *pValues); |
| 763 | |
| 764 | enum Tfa98xx_Error dsp_partial_coefficients(struct tfa_device *tfa, uint8_t *prev, uint8_t *next); |
| 765 | int is_94_N2_device(struct tfa_device *tfa); |
| 766 | /** |
| 767 | * write/read raw msg functions: |
| 768 | * the buffer is provided in little endian format, each word occupying 3 bytes, |
| 769 | * length is in bytes The functions will return immediately and do not not wait |
| 770 | * for DSP response. An ID is added to modify the command-ID |
| 771 | * @param tfa the device struct pointer |
| 772 | * @param length length of the character buffer to write |
| 773 | * @param buf character buffer to write |
| 774 | * @param cmdid command identifier |
| 775 | */ |
| 776 | enum Tfa98xx_Error tfa_dsp_msg_id(struct tfa_device *tfa, int length, |
| 777 | const char *buf, uint8_t cmdid[3]); |
| 778 | |
| 779 | /** |
| 780 | * write raw dsp msg functions |
| 781 | * @param tfa the device struct pointer |
| 782 | * @param length length of the character buffer to write |
| 783 | * @param buffer character buffer to write |
| 784 | */ |
| 785 | enum Tfa98xx_Error tfa_dsp_msg_write(struct tfa_device *tfa, int length, |
| 786 | const char *buffer); |
| 787 | |
| 788 | /** |
| 789 | * write raw dsp msg functions |
| 790 | * @param tfa the device struct pointer |
| 791 | * @param length length of the character buffer to write |
| 792 | * @param buffer character buffer to write |
| 793 | * @param cmdid command identifier |
| 794 | */ |
| 795 | enum Tfa98xx_Error tfa_dsp_msg_write_id(struct tfa_device *tfa, int length, |
| 796 | const char *buffer, uint8_t cmdid[3]); |
| 797 | |
| 798 | /** |
| 799 | * status function used by tfa_dsp_msg() to retrieve command/msg status: |
| 800 | * return a <0 status of the DSP did not ACK. |
| 801 | * @param tfa the device struct pointer |
| 802 | * @param pRpcStatus status for remote processor communication |
| 803 | */ |
| 804 | enum Tfa98xx_Error tfa_dsp_msg_status(struct tfa_device *tfa, int *pRpcStatus); |
| 805 | |
| 806 | /** |
| 807 | * Read a message from dsp |
| 808 | * @param tfa the device struct pointer |
| 809 | * @param length number of bytes of the message |
| 810 | * @param bytes pointer to unsigned char buffer |
| 811 | */ |
| 812 | enum Tfa98xx_Error tfa_dsp_msg_read(struct tfa_device *tfa, int length, |
| 813 | unsigned char *bytes); |
| 814 | |
| 815 | int tfa_set_bf(struct tfa_device *tfa, const uint16_t bf, const uint16_t value); |
| 816 | int tfa_set_bf_volatile(struct tfa_device *tfa, const uint16_t bf, |
| 817 | const uint16_t value); |
| 818 | |
| 819 | /** |
| 820 | * Get the value of a given bitfield |
| 821 | * @param tfa the device struct pointer |
| 822 | * @param bf the value indicating which bitfield |
| 823 | */ |
| 824 | int tfa_get_bf(struct tfa_device *tfa, const uint16_t bf); |
| 825 | |
| 826 | /** |
| 827 | * Set the value of a given bitfield |
| 828 | * @param bf the value indicating which bitfield |
| 829 | * @param bf_value the value of the bitfield |
| 830 | * @param p_reg_value a pointer to the register where to write the bitfield |
| 831 | * value |
| 832 | */ |
| 833 | int tfa_set_bf_value(const uint16_t bf, const uint16_t bf_value, |
| 834 | uint16_t *p_reg_value); |
| 835 | |
| 836 | uint16_t tfa_get_bf_value(const uint16_t bf, const uint16_t reg_value); |
| 837 | int tfa_write_reg(struct tfa_device *tfa, const uint16_t bf, |
| 838 | const uint16_t reg_value); |
| 839 | int tfa_read_reg(struct tfa_device *tfa, const uint16_t bf); |
| 840 | |
| 841 | /* bitfield */ |
| 842 | /** |
| 843 | * get the datasheet or bitfield name corresponding to the bitfield number |
| 844 | * @param num is the number for which to get the bitfield name |
| 845 | * @param rev is the device type |
| 846 | */ |
| 847 | char *tfaContBfName(uint16_t num, unsigned short rev); |
| 848 | |
| 849 | /** |
| 850 | * get the datasheet name corresponding to the bitfield number |
| 851 | * @param num is the number for which to get the bitfield name |
| 852 | * @param rev is the device type |
| 853 | */ |
| 854 | char *tfaContDsName(uint16_t num, unsigned short rev); |
| 855 | |
| 856 | /** |
| 857 | * get the bitfield name corresponding to the bitfield number |
| 858 | * @param num is the number for which to get the bitfield name |
| 859 | * @param rev is the device type |
| 860 | */ |
| 861 | char *tfaContBitName(uint16_t num, unsigned short rev); |
| 862 | |
| 863 | /** |
| 864 | * get the bitfield number corresponding to the bitfield name |
| 865 | * @param name is the bitfield name for which to get the bitfield number |
| 866 | * @param rev is the device type |
| 867 | */ |
| 868 | uint16_t tfaContBfEnum(const char *name, unsigned short rev); |
| 869 | |
| 870 | /** |
| 871 | * get the bitfield number corresponding to the bitfield name, checks for all devices |
| 872 | * @param name is the bitfield name for which to get the bitfield number |
| 873 | */ |
| 874 | uint16_t tfaContBfEnumAny(const char *name); |
| 875 | |
| 876 | #define TFA_FAM(tfa, fieldname) ((tfa->tfa_family == 1) ? TFA1_BF_##fieldname : TFA2_BF_##fieldname) |
| 877 | #define TFA_FAM_FW(tfa, fwname) ((tfa->tfa_family == 1) ? TFA1_FW_##fwname : TFA2_FW_##fwname) |
| 878 | |
| 879 | /* set/get bit fields to HW register*/ |
| 880 | #define TFA_SET_BF(tfa, fieldname, value) tfa_set_bf(tfa, TFA_FAM(tfa, fieldname), value) |
| 881 | #define TFA_SET_BF_VOLATILE(tfa, fieldname, value) tfa_set_bf_volatile(tfa, TFA_FAM(tfa, fieldname), value) |
| 882 | #define TFA_GET_BF(tfa, fieldname) tfa_get_bf(tfa, TFA_FAM(tfa, fieldname)) |
| 883 | |
| 884 | /* set/get bit field in variable */ |
| 885 | #define TFA_SET_BF_VALUE(tfa, fieldname, bf_value, p_reg_value) tfa_set_bf_value(TFA_FAM(tfa, fieldname), bf_value, p_reg_value) |
| 886 | #define TFA_GET_BF_VALUE(tfa, fieldname, reg_value) tfa_get_bf_value(TFA_FAM(tfa, fieldname), reg_value) |
| 887 | |
| 888 | /* write/read registers using a bit field name to determine the register address */ |
| 889 | #define TFA_WRITE_REG(tfa, fieldname, value) tfa_write_reg(tfa, TFA_FAM(tfa, fieldname), value) |
| 890 | #define TFA_READ_REG(tfa, fieldname) tfa_read_reg(tfa, TFA_FAM(tfa, fieldname)) |
| 891 | |
| 892 | /* FOR CALIBRATION RETRIES */ |
| 893 | #define TFA98XX_API_WAITRESULT_NTRIES 3000 // defined in API |
| 894 | |
| 895 | /** |
| 896 | * run the startup/init sequence and set ACS bit |
| 897 | * @param tfa the device struct pointer |
| 898 | * @param state the cold start state that is requested |
| 899 | */ |
| 900 | enum Tfa98xx_Error tfaRunColdboot(struct tfa_device *tfa, int state); |
| 901 | enum Tfa98xx_Error tfaRunMute(struct tfa_device *tfa); |
| 902 | enum Tfa98xx_Error tfaRunUnmute(struct tfa_device *tfa); |
| 903 | |
| 904 | /** |
| 905 | * wait for calibrateDone |
| 906 | * @param tfa the device struct pointer |
| 907 | * @param calibrateDone pointer to status of calibration |
| 908 | */ |
| 909 | enum Tfa98xx_Error tfaRunWaitCalibration(struct tfa_device *tfa, int *calibrateDone); |
| 910 | |
| 911 | /** |
| 912 | * run the startup/init sequence and set ACS bit |
| 913 | * @param tfa the device struct pointer |
| 914 | * @param profile the profile that should be loaded |
| 915 | */ |
| 916 | enum Tfa98xx_Error tfaRunColdStartup(struct tfa_device *tfa, int profile); |
| 917 | |
| 918 | /** |
| 919 | * this will load the patch witch will implicitly start the DSP |
| 920 | * if no patch is available the DPS is started immediately |
| 921 | * @param tfa the device struct pointer |
| 922 | */ |
| 923 | enum Tfa98xx_Error tfaRunStartDSP(struct tfa_device *tfa); |
| 924 | |
| 925 | /** |
| 926 | * start the clocks and wait until the AMP is switching |
| 927 | * on return the DSP sub system will be ready for loading |
| 928 | * @param tfa the device struct pointer |
| 929 | * @param profile the profile that should be loaded on startup |
| 930 | */ |
| 931 | enum Tfa98xx_Error tfaRunStartup(struct tfa_device *tfa, int profile); |
| 932 | |
| 933 | /** |
| 934 | * start the maximus speakerboost algorithm |
| 935 | * this implies a full system startup when the system was not already started |
| 936 | * @param tfa the device struct pointer |
| 937 | * @param force indicates whether a full system startup should be allowed |
| 938 | * @param profile the profile that should be loaded |
| 939 | */ |
| 940 | enum Tfa98xx_Error tfaRunSpeakerBoost(struct tfa_device *tfa, |
| 941 | int force, int profile); |
| 942 | |
| 943 | /** |
| 944 | * Startup the device and write all files from device and profile section |
| 945 | * @param tfa the device struct pointer |
| 946 | * @param force indicates whether a full system startup should be allowed |
| 947 | * @param profile the profile that should be loaded on speaker startup |
| 948 | */ |
| 949 | enum Tfa98xx_Error tfaRunSpeakerStartup(struct tfa_device *tfa, int force, |
| 950 | int profile); |
| 951 | |
| 952 | /** |
| 953 | * Run calibration |
| 954 | * @param tfa the device struct pointer |
| 955 | */ |
| 956 | enum Tfa98xx_Error tfaRunSpeakerCalibration(struct tfa_device *tfa); |
| 957 | |
| 958 | /** |
| 959 | * startup all devices. all step until patch loading is handled |
| 960 | * @param tfa the device struct pointer |
| 961 | */ |
| 962 | int tfaRunStartupAll(struct tfa_device *tfa); |
| 963 | |
| 964 | /** |
| 965 | * powerup the coolflux subsystem and wait for it |
| 966 | * @param tfa the device struct pointer |
| 967 | */ |
| 968 | enum Tfa98xx_Error tfa_cf_powerup(struct tfa_device *tfa); |
| 969 | |
| 970 | /* |
| 971 | * print the current device manager state |
| 972 | * @param tfa the device struct pointer |
| 973 | */ |
| 974 | enum Tfa98xx_Error show_current_state(struct tfa_device *tfa); |
| 975 | |
| 976 | /** |
| 977 | * Init registers and coldboot dsp |
| 978 | * @param tfa the device struct pointer |
| 979 | */ |
| 980 | int tfa_reset(struct tfa_device *tfa); |
| 981 | |
| 982 | /** |
| 983 | * Get profile from a register |
| 984 | * @param tfa the device struct pointer |
| 985 | */ |
| 986 | int tfa_dev_get_swprof(struct tfa_device *tfa); |
| 987 | |
| 988 | /** |
| 989 | * Save profile in a register |
| 990 | */ |
| 991 | int tfa_dev_set_swprof(struct tfa_device *tfa, unsigned short new_value); |
| 992 | |
| 993 | int tfa_dev_get_swvstep(struct tfa_device *tfa); |
| 994 | |
| 995 | int tfa_dev_set_swvstep(struct tfa_device *tfa, unsigned short new_value); |
| 996 | |
| 997 | int tfa_needs_reset(struct tfa_device *tfa); |
| 998 | |
| 999 | int tfa_is_cold(struct tfa_device *tfa); |
| 1000 | |
| 1001 | void tfa_set_query_info(struct tfa_device *tfa); |
| 1002 | |
| 1003 | int tfa_get_pga_gain(struct tfa_device *tfa); |
| 1004 | int tfa_set_pga_gain(struct tfa_device *tfa, uint16_t value); |
| 1005 | int tfa_get_noclk(struct tfa_device *tfa); |
| 1006 | |
| 1007 | /** |
| 1008 | * Status of used for monitoring |
| 1009 | * @param tfa the device struct pointer |
| 1010 | * @return tfa error enum |
| 1011 | */ |
| 1012 | |
| 1013 | enum Tfa98xx_Error tfa_status(struct tfa_device *tfa); |
| 1014 | |
| 1015 | /* |
| 1016 | * function overload for flag_mtp_busy |
| 1017 | */ |
| 1018 | int tfa_dev_get_mtpb(struct tfa_device *tfa); |
| 1019 | |
| 1020 | enum Tfa98xx_Error tfaGetFwApiVersion(struct tfa_device *tfa, unsigned char *pFirmwareVersion); |
| 1021 | #ifdef __cplusplus |
| 1022 | } |
| 1023 | #endif |
| 1024 | #endif /* TFA_SERVICE_H */ |