Video - Megatokio/kilipili GitHub Wiki

Video, VGA and VideoPlanes

Lib kilipili currently supports video output to VGA only.
DVI / HDMI will come shortly. (i hope)
The video related stuff is in the submodule kilipili_video in the Video/ folder.
Everything video related lives in the namespace kilipili::Video.

The VideoController:


struct VgaMode

header file: Video/VgaMode.h

This struct contains all timing data for a specific VGA mode. The header file contains definitions for the standard and some non-standard VGA modes. The names should be self-explanatory:

  vga_mode_640x480_60
  vga_mode_320x240_60: half-size version
  vga_mode_160x120_60: quarter-size version

  vga_mode_800x600_60
  vga_mode_400x300_60
  vga_mode_200x150_60

  vga_mode_1024x768_60
  vga_mode_512x384_60
  vga_mode_256x192_60

  vga_mode_1280x768_60
  vga_mode_640x384_60
  vga_mode_320x192_60

  vga_mode_1360x768_60: this is VESA mode 1366*768@60Hz REDUCED BLANKING

  50 Hz modes. All non-standard!:
  vga_mode_640x480_50
  vga_mode_320x240_50
  vga_mode_1024x768_50
  vga_mode_512x384_50

The larger the screen the higher the CPU clock needs to be to display anything useful.
The standard Pixmap based mode with true color attributes colormode_a1w8 displays properly up to vga_mode_1024x768_60 in release builds. (at 280 MHz)
The standard character based mode (with foreground & background indexed colors, bold and underline attributes) displays up to vga_mode_800x600_60 in release build. (at 260 MHz)

The currently active video mode is visible in the global variable vga_mode. (read-only!)
The program can define and set it's own video mode.

Video Frontend

header file: Video/Video.h

Functions:

  void startVideo(VgaMode, system_clock, scanline_buffer_count)
  void stopVideo()
  bool isVideoRunning()

  void addVideoPlane(VideoPlanePtr, bool wait)
  void removeVideoPlane(VideoPlanePtr, bool wait)
  void setVBlankAction(const VBlankAction& fu)
  void addOneTimeAction(const OneTimeAction& fu)

  void waitForVBlank()
  void waitForScanline(int scanline)
  int current_scanline()

VideoBackend

header file: Video/VideoBackend.h

Many settings are read from the board header file in boards/.
In addition the CMakeLists.txt file defines some settings which are converted into #defines:

  • VIDEO_OPTIMISTIC_A1W8 = ON|OFF default: OFF
    The scanline renderer for colormode_a1w8 (1-bit pixmap with 8 pixel wide truecolor attributes) can use a variant which optimizes it's output based on the screen contents. This allows highest video resolution up to 1280\*768 to be displayed if the screen contents are not too colorful. Else the video display will become corrupted, showing rolling screen contents displayed as the pixel supply can't catch up. Because the additional test takes time, the overall time (read: cpu load) for the worst case becomes even longer.
    Specifically 1024\*768 can not be guaranteed to display colorful contents properly, while 1024\*768 can just be displayed – and guaranteed to be displayed regardless of the contents – without optimization.
  • VIDEO_SUPPORT_200x150_A1W8
  • VIDEO_SUPPORT_400x300_A1W8 Default: ON
    File: ScanlineRenderer.h
    This extremely small screen sizes result in screen data not aligned to int32 boundary. The standard renderer for colormode_a1w8 is optimized for int32 aligned screen data. In order to display this colormode in these screen sizes slightly less optimized scanline renderers must be used. If you don't use colormode_a1w8 in these screen sizes you can turn support OFF. The default is ON because they will buserror if used anyway.
  • VIDEO_MAX_SYSCLOCK_MHz Default: 290 MHz
    Upper limit for the system clock set by start_video_backend()
  • VIDEO_MAX_SCANLINE_BUFFERS Default: 16
    Maximum size of the rolling scanline buffer. See ScanlineBuffer.h. The default should be good in most cases. Can be reduced to desperately save a few bytes of RAM. It defines the size of an array of pointers.
⚠️ **GitHub.com Fallback** ⚠️