7#ifndef _AUDIO_MODULE_H_
8#define _AUDIO_MODULE_H_
21#include <zephyr/kernel.h>
29#define AUDIO_MODULE_PARAMETERS(p, dest, stk, stk_size, pri, fifo_rx, fifo_tx, slab, slab_size) \
30 (p).description = (dest); \
31 (p).thread.stack = (stk); \
32 (p).thread.stack_size = (stk_size); \
33 (p).thread.priority = (pri); \
34 (p).thread.msg_rx = (fifo_rx); \
35 (p).thread.msg_tx = (fifo_tx); \
36 (p).thread.data_slab = (slab); \
37 (p).thread.data_size = (slab_size);
42#define AUDIO_MODULE_LOCATIONS_NUM (32)
94struct audio_module_handle_private;
99struct audio_module_context;
104struct audio_module_configuration;
130 int (*
open)(
struct audio_module_handle_private *handle,
131 struct audio_module_configuration const *
const configuration);
142 int (*
close)(
struct audio_module_handle_private *handle);
156 struct audio_module_configuration const *
const configuration);
169 struct audio_module_configuration *configuration);
180 int (*
start)(
struct audio_module_handle_private *handle);
191 int (*
stop)(
struct audio_module_handle_private *handle);
270 char name[CONFIG_AUDIO_MODULE_NAME_SIZE + 1];
336 struct audio_module_configuration
const *
const configuration,
337 char const *
const name,
struct audio_module_context *
context,
358 struct audio_module_configuration
const *
const configuration);
369 struct audio_module_configuration *configuration);
402 bool disconnect_external);
456 k_timeout_t timeout);
482 struct audio_data *audio_data_rx, k_timeout_t timeout);
495 char *instance_name);
Globally accessible audio related defines.
Data first-in first-out library header.
int audio_module_configuration_get(struct audio_module_handle const *const handle, struct audio_module_configuration *configuration)
Get the configuration of an audio module.
int audio_module_connect(struct audio_module_handle *handle_from, struct audio_module_handle *handle_to, bool connect_external)
Connect two audio modules together or connect to the module's TX FIFO.
int audio_module_state_get(struct audio_module_handle const *const handle, enum audio_module_state *state)
Helper to get the state of a given audio module handle.
int audio_module_number_channels_calculate(uint32_t locations, int8_t *number_channels)
Helper to calculate the number of channels from the channel map for the given audio data.
int audio_module_data_tx(struct audio_module_handle *handle, struct audio_data const *const audio_data, audio_module_response_cb response_cb)
Send an audio data item to an audio module, all data is consumed by the module.
int audio_module_names_get(struct audio_module_handle const *const handle, char **base_name, char *instance_name)
Helper to get the base and instance names for a given audio module handle.
int audio_module_close(struct audio_module_handle *handle)
Close an opened audio module.
int audio_module_disconnect(struct audio_module_handle *handle, struct audio_module_handle *handle_disconnect, bool disconnect_external)
Disconnect audio modules from each other or disconnect the module's TX FIFO. The function should be c...
int audio_module_data_tx_rx(struct audio_module_handle *handle_tx, struct audio_module_handle *handle_rx, struct audio_data const *const audio_data_tx, struct audio_data *audio_data_rx, k_timeout_t timeout)
Send an audio data to an audio module and retrieve an audio data from an audio module.
int audio_module_stop(struct audio_module_handle *handle)
Stop processing audio data in the audio module given by handle.
int audio_module_reconfigure(struct audio_module_handle *handle, struct audio_module_configuration const *const configuration)
Reconfigure an opened audio module.
int audio_module_start(struct audio_module_handle *handle)
Start processing audio data in the audio module given by handle.
int audio_module_open(struct audio_module_parameters const *const parameters, struct audio_module_configuration const *const configuration, char const *const name, struct audio_module_context *context, struct audio_module_handle *handle)
Open an audio module.
audio_module_type
Module type.
Definition: audio_module.h:47
@ AUDIO_MODULE_TYPE_IN_OUT
Definition: audio_module.h:71
@ AUDIO_MODULE_TYPE_INPUT
Definition: audio_module.h:56
@ AUDIO_MODULE_TYPE_UNDEFINED
Definition: audio_module.h:49
@ AUDIO_MODULE_TYPE_OUTPUT
Definition: audio_module.h:64
void(* audio_module_response_cb)(struct audio_module_handle_private *handle, struct audio_data const *const audio_data)
Callback function for a response to a data_send as supplied by the module user.
Definition: audio_module.h:113
int audio_module_data_rx(struct audio_module_handle *handle, struct audio_data *audio_data, k_timeout_t timeout)
Retrieve an audio data item from an audio module.
audio_module_state
Module state.
Definition: audio_module.h:77
@ AUDIO_MODULE_STATE_STOPPED
Definition: audio_module.h:88
@ AUDIO_MODULE_STATE_CONFIGURED
Definition: audio_module.h:82
@ AUDIO_MODULE_STATE_RUNNING
Definition: audio_module.h:85
@ AUDIO_MODULE_STATE_UNDEFINED
Definition: audio_module.h:79
A unit of audio.
Definition: audio_defines.h:90
enum audio_module_type type
Definition: audio_module.h:220
const struct audio_module_functions * functions
Definition: audio_module.h:223
char * name
Definition: audio_module.h:217
A module's minimum description.
Definition: audio_module.h:215
int(* configuration_get)(struct audio_module_handle_private const *const handle, struct audio_module_configuration *configuration)
Get the configuration of an audio module.
Definition: audio_module.h:168
int(* stop)(struct audio_module_handle_private *handle)
Stop an audio module.
Definition: audio_module.h:191
int(* start)(struct audio_module_handle_private *handle)
Start an audio module.
Definition: audio_module.h:180
int(* close)(struct audio_module_handle_private *handle)
Close an open audio module.
Definition: audio_module.h:142
int(* data_process)(struct audio_module_handle_private *handle, struct audio_data const *const audio_data_rx, struct audio_data *audio_data_tx)
The core data processing for an audio module. Can be either an input, output or input/output module t...
Definition: audio_module.h:207
int(* open)(struct audio_module_handle_private *handle, struct audio_module_configuration const *const configuration)
Open an audio module with the specified initial configuration.
Definition: audio_module.h:130
int(* configuration_set)(struct audio_module_handle_private *handle, struct audio_module_configuration const *const configuration)
Reconfigure an audio module after it has been opened with its initial configuration.
Definition: audio_module.h:155
Private pointer to a module's functions.
Definition: audio_module.h:119
struct k_mutex dest_mutex
Definition: audio_module.h:300
bool use_tx_queue
Definition: audio_module.h:285
struct k_thread thread_data
Definition: audio_module.h:282
enum audio_module_state state
Definition: audio_module.h:276
sys_snode_t node
Definition: audio_module.h:288
struct audio_module_context * context
Definition: audio_module.h:306
const struct audio_module_description * description
Definition: audio_module.h:273
struct k_sem sem
Definition: audio_module.h:297
k_tid_t thread_id
Definition: audio_module.h:279
struct audio_module_thread_configuration thread
Definition: audio_module.h:303
uint8_t dest_count
Definition: audio_module.h:294
char name[CONFIG_AUDIO_MODULE_NAME_SIZE+1]
Definition: audio_module.h:270
sys_slist_t handle_dest_list
Definition: audio_module.h:291
Private module handle.
Definition: audio_module.h:268
audio_module_response_cb response_cb
Definition: audio_module.h:320
struct audio_module_handle * tx_handle
Definition: audio_module.h:317
Private structure describing a data_in message into the module thread.
Definition: audio_module.h:312
struct audio_module_description * description
Definition: audio_module.h:259
struct audio_module_thread_configuration thread
Definition: audio_module.h:262
Module's generic set-up structure.
Definition: audio_module.h:257
size_t data_size
Definition: audio_module.h:251
struct data_fifo * msg_rx
Definition: audio_module.h:240
struct data_fifo * msg_tx
Definition: audio_module.h:243
k_thread_stack_t * stack
Definition: audio_module.h:231
int priority
Definition: audio_module.h:237
struct k_mem_slab * data_slab
Definition: audio_module.h:246
size_t stack_size
Definition: audio_module.h:234
Module's thread configuration structure.
Definition: audio_module.h:229
Definition: data_fifo.h:34