1 /* 2 * Copyright 2019 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef TFA2_DSP_FW_H 9 #define TFA2_DSP_FW_H 10 11 #include "tfa2_dev.h" 12 13 /* 14 * the order matches the ACK bits order in TFA98XX_CF_STATUS 15 */ 16 enum tfa_fw_event 17 { /* not all available on each device */ 18 tfa_fw_i2c_cmd_ack, 19 tfa_fw_reset_start, 20 tfa_fw_short_on_mips, 21 tfa_fw_soft_mute_ready, 22 tfa_fw_volume_ready, 23 tfa_fw_error_damage, 24 tfa_fw_calibrate_done, 25 tfa_fw_max 26 }; 27 28 /* the following type mappings are compiler specific */ 29 #define subaddress_t unsigned char 30 31 /* module Ids */ 32 #define MODULE_FRAMEWORK 0 33 #define MODULE_SPEAKERBOOST 1 34 #define MODULE_BIQUADFILTERBANK 2 35 #define MODULE_TAPTRIGGER 5 36 #define MODULE_SETRE 9 37 38 /* RPC commands */ 39 /* SET */ 40 #define FW_PAR_ID_SET_MEMORY 0x03 41 #define FW_PAR_ID_SET_SENSES_DELAY 0x04 42 #define FW_PAR_ID_SETSENSESCAL 0x05 43 #define FW_PAR_ID_SET_INPUT_SELECTOR 0x06 44 #define FW_PAR_ID_SET_OUTPUT_SELECTOR 0x08 45 #define FW_PAR_ID_SET_PROGRAM_CONFIG 0x09 46 #define FW_PAR_ID_SET_GAINS 0x0A 47 #define FW_PAR_ID_SET_MEMTRACK 0x0B 48 #define FW_PAR_ID_SET_FWKUSECASE 0x11 49 #define TFA1_FW_PAR_ID_SET_CURRENT_DELAY 0x03 50 #define TFA1_FW_PAR_ID_SET_CURFRAC_DELAY 0x06 51 /* GET */ 52 #define FW_PAR_ID_GET_MEMORY 0x83 53 #define FW_PAR_ID_GLOBAL_GET_INFO 0x84 54 #define FW_PAR_ID_GET_FEATURE_INFO 0x85 55 #define FW_PAR_ID_GET_MEMTRACK 0x8B 56 #define FW_PAR_ID_GET_TAG 0xFF 57 #define FW_PAR_ID_GET_API_VERSION 0xFE 58 #define FW_PAR_ID_GET_STATUS_CHANGE 0x8D 59 60 /* Load a full model into SpeakerBoost. */ 61 /* SET */ 62 #define SB_PARAM_SET_ALGO_PARAMS 0x00 63 #define SB_PARAM_SET_LAGW 0x01 64 #define SB_PARAM_SET_ALGO_PARAMS_WITHOUT_RESET 0x02 65 #define SB_PARAM_SET_RE25C 0x05 66 #define SB_PARAM_SET_LSMODEL 0x06 67 #define SB_PARAM_SET_MBDRC 0x07 68 #define SB_PARAM_SET_MBDRC_WITHOUT_RESET 0x08 69 #define SB_PARAM_SET_EXCURSION_FILTERS 0x0A 70 #define SB_PARAM_SET_DRC 0x0F 71 /* GET */ 72 #define SB_PARAM_GET_ALGO_PARAMS 0x80 73 #define SB_PARAM_GET_LAGW 0x81 74 #define SB_PARAM_GET_RE25C 0x85 75 #define SB_PARAM_GET_LSMODEL 0x86 76 #define SB_PARAM_GET_MBDRC 0x87 77 #define SB_PARAM_GET_MBDRC_DYNAMICS 0x89 78 #define SB_PARAM_GET_EXCURSION_FILTERS 0x8A 79 #define SB_PARAM_GET_TAG 0xFF 80 #define FW_MAXTAG 150 81 82 #define SB_PARAM_GET_ZFILTER 0x8F 83 #define SB_PARAM_GET_XFILTER 0x90 84 85 #define SB_PARAM_SET_EQ 0x0A /* 2 Equaliser Filters. */ 86 #define SB_PARAM_SET_PRESET 0x0D /* Load a preset */ 87 #define SB_PARAM_SET_CONFIG 0x0E /* Load a config */ 88 #define SB_PARAM_SET_AGCINS 0x10 89 #define SB_PARAM_SET_CURRENT_DELAY 0x03 90 #define SB_PARAM_GET_STATE 0xC0 91 #define SB_PARAM_GET_XMODEL 0xC1 /* Gets current Excursion Model. */ 92 #define SB_PARAM_GET_XMODEL_COEFFS 0x8C /* Get coefficients for XModel */ 93 #define SB_PARAM_GET_EXCURSION_FILTERS 0x8A /* Get excursion filters */ 94 #define SB_PARAM_SET_EXCURSION_FILTERS 0x0A /* Set excursion filters */ 95 96 /* SET: TAPTRIGGER */ 97 #define TAP_PARAM_SET_ALGO_PARAMS 0x01 98 #define TAP_PARAM_SET_DECIMATION_PARAMS 0x02 99 100 /* GET: TAPTRIGGER*/ 101 #define TAP_PARAM_GET_ALGO_PARAMS 0x81 102 #define TAP_PARAM_GET_TAP_RESULTS 0x84 103 104 /* sets the speaker calibration impedance (@25 degrees celsius) */ 105 #define SB_PARAM_SET_RE0 0x89 106 107 #define BFB_PAR_ID_SET_COEFS 0x00 108 #define BFB_PAR_ID_GET_COEFS 0x80 109 #define BFB_PAR_ID_GET_CONFIG 0x81 110 111 /* for compatibility */ 112 #define FW_PARAM_GET_STATE FW_PAR_ID_GLOBAL_GET_INFO 113 #define FW_PARAM_GET_FEATURE_BITS FW_PAR_ID_GET_FEATURE_BITS 114 115 /* RPC Status results */ 116 #define STATUS_OK 0 117 #define STATUS_INVALID_MODULE_ID 2 118 #define STATUS_INVALID_PARAM_ID 3 119 #define STATUS_INVALID_INFO_ID 4 120 121 /* parameter size in words including command id */ 122 #define TIB_MONO_ALGOPARAMETER_LENGTH (180 + 1) 123 #define TIB_STEREO_ALGOPARAMETER_LENGTH (348 + 1) 124 #define TFA_ALGOPARAMETER_LENGTH (180 + 1) 125 126 #define TIB_MONO_SPEAKERPARAMETER_LENGTH (151 + 1) 127 #define TIB_STEREO_SPEAKERPARAMETER_LENGTH (302 + 1) 128 #define TFA_SPEAKERPARAMETER_LENGTH (151 + 1) 129 130 #define TIB_MONO_MBDRC_LENGTH (99 + 1) 131 #define TIB_STEREO_MBDRC_LENGTH (99 + 1) 132 #define TFA_MBDRC_LENGTH (95 + 1) 133 134 #define TIB_MONO_FILTERCOEFS_LENGTH (1 + 6 * (10 + 2 + 1) + 1) 135 #define TIB_STEREO_FILTERCOEFS_LENGTH (1 + 6 * (10 + 10 + 2 + 2 + 1) + 1) 136 #define TFA_FILTERCOEFS_LENGTH (193) // itf(1+6*10) 137 138 #define TIB_MONO_EXCURSIONFILTER_LENGTH (25 + 1) 139 #define TIB_STEREO_EXCURSIONFILTER_LENGTH (50 + 1) 140 #define TFA_EXCURSIONFILTER_LENGTH (25 + 1) 141 142 /* the maximum message length in the communication with the DSP */ 143 #define TFA2_MAX_PARAM_SIZE (TIB_STEREO_ALGOPARAMETER_LENGTH) /* */ 144 145 #define ROUND_DOWN(a, n) (((a) / (n)) * (n)) 146 147 /* feature bits */ 148 #define FEATURE1_TCOEF 0x100 /* bit8 set means tCoefA expected */ 149 #define FEATURE1_DRC 0x200 /* bit9 NOT set means DRC expected */ 150 151 /* DSP firmware xmem defines */ 152 #define TFA2_FW_XMEM_CALIBRATION_DONE 516 153 #define TFA2_FW_XMEM_COUNT_BOOT 512 154 #define TFA2_FW_XMEM_CMD_COUNT 520 155 156 /* note that the following defs rely on the handle variable */ 157 #define TFA_FW_XMEM_CALIBRATION_DONE TFA_FAM_FW(tfa, XMEM_CALIBRATION_DONE) 158 #define TFA_FW_XMEM_COUNT_BOOT TFA_FAM_FW(tfa, XMEM_COUNT_BOOT) 159 #define TFA_FW_XMEM_CMD_COUNT TFA_FAM_FW(tfa, XMEM_CMD_COUNT) 160 161 #define TFA2_FW_ReZ_SCALE 65536 162 163 #endif /* TFA2_DSP_FW_H */ 164