AWEInstance.h
This page is a work in progress. Improvements to content and formatting are underway.
The AWEInstance API Header File.
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include "TargetProcessor.h"
Data Structures | |
struct | |
| The AWE instance. More... |
|
Typedefs | |
typedef struct _AWEInstance | |
| The AWE instance. More... |
| |
typedef INT32 | packetProcessFunction(AWEInstance *pAWE) |
|
Functions | |
INT32 | awe_init (AWEInstance *pAWE) |
| Initialize the instance. More... |
| |
INT32 | awe_initPin (IOPinDescriptor *pPin, UINT32 channels, const char *name) |
| Initialize an input or output pin. More... |
| |
void | awe_initFlashFS (AWEInstance *pAWE, AWEFlashFSInstance *pAWEFlashFSInstance) |
| Initialize the file system. More... |
| |
INT32 | awe_packetProcess (AWEInstance *pAWE) |
| Process an AWEInstance's newly received tuning packet. More... |
| |
INT32 | awe_audioPump (AWEInstance *pAWE, UINT32 layoutIndex) |
| Audio pump function. More... |
| |
INT32 | awe_audioImportSamples (const AWEInstance *pAWE, const void *inSamples, INT32 inStride, INT32 channel, SampleType inType) |
| Import samples from a user buffer to a channel. More... |
| |
INT32 | awe_audioExportSamples (const AWEInstance *pAWE, void *outSamples, INT32 outStride, INT32 channel, SampleType outType) |
| Export samples to a user buffer from a channel. More... |
| |
INT32 | awe_audioIsStarted (const AWEInstance *pAWE) |
| Check if this instance is running. More... |
| |
INT32 | awe_audioGetPumpMask (AWEInstance *pAWE) |
| Test if AWE is ready to run. More... |
| |
INT32 | awe_deferredSetCall (AWEInstance *pAWE) |
| Perform deferred awe set on a module. More... |
| |
INT32 | awe_loadAWBfromArray (AWEInstance *pAWE, const UINT32 *pCommands, UINT32 arraySize, UINT32 *pPos) |
| Executes packet commands from an in-memory array. More... |
| |
void | awe_layoutGetChannelCount (const AWEInstance *pAWE, UINT32 pinIdx, UINT32 *inCount, UINT32 *outCount) |
| Returns the number of channels in the Layout's input and output pins. More... |
| |
INT32 | awe_layoutGetInputBlockSize (const AWEInstance *pAWE, UINT32 pinIdx, UINT32 *blockSize) |
| Returns the block size of a pin. More... |
| |
INT32 | awe_layoutGetInputSampleRate (const AWEInstance *pAWE, UINT32 pinIdx, FLOAT32 *sampleRate) |
| Returns the sample rate of an input pin. More... |
| |
INT32 | awe_layoutIsValid (const AWEInstance *pAWE) |
| Determines if a layout is loaded and valid. More... |
| |
INT32 | awe_ctrlSetValue (const AWEInstance *pAWE, UINT32 handle, const void *value, INT32 arrayOffset, UINT32 length) |
| Set a scalar or array value of a module variable by handle. More... |
| |
INT32 | awe_ctrlGetValue (const AWEInstance *pAWE, UINT32 handle, void *value, INT32 arrayOffset, UINT32 length) |
| Get a scalar or array value of a module variable by handle. More... |
| |
INT32 | awe_ctrlSetStatus (const AWEInstance *pAWE, UINT32 handle, UINT32 status) |
| Set the runtime status of a module. More... |
| |
INT32 | awe_ctrlGetStatus (const AWEInstance *pAWE, UINT32 handle, UINT32 *status) |
| Get the runtime status of a module. More... |
| |
INT32 | awe_ctrlSetValueMask (const AWEInstance *pAWE, UINT32 handle, const void *value, INT32 arrayOffset, UINT32 length, UINT32 mask) |
| Set a scalar or array value of a module variable by handle with mask. More... |
| |
INT32 | awe_ctrlGetValueMask (const AWEInstance *pAWE, UINT32 handle, void *value, INT32 arrayOffset, UINT32 length, UINT32 mask) |
| Get a scalar or array value of a module variable by handle with mask. More... |
| |
INT32 | awe_ctrlGetModuleClass (const AWEInstance *pAWE, UINT32 handle, UINT32 *pClassID) |
| Get an object class from its handle. More... |
| |
INT32 | awe_setProfilingStatus (AWEInstance *pAWE, UINT32 status) |
| Enable or disable the profiling ability of the AWECore. More... |
| |
INT32 | awe_getAverageLayoutCycles (AWEInstance *pAWE, UINT32 layoutIdx, UINT32 *averageCycles) |
| Get the average cycles of a running layout, in units of cycles at profileSpeed. More... |
|
Detailed Description
The AWEInstance API Header File.
Typedef Documentation
◆ AWEInstance
typedef struct _AWEInstance AWEInstance |
The AWE instance.
The AWE Instance struct must have its members/pointers assigned at init time. The AWEInstance is the most important structure, and it must be initialized properly. After assigning all of the required members, the BSP author will call the awe_init() function. All members are required to be assigned unless they are marked optional in the detailed description below..
Function Documentation
◆ awe_init()
INT32 awe_init | ( | pAWE | ) |
|
Initialize the instance.
Call this once you have assigned all of the required members/pointers of the AWE Instance, and after calling awe_InitPin on both input and output pins. Calling awe_init before assigning all members of the instance structure or initializing the pins will result in crashes/erratic behavior.
Parameters
pAWE | instance to initialize |
ReturnsE_SUCCESS, E_NULL_PACKET_BUFFER_POINTER, E_NULL_REPLY_BUFFER_POINTER, E_ZERO_PACKET_BUFFER_LENGTH, E_EXCEPTION, E_PARAMETER_ERROR, E_NOT_CREATED
Examplesbare_metal_example.c, ControlApp.c, LinuxApp.c, and singleinstance_simple.c.
◆ awe_initPin()
INT32 awe_initPin | ( | IOPinDescriptor * | pPin, |
|
| UINT32 | channels, |
|
| const char * | name |
| ) |
|
|
Initialize an input or output pin.
This function must be called for both the input and output pins. Must be called BEFORE the awe_init API function.
Parameters
[in] | pPin | the pin instance to initialize |
[in] | channels | number of channels |
[in] | name | optional pin name |
ReturnsE_SUCCESS
Examplesbare_metal_example.c, ControlApp.c, LinuxApp.c, and singleinstance_simple.c.
◆ awe_initFlashFS()
void awe_initFlashFS | ( | pAWE, | |
|
| AWEFlashFSInstance * | pAWEFlashFSInstance |
| ) |
|
|
Initialize the file system.
Parameters
pAWE | instance to initialize |
pAWEFlashFSInstance | the file system instance |
◆ awe_packetProcess()
INT32 awe_packetProcess | ( | pAWE | ) |
|
Process an AWEInstance's newly received tuning packet.
Parameters
[in] | pAWE | The AWE instance pointer to process |
Returnserror E_SUCCESS, E_COMMAND_NOT_IMPLEMENTED, E_MESSAGE_LENGTH_TOO_LONG, E_CRC_ERROR, E_BADPACKET
Examplesbare_metal_example.c, LinuxApp.c, and singleinstance_simple.c.
◆ awe_audioPump()
INT32 awe_audioPump | ( | pAWE, | |
|
| UINT32 | layoutIndex |
| ) |
|
|
Audio pump function.
Call this in your audio thread once you have imported the data you wish to process. Before pumping, you must also check that the AudioWeaver buffers have been filled (awe_getPumpMask) and that audio has been started (awe_audioIsStarted). This function will return 1 if awe_deferredSetCall needs to be called. This is for modules that need to do more time consuming calculations, like calculating filter coefficients. For example, a SOF Control module needs to calculate new coeffs when the frequency is modified by the control input.
Parameters
[in] | pAWE | AWE instance pointer |
[in] | layoutIndex | the layout index to pump |
ReturnsE_SUCCESS, E_NO_LAYOUTS, or 1 (indicating that deferred set is needed, see documentation)
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_audioImportSamples()
INT32 awe_audioImportSamples | ( | const AWEInstance * | pAWE, |
|
| const void * | inSamples, |
|
| INT32 | inStride, |
|
| INT32 | channel, |
|
| inType | |
| ) |
|
|
Import samples from a user buffer to a channel.
The value of the fundamentalBlockSize member of the AWEInstance determines the number of samples that are imported with each call. Call this function once for each audio input channel on the hardware. Channel matching between hardware capabilities and layout will be done automatically. For example, if the target has only 1 audio input channel, and if a layout with 3 input channels is loaded, the second and third channels of the layout input will be all zeros. Inversely, if there are more HW input channels than the layout expects, then they are ignored.
The value of inStride defines the number of samples to skip between each read, and should be the number of interleaved channels in the inSamples buffer being read from. A typical usage for a single source, interleaved stereo input could look like:
awe_audioImportSamples
Sample32bit
awe_audioImportSamples
Sample32bit
Parameters
[in] | pAWE | AWE instance |
[in] | inSamples | pointer to first sample in buffer to import for current channel |
[in] | inStride | input buffer import stride |
[in] | channel | channel to write to |
[in] | inType | type of input data |
ReturnsE_SUCCESS, E_AUDIO_NOT_STARTED
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_audioExportSamples()
INT32 awe_audioExportSamples | ( | const AWEInstance * | pAWE, |
|
| void * | outSamples, |
|
| INT32 | outStride, |
|
| INT32 | channel, |
|
| outType | |
| ) |
|
|
Export samples to a user buffer from a channel.
The value of the fundamentalBlockSize member of the AWEInstance determines the number of samples that are exported with each call. Call this function once for each audio output channel on the hardware. Like awe_audioImportSamples, this will do channel matching automatically. For example, if the target has 3 audio output channels, and if a layout with 1 output channel is loaded, the second and third channels of the exported output will be all zeros. Inversely, if the layout has more output channels than the target supports, they are ignored.
The value of outStride defines the number of samples to skip between each write. It should be equal to the number of interleaved channels in the outSamples buffer being written to. A typical usage for exporting to an interleaved 3 channel output could look like:
Parameters
[in] | pAWE | AWE instance |
[out] | outSamples | pointer to first sample in buffer to export to |
[in] | outStride | output buffer export stride |
[in] | channel | channel to read from |
[in] | outType | type of output data |
ReturnsE_SUCCESS, E_AUDIO_NOT_STARTED
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_audioIsStarted()
INT32 awe_audioIsStarted | ( | const AWEInstance * | pAWE | ) |
|
Check if this instance is running.
A BSP author can use this to determine if the instance is already running to avoid pumping audio through a dead layout.
Parameters
pAWE | instance pointer |
Returns0 if audio is not started, 1 if audio is started. No error conditions
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_audioGetPumpMask()
INT32 awe_audioGetPumpMask | ( | pAWE | ) |
|
Test if AWE is ready to run.
This will return the "layout mask" which is a bit vector of threads to run. For a simple, single threaded system, the bitvector will be 0x1. If a previous pump is not complete and the layout is ready to pump again, an overflow is detected by this function. In this condition, the layoutMask bit for the overflowed layout will be zero, which prevents the layout from being pumped again. Example: int layoutMask = awe_audioGetPumpMask&g_AWEInstance); if (layoutMask > 0) { if (layoutMask & 0x1) { int ret = awe_audioPump(&g_AWEInstance, 0); } }
Parameters
pAWE | AWE instance |
Returnsbit vector of threads to run, 0 if no threads, E_AUDIO_NOT_STARTED
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_deferredSetCall()
INT32 awe_deferredSetCall | ( | pAWE | ) |
|
Perform deferred awe set on a module.
Each call to awe_deferredSetCall processes a single module. Usually this function would be called repeatedly until the return value is 0.
Parameters
[in] | pAWE | AWE instance pointer |
ReturnsfinishedProcessing Will return 1 when processing is incomplete, 0 when complete. No error codes.
Examplesbare_metal_example.c, and LinuxApp.c.
◆ awe_loadAWBfromArray()
INT32 awe_loadAWBfromArray | ( | pAWE, | |
|
| const UINT32 * | pCommands, |
|
| UINT32 | arraySize, |
|
| UINT32 * | pPos |
| ) |
|
|
Executes packet commands from an in-memory array.
Designer can generate AWB arrays directly from a layout.
Parameters
[in] | pAWE | AWE instance pointer |
[in] | pCommands | Buffer with commands to execute |
[in] | arraySize | Number of DWords in command buffer |
[out] | pPos | Report failing word index |
ReturnsE_SUCCESS, E_EXCEPTION, E_UNEXPECTED_EOF
ExamplesControlApp.c.
◆ awe_layoutGetChannelCount()
void awe_layoutGetChannelCount | ( | const AWEInstance * | pAWE, |
|
| UINT32 | pinIdx, |
|
| UINT32 * | inCount, |
|
| UINT32 * | outCount |
| ) |
|
|
Returns the number of channels in the Layout's input and output pins.
Parameters
[in] | pAWE | AWE instance pointer |
[in] | pinIdx | which input pin (always 0) |
[out] | inCount | channels in primary input pin |
[out] | outCount | channels in primary output pin |
ExamplesControlApp.c.
◆ awe_layoutGetInputBlockSize()
INT32 awe_layoutGetInputBlockSize | ( | const AWEInstance * | pAWE, |
|
| UINT32 | pinIdx, |
|
| UINT32 * | blockSize |
| ) |
|
|
Returns the block size of a pin.
Because the block size of the output pin is inherited from the input pin, the user only needs to check the input pin.
Parameters
[in] | pAWE | The AWE Instance |
[in] | pinIdx | which input pin (always 0) |
[out] | blockSize | block size of input pin |
ReturnsE_SUCCESS, E_NO_LAYOUTS
ExamplesControlApp.c.
◆ awe_layoutGetInputSampleRate()
INT32 awe_layoutGetInputSampleRate | ( | const AWEInstance * | pAWE, |
|
| UINT32 | pinIdx, |
|
| FLOAT32 * | sampleRate |
| ) |
|
|
Returns the sample rate of an input pin.
Because the sample rate of the output pin is inherited from the input pin, the user only needs to check the input pin.
Parameters
[in] | pAWE | The AWE Instance |
[in] | pinIdx | which input pin (always 0) |
[out] | sampleRate | the input pin sample rate |
ReturnsE_SUCCESS, E_NO_LAYOUTS
◆ awe_layoutIsValid()
INT32 awe_layoutIsValid | ( | const AWEInstance * | pAWE | ) |
|
Determines if a layout is loaded and valid.
Parameters
[in] | pAWE | The AWE Instance |
Returns0 if layout is not valid/loaded, 1 if layout is valid. No error codes.
Examplesbare_metal_example.c, ControlApp.c, and LinuxApp.c.
◆ awe_ctrlSetValue()
INT32 awe_ctrlSetValue | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| const void * | value, |
|
| INT32 | arrayOffset, |
|
| UINT32 | length |
| ) |
|
|
Set a scalar or array value of a module variable by handle.
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[in] | value | value(s) to set |
[in] | arrayOffset | array index if array |
[in] | length | number of elements. 1 if scaler |
ReturnsE_SUCCESS, E_ARGUMENT_ERROR, E_BAD_MEMBER_INDEX, E_CLASS_NOT_SUPPORTED, E_LINKEDLIST_CORRUPT, E_NO_MORE_OBJECTS
Examplesbare_metal_example.c, and ControlApp.c.
◆ awe_ctrlGetValue()
INT32 awe_ctrlGetValue | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| void * | value, |
|
| INT32 | arrayOffset, |
|
| UINT32 | length |
| ) |
|
|
Get a scalar or array value of a module variable by handle.
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[out] | value | value(s) to get |
[in] | arrayOffset | array index if array |
[in] | length | number of elements. 1 if scaler |
ReturnsE_SUCCESS, E_ARGUMENT_ERROR, E_BAD_MEMBER_INDEX, E_CLASS_NOT_SUPPORTED, E_LINKEDLIST_CORRUPT, E_NO_MORE_OBJECTS
Examplesbare_metal_example.c, and ControlApp.c.
◆ awe_ctrlSetStatus()
INT32 awe_ctrlSetStatus | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| UINT32 | status |
| ) |
|
|
Set the runtime status of a module.
0 = Active, 1 = Bypass, 2 = Mute, 3 = Inactive
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[in] | status | status to set |
ReturnsE_SUCCESS, E_NOT_MODULE, E_LINKEDLIST_CORRUPT, E_NO_MORE_OBJECTS
◆ awe_ctrlGetStatus()
INT32 awe_ctrlGetStatus | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| UINT32 * | status |
| ) |
|
|
Get the runtime status of a module.
0 = Active, 1 = Bypass, 2 = Mute, 3 = Inactive
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[out] | status | status to get |
ReturnsE_SUCCESS, E_NOT_MODULE, E_LINKEDLIST_CORRUPT, E_NO_MORE_OBJECTS, E_PARAMETER_ERROR
◆ awe_ctrlSetValueMask()
INT32 awe_ctrlSetValueMask | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| const void * | value, |
|
| INT32 | arrayOffset, |
|
| UINT32 | length, |
|
| UINT32 | mask |
| ) |
|
|
Set a scalar or array value of a module variable by handle with mask.
A mask allows you to only call module's set function for a single variable.
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[in] | value | value(s) to set |
[in] | arrayOffset | array index if array |
[in] | length | number of elements if array. 1 if scaler |
[in] | mask | mask to use - 0 to not call set function |
ReturnsE_SUCCESS, E_ARGUMENT_ERROR, E_BAD_MEMBER_INDEX, E_CLASS_NOT_SUPPORTED, E_OBJECT_ID_NOT_FOUND, E_NOT_MODULE
◆ awe_ctrlGetValueMask()
INT32 awe_ctrlGetValueMask | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| void * | value, |
|
| INT32 | arrayOffset, |
|
| UINT32 | length, |
|
| UINT32 | mask |
| ) |
|
|
Get a scalar or array value of a module variable by handle with mask.
A mask allows you to only call module's set function for a single variable.
Parameters
[in] | pAWE | instance pointer |
[in] | handle | packed object handle |
[out] | value | value(s) to get |
[in] | arrayOffset | array index if array |
[in] | length | number of elements if array. 1 if scaler |
[in] | mask | mask to use - 0 to not call get function |
ReturnsE_SUCCESS, E_ARGUMENT_ERROR, E_BAD_MEMBER_INDEX, E_CLASS_NOT_SUPPORTED, E_OBJECT_ID_NOT_FOUND, E_NOT_MODULE
◆ awe_ctrlGetModuleClass()
INT32 awe_ctrlGetModuleClass | ( | const AWEInstance * | pAWE, |
|
| UINT32 | handle, |
|
| UINT32 * | pClassID |
| ) |
|
|
Get an object class from its handle.
Parameters
| pAWE | instance pointer |
[in] | handle | handle of object to find |
[out] | pClassID | pointer to found object class |
ReturnsE_SUCCESS, E_NO_MORE_OBJECTS, E_LINKEDLIST_CORRUPT
Examplesbare_metal_example.c, and ControlApp.c.
◆ awe_setProfilingStatus()
INT32 awe_setProfilingStatus | ( | pAWE, | |
|
| UINT32 | status |
| ) |
|
|
Enable or disable the profiling ability of the AWECore.
Both top and module level profiling enabled by default at awe_init. Use this if you wish to selectively enable or disable per pump profiling during runtime. Disabling profiling saves a small amount of cycles per pump. User can also enable or disable independently module level profiling and top level profiling.
Parameters
pAWE | instance pointer |
status | 0 to disable both, 1 to enable both, 2 to enable module level only and 3 to enable top level only |
ReturnsE_SUCCESS, E_NOT_OBJECT, E_PARAMETER_ERROR
ExamplesControlApp.c, and LinuxApp.c.
◆ awe_getAverageLayoutCycles()
INT32 awe_getAverageLayoutCycles | ( | pAWE, | |
|
| UINT32 | layoutIdx, |
|
| UINT32 * | averageCycles |
| ) |
|
|
Get the average cycles of a running layout, in units of cycles at profileSpeed.
Returns cycles in 24.8 format, so shift right by 8 bits for integer value. To get CPU cycles, multiply by target cpuSpeed / profileSpeed. If a previous pump is not complete and the layout is ready to pump again, an overflow is detected. When in this state, the awe_getAverageLayoutCycles api will return the averageCycles = AWE_PUMP_OVF_MAX_AVG_CYCLES (0xFFFFFFFF).
Parameters
pAWE | instance pointer |
layoutIdx | Layout index (typically 0, except in advanced use cases) |
averageCycles | Pointer the output (average layout cycles) |
ReturnsE_SUCCESS, E_PARAMETER_ERROR, E_NO_LAYOUTS