PowerBlocks SDK
 
Loading...
Searching...
No Matches
video.c File Reference

Manages the video output of the system. More...

#include "video.h"
#include "system/system.h"
#include "system/exceptions.h"
#include "ios/ios_settings.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "utils/log.h"
#include <string.h>

Macros

#define VI_BASE   0xcc002000
 
#define VI_VTR   (*(volatile uint16_t*)0xcc002000)
 
#define VI_DCR   (*(volatile uint16_t*)0xCC002002)
 
#define VI_HTR0   (*(volatile uint32_t*)0xCC002004)
 
#define VI_HTR1   (*(volatile uint32_t*)0xCC002008)
 
#define VI_VTO   (*(volatile uint32_t*)0xCC00200C)
 
#define VI_VTE   (*(volatile uint32_t*)0xCC002010)
 
#define VI_BBEI   (*(volatile uint32_t*)0xCC002014)
 
#define VI_BBOI   (*(volatile uint32_t*)0xCC002018)
 
#define VI_TFBL   (*(volatile uint32_t*)0xCC00201c)
 
#define VI_TFBR   (*(volatile uint32_t*)0xCC002020)
 
#define VI_BFBL   (*(volatile uint32_t*)0xCC002024)
 
#define VI_BFBR   (*(volatile uint32_t*)0xCC002028)
 
#define VI_DPV   (*(volatile uint16_t*)0xCC00202C)
 
#define VI_DI0   (*(volatile uint32_t*)0xCC002030)
 
#define VI_DI1   (*(volatile uint32_t*)0xCC002034)
 
#define VI_DI2   (*(volatile uint32_t*)0xCC002038)
 
#define VI_DI3   (*(volatile uint32_t*)0xCC00203C)
 
#define VI_DTV   (*(volatile uint32_t*)0xCC00206E)
 
#define VI_DCR_ENABLE   (1<<0)
 
#define VI_DCR_RESET   (1<<1)
 
#define VI_DCR_PROGRESSIVE   (1<<2)
 
#define VI_DCR_3D_MODE   (1<<3)
 
#define VI_DCR_LATCH_0(x)
 
#define VI_DCR_LATCH_1(x)
 
#define VI_DCR_FORMAT(x)
 
#define VI_DTV_GPIO_COMPONENT_CABLE   (1<<0)
 
#define VI_DCR_LATCH_OFF   0
 
#define VI_DCR_LATCH_PAL   1
 
#define VI_DCR_LATCH_MPAL   2
 
#define VI_DCR_LATCH_DEBUG   3
 
#define VI_DCR_FORMAT_NTSC   0
 
#define VI_DCR_FORMAT_PAL   1
 
#define VI_DCR_FORMAT_MPAL   2
 
#define VI_DCR_FORMAT_RESERVED   3
 
#define VI_DI_STATUS   (1<<31)
 
#define VI_DI_ENABLE   (1<<28)
 

Functions

video_mode_t video_system_default_video_mode ()
 Gets the video mode of the console.
 
const video_profile_tvideo_get_profile (video_mode_t mode)
 Gets a video profile from a video mode.
 
void video_initialize (video_mode_t mode)
 Initializes the video output.
 
void video_set_framebuffer (const framebuffer_t *framebuffer)
 Sets the frame buffer presented to the screen.
 
framebuffer_tvideo_get_framebuffer ()
 Gets the frame buffer currently displayed.
 
void video_wait_vsync ()
 Waits for the next vsync with interrupts.
 
void video_wait_vsync_int ()
 Waits for the next vsync without interrupts.
 
void video_set_retrace_callback (video_retrace_callback_t callback)
 Sets the retrace callback.
 

Detailed Description

Manages the video output of the system.

Interacts and initializes the video interface. Has functions for working with VSync, creating and using framebuffers.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Macro Definition Documentation

◆ VI_DCR_FORMAT

#define VI_DCR_FORMAT ( x)
Value:
(((x) & 0b11) << 8)

◆ VI_DCR_LATCH_0

#define VI_DCR_LATCH_0 ( x)
Value:
(((x) & 0b11) << 4)

◆ VI_DCR_LATCH_1

#define VI_DCR_LATCH_1 ( x)
Value:
(((x) & 0b11) << 6)

Function Documentation

◆ video_get_framebuffer()

framebuffer_t * video_get_framebuffer ( )

Gets the frame buffer currently displayed.

Gets the frame buffer currently displayed. Can be used for some interesting functionality.

◆ video_get_profile()

const video_profile_t * video_get_profile ( video_mode_t mode)

Gets a video profile from a video mode.

Get a video profile from a video mode.

Parameters
profileMode to set into.

◆ video_initialize()

void video_initialize ( video_mode_t mode)

Initializes the video output.

Initializes the video interface with a given video mode.

Parameters
modeMode for the video interface.

◆ video_set_framebuffer()

void video_set_framebuffer ( const framebuffer_t * framebuffer)

Sets the frame buffer presented to the screen.

Sets the frame buffer presented to the screen.

Parameters
framebufferFramebuffer to put to the screen.

◆ video_set_retrace_callback()

void video_set_retrace_callback ( video_retrace_callback_t callback)

Sets the retrace callback.

This is called from the interrupt handler for the retrace from the video interface. Make sure to handle code coming from an interrupter appropriately.

Parameters
callbackFunction pointer to call on retrace.

◆ video_system_default_video_mode()

video_mode_t video_system_default_video_mode ( )

Gets the video mode of the console.

Looks at the system settings to get the system video mode.

Must be called AFTER ios_initialize.

This function is unfinished. I need dumps of the other video modes.

Returns
Default video mode.

◆ video_wait_vsync()

void video_wait_vsync ( )

Waits for the next vsync with interrupts.

Waits for the next vsync, waits for the next display interrupt to measure when the display goes into retrace.

◆ video_wait_vsync_int()

void video_wait_vsync_int ( )

Waits for the next vsync without interrupts.

Waits for the next vsync, in a interrupt handler safe way. It does by just waiting till the vertical position is in range.

This function seems to have some issues, make sure it actually works. May or may not be an emulator thing.