Lines Matching full:hal
8 // The HAL layer for I2S (common part)
11 #include "hal/i2s_hal.h"
74 void i2s_hal_init(i2s_hal_context_t *hal, int port_id) in i2s_hal_init() argument
77 hal->dev = I2S_LL_GET_HW(port_id); in i2s_hal_init()
80 void i2s_hal_set_tx_clock(i2s_hal_context_t *hal, const i2s_hal_clock_info_t *clk_info, i2s_clock_s… in i2s_hal_set_tx_clock() argument
84 i2s_ll_tx_enable_clock(hal->dev); in i2s_hal_set_tx_clock()
85 i2s_ll_mclk_bind_to_tx_clk(hal->dev); in i2s_hal_set_tx_clock()
87 i2s_ll_tx_clk_set_src(hal->dev, clk_src); in i2s_hal_set_tx_clock()
89 i2s_ll_tx_set_mclk(hal->dev, &mclk_div); in i2s_hal_set_tx_clock()
90 i2s_ll_tx_set_bck_div_num(hal->dev, clk_info->bclk_div); in i2s_hal_set_tx_clock()
93 void i2s_hal_set_rx_clock(i2s_hal_context_t *hal, const i2s_hal_clock_info_t *clk_info, i2s_clock_s… in i2s_hal_set_rx_clock() argument
97 i2s_ll_rx_enable_clock(hal->dev); in i2s_hal_set_rx_clock()
98 i2s_ll_mclk_bind_to_rx_clk(hal->dev); in i2s_hal_set_rx_clock()
100 i2s_ll_rx_clk_set_src(hal->dev, clk_src); in i2s_hal_set_rx_clock()
102 i2s_ll_rx_set_mclk(hal->dev, &mclk_div); in i2s_hal_set_rx_clock()
103 i2s_ll_rx_set_bck_div_num(hal->dev, clk_info->bclk_div); in i2s_hal_set_rx_clock()
109 void i2s_hal_std_set_tx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_std_set_tx_slot() argument
113 i2s_ll_tx_reset(hal->dev); in i2s_hal_std_set_tx_slot()
114 i2s_ll_tx_set_slave_mod(hal->dev, is_slave); //TX Slave in i2s_hal_std_set_tx_slot()
115 i2s_ll_tx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_std_set_tx_slot()
116 i2s_ll_tx_enable_msb_shift(hal->dev, slot_cfg->std.bit_shift); in i2s_hal_std_set_tx_slot()
117 i2s_ll_tx_set_ws_width(hal->dev, slot_cfg->std.ws_width); in i2s_hal_std_set_tx_slot()
119 i2s_ll_tx_enable_mono_mode(hal->dev, slot_cfg->slot_mode == I2S_SLOT_MODE_MONO); in i2s_hal_std_set_tx_slot()
120 …i2s_ll_tx_select_std_slot(hal->dev, slot_cfg->std.slot_mask, slot_cfg->slot_mode == I2S_SLOT_MODE_… in i2s_hal_std_set_tx_slot()
122 i2s_ll_tx_enable_msb_right(hal->dev, slot_cfg->std.msb_right); in i2s_hal_std_set_tx_slot()
123 i2s_ll_tx_enable_right_first(hal->dev, slot_cfg->std.ws_pol); in i2s_hal_std_set_tx_slot()
125 i2s_ll_tx_force_enable_fifo_mod(hal->dev, true); in i2s_hal_std_set_tx_slot()
128 i2s_ll_tx_enable_mono_mode(hal->dev, is_copy_mono); in i2s_hal_std_set_tx_slot()
129 i2s_ll_tx_select_std_slot(hal->dev, is_copy_mono ? I2S_STD_SLOT_LEFT : slot_cfg->std.slot_mask); in i2s_hal_std_set_tx_slot()
130 i2s_ll_tx_set_skip_mask(hal->dev, (slot_cfg->std.slot_mask != I2S_STD_SLOT_BOTH) && in i2s_hal_std_set_tx_slot()
132 i2s_ll_tx_set_half_sample_bit(hal->dev, slot_bit_width); in i2s_hal_std_set_tx_slot()
133 i2s_ll_tx_set_ws_idle_pol(hal->dev, slot_cfg->std.ws_pol); in i2s_hal_std_set_tx_slot()
134 i2s_ll_tx_set_bit_order(hal->dev, slot_cfg->std.bit_order_lsb); in i2s_hal_std_set_tx_slot()
135 i2s_ll_tx_enable_left_align(hal->dev, slot_cfg->std.left_align); in i2s_hal_std_set_tx_slot()
136 i2s_ll_tx_enable_big_endian(hal->dev, slot_cfg->std.big_endian); in i2s_hal_std_set_tx_slot()
140 void i2s_hal_std_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_std_set_rx_slot() argument
144 i2s_ll_rx_reset(hal->dev); in i2s_hal_std_set_rx_slot()
145 i2s_ll_rx_set_slave_mod(hal->dev, is_slave); //RX Slave in i2s_hal_std_set_rx_slot()
146 i2s_ll_rx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_std_set_rx_slot()
147 i2s_ll_rx_enable_mono_mode(hal->dev, slot_cfg->slot_mode == I2S_SLOT_MODE_MONO); in i2s_hal_std_set_rx_slot()
148 i2s_ll_rx_enable_msb_shift(hal->dev, slot_cfg->std.bit_shift); in i2s_hal_std_set_rx_slot()
149 i2s_ll_rx_set_ws_width(hal->dev, slot_cfg->std.ws_width); in i2s_hal_std_set_rx_slot()
151 i2s_ll_rx_select_std_slot(hal->dev, slot_cfg->std.slot_mask, slot_cfg->std.msb_right); in i2s_hal_std_set_rx_slot()
152 i2s_ll_rx_enable_msb_right(hal->dev, slot_cfg->std.msb_right); in i2s_hal_std_set_rx_slot()
153 i2s_ll_rx_enable_right_first(hal->dev, slot_cfg->std.ws_pol); in i2s_hal_std_set_rx_slot()
155 i2s_ll_rx_force_enable_fifo_mod(hal->dev, true); in i2s_hal_std_set_rx_slot()
157 i2s_ll_rx_select_std_slot(hal->dev, slot_cfg->std.slot_mask); in i2s_hal_std_set_rx_slot()
158 i2s_ll_rx_set_half_sample_bit(hal->dev, slot_bit_width); in i2s_hal_std_set_rx_slot()
159 i2s_ll_rx_set_ws_idle_pol(hal->dev, slot_cfg->std.ws_pol); in i2s_hal_std_set_rx_slot()
160 i2s_ll_rx_set_bit_order(hal->dev, slot_cfg->std.bit_order_lsb); in i2s_hal_std_set_rx_slot()
161 i2s_ll_rx_enable_left_align(hal->dev, slot_cfg->std.left_align); in i2s_hal_std_set_rx_slot()
162 i2s_ll_rx_enable_big_endian(hal->dev, slot_cfg->std.big_endian); in i2s_hal_std_set_rx_slot()
166 void i2s_hal_std_enable_tx_channel(i2s_hal_context_t *hal) in i2s_hal_std_enable_tx_channel() argument
168 i2s_ll_tx_enable_std(hal->dev); in i2s_hal_std_enable_tx_channel()
171 void i2s_hal_std_enable_rx_channel(i2s_hal_context_t *hal) in i2s_hal_std_enable_rx_channel() argument
173 i2s_ll_rx_enable_std(hal->dev); in i2s_hal_std_enable_rx_channel()
180 void i2s_hal_pdm_set_tx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_pdm_set_tx_slot() argument
183 i2s_ll_tx_reset(hal->dev); in i2s_hal_pdm_set_tx_slot()
184 i2s_ll_tx_set_slave_mod(hal->dev, is_slave); //TX Slave in i2s_hal_pdm_set_tx_slot()
185 i2s_ll_tx_enable_msb_shift(hal->dev, false); in i2s_hal_pdm_set_tx_slot()
187 i2s_ll_tx_set_pdm_prescale(hal->dev, slot_cfg->pdm_tx.sd_prescale); in i2s_hal_pdm_set_tx_slot()
188 i2s_ll_tx_set_pdm_hp_scale(hal->dev, slot_cfg->pdm_tx.hp_scale); in i2s_hal_pdm_set_tx_slot()
189 i2s_ll_tx_set_pdm_lp_scale(hal->dev, slot_cfg->pdm_tx.lp_scale); in i2s_hal_pdm_set_tx_slot()
190 i2s_ll_tx_set_pdm_sinc_scale(hal->dev, slot_cfg->pdm_tx.sinc_scale); in i2s_hal_pdm_set_tx_slot()
191 i2s_ll_tx_set_pdm_sd_scale(hal->dev, slot_cfg->pdm_tx.sd_scale); in i2s_hal_pdm_set_tx_slot()
196 i2s_ll_tx_force_enable_fifo_mod(hal->dev, true); in i2s_hal_pdm_set_tx_slot()
197 i2s_ll_tx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_pdm_set_tx_slot()
198 i2s_ll_tx_enable_mono_mode(hal->dev, is_mono); in i2s_hal_pdm_set_tx_slot()
199 i2s_ll_tx_select_pdm_slot(hal->dev, slot_cfg->pdm_tx.slot_mask & I2S_STD_SLOT_BOTH, is_mono); in i2s_hal_pdm_set_tx_slot()
200 i2s_ll_tx_enable_msb_right(hal->dev, false); in i2s_hal_pdm_set_tx_slot()
201 i2s_ll_tx_enable_right_first(hal->dev, false); in i2s_hal_pdm_set_tx_slot()
204 i2s_ll_tx_pdm_line_mode(hal->dev, slot_cfg->pdm_tx.line_mode); in i2s_hal_pdm_set_tx_slot()
207 i2s_ll_tx_set_sample_bit(hal->dev, slot_bit_width, slot_bit_width); in i2s_hal_pdm_set_tx_slot()
208 i2s_ll_tx_set_half_sample_bit(hal->dev, 16); // Fixed to 16 in PDM mode in i2s_hal_pdm_set_tx_slot()
210 i2s_ll_tx_pdm_dma_take_mode(hal->dev, is_mono, true); in i2s_hal_pdm_set_tx_slot()
211 i2s_ll_tx_set_ws_idle_pol(hal->dev, false); in i2s_hal_pdm_set_tx_slot()
213 i2s_ll_tx_pdm_slot_mode(hal->dev, is_mono, false, I2S_PDM_SLOT_BOTH); in i2s_hal_pdm_set_tx_slot()
225 i2s_ll_tx_enable_pdm_hp_filter(hal->dev, slot_cfg->pdm_tx.hp_en); in i2s_hal_pdm_set_tx_slot()
226 i2s_ll_tx_set_pdm_hp_filter_param0(hal->dev, cut_off_coef[cnt][1]); in i2s_hal_pdm_set_tx_slot()
227 i2s_ll_tx_set_pdm_hp_filter_param5(hal->dev, cut_off_coef[cnt][2]); in i2s_hal_pdm_set_tx_slot()
228 i2s_ll_tx_set_pdm_sd_dither(hal->dev, slot_cfg->pdm_tx.sd_dither); in i2s_hal_pdm_set_tx_slot()
229 i2s_ll_tx_set_pdm_sd_dither2(hal->dev, slot_cfg->pdm_tx.sd_dither2); in i2s_hal_pdm_set_tx_slot()
233 void i2s_hal_pdm_enable_tx_channel(i2s_hal_context_t *hal) in i2s_hal_pdm_enable_tx_channel() argument
235 i2s_ll_tx_enable_pdm(hal->dev); in i2s_hal_pdm_enable_tx_channel()
240 void i2s_hal_pdm_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_pdm_set_rx_slot() argument
244 i2s_ll_rx_reset(hal->dev); in i2s_hal_pdm_set_rx_slot()
245 i2s_ll_rx_set_slave_mod(hal->dev, is_slave); //RX Slave in i2s_hal_pdm_set_rx_slot()
246 i2s_ll_rx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_pdm_set_rx_slot()
248 i2s_ll_rx_enable_mono_mode(hal->dev, slot_cfg->slot_mode == I2S_SLOT_MODE_MONO); in i2s_hal_pdm_set_rx_slot()
249 i2s_ll_rx_select_pdm_slot(hal->dev, slot_cfg->pdm_rx.slot_mask); in i2s_hal_pdm_set_rx_slot()
250 i2s_ll_rx_force_enable_fifo_mod(hal->dev, true); in i2s_hal_pdm_set_rx_slot()
251 i2s_ll_rx_enable_msb_right(hal->dev, false); in i2s_hal_pdm_set_rx_slot()
252 i2s_ll_rx_enable_right_first(hal->dev, false); in i2s_hal_pdm_set_rx_slot()
254 i2s_ll_rx_set_half_sample_bit(hal->dev, 16); in i2s_hal_pdm_set_rx_slot()
255 i2s_ll_rx_enable_mono_mode(hal->dev, false); in i2s_hal_pdm_set_rx_slot()
263 i2s_ll_rx_set_active_chan_mask(hal->dev, slot_mask); in i2s_hal_pdm_set_rx_slot()
267 void i2s_hal_pdm_enable_rx_channel(i2s_hal_context_t *hal) in i2s_hal_pdm_enable_rx_channel() argument
269 i2s_ll_rx_enable_pdm(hal->dev); in i2s_hal_pdm_enable_rx_channel()
277 void i2s_hal_tdm_set_tx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_tdm_set_tx_slot() argument
288 i2s_ll_tx_reset(hal->dev); in i2s_hal_tdm_set_tx_slot()
289 i2s_ll_tx_set_slave_mod(hal->dev, is_slave); //TX Slave in i2s_hal_tdm_set_tx_slot()
290 i2s_ll_tx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_tdm_set_tx_slot()
291 i2s_ll_tx_enable_mono_mode(hal->dev, slot_cfg->slot_mode == I2S_SLOT_MODE_MONO); in i2s_hal_tdm_set_tx_slot()
292 i2s_ll_tx_enable_msb_shift(hal->dev, slot_cfg->tdm.bit_shift); in i2s_hal_tdm_set_tx_slot()
294 i2s_ll_tx_set_ws_width(hal->dev, (total_slot * slot_bit_width) / 2); in i2s_hal_tdm_set_tx_slot()
296 i2s_ll_tx_set_ws_width(hal->dev, slot_cfg->tdm.ws_width); in i2s_hal_tdm_set_tx_slot()
299 i2s_ll_tx_set_ws_idle_pol(hal->dev, slot_cfg->tdm.ws_pol); in i2s_hal_tdm_set_tx_slot()
300 i2s_ll_tx_set_chan_num(hal->dev, total_slot); in i2s_hal_tdm_set_tx_slot()
302 i2s_ll_tx_set_active_chan_mask(hal->dev, (slot_cfg->slot_mode == I2S_SLOT_MODE_MONO) ? in i2s_hal_tdm_set_tx_slot()
304 i2s_ll_tx_set_skip_mask(hal->dev, slot_cfg->tdm.skip_mask); in i2s_hal_tdm_set_tx_slot()
305 i2s_ll_tx_set_half_sample_bit(hal->dev, total_slot * slot_bit_width / 2); in i2s_hal_tdm_set_tx_slot()
306 i2s_ll_tx_set_bit_order(hal->dev, slot_cfg->tdm.bit_order_lsb); in i2s_hal_tdm_set_tx_slot()
307 i2s_ll_tx_enable_left_align(hal->dev, slot_cfg->tdm.left_align); in i2s_hal_tdm_set_tx_slot()
308 i2s_ll_tx_enable_big_endian(hal->dev, slot_cfg->tdm.big_endian); in i2s_hal_tdm_set_tx_slot()
311 void i2s_hal_tdm_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_hal_slot_config_t *sl… in i2s_hal_tdm_set_rx_slot() argument
322 i2s_ll_rx_reset(hal->dev); in i2s_hal_tdm_set_rx_slot()
323 i2s_ll_rx_set_slave_mod(hal->dev, is_slave); //RX Slave in i2s_hal_tdm_set_rx_slot()
324 i2s_ll_rx_set_sample_bit(hal->dev, slot_bit_width, slot_cfg->data_bit_width); in i2s_hal_tdm_set_rx_slot()
325 i2s_ll_rx_enable_mono_mode(hal->dev, slot_cfg->slot_mode == I2S_SLOT_MODE_MONO); in i2s_hal_tdm_set_rx_slot()
326 i2s_ll_rx_enable_msb_shift(hal->dev, slot_cfg->tdm.bit_shift); in i2s_hal_tdm_set_rx_slot()
328 i2s_ll_rx_set_ws_width(hal->dev, (total_slot * slot_bit_width) / 2); in i2s_hal_tdm_set_rx_slot()
330 i2s_ll_rx_set_ws_width(hal->dev, slot_cfg->tdm.ws_width); in i2s_hal_tdm_set_rx_slot()
333 i2s_ll_rx_set_ws_idle_pol(hal->dev, slot_cfg->tdm.ws_pol); in i2s_hal_tdm_set_rx_slot()
334 i2s_ll_rx_set_chan_num(hal->dev, total_slot); in i2s_hal_tdm_set_rx_slot()
336 i2s_ll_rx_set_active_chan_mask(hal->dev, (slot_cfg->slot_mode == I2S_SLOT_MODE_MONO) ? in i2s_hal_tdm_set_rx_slot()
338 i2s_ll_rx_set_half_sample_bit(hal->dev, total_slot * slot_bit_width / 2); in i2s_hal_tdm_set_rx_slot()
339 i2s_ll_rx_set_bit_order(hal->dev, slot_cfg->tdm.bit_order_lsb); in i2s_hal_tdm_set_rx_slot()
340 i2s_ll_rx_enable_left_align(hal->dev, slot_cfg->tdm.left_align); in i2s_hal_tdm_set_rx_slot()
341 i2s_ll_rx_enable_big_endian(hal->dev, slot_cfg->tdm.big_endian); in i2s_hal_tdm_set_rx_slot()
344 void i2s_hal_tdm_enable_tx_channel(i2s_hal_context_t *hal) in i2s_hal_tdm_enable_tx_channel() argument
346 i2s_ll_tx_enable_tdm(hal->dev); in i2s_hal_tdm_enable_tx_channel()
349 void i2s_hal_tdm_enable_rx_channel(i2s_hal_context_t *hal) in i2s_hal_tdm_enable_rx_channel() argument
351 i2s_ll_rx_enable_tdm(hal->dev); in i2s_hal_tdm_enable_rx_channel()