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#include <sys/types.h>
4
5/**
6 * @file fb.h
7 * @brief userspace access to the linear framebuffer.
8 *
9 * a program calls fbinfo() to learn the framebuffer geometry and pixel format,
10 * then fbmap() to map it into its address space and draw pixels directly.
11 * these are convenience wrappers over the /dev/fb0 fbdev (open + ioctl + mmap,
12 * see <sys/fb.h>); a program can use that interface directly instead. this is
13 * still a single-client path (no compositor yet): whoever maps it owns the
14 * whole screen until it exits.
15 */
16
17typedef unsigned int uint32_t;
18typedef unsigned char uint8_t;
19
20/**
21 * framebuffer geometry and pixel format, filled by fbinfo().
22 * mirrors the kernel's view; the channel size/shift pairs describe how r/g/b
23 * sit inside a pixel so a program can pack colours for any layout.
24 */
25typedef struct
26{
27 uint32_t width; // width in pixels.
28 uint32_t height; // height in pixels.
29 uint32_t pitch; // bytes per scanline (may exceed width * bpp/8).
30 uint32_t bpp; // bits per pixel (24 or 32).
35} fb_info_t;
36
37/**
38 * query the framebuffer geometry and pixel format.
39 * @param info output struct.
40 * @return 0 on success, -1 if there is no framebuffer.
41 */
42int fbinfo(fb_info_t *info);
43
44/**
45 * map the framebuffer into this process's address space.
46 * @return a writable pointer to the framebuffer, or NULL on failure. the
47 * returned buffer is `pitch * height` bytes; write packed pixels.
48 */
49void *fbmap(void);
50
51/**
52 * non-blocking keyboard poll for interactive graphics programs.
53 * @return the next pending character key, or 0 if none is waiting.
54 */
55int pollkey(void);
int pollkey(void)
non-blocking keyboard poll for interactive graphics programs.
unsigned int uint32_t
Definition fb.h:17
void * fbmap(void)
map the framebuffer into this process's address space.
int fbinfo(fb_info_t *info)
query the framebuffer geometry and pixel format.
unsigned char uint8_t
Definition fb.h:18
framebuffer geometry and pixel format, filled by fbinfo().
Definition fb.h:26
uint32_t bpp
Definition fb.h:30
uint8_t blue_size
Definition fb.h:33
uint32_t pitch
Definition fb.h:29
uint32_t width
Definition fb.h:27
uint8_t _pad[2]
Definition fb.h:34
uint32_t height
Definition fb.h:28
uint8_t blue_shift
Definition fb.h:33
uint8_t green_size
Definition fb.h:32
uint8_t red_size
Definition fb.h:31
uint8_t red_shift
Definition fb.h:31
uint8_t green_shift
Definition fb.h:32
basic system types.