/* Copyright (c) 2006 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual property * and proprietary rights in and to this software, related documentation * and any modifications thereto. Any use, reproduction, disclosure or * distribution of this software and related documentation without an * express license agreement from NVIDIA Corporation is strictly prohibited. */ /** @file GFRm.h GFSDK Resource Manager API header file. */ #ifndef __GFRM_H__ #define __GFRM_H__ #include "GF.h" #include "GFRmError.h" /** @addtogroup groupRm RmAPI Resource Manager API
#GF_SURFACE_ROTATE_0
#GF_SURFACE_ROTATE_90
#GF_SURFACE_ROTATE_180
#GF_SURFACE_ROTATE_270
@see GFRmSurfaceUpdate()
*/
#define GF_SURFACE_UPDATE_ROTATE 0x00000001
/** GFRmSurfaceUpdate() attribute type: Update surface width.
Meaning of parameter \a data of GFRmSurfaceUpdate():
New surface width in pixels.
The number of bytes required for the new width must not exceed the
surface stride. It is the responsibility of the caller to ensure this.
@see GFRmSurfaceUpdate()
*/
#define GF_SURFACE_UPDATE_WIDTH 0x00000002
/** GFRmSurfaceUpdate() attribute type: Update surface height.
Meaning of parameter \a data of GFRmSurfaceUpdate():
New surface height in line.
The set height * surface stride must not exceed the memory allocated
for the surface. It is the responsibility of the caller to ensure this.
@see GFRmSurfaceUpdate()
*/
#define GF_SURFACE_UPDATE_HEIGHT 0x00000003
/** GFRmSurfaceUpdate() attribute type: Update surface width and stride.
Meaning of parameter \a data of GFRmSurfaceUpdate():
New surface width in pixels.
YStride, UStride, and VStride will be updated automatically according
to alignment requirements. Supported colour formats:
- GF_SURFACE_YUV420
@see GFRmSurfaceUpdate()
*/
#define GF_SURFACE_UPDATE_WIDTH_STRIDE 0x00000004
/*@}*/
/** @name Memory types
@anchor MemoryTypes
@see GFRMMEMORYREQUEST, GFRmMemHandleAlloc()
@{*/
/** Memory Type: Host system memory. */
#define GF_MEMORY_SYSTEM 0x01
/** Memory Type: Any GPU memory */
#define GF_MEMORY_EMBEDDED 0x02
/** Memory Type: Memory mapped memory. */
#define GF_MEMORY_MEMMAPPED 0x04
/** Memory Type: External GPU memory only. */
#define GF_MEMORY_EMBEDDED_EXT_ONLY GF_MEMORY_EMBEDDED_EXT
#define GF_MEMORY_EMBEDDED_EXT 0x08
/** Memory Type: Internal GPU memory only. */
#define GF_MEMORY_EMBEDDED_INT_ONLY GF_MEMORY_EMBEDDED_INT
#define GF_MEMORY_EMBEDDED_INT 0x10
/** Memory type: Internal or external memory with preference to internal memory. */
#define GF_MEMORY_EMBEDDED_INT_PREFERRED 0x20
/** Memory type: External or internal memory with preference to external memory. */
#define GF_MEMORY_EMBEDDED_EXT_PREFERRED 0x40
/** Memory type: Direct Read access */
#define GF_MEMORY_DIRECT_CPU_READ_ACCESS 0x80
/** Memory type: Direct Write access */
#define GF_MEMORY_DIRECT_CPU_WRITE_ACCESS 0x100
/** Memory type: Direct Read/Write access */
#define GF_MEMORY_DIRECT_CPU_ACCESS (GF_MEMORY_DIRECT_CPU_WRITE_ACCESS | GF_MEMORY_DIRECT_CPU_READ_ACCESS)
/*@}*/
/** @name Memory Share Types
@anchor MemoryShare
@see GFRMMEMORYREQUEST, GFRmMemHandleAlloc()
@{*/
/** Memory Share Flag: Internal use, used in GFRmMemInfo only. */
#define GF_MEMORY_SHARE 0x80
/*@}*/
/** @name Memory Alignment
@anchor MemoryAlignment
@see GFRMMEMORYREQUEST, GFRmMemHandleAlloc()
@{*/
/** Memory alignment types, must match log2 of alignment size. */
enum
{
GF_MEMORY_ALIGN_NONE = 0, /**< Memory Alignment: Don't care. */
GF_MEMORY_ALIGN2, /**< Memory Alignment: Aligned to 2 byte boundary. */
GF_MEMORY_ALIGN4, /**< Memory Alignment: Aligned to 4 byte boundary. */
GF_MEMORY_ALIGN8, /**< Memory Alignment: Aligned to 8 byte boundary. */
GF_MEMORY_ALIGN16, /**< Memory Alignment: Aligned to 16 byte boundary. */
GF_MEMORY_ALIGN32, /**< Memory Alignment: Aligned to 32 byte boundary. */
GF_MEMORY_ALIGN64, /**< Memory Alignment: Aligned to 64 byte boundary. */
GF_MEMORY_ALIGN128, /**< Memory Alignment: Aligned to 128 byte boundary. */
GF_MEMORY_ALIGN256, /**< Memory Alignment: Aligned to 256 byte boundary. */
GF_MEMORY_ALIGN512, /**< Memory Alignment: Aligned to 512 byte boundary. */
GF_MEMORY_ALIGN1024, /**< Memory Alignment: Aligned to 1024 byte boundary. */
GF_MEMORY_ALIGN2048, /**< Memory Alignment: Aligned to 2048 byte boundary. */
GF_MEMORY_ALIGN4096, /**< Memory Alignment: Aligned to 4096 byte boundary. */
GF_MEMORY_ALIGN_DSP = 0xFF /**< Memory Alignment: Aligned properly for DSP cacheline size. */
};
/*@}*/
/** @name Memory Allocation Hints
@anchor MemoryHints
@see GFRMMEMORYREQUEST, GFRmMemHandleAlloc()
@{*/
/* Memory Hint - Follow Surface Hint */
/** Memory Allocation Hint: Allocate from high to low addresses. */
#define GF_MEMORY_HINT_TOP_DOWN GF_SURFACE_HINT_TOP_DOWN
/** Memory Allocation Hint: Allocate from low to high addresses. */
#define GF_MEMORY_HINT_BOTTOM_UP GF_SURFACE_HINT_BOTTOM_UP
/** Memory Allocation Hint: Allocate from maximum available chunk. */
#define GF_MEMORY_HINT_MAX_CHUNK GF_SURFACE_HINT_MAX_CHUNK
/** Memory Allocation Hint: Allocate at fixed address. */
#define GF_MEMORY_HINT_FIXED (GF_MEMORY_HINT_MAX_CHUNK << 1)
/** Memory Allocation Hint: Allocate for 3D. */
#define GF_MEMORY_HINT_3D (GF_MEMORY_HINT_MAX_CHUNK << 2)
/* These options are for DRAM as extended memory. This option specifies
* bank the buffer should come from. This will avoid
* bank clobbering between two buffers that are accessed in lock
* step.
*/
/** Memory Allocation Hint: Allocate from even banks in external memory. */
#define GF_MEMORY_HINT_EVEN_BANK (GF_MEMORY_HINT_MAX_CHUNK << 3)
/** Memory Allocation Hint: Allocate from odd banks in external memory. */
#define GF_MEMORY_HINT_ODD_BANK (GF_MEMORY_HINT_MAX_CHUNK << 4)
/*@}*/
/** Memory allocation request.
@see GFRmMemHandleAlloc()
*/
typedef struct _GFRMMEMORYREQUEST
{
NvU32 length; /**< Size in bytes. */
NvU32 hint; /**< Allocation hint or 0, see @ref MemoryHints. */
struct
{
NvU16 type; /**< Memory type, see @ref MemoryTypes. */
NvU8 share; /**< Share flags or 0, see @ref MemoryShare. */
NvU8 align; /**< Alignment flags, see @ref MemoryAlignment. */
}
flag;
NvU32 id; /**< User defined ID to track allocated block, debugging use */
} GFRMMEMORYREQUEST, *PGFRMMEMORYREQUEST;
/** OS Critical Section bits 0-15 are general purpose use
bit 16-31 are for internal use */
#define GF_CRITICAL_SECTION_HW 0x00000001
/** RM internal use */
#define GF_CRITICAL_SECTION_SW2 0x00000004
/** RM internal use */
#define GF_CRITICAL_SECTION_SW4 0x00000010
/** I2C critical section */
#define GF_CRITICAL_SECTION_I2C 0x00000020
/** RM All channel lock, internal use */
#define GF_CRITICAL_SECTION_ALL_CHANNELS 0x00000040
/** Ix internal use */
#define GF_CRITICAL_SECTION_SW8 0x00000100
/** RM DSP to Host communication, internal use */
#define GF_CRITICAL_SECTION_D2H 0x00000200
/** The SHUTDOWN_DSP lock protects the race between
* UpdateDSPFreq/DSPDisable and HandleInterrupt (IST).
* (Update and DSPDisable turn off the DSP, HandleInt reads
* DSP regs)
*/
#define GF_CRITICAL_SECTION_SHUTDOWN_DSP 0x00000400
/** The DSP lock protects the race between
* AddTask and RemoveTask.
*/
#define GF_CRITICAL_SECTION_DSP 0x00000401
/** Define the ID for the kernel semaphore */
#define GF_DSP_KERNEL_SEM_ID 0x0CAFEFAD
/** Shared memory lock - used for internal purposes */
#define GF_CRITICAL_SECTION_SHM 0x00000800
/** RM Host to DSP communication, internal use */
#define GF_CRITICAL_SECTION_H2D 0x00001000
/** Rm internal use: lock for channel structures */
#define GF_CRITICAL_SECTION_CHSTRUCT 0x00004000
/** Dx internal use */
#define GF_CRITICAL_SECTION_DX 0x00008000
/** Vx internal use */
#define GF_CRITICAL_SECTION_VX 0x00000080
#ifdef PROJECT_SEC_G1
/** JxDec internal use */
#define GF_CRITICAL_SECTION_JXDEC 0x00002000
#endif
/** Rm internal use: lock for DSP messages */
#define GF_CRITICAL_SECTION_DSPMSG_MIN 0x00010000
#define GF_CRITICAL_SECTION_DSPMSG_MAX 0x20000000
/** Audio Shared Memory lock - used for multiprocess OS */
#define GF_CRITICAL_SECTION_SWAUDIO 0x10002000
/** Maximiun id */
#define GF_CRITICAL_SECTION_SWMAX 0x00010000
/** OS IRQ Callback */
typedef void (* GFRMOSIRQCALLBACK)( void *pData );
struct _GFRMCOMMONSTRUCT;
struct _GFRMENVIRONMENTVARIABLES;
struct _GFRMEXTDATASTRUCT;
/** Definition of Ix powerplane operations
*/
typedef enum _GFIX_POWERPLANE_OP_TYPE
{
GFIX_POWERPLANE_OP_ENABLE = 0,
GFIX_POWERPLANE_OP_DISABLE,
GFIX_POWERPLANE_OP_QUERY
} GFIX_POWERPLANE_OP_TYPE;
/** Configuration structure that may be passed to GFRmOpen().
See GFRmOpen() for details.
*/
typedef struct _GFRMOPENSTRUCT
{
NvU32 isFirstProcess;
NvU32 isDeviceMapped;
GF_RETTYPE retStatus; //!< Return error reason code, in case GFRmOpen() fails
/** Declare which driver HW or NULL driver to use.
This is for GFSDK compiled for NULL driver case.
*/
NvU32 useDriver;
} GFRMOPENSTRUCT;
/** @name Interface Manager Returned Functions
@{*/
/** Write a 32-bit register in the device.
@param base I/O base address
@param offset Offset of register
@param data Data to write
*/
typedef void (*GF_FUNC_WRITE_32BIT)(void * base, NvU32 offset, NvU32 data);
/** Read a 32-bit register in the device.
@param base I/O base address
@param offset Offset of register
@retval #NvU32 register value
*/
typedef NvU32 (*GF_FUNC_READ_32BIT)(void * base, NvU32 offset);
/*@}*/
/** Interface Options for Read/Write Embedded FIFO (for Jx/Mx APIs) */
#define GF_EMBFIFO_SWAP_BYTE 0x00000001
#define GF_EMBFIFO_SWAP_WORD 0x00000002
/** Interface FIFO flags */
/** Front-End FIFO */
#define GF_FIFO_FEND 0x00000001
/** GE (2D/Primary) FIFO */
#define GF_FIFO_SRC 0x00000002
/** Interface Helper macro to generate Address Pointer */
#define GFMAKEADDR(base, offset) (void *)base, offset
/** Utility Debug Flag */
#define GF_DEBUG_DEFAULT 0
/** 4th argument for GFRmOSGetTickCount */
#define GF_USEC_TICKS 0
#define GF_MSEC_TICKS 1
#define GF_SEC_TICKS 2
/** Flags for the Context manager GF_CTX_DEFAULT, GF_CTX_NEW */
#define GF_CTX_DEFAULT 1
#define GF_CTX_NEW 2
#define GF_CTX_SHARED 3
/*
########################################################################
* Function Prototypes for GFSDK Resource Manager (RM) Services
########################################################################
*/
/* Object Manager */
/** GFRmOpen - Starts Resource Manager and GFSDK.
@param RmOpenHandle Must be NULL.
@return Resource manager handle, or NULL on failure.
This must be called prior using any GFSDK component APIs and RM services.
This function can be called multiple times, for each successfull call
the application must also call GFRmClose().
If this function fails, and a pointer to an open structure is passed in
\a RmOpenHandle, the a failure reasoncode will be returned in GF_OPEN_RETTYPE::retStatus.
*/
GFRmHandle GFRmOpen(GFRMOPENSTRUCT *RmOpenHandle);
/** GFRmClose - Ends Resource Manager and GFSDK.
@param pRmHandle Ptr to RmHandle to be closed.
@retval GF_RETTYPE #GF_SUCCESS if successful.| #GF_SURFACE_UPDATE_ROTATE | Set surface rotation |
| #GF_SURFACE_UPDATE_WIDTH | Set surface width |
| #GF_SURFACE_UPDATE_HEIGHT | Set surface height |
Start of block: 0x0D,0xF0,0xAD,0xDE,0x0D,0xF0,0xAD,0xDE
End of block: 0xDE,0xAD,0xFO,0xOD,0xDE,0xAD,0xFO,0xOD
This call checks if these guard markers have been overwritten
@return Index of corrupted memory block, or -1 if all are ok.
*/
int GFRmMemEmbVerify(GFRmHandle RmHandle);
/* CPU bound memory fill functions:
These functions will use CPU cycles to write 16 to 32-bit fixed data
pattern into GPU memory. These API's will use user specified channel
apperture to access memory directly and are equipped with Lock and Unlock
routines to be thread safe.
*/
/** Fill memory with fixed data pattern on a particular channel.
Function locks and unlocks the channel automatically.
@param ChHandle User-specified channel to use.
@param memHandle GPU memory handle to write fixed 32-bit data.
@param offset Byte offset relative to memHandle block,
must be 32-bit aligned.
@param fill 32-bit fixed data pattern.
@param words Number of DWORDs to write.
*/
void
GFRmChMemFill32(GFRmChHandle ChHandle, GFRmMemHandle memHandle, NvU32 offset,
NvU32 fill, NvU32 words);
/** Fill memory with fixed data pattern on a particular channel.
Function locks and unlocks the channel automatically.
@param ChHandle User-specified channel to use.
@param memHandle GPU memory handle to write fixed 16-bit data.
@param offset Byte offset relative to memHandle block,
must be 32-bit aligned.
@param fill 16-bit fixed data pattern.
@param words Number of DWORDs to write.
*/
void
GFRmChMemFill16(GFRmChHandle ChHandle, GFRmMemHandle memHandle, NvU32 offset,
NvU16 fill, NvU32 words);
/** Save/Restore functions - These functions Save embedded memory to system memory.
* This memory can then be restored back to sys mem when required. These functions
* are used during DeepPowerDown.
*/
GF_RETTYPE GFRmSaveMemory(GFRmHandle pRm,
void *sysMemPtr,
NvU32 memSize);
GF_RETTYPE GFRmRestoreMemory(GFRmHandle pRm,
void *sysMemPtr,
NvU32 memSize);
/* Linear video memory functions:
These functions are used for transferring system memory to video memory,
filling video memory, and video memory to video memory operations. These
set of functions use the "1d" engine in hardware. All operations use
channels and will be synchronized with other commands. Optionally each
operation can be passed a flag to insert a "clear/raise/wait" sequence
which will guarantee that the operation has completed before processing
more commands in the command stream. For example, if a texture is being
downloaded, it is useful that the download be complete prior to some other
engine (3d maybe) using this memory.
Prior to using functions, the 1d engine must be enabled. Disabling
will cause the channel passed in to be idled. This is required by hardware
so that the command processors state can be updated when the 1d engine
has its clock disabled and put into reset.
*/
/** Callback prototype for GFRmChLinearSetDMACallback(). */
typedef void (*GF_FUNC_DMA_CALLBACK)(void *dstAddr, void *srcAddr, NvU32 lengthInWords);
/** Setup an DMA callback for downloading data to SRAM.
*
* This function allows for the user to to setup a DMA callback when
* downloading code to the frame buffer.
*
* The callback function should return AFTER all data has been transferred to
* the device. The downloader writes all data to the framebuffer through
* the registered frame buffer window. This window is 4KBytes in length,
* so there will be a callback once for each 4Kbytes (or less to handle alignment
* constraints).
*
* Also, it is possible for downloads to be occuring on multiple channels
* concurrently, which means that this Callback function must be able to
* handle calls from different threads, and do whatever arbitration is required.
*
* For indirect addressing modes, inside the GFSDK a semaphore will be taken
* and held for the duration of this transaction, as multiple threads cannot
* access the device concurrently when using an indirect addressing model.
*
* @param ChHandle The channel that will be used for the download (channel aperture is used)
* @param dmaCallback Pointer to the callback function that is called to do the download
*/
GF_RETTYPE
GFRmChLinearSetDMACallback(GFRmChHandle ChHandle,
GF_FUNC_DMA_CALLBACK dmaCallback);
/** Flag for GFRmChLinearSysToVidMemcpy(): use a clear/raise/wait. */
#define GF_RM_LINEAR_USE_CRW 0x01
/** Flag for GFRmChLinearSysToVidMemcpy(): don't synchronize with channel's pushbuffer. */
#define GF_RM_LINEAR_NO_PB_SYNC 0x02
/** Enable 1D engine for GFRmChLinear* functions.
*
* Call before using any GFRmChLinear* function. This enables the hardware that is
* used for these functions. Internally there is a reference count, so it is safe
* to call this multiple times.
*
* @param ChHandle Any valid channel handle should work.
* @see GFRmChLinearDisable()
*/
GF_RETTYPE
GFRmChLinearEnable(GFRmChHandle ChHandle);
/** Disable 1D engine for GFRmChLinear* functions.
*
* When the internal reference count reaches zero, the accelerator's clocks will be turned
* off to save power
*
* @param ChHandle Any valid channel should work.
* @see GFRmChLinearEnable()
*/
GF_RETTYPE
GFRmChLinearDisable(GFRmChHandle ChHandle);
/** Downloads a system memory buffer to the GPU memory buffer.
*
* The main reason for using this is that
* the copy to video memory is serialized with other operations. A typical use would be something
* like: 3d-driver issues draw commands that use a texture. 3d-driver issues a clear/raise/wait to
* know when draw is complete. 3d-driver issues a download to update the texture.
*
* @param pCtx : Current context (channel)
* @param memHandle : Handle returned from the memory allocator
* @param dstOffset : Offset from the beginning of the block referenced in memHandle
* @param pSrc : Source memory address in system memory
* @param len : Length in bytes to copy
* @param flags : Flags to optionally modify copy behavior
*
* flags can be one of:
*
* GF_RM_LINEAR_USE_CRW -- use a clear/raise/wait to make the operation finish prior to other command
* in the command stream being executed.
* GF_RM_LINEAR_NO_PB_SYNC -- This means the download does not need to be synchronous with the pushbuffer
* and the RM can optionally use different more efficient path
* than the pushbuffer.
*
* @return Returns GF_SUCCESS on success
*/
GF_RETTYPE
GFRmChLinearSysToVidMemcpy(GFRmChHandle pCtx,
GFRmMemHandle memHandle,
NvU32 dstOffset,
void *srcPtr,
NvU32 bytes,
NvU32 flags);
/** Fills a region of GPU memory with a constant value, by memory handle.
*
* @param ctx Current context (or channel)
* @param memHandle Handle to the memory to fill
* @param dstOffset Offset inside the memory handle
* @param data32 The value being replicated in memory. This value is
* interpreted differently depending on the align parameter.
* if align==4 all of data32 is used
* if align==2 lower 16-bits of data32 is used
* if align==1 lower 8-bits of data32 is used
*
* @param bytes Number of bytes to fill
* @param align must 1,2,4
* @param flags Can be 0 or GF_RM_LINEAR_USE_CRW
*/
GF_RETTYPE
GFRmChLinearVidMemFill(GFRmChHandle ctx,
GFRmMemHandle memHandle,
NvU32 dstOffset,
NvU32 data32,
NvU32 bytes,
NvU32 align,
NvU32 flags);
/** Copies memory within GPU memory, by memory handle.
*
* @param ctx The channel handle
* @param dstMemHandle memory handle returned from memalloc
* @param dstOffset Offset from the beginning of dstMemHandle
* @param srcMemhandle memory handle of the src memory
* @param srcOffset Offset from the beginning of srcMemHandle
* @param bytes Number of bytes to be copied.
* @param flags Must be 0 or GF_RM_LINEAR_USE_CRW
*
*/
GF_RETTYPE
GFRmChLinearVidMemcpy(GFRmChHandle ctx,
GFRmMemHandle dstMemHandle,
NvU32 dstOffset,
GFRmMemHandle srcMemHandle,
NvU32 srcOffset,
NvU32 bytes,
NvU32 flags);
/** @name OS Manager
@{*/
/** Enter Critical section, extended version.
@param id GF_CRITICAL_SECTION_xxx
*/
void GFRmOSEnterCSExt(GFRmHandle hRm, NvU32 id);
/** Exit Critical section, extended version.
@param id GF_CRITICAL_SECTION_xxx
*/
void GFRmOSExitCSExt(GFRmHandle hRm, NvU32 id);
/** Enter Hardware Access Critical section.
*/
void GFRmOSEnterCS(GFRmHandle hRm);
/** Exit Hardware Access Critical section.
*/
void GFRmOSExitCS(GFRmHandle hRm);
/** Waits for some number of milliseconds.
@param msec Number of milliseconds to wait.
*/
void GFRmOSWaitMSec(NvU32 msec);
/** Get the current OS tick counter.
@return Low 32 bits of millisecond counter.
*/
NvU32 GFRmGetTickCountMSec(void);
/** Get the current OS tick counter.
NOTE: This function is NOT guaranteed to exist on all
platforms. Drivers should NOT call this function; it's
meant only for benchmarking.
@return 64 bit microsecond counter.
*/
NvU64 GFRmGetTickCountUSec(void);
/** Waits for a keypress with a timeout, and returns the key.
@param timeOutMSec (NvU32) Milliseconds to wait for the keypress.
@retval (int) The code for the key, or zero if we timed out.
*/
int GFRmWaitKey(NvU32 timeOutMSec);
/*@}*/
/** @name Read/Write functions
We provide APIs to read and write GPU registers and memory, independent of
which bus addressing mode is in use (direct or indirect, 16 or 32).
WARNING: These functions are not safe in all cases.
1. They do not take into account handshake mode. With fixed timings it may
be unsafe, for example, to use GFRmMemRd/Wr32 to access external memory.
2. They do not take into account limitations on the # of address bits. On
some direct addressing platforms, not all the address bits are wired up,
so it is impossible to directly access all of memory. For example, it
may be unsafe to use GFRmMemRd/Wr32 to access external memory.
3. Some buses do not have full byte enable support. It is possible that
GFRmMemWr08, for example, may clobber the other byte in the word.
It is believed that the first two pitfalls only apply to external memory.
You can probably use these APIs safely to access internal memory, subject to
caveat (3) (i.e. you should stick to 16-bit or 32-bit writes). For external
memory, "use at your own risk."
@{*/
/** Read or write an 8-, 16-, or 32-bit register in the device. */
NvU8 GFRmRegRd08(GFRmHandle hRm, NvU32 offset);
NvU16 GFRmRegRd16(GFRmHandle hRm, NvU32 offset);
NvU32 GFRmRegRd32(GFRmHandle hRm, NvU32 offset);
void GFRmRegWr08(GFRmHandle hRm, NvU32 offset, NvU8 data);
void GFRmRegWr16(GFRmHandle hRm, NvU32 offset, NvU16 data);
void GFRmRegWr32(GFRmHandle hRm, NvU32 offset, NvU32 data);
/** Read or write 8, 16, or 32 bits of data to a given offset in a block of memory.
Offset is relative to the memory handle AND not the absolute one.
*/
NvU8 GFRmMemRd08(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset);
NvU16 GFRmMemRd16(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset);
NvU32 GFRmMemRd32(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset);
void GFRmMemWr08(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset, NvU8 data);
void GFRmMemWr16(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset, NvU16 data);
void GFRmMemWr32(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset, NvU32 data);
/** Read or write a region of a block of memory. Size is in bytes */
void GFRmMemRead(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset,
void *pDst, NvU32 size);
void GFRmMemWrite(GFRmHandle hRm, GFRmMemHandle hMem, NvU32 offset,
const void *pSrc, NvU32 size);
/** Fill a block of memory with a given 8-, 16-, or 32-bit word. Size is in words, not bytes */
void GFRmMemFill08(GFRmHandle hRm, GFRmMemHandle hMem,
NvU32 offset, NvU32 size, NvU8 data);
void GFRmMemFill16(GFRmHandle hRm, GFRmMemHandle hMem,
NvU32 offset, NvU32 size, NvU16 data);
void GFRmMemFill32(GFRmHandle hRm, GFRmMemHandle hMem,
NvU32 offset, NvU32 size, NvU32 data);
/** Write to a FIFO in the chip. */
void GFRmFifoWrite(GFRmHandle hRm, const void *srcPtr,
NvU32 dstOffset, NvU32 sizeIn32bits);
/** Waits for the host to idle.
@retval GF_SUCCESS on success
@retval GF_ERROR on error
*/
GF_RETTYPE
GFRmWaitForHostIdle( GFRmHandle RmHandle );
/*@}*/
/** Dispatch DSP2Host messages.
This function can be called from an IST in response to the DSP2Host
interrupt. It will perform the following sequence:
- read the DSP2Host message from the DSP2Host registers, i.e. GFRmGetMessage()
- identify DSP task from the task ID in message parameter 0
- add the message to that task's queue
- set an event registered with that task to notify it about the new message
- clear DSP2Host interrupt register, i.e. GFRmClearDspCommInterrupt()
If the task ID from the message is unknown, the interrupt is still cleared,
but the message is ignored.
@param ChHandle Channel to use, should be the protected channel (GF_PROTECTED_CHANNEL)
@return Returns the DSP task ID the received message belonged to, or 0 if unknown
*/
NvU32 GFRmDispatchMessage(GFRmChHandle ChHandle);
NvU32 GFRmDispatchMessageDual(GFRmChHandle ChHandle, NvU32 dspModule);
/** Descriptor for circular buffer in DSP memory.
This structure is intended for shared use between DSP tasks.
If GF_RM_DSP_CBUFFER::wr == GF_RM_DSP_CBUFFER::rd, the circular buffer is empty.
If GF_RM_DSP_CBUFFER::wr != GF_RM_DSP_CBUFFER::rd, the buffer contains
(wr>=rd)?wr-rd:size+wr-rd bytes of data, starting at offset rd, wrapping on the buffer end.
*/
typedef struct _GFRM_DSP_CIRCBUFFER
{
NvU8* adr; //!< buffer address, DSP address space in GPU memory
NvU32 size; //!< Buffer size in bytes
NvU32 wr; //!< Current write offset relative to buffer address
NvU32 rd; //!< Current read offset relative to buffer address
NvU32 userData[4]; //!< User defined, specific depending on usage
} GF_RM_DSP_CIRCBUFFER;
/*
* Pins that can be used as GPIOs once the corresponding module
* has been enabled
*/
typedef enum {
/* SD PINS */
GPIO_SD_PIN_DATA0 = 1,
GPIO_SD_PIN_DATA1,
GPIO_SD_PIN_DATA2,
GPIO_SD_PIN_DATA3,
GPIO_SD_PIN_CLK,
GPIO_SD_PIN_CMD,
GPIO_SD_PIN_SDGP0,
GPIO_SD_PIN_SDGP1,
/* VI PINS */
GPIO_VI_PIN_VD0,
GPIO_VI_PIN_VD1,
GPIO_VI_PIN_VD2,
GPIO_VI_PIN_VD3,
GPIO_VI_PIN_VD4,
GPIO_VI_PIN_VD5,
GPIO_VI_PIN_VD6,
GPIO_VI_PIN_VD7,
GPIO_VI_PIN_VD8,
GPIO_VI_PIN_VD9,
GPIO_VI_PIN_VD10,
GPIO_VI_PIN_VD11,
GPIO_VI_PIN_VSCK,
GPIO_VI_PIN_VHS,
GPIO_VI_PIN_VVS,
GPIO_VI_PIN_VGP0,
GPIO_VI_PIN_VGP1,
GPIO_VI_PIN_VGP2,
GPIO_VI_PIN_VGP3,
GPIO_VI_PIN_VGP4,
GPIO_VI_PIN_VGP5,
GPIO_VI_PIN_VGP6
} GFGPIOPin;
/*
* I/O options for pins
*/
typedef enum {
GPIO_OPTION_DISABLE = 1,
GPIO_OPTION_INPUT,
GPIO_OPTION_OUTPUT
} GFGPIOOption;
/*
* Enable/Disable I/O for GPIOS
*/
typedef enum {
GPIO_MODE_DISABLE = 1,
GPIO_MODE_ENABLE
} GFGPIOMode;
/*
* Pin groups whose selects are tied together
*/
typedef enum {
GPIO_SD_PINGRP_D0_CLK_CMD = 1,
GPIO_SD_PINGRP_D1_D2
} GFGPIOPinGrp;
/*
* Pin select for GPIOS
*/
typedef enum {
GPIO_SELECT_GPIO = 1,
GPIO_SELECT_FUNC
} GFGPIOSelect;
/**
*
* Sets all the pins of a specific module to GPIO mode
*
* @param RmHandle Handle specific to the GFRm
* @param modid Module
*
* @return GF_SUCCESS on success
*
*/
GF_RETTYPE
GFRmGPIOEnable(GFRmHandle RmHandle, eGFModuleIDs modid);
/**
* Initializes the GPIO API
*
*
* @param RmHandle Handle specific to the GFRm
* @param modid Module
*
* @return GF_SUCCESS on success
*
*/
GF_RETTYPE
GFRmGPIODisable(GFRmHandle RmHandle, eGFModuleIDs modid);
/**
*
* Modifies the pin's input/output modes
*
* @param ChHandle Channel to write to modules through
* @param pin Pin to set
* @param options One of GPIO_OPTION_DISABLE (ignores mode),
* GPIO_OPTION_INPUT, GPIO_OPTION_OUTPUT
* @param mode One of GPIO_MODE_ENABLE, GPIO_MODE_DISABLE
*
* @return GF_SUCCESS on success
*
*/
GF_RETTYPE
GFRmGPIOSetPinMode(GFRmChHandle ChHandle, GFGPIOPin pin, GFGPIOOption option, GFGPIOMode mode);
/**
*
* Sets a particular pin's output select
*
* @param ChHandle Channel to write to modules through
* @param pin Pin to set
* @param select One of GPIO_SELECT_GPIO, GPIO_SELECT_FUNC
*
* @return GF_SUCCESS on success
*
*/
GF_RETTYPE
GFRmGPIOSetPinSelect(GFRmChHandle ChHandle, GFGPIOPin pin, GFGPIOSelect select);
/**
*
* Sets a particular pin group's output select
*
* @param ChHandle Channel to write to modules through
* @param group Pin group to set
* @param select One of GPIO_SELECT_GPIO, GPIO_SELECT_FUNC
*
* @return GF_SUCCESS on success
*
*/
GF_RETTYPE
GFRmGPIOSetPinGrpSelect(GFRmChHandle ChHandle, GFGPIOPinGrp group, GFGPIOSelect select);
/**
*
* Sets the status (high/low) of a pin
*
* @param ChHandle Channel to write to modules through
* @param pin Pin to set
* @param value Value to write to pin
*
*/
void
GFRmGPIOSetPin(GFRmChHandle ChHandle, GFGPIOPin pin, NvU8 value);
/**
* Gets the status (high/low) of a pin
*
* @param ChHandle Channel to write to modules through
* @param pin Pin to set
*
* @return Status (high/low) of pin
*
*/
NvU32
GFRmGPIOGetPin(GFRmChHandle ChHandle, GFGPIOPin pin);
/** @ name Bootflags
List of flags inidicating all the devices which are booted
@{*/
/** Chip is initalized in other words IxInit is called */
#define GFRM_BOOT_IXINIT 0x1
/** Display is initalized */
#define GFRM_BOOT_DXINIT 0x2
/*@}*/
/**
* Writes to some scratch register with a log of all the components which are
* initalized. GFRM_BOOT_* are passed as bootflags.
*/
GF_RETTYPE GFRmBootPostInit(GFRmHandle hRm, NvU32 bootflags);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/*@}*/
/** @page pageRmAppNotes RmAPI Application Notes
@section pageRmAppNotes1 Todo
*/
#endif /* __GFRM_H__ */