diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-01-11 10:07:38 +0100 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2017-01-12 13:52:04 +0100 |
commit | c7195c44fea2648011aabdcd15afb7236995c4c1 (patch) | |
tree | 0bd84da1ec0c2ae6a44d636248b72b0c41ff7265 /tests/kms_tv_load_detect.c | |
parent | 04cd372ff4df23c70908b2783fa9feaa4eeefb3c (diff) |
tests: Add test for tv load detection
The test is that kernel load detection works as intended,
and doesn't cause any vblank spam.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tested-by: Lyude <cpaul@redhat.com>
Diffstat (limited to 'tests/kms_tv_load_detect.c')
-rw-r--r-- | tests/kms_tv_load_detect.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/kms_tv_load_detect.c b/tests/kms_tv_load_detect.c new file mode 100644 index 00000000..5684b267 --- /dev/null +++ b/tests/kms_tv_load_detect.c @@ -0,0 +1,91 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include "igt.h" + +IGT_TEST_DESCRIPTION("Check tv load detection works correctly."); + +int main(int argc, char **argv) +{ + /* force the VGA output and test that it worked */ + int drm_fd = 0; + drmModeRes *res; + drmModeConnector *tv_connector = NULL, *temp; + + igt_subtest_init(argc, argv); + + igt_fixture { + drm_fd = drm_open_driver_master(DRIVER_INTEL); + res = drmModeGetResources(drm_fd); + igt_assert(res); + + /* find the TV connector */ + for (int i = 0; i < res->count_connectors; i++) { + + tv_connector = drmModeGetConnectorCurrent(drm_fd, + res->connectors[i]); + + if (tv_connector->connector_type == DRM_MODE_CONNECTOR_SVIDEO) { + if (kmstest_get_property(drm_fd, tv_connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "mode", NULL, NULL, NULL)) + break; + + igt_info("Skipping tv output \"%s-%d\": No tv \"mode\" property found\n", + kmstest_connector_type_str(tv_connector->connector_type), + tv_connector->connector_type_id); + } + + drmModeFreeConnector(tv_connector); + + tv_connector = NULL; + } + + igt_require(tv_connector); + } + + igt_subtest("load-detect") { + /* + * disable all outputs to make sure we have a + * free crtc available for load detect + */ + kmstest_set_vt_graphics_mode(); + kmstest_unset_all_crtcs(drm_fd, res); + + /* This can't use drmModeGetConnectorCurrent + * because connector probing is the point of this test. + */ + temp = drmModeGetConnector(drm_fd, tv_connector->connector_id); + + igt_assert(temp->connection != DRM_MODE_UNKNOWNCONNECTION); + + drmModeFreeConnector(temp); + } + + igt_fixture { + drmModeFreeConnector(tv_connector); + close(drm_fd); + } + + igt_exit(); +} |