Maarten Lankhorst | c7195c4 | 2017-01-11 10:07:38 +0100 | [diff] [blame] | 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 | int main(int argc, char **argv) |
| 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_subtest_init(argc, argv); |
| 37 | |
| 38 | igt_fixture { |
| 39 | drm_fd = drm_open_driver_master(DRIVER_INTEL); |
| 40 | res = drmModeGetResources(drm_fd); |
| 41 | igt_assert(res); |
| 42 | |
| 43 | /* find the TV connector */ |
| 44 | for (int i = 0; i < res->count_connectors; i++) { |
| 45 | |
| 46 | tv_connector = drmModeGetConnectorCurrent(drm_fd, |
| 47 | res->connectors[i]); |
| 48 | |
| 49 | if (tv_connector->connector_type == DRM_MODE_CONNECTOR_SVIDEO) { |
| 50 | if (kmstest_get_property(drm_fd, tv_connector->connector_id, |
| 51 | DRM_MODE_OBJECT_CONNECTOR, "mode", NULL, NULL, NULL)) |
| 52 | break; |
| 53 | |
| 54 | igt_info("Skipping tv output \"%s-%d\": No tv \"mode\" property found\n", |
| 55 | kmstest_connector_type_str(tv_connector->connector_type), |
| 56 | tv_connector->connector_type_id); |
| 57 | } |
| 58 | |
| 59 | drmModeFreeConnector(tv_connector); |
| 60 | |
| 61 | tv_connector = NULL; |
| 62 | } |
| 63 | |
| 64 | igt_require(tv_connector); |
| 65 | } |
| 66 | |
| 67 | igt_subtest("load-detect") { |
| 68 | /* |
| 69 | * disable all outputs to make sure we have a |
| 70 | * free crtc available for load detect |
| 71 | */ |
| 72 | kmstest_set_vt_graphics_mode(); |
| 73 | kmstest_unset_all_crtcs(drm_fd, res); |
| 74 | |
| 75 | /* This can't use drmModeGetConnectorCurrent |
| 76 | * because connector probing is the point of this test. |
| 77 | */ |
| 78 | temp = drmModeGetConnector(drm_fd, tv_connector->connector_id); |
| 79 | |
| 80 | igt_assert(temp->connection != DRM_MODE_UNKNOWNCONNECTION); |
| 81 | |
| 82 | drmModeFreeConnector(temp); |
| 83 | } |
| 84 | |
| 85 | igt_fixture { |
| 86 | drmModeFreeConnector(tv_connector); |
| 87 | close(drm_fd); |
| 88 | } |
| 89 | |
| 90 | igt_exit(); |
| 91 | } |