TDM source

This component implements a TDM source that can run on GAP9. Input TDM stream is recevied on one of GAP9 SAI blocks and outputted as a memory block that contains interleaved channel data. The component doesn’t control external devices, only GAP9.

Interface

The component doesn’t have a software input interface, as the data is received from the SAI hardware via pi_i2s driver.

There is one output software interface (push) which outputs buffer containing configured number of interleaved audio samples of all active channels.

Parameters

Memory sizing (construct-time) parameters are contained in gap9_fc_tdm_source_static_parameters.

Runtime parameters are contained in gap9_fc_tdm_source_configuration.

For detailed parameter description please see API reference.

Implementations

Only one imlementation is availabe: GAP9 FC.

Tests

gaptest.yml contains test set for this component.

API reference

group gap9_fc_tdm_source

gap9_fc_tdm_source component

Date

10-08-2024

Author

vladimir

Defines

COMPANY_ID
DEVELOPER_ID
TDM_SOURCE_ID
GAP9_FC_TDM_SOURCE_ID
GAP9_FC_TDM_SOURCE_LOG_TAG
GAP9_FC_TDM_SOURCE_LOG_TRC(fmt, ...)
GAP9_FC_TDM_SOURCE_LOG_INF(fmt, ...)
GAP9_FC_TDM_SOURCE_LOG_DBG(fmt, ...)
GAP9_FC_TDM_SOURCE_LOG_ERR(fmt, ...)
GAP9_FC_TDM_SOURCE_LOG_WNG(fmt, ...)
GAP9_FC_TDM_SOURCE_NUM_CHANNELS_DEFAULT

Default maximum number of slots in TDM frame. Number of slots can be changed at runtime by set_parameters(), but must not exceed this value.

GAP9_FC_TDM_SOURCE_NUM_CHANNELS_MAX

Maximum maximum number of slots in TDM frame.

GAP9_FC_TDM_SOURCE__CFG_TYPE__CORE

Configuration type idenfifier: core (non-channel) parameters.

GAP9_FC_TDM_SOURCE__CFG_TYPE__CH

Configuration type idenfifier: single channel.

GAP9_FC_TDM_SOURCE__CFG_TYPE__CH_MASK

Configuration type idenfifier: multiple channels (bit mask)

Typedefs

typedef struct component_gap9_fc_tdm_source component_gap9_fc_tdm_source

gap9_fc_tdm_source component (specific part)

typedef struct gap9_fc_tdm_source_static_parameters gap9_fc_tdm_source_static_parameters

Static (construc-time) parameters. Must not change during instance’s lifetime.

typedef enum gap9_sai_clock_source_e gap9_sai_clock_source_e
typedef enum gap9_sai_ws_source_e gap9_sai_ws_source_e
typedef enum gap9_sai_clock_polarity_e gap9_sai_clock_polarity_e
typedef enum gap9_sai_ws_polarity_e gap9_sai_ws_polarity_e
typedef struct gap9_fc_tdm_source_cfg_core gap9_fc_tdm_source_cfg_core

Core (non-channel) configuration of the SAI interface. See i2s driver for more details.

typedef enum gap9_sai_ch_format_bit_order_e gap9_sai_ch_format_bit_order_e
typedef enum gap9_sai_ch_format_alignment_e gap9_sai_ch_format_alignment_e
typedef enum gap9_sai_ch_format_sign_extension_e gap9_sai_ch_format_sign_extension_e
typedef struct gap9_fc_tdm_source_cfg_ch gap9_fc_tdm_source_cfg_ch

Channel configuration structure.

typedef struct gap9_fc_tdm_source_configuration gap9_fc_tdm_source_configuration

Configuration structure used with set_parameter() method.

Enums

enum gap9_sai_clock_source_e

Options for SAI interface clock source.

Values:

enumerator GAP9_SAI__CLK_SRC__INT_FLL = 0
enumerator GAP9_SAI__CLK_SRC__INT_REF_CLK_FAST = 1
enumerator GAP9_SAI__CLK_SRC__EXT = 2
enumerator GAP9_SAI__CLK_SRC__FROM_SAI0 = 3
enum gap9_sai_ws_source_e

Options for SAI WS (word strobe, i.e. TDM frame pulse) source.

Values:

enumerator GAP9_SAI__WS_SRC__INT = 0
enumerator GAP9_SAI__WS_SRC__EXT = 1
enumerator GAP9_SAI__WS_SRC__FROM_SAI0 = 2
enum gap9_sai_clock_polarity_e

Options for SAI clock polarity. Polarity here is the clock edge on which input TDM data is sampled.

