2 * Copyright © 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 main (int argc, char **argv)
33 /* force the VGA output and test that it worked */
36 drmModeConnector *connector, *temp;
37 igt_display_t display;
39 igt_simple_init(argc, argv);
41 drm_fd = drm_open_any();
42 res = drmModeGetResources(drm_fd);
44 /* find the vga connector */
45 for (int i = 0; i < res->count_connectors; i++) {
47 connector = drmModeGetConnector(drm_fd, res->connectors[i]);
49 if (connector->connector_type == DRM_MODE_CONNECTOR_VGA)
52 drmModeFreeConnector(connector);
57 igt_assert(connector);
59 /* force the connector on and check the reported values */
60 kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON);
61 temp = drmModeGetConnector(drm_fd, connector->connector_id);
62 igt_assert(temp->connection == DRM_MODE_CONNECTED);
63 igt_assert(temp->count_modes > 0);
64 drmModeFreeConnector(temp);
66 /* attempt to use the display */
67 igt_set_vt_graphics_mode();
69 igt_display_init(&display, drm_fd);
70 igt_display_commit(&display);
72 /* test edid forcing */
73 kmstest_force_edid(drm_fd, connector, generic_edid[EDID_FHD],
75 temp = drmModeGetConnector(drm_fd, connector->connector_id);
77 igt_assert(temp->count_modes == 1);
78 igt_assert(temp->modes[0].vrefresh == 60
79 && temp->modes[0].hdisplay == 1920
80 && temp->modes[0].vdisplay == 1080);
82 drmModeFreeConnector(temp);
85 kmstest_force_edid(drm_fd, connector, generic_edid[EDID_WSXGA],
87 temp = drmModeGetConnector(drm_fd, connector->connector_id);
89 igt_assert(temp->count_modes == 1);
90 igt_assert(temp->modes[0].vrefresh == 60
91 && temp->modes[0].hdisplay == 1680
92 && temp->modes[0].vdisplay == 1050);
94 drmModeFreeConnector(temp);
97 kmstest_force_edid(drm_fd, connector, NULL, 0);
98 temp = drmModeGetConnector(drm_fd, connector->connector_id);
99 /* the connector should now have the 5 default modes */
100 igt_assert(temp->count_modes == 5);
101 drmModeFreeConnector(temp);
103 /* force the connector off */
104 kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_OFF);
105 temp = drmModeGetConnector(drm_fd, connector->connector_id);
106 igt_assert(temp->connection == DRM_MODE_DISCONNECTED);
107 igt_assert(temp->count_modes == 0);
108 drmModeFreeConnector(temp);
111 /* check that the previous state is restored */
112 kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
113 temp = drmModeGetConnector(drm_fd, connector->connector_id);
114 igt_assert(temp->connection == connector->connection);
115 drmModeFreeConnector(temp);
117 drmModeFreeConnector(connector);