Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 1 | /* |
Damien Lespiau | 9cf7e8d | 2014-07-08 12:08:20 +0100 | [diff] [blame] | 2 | * Copyright © 2013,2014 Intel Corporation |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 3 | * |
| 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: |
| 10 | * |
| 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 |
| 13 | * 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 |
| 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | * |
| 23 | */ |
| 24 | |
Thomas Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 25 | #include "igt.h" |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 26 | #include <math.h> |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 27 | |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 28 | #define MAX_FENCES 32 |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 29 | |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 30 | typedef struct { |
| 31 | int gfx_fd; |
| 32 | igt_display_t display; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 33 | struct igt_fb fb; |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 34 | struct igt_fb fb_reference; |
Tvrtko Ursulin | d901106 | 2015-04-22 16:46:43 +0100 | [diff] [blame] | 35 | struct igt_fb fb_modeset; |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 36 | struct igt_fb fb_flip; |
Damien Lespiau | 19743a1 | 2014-07-08 12:59:03 +0100 | [diff] [blame] | 37 | igt_crc_t ref_crc; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 38 | igt_pipe_crc_t *pipe_crc; |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 39 | igt_rotation_t rotation; |
| 40 | int pos_x; |
| 41 | int pos_y; |
Tvrtko Ursulin | dbf6468 | 2015-04-22 16:46:48 +0100 | [diff] [blame] | 42 | uint32_t override_fmt; |
| 43 | uint64_t override_tiling; |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 44 | unsigned int flip_stress; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 45 | } data_t; |
| 46 | |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 47 | static void |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 48 | paint_squares(data_t *data, igt_rotation_t rotation, |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 49 | struct igt_fb *fb, float o) |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 50 | { |
| 51 | cairo_t *cr; |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 52 | unsigned int w = fb->width; |
| 53 | unsigned int h = fb->height; |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 54 | |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 55 | cr = igt_get_cairo_ctx(data->gfx_fd, fb); |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 56 | |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 57 | if (rotation == IGT_ROTATION_180) { |
| 58 | cairo_translate(cr, w, h); |
| 59 | cairo_rotate(cr, M_PI); |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 60 | } |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 61 | |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 62 | if (rotation == IGT_ROTATION_90) { |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 63 | /* Paint 4 squares with width == height in Green, White, |
| 64 | Blue, Red Clockwise order to look like 270 degree rotated*/ |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 65 | igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0); |
| 66 | igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o); |
| 67 | igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0); |
| 68 | igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o); |
Tvrtko Ursulin | f2a5896 | 2015-05-22 11:00:45 +0100 | [diff] [blame] | 69 | } else if (rotation == IGT_ROTATION_270) { |
| 70 | /* Paint 4 squares with width == height in Blue, Red, |
| 71 | Green, White Clockwise order to look like 90 degree rotated*/ |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 72 | igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o); |
| 73 | igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0); |
| 74 | igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, o, o); |
| 75 | igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, o, 0.0); |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 76 | } else { |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 77 | /* Paint with 4 squares of Red, Green, White, Blue Clockwise */ |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 78 | igt_paint_color(cr, 0, 0, w / 2, h / 2, o, 0.0, 0.0); |
| 79 | igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, o, 0.0); |
| 80 | igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, o); |
| 81 | igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, o, o, o); |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Damien Lespiau | 92b29b1 | 2014-07-08 12:49:03 +0100 | [diff] [blame] | 84 | cairo_destroy(cr); |
| 85 | } |
| 86 | |
Daniel Vetter | 57259d7 | 2014-11-24 16:08:32 +0100 | [diff] [blame] | 87 | static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 88 | igt_plane_t *plane, enum igt_commit_style commit) |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 89 | { |
| 90 | drmModeModeInfo *mode; |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 91 | unsigned int w, h; |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 92 | uint64_t tiling = data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE; |
| 93 | uint32_t pixel_format = data->override_fmt ?: DRM_FORMAT_XRGB8888; |
| 94 | igt_display_t *display = &data->display; |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 95 | igt_plane_t *primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 96 | |
Damien Lespiau | 8facccf | 2014-07-08 18:28:53 +0100 | [diff] [blame] | 97 | igt_output_set_pipe(output, pipe); |
Maarten Lankhorst | 44023a2 | 2017-01-31 13:31:57 +0100 | [diff] [blame] | 98 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 99 | |
| 100 | /* create the pipe_crc object for this pipe */ |
Damien Lespiau | 2eaa50f | 2014-07-08 18:56:15 +0100 | [diff] [blame] | 101 | igt_pipe_crc_free(data->pipe_crc); |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 102 | data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 103 | |
Damien Lespiau | 19743a1 | 2014-07-08 12:59:03 +0100 | [diff] [blame] | 104 | mode = igt_output_get_mode(output); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 105 | |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 106 | w = mode->hdisplay; |
| 107 | h = mode->vdisplay; |
| 108 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 109 | igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb_modeset); |
| 110 | |
| 111 | /* |
| 112 | * With igt_display_commit2 and COMMIT_UNIVERSAL, we call just the |
| 113 | * setplane without a modeset. So, to be able to call |
| 114 | * igt_display_commit and ultimately setcrtc to do the first modeset, |
| 115 | * we create an fb covering the crtc and call commit |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 116 | * |
| 117 | * It's also a good idea to set a primary fb on the primary plane |
| 118 | * regardless, to force a underrun when watermarks are allocated |
| 119 | * incorrectly for other planes. |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 120 | */ |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 121 | igt_plane_set_fb(primary, &data->fb_modeset); |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 122 | |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 123 | if (commit < COMMIT_ATOMIC) { |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 124 | primary->rotation_changed = false; |
| 125 | igt_display_commit(display); |
| 126 | |
| 127 | if (plane->type == DRM_PLANE_TYPE_PRIMARY) |
| 128 | primary->rotation_changed = true; |
| 129 | } |
| 130 | |
| 131 | igt_plane_set_fb(plane, NULL); |
| 132 | |
| 133 | igt_display_commit2(display, commit); |
| 134 | } |
| 135 | |
| 136 | static void remove_fbs(data_t *data) |
| 137 | { |
| 138 | if (!data->fb.fb_id) |
| 139 | return; |
| 140 | |
| 141 | igt_remove_fb(data->gfx_fd, &data->fb); |
| 142 | igt_remove_fb(data->gfx_fd, &data->fb_reference); |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 143 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 144 | if (data->fb_flip.fb_id) |
| 145 | igt_remove_fb(data->gfx_fd, &data->fb_flip); |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 146 | |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 147 | data->fb_flip.fb_id = data->fb.fb_id = 0; |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 148 | } |
| 149 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 150 | enum rectangle_type { |
| 151 | square, |
| 152 | portrait, |
| 153 | landscape, |
| 154 | num_rectangle_types /* must be last */ |
| 155 | }; |
| 156 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 157 | static void prepare_fbs(data_t *data, igt_output_t *output, |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 158 | igt_plane_t *plane, enum rectangle_type rect) |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 159 | { |
| 160 | drmModeModeInfo *mode; |
| 161 | igt_display_t *display = &data->display; |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 162 | unsigned int w, h, ref_w, ref_h, min_w, min_h; |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 163 | uint64_t tiling = data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE; |
| 164 | uint32_t pixel_format = data->override_fmt ?: DRM_FORMAT_XRGB8888; |
| 165 | |
| 166 | if (data->fb.fb_id) { |
| 167 | igt_plane_set_fb(plane, NULL); |
| 168 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL); |
| 169 | |
| 170 | remove_fbs(data); |
| 171 | } |
| 172 | |
| 173 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
| 174 | |
| 175 | mode = igt_output_get_mode(output); |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 176 | if (plane->type != DRM_PLANE_TYPE_CURSOR) { |
| 177 | w = mode->hdisplay; |
| 178 | h = mode->vdisplay; |
| 179 | |
| 180 | min_w = 256; |
| 181 | min_h = 256; |
| 182 | } else { |
| 183 | pixel_format = data->override_fmt ?: DRM_FORMAT_ARGB8888; |
| 184 | |
| 185 | w = h = 256; |
| 186 | min_w = min_h = 64; |
| 187 | } |
| 188 | |
| 189 | switch (rect) { |
| 190 | case square: |
| 191 | w = h = min(h, w); |
| 192 | break; |
| 193 | case portrait: |
| 194 | w = min_w; |
| 195 | break; |
| 196 | case landscape: |
| 197 | h = min_h; |
| 198 | break; |
| 199 | case num_rectangle_types: |
| 200 | igt_assert(0); |
| 201 | } |
| 202 | |
| 203 | ref_w = w; |
| 204 | ref_h = h; |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 205 | |
| 206 | /* |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 207 | * For 90/270, we will use create smaller fb so that the rotated |
| 208 | * frame can fit in |
| 209 | */ |
| 210 | if (data->rotation == IGT_ROTATION_90 || |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 211 | data->rotation == IGT_ROTATION_270) { |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 212 | tiling = data->override_tiling ?: LOCAL_I915_FORMAT_MOD_Y_TILED; |
| 213 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 214 | igt_swap(w, h); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 215 | } |
| 216 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 217 | igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb); |
Damien Lespiau | 282f560 | 2014-07-10 17:44:28 +0100 | [diff] [blame] | 218 | |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 219 | if (data->flip_stress) { |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 220 | igt_create_fb(data->gfx_fd, w, h, pixel_format, tiling, &data->fb_flip); |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 221 | paint_squares(data, IGT_ROTATION_0, &data->fb_flip, 0.92); |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Sonika Jindal | 4724698 | 2014-10-23 08:48:50 -0700 | [diff] [blame] | 224 | /* Step 1: create a reference CRC for a software-rotated fb */ |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 225 | igt_create_fb(data->gfx_fd, ref_w, ref_h, pixel_format, |
| 226 | data->override_tiling ?: LOCAL_DRM_FORMAT_MOD_NONE, &data->fb_reference); |
| 227 | paint_squares(data, data->rotation, &data->fb_reference, 1.0); |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 228 | |
| 229 | igt_plane_set_fb(plane, &data->fb_reference); |
| 230 | if (plane->type != DRM_PLANE_TYPE_CURSOR) |
| 231 | igt_plane_set_position(plane, data->pos_x, data->pos_y); |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 232 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 233 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_UNIVERSAL); |
| 234 | |
Damien Lespiau | 19743a1 | 2014-07-08 12:59:03 +0100 | [diff] [blame] | 235 | igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 236 | |
Damien Lespiau | 282f560 | 2014-07-10 17:44:28 +0100 | [diff] [blame] | 237 | /* |
| 238 | * Step 2: prepare the plane with an non-rotated fb let the hw |
| 239 | * rotate it. |
| 240 | */ |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 241 | paint_squares(data, IGT_ROTATION_0, &data->fb, 1.0); |
Tvrtko Ursulin | b769a7c | 2015-04-22 16:46:46 +0100 | [diff] [blame] | 242 | igt_plane_set_fb(plane, &data->fb); |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 243 | |
| 244 | if (plane->type != DRM_PLANE_TYPE_CURSOR) |
| 245 | igt_plane_set_position(plane, data->pos_x, data->pos_y); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 246 | } |
| 247 | |
Damien Lespiau | 05f90b0 | 2014-07-08 18:51:25 +0100 | [diff] [blame] | 248 | static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane) |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 249 | { |
| 250 | igt_display_t *display = &data->display; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 251 | |
| 252 | igt_pipe_crc_free(data->pipe_crc); |
| 253 | data->pipe_crc = NULL; |
| 254 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 255 | remove_fbs(data); |
Damien Lespiau | 1a75439 | 2014-07-09 14:00:59 +0100 | [diff] [blame] | 256 | |
Maarten Lankhorst | 9d809cd | 2017-06-06 17:12:20 +0200 | [diff] [blame^] | 257 | igt_remove_fb(data->gfx_fd, &data->fb_modeset); |
| 258 | |
Damien Lespiau | 1a75439 | 2014-07-09 14:00:59 +0100 | [diff] [blame] | 259 | /* XXX: see the note in prepare_crtc() */ |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 260 | if (plane->type != DRM_PLANE_TYPE_PRIMARY) { |
Damien Lespiau | 1a75439 | 2014-07-09 14:00:59 +0100 | [diff] [blame] | 261 | igt_plane_t *primary; |
| 262 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 263 | primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); |
Damien Lespiau | 1a75439 | 2014-07-09 14:00:59 +0100 | [diff] [blame] | 264 | igt_plane_set_fb(primary, NULL); |
| 265 | } |
| 266 | |
Damien Lespiau | 05f90b0 | 2014-07-08 18:51:25 +0100 | [diff] [blame] | 267 | igt_plane_set_fb(plane, NULL); |
Maarten Lankhorst | 44023a2 | 2017-01-31 13:31:57 +0100 | [diff] [blame] | 268 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
| 269 | |
| 270 | igt_display_commit2(display, COMMIT_UNIVERSAL); |
| 271 | |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 272 | igt_output_set_pipe(output, PIPE_ANY); |
Damien Lespiau | eb81a92 | 2014-07-08 18:20:51 +0100 | [diff] [blame] | 273 | |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 274 | igt_display_commit(display); |
| 275 | } |
| 276 | |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 277 | static void wait_for_pageflip(int fd) |
| 278 | { |
Daniel Stone | d7db79d | 2017-04-07 14:15:26 +0100 | [diff] [blame] | 279 | drmEventContext evctx = { .version = 2 }; |
Maarten Lankhorst | 3c1362f | 2016-01-05 15:19:13 +0100 | [diff] [blame] | 280 | struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 }; |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 281 | fd_set fds; |
| 282 | int ret; |
| 283 | |
| 284 | /* Wait for pageflip completion, then consume event on fd */ |
| 285 | FD_ZERO(&fds); |
| 286 | FD_SET(fd, &fds); |
| 287 | do { |
| 288 | ret = select(fd + 1, &fds, NULL, NULL, &timeout); |
| 289 | } while (ret < 0 && errno == EINTR); |
| 290 | igt_assert_eq(ret, 1); |
| 291 | igt_assert(drmHandleEvent(fd, &evctx) == 0); |
| 292 | } |
| 293 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 294 | static void test_plane_rotation(data_t *data, int plane_type) |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 295 | { |
| 296 | igt_display_t *display = &data->display; |
| 297 | igt_output_t *output; |
Damien Lespiau | aef475b | 2014-07-08 18:43:44 +0100 | [diff] [blame] | 298 | enum pipe pipe; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 299 | int valid_tests = 0; |
Thomas Wood | 1bec6cb | 2014-08-14 14:06:37 +0100 | [diff] [blame] | 300 | igt_crc_t crc_output, crc_unrotated; |
Damien Lespiau | c4564e0 | 2014-07-08 19:24:24 +0100 | [diff] [blame] | 301 | enum igt_commit_style commit = COMMIT_LEGACY; |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 302 | unsigned int flip_count; |
Tvrtko Ursulin | dbf6468 | 2015-04-22 16:46:48 +0100 | [diff] [blame] | 303 | int ret; |
Damien Lespiau | 13e979c | 2014-07-08 18:13:47 +0100 | [diff] [blame] | 304 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 305 | if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR) |
Damien Lespiau | c4564e0 | 2014-07-08 19:24:24 +0100 | [diff] [blame] | 306 | commit = COMMIT_UNIVERSAL; |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 307 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 308 | if (plane_type == DRM_PLANE_TYPE_CURSOR) |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 309 | igt_require(display->has_cursor_plane); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 310 | |
pvishwak | 8b8d7aa | 2016-04-11 11:24:56 +0530 | [diff] [blame] | 311 | if (data->display.is_atomic) |
| 312 | commit = COMMIT_ATOMIC; |
| 313 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 314 | for_each_pipe_with_valid_output(display, pipe, output) { |
| 315 | igt_plane_t *plane; |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 316 | int i; |
Damien Lespiau | 05f90b0 | 2014-07-08 18:51:25 +0100 | [diff] [blame] | 317 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 318 | igt_output_set_pipe(output, pipe); |
Damien Lespiau | 05f90b0 | 2014-07-08 18:51:25 +0100 | [diff] [blame] | 319 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 320 | plane = igt_output_get_plane_type(output, plane_type); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 321 | igt_require(igt_plane_supports_rotation(plane)); |
Damien Lespiau | 05f90b0 | 2014-07-08 18:51:25 +0100 | [diff] [blame] | 322 | |
Maarten Lankhorst | ca23986 | 2017-06-06 12:16:43 +0200 | [diff] [blame] | 323 | prepare_crtc(data, output, pipe, plane, commit); |
| 324 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 325 | for (i = 0; i < num_rectangle_types; i++) { |
| 326 | /* Unsupported on i915 */ |
| 327 | if (plane_type == DRM_PLANE_TYPE_CURSOR && |
| 328 | i != square) |
| 329 | continue; |
Daniel Vetter | 57259d7 | 2014-11-24 16:08:32 +0100 | [diff] [blame] | 330 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 331 | igt_debug("Testing case %i on pipe %s\n", i, kmstest_pipe_name(pipe)); |
| 332 | prepare_fbs(data, output, plane, i); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 333 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 334 | igt_display_commit2(display, commit); |
Thomas Wood | 1bec6cb | 2014-08-14 14:06:37 +0100 | [diff] [blame] | 335 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 336 | /* collect unrotated CRC */ |
| 337 | igt_pipe_crc_collect_crc(data->pipe_crc, &crc_unrotated); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 338 | |
Maarten Lankhorst | a7fe05b | 2017-06-06 16:41:12 +0200 | [diff] [blame] | 339 | igt_plane_set_rotation(plane, data->rotation); |
| 340 | if (data->rotation == IGT_ROTATION_90 || data->rotation == IGT_ROTATION_270) |
| 341 | igt_plane_set_size(plane, data->fb.height, data->fb.width); |
| 342 | |
| 343 | ret = igt_display_try_commit2(display, commit); |
| 344 | if (data->override_fmt || data->override_tiling) { |
| 345 | igt_assert_eq(ret, -EINVAL); |
| 346 | } else { |
| 347 | igt_assert_eq(ret, 0); |
| 348 | igt_pipe_crc_collect_crc(data->pipe_crc, |
| 349 | &crc_output); |
| 350 | igt_assert_crc_equal(&data->ref_crc, |
| 351 | &crc_output); |
| 352 | } |
| 353 | |
| 354 | flip_count = data->flip_stress; |
| 355 | while (flip_count--) { |
| 356 | ret = drmModePageFlip(data->gfx_fd, |
| 357 | output->config.crtc->crtc_id, |
| 358 | data->fb_flip.fb_id, |
| 359 | DRM_MODE_PAGE_FLIP_EVENT, |
| 360 | NULL); |
| 361 | igt_assert_eq(ret, 0); |
| 362 | wait_for_pageflip(data->gfx_fd); |
| 363 | ret = drmModePageFlip(data->gfx_fd, |
| 364 | output->config.crtc->crtc_id, |
| 365 | data->fb.fb_id, |
| 366 | DRM_MODE_PAGE_FLIP_EVENT, |
| 367 | NULL); |
| 368 | igt_assert_eq(ret, 0); |
| 369 | wait_for_pageflip(data->gfx_fd); |
| 370 | } |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 371 | } |
| 372 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 373 | valid_tests++; |
| 374 | cleanup_crtc(data, output, plane); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 375 | } |
| 376 | igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); |
| 377 | } |
| 378 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 379 | static void test_plane_rotation_ytiled_obj(data_t *data, |
| 380 | igt_output_t *output, |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 381 | int plane_type) |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 382 | { |
| 383 | igt_display_t *display = &data->display; |
| 384 | uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED; |
| 385 | uint32_t format = DRM_FORMAT_XRGB8888; |
| 386 | int bpp = igt_drm_format_to_bpp(format); |
| 387 | enum igt_commit_style commit = COMMIT_LEGACY; |
| 388 | int fd = data->gfx_fd; |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 389 | igt_plane_t *plane; |
| 390 | drmModeModeInfo *mode; |
| 391 | unsigned int stride, size, w, h; |
| 392 | uint32_t gem_handle; |
| 393 | int ret; |
| 394 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 395 | plane = igt_output_get_plane_type(output, plane_type); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 396 | igt_require(igt_plane_supports_rotation(plane)); |
| 397 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 398 | if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR) |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 399 | commit = COMMIT_UNIVERSAL; |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 400 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 401 | if (plane_type == DRM_PLANE_TYPE_CURSOR) |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 402 | igt_require(display->has_cursor_plane); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 403 | |
pvishwak | 8b8d7aa | 2016-04-11 11:24:56 +0530 | [diff] [blame] | 404 | if (data->display.is_atomic) |
| 405 | commit = COMMIT_ATOMIC; |
| 406 | |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 407 | mode = igt_output_get_mode(output); |
| 408 | w = mode->hdisplay; |
| 409 | h = mode->vdisplay; |
| 410 | |
| 411 | for (stride = 512; stride < (w * bpp / 8); stride *= 2) |
| 412 | ; |
| 413 | for (size = 1024*1024; size < stride * h; size *= 2) |
| 414 | ; |
| 415 | |
| 416 | gem_handle = gem_create(fd, size); |
| 417 | ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 418 | igt_assert_eq(ret, 0); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 419 | |
| 420 | do_or_die(__kms_addfb(fd, gem_handle, w, h, stride, |
| 421 | format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS, |
| 422 | &data->fb.fb_id)); |
| 423 | data->fb.width = w; |
| 424 | data->fb.height = h; |
| 425 | data->fb.gem_handle = gem_handle; |
| 426 | |
| 427 | igt_plane_set_fb(plane, NULL); |
| 428 | igt_display_commit(display); |
| 429 | |
| 430 | igt_plane_set_rotation(plane, data->rotation); |
| 431 | igt_plane_set_fb(plane, &data->fb); |
Maarten Lankhorst | 44023a2 | 2017-01-31 13:31:57 +0100 | [diff] [blame] | 432 | igt_plane_set_size(plane, h, w); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 433 | |
Maarten Lankhorst | 44023a2 | 2017-01-31 13:31:57 +0100 | [diff] [blame] | 434 | if (commit < COMMIT_ATOMIC) |
| 435 | drmModeObjectSetProperty(fd, plane->drm_plane->plane_id, |
| 436 | DRM_MODE_OBJECT_PLANE, |
| 437 | plane->rotation_property, |
| 438 | plane->rotation); |
| 439 | |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 440 | ret = igt_display_try_commit2(display, commit); |
| 441 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 442 | igt_output_set_pipe(output, PIPE_NONE); |
| 443 | |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 444 | kmstest_restore_vt_mode(); |
| 445 | igt_remove_fb(fd, &data->fb); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 446 | igt_assert_eq(ret, 0); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 449 | static void test_plane_rotation_exhaust_fences(data_t *data, |
| 450 | igt_output_t *output, |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 451 | int plane_type) |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 452 | { |
| 453 | igt_display_t *display = &data->display; |
| 454 | uint64_t tiling = LOCAL_I915_FORMAT_MOD_Y_TILED; |
| 455 | uint32_t format = DRM_FORMAT_XRGB8888; |
| 456 | int bpp = igt_drm_format_to_bpp(format); |
| 457 | enum igt_commit_style commit = COMMIT_LEGACY; |
| 458 | int fd = data->gfx_fd; |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 459 | igt_plane_t *plane; |
| 460 | drmModeModeInfo *mode; |
| 461 | data_t data2[MAX_FENCES+1] = {}; |
| 462 | unsigned int stride, size, w, h; |
| 463 | uint32_t gem_handle; |
| 464 | uint64_t total_aperture_size, total_fbs_size; |
| 465 | int i, ret; |
| 466 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 467 | plane = igt_output_get_plane_type(output, plane_type); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 468 | igt_require(igt_plane_supports_rotation(plane)); |
| 469 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 470 | if (plane_type == DRM_PLANE_TYPE_PRIMARY || plane_type == DRM_PLANE_TYPE_CURSOR) |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 471 | commit = COMMIT_UNIVERSAL; |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 472 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 473 | if (plane_type == DRM_PLANE_TYPE_CURSOR) |
Lyude | 80baeb0 | 2016-12-07 19:02:04 -0500 | [diff] [blame] | 474 | igt_require(display->has_cursor_plane); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 475 | |
pvishwak | 8b8d7aa | 2016-04-11 11:24:56 +0530 | [diff] [blame] | 476 | if (data->display.is_atomic) |
| 477 | commit = COMMIT_ATOMIC; |
| 478 | |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 479 | mode = igt_output_get_mode(output); |
| 480 | w = mode->hdisplay; |
| 481 | h = mode->vdisplay; |
| 482 | |
| 483 | for (stride = 512; stride < (w * bpp / 8); stride *= 2) |
| 484 | ; |
| 485 | for (size = 1024*1024; size < stride * h; size *= 2) |
| 486 | ; |
| 487 | |
| 488 | /* |
| 489 | * Make sure there is atleast 90% of the available GTT space left |
| 490 | * for creating (MAX_FENCES+1) framebuffers. |
| 491 | */ |
| 492 | total_fbs_size = size * (MAX_FENCES + 1); |
Chris Wilson | 1603890 | 2016-02-18 10:35:10 +0000 | [diff] [blame] | 493 | total_aperture_size = gem_available_aperture_size(fd); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 494 | igt_require(total_fbs_size < total_aperture_size * 0.9); |
| 495 | |
| 496 | igt_plane_set_fb(plane, NULL); |
| 497 | igt_display_commit(display); |
| 498 | |
| 499 | for (i = 0; i < MAX_FENCES + 1; i++) { |
| 500 | gem_handle = gem_create(fd, size); |
| 501 | ret = __gem_set_tiling(fd, gem_handle, I915_TILING_Y, stride); |
| 502 | if (ret) { |
| 503 | igt_warn("failed to set tiling\n"); |
| 504 | goto err_alloc; |
| 505 | } |
| 506 | |
| 507 | ret = (__kms_addfb(fd, gem_handle, w, h, stride, |
| 508 | format, tiling, LOCAL_DRM_MODE_FB_MODIFIERS, |
| 509 | &data2[i].fb.fb_id)); |
| 510 | if (ret) { |
| 511 | igt_warn("failed to create framebuffer\n"); |
| 512 | goto err_alloc; |
| 513 | } |
| 514 | |
| 515 | data2[i].fb.width = w; |
| 516 | data2[i].fb.height = h; |
| 517 | data2[i].fb.gem_handle = gem_handle; |
| 518 | |
| 519 | igt_plane_set_fb(plane, &data2[i].fb); |
| 520 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
| 521 | |
| 522 | ret = igt_display_try_commit2(display, commit); |
| 523 | if (ret) { |
| 524 | igt_warn("failed to commit unrotated fb\n"); |
| 525 | goto err_commit; |
| 526 | } |
| 527 | |
| 528 | igt_plane_set_rotation(plane, IGT_ROTATION_90); |
Maarten Lankhorst | 44023a2 | 2017-01-31 13:31:57 +0100 | [diff] [blame] | 529 | igt_plane_set_size(plane, h, w); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 530 | |
| 531 | drmModeObjectSetProperty(fd, plane->drm_plane->plane_id, |
| 532 | DRM_MODE_OBJECT_PLANE, |
| 533 | plane->rotation_property, |
| 534 | plane->rotation); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 535 | igt_display_commit2(display, commit); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 536 | if (ret) { |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 537 | igt_warn("failed to commit hardware rotated fb: %i\n", ret); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 538 | goto err_commit; |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | err_alloc: |
| 543 | if (ret) |
| 544 | gem_close(fd, gem_handle); |
| 545 | |
| 546 | i--; |
| 547 | err_commit: |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 548 | igt_plane_set_fb(plane, NULL); |
| 549 | igt_plane_set_rotation(plane, IGT_ROTATION_0); |
| 550 | |
| 551 | if (commit < COMMIT_ATOMIC) |
| 552 | igt_display_commit2(display, commit); |
| 553 | |
| 554 | igt_output_set_pipe(output, PIPE_NONE); |
| 555 | igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY); |
| 556 | |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 557 | for (; i >= 0; i--) |
| 558 | igt_remove_fb(fd, &data2[i].fb); |
| 559 | |
| 560 | kmstest_restore_vt_mode(); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 561 | igt_assert_eq(ret, 0); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 562 | } |
| 563 | |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 564 | igt_main |
| 565 | { |
| 566 | data_t data = {}; |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 567 | int gen = 0; |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 568 | |
| 569 | igt_skip_on_simulation(); |
| 570 | |
| 571 | igt_fixture { |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 572 | data.gfx_fd = drm_open_driver_master(DRIVER_INTEL); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 573 | gen = intel_gen(intel_get_drm_devid(data.gfx_fd)); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 574 | |
Daniel Vetter | 33f0884 | 2014-08-12 11:23:09 +0200 | [diff] [blame] | 575 | kmstest_set_vt_graphics_mode(); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 576 | |
Chris Wilson | 83884e9 | 2017-03-21 17:16:03 +0000 | [diff] [blame] | 577 | igt_require_pipe_crc(data.gfx_fd); |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 578 | |
| 579 | igt_display_init(&data.display, data.gfx_fd); |
| 580 | } |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 581 | igt_subtest_f("primary-rotation-180") { |
| 582 | data.rotation = IGT_ROTATION_180; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 583 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 584 | } |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 585 | |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 586 | igt_subtest_f("sprite-rotation-180") { |
| 587 | data.rotation = IGT_ROTATION_180; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 588 | test_plane_rotation(&data, DRM_PLANE_TYPE_OVERLAY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 589 | } |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 590 | |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 591 | igt_subtest_f("cursor-rotation-180") { |
| 592 | data.rotation = IGT_ROTATION_180; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 593 | test_plane_rotation(&data, DRM_PLANE_TYPE_CURSOR); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | igt_subtest_f("primary-rotation-90") { |
| 597 | igt_require(gen >= 9); |
| 598 | data.rotation = IGT_ROTATION_90; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 599 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | igt_subtest_f("primary-rotation-270") { |
| 603 | igt_require(gen >= 9); |
| 604 | data.rotation = IGT_ROTATION_270; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 605 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | igt_subtest_f("sprite-rotation-90") { |
| 609 | igt_require(gen >= 9); |
| 610 | data.rotation = IGT_ROTATION_90; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 611 | test_plane_rotation(&data, DRM_PLANE_TYPE_OVERLAY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | igt_subtest_f("sprite-rotation-270") { |
| 615 | igt_require(gen >= 9); |
| 616 | data.rotation = IGT_ROTATION_270; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 617 | test_plane_rotation(&data, DRM_PLANE_TYPE_OVERLAY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | igt_subtest_f("sprite-rotation-90-pos-100-0") { |
| 621 | igt_require(gen >= 9); |
| 622 | data.rotation = IGT_ROTATION_90; |
| 623 | data.pos_x = 100, |
| 624 | data.pos_y = 0; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 625 | test_plane_rotation(&data, DRM_PLANE_TYPE_OVERLAY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 626 | } |
| 627 | |
Tvrtko Ursulin | dbf6468 | 2015-04-22 16:46:48 +0100 | [diff] [blame] | 628 | igt_subtest_f("bad-pixel-format") { |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 629 | igt_require(gen >= 9); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 630 | data.pos_x = 0, |
| 631 | data.pos_y = 0; |
Tvrtko Ursulin | dbf6468 | 2015-04-22 16:46:48 +0100 | [diff] [blame] | 632 | data.rotation = IGT_ROTATION_90; |
| 633 | data.override_fmt = DRM_FORMAT_RGB565; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 634 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Tvrtko Ursulin | dbf6468 | 2015-04-22 16:46:48 +0100 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | igt_subtest_f("bad-tiling") { |
| 638 | igt_require(gen >= 9); |
| 639 | data.override_fmt = 0; |
| 640 | data.rotation = IGT_ROTATION_90; |
| 641 | data.override_tiling = LOCAL_DRM_FORMAT_MOD_NONE; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 642 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Sonika Jindal | e1ce5ea | 2015-04-22 16:44:05 +0530 | [diff] [blame] | 643 | } |
Sonika Jindal | 4724698 | 2014-10-23 08:48:50 -0700 | [diff] [blame] | 644 | |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 645 | igt_subtest_f("primary-rotation-90-flip-stress") { |
| 646 | igt_require(gen >= 9); |
| 647 | data.override_tiling = 0; |
| 648 | data.flip_stress = 60; |
| 649 | data.rotation = IGT_ROTATION_90; |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 650 | test_plane_rotation(&data, DRM_PLANE_TYPE_PRIMARY); |
Tvrtko Ursulin | 061a38f | 2015-10-07 12:18:52 +0100 | [diff] [blame] | 651 | } |
| 652 | |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 653 | igt_subtest_f("primary-rotation-90-Y-tiled") { |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 654 | enum pipe pipe; |
| 655 | igt_output_t *output; |
| 656 | int valid_tests = 0; |
| 657 | |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 658 | igt_require(gen >= 9); |
| 659 | data.rotation = IGT_ROTATION_90; |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 660 | |
| 661 | for_each_pipe_with_valid_output(&data.display, pipe, output) { |
| 662 | igt_output_set_pipe(output, pipe); |
| 663 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 664 | test_plane_rotation_ytiled_obj(&data, output, DRM_PLANE_TYPE_PRIMARY); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 665 | |
| 666 | valid_tests++; |
| 667 | break; |
| 668 | } |
| 669 | |
| 670 | igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); |
Vivek Kasireddy | fe548fa | 2015-10-22 18:34:03 -0700 | [diff] [blame] | 671 | } |
| 672 | |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 673 | igt_subtest_f("exhaust-fences") { |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 674 | enum pipe pipe; |
| 675 | igt_output_t *output; |
| 676 | int valid_tests = 0; |
| 677 | |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 678 | igt_require(gen >= 9); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 679 | |
| 680 | for_each_pipe_with_valid_output(&data.display, pipe, output) { |
| 681 | igt_output_set_pipe(output, pipe); |
| 682 | |
Robert Foss | 3e04c51 | 2017-01-10 20:18:41 -0500 | [diff] [blame] | 683 | test_plane_rotation_exhaust_fences(&data, output, DRM_PLANE_TYPE_PRIMARY); |
Maarten Lankhorst | eeffa25 | 2017-01-05 14:13:34 +0100 | [diff] [blame] | 684 | |
| 685 | valid_tests++; |
| 686 | break; |
| 687 | } |
| 688 | |
| 689 | igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); |
Vivek Kasireddy | 938b930 | 2015-11-04 16:10:15 -0800 | [diff] [blame] | 690 | } |
| 691 | |
Sonika Jindal | e361139 | 2014-06-18 14:27:27 +0530 | [diff] [blame] | 692 | igt_fixture { |
| 693 | igt_display_fini(&data.display); |
| 694 | } |
| 695 | } |