Values:

enumerator GAP9_SAI__CLK_POL__RISING = 0
enumerator GAP9_SAI__CLK_POL__FALLING = 1
enum gap9_sai_ws_polarity_e

Options for SAI WS polarity. Polarity here is the level of the WS pulse. During rest of the TDM frame duration the level is the opposite of this.

Values:

enumerator GAP9_SAI__WS_POL__ACTIVE_LOW = 0
enumerator GAP9_SAI__WS_POL__ACTIVE_HIGH = 1
enum gap9_sai_ch_format_bit_order_e

Bit order (time of arrival) of data word in slot of the TDM signal.

Values:

enumerator GAP9_SAI__CH_FMT_BIT_ORDER__MSB = 0
enumerator GAP9_SAI__CH_FMT_BIT_ORDER__LSB = 1
enum gap9_sai_ch_format_alignment_e

Alignment of the data word within the TDM slot.

Values:

enumerator GAP9_SAI__CH_FMT_ALIGNMENT__LEFT = 0
enumerator GAP9_SAI__CH_FMT_ALIGNMENT__RIGHT = 1
enum gap9_sai_ch_format_sign_extension_e

Whether to pad data word (of size word_size) extracted from the signal with the sign bit up to the mem_word_size before storing it in memory.

Values:

enumerator GAP9_SAI__CH_FMT_SIGN_EXTENSION__NO = 0
enumerator GAP9_SAI__CH_FMT_SIGN_EXTENSION__YES = 1

Functions

void gap9_fc_tdm_source_cfg_core_init(gap9_fc_tdm_source_cfg_core *cfg)

Initializer for gap9_fc_tdm_source_cfg_core.

void gap9_fc_tdm_source_cfg_ch_init(gap9_fc_tdm_source_cfg_ch *cfg)

Initializer for gap9_fc_tdm_source_cfg_ch.

Variables

component gap9_fc_tdm_source
struct gap9_fc_tdm_source_static_parameters
#include <gap9_fc_tdm_source.h>

Static (construc-time) parameters. Must not change during instance’s lifetime.

Public Members

uint8_t nb_channels_max

Maximum number of channels (TDM slots) during instance’s lifetime.

uint32_t buffer_size_max

Maximum ping-pong buffer size (in bytes) during instance’s lifetime.

struct gap9_fc_tdm_source_cfg_core
#include <gap9_fc_tdm_source.h>

Core (non-channel) configuration of the SAI interface. See i2s driver for more details.

Public Members

uint8_t sai_id

SAI id (0, 1, 2)

uint32_t frame_freq

Frame (WS) frequency in Hz

uint8_t nb_slots

Total number of slots in the frame

uint8_t slot_width

TDM slot width (in bits)

uint32_t enable

Enable (open) or disable (close)

uint32_t clock_source

gap9_sai_clock_source_e

uint32_t ws_source

gap9_sai_ws_source_e

uint32_t clock_polarity

gap9_sai_clock_polarity_e

uint32_t ws_polarity

gap9_sai_ws_polarity_e

uint8_t ws_delay

Number of TDM clock interfals between front edge of the WS pulse to the first bit of the TDM frame.

struct gap9_fc_tdm_source_cfg_ch
#include <gap9_fc_tdm_source.h>

Channel configuration structure.

Public Members

uint8_t enable

Whether the channel is enabled

int8_t slot_id

Slot index (internal usage only)

uint8_t word_size

Data word size (in bits) within pysical TDM slot

uint8_t mem_word_size

Data word size (in bits) for transfers to/from L2 memory

uint8_t out_word_size

Data word size (in bytes) for the output (push)

int32_t block_size

Size (in bytes) of the uDMA transfer chunk

uint32_t bit_order

See gap9_sai_ch_format_bit_order_e

uint32_t alignment

See gap9_sai_ch_format_alignment_e

uint32_t sign_extension

See gap9_sai_ch_format_sign_extension_e

struct gap9_fc_tdm_source_configuration
#include <gap9_fc_tdm_source.h>

Configuration structure used with set_parameter() method.

Public Members

uint8_t cfg_type

Configuration item type If cfg_type == CORE: N/A If cfg_type == CH: Slot index If cfg_type == CH_MASK: Slot bit mask

gap9_fc_tdm_source_cfg_core core

If cfg_type == CORE

gap9_fc_tdm_source_cfg_ch ch

If cfg_type == CH or CH_MASK

struct component_gap9_fc_tdm_source
#include <gap9_fc_tdm_source.h>

gap9_fc_tdm_source component (specific part)