RetroArch
Classes | Macros | Typedefs | Functions | Variables
video.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "asm.h"
#include "processor.h"
#include "ogcsys.h"
#include "irq.h"
#include "exi.h"
#include "gx.h"
#include "si.h"
#include "lwp.h"
#include "system.h"
#include "video.h"
#include "video_types.h"
Include dependency graph for video.c:

Classes

struct  _horVer
 
struct  _timing
 

Macros

#define VIDEO_MQ   1
 
#define _SHIFTL(v, s, w)   ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))
 
#define _SHIFTR(v, s, w)   ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))
 
#define VI_REGCHANGE(_reg)   ((u64)0x01<<(63-_reg))
 

Typedefs

typedef struct _horVer horVer
 

Functions

syssram__SYS_LockSram ()
 
u32 __SYS_UnlockSram (u32 write)
 
void __VIClearFramebuffer (void *, u32, u32)
 
void udelay (int us)
 
static __inline__ u32 cntlzd (u64 bit)
 
static const struct _timing__gettiming (u32 vimode)
 
static void __setInterruptRegs (const struct _timing *tm)
 
static void __setPicConfig (u16 fbSizeX, u32 xfbMode, u16 panPosX, u16 panSizeX, u8 *wordPerLine, u8 *std, u8 *wpl, u8 *xof)
 
static void __setBBIntervalRegs (const struct _timing *tm)
 
static void __setScalingRegs (u16 panSizeX, u16 dispSizeX, s32 threeD)
 
static void __calcFbbs (u32 bufAddr, u16 panPosX, u16 panPosY, u8 wordperline, u32 xfbMode, u16 dispPosY, u32 *tfbb, u32 *bfbb)
 
static void __setFbbRegs (struct _horVer *horVer, u32 *tfbb, u32 *bfbb, u32 *rtfbb, u32 *rbfbb)
 
static void __setHorizontalRegs (const struct _timing *tm, u16 dispPosX, u16 dispSizeX)
 
static void __setVerticalRegs (u16 dispPosY, u16 dispSizeY, u8 equ, u16 acv, u16 prbOdd, u16 prbEven, u16 psbOdd, u16 psbEven, s32 black)
 
static void __adjustPosition (u16 acv)
 
static void __importAdjustingValues ()
 
static void __VIInit (u32 vimode)
 
static void __getCurrentDisplayPosition (u32 *px, u32 *py)
 
static u32 __getCurrentHalfLine ()
 
static u32 __getCurrentFieldEvenOdd ()
 
static u32 __VISetRegs ()
 
static void __VIDisplayPositionToXY (s32 xpos, s32 ypos, s32 *px, s32 *py)
 
static void __VIGetCurrentPosition (s32 *px, s32 *py)
 
static void __VIRetraceHandler (u32 nIrq, void *pCtx)
 
voidVIDEO_GetNextFramebuffer ()
 
voidVIDEO_GetCurrentFramebuffer ()
 
void VIDEO_Init ()
 Initializes the VIDEO subsystem. This call should be done in the early stages of your main() More...
 
void VIDEO_Configure (GXRModeObj *rmode)
 Configure the VI with the given render mode object. More...
 
void VIDEO_WaitVSync (void)
 Wait on the next vertical retrace. More...
 
void VIDEO_SetFramebuffer (void *fb)
 
void VIDEO_SetNextFramebuffer (void *fb)
 Set the framebuffer for the next VI register update. More...
 
void VIDEO_SetNextRightFramebuffer (void *fb)
 Set the right framebuffer for the next VI register update. This is used for 3D Gloves for instance. More...
 
void VIDEO_Flush ()
 Flush the shadow registers to the drivers video registers. More...
 
void VIDEO_SetBlack (bool black)
 Blackout the VIDEO interface. More...
 
u32 VIDEO_GetNextField ()
 Get the next field in DS mode. More...
 
u32 VIDEO_GetCurrentTvMode ()
 Get current configured TV mode. More...
 
GXRModeObjVIDEO_GetPreferredMode (GXRModeObj *mode)
 
u32 VIDEO_GetCurrentLine ()
 Get current video line. More...
 
