• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2015 Intel Corporation
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 #include "igt.h"
25 #include <errno.h>
26 
27 
28 IGT_TEST_DESCRIPTION("Check that the legacy set colorkey ioctl only works on sprite planes.");
29 
30 static int drm_fd;
31 static igt_display_t display;
32 static int p;
33 static igt_plane_t *plane;
34 static uint32_t max_id;
35 
test_plane(uint32_t plane_id,int expected_ret)36 static void test_plane(uint32_t plane_id, int expected_ret)
37 {
38 	struct drm_intel_sprite_colorkey ckey = {
39 		.plane_id = plane_id,
40 	};
41 
42 	igt_assert(drmCommandWrite(drm_fd, DRM_I915_SET_SPRITE_COLORKEY, &ckey,
43 				   sizeof(ckey)) == expected_ret);
44 }
45 
46 igt_simple_main
47 {
48 	igt_skip_on_simulation();
49 
50 	drm_fd = drm_open_driver_master(DRIVER_INTEL);
51 
52 	kmstest_set_vt_graphics_mode();
53 
54 	igt_display_require(&display, drm_fd);
55 
56 	for_each_pipe(&display, p) {
57 		for_each_plane_on_pipe(&display, p, plane) {
58 			bool is_valid = (plane->type == DRM_PLANE_TYPE_PRIMARY ||
59 			                 plane->type == DRM_PLANE_TYPE_CURSOR);
60 			test_plane(plane->drm_plane->plane_id,
61 				   is_valid ? -ENOENT : 0);
62 
63 			max_id = max(max_id, plane->drm_plane->plane_id);
64 		}
65 	}
66 
67 	/* try some invalid IDs too */
68 	test_plane(0, -ENOENT);
69 	test_plane(max_id + 1, -ENOENT);
70 
71 	igt_display_fini(&display);
72 }
73