Linux debugging
Check our new training course
Linux debugging, tracing, profiling & perf. analysis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
/* * Copyright (c) 2019 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #define LOG_LEVEL LOG_LEVEL_INF #include <logging/log.h> LOG_MODULE_REGISTER(audio_core); #include <zephyr.h> #include "audio_core.h" /* * stereo mic in * stereo host in * stereo speaker out * stereo host out */ #define AUDIO_ACTIVE_CHANNELS 2 /* core audio processing buffers with interleaved samples */ static int32_t mic_input[AUDIO_ACTIVE_CHANNELS][AUDIO_SAMPLES_PER_FRAME]; static int32_t host_input[AUDIO_ACTIVE_CHANNELS][AUDIO_SAMPLES_PER_FRAME]; static bool tuning_reply_ready; static uint32_t *tuning_command_buffer; static uint32_t tuning_cmd_buf_size_in_words; #define CMD_START_AUDIO 1 #define CMD_STOP_AUDIO 2 int audio_core_initialize(void) { return 0; } int audio_core_process_mic_source(int32_t *buffer, int channels) { int sample; int channel; int32_t *read; read = buffer; /* copy audio samples from mic source buffer to mic_input */ for (sample = 0; sample < AUDIO_SAMPLES_PER_FRAME; sample++) { for (channel = 0; channel < AUDIO_ACTIVE_CHANNELS; channel++) { mic_input[channel][sample] = read[channel]; } read += channels; } return 0; } int audio_core_process_host_source(int32_t *buffer, int channels) { int sample; int channel; int32_t *read; read = buffer; /* copy audio samples from host source buffer to host_input */ for (sample = 0; sample < AUDIO_SAMPLES_PER_FRAME; sample++) { for (channel = 0; channel < AUDIO_ACTIVE_CHANNELS; channel++) { host_input[channel][sample] = read[channel]; } read += channels; } return 0; } int audio_core_process_speaker_sink(int32_t *buffer, int channels) { int sample; int channel; int32_t *write; write = buffer; /* copy audio samples from host_input to speaker sink buffer */ for (sample = 0; sample < AUDIO_SAMPLES_PER_FRAME; sample++) { for (channel = 0; channel < AUDIO_ACTIVE_CHANNELS; channel++) { write[channel] = host_input[channel][sample]; } write += channels; } return 0; } int audio_core_process_host_sink(int32_t *buffer, int channels) { int sample; int channel; int32_t *write; write = buffer; /* copy audio samples from mic_input to host sink buffer */ for (sample = 0; sample < AUDIO_SAMPLES_PER_FRAME; sample++) { for (channel = 0; channel < AUDIO_ACTIVE_CHANNELS; channel++) { write[channel] = mic_input[channel][sample]; } write += channels; } return 0; } int audio_core_notify_frame_tick(void) { return 0; } int audio_core_tuning_interface_init(uint32_t *command_buffer, uint32_t size_in_words) { tuning_command_buffer = command_buffer; tuning_cmd_buf_size_in_words = size_in_words; return 0; } int audio_core_notify_tuning_cmd(void) { uint32_t first_word = *((uint32_t *)tuning_command_buffer); uint32_t command = (first_word << 16) >> 16; switch (command) { case CMD_START_AUDIO: audio_driver_start(); break; case CMD_STOP_AUDIO: audio_driver_stop(); break; default: LOG_INF("Unknown command %d", command); } tuning_reply_ready = true; return 0; } bool audio_core_is_tuning_reply_ready(void) { if (tuning_reply_ready == true) { tuning_reply_ready = false; return true; } return false; } int audio_core_process_background_tasks(void) { return 0; } int audio_core_process_small_blocks(void) { return 0; } int audio_core_process_large_blocks(void) { return 0; }