summaryrefslogtreecommitdiff
path: root/src/backends/meta-output.h
blob: 08e59ddd192f68fb43d70d5c658e0d35a03c2d44 (plain)
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
/*
 * Copyright (C) 2017 Red Hat
 * Copyright (C) 2020 NVIDIA CORPORATION
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#ifndef META_OUTPUT_H
#define META_OUTPUT_H

#include <glib-object.h>

#include "backends/edid.h"
#include "backends/meta-backend-types.h"
#include "backends/meta-gpu.h"
#include "core/util-private.h"

typedef enum _MetaOutputColorspace
{
  META_OUTPUT_COLORSPACE_UNKNOWN = 0,
  META_OUTPUT_COLORSPACE_DEFAULT,
  META_OUTPUT_COLORSPACE_BT2020,
} MetaOutputColorspace;

typedef enum
{
  META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR,
  META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_HDR,
  META_OUTPUT_HDR_METADATA_EOTF_PQ,
  META_OUTPUT_HDR_METADATA_EOTF_HLG,
} MetaOutputHdrMetadataEOTF;

typedef struct _MetaOutputHdrMetadata
{
  gboolean active;
  MetaOutputHdrMetadataEOTF eotf;
  struct {
    double x;
    double y;
  } mastering_display_primaries[3];
  struct {
    double x;
    double y;
  } mastering_display_white_point;
  double mastering_display_max_luminance;
  double mastering_display_min_luminance;
  double max_cll;
  double max_fall;
} MetaOutputHdrMetadata;

struct _MetaTileInfo
{
  uint32_t group_id;
  uint32_t flags;
  uint32_t max_h_tiles;
  uint32_t max_v_tiles;
  uint32_t loc_h_tile;
  uint32_t loc_v_tile;
  uint32_t tile_w;
  uint32_t tile_h;
};

/* The first 17 matches the values in drm_mode.h, the ones starting with
 * 1000 do not. */
typedef enum
{
  META_CONNECTOR_TYPE_Unknown = 0,
  META_CONNECTOR_TYPE_VGA = 1,
  META_CONNECTOR_TYPE_DVII = 2,
  META_CONNECTOR_TYPE_DVID = 3,
  META_CONNECTOR_TYPE_DVIA = 4,
  META_CONNECTOR_TYPE_Composite = 5,
  META_CONNECTOR_TYPE_SVIDEO = 6,
  META_CONNECTOR_TYPE_LVDS = 7,
  META_CONNECTOR_TYPE_Component = 8,
  META_CONNECTOR_TYPE_9PinDIN = 9,
  META_CONNECTOR_TYPE_DisplayPort = 10,
  META_CONNECTOR_TYPE_HDMIA = 11,
  META_CONNECTOR_TYPE_HDMIB = 12,
  META_CONNECTOR_TYPE_TV = 13,
  META_CONNECTOR_TYPE_eDP = 14,
  META_CONNECTOR_TYPE_VIRTUAL = 15,
  META_CONNECTOR_TYPE_DSI = 16,
  META_CONNECTOR_TYPE_DPI = 17,
  META_CONNECTOR_TYPE_WRITEBACK = 18,
  META_CONNECTOR_TYPE_SPI = 19,
  META_CONNECTOR_TYPE_USB = 20,

  META_CONNECTOR_TYPE_META = 1000,
} MetaConnectorType;

typedef enum
{
  META_PRIVACY_SCREEN_UNAVAILABLE = 0,
  META_PRIVACY_SCREEN_ENABLED = 1 << 0,
  META_PRIVACY_SCREEN_DISABLED = 1 << 1,
  META_PRIVACY_SCREEN_LOCKED = 1 << 2,
} MetaPrivacyScreenState;

typedef struct _MetaOutputInfo
{
  grefcount ref_count;

  gboolean is_virtual;

  char *name;
  char *vendor;
  char *product;
  char *serial;

  char *edid_checksum_md5;
  MetaEdidInfo *edid_info;

  int width_mm;
  int height_mm;
  CoglSubpixelOrder subpixel_order;

  MetaConnectorType connector_type;
  MetaMonitorTransform panel_orientation_transform;

  MetaCrtcMode *preferred_mode;
  MetaCrtcMode **modes;
  unsigned int n_modes;

  MetaCrtc **possible_crtcs;
  unsigned int n_possible_crtcs;

  MetaOutput **possible_clones;
  unsigned int n_possible_clones;

  int backlight_min;
  int backlight_max;

  gboolean supports_underscanning;
  gboolean supports_color_transform;

  unsigned int max_bpc_min;
  unsigned int max_bpc_max;

  /*
   * Get a new preferred mode on hotplug events, to handle dynamic guest
   * resizing.
   */
  gboolean hotplug_mode_update;
  int suggested_x;
  int suggested_y;

  MetaTileInfo tile_info;
} MetaOutputInfo;

