The manual
ginnOS
The reference: libc, the libraries and the kernel
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
12typedef unsigned int uint32_t;
13
14// how a single colour channel sits inside a pixel.
21
22// fixed screen info.
32
33// variable screen info.
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 */
61typedef struct
62{
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 */
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
110typedef struct
111{
115 uint32_t pixels[FB_CURSOR_SIZE * FB_CURSOR_SIZE]; // a8r8g8b8, row after row
117
118typedef struct
119{
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 */
136typedef struct
137{
138 uint32_t type; // FB_EVENT_*
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 */
150int fb_open(void);
#define FB_CURSOR_SIZE
FBIO_CURSOR: arg is an fb_cursor_t.
Definition fb_ioctl.h:116
unsigned int uint32_t
Definition fb.h:17
int fb_open(void)
open the framebuffer device (/dev/fb0).
Definition fb.h:16
uint32_t offset
Definition fb.h:17
uint32_t msb_right
Definition fb.h:19
uint32_t length
Definition fb.h:18
Definition fb.h:111
uint32_t x
Definition fb.h:113
uint32_t shown
Definition fb.h:112
uint32_t y
Definition fb.h:114
uint32_t pixels[FB_CURSOR_SIZE *FB_CURSOR_SIZE]
Definition fb.h:115
FBIOPUT_VSCREENINFO sets the mode to xres x yres at 32 bits per pixel when a display driver can (EINV...
Definition fb.h:137
uint32_t type
Definition fb.h:138
uint32_t height
Definition fb.h:140
uint32_t width
Definition fb.h:139
Definition fb.h:24
uint32_t smem_start
Definition fb.h:26
uint32_t visual
Definition fb.h:29
uint32_t smem_len
Definition fb.h:27
uint32_t type
Definition fb.h:28
uint32_t line_length
Definition fb.h:30
FBIOGET_MODE: one video mode.
Definition fb.h:62
uint32_t width
Definition fb.h:64
uint32_t preferred
Definition fb.h:68
uint32_t bpp
Definition fb.h:66
uint32_t current
Definition fb.h:67
uint32_t height
Definition fb.h:65
uint32_t index
Definition fb.h:63
Definition fb.h:119
uint32_t y
Definition fb.h:121
uint32_t x
Definition fb.h:120
FBIO_FLUSH: arg is an fb_rect_t of pixels that changed.
Definition fb.h:89
uint32_t x
Definition fb.h:90
uint32_t width
Definition fb.h:92
uint32_t height
Definition fb.h:93
uint32_t y
Definition fb.h:91
Definition fb.h:35
uint32_t xres
Definition fb.h:36
fb_bitfield_t green
Definition fb.h:42
fb_bitfield_t transp
Definition fb.h:44
uint32_t xres_virtual
Definition fb.h:38
uint32_t yres
Definition fb.h:37
fb_bitfield_t red
Definition fb.h:41
fb_bitfield_t blue
Definition fb.h:43
uint32_t yres_virtual
Definition fb.h:39
uint32_t bits_per_pixel
Definition fb.h:40