Skip to content

Commit c475820

Browse files
gl-agnxL-KAYA
authored andcommitted
change(esp32): undo forcing two slots in I2S
fix(i2s): fixed the issue in PR 14879 Closes espressif#14879 [Kevin: Update to only remove the limitation for PCM short format]
1 parent 75fb8bb commit c475820

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

components/esp_driver_i2s/i2s_tdm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ static esp_err_t i2s_tdm_set_slot(i2s_chan_handle_t handle, const i2s_tdm_slot_c
105105
handle->active_slot = slot_cfg->slot_mode == I2S_SLOT_MODE_MONO ? 1 : __builtin_popcount(slot_cfg->slot_mask);
106106
uint32_t max_slot_num = 32 - __builtin_clz(slot_cfg->slot_mask);
107107
handle->total_slot = slot_cfg->total_slot < max_slot_num ? max_slot_num : slot_cfg->total_slot;
108-
handle->total_slot = handle->total_slot < 2 ? 2 : handle->total_slot; // At least two slots in a frame
109-
108+
// At least two slots in a frame if not using PCM short format
109+
handle->total_slot = ((handle->total_slot < 2) && (slot_cfg->ws_width != 1)) ? 2 : handle->total_slot;
110110
uint32_t buf_size = i2s_get_buf_size(handle, slot_cfg->data_bit_width, handle->dma.frame_num);
111111
/* The DMA buffer need to re-allocate if the buffer size changed */
112112
if (handle->dma.buf_size != buf_size) {

components/hal/i2s_hal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ void i2s_hal_tdm_set_tx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_ha
318318
uint32_t msk = slot_cfg->tdm.slot_mask;
319319
/* Get the maximum slot number */
320320
cnt = 32 - __builtin_clz(msk);
321-
/* There should be at least 2 slots in total even for mono mode */
322-
cnt = cnt < 2 ? 2 : cnt;
321+
/* Except PCM short format (ws_width = 1), there should be at least 2 slots in total even for mono mode */
322+
cnt = ((cnt < 2) && (slot_cfg->tdm.ws_width != 1)) ? 2 : cnt;
323323
uint32_t total_slot = slot_cfg->tdm.total_slot > cnt ? slot_cfg->tdm.total_slot : cnt;
324324
i2s_ll_tx_reset(hal->dev);
325325
i2s_ll_tx_set_slave_mod(hal->dev, is_slave); //TX Slave
@@ -352,8 +352,8 @@ void i2s_hal_tdm_set_rx_slot(i2s_hal_context_t *hal, bool is_slave, const i2s_ha
352352
uint32_t msk = slot_cfg->tdm.slot_mask;
353353
/* Get the maximum slot number */
354354
cnt = 32 - __builtin_clz(msk);
355-
/* There should be at least 2 slots in total even for mono mode */
356-
cnt = cnt < 2 ? 2 : cnt;
355+
/* Except PCM short format (ws_width = 1), there should be at least 2 slots in total even for mono mode */
356+
cnt = ((cnt < 2) && (slot_cfg->tdm.ws_width != 1)) ? 2 : cnt;
357357
uint32_t total_slot = slot_cfg->tdm.total_slot > cnt ? slot_cfg->tdm.total_slot : cnt;
358358
i2s_ll_rx_reset(hal->dev);
359359
i2s_ll_rx_set_slave_mod(hal->dev, is_slave); //RX Slave

0 commit comments

Comments
 (0)