• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __TGT_HARDWARE__
16 #define __TGT_HARDWARE__
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #include "hal_iomux.h"
23 #include "hal_gpio.h"
24 #include "hal_key.h"
25 #include "hal_aud.h"
26 
27 //config hwardware codec iir.
28 #define EQ_HW_DAC_IIR_LIST_NUM              1
29 #define EQ_HW_ADC_IIR_LIST_NUM              1
30 #define EQ_HW_IIR_LIST_NUM                  1
31 #define EQ_SW_IIR_LIST_NUM                  1
32 #define EQ_HW_FIR_LIST_NUM                  3
33 
34 //pwl
35 #define CFG_HW_PWL_NUM (2)
36 extern const struct HAL_IOMUX_PIN_FUNCTION_MAP cfg_hw_pinmux_pwl[CFG_HW_PWL_NUM];
37 
38 //adckey define
39 #define CFG_HW_ADCKEY_NUMBER 5
40 #define CFG_HW_ADCKEY_BASE 0
41 #define CFG_HW_ADCKEY_ADC_MAXVOLT 1000
42 #define CFG_HW_ADCKEY_ADC_MINVOLT 0
43 #define CFG_HW_ADCKEY_ADC_KEYVOLT_BASE 0
44 extern const uint16_t CFG_HW_ADCKEY_MAP_TABLE[CFG_HW_ADCKEY_NUMBER];
45 extern const uint16_t CFG_HW_ADCKEY_VOL_TABLE[CFG_HW_ADCKEY_NUMBER];
46 #define BTA_AV_CO_SBC_MAX_BITPOOL  52
47 
48 //gpiokey define
49 #ifdef IS_MULTI_AI_ENABLED
50 #define CFG_HW_GPIOKEY_NUM (3)
51 #else
52 #define CFG_HW_GPIOKEY_NUM (1)
53 #endif
54 extern const struct HAL_KEY_GPIOKEY_CFG_T cfg_hw_gpio_key_cfg[CFG_HW_GPIOKEY_NUM];
55 
56 // ANC function key
57 #define ANC_FUNCTION_KEY                    HAL_KEY_CODE_PWR
58 
59 // ANC coefficient curve number
60 #define ANC_COEF_NUM                        (1)
61 
62 //#define ANC_TALK_THROUGH
63 
64 #ifdef ANC_TALK_THROUGH
65 #define ANC_COEF_LIST_NUM                   (ANC_COEF_NUM + 1)
66 #else
67 #define ANC_COEF_LIST_NUM                   (ANC_COEF_NUM)
68 #endif
69 
70 #define ANC_FF_MIC_CH_L                     AUD_CHANNEL_MAP_CH0
71 #define ANC_FF_MIC_CH_R                     AUD_CHANNEL_MAP_CH1
72 #define ANC_FB_MIC_CH_L                     AUD_CHANNEL_MAP_CH2
73 #define ANC_FB_MIC_CH_R                     AUD_CHANNEL_MAP_CH3
74 
75 // audio codec
76 #define CFG_HW_AUD_INPUT_PATH_NUM           3
77 #ifdef HW_AUD_LOOPBACK_MODE
78 #define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV   (AUD_CHANNEL_MAP_CH6 | AUD_CHANNEL_MAP_CH7 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH2 | AUD_VMIC_MAP_VMIC1)
79 #else
80 #ifndef USB_AUDIO_FS
81 #define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV   (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_CHANNEL_MAP_CH2 | AUD_VMIC_MAP_VMIC1)
82 #else
83 #define CFG_HW_AUD_INPUT_PATH_MAINMIC_DEV   (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1 | AUD_VMIC_MAP_VMIC1)
84 #endif /*USB_AUDIO_FS*/
85 #endif /* HW_AUD_LOOPBACK_MODE */
86 
87 extern const struct AUD_IO_PATH_CFG_T cfg_audio_input_path_cfg[CFG_HW_AUD_INPUT_PATH_NUM];
88 
89 #ifdef ALSA_STEREO_TO_MONO_EN
90 #define CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV  (AUD_CHANNEL_MAP_CH1)
91 #else
92 #define CFG_HW_AUD_OUTPUT_PATH_SPEAKER_DEV  (AUD_CHANNEL_MAP_CH0 | AUD_CHANNEL_MAP_CH1)
93 #endif
94 #define CFG_HW_AUD_SIDETONE_MIC_DEV         (AUD_CHANNEL_MAP_CH0)
95 #define CFG_HW_AUD_SIDETONE_GAIN_DBVAL      (-20)
96 
97 //bt config
98 extern const char *BT_LOCAL_NAME;
99 extern const char *BLE_DEFAULT_NAME;
100 extern uint8_t ble_global_addr[6];
101 extern uint8_t bt_global_addr[6];
102 extern uint8_t wifi_addr[6];
103 
104 #define CODEC_SADC_VOL (12)
105 
106 // #ifndef TGT_VOLUME_LEVEL_USER_MAX    // for user specific
107 // #define TGT_VOLUME_LEVEL_USER_MAX        (17)
108 // #endif
109 
110 #ifdef TGT_VOLUME_LEVEL_USER_MAX
111 #define TGT_VOLUME_LEVEL_FACTORY_MAX     (6)
112 
113 /* silence + user_vol_tbl + factory_vol_tbl + + debug_vol_tbl + 1 */
114 #define TGT_VOLUME_LEVEL_QTY_USER_SPECIFIC      ( 1 + \
115                                                   TGT_VOLUME_LEVEL_USER_MAX + \
116                                                   TGT_VOLUME_LEVEL_FACTORY_MAX + \
117                                                   TGT_VOLUME_LEVEL_DEBUG_MAX + \
118                                                   1 )
119 
120 #ifdef TGT_VOLUME_LEVEL_USER_MAX
121 extern const uint32_t alsa_float_volume_mapping_array[TGT_VOLUME_LEVEL_USER_MAX];
122 uint8_t tgt_user_volume_step_get(void);
123 #endif
124 
125 #ifdef TGT_VOLUME_LEVEL_FACTORY_MAX
126 uint8_t tgt_factory_volume_step_get(void);
127 #endif
128 #endif // TGT_VOLUME_LEVEL_USER_MAX
129 
130 #ifdef TGT_VOLUME_LEVEL_QTY_USER_SPECIFIC
131 extern const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY_USER_SPECIFIC];
132 #else
133 extern const struct CODEC_DAC_VOL_T codec_dac_vol[TGT_VOLUME_LEVEL_QTY];
134 #endif
135 
136 #define CFG_AUD_EQ_IIR_NUM_BANDS (4)
137 
138 //battery info
139 #define APP_BATTERY_MIN_MV (3200)
140 #define APP_BATTERY_PD_MV   (3100)
141 
142 #define APP_BATTERY_MAX_MV (4200)
143 
144 extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_enable_cfg;
145 extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_detecter_cfg;
146 extern const struct HAL_IOMUX_PIN_FUNCTION_MAP app_battery_ext_charger_indicator_cfg;
147 
148 #define CFG_HW_AUD_OUTPUT_POP_SWITCH HAL_IOMUX_PIN_P2_5
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif
155