diff options
author | Dana Conrad <dconrad@fastmail.com> | 2023-12-03 15:07:26 -0600 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2024-01-02 08:19:23 -0500 |
commit | 8cc7476735dd3f9f9e3f5b1356eadc4ef40c23b4 (patch) | |
tree | 23891c54ebb8e6adaea8b8382830c7e29ad7475d /firmware | |
parent | a3fe07ff128e521051aee8bc91add071724d6538 (diff) | |
download | rockbox-8cc7476735dd3f9f9e3f5b1356eadc4ef40c23b4.tar.gz rockbox-8cc7476735dd3f9f9e3f5b1356eadc4ef40c23b4.zip |
ErosQ Native ES9018K2M: Add digital filters capability
Setting not yet hidden for older hardware revision.
Change-Id: Iaaa5727e63c38de578a6bbc73498ae1073180e65
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/es9018k2m.c | 48 | ||||
-rw-r--r-- | firmware/export/config/erosqnative.h | 2 | ||||
-rw-r--r-- | firmware/export/es9018k2m.h | 14 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c | 10 |
4 files changed, 68 insertions, 6 deletions
diff --git a/firmware/drivers/audio/es9018k2m.c b/firmware/drivers/audio/es9018k2m.c index e19cf6e8a9..3f14aaea39 100644 --- a/firmware/drivers/audio/es9018k2m.c +++ b/firmware/drivers/audio/es9018k2m.c | |||
@@ -55,15 +55,20 @@ static int vol_tenthdb2hw(const int tdb) | |||
55 | * static uint8_t reg4_automute_time = 0x00; // Automute time. Default = disabled | 55 | * static uint8_t reg4_automute_time = 0x00; // Automute time. Default = disabled |
56 | * static uint8_t reg5_automute_level = 0x68; // Automute level. Default is some level | 56 | * static uint8_t reg5_automute_level = 0x68; // Automute level. Default is some level |
57 | * static uint8_t reg6_deemphasis = 0x4A; // Deemphasis. Default = disabled | 57 | * static uint8_t reg6_deemphasis = 0x4A; // Deemphasis. Default = disabled |
58 | * static uint8_t reg7_general_settings = 0x80; // General settings. Default sharp fir, pcm iir and unmuted | 58 | */ |
59 | static uint8_t reg7_general_settings = 0x80; // General settings. Default sharp fir, pcm iir and unmuted | ||
60 | /* | ||
59 | * static uint8_t reg8_gpio_configuration = 0x10; // GPIO configuration | 61 | * static uint8_t reg8_gpio_configuration = 0x10; // GPIO configuration |
60 | * static uint8_t reg10_master_mode_control = 0x05; // Master Mode Control. Default value: master mode off | 62 | * static uint8_t reg10_master_mode_control = 0x05; // Master Mode Control. Default value: master mode off |
61 | * static uint8_t reg11_channel_mapping = 0x02; // Channel Mapping. Default stereo is Ch1=left, Ch2=right | 63 | * static uint8_t reg11_channel_mapping = 0x02; // Channel Mapping. Default stereo is Ch1=left, Ch2=right |
62 | * static uint8_t reg12_dpll_settings = 0x5A; // DPLL Settings. Default = 5 for I2S, A for DSD | 64 | * static uint8_t reg12_dpll_settings = 0x5A; // DPLL Settings. Default = 5 for I2S, A for DSD |
63 | * static uint8_t reg13_thd_comp = 0x40; // THD Compensation | 65 | * static uint8_t reg13_thd_comp = 0x40; // THD Compensation |
64 | * static uint8_t reg14_softstart_settings = 0x8A; // Soft Start Settings | 66 | * static uint8_t reg14_softstart_settings = 0x8A; // Soft Start Settings |
65 | * static uint8_t reg21_gpio_input_selection = 0x00; // Oversampling filter. Default: oversampling ON | ||
66 | */ | 67 | */ |
68 | static uint8_t reg21_gpio_input_selection = 0x00; // Oversampling filter. Default: oversampling ON | ||
69 | |||
70 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) | ||
71 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) | ||
67 | 72 | ||
68 | static uint8_t vol_reg_l = ES9018K2M_REG15_VOLUME_L; | 73 | static uint8_t vol_reg_l = ES9018K2M_REG15_VOLUME_L; |
69 | static uint8_t reg15_vol_l = 0; | 74 | static uint8_t reg15_vol_l = 0; |
@@ -95,7 +100,7 @@ i2c_descriptor vol_desc_r = { | |||
95 | .next = NULL, | 100 | .next = NULL, |
96 | }; | 101 | }; |
97 | 102 | ||
98 | void es9018k2m_set_volume(int vol_l, int vol_r) | 103 | void es9018k2m_set_volume_async(int vol_l, int vol_r) |
99 | { | 104 | { |
100 | /* Queue writes to the DAC's volume. | 105 | /* Queue writes to the DAC's volume. |
101 | * Note that this needs to be done asynchronously. From testing, calling | 106 | * Note that this needs to be done asynchronously. From testing, calling |
@@ -106,6 +111,43 @@ void es9018k2m_set_volume(int vol_l, int vol_r) | |||
106 | i2c_async_queue(ES9018K2M_BUS, TIMEOUT_NOBLOCK, I2C_Q_ADD, 0, &vol_desc_r); | 111 | i2c_async_queue(ES9018K2M_BUS, TIMEOUT_NOBLOCK, I2C_Q_ADD, 0, &vol_desc_r); |
107 | } | 112 | } |
108 | 113 | ||
114 | void es9018k2m_set_filter_roll_off(int value) | ||
115 | { | ||
116 | /* Note: the ihifi800 implementation manipulates | ||
117 | * bit 0 of reg21, but I think that is incorrect? | ||
118 | * Bit 2 is the bypass for the IIR digital filters, | ||
119 | * Whereas Bit 0 is the oversampling filter, which | ||
120 | * the datasheet seems to say should be left on. */ | ||
121 | |||
122 | /* 0 = "Sharp" / Fast Rolloff (Default) | ||
123 | 1 = Slow Rolloff | ||
124 | 2 = "Short" / Minimum Phase | ||
125 | 3 = Bypass */ | ||
126 | switch(value) | ||
127 | { | ||
128 | case 0: | ||
129 | bitClear(reg7_general_settings, 5); | ||
130 | bitClear(reg7_general_settings, 6); | ||
131 | bitClear(reg21_gpio_input_selection, 2); | ||
132 | break; | ||
133 | case 1: | ||
134 | bitSet(reg7_general_settings, 5); | ||
135 | bitClear(reg7_general_settings, 6); | ||
136 | bitClear(reg21_gpio_input_selection, 2); | ||
137 | break; | ||
138 | case 2: | ||
139 | bitClear(reg7_general_settings, 5); | ||
140 | bitSet(reg7_general_settings, 6); | ||
141 | bitClear(reg21_gpio_input_selection, 2); | ||
142 | break; | ||
143 | case 3: | ||
144 | bitSet(reg21_gpio_input_selection, 2); | ||
145 | break; | ||
146 | } | ||
147 | es9018k2m_write_reg(ES9018K2M_REG7_GENERAL_SETTINGS, reg7_general_settings); | ||
148 | es9018k2m_write_reg(ES9018K2M_REG21_GPIO_INPUT_SELECT, reg21_gpio_input_selection); | ||
149 | } | ||
150 | |||
109 | /* returns I2C_STATUS_OK upon success, I2C_STATUS_* errors upon error */ | 151 | /* returns I2C_STATUS_OK upon success, I2C_STATUS_* errors upon error */ |
110 | int es9018k2m_write_reg(uint8_t reg, uint8_t val) | 152 | int es9018k2m_write_reg(uint8_t reg, uint8_t val) |
111 | { | 153 | { |
diff --git a/firmware/export/config/erosqnative.h b/firmware/export/config/erosqnative.h index c71f7ade49..4f87282f1f 100644 --- a/firmware/export/config/erosqnative.h +++ b/firmware/export/config/erosqnative.h | |||
@@ -63,6 +63,8 @@ | |||
63 | #define HAVE_EROS_QN_CODEC | 63 | #define HAVE_EROS_QN_CODEC |
64 | #define HAVE_SW_TONE_CONTROLS | 64 | #define HAVE_SW_TONE_CONTROLS |
65 | #define HAVE_SW_VOLUME_CONTROL | 65 | #define HAVE_SW_VOLUME_CONTROL |
66 | #define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP) | ||
67 | #define AUDIOHW_HAVE_SHORT_ROLL_OFF | ||
66 | 68 | ||
67 | /* use high-bitdepth volume scaling */ | 69 | /* use high-bitdepth volume scaling */ |
68 | #define PCM_NATIVE_BITDEPTH 24 | 70 | #define PCM_NATIVE_BITDEPTH 24 |
diff --git a/firmware/export/es9018k2m.h b/firmware/export/es9018k2m.h index 035a607030..2824fed505 100644 --- a/firmware/export/es9018k2m.h +++ b/firmware/export/es9018k2m.h | |||
@@ -25,6 +25,13 @@ | |||
25 | 25 | ||
26 | //====================================================================================== | 26 | //====================================================================================== |
27 | // ES9018K2M support stuff | 27 | // ES9018K2M support stuff |
28 | // Implement audiohw_* functions in audiohw-*.c. These functions are utilities which | ||
29 | // may be used there. | ||
30 | |||
31 | // AUDIOHW_SETTING(VOLUME, *) not set here, probably best to put it in device-specific *_codec.h | ||
32 | #ifdef AUDIOHW_HAVE_SHORT_ROLL_OFF | ||
33 | AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 3, 0) | ||
34 | #endif | ||
28 | 35 | ||
29 | #ifndef ES9018K2M_VOLUME_MIN | 36 | #ifndef ES9018K2M_VOLUME_MIN |
30 | # define ES9018K2M_VOLUME_MIN -1270 | 37 | # define ES9018K2M_VOLUME_MIN -1270 |
@@ -50,8 +57,11 @@ | |||
50 | #define ES9018K2M_REG16_VOLUME_R 16 | 57 | #define ES9018K2M_REG16_VOLUME_R 16 |
51 | #define ES9018K2M_REG21_GPIO_INPUT_SELECT 21 | 58 | #define ES9018K2M_REG21_GPIO_INPUT_SELECT 21 |
52 | 59 | ||
53 | /* writes volume levels to DAC over I2C */ | 60 | /* writes volume levels to DAC over I2C, asynchronously */ |
54 | void es9018k2m_set_volume(int vol_l, int vol_r); | 61 | void es9018k2m_set_volume_async(int vol_l, int vol_r); |
62 | |||
63 | /* write filter roll-off setting to DAC over I2C, synchronously */ | ||
64 | void es9018k2m_set_filter_roll_off(int value); | ||
55 | 65 | ||
56 | /* writes a single register */ | 66 | /* writes a single register */ |
57 | /* returns I2C_STATUS_OK upon success, I2C_STATUS_* errors upon error */ | 67 | /* returns I2C_STATUS_OK upon success, I2C_STATUS_* errors upon error */ |
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c index 1e3e7f0b7f..df97aba0c8 100644 --- a/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c +++ b/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c | |||
@@ -162,7 +162,7 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
162 | /* set software volume just below unity due to | 162 | /* set software volume just below unity due to |
163 | * DAC offset. We don't want to overflow the PCM system. */ | 163 | * DAC offset. We don't want to overflow the PCM system. */ |
164 | pcm_set_master_volume(-1, -1); | 164 | pcm_set_master_volume(-1, -1); |
165 | es9018k2m_set_volume(l, r); | 165 | es9018k2m_set_volume_async(l, r); |
166 | } | 166 | } |
167 | else /* PCM5102A */ | 167 | else /* PCM5102A */ |
168 | { | 168 | { |
@@ -171,4 +171,12 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
171 | 171 | ||
172 | pcm_set_master_volume(l, r); | 172 | pcm_set_master_volume(l, r); |
173 | } | 173 | } |
174 | } | ||
175 | |||
176 | void audiohw_set_filter_roll_off(int value) | ||
177 | { | ||
178 | if (es9018k2m_present_flag) | ||
179 | { | ||
180 | es9018k2m_set_filter_roll_off(value); | ||
181 | } | ||
174 | } \ No newline at end of file | 182 | } \ No newline at end of file |