|
Sound Open Firmware
|
Data Structures | |
| struct | audio_stream |
| Audio stream is a circular buffer aware of audio format of the data in the buffer so provides API for reading and writing not only bytes, but also samples and frames. More... | |
| struct | cir_buf_ptr |
Macros | |
| #define | audio_stream_read_frag(buffer, idx, size) |
| Retrieves readable address of a sample at specified index (see versions of this macro specialized for various sample types). | |
| #define | audio_stream_read_frag_s16(buffer, idx) |
| Retrieves readable address of a signed 16-bit sample at specified index. | |
| #define | audio_stream_read_frag_s32(buffer, idx) |
| Retrieves readable address of a signed 32-bit sample at specified index. | |
| #define | audio_stream_write_frag(buffer, idx, size) |
| Retrieves writeable address of a sample at specified index (see versions of this macro specialized for various sample types). | |
| #define | audio_stream_write_frag_s16(buffer, idx) |
| Retrieves writeable address of a signed 16-bit sample at specified index. | |
| #define | audio_stream_write_frag_s32(buffer, idx) |
| Retrieves writeable address of a signed 32-bit sample at specified index. | |
| #define | audio_stream_get_frag(buffer, ptr, idx, sample_size) |
| Retrieves address of sample (space for sample) at specified index within the buffer. | |
Functions | |
| void | audio_stream_recalc_align (struct audio_stream *stream) |
| static void * | audio_stream_get_rptr (const struct audio_stream *buf) |
| static void * | audio_stream_get_wptr (const struct audio_stream *buf) |
| static void * | audio_stream_get_end_addr (const struct audio_stream *buf) |
| static void * | audio_stream_get_addr (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_size (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_avail (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_free (const struct audio_stream *buf) |
| static enum sof_ipc_frame | audio_stream_get_frm_fmt (const struct audio_stream *buf) |
| static enum sof_ipc_frame | audio_stream_get_valid_fmt (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_rate (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_channels (const struct audio_stream *buf) |
| static bool | audio_stream_get_underrun (const struct audio_stream *buf) |
| static uint32_t | audio_stream_get_buffer_fmt (const struct audio_stream *buf) |
| static bool | audio_stream_get_overrun (const struct audio_stream *buf) |
| static void | audio_stream_set_rptr (struct audio_stream *buf, void *val) |
| static void | audio_stream_set_wptr (struct audio_stream *buf, void *val) |
| static void | audio_stream_set_end_addr (struct audio_stream *buf, void *val) |
| static void | audio_stream_set_addr (struct audio_stream *buf, void *val) |
| static void | audio_stream_set_size (struct audio_stream *buf, uint32_t val) |
| static void | audio_stream_set_avail (struct audio_stream *buf, uint32_t val) |
| static void | audio_stream_set_free (struct audio_stream *buf, uint32_t val) |
| static void | audio_stream_set_frm_fmt (struct audio_stream *buf, enum sof_ipc_frame val) |
| static void | audio_stream_set_valid_fmt (struct audio_stream *buf, enum sof_ipc_frame val) |
| static void | audio_stream_set_rate (struct audio_stream *buf, uint32_t val) |
| static void | audio_stream_set_channels (struct audio_stream *buf, uint16_t val) |
| static void | audio_stream_set_underrun (struct audio_stream *buf, bool underrun_permitted) |
| static void | audio_stream_set_overrun (struct audio_stream *buf, bool overrun_permitted) |
| static void | audio_stream_set_buffer_fmt (struct audio_stream *buf, uint32_t buffer_fmt) |
| static uint32_t | audio_stream_frame_bytes (const struct audio_stream *buf) |
| Calculates period size in bytes based on component stream's parameters. | |
| static uint32_t | audio_stream_sample_bytes (const struct audio_stream *buf) |
| Calculates sample size in bytes based on component stream's parameters. | |
| void | audio_stream_set_align (const uint32_t byte_align, const uint32_t frame_align_req, struct audio_stream *stream) |
| Set processing alignment requirements. | |
| static int | audio_stream_set_params (struct audio_stream *buffer, struct sof_ipc_stream_params *params) |
| Applies parameters to the buffer. | |
| static uint32_t | audio_stream_period_bytes (const struct audio_stream *buf, uint32_t frames) |
| Calculates period size in bytes based on component stream's parameters. | |
| static void * | audio_stream_wrap (const struct audio_stream *buffer, void *ptr) |
| Verifies the pointer and performs rollover when reached the end of the buffer. | |
| static void * | audio_stream_rewind_wrap (const struct audio_stream *buffer, void *ptr) |
| Verifies the pointer and performs rollover when reached the end of the buffer. | |
| static uint32_t | audio_stream_get_avail_bytes (const struct audio_stream *stream) |
| Calculates available data in bytes, handling underrun_permitted behaviour. | |
| static uint32_t | audio_stream_get_avail_samples (const struct audio_stream *stream) |
| Calculates available data in samples, handling underrun_permitted behaviour. | |
| static uint32_t | audio_stream_get_avail_frames (const struct audio_stream *stream) |
| Calculates available data in frames, handling underrun_permitted behaviour. | |
| static uint32_t | audio_stream_get_free_bytes (const struct audio_stream *stream) |
| Calculates free space in bytes, handling overrun_permitted behaviour. | |
| static uint32_t | audio_stream_get_free_samples (const struct audio_stream *stream) |
| Calculates free space in samples, handling overrun_permitted behaviour. | |
| static uint32_t | audio_stream_get_free_frames (const struct audio_stream *stream) |
| Calculates free space in frames, handling overrun_permitted behaviour. | |
| static int | audio_stream_can_copy_bytes (const struct audio_stream *source, const struct audio_stream *sink, uint32_t bytes) |
| Verifies whether specified number of bytes can be copied from source buffer to sink buffer. | |
| static uint32_t | audio_stream_get_copy_bytes (const struct audio_stream *source, const struct audio_stream *sink) |
| Computes maximum number of bytes that can be copied from source buffer to sink buffer, verifying number of bytes available in source vs. | |
| static uint32_t | audio_stream_avail_frames (const struct audio_stream *source, const struct audio_stream *sink) |
| Computes maximum number of frames that can be copied from source buffer to sink buffer, verifying number of available source frames vs. | |
| static uint32_t | audio_stream_align_frames_round_down (const struct audio_stream *stream, uint32_t frames) |
| Rounds down a frame count to meet the alignment constraint of the stream. | |
| static uint32_t | audio_stream_align_frames_round_up (const struct audio_stream *stream, uint32_t frames) |
| Rounds up a frame count to meet the alignment constraint of the stream. | |
| static uint32_t | audio_stream_align_frames_round_nearest (const struct audio_stream *stream, uint32_t frames) |
| Rounds to nearest a frame count to meet the alignment constraint of the stream. | |
| static uint32_t | audio_stream_avail_frames_aligned (const struct audio_stream *source, const struct audio_stream *sink) |
| Computes maximum number of frames aligned with source align criteria that can be copied from source buffer to sink buffer, verifying number of available source frames vs. | |
| static void | audio_stream_produce (struct audio_stream *buffer, uint32_t bytes) |
| Updates the buffer state after writing to the buffer. | |
| static void | audio_stream_consume (struct audio_stream *buffer, uint32_t bytes) |
| Updates the buffer state after reading from the buffer. | |
| static void | audio_stream_reset (struct audio_stream *buffer) |
| Resets the buffer. | |
| void | audio_stream_init (struct audio_stream *audio_stream, void *buff_addr, uint32_t size) |
| Initializes the buffer with specified memory block and size. | |
| static void | audio_stream_invalidate (struct audio_stream *buffer, uint32_t bytes) |
| Invalidates (in DSP d-cache) the buffer in range [r_ptr, r_ptr+bytes], with rollover if necessary. | |
| static void | audio_stream_writeback (struct audio_stream *buffer, uint32_t bytes) |
| Writes back (from DSP d-cache) the buffer in range [w_ptr, w_ptr+bytes], with rollover if necessary. | |
| static int | audio_stream_bytes_without_wrap (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of bytes to buffer wrap. | |
| static int | audio_stream_rewind_bytes_without_wrap (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of bytes to buffer wrap when reading stream backwards from current sample pointed by ptr towards begin. | |
| static uint32_t * | audio_stream_rewind_wptr_by_bytes (const struct audio_stream *source, const uint32_t bytes) |
| Calculate position of write pointer to the position before the data was copied to source buffer. | |
| static int | audio_stream_samples_without_wrap_s16 (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of s16 samples to buffer wrap when buffer is read forward towards end address. | |
| static int | audio_stream_samples_without_wrap_s24 (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of s24 samples to buffer wrap when buffer is read forward towards end address. | |
| static int | audio_stream_samples_without_wrap_s32 (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of s32 samples to buffer wrap when buffer is read forward towards end address. | |
| static int | cir_buf_bytes_without_wrap (const void *ptr, const void *buf_end) |
| Calculates numbers of bytes to buffer wrap when reading stream backwards from current sample pointed by ptr towards begin. | |
| static uint32_t | audio_stream_frames_without_wrap (const struct audio_stream *source, const void *ptr) |
| Calculates numbers of frames to buffer wrap and return minimum of calculated value. | |
| int | audio_stream_copy (const struct audio_stream *source, uint32_t ioffset, struct audio_stream *sink, uint32_t ooffset, uint32_t samples) |
| Copies data from source buffer to sink buffer. | |
| void | cir_buf_copy (const void *src, const void *src_addr, const void *src_end, void *dst, void *dst_addr, void *dst_end, size_t byte_size) |
| Copies data from one circular buffer to another circular buffer. | |
| void | audio_stream_copy_from_linear (const void *linear_source, int ioffset, struct audio_stream *sink, int ooffset, unsigned int samples) |
| Copies data from linear source buffer to circular sink buffer. | |
| void | audio_stream_copy_to_linear (const struct audio_stream *source, int ioffset, void *linear_sink, int ooffset, unsigned int samples) |
| Copies data from circular source buffer to linear sink buffer. | |
| static int | audio_stream_set_zero (struct audio_stream *buffer, uint32_t bytes) |
| Writes zeros in range [w_ptr, w_ptr+bytes], with rollover if necessary. | |
| static void | cir_buf_set_zero (void *ptr, void *buf_addr, void *buf_end, uint32_t bytes) |
| Writes zeros to circular buffer in range [ptr, ptr+bytes] with rollover if necessary. | |
| static int | audio_stream_fmt_conversion (enum ipc4_bit_depth depth, enum ipc4_bit_depth valid, enum sof_ipc_frame *frame_fmt, enum sof_ipc_frame *valid_fmt, enum ipc4_sample_type type) |
| #define audio_stream_get_frag | ( | buffer, | |
| ptr, | |||
| idx, | |||
| sample_size ) |
Retrieves address of sample (space for sample) at specified index within the buffer.
Index is interpreted as an offset relative to the specified pointer, rollover is ensured.
| buffer | Circular buffer. |
| ptr | Pointer to start from, it may be either read or write pointer. |
| idx | Index of the sample. |
| sample_size | Size of the sample in bytes. |
| #define audio_stream_read_frag | ( | buffer, | |
| idx, | |||
| size ) |
Retrieves readable address of a sample at specified index (see versions of this macro specialized for various sample types).
| buffer | Buffer. |
| idx | Index of sample. |
| size | Size of sample in bytes. |
Once the consumer finishes reading samples from the buffer, it should "commit" the operation and update the buffer state by calling audio_stream_consume().
| #define audio_stream_read_frag_s16 | ( | buffer, | |
| idx ) |
Retrieves readable address of a signed 16-bit sample at specified index.
| buffer | Buffer. |
| idx | Index of sample. |
| #define audio_stream_read_frag_s32 | ( | buffer, | |
| idx ) |
Retrieves readable address of a signed 32-bit sample at specified index.
| buffer | Buffer. |
| idx | Index of sample. |
| #define audio_stream_write_frag | ( | buffer, | |
| idx, | |||
| size ) |
Retrieves writeable address of a sample at specified index (see versions of this macro specialized for various sample types).
| buffer | Buffer. |
| idx | Index of sample. |
| size | Size of sample in bytes. |
Once the producer finishes writing samples to the buffer, it should "commit" the operation and update the buffer state by calling audio_stream_produce().
| #define audio_stream_write_frag_s16 | ( | buffer, | |
| idx ) |
Retrieves writeable address of a signed 16-bit sample at specified index.
| buffer | Buffer. |
| idx | Index of sample. |
| #define audio_stream_write_frag_s32 | ( | buffer, | |
| idx ) |
Retrieves writeable address of a signed 32-bit sample at specified index.
| buffer | Buffer. |
| idx | Index of sample. |
|
inlinestatic |
Rounds down a frame count to meet the alignment constraint of the stream.
| stream | Audio stream with alignment requirements set. |
| frames | Frame count to round down. |
|
inlinestatic |
Rounds to nearest a frame count to meet the alignment constraint of the stream.
| stream | Audio stream with alignment requirements set. |
| frames | Frame count to round to nearest. |
|
inlinestatic |
Rounds up a frame count to meet the alignment constraint of the stream.
| stream | Audio stream with alignment requirements set. |
| frames | Frame count to round up. |
|
inlinestatic |
Computes maximum number of frames that can be copied from source buffer to sink buffer, verifying number of available source frames vs.
free space available in sink.
| source | Source buffer. |
| sink | Sink buffer. |
|
inlinestatic |
Computes maximum number of frames aligned with source align criteria that can be copied from source buffer to sink buffer, verifying number of available source frames vs.
free space available in sink.
| source | Buffer of source. |
| sink | Buffer of sink. |
|
inlinestatic |
Calculates numbers of bytes to buffer wrap.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
Verifies whether specified number of bytes can be copied from source buffer to sink buffer.
| source | Source buffer. |
| sink | Sink buffer. |
| bytes | Number of bytes to copy. |
|
inlinestatic |
Updates the buffer state after reading from the buffer.
| buffer | Buffer to update. |
| bytes | Number of read bytes. |
| int audio_stream_copy | ( | const struct audio_stream * | source, |
| uint32_t | ioffset, | ||
| struct audio_stream * | sink, | ||
| uint32_t | ooffset, | ||
| uint32_t | samples ) |
Copies data from source buffer to sink buffer.
| source | Source buffer. |
| ioffset | Offset (in samples) in source buffer to start reading from. |
| sink | Sink buffer. |
| ooffset | Offset (in samples) in sink buffer to start writing to. |
| samples | Number of samples to copy. |
| void audio_stream_copy_from_linear | ( | const void * | linear_source, |
| int | ioffset, | ||
| struct audio_stream * | sink, | ||
| int | ooffset, | ||
| unsigned int | samples ) |
Copies data from linear source buffer to circular sink buffer.
| linear_source | Source buffer. |
| ioffset | Offset (in samples) in source buffer to start reading from. |
| sink | Sink buffer. |
| ooffset | Offset (in samples) in sink buffer to start writing to. |
| samples | Number of samples to copy. |
| void audio_stream_copy_to_linear | ( | const struct audio_stream * | source, |
| int | ioffset, | ||
| void * | linear_sink, | ||
| int | ooffset, | ||
| unsigned int | samples ) |
Copies data from circular source buffer to linear sink buffer.
| source | Source buffer. |
| ioffset | Offset (in samples) in source buffer to start reading from. |
| linear_sink | Sink buffer. |
| ooffset | Offset (in samples) in sink buffer to start writing to. |
| samples | Number of samples to copy. |
|
inlinestatic |
|
inlinestatic |
Calculates period size in bytes based on component stream's parameters.
| buf | Component buffer. |
|
inlinestatic |
Calculates numbers of frames to buffer wrap and return minimum of calculated value.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Calculates available data in bytes, handling underrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
Calculates available data in frames, handling underrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
Calculates available data in samples, handling underrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Computes maximum number of bytes that can be copied from source buffer to sink buffer, verifying number of bytes available in source vs.
free space available in sink.
| source | Source buffer. |
| sink | Sink buffer. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Calculates free space in bytes, handling overrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
Calculates free space in frames, handling overrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
Calculates free space in samples, handling overrun_permitted behaviour.
| stream | Stream pointer |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| void audio_stream_init | ( | struct audio_stream * | audio_stream, |
| void * | buff_addr, | ||
| uint32_t | size ) |
Initializes the buffer with specified memory block and size.
| audio_stream | the audio_stream a to initialize. |
| buff_addr | Address of the memory block to assign. |
| size | Size of the memory block in bytes. |
|
inlinestatic |
Invalidates (in DSP d-cache) the buffer in range [r_ptr, r_ptr+bytes], with rollover if necessary.
| buffer | Buffer. |
| bytes | Size of the fragment to invalidate. |
|
inlinestatic |
Calculates period size in bytes based on component stream's parameters.
| buf | Component buffer. |
| frames | Number of processing frames. |
|
inlinestatic |
Updates the buffer state after writing to the buffer.
| buffer | Buffer to update. |
| bytes | Number of written bytes. |
| void audio_stream_recalc_align | ( | struct audio_stream * | stream | ) |
|
inlinestatic |
Resets the buffer.
| buffer | Buffer to reset. |
|
inlinestatic |
Calculates numbers of bytes to buffer wrap when reading stream backwards from current sample pointed by ptr towards begin.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
Calculate position of write pointer to the position before the data was copied to source buffer.
| source | Stream to get information from. |
| bytes | Number of bytes copied to source buffer. |
|
inlinestatic |
Verifies the pointer and performs rollover when reached the end of the buffer.
| buffer | Buffer accessed by the pointer. |
| ptr | Pointer |
|
inlinestatic |
Calculates sample size in bytes based on component stream's parameters.
| buf | Component buffer. |
|
inlinestatic |
Calculates numbers of s16 samples to buffer wrap when buffer is read forward towards end address.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
Calculates numbers of s24 samples to buffer wrap when buffer is read forward towards end address.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
Calculates numbers of s32 samples to buffer wrap when buffer is read forward towards end address.
| source | Stream to get information from. |
| ptr | Read or write pointer from source |
|
inlinestatic |
| void audio_stream_set_align | ( | const uint32_t | byte_align, |
| const uint32_t | frame_align_req, | ||
| struct audio_stream * | stream ) |
Set processing alignment requirements.
Sets the sample byte alignment and aligned frame count required for processing done on this stream. This function may be called at any time, the internal constants are recalculated if the frame/sample size changes.
| byte_align | Processing byte alignment requirement. |
| frame_align_req | Processing frames alignment requirement. |
| stream | Sink or source stream structure which to be set. |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Applies parameters to the buffer.
| buffer | Audio stream buffer. |
| params | Parameters (frame format, rate, number of channels). |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Writes zeros in range [w_ptr, w_ptr+bytes], with rollover if necessary.
| buffer | Buffer. |
| bytes | Size of the fragment to write zero. |
|
inlinestatic |
Verifies the pointer and performs rollover when reached the end of the buffer.
| buffer | Buffer accessed by the pointer. |
| ptr | Pointer |
|
inlinestatic |
Writes back (from DSP d-cache) the buffer in range [w_ptr, w_ptr+bytes], with rollover if necessary.
| buffer | Buffer. |
| bytes | Size of the fragment to write back. |
|
inlinestatic |
Calculates numbers of bytes to buffer wrap when reading stream backwards from current sample pointed by ptr towards begin.
| ptr | Read or write pointer og circular buffer. |
| buf_end | End address of circular buffer. |
| void cir_buf_copy | ( | const void * | src, |
| const void * | src_addr, | ||
| const void * | src_end, | ||
| void * | dst, | ||
| void * | dst_addr, | ||
| void * | dst_end, | ||
| size_t | byte_size ) |
Copies data from one circular buffer to another circular buffer.
| src | Source pointer of source circular buffer. |
| src_addr | Start address of source circular buffer. |
| src_end | End address of source circular buffer. |
| dst | Sink pointer of source circular buffer. |
| dst_addr | Start address of sink circular buffer |
| dst_end | End address of sink circular buffer. |
| byte_size | Number of bytes to copy. |
|
inlinestatic |
Writes zeros to circular buffer in range [ptr, ptr+bytes] with rollover if necessary.
| ptr | Pointer inside circular biffer to start writing from. |
| buf_addr | Start of the circular buffer. |
| buf_end | End of the circular buffer. |
| bytes | Size of the fragment to write zeros. |