initial commit
[vidsys] / vidsys.h
1 #ifndef VIDSYS_VIDEO_H_
2 #define VIDSYS_VIDEO_H_
3
4 #include <stdlib.h>
5 #include "sizeint.h"
6
7 struct vid_drvops;
8
9 struct vid_color {
10         int r, g, b;
11 };
12
13 struct vid_gfxops {
14         void (*pack)(uint32_t *pix, int r, int g, int b);
15         void (*unpack)(uint32_t pix, int *r, int *g, int *b);
16         void (*setpal)(int idx, int count, const struct vid_color *col);
17         void (*getpal)(int idx, int count, struct vid_color *col);
18         void (*vsync)(void);
19
20         void (*clear)(uint32_t color);
21         void (*blitfb)(void *fb, int pitch);
22         void (*flip)(int vsync);
23
24         void (*fill)(int x, int y, int w, int h, uint32_t color);
25         void (*blit)(int x, int y, int w, int h, void *img, int pitch);
26         void (*line)(int x0, int y0, int x1, int y1, uint32_t color);
27         void (*hline)(int x, int y, int len, uint32_t color);
28         void (*vline)(int x, int y, int len, uint32_t color);
29 };
30
31 struct vid_driver {
32         const char *name;
33         int prio;
34
35         struct vid_modeinfo *modes;
36         int num_modes;
37
38         struct vid_drvops *ops;
39 };
40
41 struct vid_modeinfo {
42         int modeno;
43         int width, height, bpp, ncolors;
44         uint32_t rmask, gmask, bmask;
45         int rshift, gshift, bshift;
46         int pages;
47         int win_size, win_gran;
48         uint32_t vmem_addr;
49         size_t vmem_size;
50
51         struct vid_driver *drv;
52         struct vid_gfxops ops;
53 };
54
55 int vid_init(void);
56 void vid_cleanup(void);
57
58 int vid_curmode(void);
59 void *vid_setmode(int mode);
60 int vid_findmode(int xsz, int ysz, int bpp);
61 struct vid_modeinfo *vid_modeinfo(int mode);
62
63 void vid_vsync(void);
64
65 /* current mode functions */
66 void vid_setpal(int idx, int count, const struct vid_color *col);
67 void vid_getpal(int idx, int count, struct vid_color *col);
68
69 #endif  /* VIDSYS_VIDEO_H_ */