VIRetraceCallback VIDEO_SetPreRetraceCallback (VIRetraceCallback callback)
 Set the Pre-Retrace callback function. This function is called within the video interrupt handler before the VI registers will be updated. More...
 
VIRetraceCallback VIDEO_SetPostRetraceCallback (VIRetraceCallback callback)
 Set the Post-Retrace callback function. This function is called within the video interrupt handler after the VI registers are updated. More...
 
u32 VIDEO_GetFrameBufferSize (GXRModeObj *rmode)
 
void VIDEO_ClearFrameBuffer (GXRModeObj *rmode, void *fb, u32 color)
 Clear the given framebuffer. More...
 
u32 VIDEO_HaveComponentCable (void)
 Check for a component cable. This function returns 1 when a Component (YPbPr) cable is connected. More...
 

Variables

GXRModeObj TVNtsc240Ds
 
GXRModeObj TVNtsc240DsAa
 
GXRModeObj TVNtsc240Int
 
GXRModeObj TVNtsc240IntAa
 
GXRModeObj TVNtsc480Int
 
GXRModeObj TVNtsc480IntDf
 
GXRModeObj TVNtsc480IntAa
 
GXRModeObj TVNtsc480Prog
 
GXRModeObj TVNtsc480ProgSoft
 
GXRModeObj TVNtsc480ProgAa
 
GXRModeObj TVMpal240Ds
 
GXRModeObj TVMpal240DsAa
 
GXRModeObj TVMpal480IntDf
 
GXRModeObj TVMpal480IntAa
 
GXRModeObj TVMpal480Prog
 
GXRModeObj TVPal264Ds
 
GXRModeObj TVPal264DsAa
 
GXRModeObj TVPal264Int
 
GXRModeObj TVPal264IntAa
 
GXRModeObj TVPal524IntAa
 
GXRModeObj TVPal528Int
 
GXRModeObj TVPal528IntDf
 
GXRModeObj TVPal576IntDfScale
 
GXRModeObj TVPal576ProgScale
 
GXRModeObj TVEurgb60Hz240Ds
 
GXRModeObj TVEurgb60Hz240DsAa
 
GXRModeObj TVEurgb60Hz240Int
 
GXRModeObj TVEurgb60Hz240IntAa
 
GXRModeObj TVEurgb60Hz480Int
 
GXRModeObj TVEurgb60Hz480IntDf
 
GXRModeObj TVEurgb60Hz480IntAa
 
GXRModeObj TVEurgb60Hz480Prog
 
GXRModeObj TVEurgb60Hz480ProgSoft
 
GXRModeObj TVEurgb60Hz480ProgAa
 
static const u16 taps [26]
 
static const struct _timing video_timing []
 
static u16 regs [60]
 
static u16 shdw_regs [60]
 
static u32 fbSet = 0
 
static s16 displayOffsetH
 
static s16 displayOffsetV
 
static u32 currTvMode
 
static u32 changeMode
 
static u32 shdw_changeMode
 
static u32 flushFlag
 
static u64 changed
 
static u64 shdw_changed
 
static vu32 retraceCount
 
static const struct _timingcurrTiming
 
static lwpq_t video_queue
 
static horVer HorVer
 
static voidcurrentFb = NULL
 
static voidnextFb = NULL
 
static VIRetraceCallback preRetraceCB = NULL
 
static VIRetraceCallback postRetraceCB = NULL
 
static VIPositionCallback positionCB = NULL
 
static vu16 *const _viReg = (u16*)0xCC002000
 

Macro Definition Documentation

◆ _SHIFTL

#define _SHIFTL (   v,
  s,
  w 
)    ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s)))

◆ _SHIFTR

#define _SHIFTR (   v,
  s,
  w 
)    ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1)))

◆ VI_REGCHANGE

#define VI_REGCHANGE (   _reg)    ((u64)0x01<<(63-_reg))

◆ VIDEO_MQ

#define VIDEO_MQ   1

Typedef Documentation

◆ horVer

typedef struct _horVer horVer

Function Documentation

◆ __adjustPosition()

static void __adjustPosition ( u16  acv)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __calcFbbs()

static void __calcFbbs ( u32  bufAddr,
u16  panPosX,
u16  panPosY,
u8  wordperline,
u32  xfbMode,
u16  dispPosY,
u32 tfbb,
u32 bfbb 
)
inlinestatic
Here is the caller graph for this function:

