Although I don‘t get the whole picture of your application, but isn‘t the busy-polling of the i2s_free state the problem to solve ?
So why not just setting up and start the transfer of the display data and block on a task notification getting signaled by DMA ISR ? I’d propose to poll for the FIFO empty in the now unblocked task to keep the ISR as short as possible.
If the buffer a/b sending happens from different tasks you should use a mutex taken right before i2s_dma_trans_start_interrupt
to protect the DMA transfer and given back when done with the display access.
You could add a task handle variable used by the ISR to signal the notification where you simply store the handle of the current task with the mutex being held before starting the DMA.
The current task handle should be known or stored somewhere so you shouldn’t need to call xTaskGetCurrentTaskHandle
but that’s not important here.
Edit: I re-read your original post telling it’s a driver called from unknown application code. So you should take the mutexed approach and use xTaskGetCurrentTaskHandle
as you already planned.