aboutsummaryrefslogtreecommitdiffstats
path: root/src/libgamma-method.hh
blob: 514ae31210f7aaeca6d745cdee776b243f99430e (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/**
 * libgammamm -- C++ wrapper for libgamma
 * Copyright (C) 2014  Mattias Andrée (maandree@member.fsf.org)
 * 
 * This library 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 library 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 library.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef LIBGAMMA_METHOD_HH
#define LIBGAMMA_METHOD_HH


#include <string>

#include "libgamma-native.hh"


namespace libgamma
{
  /**
   * Cathode ray tube controller information data structure.
   */
  class CRTCInformation;
  
  /**
   * Capabilities of adjustment methods.
   */
  class MethodCapabilities;
  
  
  
  /**
   * Capabilities of adjustment methods.
   */
  class MethodCapabilities
  {
  public:
    /**
     * Constructor.
     */
    MethodCapabilities();
    
    /**
     * Constructor.
     * 
     * @param  caps  The information in the native structure
     */
    MethodCapabilities(libgamma_method_capabilities_t* caps);
    
    /**
     * Copy constructor.
     * 
     * @param  other  The information to copy.
     */
    MethodCapabilities(const MethodCapabilities& other);
    
    /**
     * Destructor.
     */
    ~MethodCapabilities();
    
    /**
     * Copy operator.
     * 
     * @param  other  The information to copy.
     */
    MethodCapabilities& operator =(const MethodCapabilities& other);
    
    
    
    
    /**
     * OR of the CRTC information fields in `libgamma_crtc_information_t`
     * that may (but can fail) be read successfully.
     */
    int32_t crtc_information;
    
    /**
     * Whether the default site is known, if true the site is integrated
     * to the system or can be determined using environment variables.
     */
    bool default_site_known;
    
    /**
     * Whether the adjustment method supports multiple sites rather
     * than just the default site.
     */
    bool multiple_sites;
    
    /**
     * Whether the adjustment method supports multiple partitions
     * per site.
     */
    bool multiple_partitions;
    
    /**
     * Whether the adjustment method supports multiple CRTC:s
     * per partition per site.
     */
    bool multiple_crtcs;
    
    /**
     * Whether the partition to graphics card is a bijection.
     */
    bool partitions_are_graphics_cards;
    
    /**
     * Whether the adjustment method supports `libgamma_site_restore`.
     */
    bool site_restore;
    
    /**
     * Whether the adjustment method supports `libgamma_partition_restore`.
     */
    bool partition_restore;
    
    /**
     * Whether the adjustment method supports `libgamma_crtc_restore`.
     */
    bool crtc_restore;
    
    /**
     * Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
     * fields in `libgamma_crtc_information_t` will always have the same
     * values as each other for the adjustment method.
     */
    bool identical_gamma_sizes;
    
    /**
     * Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
     * fields in `libgamma_crtc_information_t` will always be filled with the
     * same value for the adjustment method.
     */
    bool fixed_gamma_size;
    
    /**
     * Whether the `gamma_depth` field in `libgamma_crtc_information_t`
     * will always be filled with the same value for the adjustment method.
     */
    bool fixed_gamma_depth;
    
    /**
     * Whether the adjustment method will actually perform adjustments.
     */
    bool real;
    
    /**
     * Whether the adjustment method is implement using a translation layer.
     */
    bool fake;
    
  };
  
  
  /**
   * Types for connectors.
   */
  typedef libgamma_connector_type_t ConnectorType;
  
  /**
   * Orders for subpixels. Currently the possible values are
   * very biased to LCD, Plasma and monochrome monitors.
   */
  typedef libgamma_subpixel_order_t SubpixelOrder;
  
  
  /**
   * Cathode ray tube controller information data structure.
   */
  class CRTCInformation
  {
  public:
    /**
     * Constructor.
     */
    CRTCInformation();
    
    /**
     * Constructor.
     * 
     * @param  info  The information in the native structure
     */
    CRTCInformation(libgamma_crtc_information_t* info);
    
    /**
     * Copy constructor.
     * 
     * @param  other  The information to copy.
     */
    CRTCInformation(const CRTCInformation& other);
    
    /**
     * Destructor.
     */
    ~CRTCInformation();
    
    /**
     * Copy operator.
     * 
     * @param  other  The information to copy.
     */
    CRTCInformation& operator =(const CRTCInformation& other);
    
    
    
    /**
     * The Extended Display Identification Data associated with
     * the attached monitor. This is raw byte array that is usually
     * 128 bytes long. It is not NUL-terminate, rather its length
     * is stored in `edid_length`.
     */
    unsigned char* edid;
    
    /**
     * The length of `edid`.
     */
    size_t edid_length;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int edid_error;
    
    
    /**
     * The phyical width, in millimetres, of the viewport of the
     * attached monitor, as reported by the adjustment method. This
     * value may be incorrect, which is a known issue with the X
     * server where it is the result of the X server attempting
     * the estimate the size on its own.
     * Zero means that its is not applicable, which is the case
     * for projectors.
     */
    size_t width_mm;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int width_mm_error;
    
    
    /**
     * The phyical height, in millimetres, of the viewport of the
     * attached monitor, as reported by the adjustment method. This
     * value may be incorrect, which is a known issue with the X
     * server where it is the result of the X server attempting
     * the estimate the size on its own.
     * Zero means that its is not applicable, which is the case
     * for projectors.
     */
    size_t height_mm;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int height_mm_error;
    
    
    /**
     * The phyical width, in millimetres, of the viewport of the
     * attached monitor, as reported by it the monitor's Extended
     * Display Information Data. This value can only contain whole
     * centimetres, which means that the result is always zero
     * modulus ten. However, this could change with revisions of
     * the EDID structure.
     * Zero means that its is not applicable, which is the case
     * for projectors.
     */
    size_t width_mm_edid;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int width_mm_edid_error;
    
    
    /**
     * The phyical height, in millimetres, of the viewport of the
     * attached monitor, as reported by it the monitor's Extended
     * Display Information Data. This value can only contain whole
     * centimetres, which means that the result is always zero
     * modulus ten. However, this could change with revisions of
     * the EDID structure.
     * Zero means that its is not applicable, which is the case
     * for projectors.
     */
    size_t height_mm_edid;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int height_mm_edid_error;
    
    
    /**
     * The size of the encoding axis of the red gamma ramp.
     */
    size_t red_gamma_size;
    
    /**
     * The size of the encoding axis of the green gamma ramp.
     */
    size_t green_gamma_size;
    
    /**
     * The size of the encoding axis of the blue gamma ramp.
     */
    size_t blue_gamma_size;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int gamma_size_error;
    
    
    /**
     * The bit-depth of the value axes of gamma ramps,
     * -1 for single precision floating point, and -2 for
     * double precision floating point.
     */
    signed gamma_depth;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int gamma_depth_error;
    
    
    /**
     * Non-zero gamma ramp adjustments are supported.
     */
    int gamma_support;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int gamma_support_error;
    
    
    /**
     * The layout of the subpixels.
     * You cannot count on this value --- especially for CRT:s ---
     * but it is provided anyway as a means of distinguishing monitors.
     */
    SubpixelOrder subpixel_order;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int subpixel_order_error;
    
    
    /**
     * Whether there is a monitors connected to the CRTC.
     */
    int active;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int active_error;
    
    
    /**
     * The name of the connector as designated by the display
     * server or as give by this library in case the display
     * server lacks this feature.
     */
    std::string* connector_name;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int connector_name_error;
    
    
    /**
     * The type of the connector that is associated with the CRTC.
     */
    ConnectorType connector_type;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int connector_type_error;
    
    
    /**
     * The gamma characteristics of the monitor as reported
     * in its Extended Display Information Data. The value
     * holds the value for the red channel. If you do not have
     * and more accurate measurement of the gamma for the
     * monitor this could be used to give a rought gamma
     * correction; simply divide the value with 2.2 and use
     * the result for the red channel in the gamma correction.
     */
    float gamma_red;
    
    /**
     * The gamma characteristics of the monitor as reported
     * in its Extended Display Information Data. The value
     * holds the value for the green channel. If you do not have
     * and more accurate measurement of the gamma for the
     * monitor this could be used to give a rought gamma
     * correction; simply divide the value with 2.2 and use
     * the result for the green channel in the gamma correction.
     */
    float gamma_green;
    
    /**
     * The gamma characteristics of the monitor as reported
     * in its Extended Display Information Data. The value
     * holds the value for the blue channel. If you do not have
     * and more accurate measurement of the gamma for the
     * monitor this could be used to give a rought gamma
     * correction; simply divide the value with 2.2 and use
     * the result for the blue channel in the gamma correction.
     */
    float gamma_blue;
    
    /**
     * Zero on success, positive it holds the value `errno` had
     * when the reading failed, otherwise (negative) the value
     * of an error identifier provided by this library.
     */
    int gamma_error;
    
  };

  
}


#endif