|
40 | 40 | #include <sof/audio/dai_copier.h> |
41 | 41 | #include <sof/audio/ipcgtw_copier.h> |
42 | 42 | #include <sof/audio/module_adapter/module/generic.h> |
| 43 | +#include <sof/schedule/ll_schedule_domain.h> |
43 | 44 |
|
44 | 45 | #if CONFIG_ZEPHYR_NATIVE_DRIVERS |
45 | 46 | #include <zephyr/drivers/dai.h> |
@@ -92,6 +93,41 @@ static int copier_init(struct processing_module *mod) |
92 | 93 | } |
93 | 94 |
|
94 | 95 | dev->pipeline = ipc_pipe->pipeline; |
| 96 | + /* Calculation of the period in which the component should be scheduled based on |
| 97 | + * the input buffer size. |
| 98 | + */ |
| 99 | + if (copier->gtw_cfg.dma_buffer_size > 0 && dev->pipeline->deep_buffering) { |
| 100 | + /* Size of the single frame in bytes. */ |
| 101 | + uint32_t frame_size = copier->base.audio_fmt.channels_count * |
| 102 | + (copier->base.audio_fmt.depth >> 3); |
| 103 | + /* Size of the one second of audio data in bytes. */ |
| 104 | + uint32_t one_s = frame_size * copier->base.audio_fmt.sampling_frequency; |
| 105 | + /* Size of the ten millisecond of audio data in bytes. */ |
| 106 | + uint32_t ten_ms = DIV_ROUND_UP(one_s, 100); |
| 107 | + /* The number of ten milliseconds chunks of data that will fit into the buffer. */ |
| 108 | + uint32_t chunk_count = copier->gtw_cfg.dma_buffer_size / ten_ms; |
| 109 | + |
| 110 | + /* If buffer can fit at more than ten milliseconds of data we can try to schedule |
| 111 | + * pipe on periods bigger than one millisecond. |
| 112 | + */ |
| 113 | + if (chunk_count) { |
| 114 | + dev->deep_buffering = true; |
| 115 | + if (chunk_count == 1) |
| 116 | + dev->period = (5 * LL_TIMER_PERIOD_US); |
| 117 | + else |
| 118 | + dev->period = (10 * LL_TIMER_PERIOD_US); |
| 119 | + |
| 120 | + /* If a component that may run on bigger periods has already been added to |
| 121 | + * the pipeline, the pipe must run at the lowest possible value. |
| 122 | + */ |
| 123 | + if (!dev->pipeline->period || dev->pipeline->period < dev->period) { |
| 124 | + dev->pipeline->period = dev->period; |
| 125 | + comp_cl_warn(&comp_copier, |
| 126 | + "changing the period for the pipe (new value %u)", |
| 127 | + dev->pipeline->period); |
| 128 | + } |
| 129 | + } |
| 130 | + } |
95 | 131 |
|
96 | 132 | node_id = copier->gtw_cfg.node_id; |
97 | 133 | /* copier is linked to gateway */ |
|
0 commit comments