PicoVGA  1.0-cmake
VGA/TV display on Raspberry Pico
vga_vmode.h
Go to the documentation of this file.
1 
8 #ifndef _VGA_VMODE_H
9 #define _VGA_VMODE_H
10 
28 #define VIDEO_NAME_LEN 5
29 
30 typedef struct {
32  // horizontal
33  float htot;
34  float hfront;
35  float hsync;
36  float hback;
37  float hfull;
38 
39  // vertical
40  u16 vtot;
41  u16 vmax;
42 
43  // subframe 1
44  u16 vsync1;
45  u16 vpost1;
46  u16 vback1;
47  u16 vact1;
48  u16 vfront1;
49  u16 vpre1;
50 
51  // subframe 2 (ignored if not interlaced)
52  u16 vsync2;
53  u16 vpost2;
54  u16 vback2;
55  u16 vact2;
56  u16 vfront2;
57  u16 vpre2;
58 
59  // name
60  const char* name;
61 
62  // flags
63  bool inter;
64  bool psync;
65  bool odd;
66 } sVideo;
67 
68 
69 // === TV videomodes
70 
72 extern const sVideo VideoPAL;
73 
75 extern const sVideo VideoPALp;
76 
78 extern const sVideo VideoNTSC;
79 
81 extern const sVideo VideoNTSCp;
82 
83 // === Monitor videomodes
84 
86 extern const sVideo VideoEGA;
87 
89 extern const sVideo VideoVGA;
90 
92 extern const sVideo VideoSVGA;
93 
95 extern const sVideo VideoXGA;
96 
98 extern const sVideo VideoVESA;
99 
101 extern const sVideo VideoHD;
102 
104 typedef struct {
105  u16 width;
106  u16 height;
107  u16 wfull;
108  const sVideo* video;
109  u32 freq;
110  u32 fmax;
111  u8 mode[LAYERS_MAX];
112  bool dbly;
115  bool lockfreq;
116 } sVgaCfg;
117 
119 typedef struct {
120  // screen resolution
121  u16 width;
122  u16 height;
123  u16 wfull;
124  u16 wmax;
125 
126  // setup PLL system clock
127  u32 freq;
128  u32 vco;
129  u16 fbdiv;
130  u8 pd1;
131  u8 pd2;
132 
133  // setup PIO state machine
134  u16 div;
135  u16 cpp;
136  u8 prog;
137  u8 mode[LAYERS_MAX];
138 
139  // horizontal timings
140  u16 htot;
141  u16 hfront;
142  u16 hsync;
143  u16 hback;
144  float hfreq;
145 
146  // vertical timings
147  u16 vtot;
148  u16 vmax;
149  float vfreq;
150 
151  // subframe 1
152  u16 vsync1;
153  u16 vpost1;
154  u16 vback1;
155  u16 vact1;
156  u16 vfront1;
157  u16 vpre1;
158  u16 vfirst1;
159 
160  // subframe 2 (ignored if not interlaced)
161  u16 vsync2;
162  u16 vpost2;
163  u16 vback2;
164  u16 vact2;
165  u16 vfront2;
166  u16 vpre2;
167  u16 vfirst2;
168 
169  // name
170  const char* name;
171 
172  // flags
173  bool lockfreq;
174  bool dbly;
175  bool inter;
176  bool psync;
177  bool odd;
178 } sVmode;
179 
181 enum {
182  DEV_PAL = 0,
185 
186  DEV_MAX
187 };
188 
190 enum {
191  RES_ZX = 0,
199 
200  RES_MAX
201 };
202 
204 enum {
205  FORM_8BIT = 0,
220 
221  FORM_MAX
222 };
223 
224 extern sVmode Vmode;
225 extern sVgaCfg Cfg;
226 extern sCanvas Canvas;
227 
229 extern u16 Pal16Trans[256];
230 
237 void VgaCfgDef(sVgaCfg* cfg);
238 
243 void VgaPrintCfg(const sVmode* vmode);
244 
251 void VgaCfg(const sVgaCfg* cfg, sVmode* vmode);
252 
254 
257 
275 void Video(u8 dev, u8 res, u8 form, u8* buf, const void* buf2 = FontBoldB8x16);
276 
278 
279 
280 #endif // _VGA_VMODE_H
RES_HD
@ RES_HD
1280x960 (not for TV device)
Definition: vga_vmode.h:198
sVmode::htot
u16 htot
Total state machine clocks per line.
Definition: vga_vmode.h:140
sVideo::hsync
float hsync
Horizontal sync pulse in [us].
Definition: vga_vmode.h:35
sVideo::vmax
u16 vmax
Vertical maximal height.
Definition: vga_vmode.h:41
sVgaCfg::wfull
u16 wfull
Width of full screen, corresponding to 'hfull' time (0=use 'width' parameter)
Definition: vga_vmode.h:107
sVmode::odd
bool odd
First sub-frame is odd lines 1, 3, 5,... (PAL)
Definition: vga_vmode.h:177
FORM_TILE32
@ FORM_TILE32
32x32 tiles
Definition: vga_vmode.h:212
sVmode::vpre2
u16 vpre2
V sync pre half-pulses on subframe 2.
Definition: vga_vmode.h:166
RES_QVGA
@ RES_QVGA
320x240
Definition: vga_vmode.h:193
sVideo::vpost1
u16 vpost1
V sync post half-pulses on subframe 1.
Definition: vga_vmode.h:45
RES_EGA
@ RES_EGA
512x400
Definition: vga_vmode.h:194
VgaPrintCfg
void VgaPrintCfg(const sVmode *vmode)
Debug print videomode setup.
Definition: vga_vmode.cpp:485
sVmode::lockfreq
bool lockfreq
Lock current frequency, do not change it.
Definition: vga_vmode.h:173
FORM_RLE
@ FORM_RLE
images with RLE compression (on overlapped layer 1)
Definition: vga_vmode.h:219
sVmode::name
const char * name
Video timing name (VIDEO_NAME_LEN characters + terminating 0)
Definition: vga_vmode.h:170
DEV_VGA
@ DEV_VGA
VGA monitor.
Definition: vga_vmode.h:184
sVmode::pd1
u8 pd1
postdiv1
Definition: vga_vmode.h:130
sVideo
Video timings structure.
Definition: vga_vmode.h:31
sVmode::vpost1
u16 vpost1
V sync post (half-)pulses on subframe 1.
Definition: vga_vmode.h:153
sVmode::vsync1
u16 vsync1
V sync (half-)pulses on subframe 1.
Definition: vga_vmode.h:152
sVmode::freq
u32 freq
system clock frequency in kHz
Definition: vga_vmode.h:127
sVmode::vfront2
u16 vfront2
V front porch (after image, before VSYNC) on subframe 2.
Definition: vga_vmode.h:165
FORM_TILE16
@ FORM_TILE16
16x16 tiles
Definition: vga_vmode.h:210
sVmode::vact2
u16 vact2
active visible scanlines, subframe 2
Definition: vga_vmode.h:164
sVmode::psync
bool psync
Positive synchronization.
Definition: vga_vmode.h:176
sVmode::vco
u32 vco
VCO frequency in kHz.
Definition: vga_vmode.h:128
sVmode::vfirst1
u16 vfirst1
first active scanline, subframe 1
Definition: vga_vmode.h:158
sVmode::vpost2
u16 vpost2
V sync post half-pulses on subframe 2.
Definition: vga_vmode.h:162
sVideo::hback
float hback
Horizontal back porch (after HSYNC, before image) in [us].
Definition: vga_vmode.h:36
DEV_PAL
@ DEV_PAL
PAL TV.
Definition: vga_vmode.h:182
sVgaCfg::fmax
u32 fmax
Maximal system frequency in kHz (limit resolution if needed)
Definition: vga_vmode.h:110
FORM_MONO
@ FORM_MONO
1-bit pixel graphics
Definition: vga_vmode.h:207
sVideo::vact2
u16 vact2
active visible scanlines, subframe 2
Definition: vga_vmode.h:55
sVmode::vfront1
u16 vfront1
V front porch (after image, before VSYNC) on subframe 1.
Definition: vga_vmode.h:156
FORM_TILE64
@ FORM_TILE64
64x64 tiles
Definition: vga_vmode.h:214
sVideo::vfront2
u16 vfront2
V front porch (after image, before VSYNC) on subframe 2.
Definition: vga_vmode.h:56
sVideo::name
const char * name
video timing name (VIDEO_NAME_LEN characters + terminating 0)
Definition: vga_vmode.h:60
sVmode::div
u16 div
PIO divide base state machine clock.
Definition: vga_vmode.h:134
VgaCfg
void VgaCfg(const sVgaCfg *cfg, sVmode *vmode)
Calculate the structure for setting up the video mode.
Definition: vga_vmode.cpp:502
sVmode::vfirst2
u16 vfirst2
first active scanline, subframe 2
Definition: vga_vmode.h:167
sVideo::vpre1
u16 vpre1
V sync pre half-pulses on subframe 1.
Definition: vga_vmode.h:49
Video
void Video(u8 dev, u8 res, u8 form, u8 *buf, const void *buf2=FontBoldB8x16)
Simplified initialization of the video mode.
Definition: vga_vmode.cpp:770
VgaCfgDef
void VgaCfgDef(sVgaCfg *cfg)
Initialize configuration structure to VGA defaults.
Definition: vga_vmode.cpp:468
sVmode::vmax
u16 vmax
Maximal height.
Definition: vga_vmode.h:148
sVideo::vpre2
u16 vpre2
V sync pre half-pulses on subframe 2.
Definition: vga_vmode.h:57
FORM_MTEXT8
@ FORM_MTEXT8
mono text with font 8x8
Definition: vga_vmode.h:215
sVideo::vback1
u16 vback1
V back porch (after VSYNC, before image) on subframe 1.
Definition: vga_vmode.h:46
sVmode::vback2
u16 vback2
V back porch (after VSYNC, before image) on subframe 2.
Definition: vga_vmode.h:163
sVideo::vfront1
u16 vfront1
V front porch (after image, before VSYNC) on subframe 1.
Definition: vga_vmode.h:48
sVideo::odd
bool odd
first sub-frame is odd lines 1, 3, 5,... (PAL)
Definition: vga_vmode.h:65
FORM_TEXT16
@ FORM_TEXT16
attribute text with font 8x16
Definition: vga_vmode.h:218
sVgaCfg::height
u16 height
Height in lines.
Definition: vga_vmode.h:106
VideoNTSC
const sVideo VideoNTSC
TV NTSC interlaced 4:3 640x480 (5:4 600x480, 16:9 848x480)
Definition: vga_vmode.cpp:161
RES_SVGA
@ RES_SVGA
800x600 (not for TV device)
Definition: vga_vmode.h:196
DEV_NTSC
@ DEV_NTSC
NTSC TV.
Definition: vga_vmode.h:183
RES_CGA
@ RES_CGA
320x200
Definition: vga_vmode.h:192
RES_XGA
@ RES_XGA
1024x768 (not for TV device)
Definition: vga_vmode.h:197
VideoXGA
const sVideo VideoXGA
XGA 4:3 1024x768 (16:9 1360x768), vert. 60 Hz, hor. 48.36310 kHz, pixel clock 65 MHz.
Definition: vga_vmode.cpp:353
sVideo::vsync2
u16 vsync2
V sync half-pulses on subframe 2.
Definition: vga_vmode.h:52
VideoVGA
const sVideo VideoVGA
VGA 4:3 640x480 (16:9 848x480), vert. 60 Hz, hor. 31.4685 kHz, pixel clock 25.175 MHz.
Definition: vga_vmode.cpp:277
FORM_TILE48
@ FORM_TILE48
48x48 tiles
Definition: vga_vmode.h:213
VideoPALp
const sVideo VideoPALp
TV PAL progressive 5:4 360x288 (4:3 384x288, 16:9 512x288)
Definition: vga_vmode.cpp:120
VideoEGA
const sVideo VideoEGA
EGA 8:5 640x400 (5:4 500x400, 4:3 528x400, 16:9 704x400), vert. 70 Hz, hor. 31.4685 kHz,...
Definition: vga_vmode.cpp:239
FORM_4BIT
@ FORM_4BIT
4-bit pixel graphics (up to SVGA graphics)
Definition: vga_vmode.h:206
sVmode::wfull
u16 wfull
Screen width of full screen (corresponding to 'hfull' time)
Definition: vga_vmode.h:123
sVmode::inter
bool inter
Interlaced (use sub-frames)
Definition: vga_vmode.h:175
sVmode::vsync2
u16 vsync2
V sync half-pulses on subframe 2.
Definition: vga_vmode.h:161
sVideo::htot
float htot
Horizontal total scanline in [us].
Definition: vga_vmode.h:33
sVideo::psync
bool psync
positive synchronization
Definition: vga_vmode.h:64
sVmode::width
u16 width
Screen width in pixels.
Definition: vga_vmode.h:121
sVmode::vact1
u16 vact1
active visible scanlines, subframe 1
Definition: vga_vmode.h:155
Pal16Trans
u16 Pal16Trans[256]
16-color palette translation table
Definition: vga_vmode.cpp:19
sVmode::pd2
u8 pd2
postdiv2
Definition: vga_vmode.h:131
sVmode::hback
u16 hback
H back porch in state machine clocks (min. 13)
Definition: vga_vmode.h:143
Vmode
sVmode Vmode
Videomode setup.
Definition: vga_vmode.cpp:14
FORM_TILE8
@ FORM_TILE8
8x8 tiles
Definition: vga_vmode.h:208
sVmode::cpp
u16 cpp
State machine clocks per pixel.
Definition: vga_vmode.h:135
VideoSVGA
const sVideo VideoSVGA
SVGA 4:3 800x600 (16:9 1064x600), vert. 60 Hz, hor. 37.897 kHz, pixel clock 40 MHz.
Definition: vga_vmode.cpp:315
sVmode::vtot
u16 vtot
Total scanlines (both sub-frames)
Definition: vga_vmode.h:147
sVideo::vback2
u16 vback2
V back porch (after VSYNC, before image) on subframe 2.
Definition: vga_vmode.h:54
VideoPAL
const sVideo VideoPAL
TV PAL interlaced 5:4 720x576 (4:3 768x576, 16:9 1024x576)
Definition: vga_vmode.cpp:82
VideoHD
const sVideo VideoHD
HD 4:3 1280x960, vert. 53 Hz, hor. 51.858 kHz, pixel clock 102.1 MHz.
Definition: vga_vmode.cpp:430
sVmode::vfreq
float vfreq
Vertical frequency in [Hz].
Definition: vga_vmode.h:149
sVmode::height
u16 height
Screen height in lines.
Definition: vga_vmode.h:122
sCanvas
Canvas descriptor.
Definition: canvas.h:41
sVgaCfg
Required configuration to initialize VGA output.
Definition: vga_vmode.h:104
RES_VGA
@ RES_VGA
640x480
Definition: vga_vmode.h:195
sVmode::dbly
bool dbly
Double scanlines.
Definition: vga_vmode.h:174
sVmode::fbdiv
u16 fbdiv
fbdiv PLL divider
Definition: vga_vmode.h:129
FORM_8BIT
@ FORM_8BIT
8-bit pixel graphics (up to EGA resolution)
Definition: vga_vmode.h:205
sVideo::vtot
u16 vtot
Vertical total scanlines (both subframes)
Definition: vga_vmode.h:40
sVmode::wmax
u16 wmax
Screen maximal width (corresponding to 'hmax' time)
Definition: vga_vmode.h:124
FORM_TILE24
@ FORM_TILE24
24x24 tiles
Definition: vga_vmode.h:211
RES_ZX
@ RES_ZX
256x192
Definition: vga_vmode.h:191
sVgaCfg::width
u16 width
Width in pixels.
Definition: vga_vmode.h:105
FORM_TILE12
@ FORM_TILE12
12x12 tiles
Definition: vga_vmode.h:209
sVmode::prog
u8 prog
Layer program LAYERPROG_*.
Definition: vga_vmode.h:136
sVgaCfg::lockfreq
bool lockfreq
Lock required frequency, do not change it.
Definition: vga_vmode.h:115
Canvas
sCanvas Canvas
Canvas of draw box.
Definition: vga_vmode.cpp:16
FORM_MTEXT16
@ FORM_MTEXT16
mono text with font 8x16
Definition: vga_vmode.h:216
VideoVESA
const sVideo VideoVESA
VESA 4:3 1152x864, vert. 60 Hz, hor. 53.697 kHz, pixel clock 81.62 MHz.
Definition: vga_vmode.cpp:391
FORM_TEXT8
@ FORM_TEXT8
attribute text with font 8x8
Definition: vga_vmode.h:217
sVideo::hfront
float hfront
Horizontal front porch (after image, before HSYNC) in [us].
Definition: vga_vmode.h:34
sVmode
Videomode table - used to setup video driver.
Definition: vga_vmode.h:119
sVmode::vback1
u16 vback1
V back porch (after VSYNC, before image) on subframe 1.
Definition: vga_vmode.h:154
sVideo::vact1
u16 vact1
active visible scanlines, subframe 1
Definition: vga_vmode.h:47
sVgaCfg::freq
u32 freq
Required minimal system frequency in kHz (real frequency can be higher)
Definition: vga_vmode.h:109
sVideo::vpost2
u16 vpost2
V sync post half-pulses on subframe 2.
Definition: vga_vmode.h:53
sVideo::inter
bool inter
interlaced (use subframes)
Definition: vga_vmode.h:63
VideoNTSCp
const sVideo VideoNTSCp
TV NTSC progressive 4:3 320x240 (5:4 300x240, 16:9 424x240)
Definition: vga_vmode.cpp:199
sVmode::hsync
u16 hsync
H sync pulse in state machine clocks (min. 4)
Definition: vga_vmode.h:142
Cfg
sVgaCfg Cfg
Required configuration.
Definition: vga_vmode.cpp:15
sVideo::hfull
float hfull
Horizontal full visible in [us] (corresponding to 'wfull' pixels)
Definition: vga_vmode.h:37
sVideo::vsync1
u16 vsync1
V sync (half-)pulses on subframe 1.
Definition: vga_vmode.h:44
sVgaCfg::video
const sVideo * video
Used video timings.
Definition: vga_vmode.h:108
sVmode::hfront
u16 hfront
H front porch in state machine clocks (min. 2)
Definition: vga_vmode.h:141
sVmode::vpre1
u16 vpre1
V sync pre (half-)pulses on subframe 1.
Definition: vga_vmode.h:157
sVmode::hfreq
float hfreq
Horizontal frequency in [Hz].
Definition: vga_vmode.h:144