aboutsummaryrefslogtreecommitdiffstats
path: root/src/calibrator.h
blob: 7b823dbbd38171a93162a6a4d80438a85e404cc2 (plain) (blame)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
 * 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_CALIBRATOR_H
#define CRT_CALIBRATOR_CALIBRATOR_H


#include "framebuffer.h"
#include "drmgamma.h"

#include <stdint.h>
#include <stddef.h>
#include <stdio.h>


/**
 * Draw bars in different shades of grey, red, green and blue
 * used for calibrating the contrast and brightness
 */
void draw_contrast_brightness(void);

/**
 * Draw a seven segment display
 * 
 * @param  fb      The framebuffer to draw on
 * @param  colour  The intensity of the least intense colour to use
 * @param  x       The X component of the top left corner of the seven segment display
 * @param  y       The Y component of the top left corner of the seven segment display
 */
void draw_digit(framebuffer_t* restrict fb, int colour, uint32_t x, uint32_t y);

/**
 * Manipulate a CRT controllers gamma ramps to display a specific digit
 * for one of the seven segment display on only that CRT controller's
 * monitors
 * 
 * @param  crtc    The CRT controller information
 * @param  colour  The intensity of the least intense colour in the seven segment display
 * @param  value   The valud of the digit to display
 */
void gamma_digit(drm_crtc_t* restrict crtc, int colour, size_t value);

/**
 * Draw an unique index on each monitor
 * 
 * @return  Zero on success, -1 on error
 */
int draw_id(void);

/**
 * Draw squares used as reference when tweeking the gamma correction
 */
void draw_gamma(void);

/**
 * Print a pattern on the screen that can be used when
 * calibrating the convergence
 */
void draw_convergence(void);

/**
 * Print a pattern on the screen that can be used when
 * calibrating the moiré cancellation
 * 
 * @param  gap       The horizontal and vertical gap, in pixels, between the dots
 * @param  diagonal  Whether to draw dots in a diagonal pattern
 */
void draw_moire(uint32_t gap, int diagonal);

/**
 * Analyse the monitors calibrations
 * 
 * @return  Zero on success, -1 on error
 */
int read_calibs(void);

/**
 * Apply the selected calibrations to the monitors
 * 
 * @return  Zero on success, -1 on error
 */
int apply_calibs(void);

/**
 * Print calibrations into a file
 * 
 * @param   f  The file
 * @return     Zero on success, -1 on error
 */
int save_calibs(FILE* f);


#endif