1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/**
* crt-calibrator – Calibration utility for CRT monitors
* Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CRT_CALIBRATOR_H
#define CRT_CALIBRATOR_H
#include <stddef.h>
#include <stdint.h>
/**
* Framebuffer information
*/
typedef struct framebuffer
{
/**
* The file descriptor used to access the framebuffer, 0 if not opened
*/
int fd;
/**
* The width of the display in pixels
*/
uint32_t width;
/**
* The height of the display in pixels
*/
uint32_t height;
/**
* Increment for `mem` to move to next pixel on the line
*/
uint32_t bytes_per_pixel;
/**
* Increment for `mem` to move down one line but stay in the same column
*/
uint32_t line_length;
/**
* Framebuffer pointer, `MAP_FAILED` (from <sys/mman.h>) if not mapped
*/
int8_t* mem;
} framebuffer_t;
/**
* Figure out how many framebuffers there are on the system
*
* @return The number of framebuffers on the system
*/
size_t fb_count(void);
/**
* Open a framebuffer
*
* @param index The index of the framebuffer to open
* @param fb Framevuffer information to fill in
* @return Zero on success, -1 on error
*/
int fb_open(size_t index, framebuffer_t* restrict fb);
/**
* Close a framebuffer
*
* @param fb The framebuffer information
*/
void fb_close(framebuffer_t* restrict fb);
uint32_t fb_colour(int red, int green, int blue);
void fb_fill_rectangle(framebuffer_t* restrict fb, uint32_t colour,
uint32_t x, uint32_t y, uint32_t width, uint32_t height);
#endif
|