1 /* 2 * Copyright © 2014 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 25 #include "igt.h" 26 27 IGT_TEST_DESCRIPTION("Check tv load detection works correctly."); 28 29 igt_main 30 { 31 /* force the VGA output and test that it worked */ 32 int drm_fd = 0; 33 drmModeRes *res; 34 drmModeConnector *tv_connector = NULL, *temp; 35 36 igt_fixture { 37 drm_fd = drm_open_driver_master(DRIVER_INTEL); 38 39 res = drmModeGetResources(drm_fd); 40 igt_require(res); 41 42 /* find the TV connector */ 43 for (int i = 0; i < res->count_connectors; i++) { 44 45 tv_connector = drmModeGetConnectorCurrent(drm_fd, 46 res->connectors[i]); 47 48 if (tv_connector->connector_type == DRM_MODE_CONNECTOR_SVIDEO) { 49 if (kmstest_get_property(drm_fd, tv_connector->connector_id, 50 DRM_MODE_OBJECT_CONNECTOR, "mode", NULL, NULL, NULL)) 51 break; 52 53 igt_info("Skipping tv output \"%s-%d\": No tv \"mode\" property found\n", 54 kmstest_connector_type_str(tv_connector->connector_type), 55 tv_connector->connector_type_id); 56 } 57 58 drmModeFreeConnector(tv_connector); 59 60 tv_connector = NULL; 61 } 62 63 igt_require(tv_connector); 64 } 65 66 igt_subtest("load-detect") { 67 /* 68 * disable all outputs to make sure we have a 69 * free crtc available for load detect 70 */ 71 kmstest_set_vt_graphics_mode(); 72 kmstest_unset_all_crtcs(drm_fd, res); 73 74 /* This can't use drmModeGetConnectorCurrent 75 * because connector probing is the point of this test. 76 */ 77 temp = drmModeGetConnector(drm_fd, tv_connector->connector_id); 78 79 igt_assert(temp->connection != DRM_MODE_UNKNOWNCONNECTION); 80 81 drmModeFreeConnector(temp); 82 } 83 84 igt_fixture { 85 drmModeFreeConnector(tv_connector); 86 close(drm_fd); 87 } 88 } 89