◆ __getCurrentDisplayPosition()

static void __getCurrentDisplayPosition ( u32 px,
u32 py 
)
inlinestatic
Here is the caller graph for this function:

◆ __getCurrentFieldEvenOdd()

static u32 __getCurrentFieldEvenOdd ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __getCurrentHalfLine()

static u32 __getCurrentHalfLine ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __gettiming()

static const struct _timing* __gettiming ( u32  vimode)
static
Here is the caller graph for this function:

◆ __importAdjustingValues()

static void __importAdjustingValues ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __setBBIntervalRegs()

static void __setBBIntervalRegs ( const struct _timing tm)
inlinestatic
Here is the caller graph for this function:

◆ __setFbbRegs()

static void __setFbbRegs ( struct _horVer horVer,
u32 tfbb,
u32 bfbb,
u32 rtfbb,
u32 rbfbb 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __setHorizontalRegs()

static void __setHorizontalRegs ( const struct _timing tm,
u16  dispPosX,
u16  dispSizeX 
)
inlinestatic
Here is the caller graph for this function:

◆ __setInterruptRegs()

static void __setInterruptRegs ( const struct _timing tm)
inlinestatic
Here is the caller graph for this function:

◆ __setPicConfig()

static void __setPicConfig ( u16  fbSizeX,
u32  xfbMode,
u16  panPosX,
u16  panSizeX,
u8 wordPerLine,
u8 std,
u8 wpl,
u8 xof 
)
inlinestatic
Here is the caller graph for this function:

◆ __setScalingRegs()

static void __setScalingRegs ( u16  panSizeX,
u16  dispSizeX,
s32  threeD 
)
static
Here is the caller graph for this function:

◆ __setVerticalRegs()

static void __setVerticalRegs ( u16  dispPosY,
u16  dispSizeY,
u8  equ,
u16  acv,
u16  prbOdd,
u16  prbEven,
u16  psbOdd,
u16  psbEven,
s32  black 
)
inlinestatic
Here is the caller graph for this function:

◆ __SYS_LockSram()

syssram* __SYS_LockSram ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __SYS_UnlockSram()

u32 __SYS_UnlockSram ( u32  write)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __VIClearFramebuffer()

void __VIClearFramebuffer ( void ,
u32  ,
u32   
)
Here is the caller graph for this function:

◆ __VIDisplayPositionToXY()

static void __VIDisplayPositionToXY ( s32  xpos,
s32  ypos,
s32 px,
s32 py 
)
static
Here is the caller graph for this function:

◆ __VIGetCurrentPosition()

static void __VIGetCurrentPosition ( s32 px,
s32 py 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __VIInit()

static void __VIInit ( u32  vimode)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __VIRetraceHandler()

static void __VIRetraceHandler ( u32  nIrq,
void pCtx 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __VISetRegs()

static u32 __VISetRegs ( )
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cntlzd()

static __inline__ u32 cntlzd ( u64  bit)
static
Here is the caller graph for this function:

◆ udelay()

void udelay ( int  us)

◆ VIDEO_ClearFrameBuffer()

void VIDEO_ClearFrameBuffer ( GXRModeObj rmode,
void fb,
u32  color 
)

Clear the given framebuffer.

Parameters
[in]rmodepointer to a GXRModeObj, specifying the mode.
[in]fbpointer to the startaddress of the framebuffer to clear.
[in]colorYUYUV value to use for clearing.
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_Configure()

void VIDEO_Configure ( GXRModeObj rmode)

Configure the VI with the given render mode object.

Parameters
[in]rmodepointer to the video/render mode configuration.
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_Flush()

void VIDEO_Flush ( )

Flush the shadow registers to the drivers video registers.

Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_GetCurrentFramebuffer()

void* VIDEO_GetCurrentFramebuffer ( )
Here is the caller graph for this function:

◆ VIDEO_GetCurrentLine()

u32 VIDEO_GetCurrentLine ( )

Get current video line.

Returns
linenumber
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_GetCurrentTvMode()

u32 VIDEO_GetCurrentTvMode ( )

Get current configured TV mode.

Returns
tvmode
Here is the caller graph for this function:

◆ VIDEO_GetFrameBufferSize()

u32 VIDEO_GetFrameBufferSize ( GXRModeObj rmode)
Here is the caller graph for this function:

◆ VIDEO_GetNextField()

u32 VIDEO_GetNextField ( )

Get the next field in DS mode.

Returns
field
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_GetNextFramebuffer()

void* VIDEO_GetNextFramebuffer ( )

◆ VIDEO_GetPreferredMode()

GXRModeObj* VIDEO_GetPreferredMode ( GXRModeObj mode)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_HaveComponentCable()

u32 VIDEO_HaveComponentCable ( void  )

Check for a component cable. This function returns 1 when a Component (YPbPr) cable is connected.

Returns
1 if a component cable is connected, 0 otherwise
Here is the caller graph for this function:

◆ VIDEO_Init()

void VIDEO_Init ( )

Initializes the VIDEO subsystem. This call should be done in the early stages of your main()

Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_SetBlack()

void VIDEO_SetBlack ( bool  black)

Blackout the VIDEO interface.

Parameters
[in]blackBoolean flag to determine whether to blackout the VI or not.
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_SetFramebuffer()

void VIDEO_SetFramebuffer ( void fb)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_SetNextFramebuffer()

void VIDEO_SetNextFramebuffer ( void fb)

Set the framebuffer for the next VI register update.

Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_SetNextRightFramebuffer()

void VIDEO_SetNextRightFramebuffer ( void fb)

Set the right framebuffer for the next VI register update. This is used for 3D Gloves for instance.

Returns
none
Here is the call graph for this function:

◆ VIDEO_SetPostRetraceCallback()

VIRetraceCallback VIDEO_SetPostRetraceCallback ( VIRetraceCallback  callback)

Set the Post-Retrace callback function. This function is called within the video interrupt handler after the VI registers are updated.

Parameters
[in]callbackpointer to the callback function which is called at post-retrace.
Returns
Old post-retrace callback or NULL
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VIDEO_SetPreRetraceCallback()

VIRetraceCallback VIDEO_SetPreRetraceCallback ( VIRetraceCallback  callback)

Set the Pre-Retrace callback function. This function is called within the video interrupt handler before the VI registers will be updated.

Parameters
[in]callbackpointer to the callback function which is called at pre-retrace.
Returns
Old pre-retrace callback or NULL
Here is the call graph for this function:

◆ VIDEO_WaitVSync()

void VIDEO_WaitVSync ( void  )

Wait on the next vertical retrace.

Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _viReg

vu16* const _viReg = (u16*)0xCC002000
static

◆ changed

u64 changed
static

◆ changeMode

u32 changeMode
static

◆ currentFb

void* currentFb = NULL
static

◆ currTiming

const struct _timing* currTiming
static

◆ currTvMode

u32 currTvMode
static

◆ displayOffsetH

s16 displayOffsetH
static

◆ displayOffsetV

s16 displayOffsetV
static

◆ fbSet

u32 fbSet = 0
static

◆ flushFlag

u32 flushFlag
static

◆ HorVer

horVer HorVer
static

◆ nextFb

void* nextFb = NULL
static

◆ positionCB

VIPositionCallback positionCB = NULL
static

◆ postRetraceCB

VIRetraceCallback postRetraceCB = NULL
static

◆ preRetraceCB

VIRetraceCallback preRetraceCB = NULL
static

◆ regs

u16 regs[60]
static

◆ retraceCount

vu32 retraceCount
static

◆ shdw_changed

u64 shdw_changed
static

◆ shdw_changeMode

u32 shdw_changeMode
static

◆ shdw_regs

u16 shdw_regs[60]
static

◆ taps

const u16 taps[26]
static
Initial value:
= {
0x01F0,0x01DC,0x01AE,0x0174,0x0129,0x00DB,
0x008E,0x0046,0x000C,0x00E2,0x00CB,0x00C0,
0x00C4,0x00CF,0x00DE,0x00EC,0x00FC,0x0008,
0x000F,0x0013,0x0013,0x000F,0x000C,0x0008,
0x0001,0x0000
}

◆ video_queue

lwpq_t video_queue
static

◆ video_timing

const struct _timing video_timing[]
static