The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
fb.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file sys/fb.h
5
* @brief framebuffer device interface (userspace).
6
*
7
* the fbdev model: open "/dev/fb0", ioctl for geometry, mmap for pixels.
8
* the screeninfo structs and FBIO* codes are ABI and must match the kernel in
9
* src/common/fb/fb_ioctl.h exactly.
10
*/
11
12
typedef
unsigned
int
uint32_t
;
13
14
// how a single colour channel sits inside a pixel.
15
typedef
struct
16
{
17
uint32_t
offset
;
18
uint32_t
length
;
19
uint32_t
msb_right
;
20
}
fb_bitfield_t
;
21
22
// fixed screen info.
23
typedef
struct
24
{
25
char
id
[16];
26
uint32_t
smem_start
;
27
uint32_t
smem_len
;
28
uint32_t
type
;
29
uint32_t
visual
;
30
uint32_t
line_length
;
31
}
fb_fix_screeninfo_t
;
32
33
// variable screen info.
34
typedef
struct
35
{
36
uint32_t
xres
;
37
uint32_t
yres
;
38
uint32_t
xres_virtual
;
39
uint32_t
yres_virtual
;
40
uint32_t
bits_per_pixel
;
41
fb_bitfield_t
red
;
42
fb_bitfield_t
green
;
43
fb_bitfield_t
blue
;
44
fb_bitfield_t
transp
;
45
}
fb_var_screeninfo_t
;
46
47
#define FB_TYPE_PACKED_PIXELS 0
48
#define FB_VISUAL_TRUECOLOR 2
49
50
#define FBIOGET_VSCREENINFO 0x4600
51
#define FBIOPUT_VSCREENINFO 0x4601
52
#define FBIOGET_FSCREENINFO 0x4602
53
54
/**
55
* FBIOGET_MODE: one video mode. the caller sets index (0, 1, ...); the
56
* kernel fills in the rest, or fails with EINVAL past the last mode. with
57
* a display driver the list is the sizes it can set, the preferred one
58
* first; without one it is the firmware's list from the bootloader (or
59
* only the current mode).
60
*/
61
typedef
struct
62
{
63
uint32_t
index
;
64
uint32_t
width
;
65
uint32_t
height
;
66
uint32_t
bpp
;
67
uint32_t
current
;
// 1 for the mode in use
68
uint32_t
preferred
;
// 1 for the size the screen wants (the QEMU window)
69
}
fb_mode_t
;
70
71
#define FBIOGET_MODE 0x46F0
72
73
/**
74
* FBIO_GRAPHICS: int arg 1 takes the screen for this process, 0 gives it
75
* back. while a process has the screen, the text console does not draw on
76
* it (its text is kept, and comes back when the screen is given back). the
77
* screen comes back by itself when the process ends, and on a kernel
78
* panic. EBUSY if another live process has it.
79
*/
80
#define FBIO_GRAPHICS 0x46F1
81
82
/**
83
* FBIO_FLUSH: arg is an fb_rect_t of pixels that changed. a display that
84
* does not show the memory by itself (virtio-gpu) copies them to the
85
* screen; for the others it does nothing. a mapped framebuffer is only
86
* sure to be seen after this.
87
*/
88
typedef
struct
89
{
90
uint32_t
x
;
91
uint32_t
y
;
92
uint32_t
width
;
93
uint32_t
height
;
94
}
fb_rect_t
;
95
96
#define FBIO_FLUSH 0x46F2
97
98
/**
99
* FBIO_CURSOR: arg is an fb_cursor_t. a display that has a pointer of its
100
* own (virtio-gpu) shows pixels over the screen, with their top left
101
* corner at x, y; shown 0 hides it. only the owner of the screen
102
* (FBIO_GRAPHICS) can use it, and the pointer goes when the owner gives
103
* the screen back or ends. ENOTTY when the display has no pointer: draw
104
* it in the picture then.
105
*
106
* FBIO_CURSOR_MOVE: arg is an fb_point_t, the new top left corner.
107
*/
108
#define FB_CURSOR_SIZE 64
109
110
typedef
struct
111
{
112
uint32_t
shown
;
113
uint32_t
x
;
114
uint32_t
y
;
115
uint32_t
pixels
[
FB_CURSOR_SIZE
*
FB_CURSOR_SIZE
];
// a8r8g8b8, row after row
116
}
fb_cursor_t
;
117
118
typedef
struct
119
{
120
uint32_t
x
;
121
uint32_t
y
;
122
}
fb_point_t
;
123
124
#define FBIO_CURSOR 0x46F3
125
#define FBIO_CURSOR_MOVE 0x46F4
126
127
/**
128
* FBIOPUT_VSCREENINFO sets the mode to xres x yres at 32 bits per pixel
129
* when a display driver can (EINVAL if it cannot). the framebuffer can
130
* move: map it again after a change.
131
*
132
* /dev/display: read gives fb_event_t records; poll says when one is
133
* there. a record comes when the mode changed and when the size the
134
* screen wants changed (the QEMU window was resized).
135
*/
136
typedef
struct
137
{
138
uint32_t
type
;
// FB_EVENT_*
139
uint32_t
width
;
140
uint32_t
height
;
141
}
fb_event_t
;
142
143
#define FB_EVENT_MODE 1
// the mode is now width x height
144
#define FB_EVENT_PREFERRED 2
// the screen wants width x height
145
146
/**
147
* open the framebuffer device (/dev/fb0).
148
* @return an open fd on success, or -1 on error (errno set).
149
*/
150
int
fb_open
(
void
);
FB_CURSOR_SIZE
#define FB_CURSOR_SIZE
FBIO_CURSOR: arg is an fb_cursor_t.
Definition
fb_ioctl.h:116
uint32_t
unsigned int uint32_t
Definition
fb.h:17
fb_open
int fb_open(void)
open the framebuffer device (/dev/fb0).
fb_bitfield_t
Definition
fb.h:16
fb_bitfield_t::offset
uint32_t offset
Definition
fb.h:17
fb_bitfield_t::msb_right
uint32_t msb_right
Definition
fb.h:19
fb_bitfield_t::length
uint32_t length
Definition
fb.h:18
fb_cursor_t
Definition
fb.h:111
fb_cursor_t::x
uint32_t x
Definition
fb.h:113
fb_cursor_t::shown
uint32_t shown
Definition
fb.h:112
fb_cursor_t::y
uint32_t y
Definition
fb.h:114
fb_cursor_t::pixels
uint32_t pixels[FB_CURSOR_SIZE *FB_CURSOR_SIZE]
Definition
fb.h:115
fb_event_t
FBIOPUT_VSCREENINFO sets the mode to xres x yres at 32 bits per pixel when a display driver can (EINV...
Definition
fb.h:137
fb_event_t::type
uint32_t type
Definition
fb.h:138
fb_event_t::height
uint32_t height
Definition
fb.h:140
fb_event_t::width
uint32_t width
Definition
fb.h:139
fb_fix_screeninfo_t
Definition
fb.h:24
fb_fix_screeninfo_t::smem_start
uint32_t smem_start
Definition
fb.h:26
fb_fix_screeninfo_t::visual
uint32_t visual
Definition
fb.h:29
fb_fix_screeninfo_t::smem_len
uint32_t smem_len
Definition
fb.h:27
fb_fix_screeninfo_t::type
uint32_t type
Definition
fb.h:28
fb_fix_screeninfo_t::line_length
uint32_t line_length
Definition
fb.h:30
fb_mode_t
FBIOGET_MODE: one video mode.
Definition
fb.h:62
fb_mode_t::width
uint32_t width
Definition
fb.h:64
fb_mode_t::preferred
uint32_t preferred
Definition
fb.h:68
fb_mode_t::bpp
uint32_t bpp
Definition
fb.h:66
fb_mode_t::current
uint32_t current
Definition
fb.h:67
fb_mode_t::height
uint32_t height
Definition
fb.h:65
fb_mode_t::index
uint32_t index
Definition
fb.h:63
fb_point_t
Definition
fb.h:119
fb_point_t::y
uint32_t y
Definition
fb.h:121
fb_point_t::x
uint32_t x
Definition
fb.h:120
fb_rect_t
FBIO_FLUSH: arg is an fb_rect_t of pixels that changed.
Definition
fb.h:89
fb_rect_t::x
uint32_t x
Definition
fb.h:90
fb_rect_t::width
uint32_t width
Definition
fb.h:92
fb_rect_t::height
uint32_t height
Definition
fb.h:93
fb_rect_t::y
uint32_t y
Definition
fb.h:91
fb_var_screeninfo_t
Definition
fb.h:35
fb_var_screeninfo_t::xres
uint32_t xres
Definition
fb.h:36
fb_var_screeninfo_t::green
fb_bitfield_t green
Definition
fb.h:42
fb_var_screeninfo_t::transp
fb_bitfield_t transp
Definition
fb.h:44
fb_var_screeninfo_t::xres_virtual
uint32_t xres_virtual
Definition
fb.h:38
fb_var_screeninfo_t::yres
uint32_t yres
Definition
fb.h:37
fb_var_screeninfo_t::red
fb_bitfield_t red
Definition
fb.h:41
fb_var_screeninfo_t::blue
fb_bitfield_t blue
Definition
fb.h:43
fb_var_screeninfo_t::yres_virtual
uint32_t yres_virtual
Definition
fb.h:39
fb_var_screeninfo_t::bits_per_pixel
uint32_t bits_per_pixel
Definition
fb.h:40
src
libc
include
sys
fb.h
Generated by
1.18.0