The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
display.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file display.h
5
* @brief display drivers: the layer between the fbdev (/dev/fb0) and a
6
* card that can change its mode.
7
*
8
* without a driver, the screen is the framebuffer the bootloader set up,
9
* in one mode. a driver (the Bochs/QEMU VGA, virtio-gpu) can set other
10
* sizes at run time, and can know the size the screen wants (the QEMU
11
* window). /dev/display tells programs when the mode or that size
12
* changes.
13
*/
14
15
#include "
common/stdint.h
"
16
#include "
kernel/memory/phys.h
"
17
18
/**
19
* a framebuffer in a mode: 32 bits per pixel, x8r8g8b8.
20
*/
21
typedef
struct
22
{
23
phys_addr_t
phys
;
// where it is (contiguous)
24
uint8_t
*
addr
;
// the kernel's pointer to it
25
uint32_t
width
;
26
uint32_t
height
;
27
uint32_t
pitch
;
// bytes per row
28
}
display_surface_t
;
29
30
typedef
struct
31
{
32
const
char
*
name
;
33
uint32_t
max_width
;
// the largest mode it can set
34
uint32_t
max_height
;
35
36
/**
37
* set a mode.
38
* @param out receives the framebuffer of the new mode.
39
* @return false if the size is not possible (the old mode stays).
40
*/
41
bool
(*
set_mode
)(
uint32_t
width,
uint32_t
height,
display_surface_t
*out);
42
43
/**
44
* the size the screen wants (optional).
45
* @return false if it does not know.
46
*/
47
bool
(*
preferred
)(
uint32_t
*width,
uint32_t
*height);
48
49
/**
50
* copy a rect of the framebuffer to the screen (optional: NULL when
51
* the screen shows the memory by itself).
52
*/
53
void (*
flush
)(
uint32_t
x,
uint32_t
y,
uint32_t
width,
uint32_t
height);
54
55
/**
56
* show a pointer over the framebuffer, drawn by the card (optional).
57
* @param pixels FB_CURSOR_SIZE x FB_CURSOR_SIZE a8r8g8b8, or NULL to
58
* hide the pointer.
59
* @param x where its top left corner goes.
60
* @return false if the card refused.
61
*/
62
bool
(*
cursor_set
)(
const
uint32_t
*pixels,
uint32_t
x,
uint32_t
y);
63
64
/**
65
* move the pointer's top left corner to x, y (with cursor_set).
66
*/
67
void (*
cursor_move
)(
uint32_t
x,
uint32_t
y);
68
}
display_driver_t
;
69
70
/**
71
* register /dev/display. call once, before the drivers.
72
*/
73
void
display_init
(
void
);
74
75
/**
76
* the driver in use, or NULL (the bootloader's framebuffer only).
77
*/
78
const
display_driver_t
*
display_driver
(
void
);
79
80
/**
81
* use a driver from now on, and set the size the screen wants if it knows
82
* one. call after fb_init.
83
*/
84
void
display_attach
(
const
display_driver_t
*driver);
85
86
/**
87
* a mode by index for FBIOGET_MODE: the preferred size first, then common
88
* sizes the driver can set.
89
* @return false past the last one.
90
*/
91
bool
display_mode_at
(
uint32_t
index,
uint32_t
*width,
uint32_t
*height,
bool
*preferred);
92
93
/**
94
* tell the readers of /dev/display about a change.
95
* @param type FB_EVENT_MODE or FB_EVENT_PREFERRED.
96
*/
97
void
display_event
(
uint32_t
type,
uint32_t
width,
uint32_t
height);
98
99
/**
100
* the size the screen wants may have changed (a driver's interrupt calls
101
* it). the driver is asked again in process context, when /dev/display is
102
* read or polled.
103
*/
104
void
display_preferred_changed
(
void
);
stdint.h
display_driver
const display_driver_t * display_driver(void)
the driver in use, or NULL (the bootloader's framebuffer only).
Definition
display.c:119
display_preferred_changed
void display_preferred_changed(void)
the size the screen wants may have changed (a driver's interrupt calls it).
Definition
display.c:112
display_init
void display_init(void)
register /dev/display.
Definition
display.c:296
display_event
void display_event(uint32_t type, uint32_t width, uint32_t height)
tell the readers of /dev/display about a change.
Definition
display.c:71
display_attach
void display_attach(const display_driver_t *d)
use a driver from now on, and set the size the screen wants if it knows one.
Definition
display.c:124
display_mode_at
bool display_mode_at(uint32_t index, uint32_t *width, uint32_t *height, bool *preferred)
a mode by index for FBIOGET_MODE: the preferred size first, then common sizes the driver can set.
Definition
display.c:136
uint32_t
unsigned int uint32_t
Definition
fb.h:17
uint8_t
unsigned char uint8_t
Definition
fb.h:18
phys.h
phys_addr_t
uintptr_t phys_addr_t
physical addresses and the conversion between physical and virtual.
Definition
phys.h:18
bool
#define bool
Definition
stdbool.h:8
display_driver_t
Definition
display.h:31
display_driver_t::max_height
uint32_t max_height
Definition
display.h:34
display_driver_t::cursor_move
void(*) cursor_move(uint32_t x, uint32_t y)
move the pointer's top left corner to x, y (with cursor_set).
Definition
display.h:67
display_driver_t::max_width
uint32_t max_width
Definition
display.h:33
display_driver_t::name
const char * name
Definition
display.h:32
display_driver_t::cursor_set
bool(*) cursor_set(const uint32_t *pixels, uint32_t x, uint32_t y)
show a pointer over the framebuffer, drawn by the card (optional).
Definition
display.h:62
display_driver_t::preferred
bool(*) preferred(uint32_t *width, uint32_t *height)
the size the screen wants (optional).
Definition
display.h:47
display_driver_t::set_mode
bool(*) set_mode(uint32_t width, uint32_t height, display_surface_t *out)
set a mode.
Definition
display.h:41
display_driver_t::flush
void(*) flush(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
copy a rect of the framebuffer to the screen (optional: NULL when the screen shows the memory by itse...
Definition
display.h:53
display_surface_t
a framebuffer in a mode: 32 bits per pixel, x8r8g8b8.
Definition
display.h:22
display_surface_t::width
uint32_t width
Definition
display.h:25
display_surface_t::height
uint32_t height
Definition
display.h:26
display_surface_t::addr
uint8_t * addr
Definition
display.h:24
display_surface_t::pitch
uint32_t pitch
Definition
display.h:27
display_surface_t::phys
phys_addr_t phys
Definition
display.h:23
src
drivers
video
display.h
Generated by
1.18.0