Skip to content

Commit cee3935

Browse files
DP: implementation of Get Last Feeding time for a buffers
This commit introduces calculating of LFT for a module following description from zephyr_dp_scheduler.c The implementation is ready for DP to DP deadline calculations, however, the rest of the code is not. Therefore the DP to DP part has been deactivated with proper comment Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent a59171a commit cee3935

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

src/audio/buffers/audio_buffer.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include <rtos/panic.h>
1111
#include <rtos/alloc.h>
1212
#include <ipc/stream.h>
13+
#include <sof/audio/module_adapter/module/generic.h>
14+
#include <module/ipc4/base-config.h>
15+
#include <sof/audio/component.h>
16+
#include <module/module/base.h>
1317
#include <sof/audio/audio_buffer.h>
1418
#include <sof/audio/sink_api.h>
1519
#include <sof/audio/source_api.h>
@@ -182,12 +186,36 @@ int audio_buffer_source_set_alignment_constants(struct sof_source *source,
182186
return 0;
183187
}
184188

185-
/**
186-
* this is stub, always return Last Feeding Time - 0, meaning "NOW"
187-
*/
188189
uint32_t audio_buffer_sink_get_lft(struct sof_sink *sink)
189190
{
190-
return 0;
191+
struct sof_audio_buffer *buffer = sof_audio_buffer_from_sink(sink);
192+
/* get number of ms in the buffer */
193+
size_t bytes_per_sec = sink_get_frame_bytes(&buffer->_sink_api) *
194+
sink_get_rate(&buffer->_sink_api);
195+
size_t bytes_per_ms = bytes_per_sec / 1000;
196+
197+
/* round up for frequencies like 44100 */
198+
if (bytes_per_ms * 1000 != bytes_per_sec)
199+
bytes_per_ms++;
200+
uint32_t us_in_buffer =
201+
1000 * source_get_data_available(&buffer->_source_api) / bytes_per_ms;
202+
203+
return us_in_buffer;
204+
205+
/*
206+
* TODO, Currently there's no DP to DP connection
207+
* >>> the code below is never accessible and won't work because of cache incoherence <<<
208+
*
209+
* to make DP to DP connection possible:
210+
*
211+
* 1) module data must be ALWAYS located in non cached memory alias, allowing
212+
* cross core access to params like period (needed below) and calling
213+
* module_get_deadline for the next module, regardless of cores the modules are
214+
* running on
215+
* 2) comp_buffer must be removed from all pipeline code, replaced with a generic abstract
216+
* class audio_buffer - allowing using comp_buffer and ring_buffer without current
217+
* "hybrid buffer" solution
218+
*/
191219
}
192220

193221
void audio_buffer_init(struct sof_audio_buffer *buffer, uint32_t buffer_type, bool is_shared,

0 commit comments

Comments
 (0)