|
Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
|
Abstraction for audio codecs. More...
Data Structures | |
| struct | pcm_config |
| PCM configuration options. More... | |
| union | audio_dai_cfg_t |
| Digital Audio Interface Configuration. More... | |
| struct | audio_codec_cfg |
| Codec configuration parameters. More... | |
| union | audio_property_value_t |
| Codec property values. More... | |
Macros | |
| #define | AUDIO_DAI_DIR_TX BIT(0) |
| Transmit data. | |
| #define | AUDIO_DAI_DIR_RX BIT(1) |
| Receive data. | |
| #define | AUDIO_DAI_DIR_TXRX (AUDIO_DAI_DIR_TX | AUDIO_DAI_DIR_RX) |
| Both receive and transmit data. | |
Typedefs | |
| typedef uint8_t | audio_dai_dir_t |
| DAI Direction Bitmap. | |
| typedef void(* | audio_codec_error_callback_t) (const struct device *dev, uint32_t errors) |
| Callback for error interrupt. | |
| typedef void(* | audio_codec_tx_done_callback_t) (const struct device *dev, void *user_data) |
| Callback for one frame(block memory) size data transmitted. | |
| typedef void(* | audio_codec_rx_done_callback_t) (const struct device *dev, uint8_t *buf, uint32_t len, void *user_data) |
| Callback for coming one frame size data. | |
Functions | |
| static int | audio_codec_configure (const struct device *dev, struct audio_codec_cfg *cfg) |
| Configure the audio codec. | |
| static void | audio_codec_start_output (const struct device *dev) |
| Set codec to start output audio playback. | |
| static void | audio_codec_stop_output (const struct device *dev) |
| Set codec to stop output audio playback. | |
| static int | audio_codec_set_property (const struct device *dev, audio_property_t property, audio_channel_t channel, audio_property_value_t val) |
| Set a codec property defined by audio_property_t. | |
| static int | audio_codec_apply_properties (const struct device *dev) |
| Atomically apply any cached properties. | |
| static int | audio_codec_clear_errors (const struct device *dev) |
| Clear any codec errors. | |
| static int | audio_codec_register_error_callback (const struct device *dev, audio_codec_error_callback_t cb) |
| Register a callback function for codec error. | |
| static int | audio_codec_route_input (const struct device *dev, audio_channel_t channel, uint32_t input) |
| Sets up signal routing for a given input channel. | |
| static int | audio_codec_route_output (const struct device *dev, audio_channel_t channel, uint32_t output) |
| Sets up signal routing for a given output channel. | |
| static int | audio_codec_start (const struct device *dev, audio_dai_dir_t dir) |
| Set codec to start audio playback or capture. | |
| static int | audio_codec_stop (const struct device *dev, audio_dai_dir_t dir) |
| Set codec to stop audio playback or capture. | |
| static int | audio_codec_write (const struct device *dev, uint8_t *data, size_t data_size) |
| write one block size data for audio playback. | |
| static int | audio_codec_register_done_callback (const struct device *dev, audio_codec_tx_done_callback_t tx_cb, void *tx_cb_user_data, audio_codec_rx_done_callback_t rx_cb, void *rx_cb_user_data) |
| Register a callback function for codec one frame data tx/rx done. | |
Abstraction for audio codecs.
| #define AUDIO_DAI_DIR_RX BIT(1) |
#include <zephyr/audio/codec.h>
Receive data.
| #define AUDIO_DAI_DIR_TX BIT(0) |
#include <zephyr/audio/codec.h>
Transmit data.
| #define AUDIO_DAI_DIR_TXRX (AUDIO_DAI_DIR_TX | AUDIO_DAI_DIR_RX) |
#include <zephyr/audio/codec.h>
Both receive and transmit data.
#include <zephyr/audio/codec.h>
Callback for error interrupt.
| dev | Pointer to the codec device |
| errors | Device errors (bitmask of audio_codec_error_type values) |
| typedef void(* audio_codec_rx_done_callback_t) (const struct device *dev, uint8_t *buf, uint32_t len, void *user_data) |
#include <zephyr/audio/codec.h>
Callback for coming one frame size data.
| dev | Pointer to the codec device |
| buf | Pointer to received data |
| len | received data size in bytes |
| user_data | Pointer to user data |
| typedef void(* audio_codec_tx_done_callback_t) (const struct device *dev, void *user_data) |
#include <zephyr/audio/codec.h>
Callback for one frame(block memory) size data transmitted.
| dev | Pointer to the codec device |
| user_data | Pointer to user data |
| typedef uint8_t audio_dai_dir_t |
#include <zephyr/audio/codec.h>
DAI Direction Bitmap.
| enum audio_channel_t |
#include <zephyr/audio/codec.h>
Audio channel identifiers to use in audio_codec_set_property().
#include <zephyr/audio/codec.h>
Codec error type.
| enum audio_dai_type_t |
#include <zephyr/audio/codec.h>
Digital Audio Interface (DAI) type.
| enum audio_pcm_rate_t |
#include <zephyr/audio/codec.h>
PCM audio sample rates.
| enum audio_pcm_width_t |
#include <zephyr/audio/codec.h>
PCM audio sample bit widths.
| Enumerator | |
|---|---|
| AUDIO_PCM_WIDTH_16_BITS | 16-bit sample width |
| AUDIO_PCM_WIDTH_20_BITS | 20-bit sample width |
| AUDIO_PCM_WIDTH_24_BITS | 24-bit sample width |
| AUDIO_PCM_WIDTH_32_BITS | 32-bit sample width |
| enum audio_property_t |
#include <zephyr/audio/codec.h>
Codec properties that can be set by audio_codec_set_property().
| Enumerator | |
|---|---|
| AUDIO_PROPERTY_OUTPUT_VOLUME | Output volume. |
| AUDIO_PROPERTY_OUTPUT_MUTE | Output mute/unmute. |
| AUDIO_PROPERTY_INPUT_VOLUME | Input volume. |
| AUDIO_PROPERTY_INPUT_MUTE | Input mute/unmute. |
| enum audio_route_t |
#include <zephyr/audio/codec.h>
| Enumerator | |
|---|---|
| AUDIO_ROUTE_BYPASS | |
| AUDIO_ROUTE_PLAYBACK | |
| AUDIO_ROUTE_PLAYBACK_CAPTURE | |
| AUDIO_ROUTE_CAPTURE | |
|
inlinestatic |
#include <zephyr/audio/codec.h>
Atomically apply any cached properties.
Following one or more invocations of audio_codec_set_property, that may have been cached by the driver, audio_codec_apply_properties can be invoked to apply all the properties as atomic as possible
| dev | Pointer to the device structure for codec driver instance. |
|
inlinestatic |
#include <zephyr/audio/codec.h>
Clear any codec errors.
Clear all codec errors. If an error interrupt exists, it will be de-asserted.
| dev | Pointer to the device structure for codec driver instance. |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Configure the audio codec.
Configure the audio codec device according to the configuration parameters provided as input
| dev | Pointer to the device structure for codec driver instance. |
| cfg | Pointer to the structure containing the codec configuration. |
|
inlinestatic |
#include <zephyr/audio/codec.h>
Register a callback function for codec one frame data tx/rx done.
The callback will be called from a DMA ISR (interrupt) context. Callbacks must therefore:
| dev | Pointer to the audio codec device |
| tx_cb | The function that should be called when an DMA frame transmitted |
| tx_cb_user_data | The user data that will be passed to tx_cb |
| rx_cb | The function that should be called when an DMA frame received |
| rx_cb_user_data | The user data that will be passed to rx_cb |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Register a callback function for codec error.
The callback will be called from a thread, so I2C or SPI operations are safe. However, the thread's stack is limited and defined by the driver. It is currently up to the caller to ensure that the callback does not overflow the stack.
| dev | Pointer to the audio codec device |
| cb | The function that should be called when an error is detected fires |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Sets up signal routing for a given input channel.
Some codecs can do input routing (multiplexing) from a chosen set of physical inputs. This function maps a given audio (stream) channel to a given physical input terminal.
| dev | Pointer to the audio codec device |
| channel | The channel to map |
| input | The input terminal index, codec-specific |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Sets up signal routing for a given output channel.
Some codecs can do output routing (multiplexing) from a chosen set of physical output. This function maps a given audio (stream) channel to a given physical output terminal.
| dev | Pointer to the audio codec device |
| channel | The channel to map |
| output | The output terminal index, codec-specific |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Set a codec property defined by audio_property_t.
Set a property such as volume level, clock configuration etc.
| dev | Pointer to the device structure for codec driver instance. |
| property | The codec property to set |
| channel | The audio channel for which the property has to be set |
| val | pointer to a property value of type audio_codec_property_value_t |
|
inlinestatic |
#include <zephyr/audio/codec.h>
Set codec to start audio playback or capture.
Setup the audio codec device to start the audio playback or capture
| dev | Pointer to the device structure for codec driver instance. |
| dir | device audio playback and capture selection. |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Set codec to start output audio playback.
Setup the audio codec device to start the audio playback
| dev | Pointer to the device structure for codec driver instance. |
|
inlinestatic |
#include <zephyr/audio/codec.h>
Set codec to stop audio playback or capture.
Setup the audio codec device to stop the audio playback or capture.
| dev | Pointer to the device structure for codec driver instance. |
| dir | device audio playback and capture selection. |
< Function not implemented
|
inlinestatic |
#include <zephyr/audio/codec.h>
Set codec to stop output audio playback.
Setup the audio codec device to stop the audio playback
| dev | Pointer to the device structure for codec driver instance. |
#include <zephyr/audio/codec.h>
write one block size data for audio playback.
Write audio data to the device for audio playback without waiting for the data to be transmitted. This is a non-blocking API: the function returns as soon as the driver has accepted (or rejected) the buffer, not when the audio data has actually been played out.
| dev | Pointer to the device structure for codec driver instance. |
| data | Pointer to data. |
| data_size | data size in bytes. |
< Function not implemented