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("Tests 3D mode setting."); 28 29 igt_simple_main 30 { 31 int drm_fd; 32 drmModeRes *res; 33 drmModeConnector *connector; 34 const struct edid *edid; 35 int mode_count, connector_id; 36 37 drm_fd = drm_open_driver_master(DRIVER_INTEL); 38 39 res = drmModeGetResources(drm_fd); 40 igt_require(res); 41 42 igt_assert(drmSetClientCap(drm_fd, DRM_CLIENT_CAP_STEREO_3D, 1) >= 0); 43 44 /* find an hdmi connector */ 45 for (int i = 0; i < res->count_connectors; i++) { 46 47 connector = drmModeGetConnectorCurrent(drm_fd, res->connectors[i]); 48 49 if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA) 50 break; 51 52 drmModeFreeConnector(connector); 53 54 connector = NULL; 55 } 56 igt_require(connector); 57 58 kmstest_unset_all_crtcs(drm_fd, res); 59 60 edid = igt_kms_get_3d_edid(); 61 62 kmstest_force_edid(drm_fd, connector, edid); 63 if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON)) 64 igt_skip("Could not force connector on\n"); 65 66 connector_id = connector->connector_id; 67 68 /* check for 3D modes */ 69 mode_count = 0; 70 connector = drmModeGetConnectorCurrent(drm_fd, connector_id); 71 for (int i = 0; i < connector->count_modes; i++) { 72 if (connector->modes[i].flags & DRM_MODE_FLAG_3D_MASK) 73 mode_count++; 74 } 75 76 igt_assert_eq(mode_count, 13); 77 78 /* set 3D modes */ 79 igt_info("Testing:\n"); 80 for (int i = 0; i < connector->count_modes; i++) { 81 int fb_id; 82 struct kmstest_connector_config config; 83 int crtc_mask = -1; 84 int ret; 85 86 if (!(connector->modes[i].flags & DRM_MODE_FLAG_3D_MASK)) 87 continue; 88 89 /* create a configuration */ 90 ret = kmstest_get_connector_config(drm_fd, connector_id, 91 crtc_mask, &config); 92 if (ret != true) { 93 igt_info("Error creating configuration for:\n "); 94 kmstest_dump_mode(&connector->modes[i]); 95 96 continue; 97 } 98 99 igt_info(" "); 100 kmstest_dump_mode(&connector->modes[i]); 101 102 /* create stereo framebuffer */ 103 fb_id = igt_create_stereo_fb(drm_fd, &connector->modes[i], 104 igt_bpp_depth_to_drm_format(32, 24), 105 LOCAL_DRM_FORMAT_MOD_NONE); 106 107 ret = drmModeSetCrtc(drm_fd, config.crtc->crtc_id, fb_id, 0, 0, 108 &connector->connector_id, 1, 109 &connector->modes[i]); 110 111 igt_assert(ret == 0); 112 } 113 114 kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED); 115 kmstest_force_edid(drm_fd, connector, NULL); 116 117 drmModeFreeConnector(connector); 118 } 119