How to Use the DSP Component (Overview)

This page describes how to use the various components provided by the DSP library.

Overview

The TWL-SDK provides a DSP library, which can encode and decode images and audio using a DSP.

The following features are provided by the DSP library.

Components

Linking to the DSP library does not make each of its features immediately available. Individual features are split into "components", and the application must load components to the DSP to use them.
The DSP becomes operative when the functions that load the components (DSP_Load*) run. Sleep mode is prohibited while any component is loaded.

The DSP uses the WRAM-B as the code region and the WRAM-C as the data region (see the Work RAM Overview for details). Each component uses a different size (number of slots). A macro is defined for indicating the size of each component. These macros are written in the description for each component-loading function (DSP_Load*).

Loading Components

Each component is a .a file under the $TwlSDK/dspcomponents/{component name} folder. These component files must be expanded, and the DSP library places each component file in static memory and opens it. The DSP_OpenStaticComponent* functions are provided (this increases the program's resident memory size, however).

If you would like to reduce the size, you can place the compressed component files in memory and use the FS_CreateFileFromMemory function to expand and open them on demand.(The FS_CreateFileFromMemory function is used within the DSP_OpenStaticComponent* functions as well.)

After opening a component file, pass the FSFile structure for that file as an argument to a DSP_Load* function to load the component. You must specify a slot in WRAM-B or WRAM-C that can be used by the DSP. This fails if there are not enough free slots in WRAM-B or WRAM-C for loading.

The DSP loading functions switches WRAM slots to both ARM9 and DSP, as necessary. Switching slots reserved by the MI_ReserveWram* functions is prohibited, so specifying these slots results in failure. Consequently, you do not need to reserve the WRAM in advance for the DSP.

If there are enough free regions for loading, only the required regions will be assigned to the DSP.

You cannot load and use multiple components at the same time.

Example

// Example using the G.711 component
FSFile *file;
// Open the G.711 component file
DSP_OpenStaticComponentG711(file);
// Load
DSP_LoadG711(file, 0xff, 0xff);

In the example above, only the necessary slots are selected from all the WRAM-B and WRAM-C slots to be allocated for the DSP.

Unloading Components

You must unload components using the DSP_Unload* functions when deleting the loaded component files to free WRAM or when the application sleeps or exits.

Unloading releases the WRAM-B and WRAM-C slots that were allocated to the DSP.

Example

// Unloading the G.711 component
DSP_UnloadG711();

See Also

DSP Function List

Revision History

2008/11/04 Added mention that Sleep mode is prohibited when components are loaded.
2008/10/21 Added situations where components must be unloaded.
2008/09/03 Initial version.


CONFIDENTIAL