# MI_SendNDmaGXCommand*

## Syntax

  `#include <twl/mi.h>`
  `void MI_SendNDmaGXCommand( u32 ndmaNo, const void* src, u32 commandLength );
  void MI_SendNDmaGXCommandAsync( u32 ndmaNo, const void* src, u32 commandLength,
  MINDmaCallback callback, void* arg );`
  `
  void MI_SendNDmaGXCommandAsyncFast( u32 ndmaNo, const void* src, u32 commandLength,
  MINDmaCallback callback, void* arg );`

## Arguments

ndmaNo | DMA channel used.
src | The transfer source address.
commandLength | Transfer command size
callback | Callback when DMA ends.
arg | Callback argument when DMA ends.

## Return Values

None.

## Description

This function uses DMA to send a display list (GX command string) to the command FIFO. The transfer source address must be 4-byte aligned.

The synchronous version of the `MI_SendNDmaGXCommand` function waits for DMA to end inside the function. The asynchronous version of the `MI_SendNDmaGXCommandAsync` and `MI_SendNDmaGXCommandAsFast` functions call `callback` when DMA ends. The callback type is `MINDmaCallback` (a `void`–type function that takes one `void*` argument). `callback` is called from the system DMA interrupt handler and therefore is called even if interrupts are prohibited.

The differences between the `MI_SendNDmaGXCommandAsync` and `MI_SendNDmaGXCommandAsyncFast` functions are as follows.
The `MI_SendGXCommandAsync` function does not use the geometry transfer DMA but uses only the usual synchronous DMA. A small amount of DMA is performed by using the interrupt that is generated when GXFIFO is less than half. The `MI_SendGXCommandAsyncFast` function uses the geometry transfer DMA, so that DMA starts automatically when GXFIFO becomes low. Note that multiple automatic DMAs cannot be started simultaneously because of hardware restrictions. However, the hardware allows the simultaneous startup of multiple automatic DMAs of the same type.

With TWL-SDK, the exclusive processing with the `MI_SendNDmaGXCommandAsync*` and other `G3_`-based functions is not performed because the execution speed of the graphics command has been prioritized. Therefore, we cannot guarantee correct operation if the GX command is written directly to the command FIFO by a `G3_` function while the GX command is being transferred by the `MI_SendNDmaGXCommandAsync*` function. It is strongly recommended that you pay particular attention in avoiding such an API call situation.

###
About the DMA to be Used

Although this function uses a new DMA, the function that performs the same operation using the old DMA is `MI_SendGXCommand*`. The `MI_SendGXCommand*` and `MI_SendNDmaGXCommand*` functions cannot be used at the same time.

## Internal Operation

Uses the new I/O DMA registers.

## See Also

`MI_NDmaCopy*
G3_BeginMakeDL
G3_EndMakeDL`
`MI_SendGXCommand*`

## Revision History

2008/10/16 Initial version.

CONFIDENTIAL