From c7195c44fea2648011aabdcd15afb7236995c4c1 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 11 Jan 2017 10:07:38 +0100 Subject: 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 Tested-by: Lyude --- tests/Makefile.sources | 1 + tests/kms_tv_load_detect.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tests/kms_tv_load_detect.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 9cac8e98..17afa508 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -124,6 +124,7 @@ TESTS_progs_M = \ kms_crtc_background_color \ kms_plane_scaling \ kms_panel_fitting \ + kms_tv_load_detect \ pm_backlight \ pm_lpsp \ pm_rpm \ 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(); +} -- cgit v1.2.3