Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010 Intel Corporation |
| 3 | * Jesse Barnes <jesse.barnes@intel.com> |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included in |
| 13 | * all copies or substantial portions of the Software. |
| 14 | * |
| 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 THE |
| 18 | * 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * This program is intended for testing of display functionality. It should |
| 26 | * allow for testing of |
| 27 | * - hotplug |
| 28 | * - mode setting |
| 29 | * - clone & twin modes |
| 30 | * - panel fitting |
| 31 | * - test patterns & pixel generators |
| 32 | * Additional programs can test the detected outputs against VBT provided |
| 33 | * device lists (both docked & undocked). |
| 34 | * |
| 35 | * TODO: |
| 36 | * - pixel generator in transcoder |
| 37 | * - test pattern reg in pipe |
| 38 | * - test patterns on outputs (e.g. TV) |
| 39 | * - handle hotplug (leaks crtcs, can't handle clones) |
| 40 | * - allow mode force |
| 41 | * - expose output specific controls |
| 42 | * - e.g. DDC-CI brightness |
| 43 | * - HDMI controls |
| 44 | * - panel brightness |
| 45 | * - DP commands (e.g. poweroff) |
| 46 | * - verify outputs against VBT/physical connectors |
| 47 | */ |
Damien Lespiau | 7ee278f | 2013-02-20 14:40:07 +0000 | [diff] [blame] | 48 | #ifdef HAVE_CONFIG_H |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 49 | #include "config.h" |
Damien Lespiau | 7ee278f | 2013-02-20 14:40:07 +0000 | [diff] [blame] | 50 | #endif |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 51 | |
Thomas Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 52 | #include "igt.h" |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 53 | #include <cairo.h> |
| 54 | #include <errno.h> |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 55 | #include <getopt.h> |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 56 | #include <math.h> |
| 57 | #include <stdint.h> |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 58 | #include <stdbool.h> |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 59 | #include <strings.h> |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 60 | #include <unistd.h> |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 61 | #include <termios.h> |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 62 | #include <sys/poll.h> |
| 63 | #include <sys/time.h> |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 64 | #include <sys/ioctl.h> |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 65 | #include <sys/types.h> |
| 66 | #include <sys/stat.h> |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 67 | |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 68 | #include "testdisplay.h" |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 69 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 70 | #include <stdlib.h> |
| 71 | #include <signal.h> |
| 72 | |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 73 | #define SUBTEST_OPTS 1 |
Thomas Wood | 895204f | 2014-10-30 15:54:02 +0000 | [diff] [blame] | 74 | #define HELP_DESCRIPTION 2 |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 75 | #define Yb_OPT 3 |
| 76 | #define Yf_OPT 4 |
Thomas Wood | ff6b068 | 2014-07-31 16:26:55 +0100 | [diff] [blame] | 77 | |
Imre Deak | 6374641 | 2014-05-12 13:29:49 +0300 | [diff] [blame] | 78 | static int tio_fd; |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 79 | struct termios saved_tio; |
| 80 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 81 | drmModeRes *resources; |
Daniel Vetter | 73d1b88 | 2012-01-10 18:20:39 +0100 | [diff] [blame] | 82 | int drm_fd, modes; |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 83 | int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane, |
Damien Lespiau | d9ffb7d | 2014-06-20 12:02:09 +0100 | [diff] [blame] | 84 | test_stereo_modes; |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 85 | uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE; |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 86 | int sleep_between_modes = 5; |
Daniel Vetter | cef9b31 | 2014-02-13 19:22:35 +0100 | [diff] [blame] | 87 | int do_dpms = 0; /* This aliases to DPMS_ON */ |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 88 | uint32_t depth = 24, stride, bpp; |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 89 | int qr_code = 0; |
Yi Sun | 6157d24 | 2013-02-12 23:11:35 +0800 | [diff] [blame] | 90 | int specified_mode_num = -1, specified_disp_id = -1; |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 91 | |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 92 | drmModeModeInfo force_timing; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 93 | |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 94 | int crtc_x, crtc_y, crtc_w, crtc_h, width, height; |
Jesse Barnes | 1f4c37a | 2011-10-28 05:25:53 +0200 | [diff] [blame] | 95 | unsigned int plane_fb_id; |
| 96 | unsigned int plane_crtc_id; |
| 97 | unsigned int plane_id; |
| 98 | int plane_width, plane_height; |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 99 | static const uint32_t SPRITE_COLOR_KEY = 0x00aaaaaa; |
Jesse Barnes | 24e6038 | 2011-10-24 17:15:34 +0200 | [diff] [blame] | 100 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 101 | /* |
| 102 | * Mode setting with the kernel interfaces is a bit of a chore. |
| 103 | * First you have to find the connector in question and make sure the |
| 104 | * requested mode is available. |
| 105 | * Then you need to find the encoder attached to that connector so you |
| 106 | * can bind it with a free crtc. |
| 107 | */ |
| 108 | struct connector { |
| 109 | uint32_t id; |
| 110 | int mode_valid; |
| 111 | drmModeModeInfo mode; |
| 112 | drmModeEncoder *encoder; |
| 113 | drmModeConnector *connector; |
| 114 | int crtc; |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 115 | int crtc_idx; |
Jesse Barnes | 9c29be4 | 2011-11-02 12:57:40 -0700 | [diff] [blame] | 116 | int pipe; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 117 | }; |
| 118 | |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 119 | static void dump_connectors_fd(int drmfd) |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 120 | { |
| 121 | int i, j; |
| 122 | |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 123 | drmModeRes *mode_resources = drmModeGetResources(drmfd); |
| 124 | |
| 125 | if (!mode_resources) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 126 | igt_warn("drmModeGetResources failed: %s\n", strerror(errno)); |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 127 | return; |
| 128 | } |
| 129 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 130 | igt_info("Connectors:\n"); |
| 131 | igt_info("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n"); |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 132 | for (i = 0; i < mode_resources->count_connectors; i++) { |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 133 | drmModeConnector *connector; |
| 134 | |
Daniel Vetter | db4f83c | 2015-12-01 11:24:19 +0100 | [diff] [blame] | 135 | connector = drmModeGetConnectorCurrent(drmfd, |
| 136 | mode_resources->connectors[i]); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 137 | if (!connector) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 138 | igt_warn("could not get connector %i: %s\n", mode_resources->connectors[i], strerror(errno)); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 139 | continue; |
| 140 | } |
| 141 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 142 | igt_info("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n", connector->connector_id, connector->encoder_id, kmstest_connector_status_str(connector->connection), kmstest_connector_type_str(connector->connector_type), connector->mmWidth, connector->mmHeight, connector->count_modes); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 143 | |
| 144 | if (!connector->count_modes) |
| 145 | continue; |
| 146 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 147 | igt_info(" modes:\n"); |
| 148 | igt_info(" name refresh (Hz) hdisp hss hse htot vdisp ""vss vse vtot flags type clock\n"); |
Yi Sun | 53895ac | 2012-09-25 17:13:17 +0800 | [diff] [blame] | 149 | for (j = 0; j < connector->count_modes; j++){ |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 150 | igt_info("[%d]", j); |
Daniel Vetter | 17787f3 | 2012-05-22 16:15:15 +0200 | [diff] [blame] | 151 | kmstest_dump_mode(&connector->modes[j]); |
Yi Sun | 53895ac | 2012-09-25 17:13:17 +0800 | [diff] [blame] | 152 | } |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 153 | |
| 154 | drmModeFreeConnector(connector); |
| 155 | } |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 156 | igt_info("\n"); |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 157 | |
| 158 | drmModeFreeResources(mode_resources); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 159 | } |
| 160 | |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 161 | static void dump_crtcs_fd(int drmfd) |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 162 | { |
| 163 | int i; |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 164 | drmModeRes *mode_resources = drmModeGetResources(drmfd); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 165 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 166 | igt_info("CRTCs:\n"); |
| 167 | igt_info("id\tfb\tpos\tsize\n"); |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 168 | for (i = 0; i < mode_resources->count_crtcs; i++) { |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 169 | drmModeCrtc *crtc; |
| 170 | |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 171 | crtc = drmModeGetCrtc(drmfd, mode_resources->crtcs[i]); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 172 | if (!crtc) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 173 | igt_warn("could not get crtc %i: %s\n", mode_resources->crtcs[i], strerror(errno)); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 174 | continue; |
| 175 | } |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 176 | igt_info("%d\t%d\t(%d,%d)\t(%dx%d)\n", crtc->crtc_id, crtc->buffer_id, crtc->x, crtc->y, crtc->width, crtc->height); |
Daniel Vetter | 17787f3 | 2012-05-22 16:15:15 +0200 | [diff] [blame] | 177 | kmstest_dump_mode(&crtc->mode); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 178 | |
| 179 | drmModeFreeCrtc(crtc); |
| 180 | } |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 181 | igt_info("\n"); |
Yi Sun | 3d46ca8 | 2012-02-03 22:45:39 +0800 | [diff] [blame] | 182 | |
| 183 | drmModeFreeResources(mode_resources); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 184 | } |
| 185 | |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 186 | static void dump_info(void) |
| 187 | { |
| 188 | dump_connectors_fd(drm_fd); |
| 189 | dump_crtcs_fd(drm_fd); |
| 190 | } |
| 191 | |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 192 | static void connector_find_preferred_mode(uint32_t connector_id, |
| 193 | unsigned long crtc_idx_mask, |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 194 | int mode_num, struct connector *c, |
| 195 | bool probe) |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 196 | { |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 197 | struct kmstest_connector_config config; |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 198 | bool ret; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 199 | |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 200 | if (probe) |
| 201 | ret = kmstest_probe_connector_config(drm_fd, connector_id, |
| 202 | crtc_idx_mask, &config); |
| 203 | else |
| 204 | ret = kmstest_get_connector_config(drm_fd, connector_id, |
| 205 | crtc_idx_mask, &config); |
| 206 | if (!ret) { |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 207 | c->mode_valid = 0; |
| 208 | return; |
| 209 | } |
| 210 | |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 211 | c->connector = config.connector; |
| 212 | c->encoder = config.encoder; |
| 213 | c->crtc = config.crtc->crtc_id; |
| 214 | c->crtc_idx = config.crtc_idx; |
| 215 | c->pipe = config.pipe; |
| 216 | |
| 217 | if (mode_num != -1) { |
Daniel Vetter | 8344095 | 2013-08-13 12:35:58 +0200 | [diff] [blame] | 218 | igt_assert(mode_num < config.connector->count_modes); |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 219 | c->mode = config.connector->modes[mode_num]; |
| 220 | } else { |
| 221 | c->mode = config.default_mode; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 222 | } |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 223 | c->mode_valid = 1; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Jesse Barnes | 0d3043f | 2011-04-18 16:48:27 -0700 | [diff] [blame] | 226 | static void |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 227 | paint_color_key(struct igt_fb *fb_info) |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 228 | { |
Tomeu Vizoso | 99bdf4f | 2016-05-06 15:36:22 +0200 | [diff] [blame] | 229 | cairo_t *cr = igt_get_cairo_ctx(drm_fd, fb_info); |
Damien Lespiau | 5a1d843 | 2013-09-04 12:12:37 +0100 | [diff] [blame] | 230 | |
Tomeu Vizoso | 99bdf4f | 2016-05-06 15:36:22 +0200 | [diff] [blame] | 231 | cairo_rectangle(cr, crtc_x, crtc_y, crtc_w, crtc_h); |
| 232 | cairo_set_source_rgb(cr, .8, .8, .8); |
| 233 | cairo_fill(cr); |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 234 | |
Tomeu Vizoso | 99bdf4f | 2016-05-06 15:36:22 +0200 | [diff] [blame] | 235 | igt_assert(!cairo_status(cr)); |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 236 | |
Tomeu Vizoso | 99bdf4f | 2016-05-06 15:36:22 +0200 | [diff] [blame] | 237 | cairo_destroy(cr); |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 240 | static void paint_image(cairo_t *cr, const char *file) |
| 241 | { |
Thomas Wood | ecb0326 | 2015-04-13 17:37:22 +0100 | [diff] [blame] | 242 | int img_x, img_y, img_w, img_h; |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 243 | |
| 244 | img_y = height * (0.10 ); |
| 245 | img_h = height * 0.08 * 4; |
| 246 | img_w = img_h; |
| 247 | |
| 248 | img_x = (width / 2) - (img_w / 2); |
| 249 | |
Thomas Wood | ecb0326 | 2015-04-13 17:37:22 +0100 | [diff] [blame] | 250 | igt_paint_image(cr, file, img_x, img_y, img_h, img_w); |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 251 | } |
| 252 | |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 253 | static void paint_output_info(struct connector *c, struct igt_fb *fb) |
Jesse Barnes | 0d3043f | 2011-04-18 16:48:27 -0700 | [diff] [blame] | 254 | { |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 255 | cairo_t *cr = igt_get_cairo_ctx(drm_fd, fb); |
Imre Deak | f68d964 | 2013-05-24 17:26:54 +0300 | [diff] [blame] | 256 | int l_width = fb->width; |
| 257 | int l_height = fb->height; |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 258 | double str_width; |
| 259 | double x, y, top_y; |
| 260 | double max_width; |
| 261 | int i; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 262 | |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 263 | cairo_move_to(cr, l_width / 2, l_height / 2); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 264 | |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 265 | /* Print connector and mode name */ |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 266 | cairo_set_font_size(cr, 48); |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 267 | igt_cairo_printf_line(cr, align_hcenter, 10, "%s", |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 268 | kmstest_connector_type_str(c->connector->connector_type)); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 269 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 270 | cairo_set_font_size(cr, 36); |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 271 | str_width = igt_cairo_printf_line(cr, align_hcenter, 10, |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 272 | "%s @ %dHz on %s encoder", c->mode.name, c->mode.vrefresh, |
| 273 | kmstest_encoder_type_str(c->encoder->encoder_type)); |
| 274 | |
| 275 | cairo_rel_move_to(cr, -str_width / 2, 0); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 276 | |
| 277 | /* List available modes */ |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 278 | cairo_set_font_size(cr, 18); |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 279 | str_width = igt_cairo_printf_line(cr, align_left, 10, |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 280 | "Available modes:"); |
| 281 | cairo_rel_move_to(cr, str_width, 0); |
| 282 | cairo_get_current_point(cr, &x, &top_y); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 283 | |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 284 | max_width = 0; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 285 | for (i = 0; i < c->connector->count_modes; i++) { |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 286 | cairo_get_current_point(cr, &x, &y); |
| 287 | if (y >= l_height) { |
| 288 | x += max_width + 10; |
| 289 | max_width = 0; |
| 290 | cairo_move_to(cr, x, top_y); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 291 | } |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 292 | str_width = igt_cairo_printf_line(cr, align_right, 10, |
Imre Deak | 542a40c | 2013-05-30 15:03:48 +0300 | [diff] [blame] | 293 | "%s @ %dHz", c->connector->modes[i].name, |
| 294 | c->connector->modes[i].vrefresh); |
| 295 | if (str_width > max_width) |
| 296 | max_width = str_width; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 297 | } |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 298 | |
| 299 | if (qr_code) |
Joonas Lahtinen | a95033f | 2015-03-31 15:53:17 +0300 | [diff] [blame] | 300 | paint_image(cr, "pass.png"); |
Imre Deak | f68d964 | 2013-05-24 17:26:54 +0300 | [diff] [blame] | 301 | |
Daniel Vetter | 8344095 | 2013-08-13 12:35:58 +0200 | [diff] [blame] | 302 | igt_assert(!cairo_status(cr)); |
Damien Lespiau | 660a7ff | 2014-06-30 16:19:05 +0100 | [diff] [blame] | 303 | |
| 304 | cairo_destroy(cr); |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static void sighandler(int signo) |
| 308 | { |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | static void set_single(void) |
| 313 | { |
| 314 | int sigs[] = { SIGUSR1 }; |
| 315 | struct sigaction sa; |
| 316 | sa.sa_handler = sighandler; |
| 317 | |
| 318 | sigemptyset(&sa.sa_mask); |
| 319 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 320 | igt_warn_on_f(sigaction(sigs[0], &sa, NULL) == -1, |
| 321 | "Could not set signal handler"); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 322 | } |
| 323 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 324 | static void |
| 325 | set_mode(struct connector *c) |
| 326 | { |
Daniel Vetter | 434be47 | 2012-07-21 17:36:36 +0200 | [diff] [blame] | 327 | unsigned int fb_id = 0; |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 328 | struct igt_fb fb_info[2] = { }; |
Damien Lespiau | eecd006 | 2013-09-03 19:46:19 +0100 | [diff] [blame] | 329 | int j, test_mode_num, current_fb = 0, old_fb = -1; |
Jesse Barnes | c56cd10 | 2011-04-19 11:50:16 -0700 | [diff] [blame] | 330 | |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 331 | test_mode_num = 1; |
| 332 | if (force_mode){ |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 333 | memcpy( &c->mode, &force_timing, sizeof(force_timing)); |
| 334 | c->mode.vrefresh =(force_timing.clock*1e3)/(force_timing.htotal*force_timing.vtotal); |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 335 | c->mode_valid = 1; |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 336 | sprintf(c->mode.name, "%dx%d", force_timing.hdisplay, force_timing.vdisplay); |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 337 | } else if (test_all_modes) |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 338 | test_mode_num = c->connector->count_modes; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 339 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 340 | for (j = 0; j < test_mode_num; j++) { |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 341 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 342 | if (test_all_modes) |
| 343 | c->mode = c->connector->modes[j]; |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 344 | |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 345 | /* set_mode() only tests 2D modes */ |
Damien Lespiau | a7d1937 | 2013-09-26 17:56:01 +0100 | [diff] [blame] | 346 | if (c->mode.flags & DRM_MODE_FLAG_3D_MASK) |
| 347 | continue; |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 348 | |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 349 | if (!c->mode_valid) |
| 350 | continue; |
| 351 | |
| 352 | width = c->mode.hdisplay; |
| 353 | height = c->mode.vdisplay; |
| 354 | |
Ville Syrjälä | 5b113d3 | 2015-12-17 01:39:31 +0200 | [diff] [blame] | 355 | fb_id = igt_create_pattern_fb(drm_fd, width, height, |
| 356 | igt_bpp_depth_to_drm_format(bpp, depth), |
| 357 | tiling, &fb_info[current_fb]); |
Damien Lespiau | eecd006 | 2013-09-03 19:46:19 +0100 | [diff] [blame] | 358 | paint_output_info(c, &fb_info[current_fb]); |
| 359 | paint_color_key(&fb_info[current_fb]); |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 360 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 361 | igt_info("CRTC(%u):[%d]", c->crtc, j); |
Daniel Vetter | 17787f3 | 2012-05-22 16:15:15 +0200 | [diff] [blame] | 362 | kmstest_dump_mode(&c->mode); |
Daniel Vetter | 73d1b88 | 2012-01-10 18:20:39 +0100 | [diff] [blame] | 363 | if (drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 364 | &c->id, 1, &c->mode)) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 365 | igt_warn("failed to set mode (%dx%d@%dHz): %s\n", width, height, c->mode.vrefresh, strerror(errno)); |
Ander Conselvan de Oliveira | 571942f | 2015-05-27 10:33:41 +0300 | [diff] [blame] | 366 | igt_remove_fb(drm_fd, &fb_info[current_fb]); |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 367 | continue; |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 368 | } |
| 369 | |
Damien Lespiau | eecd006 | 2013-09-03 19:46:19 +0100 | [diff] [blame] | 370 | if (old_fb != -1) |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 371 | igt_remove_fb(drm_fd, &fb_info[old_fb]); |
Damien Lespiau | eecd006 | 2013-09-03 19:46:19 +0100 | [diff] [blame] | 372 | old_fb = current_fb; |
| 373 | current_fb = 1 - current_fb; |
| 374 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 375 | if (sleep_between_modes && test_all_modes && !qr_code) |
Hai Lan | dac602b | 2011-02-11 23:25:36 -0500 | [diff] [blame] | 376 | sleep(sleep_between_modes); |
Yi Sun | 1f41a30 | 2011-12-01 18:57:16 +0800 | [diff] [blame] | 377 | |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 378 | if (do_dpms) { |
Daniel Vetter | 29ee36f | 2014-04-24 23:33:09 +0200 | [diff] [blame] | 379 | kmstest_set_connector_dpms(drm_fd, c->connector, do_dpms); |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 380 | sleep(sleep_between_modes); |
Daniel Vetter | 29ee36f | 2014-04-24 23:33:09 +0200 | [diff] [blame] | 381 | kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_ON); |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 382 | } |
| 383 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 384 | if (qr_code){ |
| 385 | set_single(); |
| 386 | pause(); |
| 387 | } |
Yi Sun | 1f41a30 | 2011-12-01 18:57:16 +0800 | [diff] [blame] | 388 | } |
| 389 | |
Ander Conselvan de Oliveira | 571942f | 2015-05-27 10:33:41 +0300 | [diff] [blame] | 390 | if (test_all_modes && old_fb != -1) |
Daniel Vetter | 9aea7ae | 2014-03-26 09:18:11 +0100 | [diff] [blame] | 391 | igt_remove_fb(drm_fd, &fb_info[old_fb]); |
Chris Wilson | 5534cb1 | 2011-02-11 10:48:04 +0000 | [diff] [blame] | 392 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 393 | drmModeFreeEncoder(c->encoder); |
| 394 | drmModeFreeConnector(c->connector); |
| 395 | } |
| 396 | |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 397 | static void do_set_stereo_mode(struct connector *c) |
| 398 | { |
| 399 | uint32_t fb_id; |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 400 | |
Thomas Wood | 4cb1946 | 2014-08-04 16:14:51 +0100 | [diff] [blame] | 401 | fb_id = igt_create_stereo_fb(drm_fd, &c->mode, |
| 402 | igt_bpp_depth_to_drm_format(bpp, depth), |
| 403 | tiling); |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 404 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 405 | igt_warn_on_f(drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, &c->id, 1, &c->mode), |
| 406 | "failed to set mode (%dx%d@%dHz): %s\n", width, height, c->mode.vrefresh, strerror(errno)); |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | static void |
| 410 | set_stereo_mode(struct connector *c) |
| 411 | { |
Damien Lespiau | e836b60 | 2013-09-30 17:42:33 +0100 | [diff] [blame] | 412 | int i, n; |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 413 | |
Damien Lespiau | e836b60 | 2013-09-30 17:42:33 +0100 | [diff] [blame] | 414 | |
| 415 | if (specified_mode_num != -1) |
| 416 | n = 1; |
| 417 | else |
| 418 | n = c->connector->count_modes; |
| 419 | |
| 420 | for (i = 0; i < n; i++) { |
| 421 | if (specified_mode_num == -1) |
| 422 | c->mode = c->connector->modes[i]; |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 423 | |
| 424 | if (!c->mode_valid) |
| 425 | continue; |
| 426 | |
Damien Lespiau | a7d1937 | 2013-09-26 17:56:01 +0100 | [diff] [blame] | 427 | if (!(c->mode.flags & DRM_MODE_FLAG_3D_MASK)) |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 428 | continue; |
| 429 | |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 430 | igt_info("CRTC(%u): [%d]", c->crtc, i); |
Damien Lespiau | 6de613f | 2013-09-30 18:03:33 +0100 | [diff] [blame] | 431 | kmstest_dump_mode(&c->mode); |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 432 | do_set_stereo_mode(c); |
| 433 | |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 434 | if (qr_code) { |
| 435 | set_single(); |
| 436 | pause(); |
| 437 | } else if (sleep_between_modes) |
| 438 | sleep(sleep_between_modes); |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 439 | |
| 440 | if (do_dpms) { |
Daniel Vetter | 29ee36f | 2014-04-24 23:33:09 +0200 | [diff] [blame] | 441 | kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_OFF); |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 442 | sleep(sleep_between_modes); |
Daniel Vetter | 29ee36f | 2014-04-24 23:33:09 +0200 | [diff] [blame] | 443 | kmstest_set_connector_dpms(drm_fd, c->connector, DRM_MODE_DPMS_ON); |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 444 | } |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | drmModeFreeEncoder(c->encoder); |
| 448 | drmModeFreeConnector(c->connector); |
| 449 | } |
| 450 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 451 | /* |
| 452 | * Re-probe outputs and light up as many as possible. |
| 453 | * |
| 454 | * On Intel, we have two CRTCs that we can drive independently with |
| 455 | * different timings and scanout buffers. |
| 456 | * |
| 457 | * Each connector has a corresponding encoder, except in the SDVO case |
| 458 | * where an encoder may have multiple connectors. |
| 459 | */ |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 460 | int update_display(bool probe) |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 461 | { |
| 462 | struct connector *connectors; |
| 463 | int c; |
| 464 | |
Daniel Vetter | 73d1b88 | 2012-01-10 18:20:39 +0100 | [diff] [blame] | 465 | resources = drmModeGetResources(drm_fd); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 466 | if (!resources) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 467 | igt_warn("drmModeGetResources failed: %s\n", strerror(errno)); |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 468 | return 0; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | connectors = calloc(resources->count_connectors, |
| 472 | sizeof(struct connector)); |
| 473 | if (!connectors) |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 474 | return 0; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 475 | |
Damien Lespiau | e836b60 | 2013-09-30 17:42:33 +0100 | [diff] [blame] | 476 | if (test_preferred_mode || test_all_modes || |
| 477 | force_mode || specified_disp_id != -1) { |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 478 | unsigned long crtc_idx_mask = -1UL; |
| 479 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 480 | /* Find any connected displays */ |
| 481 | for (c = 0; c < resources->count_connectors; c++) { |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 482 | struct connector *connector = &connectors[c]; |
| 483 | |
| 484 | connector->id = resources->connectors[c]; |
| 485 | if (specified_disp_id != -1 && |
| 486 | connector->id != specified_disp_id) |
Yi Sun | 05bfbf4 | 2012-12-26 17:12:39 +0800 | [diff] [blame] | 487 | continue; |
| 488 | |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 489 | connector_find_preferred_mode(connector->id, |
| 490 | crtc_idx_mask, |
| 491 | specified_mode_num, |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 492 | connector, probe); |
Imre Deak | bfb0cdd | 2013-05-31 00:21:43 +0300 | [diff] [blame] | 493 | if (!connector->mode_valid) |
| 494 | continue; |
| 495 | |
| 496 | set_mode(connector); |
| 497 | |
| 498 | if (test_preferred_mode || force_mode || |
| 499 | specified_mode_num != -1) |
| 500 | crtc_idx_mask &= ~(1 << connector->crtc_idx); |
| 501 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 502 | } |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 503 | } |
Damien Lespiau | 5d99634 | 2013-09-04 14:21:55 +0100 | [diff] [blame] | 504 | |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 505 | if (test_stereo_modes) { |
| 506 | for (c = 0; c < resources->count_connectors; c++) { |
| 507 | struct connector *connector = &connectors[c]; |
| 508 | |
| 509 | connector->id = resources->connectors[c]; |
Damien Lespiau | c128b73 | 2013-09-30 17:02:21 +0100 | [diff] [blame] | 510 | if (specified_disp_id != -1 && |
| 511 | connector->id != specified_disp_id) |
| 512 | continue; |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 513 | |
| 514 | connector_find_preferred_mode(connector->id, |
| 515 | -1UL, |
| 516 | specified_mode_num, |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 517 | connector, probe); |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 518 | if (!connector->mode_valid) |
| 519 | continue; |
| 520 | |
| 521 | set_stereo_mode(connector); |
| 522 | } |
| 523 | } |
| 524 | |
Damien Lespiau | 5d99634 | 2013-09-04 14:21:55 +0100 | [diff] [blame] | 525 | free(connectors); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 526 | drmModeFreeResources(resources); |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 527 | return 1; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 528 | } |
| 529 | |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 530 | static char optstr[] = "3hiaf:s:d:p:mrto:j:y"; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 531 | |
Thomas Wood | db425d6 | 2014-10-31 12:32:22 +0000 | [diff] [blame] | 532 | static void __attribute__((noreturn)) usage(char *name, char opt) |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 533 | { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 534 | igt_info("usage: %s [-hiasdpmtf]\n", name); |
| 535 | igt_info("\t-i\tdump info\n"); |
| 536 | igt_info("\t-a\ttest all modes\n"); |
| 537 | igt_info("\t-s\t<duration>\tsleep between each mode test\n"); |
| 538 | igt_info("\t-d\t<depth>\tbit depth of scanout buffer\n"); |
| 539 | igt_info("\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n"); |
| 540 | igt_info("\t-m\ttest the preferred mode\n"); |
| 541 | igt_info("\t-3\ttest all 3D modes\n"); |
| 542 | igt_info("\t-t\tuse a tiled framebuffer\n"); |
| 543 | igt_info("\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n"); |
| 544 | igt_info("\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n"); |
| 545 | igt_info("\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n"); |
| 546 | igt_info("\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n"); |
| 547 | igt_info("\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n"); |
| 548 | igt_info("\t\ttest force mode\n"); |
| 549 | igt_info("\tDefault is to test all modes.\n"); |
Thomas Wood | db425d6 | 2014-10-31 12:32:22 +0000 | [diff] [blame] | 550 | exit((opt != 'h') ? -1 : 0); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 551 | } |
| 552 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 553 | #define dump_resource(res) if (res) dump_##res() |
| 554 | |
Thomas Wood | 36b8143 | 2015-11-02 10:02:08 +0000 | [diff] [blame] | 555 | static void __attribute__((noreturn)) cleanup_and_exit(int ret) |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 556 | { |
| 557 | close(drm_fd); |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 558 | exit(ret); |
| 559 | } |
| 560 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 561 | static gboolean input_event(GIOChannel *source, GIOCondition condition, |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 562 | gpointer data) |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 563 | { |
Daniel Vetter | 74d6545 | 2011-12-18 00:24:45 +0100 | [diff] [blame] | 564 | gchar buf[2]; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 565 | gsize count; |
| 566 | |
Chris Wilson | 2803238 | 2011-02-11 10:56:41 +0000 | [diff] [blame] | 567 | count = read(g_io_channel_unix_get_fd(source), buf, sizeof(buf)); |
Jesse Barnes | 24e6038 | 2011-10-24 17:15:34 +0200 | [diff] [blame] | 568 | if (buf[0] == 'q' && (count == 1 || buf[1] == '\n')) { |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 569 | cleanup_and_exit(0); |
Jesse Barnes | ea41633 | 2012-02-27 12:46:11 -0800 | [diff] [blame] | 570 | } |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 571 | |
| 572 | return TRUE; |
| 573 | } |
| 574 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 575 | static void enter_exec_path( char **argv ) |
| 576 | { |
| 577 | char *exec_path = NULL; |
| 578 | char *pos = NULL; |
| 579 | short len_path = 0; |
Imre Deak | 31dfc98 | 2012-10-10 16:04:45 +0300 | [diff] [blame] | 580 | int ret; |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 581 | |
| 582 | len_path = strlen( argv[0] ); |
| 583 | exec_path = (char*) malloc(len_path); |
| 584 | |
| 585 | memcpy(exec_path, argv[0], len_path); |
| 586 | pos = strrchr(exec_path, '/'); |
| 587 | if (pos != NULL) |
| 588 | *(pos+1) = '\0'; |
| 589 | |
Imre Deak | 31dfc98 | 2012-10-10 16:04:45 +0300 | [diff] [blame] | 590 | ret = chdir(exec_path); |
Matt Roper | 07be8fe | 2015-03-05 15:01:00 -0800 | [diff] [blame] | 591 | igt_assert_eq(ret, 0); |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 592 | free(exec_path); |
| 593 | } |
| 594 | |
Imre Deak | 6374641 | 2014-05-12 13:29:49 +0300 | [diff] [blame] | 595 | static void restore_termio_mode(int sig) |
| 596 | { |
| 597 | tcsetattr(tio_fd, TCSANOW, &saved_tio); |
| 598 | close(tio_fd); |
| 599 | } |
| 600 | |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 601 | static void set_termio_mode(void) |
| 602 | { |
| 603 | struct termios tio; |
| 604 | |
Thomas Wood | 8408e00 | 2014-07-24 17:45:48 +0100 | [diff] [blame] | 605 | /* don't attempt to set terminal attributes if not in the foreground |
| 606 | * process group */ |
| 607 | if (getpgrp() != tcgetpgrp(STDOUT_FILENO)) |
| 608 | return; |
| 609 | |
Imre Deak | 6374641 | 2014-05-12 13:29:49 +0300 | [diff] [blame] | 610 | tio_fd = dup(STDIN_FILENO); |
| 611 | tcgetattr(tio_fd, &saved_tio); |
| 612 | igt_install_exit_handler(restore_termio_mode); |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 613 | tio = saved_tio; |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 614 | tio.c_lflag &= ~(ICANON | ECHO); |
Imre Deak | 6374641 | 2014-05-12 13:29:49 +0300 | [diff] [blame] | 615 | tcsetattr(tio_fd, TCSANOW, &tio); |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 616 | } |
| 617 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 618 | int main(int argc, char **argv) |
| 619 | { |
| 620 | int c; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 621 | int ret = 0; |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 622 | GIOChannel *stdinchannel; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 623 | GMainLoop *mainloop; |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 624 | float force_clock; |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 625 | bool opt_dump_info = false; |
Thomas Wood | ff6b068 | 2014-07-31 16:26:55 +0100 | [diff] [blame] | 626 | struct option long_opts[] = { |
| 627 | {"list-subtests", 0, 0, SUBTEST_OPTS}, |
| 628 | {"run-subtest", 1, 0, SUBTEST_OPTS}, |
Thomas Wood | 895204f | 2014-10-30 15:54:02 +0000 | [diff] [blame] | 629 | {"help-description", 0, 0, HELP_DESCRIPTION}, |
Thomas Wood | ce0d34d | 2014-10-31 15:00:03 +0000 | [diff] [blame] | 630 | {"help", 0, 0, 'h'}, |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 631 | {"yb", 0, 0, Yb_OPT}, |
| 632 | {"yf", 0, 0, Yf_OPT}, |
Thomas Wood | ff6b068 | 2014-07-31 16:26:55 +0100 | [diff] [blame] | 633 | { 0, 0, 0, 0 } |
| 634 | }; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 635 | |
Daniel Vetter | 1caaf0a | 2013-08-12 12:17:35 +0200 | [diff] [blame] | 636 | igt_skip_on_simulation(); |
Damien Lespiau | 5fa15f7 | 2013-04-29 18:40:39 +0100 | [diff] [blame] | 637 | |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 638 | enter_exec_path( argv ); |
| 639 | |
Thomas Wood | ff6b068 | 2014-07-31 16:26:55 +0100 | [diff] [blame] | 640 | while ((c = getopt_long(argc, argv, optstr, long_opts, NULL)) != -1) { |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 641 | switch (c) { |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 642 | case '3': |
| 643 | test_stereo_modes = 1; |
| 644 | break; |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 645 | case 'i': |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 646 | opt_dump_info = true; |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 647 | break; |
| 648 | case 'a': |
| 649 | test_all_modes = 1; |
| 650 | break; |
| 651 | case 'f': |
| 652 | force_mode = 1; |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 653 | if(sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu", |
| 654 | &force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal, |
| 655 | &force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9) |
Thomas Wood | db425d6 | 2014-10-31 12:32:22 +0000 | [diff] [blame] | 656 | usage(argv[0], c); |
Yi Sun | 4cceae7 | 2012-02-03 19:23:55 +0800 | [diff] [blame] | 657 | force_timing.clock = force_clock*1000; |
| 658 | |
Hai Lan | 62d5168 | 2011-02-11 11:14:15 -0500 | [diff] [blame] | 659 | break; |
| 660 | case 's': |
| 661 | sleep_between_modes = atoi(optarg); |
| 662 | break; |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 663 | case 'j': |
Daniel Vetter | cef9b31 | 2014-02-13 19:22:35 +0100 | [diff] [blame] | 664 | do_dpms = atoi(optarg); |
| 665 | if (do_dpms == 0) |
| 666 | do_dpms = DRM_MODE_DPMS_OFF; |
Daniel Vetter | 30cfde5 | 2014-02-13 19:15:38 +0100 | [diff] [blame] | 667 | break; |
Jesse Barnes | c56cd10 | 2011-04-19 11:50:16 -0700 | [diff] [blame] | 668 | case 'd': |
| 669 | depth = atoi(optarg); |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 670 | igt_info("using depth %d\n", depth); |
Jesse Barnes | c56cd10 | 2011-04-19 11:50:16 -0700 | [diff] [blame] | 671 | break; |
Jesse Barnes | 7230c01 | 2011-06-07 13:17:46 -0700 | [diff] [blame] | 672 | case 'p': |
Jesse Barnes | 5a9d82c | 2011-12-07 08:22:41 -0800 | [diff] [blame] | 673 | if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width, |
| 674 | &plane_height, &crtc_x, &crtc_y, |
| 675 | &crtc_w, &crtc_h) != 6) |
Thomas Wood | db425d6 | 2014-10-31 12:32:22 +0000 | [diff] [blame] | 676 | usage(argv[0], c); |
Jesse Barnes | 7230c01 | 2011-06-07 13:17:46 -0700 | [diff] [blame] | 677 | test_plane = 1; |
| 678 | break; |
Paulo Zanoni | 9fe1148 | 2011-09-15 15:13:41 -0300 | [diff] [blame] | 679 | case 'm': |
| 680 | test_preferred_mode = 1; |
| 681 | break; |
Jesse Barnes | b707feb | 2011-06-07 13:27:35 -0700 | [diff] [blame] | 682 | case 't': |
Tvrtko Ursulin | e36091d | 2015-03-03 14:11:01 +0000 | [diff] [blame] | 683 | tiling = LOCAL_I915_FORMAT_MOD_X_TILED; |
Jesse Barnes | b707feb | 2011-06-07 13:27:35 -0700 | [diff] [blame] | 684 | break; |
Damien Lespiau | 7b8ba12 | 2015-03-03 14:11:05 +0000 | [diff] [blame] | 685 | case 'y': |
| 686 | case Yb_OPT: |
| 687 | tiling = LOCAL_I915_FORMAT_MOD_Y_TILED; |
| 688 | break; |
| 689 | case Yf_OPT: |
| 690 | tiling = LOCAL_I915_FORMAT_MOD_Yf_TILED; |
| 691 | break; |
Yi Sun | 41fe811 | 2012-07-26 14:23:36 +0800 | [diff] [blame] | 692 | case 'r': |
| 693 | qr_code = 1; |
| 694 | break; |
Yi Sun | 53895ac | 2012-09-25 17:13:17 +0800 | [diff] [blame] | 695 | case 'o': |
Yi Sun | 05bfbf4 | 2012-12-26 17:12:39 +0800 | [diff] [blame] | 696 | sscanf(optarg, "%d,%d", &specified_disp_id, &specified_mode_num); |
Yi Sun | 53895ac | 2012-09-25 17:13:17 +0800 | [diff] [blame] | 697 | break; |
Thomas Wood | ff6b068 | 2014-07-31 16:26:55 +0100 | [diff] [blame] | 698 | case SUBTEST_OPTS: |
| 699 | /* invalid subtest options */ |
| 700 | exit(IGT_EXIT_INVALID); |
| 701 | break; |
Thomas Wood | 895204f | 2014-10-30 15:54:02 +0000 | [diff] [blame] | 702 | case HELP_DESCRIPTION: |
Matt Roper | 07be8fe | 2015-03-05 15:01:00 -0800 | [diff] [blame] | 703 | igt_info("Tests display functionality."); |
Thomas Wood | 895204f | 2014-10-30 15:54:02 +0000 | [diff] [blame] | 704 | exit(0); |
| 705 | break; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 706 | default: |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 707 | /* fall through */ |
| 708 | case 'h': |
Thomas Wood | db425d6 | 2014-10-31 12:32:22 +0000 | [diff] [blame] | 709 | usage(argv[0], c); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 710 | break; |
| 711 | } |
| 712 | } |
Damien Lespiau | 0396273 | 2013-09-03 14:57:31 +0100 | [diff] [blame] | 713 | |
Jesse Barnes | 7255a84 | 2014-03-26 11:02:48 -0700 | [diff] [blame] | 714 | set_termio_mode(); |
| 715 | |
Damien Lespiau | 0396273 | 2013-09-03 14:57:31 +0100 | [diff] [blame] | 716 | if (depth <= 8) |
| 717 | bpp = 8; |
| 718 | else if (depth <= 16) |
| 719 | bpp = 16; |
| 720 | else if (depth <= 32) |
| 721 | bpp = 32; |
| 722 | |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 723 | if (!test_all_modes && !force_mode && !test_preferred_mode && |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 724 | specified_mode_num == -1 && !test_stereo_modes) |
Paulo Zanoni | 9fe1148 | 2011-09-15 15:13:41 -0300 | [diff] [blame] | 725 | test_all_modes = 1; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 726 | |
Tomeu Vizoso | 7aee511 | 2016-05-06 15:36:23 +0200 | [diff] [blame] | 727 | drm_fd = drm_open_driver(DRIVER_ANY); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 728 | |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 729 | if (test_stereo_modes && |
| 730 | drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) < 0) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 731 | igt_warn("DRM_CLIENT_CAP_STEREO_3D failed\n"); |
Damien Lespiau | 9a8fda7 | 2012-09-10 13:33:26 +0100 | [diff] [blame] | 732 | goto out_close; |
| 733 | } |
| 734 | |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 735 | if (opt_dump_info) { |
| 736 | dump_info(); |
| 737 | goto out_close; |
| 738 | } |
| 739 | |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 740 | kmstest_set_vt_graphics_mode(); |
Imre Deak | 01b408e | 2013-05-08 19:06:44 +0300 | [diff] [blame] | 741 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 742 | mainloop = g_main_loop_new(NULL, FALSE); |
| 743 | if (!mainloop) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 744 | igt_warn("failed to create glib mainloop\n"); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 745 | ret = -1; |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 746 | goto out_close; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 747 | } |
| 748 | |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 749 | if (!testdisplay_setup_hotplug()) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 750 | igt_warn("failed to initialize hotplug support\n"); |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 751 | goto out_mainloop; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | stdinchannel = g_io_channel_unix_new(0); |
| 755 | if (!stdinchannel) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 756 | igt_warn("failed to create stdin GIO channel\n"); |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 757 | goto out_hotplug; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | ret = g_io_add_watch(stdinchannel, G_IO_IN | G_IO_ERR, input_event, |
| 761 | NULL); |
| 762 | if (ret < 0) { |
Daniel Vetter | c9c5545 | 2014-06-13 18:27:59 +0200 | [diff] [blame] | 763 | igt_warn("failed to add watch on stdin GIO channel\n"); |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 764 | goto out_stdio; |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 765 | } |
| 766 | |
Paulo Zanoni | 17cecce | 2011-09-16 18:06:27 -0300 | [diff] [blame] | 767 | ret = 0; |
| 768 | |
Jesse Barnes | e28acef | 2016-01-14 14:03:53 -0800 | [diff] [blame] | 769 | if (!update_display(false)) { |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 770 | ret = 1; |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 771 | goto out_stdio; |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 772 | } |
| 773 | |
Damien Lespiau | 66477a2 | 2013-09-05 16:49:11 +0100 | [diff] [blame] | 774 | if (test_all_modes) |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 775 | goto out_stdio; |
Paulo Zanoni | 7ead7ba | 2011-09-15 15:14:18 -0300 | [diff] [blame] | 776 | |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 777 | g_main_loop_run(mainloop); |
| 778 | |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 779 | out_stdio: |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 780 | g_io_channel_shutdown(stdinchannel, TRUE, NULL); |
Daniel Vetter | 7f7cafe | 2012-01-24 10:50:05 +0100 | [diff] [blame] | 781 | out_hotplug: |
| 782 | testdisplay_cleanup_hotplug(); |
| 783 | out_mainloop: |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 784 | g_main_loop_unref(mainloop); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 785 | out_close: |
Daniel Vetter | 0732cc5 | 2012-05-22 12:01:36 +0200 | [diff] [blame] | 786 | close(drm_fd); |
| 787 | |
Matt Roper | 07be8fe | 2015-03-05 15:01:00 -0800 | [diff] [blame] | 788 | igt_assert_eq(ret, 0); |
Daniel Vetter | 4306538 | 2014-10-02 11:18:20 +0200 | [diff] [blame] | 789 | |
| 790 | igt_exit(); |
Jesse Barnes | 5406c63 | 2010-12-21 09:38:23 -0800 | [diff] [blame] | 791 | } |