2
* Copyright © 2016 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
19
#ifndef MIR_TOOLKIT_MIR_DISPLAY_CONFIGURATION_H_
20
#define MIR_TOOLKIT_MIR_DISPLAY_CONFIGURATION_H_
22
#include "client_types.h"
29
* \addtogroup mir_toolkit
34
* A descriptor for a display mode.
36
* A display mode contains all the information necessary to drive a display. It
37
* includes resolution and refresh rate, but also pixel clock, vsync and hsync
40
typedef struct MirOutputMode MirOutputMode;
43
* Release resources associated with a MirDisplayConfig handle.
45
* \param [in] config The handle to release
47
void mir_display_config_release(MirDisplayConfig* config);
50
* Get the maximum possible number of simultaneously active outputs this system
53
* \note There may be restrictions on the configuration required to achieve this
54
* many active outputs. Typically the achievable number of simultaneously active
55
* outputs is lower than this number.
57
* \param [in] config The configuration to query
58
* \returns The maximum number of simultaneously active outputs
59
* supportable at this time.
61
int mir_display_config_get_max_simultaneous_outputs(
62
MirDisplayConfig const* config);
65
* Get the number of outputs available in this display configuration.
67
* This returns the total number of outputs the system has. This includes both
68
* enabled and disabled output connections, and is typically larger than the
69
* value returned from mir_display_config_get_max_simultaneous_outputs().
71
* Typically this will be constant over the lifetime of a client as devices
72
* usually do not gain extra physical ports at runtime. However, hotpluggable
73
* display devices exist and the number of virtual outputs may change at
74
* runtime, so this should always be called to determine the number of outputs
77
* \param [in] config The configuration to query
78
* \returns The number of outputs available in this configuration.
80
int mir_display_config_get_num_outputs(MirDisplayConfig const* config);
83
* Get a read-only handle to the index 'th output of this configuration
85
* \note The MirOutput handle is only valid while config is valid.
86
* \pre 0 <= index < mir_display_config_get_num_outputs(config)
87
* \param [in] config The configuration to query
88
* \param [in] index The index of the output to get
89
* \returns A read-only handle to a MirOutput within config which is valid
90
* until mir_display_config_release(config) is called.
92
MirOutput const* mir_display_config_get_output(MirDisplayConfig const* config,
96
* Get the number of modes in the supported mode list of this output.
98
* The list of supported modes is retrieved from the hardware, possibly modified
99
* by any applicable quirk tables, and may not be exhaustive.
101
* \param [in] output The MirOutput to query
102
* \returns The number of modes in the supported mode list of output.
104
int mir_output_get_num_modes(MirOutput const* output);
107
* Get a handle for a mode descriptor from the list of supported modes.
109
* The list of supported modes is retrieved from the hardware, possibly modified
110
* by any applicable quirk tables, and may not be exhaustive.
112
* \pre 0 <= index < mir_output_get_num_modes(output)
113
* \note The handle remains valid as long as output is valid.
115
* \param [in] output The MirOutput to query
116
* \param [in] index The index of the mode to retrieve.
117
* \returns A handle for a description of the supported mode. This is valid
118
* for as long as output is valid. The return value is never null.
120
MirOutputMode const* mir_output_get_mode(MirOutput const* output, size_t index);
123
* Get a handle to the output's preferred mode.
125
* This is provided by the output itself. For modern displays (LCD, OLED, etc)
126
* it is typically a mode with the native resolution.
128
* An output may not have a preferred mode, in which case this call will return
131
* \note The handle remains valid as long as output is valid.
133
* \param [in] output The MirOutput to query
134
* \returns A handle for a description of the supported mode. This is valid
135
* for as long as output is valid. If the output does not have a
136
* preferred mode, it returns NULL.
138
MirOutputMode const* mir_output_get_preferred_mode(MirOutput const* output);
141
* Get a handle to the output's current mode.
143
* An output may not have a current mode (for example, if it is disabled), in
144
* which case this call will return NULL.
146
* \note The handle remains valid as long as output is valid.
148
* \param [in] output The MirOutput to query
149
* \returns A handle for a description of the supported mode. This is valid
150
* for as long as output is valid. If the output does not have a
151
* current mode, it returns NULL.
153
MirOutputMode const* mir_output_get_current_mode(MirOutput const* output);
156
* Get the number of pixel formats supported by this output
158
* \param [in] output The MirOutput to query
159
* \returns The number of pixel formats for output.
161
int mir_output_get_num_pixel_formats(MirOutput const* output);
164
* Get a pixel format from the list of supported formats
166
* \pre 0 <= index < mir_output_get_num_pixel_formats(output)
168
* \param [in] output The MirOutput to query
169
* \param [in] index The index of the format to query
170
* \returns The index 'th supported pixel format.
172
MirPixelFormat mir_output_get_pixel_format(MirOutput const* output,
176
* Get the current pixel format.
178
* \param [in] output The MirOutput to query
179
* \returns The current pixel format. This may be mir_pixel_format_invalid
180
* (for example, if the output is not currently enabled).
182
MirPixelFormat mir_output_get_current_pixel_format(MirOutput const* output);
185
* Set the output format
187
* \param [in] output The MirOutput to modify
188
* \param [in] format The MirPixelFormat to set
190
void mir_output_set_pixel_format(MirOutput* output, MirPixelFormat format);
193
* Get the ID of an output
195
* This can be used to refer to the output in other parts of the API, such as
196
* mir_surface_spec_set_fullscreen_on_output().
198
* \param [in] output The MirOutput to query.
199
* \returns The ID of output, which may be used to refer to it in other
202
int mir_output_get_id(MirOutput const* output);
205
* Get the physical connection type of an output.
207
* This is a best-effort determination, and may be incorrect.
209
* \param [in] output The MirOutput to query
210
* \returns The type of the display connection, or mir_output_type_unknown
211
* if it cannot be determined.
213
MirOutputType mir_output_get_type(MirOutput const* output);
216
* Get the x coordinate of the top-left point of the output in the virtual
219
* Outputs can be thought of as viewports into a virtual display space. They may
220
* freely overlap, coincide, or be disjoint as desired.
222
* Output orientation changes the orientation of the output rectangle in virtual
223
* display space, but does not change its top-left corner.
225
* \param [in] output The MirOutput to query
226
* \returns The x coordinate of the top-left point of the output in the
227
* virtual display space.
229
int mir_output_get_position_x(MirOutput const* output);
232
* Get the y coordinate of the top-left point of the output in the virtual
235
* Outputs can be thought of as viewports into a virtual display space. They may
236
* freely overlap, coincide, or be disjoint as desired.
238
* Output orientation changes the orientation of the output rectangle in virtual
239
* display space, but does not change its top-left corner.
241
* \param [in] output The MirOutput to query
242
* \returns The y coordinate of the top-left point of the output in the
243
* virtual display space.
245
int mir_output_get_position_y(MirOutput const* output);
248
* Get whether there is a display physically connected to the output.
250
* This gives a best-effort determination of whether or not enabling this output
251
* will result in an image being displayed to the user.
253
* The accuracy of this determination varies with connection type - for example,
254
* for DisplayPort and HDMI connections a return value of
255
* mir_output_connection_state_connected is usually a reliable indicator that
256
* there is a powered-on display connected.
258
* VGA and DVI connectors can usually determine whether or not there is a
259
* physically connected display, but cannot distinguish between a powered or
262
* It is not always possible to determine whether or not there is a display
263
* connected; in such cases mir_output_connection_state_unknown is returned.
265
* \param [in] output The MirOutput to query
266
* \returns Whether there is a display connected to this output.
268
MirOutputConnectionState mir_output_get_connection_state(
269
MirOutput const* output);
272
* Get whether this output is enabled in the current configuration.
274
* \param [in] output the MirOutput to query
275
* \returns Whether the output is enabled.
277
bool mir_output_is_enabled(MirOutput const* output);
280
* Get the physical width of the connected display, in millimetres.
282
* A best-effort report of the physical width of the display connected to this
283
* output. This is retrieved from the display hardware, possibly modified by any
284
* applicable quirk tables.
286
* Where this information is unavailable or inapplicable (for example,
287
* projectors), 0 is returned.
289
* \param [in] output the MirOutput to query
290
* \returns Physical width of the connected display, in mm.
292
int mir_output_get_physical_width_mm(MirOutput const* output);
295
* Get the physical height of the connected display, in millimetres.
297
* A best-effort report of the physical height of the display connected to this
298
* output. This is retrieved from the display hardware, possibly modified by any
299
* applicable quirk tables.
301
* Where this information is unavailable or inapplicable (for example,
302
* projectors), 0 is returned.
304
* \param [in] output the MirOutput to query
305
* \returns Physical height of the connected display, in mm.
307
int mir_output_get_physical_height_mm(MirOutput const* output);
310
* Get the power state of a connected display.
312
* It is undefined which power state is returned for an output which is not
315
* \param [in] output The MirOutput to query
316
* \returns The power state of the display connected to output.
318
MirPowerMode mir_output_get_power_mode(MirOutput const* output);
321
* Get the orientation of a display.
323
* \param [in] output The MirOutput to query
324
* \returns The orientation of output
326
MirOrientation mir_output_get_orientation(MirOutput const* output);
329
* Get the scale-factor of a display
331
* The scale-factor specifies the conversion between logical pixels and physical pixels on this output.
333
* A surface with dimensions 200×100 on an output with scale-factor 2.0 will display 400x200 pixels
334
* on this output, will display 300x150 pixels on an output with scale-factor 1.5, and so on.
336
* Where this calculation would result in a fractional number of pixels the floor is used, so a surface with
337
* dimensions 101x100 on an output with scale-factor of 1.5 will display 151x150 pixels, not 152x150.
339
* \param [in] output The MirOutput to query
340
* \returns The scale-factor of this monitor
342
float mir_output_get_scale_factor(MirOutput const* output);
345
* Get the form-factor of a connected output.
347
* This call succeeds even if the output is not connected, but may return nonsense values.
349
* \param [in] output The MirOutput to query
350
* \returns The form factor of this output
352
MirFormFactor mir_output_get_form_factor(MirOutput const* output);
355
* Get the width, in pixels, of a MirOutputMode
357
* \note This is unaffected by the orientation of the output
359
* \param [in] mode The MirOutputMode to query
360
* \returns The width, in pixels, of mode.
362
int mir_output_mode_get_width(MirOutputMode const* mode);
364
/** Get the height, in pixels, of a MirOutputMode
366
* \note This is unaffected by the orientation of the output
368
* \param [in] mode The MirOutputMode to query
369
* \returns The height, in pixels, of mode.
371
int mir_output_mode_get_height(MirOutputMode const* mode);
373
/** Get the refresh rate, in Hz, of a MirOutputMode
375
* \param [in] mode The MirOutputMode to query
376
* \returns The refresh rate, in Hz, of mode
378
double mir_output_mode_get_refresh_rate(MirOutputMode const* mode);
386
#endif //MIR_TOOLKIT_MIR_DISPLAY_CONFIGURATION_H_