2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Daniel Vetter <daniel.vetter@ffwll.ch>
25 * Damien Lespiau <damien.lespiau@intel.com>
35 #include <xf86drmMode.h>
43 const char *kmstest_pipe_name(enum pipe pipe);
45 /* We namespace this enum to not conflict with the Android i915_drm.h */
48 IGT_PLANE_PRIMARY = IGT_PLANE_1,
54 const char *kmstest_plane_name(enum igt_plane plane);
67 * @port: display plane
69 * Returns: String represnting @port, e.g. "A".
71 #define kmstest_port_name(port) ((port) + 'A')
73 enum igt_commit_style {
76 /* We'll add atomic here eventually. */
80 /* this maps to the kernel API */
81 IGT_ROTATION_0 = 1 << 0,
82 IGT_ROTATION_90 = 1 << 1,
83 IGT_ROTATION_180 = 1 << 2,
84 IGT_ROTATION_270 = 1 << 3,
89 struct kmstest_connector_config {
91 drmModeConnector *connector;
92 drmModeEncoder *encoder;
93 drmModeModeInfo default_mode;
99 * kmstest_force_connector_state:
100 * @FORCE_CONNECTOR_UNSPECIFIED: Unspecified
101 * @FORCE_CONNECTOR_ON: On
102 * @FORCE_CONNECTOR_DIGITAL: Digital
103 * @FORCE_CONNECTOR_OFF: Off
105 enum kmstest_force_connector_state {
106 FORCE_CONNECTOR_UNSPECIFIED,
108 FORCE_CONNECTOR_DIGITAL,
114 * kmstest_generic_edid:
115 * @EDID_XGA: 1024x768
116 * @EDID_SXGA: 1280x1024
117 * @EDID_UXGA: 1600x1200
118 * @EDID_WSXGA: 1680x1050
119 * @EDID_FHD: 1920x1080
120 * @MAX_EDIDS: Size of #generic_edid array
122 enum kmstest_generic_edid {
123 EDID_XGA, /* 1024x768 */
124 EDID_SXGA, /* 1280x1024 */
125 EDID_UXGA, /* 1600x1200 */
126 EDID_WSXGA, /* 1680x1050 */
127 EDID_FHD, /* 1920x1080 */
133 int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
134 drmModeModeInfo *mode);
135 int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
136 unsigned long crtc_idx_mask,
137 struct kmstest_connector_config *config);
138 bool kmstest_force_connector(int fd, drmModeConnector *connector,
139 enum kmstest_force_connector_state state);
140 void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
141 const unsigned char *edid, size_t length);
142 void kmstest_free_connector_config(struct kmstest_connector_config *config);
144 void kmstest_dump_mode(drmModeModeInfo *mode);
145 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
146 const char *kmstest_encoder_type_str(int type);
147 const char *kmstest_connector_status_str(int type);
148 const char *kmstest_connector_type_str(int type);
149 void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode);
150 bool kmstest_get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
151 const char *name, uint32_t *prop_id, uint64_t *value,
152 drmModePropertyPtr *prop);
153 void kmstest_unset_all_crtcs(int drm_fd, drmModeResPtr resources);
156 * A small modeset API
159 typedef struct igt_display igt_display_t;
160 typedef struct igt_pipe igt_pipe_t;
161 typedef uint32_t igt_fixed_t; /* 16.16 fixed point */
168 unsigned int is_primary : 1;
169 unsigned int is_cursor : 1;
171 unsigned int fb_changed : 1;
172 unsigned int position_changed : 1;
173 unsigned int panning_changed : 1;
174 unsigned int rotation_changed : 1;
176 * drm_plane can be NULL for primary and cursor planes (when not
177 * using the atomic modeset API)
179 drmModePlane *drm_plane;
182 uint32_t rotation_property;
184 /* position within pipe_src_w x pipe_src_h */
186 /* panning offset within the fb */
187 unsigned int pan_x, pan_y;
188 igt_rotation_t rotation;
192 igt_display_t *display;
195 #define IGT_MAX_PLANES 4
197 igt_plane_t planes[IGT_MAX_PLANES];
202 igt_display_t *display;
203 uint32_t id; /* KMS id */
204 struct kmstest_connector_config config;
207 unsigned long pending_crtc_idx_mask;
215 unsigned long pipes_in_use;
216 igt_output_t *outputs;
217 igt_pipe_t pipes[I915_MAX_PIPES];
218 bool has_universal_planes;
221 /* set vt into graphics mode, required to prevent fbcon from interfering */
222 void igt_set_vt_graphics_mode(void);
224 void igt_display_init(igt_display_t *display, int drm_fd);
225 void igt_display_fini(igt_display_t *display);
226 int igt_display_commit2(igt_display_t *display, enum igt_commit_style s);
227 int igt_display_commit(igt_display_t *display);
228 int igt_display_try_commit2(igt_display_t *display, enum igt_commit_style s);
229 int igt_display_get_n_pipes(igt_display_t *display);
231 const char *igt_output_name(igt_output_t *output);
232 drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
233 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
234 igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane);
236 static inline bool igt_plane_supports_rotation(igt_plane_t *plane)
238 return plane->rotation_property != 0;
241 void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
242 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
243 void igt_plane_set_panning(igt_plane_t *plane, int x, int y);
244 void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);
246 void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
248 #define for_each_connected_output(display, output) \
249 for (int i__ = 0; i__ < (display)->n_outputs; i__++) \
250 if ((output = &(display)->outputs[i__]), output->valid)
252 #define for_each_pipe(display, pipe) \
253 for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++) \
256 * Can be used with igt_output_set_pipe() to mean we don't care about the pipe
257 * that should drive this output
259 #define PIPE_ANY (-1)
261 #define IGT_FIXED(i,f) ((i) << 16 | (f))
263 void igt_enable_connectors(void);
264 void igt_reset_connectors(void);
266 #endif /* __IGT_KMS_H__ */