1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef FEEDBACK_H_ 8 #define FEEDBACK_H_ 9 10 #include <stdint.h> 11 12 /* Nominal number of samples received on each SOF. This sample is currently 13 * supporting only 48 kHz sample rate. 14 */ 15 #define SAMPLES_PER_SOF 48 16 17 struct feedback_ctx *feedback_init(void); 18 void feedback_reset_ctx(struct feedback_ctx *ctx); 19 void feedback_process(struct feedback_ctx *ctx); 20 void feedback_start(struct feedback_ctx *ctx, int i2s_blocks_queued); 21 22 /* Return offset between I2S block start and USB SOF in samples. 23 * 24 * Positive offset means that I2S block started at least 1 sample after SOF and 25 * to correct the situation, shorter than nominal buffers are needed. 26 * 27 * Negative offset means that I2S block started at least 1 sample before SOF and 28 * to correct the situation, larger than nominal buffers are needed. 29 * 30 * Offset 0 means that I2S block started within 1 sample around SOF. This is the 31 * dominant value expected during normal operation. 32 */ 33 int feedback_samples_offset(struct feedback_ctx *ctx); 34 35 #endif /* FEEDBACK_H_ */ 36