gboolean
meta_tile_info_equal (MetaTileInfo *a,
                      MetaTileInfo *b);

#define META_TYPE_OUTPUT_INFO (meta_output_info_get_type ())
META_EXPORT_TEST
GType meta_output_info_get_type (void);

META_EXPORT_TEST
MetaOutputInfo * meta_output_info_new (void);

META_EXPORT_TEST
MetaOutputInfo * meta_output_info_ref (MetaOutputInfo *output_info);

META_EXPORT_TEST
void meta_output_info_unref (MetaOutputInfo *output_info);

META_EXPORT_TEST
void meta_output_info_parse_edid (MetaOutputInfo *output_info,
                                  GBytes         *edid);

gboolean meta_output_info_is_color_space_supported (const MetaOutputInfo *output_info,
                                                    MetaOutputColorspace  color_space);

gboolean meta_output_is_laptop  (MetaOutput *output);

G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaOutputInfo, meta_output_info_unref)

#define META_TYPE_OUTPUT (meta_output_get_type ())
META_EXPORT_TEST
G_DECLARE_DERIVABLE_TYPE (MetaOutput, meta_output, META, OUTPUT, GObject)

struct _MetaOutputClass
{
  GObjectClass parent_class;

  MetaPrivacyScreenState (* get_privacy_screen_state) (MetaOutput *output);
  gboolean (* set_privacy_screen_enabled) (MetaOutput  *output,
                                           gboolean     enabled,
                                           GError     **error);
  gboolean (* is_color_space_supported) (MetaOutput           *output,
                                         MetaOutputColorspace  color_space);
  gboolean (* is_hdr_metadata_supported) (MetaOutput *output);
};

META_EXPORT_TEST
uint64_t meta_output_get_id (MetaOutput *output);

META_EXPORT_TEST
MetaGpu * meta_output_get_gpu (MetaOutput *output);

META_EXPORT_TEST
MetaMonitor * meta_output_get_monitor (MetaOutput *output);

void meta_output_set_monitor (MetaOutput  *output,
                              MetaMonitor *monitor);

void meta_output_unset_monitor (MetaOutput *output);

const char * meta_output_get_name (MetaOutput *output);

META_EXPORT_TEST
gboolean meta_output_is_primary (MetaOutput *output);

META_EXPORT_TEST
gboolean meta_output_is_presentation (MetaOutput *output);

META_EXPORT_TEST
gboolean meta_output_is_underscanning (MetaOutput *output);

META_EXPORT_TEST
gboolean meta_output_get_max_bpc (MetaOutput   *output,
                                  unsigned int *max_bpc);

void meta_output_set_backlight (MetaOutput *output,
                                int         backlight);

int meta_output_get_backlight (MetaOutput *output);

MetaPrivacyScreenState meta_output_get_privacy_screen_state (MetaOutput *output);

gboolean meta_output_is_privacy_screen_supported (MetaOutput *output);

gboolean meta_output_is_privacy_screen_enabled (MetaOutput *output);

gboolean meta_output_set_privacy_screen_enabled (MetaOutput  *output,
                                                 gboolean     enabled,
                                                 GError     **error);

gboolean meta_output_is_color_space_supported (MetaOutput *output,
                                               MetaOutputColorspace color_space);

void meta_output_set_color_space (MetaOutput           *output,
                                  MetaOutputColorspace  color_space);

MetaOutputColorspace meta_output_peek_color_space (MetaOutput *output);

gboolean meta_output_is_hdr_metadata_supported (MetaOutput                *output,
                                                MetaOutputHdrMetadataEOTF  eotf);

void meta_output_set_hdr_metadata (MetaOutput            *output,
                                   MetaOutputHdrMetadata *metadata);

MetaOutputHdrMetadata * meta_output_peek_hdr_metadata (MetaOutput *output);

void meta_output_add_possible_clone (MetaOutput *output,
                                     MetaOutput *possible_clone);

META_EXPORT_TEST
const MetaOutputInfo * meta_output_get_info (MetaOutput *output);

META_EXPORT_TEST
void meta_output_assign_crtc (MetaOutput                 *output,
                              MetaCrtc                   *crtc,
                              const MetaOutputAssignment *output_assignment);

META_EXPORT_TEST
void meta_output_unassign_crtc (MetaOutput *output);

META_EXPORT_TEST
MetaCrtc * meta_output_get_assigned_crtc (MetaOutput *output);

MetaMonitorTransform meta_output_logical_to_crtc_transform (MetaOutput           *output,
                                                            MetaMonitorTransform  transform);

MetaMonitorTransform meta_output_crtc_to_logical_transform (MetaOutput           *output,
                                                            MetaMonitorTransform  transform);

void meta_output_update_modes (MetaOutput    *output,
                               MetaCrtcMode  *preferred_mode,
                               MetaCrtcMode **modes,
                               int            n_modes);

#endif /* META_OUTPUT_H */