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