Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2006 Luc Verhaegen (quirks list) |
| 3 | * Copyright (c) 2007-2008 Intel Corporation |
| 4 | * Jesse Barnes <jesse.barnes@intel.com> |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 5 | * Copyright 2010 Red Hat, Inc. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 6 | * |
| 7 | * DDC probing routines (drm_ddc_read & drm_do_probe_ddc_edid) originally from |
| 8 | * FB layer. |
| 9 | * Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com> |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 12 | * copy of this software and associated documentation files (the "Software"), |
| 13 | * to deal in the Software without restriction, including without limitation |
| 14 | * the rights to use, copy, modify, merge, publish, distribute, sub license, |
| 15 | * and/or sell copies of the Software, and to permit persons to whom the |
| 16 | * Software is furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice (including the |
| 19 | * next paragraph) shall be included in all copies or substantial portions |
| 20 | * of the Software. |
| 21 | * |
| 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 25 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 28 | * DEALINGS IN THE SOFTWARE. |
| 29 | */ |
| 30 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 31 | #include <linux/slab.h> |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 32 | #include <linux/hdmi.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 33 | #include <linux/i2c.h> |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 34 | #include <linux/module.h> |
Lukas Wunner | 5cb8eaa2 | 2016-01-11 20:09:20 +0100 | [diff] [blame] | 35 | #include <linux/vga_switcheroo.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 36 | #include <drm/drmP.h> |
| 37 | #include <drm/drm_edid.h> |
Laurent Pinchart | 9338203 | 2016-11-28 20:51:09 +0200 | [diff] [blame] | 38 | #include <drm/drm_encoder.h> |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 39 | #include <drm/drm_displayid.h> |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 40 | #include <drm/drm_scdc_helper.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 41 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 42 | #include "drm_crtc_internal.h" |
| 43 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 44 | #define version_greater(edid, maj, min) \ |
| 45 | (((edid)->version > (maj)) || \ |
| 46 | ((edid)->version == (maj) && (edid)->revision > (min))) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 47 | |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 48 | #define EDID_EST_TIMINGS 16 |
| 49 | #define EDID_STD_TIMINGS 8 |
| 50 | #define EDID_DETAILED_TIMINGS 4 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * EDID blocks out in the wild have a variety of bugs, try to collect |
| 54 | * them here (note that userspace may work around broken monitors first, |
| 55 | * but fixes should make their way here so that the kernel "just works" |
| 56 | * on as many displays as possible). |
| 57 | */ |
| 58 | |
| 59 | /* First detailed mode wrong, use largest 60Hz mode */ |
| 60 | #define EDID_QUIRK_PREFER_LARGE_60 (1 << 0) |
| 61 | /* Reported 135MHz pixel clock is too high, needs adjustment */ |
| 62 | #define EDID_QUIRK_135_CLOCK_TOO_HIGH (1 << 1) |
| 63 | /* Prefer the largest mode at 75 Hz */ |
| 64 | #define EDID_QUIRK_PREFER_LARGE_75 (1 << 2) |
| 65 | /* Detail timing is in cm not mm */ |
| 66 | #define EDID_QUIRK_DETAILED_IN_CM (1 << 3) |
| 67 | /* Detailed timing descriptors have bogus size values, so just take the |
| 68 | * maximum size and use that. |
| 69 | */ |
| 70 | #define EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE (1 << 4) |
| 71 | /* Monitor forgot to set the first detailed is preferred bit. */ |
| 72 | #define EDID_QUIRK_FIRST_DETAILED_PREFERRED (1 << 5) |
| 73 | /* use +hsync +vsync for detailed mode */ |
| 74 | #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 75 | /* Force reduced-blanking timings for detailed modes */ |
| 76 | #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7) |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 77 | /* Force 8bpc */ |
| 78 | #define EDID_QUIRK_FORCE_8BPC (1 << 8) |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 79 | /* Force 12bpc */ |
| 80 | #define EDID_QUIRK_FORCE_12BPC (1 << 9) |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 81 | /* Force 6bpc */ |
| 82 | #define EDID_QUIRK_FORCE_6BPC (1 << 10) |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 83 | /* Force 10bpc */ |
| 84 | #define EDID_QUIRK_FORCE_10BPC (1 << 11) |
Dave Airlie | 66660d4 | 2017-10-16 05:08:09 +0100 | [diff] [blame] | 85 | /* Non desktop display (i.e. HMD) */ |
| 86 | #define EDID_QUIRK_NON_DESKTOP (1 << 12) |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 87 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 88 | struct detailed_mode_closure { |
| 89 | struct drm_connector *connector; |
| 90 | struct edid *edid; |
| 91 | bool preferred; |
| 92 | u32 quirks; |
| 93 | int modes; |
| 94 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 95 | |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 96 | #define LEVEL_DMT 0 |
| 97 | #define LEVEL_GTF 1 |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 98 | #define LEVEL_GTF2 2 |
| 99 | #define LEVEL_CVT 3 |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 100 | |
Jani Nikula | 23c4cfb | 2016-12-28 13:06:26 +0200 | [diff] [blame] | 101 | static const struct edid_quirk { |
Ian Pilcher | c51a3fd6 | 2012-04-22 11:40:26 -0500 | [diff] [blame] | 102 | char vendor[4]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 103 | int product_id; |
| 104 | u32 quirks; |
| 105 | } edid_quirk_list[] = { |
| 106 | /* Acer AL1706 */ |
| 107 | { "ACR", 44358, EDID_QUIRK_PREFER_LARGE_60 }, |
| 108 | /* Acer F51 */ |
| 109 | { "API", 0x7602, EDID_QUIRK_PREFER_LARGE_60 }, |
| 110 | /* Unknown Acer */ |
| 111 | { "ACR", 2423, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, |
| 112 | |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 113 | /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ |
| 114 | { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, |
| 115 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 116 | /* Belinea 10 15 55 */ |
| 117 | { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, |
| 118 | { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, |
| 119 | |
| 120 | /* Envision Peripherals, Inc. EN-7100e */ |
| 121 | { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH }, |
Adam Jackson | ba1163d | 2010-04-06 16:11:00 +0000 | [diff] [blame] | 122 | /* Envision EN2028 */ |
| 123 | { "EPI", 8232, EDID_QUIRK_PREFER_LARGE_60 }, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 124 | |
| 125 | /* Funai Electronics PM36B */ |
| 126 | { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | |
| 127 | EDID_QUIRK_DETAILED_IN_CM }, |
| 128 | |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 129 | /* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ |
| 130 | { "LGD", 764, EDID_QUIRK_FORCE_10BPC }, |
| 131 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 132 | /* LG Philips LCD LP154W01-A5 */ |
| 133 | { "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, |
| 134 | { "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, |
| 135 | |
| 136 | /* Philips 107p5 CRT */ |
| 137 | { "PHL", 57364, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, |
| 138 | |
| 139 | /* Proview AY765C */ |
| 140 | { "PTS", 765, EDID_QUIRK_FIRST_DETAILED_PREFERRED }, |
| 141 | |
| 142 | /* Samsung SyncMaster 205BW. Note: irony */ |
| 143 | { "SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP }, |
| 144 | /* Samsung SyncMaster 22[5-6]BW */ |
| 145 | { "SAM", 596, EDID_QUIRK_PREFER_LARGE_60 }, |
| 146 | { "SAM", 638, EDID_QUIRK_PREFER_LARGE_60 }, |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 147 | |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 148 | /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ |
| 149 | { "SNY", 0x2541, EDID_QUIRK_FORCE_12BPC }, |
| 150 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 151 | /* ViewSonic VA2026w */ |
| 152 | { "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING }, |
Alex Deucher | 118bdbd | 2013-08-12 11:04:29 -0400 | [diff] [blame] | 153 | |
| 154 | /* Medion MD 30217 PG */ |
| 155 | { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 156 | |
| 157 | /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ |
| 158 | { "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC }, |
Tomeu Vizoso | 36fc579 | 2017-02-20 16:25:45 +0100 | [diff] [blame] | 159 | |
| 160 | /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ |
| 161 | { "ETR", 13896, EDID_QUIRK_FORCE_8BPC }, |
Dave Airlie | acb1d8e | 2017-10-16 05:26:19 +0100 | [diff] [blame] | 162 | |
| 163 | /* HTC Vive VR Headset */ |
| 164 | { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | b3b12ea | 2018-02-19 18:59:36 +0100 | [diff] [blame] | 165 | |
| 166 | /* Oculus Rift DK1, DK2, and CV1 VR Headsets */ |
| 167 | { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP }, |
| 168 | { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP }, |
| 169 | { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | 90eda8f | 2018-02-19 18:59:37 +0100 | [diff] [blame] | 170 | |
| 171 | /* Windows Mixed Reality Headsets */ |
| 172 | { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP }, |
| 173 | { "HPN", 0x3515, EDID_QUIRK_NON_DESKTOP }, |
| 174 | { "LEN", 0x0408, EDID_QUIRK_NON_DESKTOP }, |
| 175 | { "LEN", 0xb800, EDID_QUIRK_NON_DESKTOP }, |
| 176 | { "FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP }, |
| 177 | { "DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP }, |
| 178 | { "SEC", 0x144a, EDID_QUIRK_NON_DESKTOP }, |
| 179 | { "AUS", 0xc102, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | ccffc9e | 2018-02-19 18:59:38 +0100 | [diff] [blame^] | 180 | |
| 181 | /* Sony PlayStation VR Headset */ |
| 182 | { "SNY", 0x0704, EDID_QUIRK_NON_DESKTOP }, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 183 | }; |
| 184 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 185 | /* |
| 186 | * Autogenerated from the DMT spec. |
| 187 | * This table is copied from xfree86/modes/xf86EdidModes.c. |
| 188 | */ |
| 189 | static const struct drm_display_mode drm_dmt_modes[] = { |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 190 | /* 0x01 - 640x350@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 191 | { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, |
| 192 | 736, 832, 0, 350, 382, 385, 445, 0, |
| 193 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 194 | /* 0x02 - 640x400@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 195 | { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, |
| 196 | 736, 832, 0, 400, 401, 404, 445, 0, |
| 197 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 198 | /* 0x03 - 720x400@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 199 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756, |
| 200 | 828, 936, 0, 400, 401, 404, 446, 0, |
| 201 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 202 | /* 0x04 - 640x480@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 203 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 204 | 752, 800, 0, 480, 490, 492, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 205 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 206 | /* 0x05 - 640x480@72Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 207 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, |
| 208 | 704, 832, 0, 480, 489, 492, 520, 0, |
| 209 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 210 | /* 0x06 - 640x480@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 211 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, |
| 212 | 720, 840, 0, 480, 481, 484, 500, 0, |
| 213 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 214 | /* 0x07 - 640x480@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 215 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696, |
| 216 | 752, 832, 0, 480, 481, 484, 509, 0, |
| 217 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 218 | /* 0x08 - 800x600@56Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 219 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, |
| 220 | 896, 1024, 0, 600, 601, 603, 625, 0, |
| 221 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 222 | /* 0x09 - 800x600@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 223 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, |
| 224 | 968, 1056, 0, 600, 601, 605, 628, 0, |
| 225 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 226 | /* 0x0a - 800x600@72Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 227 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, |
| 228 | 976, 1040, 0, 600, 637, 643, 666, 0, |
| 229 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 230 | /* 0x0b - 800x600@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 231 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, |
| 232 | 896, 1056, 0, 600, 601, 604, 625, 0, |
| 233 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 234 | /* 0x0c - 800x600@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 235 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832, |
| 236 | 896, 1048, 0, 600, 601, 604, 631, 0, |
| 237 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 238 | /* 0x0d - 800x600@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 239 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 73250, 800, 848, |
| 240 | 880, 960, 0, 600, 603, 607, 636, 0, |
| 241 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 242 | /* 0x0e - 848x480@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 243 | { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864, |
| 244 | 976, 1088, 0, 480, 486, 494, 517, 0, |
| 245 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 246 | /* 0x0f - 1024x768@43Hz, interlace */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 247 | { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032, |
Paul Parsons | 735b100 | 2016-04-04 20:36:34 +0100 | [diff] [blame] | 248 | 1208, 1264, 0, 768, 768, 776, 817, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 249 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 250 | DRM_MODE_FLAG_INTERLACE) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 251 | /* 0x10 - 1024x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 252 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, |
| 253 | 1184, 1344, 0, 768, 771, 777, 806, 0, |
| 254 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 255 | /* 0x11 - 1024x768@70Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 256 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, |
| 257 | 1184, 1328, 0, 768, 771, 777, 806, 0, |
| 258 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 259 | /* 0x12 - 1024x768@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 260 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, |
| 261 | 1136, 1312, 0, 768, 769, 772, 800, 0, |
| 262 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 263 | /* 0x13 - 1024x768@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 264 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072, |
| 265 | 1168, 1376, 0, 768, 769, 772, 808, 0, |
| 266 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 267 | /* 0x14 - 1024x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 268 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 115500, 1024, 1072, |
| 269 | 1104, 1184, 0, 768, 771, 775, 813, 0, |
| 270 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 271 | /* 0x15 - 1152x864@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 272 | { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, |
| 273 | 1344, 1600, 0, 864, 865, 868, 900, 0, |
| 274 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 275 | /* 0x55 - 1280x720@60Hz */ |
| 276 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 277 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 278 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 279 | /* 0x16 - 1280x768@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 280 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 68250, 1280, 1328, |
| 281 | 1360, 1440, 0, 768, 771, 778, 790, 0, |
| 282 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 283 | /* 0x17 - 1280x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 284 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344, |
| 285 | 1472, 1664, 0, 768, 771, 778, 798, 0, |
| 286 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 287 | /* 0x18 - 1280x768@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 288 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360, |
| 289 | 1488, 1696, 0, 768, 771, 778, 805, 0, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 290 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 291 | /* 0x19 - 1280x768@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 292 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360, |
| 293 | 1496, 1712, 0, 768, 771, 778, 809, 0, |
| 294 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 295 | /* 0x1a - 1280x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 296 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 140250, 1280, 1328, |
| 297 | 1360, 1440, 0, 768, 771, 778, 813, 0, |
| 298 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 299 | /* 0x1b - 1280x800@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 300 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 71000, 1280, 1328, |
| 301 | 1360, 1440, 0, 800, 803, 809, 823, 0, |
| 302 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 303 | /* 0x1c - 1280x800@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 304 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352, |
| 305 | 1480, 1680, 0, 800, 803, 809, 831, 0, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 306 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 307 | /* 0x1d - 1280x800@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 308 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360, |
| 309 | 1488, 1696, 0, 800, 803, 809, 838, 0, |
| 310 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 311 | /* 0x1e - 1280x800@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 312 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360, |
| 313 | 1496, 1712, 0, 800, 803, 809, 843, 0, |
| 314 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 315 | /* 0x1f - 1280x800@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 316 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 146250, 1280, 1328, |
| 317 | 1360, 1440, 0, 800, 803, 809, 847, 0, |
| 318 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 319 | /* 0x20 - 1280x960@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 320 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376, |
| 321 | 1488, 1800, 0, 960, 961, 964, 1000, 0, |
| 322 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 323 | /* 0x21 - 1280x960@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 324 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344, |
| 325 | 1504, 1728, 0, 960, 961, 964, 1011, 0, |
| 326 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 327 | /* 0x22 - 1280x960@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 328 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 175500, 1280, 1328, |
| 329 | 1360, 1440, 0, 960, 963, 967, 1017, 0, |
| 330 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 331 | /* 0x23 - 1280x1024@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 332 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328, |
| 333 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 334 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 335 | /* 0x24 - 1280x1024@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 336 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, |
| 337 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 338 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 339 | /* 0x25 - 1280x1024@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 340 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344, |
| 341 | 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, |
| 342 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 343 | /* 0x26 - 1280x1024@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 344 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 187250, 1280, 1328, |
| 345 | 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, |
| 346 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 347 | /* 0x27 - 1360x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 348 | { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424, |
| 349 | 1536, 1792, 0, 768, 771, 777, 795, 0, |
| 350 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 351 | /* 0x28 - 1360x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 352 | { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 148250, 1360, 1408, |
| 353 | 1440, 1520, 0, 768, 771, 776, 813, 0, |
| 354 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 355 | /* 0x51 - 1366x768@60Hz */ |
| 356 | { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 85500, 1366, 1436, |
| 357 | 1579, 1792, 0, 768, 771, 774, 798, 0, |
| 358 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
| 359 | /* 0x56 - 1366x768@60Hz */ |
| 360 | { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 72000, 1366, 1380, |
| 361 | 1436, 1500, 0, 768, 769, 772, 800, 0, |
| 362 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 363 | /* 0x29 - 1400x1050@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 364 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 101000, 1400, 1448, |
| 365 | 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, |
| 366 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 367 | /* 0x2a - 1400x1050@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 368 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488, |
| 369 | 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, |
| 370 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 371 | /* 0x2b - 1400x1050@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 372 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504, |
| 373 | 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, |
| 374 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 375 | /* 0x2c - 1400x1050@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 376 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504, |
| 377 | 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, |
| 378 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 379 | /* 0x2d - 1400x1050@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 380 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 208000, 1400, 1448, |
| 381 | 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, |
| 382 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 383 | /* 0x2e - 1440x900@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 384 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 88750, 1440, 1488, |
| 385 | 1520, 1600, 0, 900, 903, 909, 926, 0, |
| 386 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 387 | /* 0x2f - 1440x900@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 388 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520, |
| 389 | 1672, 1904, 0, 900, 903, 909, 934, 0, |
| 390 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 391 | /* 0x30 - 1440x900@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 392 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536, |
| 393 | 1688, 1936, 0, 900, 903, 909, 942, 0, |
| 394 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 395 | /* 0x31 - 1440x900@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 396 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544, |
| 397 | 1696, 1952, 0, 900, 903, 909, 948, 0, |
| 398 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 399 | /* 0x32 - 1440x900@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 400 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 182750, 1440, 1488, |
| 401 | 1520, 1600, 0, 900, 903, 909, 953, 0, |
| 402 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 403 | /* 0x53 - 1600x900@60Hz */ |
| 404 | { DRM_MODE("1600x900", DRM_MODE_TYPE_DRIVER, 108000, 1600, 1624, |
| 405 | 1704, 1800, 0, 900, 901, 904, 1000, 0, |
| 406 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 407 | /* 0x33 - 1600x1200@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 408 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664, |
| 409 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 410 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 411 | /* 0x34 - 1600x1200@65Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 412 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664, |
| 413 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 414 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 415 | /* 0x35 - 1600x1200@70Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 416 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664, |
| 417 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 418 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 419 | /* 0x36 - 1600x1200@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 420 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 202500, 1600, 1664, |
| 421 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 422 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 423 | /* 0x37 - 1600x1200@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 424 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664, |
| 425 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 426 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 427 | /* 0x38 - 1600x1200@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 428 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 268250, 1600, 1648, |
| 429 | 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, |
| 430 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 431 | /* 0x39 - 1680x1050@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 432 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 119000, 1680, 1728, |
| 433 | 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, |
| 434 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 435 | /* 0x3a - 1680x1050@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 436 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784, |
| 437 | 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, |
| 438 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 439 | /* 0x3b - 1680x1050@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 440 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800, |
| 441 | 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, |
| 442 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 443 | /* 0x3c - 1680x1050@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 444 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808, |
| 445 | 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, |
| 446 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 447 | /* 0x3d - 1680x1050@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 448 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 245500, 1680, 1728, |
| 449 | 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, |
| 450 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 451 | /* 0x3e - 1792x1344@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 452 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920, |
| 453 | 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, |
| 454 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 455 | /* 0x3f - 1792x1344@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 456 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888, |
| 457 | 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, |
| 458 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 459 | /* 0x40 - 1792x1344@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 460 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 333250, 1792, 1840, |
| 461 | 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, |
| 462 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 463 | /* 0x41 - 1856x1392@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 464 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952, |
| 465 | 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, |
| 466 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 467 | /* 0x42 - 1856x1392@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 468 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 469 | 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 470 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 471 | /* 0x43 - 1856x1392@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 472 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 356500, 1856, 1904, |
| 473 | 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, |
| 474 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 475 | /* 0x52 - 1920x1080@60Hz */ |
| 476 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 477 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 478 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 479 | /* 0x44 - 1920x1200@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 480 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 154000, 1920, 1968, |
| 481 | 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, |
| 482 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 483 | /* 0x45 - 1920x1200@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 484 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056, |
| 485 | 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, |
| 486 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 487 | /* 0x46 - 1920x1200@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 488 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056, |
| 489 | 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, |
| 490 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 491 | /* 0x47 - 1920x1200@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 492 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064, |
| 493 | 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, |
| 494 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 495 | /* 0x48 - 1920x1200@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 496 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 317000, 1920, 1968, |
| 497 | 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, |
| 498 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 499 | /* 0x49 - 1920x1440@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 500 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048, |
| 501 | 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, |
| 502 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 503 | /* 0x4a - 1920x1440@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 504 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064, |
| 505 | 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, |
| 506 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 507 | /* 0x4b - 1920x1440@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 508 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 380500, 1920, 1968, |
| 509 | 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, |
| 510 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 511 | /* 0x54 - 2048x1152@60Hz */ |
| 512 | { DRM_MODE("2048x1152", DRM_MODE_TYPE_DRIVER, 162000, 2048, 2074, |
| 513 | 2154, 2250, 0, 1152, 1153, 1156, 1200, 0, |
| 514 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 515 | /* 0x4c - 2560x1600@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 516 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 268500, 2560, 2608, |
| 517 | 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, |
| 518 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 519 | /* 0x4d - 2560x1600@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 520 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752, |
| 521 | 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, |
| 522 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 523 | /* 0x4e - 2560x1600@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 524 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768, |
| 525 | 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, |
| 526 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 527 | /* 0x4f - 2560x1600@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 528 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768, |
| 529 | 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, |
| 530 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 531 | /* 0x50 - 2560x1600@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 532 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 552750, 2560, 2608, |
| 533 | 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, |
| 534 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 535 | /* 0x57 - 4096x2160@60Hz RB */ |
| 536 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556744, 4096, 4104, |
| 537 | 4136, 4176, 0, 2160, 2208, 2216, 2222, 0, |
| 538 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
| 539 | /* 0x58 - 4096x2160@59.94Hz RB */ |
| 540 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556188, 4096, 4104, |
| 541 | 4136, 4176, 0, 2160, 2208, 2216, 2222, 0, |
| 542 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 543 | }; |
| 544 | |
Ville Syrjälä | e7bfa5c | 2013-10-14 16:44:27 +0300 | [diff] [blame] | 545 | /* |
| 546 | * These more or less come from the DMT spec. The 720x400 modes are |
| 547 | * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75 |
| 548 | * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode |
| 549 | * should be 1152x870, again for the Mac, but instead we use the x864 DMT |
| 550 | * mode. |
| 551 | * |
| 552 | * The DMT modes have been fact-checked; the rest are mild guesses. |
| 553 | */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 554 | static const struct drm_display_mode edid_est_modes[] = { |
| 555 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, |
| 556 | 968, 1056, 0, 600, 601, 605, 628, 0, |
| 557 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */ |
| 558 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, |
| 559 | 896, 1024, 0, 600, 601, 603, 625, 0, |
| 560 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */ |
| 561 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, |
| 562 | 720, 840, 0, 480, 481, 484, 500, 0, |
| 563 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */ |
| 564 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 565 | 704, 832, 0, 480, 489, 492, 520, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 566 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */ |
| 567 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704, |
| 568 | 768, 864, 0, 480, 483, 486, 525, 0, |
| 569 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */ |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 570 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 571 | 752, 800, 0, 480, 490, 492, 525, 0, |
| 572 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */ |
| 573 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738, |
| 574 | 846, 900, 0, 400, 421, 423, 449, 0, |
| 575 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */ |
| 576 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738, |
| 577 | 846, 900, 0, 400, 412, 414, 449, 0, |
| 578 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */ |
| 579 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, |
| 580 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 581 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */ |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 582 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 583 | 1136, 1312, 0, 768, 769, 772, 800, 0, |
| 584 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */ |
| 585 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, |
| 586 | 1184, 1328, 0, 768, 771, 777, 806, 0, |
| 587 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */ |
| 588 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, |
| 589 | 1184, 1344, 0, 768, 771, 777, 806, 0, |
| 590 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */ |
| 591 | { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032, |
| 592 | 1208, 1264, 0, 768, 768, 776, 817, 0, |
| 593 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */ |
| 594 | { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864, |
| 595 | 928, 1152, 0, 624, 625, 628, 667, 0, |
| 596 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */ |
| 597 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, |
| 598 | 896, 1056, 0, 600, 601, 604, 625, 0, |
| 599 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */ |
| 600 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, |
| 601 | 976, 1040, 0, 600, 637, 643, 666, 0, |
| 602 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */ |
| 603 | { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, |
| 604 | 1344, 1600, 0, 864, 865, 868, 900, 0, |
| 605 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */ |
| 606 | }; |
| 607 | |
| 608 | struct minimode { |
| 609 | short w; |
| 610 | short h; |
| 611 | short r; |
| 612 | short rb; |
| 613 | }; |
| 614 | |
| 615 | static const struct minimode est3_modes[] = { |
| 616 | /* byte 6 */ |
| 617 | { 640, 350, 85, 0 }, |
| 618 | { 640, 400, 85, 0 }, |
| 619 | { 720, 400, 85, 0 }, |
| 620 | { 640, 480, 85, 0 }, |
| 621 | { 848, 480, 60, 0 }, |
| 622 | { 800, 600, 85, 0 }, |
| 623 | { 1024, 768, 85, 0 }, |
| 624 | { 1152, 864, 75, 0 }, |
| 625 | /* byte 7 */ |
| 626 | { 1280, 768, 60, 1 }, |
| 627 | { 1280, 768, 60, 0 }, |
| 628 | { 1280, 768, 75, 0 }, |
| 629 | { 1280, 768, 85, 0 }, |
| 630 | { 1280, 960, 60, 0 }, |
| 631 | { 1280, 960, 85, 0 }, |
| 632 | { 1280, 1024, 60, 0 }, |
| 633 | { 1280, 1024, 85, 0 }, |
| 634 | /* byte 8 */ |
| 635 | { 1360, 768, 60, 0 }, |
| 636 | { 1440, 900, 60, 1 }, |
| 637 | { 1440, 900, 60, 0 }, |
| 638 | { 1440, 900, 75, 0 }, |
| 639 | { 1440, 900, 85, 0 }, |
| 640 | { 1400, 1050, 60, 1 }, |
| 641 | { 1400, 1050, 60, 0 }, |
| 642 | { 1400, 1050, 75, 0 }, |
| 643 | /* byte 9 */ |
| 644 | { 1400, 1050, 85, 0 }, |
| 645 | { 1680, 1050, 60, 1 }, |
| 646 | { 1680, 1050, 60, 0 }, |
| 647 | { 1680, 1050, 75, 0 }, |
| 648 | { 1680, 1050, 85, 0 }, |
| 649 | { 1600, 1200, 60, 0 }, |
| 650 | { 1600, 1200, 65, 0 }, |
| 651 | { 1600, 1200, 70, 0 }, |
| 652 | /* byte 10 */ |
| 653 | { 1600, 1200, 75, 0 }, |
| 654 | { 1600, 1200, 85, 0 }, |
| 655 | { 1792, 1344, 60, 0 }, |
Ville Syrjälä | c068b32 | 2013-10-14 16:44:25 +0300 | [diff] [blame] | 656 | { 1792, 1344, 75, 0 }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 657 | { 1856, 1392, 60, 0 }, |
| 658 | { 1856, 1392, 75, 0 }, |
| 659 | { 1920, 1200, 60, 1 }, |
| 660 | { 1920, 1200, 60, 0 }, |
| 661 | /* byte 11 */ |
| 662 | { 1920, 1200, 75, 0 }, |
| 663 | { 1920, 1200, 85, 0 }, |
| 664 | { 1920, 1440, 60, 0 }, |
| 665 | { 1920, 1440, 75, 0 }, |
| 666 | }; |
| 667 | |
| 668 | static const struct minimode extra_modes[] = { |
| 669 | { 1024, 576, 60, 0 }, |
| 670 | { 1366, 768, 60, 0 }, |
| 671 | { 1600, 900, 60, 0 }, |
| 672 | { 1680, 945, 60, 0 }, |
| 673 | { 1920, 1080, 60, 0 }, |
| 674 | { 2048, 1152, 60, 0 }, |
| 675 | { 2048, 1536, 60, 0 }, |
| 676 | }; |
| 677 | |
| 678 | /* |
| 679 | * Probably taken from CEA-861 spec. |
| 680 | * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c. |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 681 | * |
| 682 | * Index using the VIC. |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 683 | */ |
| 684 | static const struct drm_display_mode edid_cea_modes[] = { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 685 | /* 0 - dummy, VICs start at 1 */ |
| 686 | { }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 687 | /* 1 - 640x480@60Hz */ |
| 688 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
| 689 | 752, 800, 0, 480, 490, 492, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 690 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 691 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 692 | /* 2 - 720x480@60Hz */ |
| 693 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736, |
| 694 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 695 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 696 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 697 | /* 3 - 720x480@60Hz */ |
| 698 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736, |
| 699 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 700 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 701 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 702 | /* 4 - 1280x720@60Hz */ |
| 703 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 704 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 705 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 706 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 707 | /* 5 - 1920x1080i@60Hz */ |
| 708 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 709 | 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, |
| 710 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 711 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 712 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 713 | /* 6 - 720(1440)x480i@60Hz */ |
| 714 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 715 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 716 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 717 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 718 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 719 | /* 7 - 720(1440)x480i@60Hz */ |
| 720 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 721 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 722 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 723 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 724 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 725 | /* 8 - 720(1440)x240@60Hz */ |
| 726 | { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 727 | 801, 858, 0, 240, 244, 247, 262, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 728 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 729 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 730 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 731 | /* 9 - 720(1440)x240@60Hz */ |
| 732 | { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 733 | 801, 858, 0, 240, 244, 247, 262, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 734 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 735 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 736 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 737 | /* 10 - 2880x480i@60Hz */ |
| 738 | { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 739 | 3204, 3432, 0, 480, 488, 494, 525, 0, |
| 740 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 741 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 742 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 743 | /* 11 - 2880x480i@60Hz */ |
| 744 | { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 745 | 3204, 3432, 0, 480, 488, 494, 525, 0, |
| 746 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 747 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 748 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 749 | /* 12 - 2880x240@60Hz */ |
| 750 | { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 751 | 3204, 3432, 0, 240, 244, 247, 262, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 752 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 753 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 754 | /* 13 - 2880x240@60Hz */ |
| 755 | { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 756 | 3204, 3432, 0, 240, 244, 247, 262, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 757 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 758 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 759 | /* 14 - 1440x480@60Hz */ |
| 760 | { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472, |
| 761 | 1596, 1716, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 762 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 763 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 764 | /* 15 - 1440x480@60Hz */ |
| 765 | { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472, |
| 766 | 1596, 1716, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 767 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 768 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 769 | /* 16 - 1920x1080@60Hz */ |
| 770 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 771 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 772 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 773 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 774 | /* 17 - 720x576@50Hz */ |
| 775 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 776 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 777 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 778 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 779 | /* 18 - 720x576@50Hz */ |
| 780 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 781 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 782 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 783 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 784 | /* 19 - 1280x720@50Hz */ |
| 785 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720, |
| 786 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 787 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 788 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 789 | /* 20 - 1920x1080i@50Hz */ |
| 790 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 791 | 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, |
| 792 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 793 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 794 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 795 | /* 21 - 720(1440)x576i@50Hz */ |
| 796 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 797 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 798 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 799 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 800 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 801 | /* 22 - 720(1440)x576i@50Hz */ |
| 802 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 803 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 804 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 805 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 806 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 807 | /* 23 - 720(1440)x288@50Hz */ |
| 808 | { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 809 | 795, 864, 0, 288, 290, 293, 312, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 810 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 811 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 812 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 813 | /* 24 - 720(1440)x288@50Hz */ |
| 814 | { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 815 | 795, 864, 0, 288, 290, 293, 312, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 816 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 817 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 818 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 819 | /* 25 - 2880x576i@50Hz */ |
| 820 | { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 821 | 3180, 3456, 0, 576, 580, 586, 625, 0, |
| 822 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 823 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 824 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 825 | /* 26 - 2880x576i@50Hz */ |
| 826 | { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 827 | 3180, 3456, 0, 576, 580, 586, 625, 0, |
| 828 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 829 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 830 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 831 | /* 27 - 2880x288@50Hz */ |
| 832 | { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 833 | 3180, 3456, 0, 288, 290, 293, 312, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 834 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 835 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 836 | /* 28 - 2880x288@50Hz */ |
| 837 | { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 838 | 3180, 3456, 0, 288, 290, 293, 312, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 839 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 840 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 841 | /* 29 - 1440x576@50Hz */ |
| 842 | { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464, |
| 843 | 1592, 1728, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 844 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 845 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 846 | /* 30 - 1440x576@50Hz */ |
| 847 | { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464, |
| 848 | 1592, 1728, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 849 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 850 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 851 | /* 31 - 1920x1080@50Hz */ |
| 852 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 853 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 854 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 855 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 856 | /* 32 - 1920x1080@24Hz */ |
| 857 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558, |
| 858 | 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 859 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 860 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 861 | /* 33 - 1920x1080@25Hz */ |
| 862 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 863 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 864 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 865 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 866 | /* 34 - 1920x1080@30Hz */ |
| 867 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 868 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 869 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 870 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 871 | /* 35 - 2880x480@60Hz */ |
| 872 | { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944, |
| 873 | 3192, 3432, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 874 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 875 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 876 | /* 36 - 2880x480@60Hz */ |
| 877 | { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944, |
| 878 | 3192, 3432, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 879 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 880 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 881 | /* 37 - 2880x576@50Hz */ |
| 882 | { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928, |
| 883 | 3184, 3456, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 884 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 885 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 886 | /* 38 - 2880x576@50Hz */ |
| 887 | { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928, |
| 888 | 3184, 3456, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 889 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 890 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 891 | /* 39 - 1920x1080i@50Hz */ |
| 892 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 72000, 1920, 1952, |
| 893 | 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, |
| 894 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 895 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 896 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 897 | /* 40 - 1920x1080i@100Hz */ |
| 898 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 899 | 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, |
| 900 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 901 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 902 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 903 | /* 41 - 1280x720@100Hz */ |
| 904 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720, |
| 905 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 906 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 907 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 908 | /* 42 - 720x576@100Hz */ |
| 909 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 910 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 911 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 912 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 913 | /* 43 - 720x576@100Hz */ |
| 914 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 915 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 916 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 917 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 918 | /* 44 - 720(1440)x576i@100Hz */ |
| 919 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 920 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 921 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Clint Taylor | 5a11f7f | 2014-09-26 09:55:24 -0700 | [diff] [blame] | 922 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 923 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 924 | /* 45 - 720(1440)x576i@100Hz */ |
| 925 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 926 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 927 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Clint Taylor | 5a11f7f | 2014-09-26 09:55:24 -0700 | [diff] [blame] | 928 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 929 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 930 | /* 46 - 1920x1080i@120Hz */ |
| 931 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 932 | 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, |
| 933 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 934 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 935 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 936 | /* 47 - 1280x720@120Hz */ |
| 937 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390, |
| 938 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 939 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 940 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 941 | /* 48 - 720x480@120Hz */ |
| 942 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736, |
| 943 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 944 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 945 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 946 | /* 49 - 720x480@120Hz */ |
| 947 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736, |
| 948 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 949 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 950 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 951 | /* 50 - 720(1440)x480i@120Hz */ |
| 952 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739, |
| 953 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 954 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 955 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 956 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 957 | /* 51 - 720(1440)x480i@120Hz */ |
| 958 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739, |
| 959 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 960 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 961 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 962 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 963 | /* 52 - 720x576@200Hz */ |
| 964 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732, |
| 965 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 966 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 967 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 968 | /* 53 - 720x576@200Hz */ |
| 969 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732, |
| 970 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 971 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 972 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 973 | /* 54 - 720(1440)x576i@200Hz */ |
| 974 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 975 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 976 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 977 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 978 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 979 | /* 55 - 720(1440)x576i@200Hz */ |
| 980 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 981 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 982 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 983 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 984 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 985 | /* 56 - 720x480@240Hz */ |
| 986 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736, |
| 987 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 988 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 989 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 990 | /* 57 - 720x480@240Hz */ |
| 991 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736, |
| 992 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 993 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 994 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | e587803 | 2016-11-03 14:53:28 +0200 | [diff] [blame] | 995 | /* 58 - 720(1440)x480i@240Hz */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 996 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739, |
| 997 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 998 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 999 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1000 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | e587803 | 2016-11-03 14:53:28 +0200 | [diff] [blame] | 1001 | /* 59 - 720(1440)x480i@240Hz */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 1002 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739, |
| 1003 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1004 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1005 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1006 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1007 | /* 60 - 1280x720@24Hz */ |
| 1008 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040, |
| 1009 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1010 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1011 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1012 | /* 61 - 1280x720@25Hz */ |
| 1013 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700, |
| 1014 | 3740, 3960, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1015 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1016 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1017 | /* 62 - 1280x720@30Hz */ |
| 1018 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040, |
| 1019 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1020 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1021 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1022 | /* 63 - 1920x1080@120Hz */ |
| 1023 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008, |
| 1024 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1025 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1026 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1027 | /* 64 - 1920x1080@100Hz */ |
| 1028 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448, |
Clint Taylor | 8f0e490 | 2016-08-15 10:31:28 -0700 | [diff] [blame] | 1029 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1030 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1031 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1032 | /* 65 - 1280x720@24Hz */ |
| 1033 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040, |
| 1034 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1035 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1036 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1037 | /* 66 - 1280x720@25Hz */ |
| 1038 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700, |
| 1039 | 3740, 3960, 0, 720, 725, 730, 750, 0, |
| 1040 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1041 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1042 | /* 67 - 1280x720@30Hz */ |
| 1043 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040, |
| 1044 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1045 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1046 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1047 | /* 68 - 1280x720@50Hz */ |
| 1048 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720, |
| 1049 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
| 1050 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1051 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1052 | /* 69 - 1280x720@60Hz */ |
| 1053 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 1054 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 1055 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1056 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1057 | /* 70 - 1280x720@100Hz */ |
| 1058 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720, |
| 1059 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
| 1060 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1061 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1062 | /* 71 - 1280x720@120Hz */ |
| 1063 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390, |
| 1064 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 1065 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1066 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1067 | /* 72 - 1920x1080@24Hz */ |
| 1068 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558, |
| 1069 | 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, |
| 1070 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1071 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1072 | /* 73 - 1920x1080@25Hz */ |
| 1073 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 1074 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1075 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1076 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1077 | /* 74 - 1920x1080@30Hz */ |
| 1078 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 1079 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1080 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1081 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1082 | /* 75 - 1920x1080@50Hz */ |
| 1083 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 1084 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1085 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1086 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1087 | /* 76 - 1920x1080@60Hz */ |
| 1088 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 1089 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1090 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1091 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1092 | /* 77 - 1920x1080@100Hz */ |
| 1093 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448, |
| 1094 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1095 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1096 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1097 | /* 78 - 1920x1080@120Hz */ |
| 1098 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008, |
| 1099 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1100 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1101 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1102 | /* 79 - 1680x720@24Hz */ |
| 1103 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 3040, |
| 1104 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1105 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1106 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1107 | /* 80 - 1680x720@25Hz */ |
| 1108 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2908, |
| 1109 | 2948, 3168, 0, 720, 725, 730, 750, 0, |
| 1110 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1111 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1112 | /* 81 - 1680x720@30Hz */ |
| 1113 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2380, |
| 1114 | 2420, 2640, 0, 720, 725, 730, 750, 0, |
| 1115 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1116 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1117 | /* 82 - 1680x720@50Hz */ |
| 1118 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 82500, 1680, 1940, |
| 1119 | 1980, 2200, 0, 720, 725, 730, 750, 0, |
| 1120 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1121 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1122 | /* 83 - 1680x720@60Hz */ |
| 1123 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 99000, 1680, 1940, |
| 1124 | 1980, 2200, 0, 720, 725, 730, 750, 0, |
| 1125 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1126 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1127 | /* 84 - 1680x720@100Hz */ |
| 1128 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 165000, 1680, 1740, |
| 1129 | 1780, 2000, 0, 720, 725, 730, 825, 0, |
| 1130 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1131 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1132 | /* 85 - 1680x720@120Hz */ |
| 1133 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 198000, 1680, 1740, |
| 1134 | 1780, 2000, 0, 720, 725, 730, 825, 0, |
| 1135 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1136 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1137 | /* 86 - 2560x1080@24Hz */ |
| 1138 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 99000, 2560, 3558, |
| 1139 | 3602, 3750, 0, 1080, 1084, 1089, 1100, 0, |
| 1140 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1141 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1142 | /* 87 - 2560x1080@25Hz */ |
| 1143 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 90000, 2560, 3008, |
| 1144 | 3052, 3200, 0, 1080, 1084, 1089, 1125, 0, |
| 1145 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1146 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1147 | /* 88 - 2560x1080@30Hz */ |
| 1148 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 118800, 2560, 3328, |
| 1149 | 3372, 3520, 0, 1080, 1084, 1089, 1125, 0, |
| 1150 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1151 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1152 | /* 89 - 2560x1080@50Hz */ |
| 1153 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 185625, 2560, 3108, |
| 1154 | 3152, 3300, 0, 1080, 1084, 1089, 1125, 0, |
| 1155 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1156 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1157 | /* 90 - 2560x1080@60Hz */ |
| 1158 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 198000, 2560, 2808, |
| 1159 | 2852, 3000, 0, 1080, 1084, 1089, 1100, 0, |
| 1160 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1161 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1162 | /* 91 - 2560x1080@100Hz */ |
| 1163 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 371250, 2560, 2778, |
| 1164 | 2822, 2970, 0, 1080, 1084, 1089, 1250, 0, |
| 1165 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1166 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1167 | /* 92 - 2560x1080@120Hz */ |
| 1168 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 495000, 2560, 3108, |
| 1169 | 3152, 3300, 0, 1080, 1084, 1089, 1250, 0, |
| 1170 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1171 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1172 | /* 93 - 3840x2160p@24Hz 16:9 */ |
| 1173 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, |
| 1174 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1175 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1176 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1177 | /* 94 - 3840x2160p@25Hz 16:9 */ |
| 1178 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896, |
| 1179 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1180 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1181 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1182 | /* 95 - 3840x2160p@30Hz 16:9 */ |
| 1183 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016, |
| 1184 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1185 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1186 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1187 | /* 96 - 3840x2160p@50Hz 16:9 */ |
| 1188 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896, |
| 1189 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1190 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1191 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1192 | /* 97 - 3840x2160p@60Hz 16:9 */ |
| 1193 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, |
| 1194 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1195 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1196 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1197 | /* 98 - 4096x2160p@24Hz 256:135 */ |
| 1198 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5116, |
| 1199 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1200 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1201 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
| 1202 | /* 99 - 4096x2160p@25Hz 256:135 */ |
| 1203 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5064, |
| 1204 | 5152, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1205 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1206 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
| 1207 | /* 100 - 4096x2160p@30Hz 256:135 */ |
| 1208 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 4184, |
| 1209 | 4272, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1210 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1211 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
| 1212 | /* 101 - 4096x2160p@50Hz 256:135 */ |
| 1213 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 5064, |
| 1214 | 5152, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1215 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1216 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
| 1217 | /* 102 - 4096x2160p@60Hz 256:135 */ |
| 1218 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184, |
| 1219 | 4272, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1220 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1221 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
| 1222 | /* 103 - 3840x2160p@24Hz 64:27 */ |
| 1223 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, |
| 1224 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1225 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1226 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1227 | /* 104 - 3840x2160p@25Hz 64:27 */ |
| 1228 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896, |
| 1229 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1230 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1231 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1232 | /* 105 - 3840x2160p@30Hz 64:27 */ |
| 1233 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016, |
| 1234 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1235 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1236 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1237 | /* 106 - 3840x2160p@50Hz 64:27 */ |
| 1238 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896, |
| 1239 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1240 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1241 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
| 1242 | /* 107 - 3840x2160p@60Hz 64:27 */ |
| 1243 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, |
| 1244 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1245 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1246 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1247 | }; |
| 1248 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1249 | /* |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 1250 | * HDMI 1.4 4k modes. Index using the VIC. |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1251 | */ |
| 1252 | static const struct drm_display_mode edid_4k_modes[] = { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 1253 | /* 0 - dummy, VICs start at 1 */ |
| 1254 | { }, |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1255 | /* 1 - 3840x2160@30Hz */ |
| 1256 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1257 | 3840, 4016, 4104, 4400, 0, |
| 1258 | 2160, 2168, 2178, 2250, 0, |
| 1259 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1260 | .vrefresh = 30, }, |
| 1261 | /* 2 - 3840x2160@25Hz */ |
| 1262 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1263 | 3840, 4896, 4984, 5280, 0, |
| 1264 | 2160, 2168, 2178, 2250, 0, |
| 1265 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1266 | .vrefresh = 25, }, |
| 1267 | /* 3 - 3840x2160@24Hz */ |
| 1268 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1269 | 3840, 5116, 5204, 5500, 0, |
| 1270 | 2160, 2168, 2178, 2250, 0, |
| 1271 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1272 | .vrefresh = 24, }, |
| 1273 | /* 4 - 4096x2160@24Hz (SMPTE) */ |
| 1274 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1275 | 4096, 5116, 5204, 5500, 0, |
| 1276 | 2160, 2168, 2178, 2250, 0, |
| 1277 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1278 | .vrefresh = 24, }, |
| 1279 | }; |
| 1280 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1281 | /*** DDC fetch and block validation ***/ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1282 | |
Adam Jackson | 083ae05 | 2009-09-23 17:30:45 -0400 | [diff] [blame] | 1283 | static const u8 edid_header[] = { |
| 1284 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 |
| 1285 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1286 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1287 | /** |
| 1288 | * drm_edid_header_is_valid - sanity check the header of the base EDID block |
| 1289 | * @raw_edid: pointer to raw base EDID block |
| 1290 | * |
| 1291 | * Sanity check the header of the base EDID block. |
| 1292 | * |
| 1293 | * Return: 8 if the header is perfect, down to 0 if it's totally wrong. |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 1294 | */ |
| 1295 | int drm_edid_header_is_valid(const u8 *raw_edid) |
| 1296 | { |
| 1297 | int i, score = 0; |
| 1298 | |
| 1299 | for (i = 0; i < sizeof(edid_header); i++) |
| 1300 | if (raw_edid[i] == edid_header[i]) |
| 1301 | score++; |
| 1302 | |
| 1303 | return score; |
| 1304 | } |
| 1305 | EXPORT_SYMBOL(drm_edid_header_is_valid); |
| 1306 | |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 1307 | static int edid_fixup __read_mostly = 6; |
| 1308 | module_param_named(edid_fixup, edid_fixup, int, 0400); |
| 1309 | MODULE_PARM_DESC(edid_fixup, |
| 1310 | "Minimum number of valid EDID header bytes (0-8, default 6)"); |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 1311 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1312 | static void drm_get_displayid(struct drm_connector *connector, |
| 1313 | struct edid *edid); |
Dave Airlie | da9df2f | 2014-12-11 10:12:57 +1000 | [diff] [blame] | 1314 | |
Stefan Brüns | c465bbc | 2014-11-30 19:57:43 +0100 | [diff] [blame] | 1315 | static int drm_edid_block_checksum(const u8 *raw_edid) |
| 1316 | { |
| 1317 | int i; |
| 1318 | u8 csum = 0; |
| 1319 | for (i = 0; i < EDID_LENGTH; i++) |
| 1320 | csum += raw_edid[i]; |
| 1321 | |
| 1322 | return csum; |
| 1323 | } |
| 1324 | |
Stefan Brüns | d6885d6 | 2014-11-30 19:57:41 +0100 | [diff] [blame] | 1325 | static bool drm_edid_is_zero(const u8 *in_edid, int length) |
| 1326 | { |
| 1327 | if (memchr_inv(in_edid, 0, length)) |
| 1328 | return false; |
| 1329 | |
| 1330 | return true; |
| 1331 | } |
| 1332 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1333 | /** |
| 1334 | * drm_edid_block_valid - Sanity check the EDID block (base or extension) |
| 1335 | * @raw_edid: pointer to raw EDID block |
| 1336 | * @block: type of block to validate (0 for base, extension otherwise) |
| 1337 | * @print_bad_edid: if true, dump bad EDID blocks to the console |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1338 | * @edid_corrupt: if true, the header or checksum is invalid |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1339 | * |
| 1340 | * Validate a base or extension EDID block and optionally dump bad blocks to |
| 1341 | * the console. |
| 1342 | * |
| 1343 | * Return: True if the block is valid, false otherwise. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1344 | */ |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1345 | bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
| 1346 | bool *edid_corrupt) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1347 | { |
Stefan Brüns | c465bbc | 2014-11-30 19:57:43 +0100 | [diff] [blame] | 1348 | u8 csum; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1349 | struct edid *edid = (struct edid *)raw_edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1350 | |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1351 | if (WARN_ON(!raw_edid)) |
| 1352 | return false; |
| 1353 | |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 1354 | if (edid_fixup > 8 || edid_fixup < 0) |
| 1355 | edid_fixup = 6; |
| 1356 | |
Adam Jackson | f89ec8a | 2012-04-16 10:40:08 -0400 | [diff] [blame] | 1357 | if (block == 0) { |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 1358 | int score = drm_edid_header_is_valid(raw_edid); |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1359 | if (score == 8) { |
| 1360 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1361 | *edid_corrupt = false; |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1362 | } else if (score >= edid_fixup) { |
| 1363 | /* Displayport Link CTS Core 1.2 rev1.1 test 4.2.2.6 |
| 1364 | * The corrupt flag needs to be set here otherwise, the |
| 1365 | * fix-up code here will correct the problem, the |
| 1366 | * checksum is correct and the test fails |
| 1367 | */ |
| 1368 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1369 | *edid_corrupt = true; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1370 | DRM_DEBUG("Fixing EDID header, your hardware may be failing\n"); |
| 1371 | memcpy(raw_edid, edid_header, sizeof(edid_header)); |
| 1372 | } else { |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1373 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1374 | *edid_corrupt = true; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1375 | goto bad; |
| 1376 | } |
| 1377 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1378 | |
Stefan Brüns | c465bbc | 2014-11-30 19:57:43 +0100 | [diff] [blame] | 1379 | csum = drm_edid_block_checksum(raw_edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1380 | if (csum) { |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1381 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1382 | *edid_corrupt = true; |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1383 | |
Adam Jackson | 4a638b4 | 2010-05-25 16:33:09 -0400 | [diff] [blame] | 1384 | /* allow CEA to slide through, switches mangle this */ |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1385 | if (raw_edid[0] == CEA_EXT) { |
| 1386 | DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum); |
| 1387 | DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n"); |
| 1388 | } else { |
| 1389 | if (print_bad_edid) |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1390 | DRM_NOTE("EDID checksum is invalid, remainder is %d\n", csum); |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1391 | |
Adam Jackson | 4a638b4 | 2010-05-25 16:33:09 -0400 | [diff] [blame] | 1392 | goto bad; |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1393 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1394 | } |
| 1395 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1396 | /* per-block-type checks */ |
| 1397 | switch (raw_edid[0]) { |
| 1398 | case 0: /* base */ |
| 1399 | if (edid->version != 1) { |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1400 | DRM_NOTE("EDID has major version %d, instead of 1\n", edid->version); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1401 | goto bad; |
| 1402 | } |
Adam Jackson | 862b89c | 2009-11-23 14:23:06 -0500 | [diff] [blame] | 1403 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1404 | if (edid->revision > 4) |
| 1405 | DRM_DEBUG("EDID minor > 4, assuming backward compatibility\n"); |
| 1406 | break; |
| 1407 | |
| 1408 | default: |
| 1409 | break; |
| 1410 | } |
Adam Jackson | 47ee4ccf | 2009-11-23 14:23:05 -0500 | [diff] [blame] | 1411 | |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1412 | return true; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1413 | |
| 1414 | bad: |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1415 | if (print_bad_edid) { |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1416 | if (drm_edid_is_zero(raw_edid, EDID_LENGTH)) { |
Joe Perches | 499447d | 2017-02-28 04:55:53 -0800 | [diff] [blame] | 1417 | pr_notice("EDID block is all zeroes\n"); |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1418 | } else { |
Joe Perches | 499447d | 2017-02-28 04:55:53 -0800 | [diff] [blame] | 1419 | pr_notice("Raw EDID:\n"); |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1420 | print_hex_dump(KERN_NOTICE, |
| 1421 | " \t", DUMP_PREFIX_NONE, 16, 1, |
| 1422 | raw_edid, EDID_LENGTH, false); |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1423 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1424 | } |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1425 | return false; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1426 | } |
Carsten Emde | da0df92 | 2012-03-18 22:37:33 +0100 | [diff] [blame] | 1427 | EXPORT_SYMBOL(drm_edid_block_valid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1428 | |
| 1429 | /** |
| 1430 | * drm_edid_is_valid - sanity check EDID data |
| 1431 | * @edid: EDID data |
| 1432 | * |
| 1433 | * Sanity-check an entire EDID record (including extensions) |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1434 | * |
| 1435 | * Return: True if the EDID data is valid, false otherwise. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1436 | */ |
| 1437 | bool drm_edid_is_valid(struct edid *edid) |
| 1438 | { |
| 1439 | int i; |
| 1440 | u8 *raw = (u8 *)edid; |
| 1441 | |
| 1442 | if (!edid) |
| 1443 | return false; |
| 1444 | |
| 1445 | for (i = 0; i <= edid->extensions; i++) |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1446 | if (!drm_edid_block_valid(raw + i * EDID_LENGTH, i, true, NULL)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1447 | return false; |
| 1448 | |
| 1449 | return true; |
| 1450 | } |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 1451 | EXPORT_SYMBOL(drm_edid_is_valid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1452 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1453 | #define DDC_SEGMENT_ADDR 0x30 |
| 1454 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1455 | * drm_do_probe_ddc_edid() - get EDID information via I2C |
Thierry Reding | 7c58e87 | 2014-12-03 16:52:18 +0100 | [diff] [blame] | 1456 | * @data: I2C device adapter |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 1457 | * @buf: EDID data buffer to be filled |
| 1458 | * @block: 128 byte EDID block to start fetching from |
| 1459 | * @len: EDID data buffer length to fetch |
| 1460 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1461 | * Try to fetch EDID information by calling I2C driver functions. |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 1462 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1463 | * Return: 0 on success or -1 on failure. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1464 | */ |
| 1465 | static int |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1466 | drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1467 | { |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1468 | struct i2c_adapter *adapter = data; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1469 | unsigned char start = block * EDID_LENGTH; |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1470 | unsigned char segment = block >> 1; |
| 1471 | unsigned char xfers = segment ? 3 : 2; |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1472 | int ret, retries = 5; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1473 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1474 | /* |
| 1475 | * The core I2C driver will automatically retry the transfer if the |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1476 | * adapter reports EAGAIN. However, we find that bit-banging transfers |
| 1477 | * are susceptible to errors under a heavily loaded machine and |
| 1478 | * generate spurious NAKs and timeouts. Retrying the transfer |
| 1479 | * of the individual block a few times seems to overcome this. |
| 1480 | */ |
| 1481 | do { |
| 1482 | struct i2c_msg msgs[] = { |
| 1483 | { |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1484 | .addr = DDC_SEGMENT_ADDR, |
| 1485 | .flags = 0, |
| 1486 | .len = 1, |
| 1487 | .buf = &segment, |
| 1488 | }, { |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1489 | .addr = DDC_ADDR, |
| 1490 | .flags = 0, |
| 1491 | .len = 1, |
| 1492 | .buf = &start, |
| 1493 | }, { |
| 1494 | .addr = DDC_ADDR, |
| 1495 | .flags = I2C_M_RD, |
| 1496 | .len = len, |
| 1497 | .buf = buf, |
| 1498 | } |
| 1499 | }; |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1500 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1501 | /* |
| 1502 | * Avoid sending the segment addr to not upset non-compliant |
| 1503 | * DDC monitors. |
| 1504 | */ |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1505 | ret = i2c_transfer(adapter, &msgs[3 - xfers], xfers); |
| 1506 | |
Eugeni Dodonov | 9292f37 | 2012-01-05 09:34:28 -0200 | [diff] [blame] | 1507 | if (ret == -ENXIO) { |
| 1508 | DRM_DEBUG_KMS("drm: skipping non-existent adapter %s\n", |
| 1509 | adapter->name); |
| 1510 | break; |
| 1511 | } |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1512 | } while (ret != xfers && --retries); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1513 | |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1514 | return ret == xfers ? 0 : -1; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1515 | } |
| 1516 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1517 | static void connector_bad_edid(struct drm_connector *connector, |
| 1518 | u8 *edid, int num_blocks) |
| 1519 | { |
| 1520 | int i; |
| 1521 | |
| 1522 | if (connector->bad_edid_counter++ && !(drm_debug & DRM_UT_KMS)) |
| 1523 | return; |
| 1524 | |
| 1525 | dev_warn(connector->dev->dev, |
| 1526 | "%s: EDID is invalid:\n", |
| 1527 | connector->name); |
| 1528 | for (i = 0; i < num_blocks; i++) { |
| 1529 | u8 *block = edid + i * EDID_LENGTH; |
| 1530 | char prefix[20]; |
| 1531 | |
| 1532 | if (drm_edid_is_zero(block, EDID_LENGTH)) |
| 1533 | sprintf(prefix, "\t[%02x] ZERO ", i); |
| 1534 | else if (!drm_edid_block_valid(block, i, false, NULL)) |
| 1535 | sprintf(prefix, "\t[%02x] BAD ", i); |
| 1536 | else |
| 1537 | sprintf(prefix, "\t[%02x] GOOD ", i); |
| 1538 | |
| 1539 | print_hex_dump(KERN_WARNING, |
| 1540 | prefix, DUMP_PREFIX_NONE, 16, 1, |
| 1541 | block, EDID_LENGTH, false); |
| 1542 | } |
| 1543 | } |
| 1544 | |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1545 | /** |
| 1546 | * drm_do_get_edid - get EDID data using a custom EDID block read function |
| 1547 | * @connector: connector we're probing |
| 1548 | * @get_edid_block: EDID block read function |
| 1549 | * @data: private data passed to the block read function |
| 1550 | * |
| 1551 | * When the I2C adapter connected to the DDC bus is hidden behind a device that |
| 1552 | * exposes a different interface to read EDID blocks this function can be used |
| 1553 | * to get EDID data using a custom block read function. |
| 1554 | * |
| 1555 | * As in the general case the DDC bus is accessible by the kernel at the I2C |
| 1556 | * level, drivers must make all reasonable efforts to expose it as an I2C |
| 1557 | * adapter and use drm_get_edid() instead of abusing this function. |
| 1558 | * |
Jani Nikula | 53fd40a | 2017-09-12 11:19:26 +0300 | [diff] [blame] | 1559 | * The EDID may be overridden using debugfs override_edid or firmare EDID |
| 1560 | * (drm_load_edid_firmware() and drm.edid_firmware parameter), in this priority |
| 1561 | * order. Having either of them bypasses actual EDID reads. |
| 1562 | * |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1563 | * Return: Pointer to valid EDID or NULL if we couldn't find any. |
| 1564 | */ |
| 1565 | struct edid *drm_do_get_edid(struct drm_connector *connector, |
| 1566 | int (*get_edid_block)(void *data, u8 *buf, unsigned int block, |
| 1567 | size_t len), |
| 1568 | void *data) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1569 | { |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1570 | int i, j = 0, valid_extensions = 0; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1571 | u8 *edid, *new; |
Jani Nikula | 53fd40a | 2017-09-12 11:19:26 +0300 | [diff] [blame] | 1572 | struct edid *override = NULL; |
| 1573 | |
| 1574 | if (connector->override_edid) |
| 1575 | override = drm_edid_duplicate((const struct edid *) |
| 1576 | connector->edid_blob_ptr->data); |
| 1577 | |
| 1578 | if (!override) |
| 1579 | override = drm_load_edid_firmware(connector); |
| 1580 | |
| 1581 | if (!IS_ERR_OR_NULL(override)) |
| 1582 | return override; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1583 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1584 | if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1585 | return NULL; |
| 1586 | |
| 1587 | /* base block fetch */ |
| 1588 | for (i = 0; i < 4; i++) { |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1589 | if (get_edid_block(data, edid, 0, EDID_LENGTH)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1590 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1591 | if (drm_edid_block_valid(edid, 0, false, |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1592 | &connector->edid_corrupt)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1593 | break; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1594 | if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1595 | connector->null_edid_counter++; |
| 1596 | goto carp; |
| 1597 | } |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1598 | } |
| 1599 | if (i == 4) |
| 1600 | goto carp; |
| 1601 | |
| 1602 | /* if there's no extensions, we're done */ |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1603 | valid_extensions = edid[0x7e]; |
| 1604 | if (valid_extensions == 0) |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1605 | return (struct edid *)edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1606 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1607 | new = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1608 | if (!new) |
| 1609 | goto out; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1610 | edid = new; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1611 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1612 | for (j = 1; j <= edid[0x7e]; j++) { |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1613 | u8 *block = edid + j * EDID_LENGTH; |
Chris Wilson | a28187c | 2016-10-17 09:35:13 +0100 | [diff] [blame] | 1614 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1615 | for (i = 0; i < 4; i++) { |
Chris Wilson | a28187c | 2016-10-17 09:35:13 +0100 | [diff] [blame] | 1616 | if (get_edid_block(data, block, j, EDID_LENGTH)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1617 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1618 | if (drm_edid_block_valid(block, j, false, NULL)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1619 | break; |
| 1620 | } |
Maarten Lankhorst | f934ec8c | 2013-01-29 14:27:39 +0100 | [diff] [blame] | 1621 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1622 | if (i == 4) |
| 1623 | valid_extensions--; |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1624 | } |
| 1625 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1626 | if (valid_extensions != edid[0x7e]) { |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1627 | u8 *base; |
| 1628 | |
| 1629 | connector_bad_edid(connector, edid, edid[0x7e] + 1); |
| 1630 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1631 | edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions; |
| 1632 | edid[0x7e] = valid_extensions; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1633 | |
| 1634 | new = kmalloc((valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1635 | if (!new) |
| 1636 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1637 | |
| 1638 | base = new; |
| 1639 | for (i = 0; i <= edid[0x7e]; i++) { |
| 1640 | u8 *block = edid + i * EDID_LENGTH; |
| 1641 | |
| 1642 | if (!drm_edid_block_valid(block, i, false, NULL)) |
| 1643 | continue; |
| 1644 | |
| 1645 | memcpy(base, block, EDID_LENGTH); |
| 1646 | base += EDID_LENGTH; |
| 1647 | } |
| 1648 | |
| 1649 | kfree(edid); |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1650 | edid = new; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1651 | } |
| 1652 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1653 | return (struct edid *)edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1654 | |
| 1655 | carp: |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1656 | connector_bad_edid(connector, edid, 1); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1657 | out: |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1658 | kfree(edid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1659 | return NULL; |
| 1660 | } |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1661 | EXPORT_SYMBOL_GPL(drm_do_get_edid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1662 | |
| 1663 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1664 | * drm_probe_ddc() - probe DDC presence |
| 1665 | * @adapter: I2C adapter to probe |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1666 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1667 | * Return: True on success, false on failure. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1668 | */ |
Adam Jackson | fbff469 | 2012-09-18 10:58:47 -0400 | [diff] [blame] | 1669 | bool |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1670 | drm_probe_ddc(struct i2c_adapter *adapter) |
| 1671 | { |
| 1672 | unsigned char out; |
| 1673 | |
| 1674 | return (drm_do_probe_ddc_edid(adapter, &out, 0, 1) == 0); |
| 1675 | } |
Adam Jackson | fbff469 | 2012-09-18 10:58:47 -0400 | [diff] [blame] | 1676 | EXPORT_SYMBOL(drm_probe_ddc); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1677 | |
| 1678 | /** |
| 1679 | * drm_get_edid - get EDID data, if available |
| 1680 | * @connector: connector we're probing |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1681 | * @adapter: I2C adapter to use for DDC |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1682 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1683 | * Poke the given I2C channel to grab EDID data if possible. If found, |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1684 | * attach it to the connector. |
| 1685 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1686 | * Return: Pointer to valid EDID or NULL if we couldn't find any. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1687 | */ |
| 1688 | struct edid *drm_get_edid(struct drm_connector *connector, |
| 1689 | struct i2c_adapter *adapter) |
| 1690 | { |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1691 | struct edid *edid; |
| 1692 | |
Jani Nikula | 15f080f | 2017-02-17 17:20:53 +0200 | [diff] [blame] | 1693 | if (connector->force == DRM_FORCE_OFF) |
| 1694 | return NULL; |
| 1695 | |
| 1696 | if (connector->force == DRM_FORCE_UNSPECIFIED && !drm_probe_ddc(adapter)) |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1697 | return NULL; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1698 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1699 | edid = drm_do_get_edid(connector, drm_do_probe_ddc_edid, adapter); |
| 1700 | if (edid) |
| 1701 | drm_get_displayid(connector, edid); |
| 1702 | return edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1703 | } |
| 1704 | EXPORT_SYMBOL(drm_get_edid); |
| 1705 | |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1706 | /** |
Lukas Wunner | 5cb8eaa2 | 2016-01-11 20:09:20 +0100 | [diff] [blame] | 1707 | * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output |
| 1708 | * @connector: connector we're probing |
| 1709 | * @adapter: I2C adapter to use for DDC |
| 1710 | * |
| 1711 | * Wrapper around drm_get_edid() for laptops with dual GPUs using one set of |
| 1712 | * outputs. The wrapper adds the requisite vga_switcheroo calls to temporarily |
| 1713 | * switch DDC to the GPU which is retrieving EDID. |
| 1714 | * |
| 1715 | * Return: Pointer to valid EDID or %NULL if we couldn't find any. |
| 1716 | */ |
| 1717 | struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, |
| 1718 | struct i2c_adapter *adapter) |
| 1719 | { |
| 1720 | struct pci_dev *pdev = connector->dev->pdev; |
| 1721 | struct edid *edid; |
| 1722 | |
| 1723 | vga_switcheroo_lock_ddc(pdev); |
| 1724 | edid = drm_get_edid(connector, adapter); |
| 1725 | vga_switcheroo_unlock_ddc(pdev); |
| 1726 | |
| 1727 | return edid; |
| 1728 | } |
| 1729 | EXPORT_SYMBOL(drm_get_edid_switcheroo); |
| 1730 | |
| 1731 | /** |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1732 | * drm_edid_duplicate - duplicate an EDID and the extensions |
| 1733 | * @edid: EDID to duplicate |
| 1734 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1735 | * Return: Pointer to duplicated EDID or NULL on allocation failure. |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1736 | */ |
| 1737 | struct edid *drm_edid_duplicate(const struct edid *edid) |
| 1738 | { |
| 1739 | return kmemdup(edid, (edid->extensions + 1) * EDID_LENGTH, GFP_KERNEL); |
| 1740 | } |
| 1741 | EXPORT_SYMBOL(drm_edid_duplicate); |
| 1742 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1743 | /*** EDID parsing ***/ |
| 1744 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1745 | /** |
| 1746 | * edid_vendor - match a string against EDID's obfuscated vendor field |
| 1747 | * @edid: EDID to match |
| 1748 | * @vendor: vendor string |
| 1749 | * |
| 1750 | * Returns true if @vendor is in @edid, false otherwise |
| 1751 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 1752 | static bool edid_vendor(const struct edid *edid, const char *vendor) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1753 | { |
| 1754 | char edid_vendor[3]; |
| 1755 | |
| 1756 | edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@'; |
| 1757 | edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) | |
| 1758 | ((edid->mfg_id[1] & 0xe0) >> 5)) + '@'; |
Dave Airlie | 16456c8 | 2009-04-03 09:10:33 +1000 | [diff] [blame] | 1759 | edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@'; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1760 | |
| 1761 | return !strncmp(edid_vendor, vendor, 3); |
| 1762 | } |
| 1763 | |
| 1764 | /** |
| 1765 | * edid_get_quirks - return quirk flags for a given EDID |
| 1766 | * @edid: EDID to process |
| 1767 | * |
| 1768 | * This tells subsequent routines what fixes they need to apply. |
| 1769 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 1770 | static u32 edid_get_quirks(const struct edid *edid) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1771 | { |
Jani Nikula | 23c4cfb | 2016-12-28 13:06:26 +0200 | [diff] [blame] | 1772 | const struct edid_quirk *quirk; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1773 | int i; |
| 1774 | |
| 1775 | for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) { |
| 1776 | quirk = &edid_quirk_list[i]; |
| 1777 | |
| 1778 | if (edid_vendor(edid, quirk->vendor) && |
| 1779 | (EDID_PRODUCT_ID(edid) == quirk->product_id)) |
| 1780 | return quirk->quirks; |
| 1781 | } |
| 1782 | |
| 1783 | return 0; |
| 1784 | } |
| 1785 | |
| 1786 | #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay) |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1787 | #define MODE_REFRESH_DIFF(c,t) (abs((c) - (t))) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1788 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1789 | /** |
| 1790 | * edid_fixup_preferred - set preferred modes based on quirk list |
| 1791 | * @connector: has mode list to fix up |
| 1792 | * @quirks: quirks list |
| 1793 | * |
| 1794 | * Walk the mode list for @connector, clearing the preferred status |
| 1795 | * on existing modes and setting it anew for the right mode ala @quirks. |
| 1796 | */ |
| 1797 | static void edid_fixup_preferred(struct drm_connector *connector, |
| 1798 | u32 quirks) |
| 1799 | { |
| 1800 | struct drm_display_mode *t, *cur_mode, *preferred_mode; |
Dave Airlie | f890607 | 2008-12-18 16:59:02 +1000 | [diff] [blame] | 1801 | int target_refresh = 0; |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1802 | int cur_vrefresh, preferred_vrefresh; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1803 | |
| 1804 | if (list_empty(&connector->probed_modes)) |
| 1805 | return; |
| 1806 | |
| 1807 | if (quirks & EDID_QUIRK_PREFER_LARGE_60) |
| 1808 | target_refresh = 60; |
| 1809 | if (quirks & EDID_QUIRK_PREFER_LARGE_75) |
| 1810 | target_refresh = 75; |
| 1811 | |
| 1812 | preferred_mode = list_first_entry(&connector->probed_modes, |
| 1813 | struct drm_display_mode, head); |
| 1814 | |
| 1815 | list_for_each_entry_safe(cur_mode, t, &connector->probed_modes, head) { |
| 1816 | cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED; |
| 1817 | |
| 1818 | if (cur_mode == preferred_mode) |
| 1819 | continue; |
| 1820 | |
| 1821 | /* Largest mode is preferred */ |
| 1822 | if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode)) |
| 1823 | preferred_mode = cur_mode; |
| 1824 | |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1825 | cur_vrefresh = cur_mode->vrefresh ? |
| 1826 | cur_mode->vrefresh : drm_mode_vrefresh(cur_mode); |
| 1827 | preferred_vrefresh = preferred_mode->vrefresh ? |
| 1828 | preferred_mode->vrefresh : drm_mode_vrefresh(preferred_mode); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1829 | /* At a given size, try to get closest to target refresh */ |
| 1830 | if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) && |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1831 | MODE_REFRESH_DIFF(cur_vrefresh, target_refresh) < |
| 1832 | MODE_REFRESH_DIFF(preferred_vrefresh, target_refresh)) { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1833 | preferred_mode = cur_mode; |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | preferred_mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 1838 | } |
| 1839 | |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1840 | static bool |
| 1841 | mode_is_rb(const struct drm_display_mode *mode) |
| 1842 | { |
| 1843 | return (mode->htotal - mode->hdisplay == 160) && |
| 1844 | (mode->hsync_end - mode->hdisplay == 80) && |
| 1845 | (mode->hsync_end - mode->hsync_start == 32) && |
| 1846 | (mode->vsync_start - mode->vdisplay == 3); |
| 1847 | } |
| 1848 | |
Adam Jackson | 33c7531 | 2012-04-13 16:33:29 -0400 | [diff] [blame] | 1849 | /* |
| 1850 | * drm_mode_find_dmt - Create a copy of a mode if present in DMT |
| 1851 | * @dev: Device to duplicate against |
| 1852 | * @hsize: Mode width |
| 1853 | * @vsize: Mode height |
| 1854 | * @fresh: Mode refresh rate |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1855 | * @rb: Mode reduced-blanking-ness |
Adam Jackson | 33c7531 | 2012-04-13 16:33:29 -0400 | [diff] [blame] | 1856 | * |
| 1857 | * Walk the DMT mode list looking for a match for the given parameters. |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1858 | * |
| 1859 | * Return: A newly allocated copy of the mode, or NULL if not found. |
Adam Jackson | 33c7531 | 2012-04-13 16:33:29 -0400 | [diff] [blame] | 1860 | */ |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 1861 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1862 | int hsize, int vsize, int fresh, |
| 1863 | bool rb) |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1864 | { |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 1865 | int i; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1866 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1867 | for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 1868 | const struct drm_display_mode *ptr = &drm_dmt_modes[i]; |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1869 | if (hsize != ptr->hdisplay) |
| 1870 | continue; |
| 1871 | if (vsize != ptr->vdisplay) |
| 1872 | continue; |
| 1873 | if (fresh != drm_mode_vrefresh(ptr)) |
| 1874 | continue; |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1875 | if (rb != mode_is_rb(ptr)) |
| 1876 | continue; |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1877 | |
| 1878 | return drm_mode_duplicate(dev, ptr); |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1879 | } |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1880 | |
| 1881 | return NULL; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1882 | } |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 1883 | EXPORT_SYMBOL(drm_mode_find_dmt); |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 1884 | |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1885 | typedef void detailed_cb(struct detailed_timing *timing, void *closure); |
| 1886 | |
| 1887 | static void |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1888 | cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) |
| 1889 | { |
| 1890 | int i, n = 0; |
Christian Schmidt | 4966b2a | 2011-12-19 20:03:43 +0100 | [diff] [blame] | 1891 | u8 d = ext[0x02]; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1892 | u8 *det_base = ext + d; |
| 1893 | |
Christian Schmidt | 4966b2a | 2011-12-19 20:03:43 +0100 | [diff] [blame] | 1894 | n = (127 - d) / 18; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1895 | for (i = 0; i < n; i++) |
| 1896 | cb((struct detailed_timing *)(det_base + 18 * i), closure); |
| 1897 | } |
| 1898 | |
| 1899 | static void |
Adam Jackson | cbba98f | 2010-08-03 14:38:18 -0400 | [diff] [blame] | 1900 | vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) |
| 1901 | { |
| 1902 | unsigned int i, n = min((int)ext[0x02], 6); |
| 1903 | u8 *det_base = ext + 5; |
| 1904 | |
| 1905 | if (ext[0x01] != 1) |
| 1906 | return; /* unknown version */ |
| 1907 | |
| 1908 | for (i = 0; i < n; i++) |
| 1909 | cb((struct detailed_timing *)(det_base + 18 * i), closure); |
| 1910 | } |
| 1911 | |
| 1912 | static void |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1913 | drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) |
| 1914 | { |
| 1915 | int i; |
| 1916 | struct edid *edid = (struct edid *)raw_edid; |
| 1917 | |
| 1918 | if (edid == NULL) |
| 1919 | return; |
| 1920 | |
| 1921 | for (i = 0; i < EDID_DETAILED_TIMINGS; i++) |
| 1922 | cb(&(edid->detailed_timings[i]), closure); |
| 1923 | |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1924 | for (i = 1; i <= raw_edid[0x7e]; i++) { |
| 1925 | u8 *ext = raw_edid + (i * EDID_LENGTH); |
| 1926 | switch (*ext) { |
| 1927 | case CEA_EXT: |
| 1928 | cea_for_each_detailed_block(ext, cb, closure); |
| 1929 | break; |
Adam Jackson | cbba98f | 2010-08-03 14:38:18 -0400 | [diff] [blame] | 1930 | case VTB_EXT: |
| 1931 | vtb_for_each_detailed_block(ext, cb, closure); |
| 1932 | break; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1933 | default: |
| 1934 | break; |
| 1935 | } |
| 1936 | } |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1937 | } |
| 1938 | |
| 1939 | static void |
| 1940 | is_rb(struct detailed_timing *t, void *data) |
| 1941 | { |
| 1942 | u8 *r = (u8 *)t; |
| 1943 | if (r[3] == EDID_DETAIL_MONITOR_RANGE) |
| 1944 | if (r[15] & 0x10) |
| 1945 | *(bool *)data = true; |
| 1946 | } |
| 1947 | |
| 1948 | /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ |
| 1949 | static bool |
| 1950 | drm_monitor_supports_rb(struct edid *edid) |
| 1951 | { |
| 1952 | if (edid->revision >= 4) { |
Daniel Vetter | b196a49 | 2012-06-19 11:33:06 +0200 | [diff] [blame] | 1953 | bool ret = false; |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1954 | drm_for_each_detailed_block((u8 *)edid, is_rb, &ret); |
| 1955 | return ret; |
| 1956 | } |
| 1957 | |
| 1958 | return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0); |
| 1959 | } |
| 1960 | |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 1961 | static void |
| 1962 | find_gtf2(struct detailed_timing *t, void *data) |
| 1963 | { |
| 1964 | u8 *r = (u8 *)t; |
| 1965 | if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02) |
| 1966 | *(u8 **)data = r; |
| 1967 | } |
| 1968 | |
| 1969 | /* Secondary GTF curve kicks in above some break frequency */ |
| 1970 | static int |
| 1971 | drm_gtf2_hbreak(struct edid *edid) |
| 1972 | { |
| 1973 | u8 *r = NULL; |
| 1974 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 1975 | return r ? (r[12] * 2) : 0; |
| 1976 | } |
| 1977 | |
| 1978 | static int |
| 1979 | drm_gtf2_2c(struct edid *edid) |
| 1980 | { |
| 1981 | u8 *r = NULL; |
| 1982 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 1983 | return r ? r[13] : 0; |
| 1984 | } |
| 1985 | |
| 1986 | static int |
| 1987 | drm_gtf2_m(struct edid *edid) |
| 1988 | { |
| 1989 | u8 *r = NULL; |
| 1990 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 1991 | return r ? (r[15] << 8) + r[14] : 0; |
| 1992 | } |
| 1993 | |
| 1994 | static int |
| 1995 | drm_gtf2_k(struct edid *edid) |
| 1996 | { |
| 1997 | u8 *r = NULL; |
| 1998 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 1999 | return r ? r[16] : 0; |
| 2000 | } |
| 2001 | |
| 2002 | static int |
| 2003 | drm_gtf2_2j(struct edid *edid) |
| 2004 | { |
| 2005 | u8 *r = NULL; |
| 2006 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2007 | return r ? r[17] : 0; |
| 2008 | } |
| 2009 | |
| 2010 | /** |
| 2011 | * standard_timing_level - get std. timing level(CVT/GTF/DMT) |
| 2012 | * @edid: EDID block to scan |
| 2013 | */ |
| 2014 | static int standard_timing_level(struct edid *edid) |
| 2015 | { |
| 2016 | if (edid->revision >= 2) { |
| 2017 | if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) |
| 2018 | return LEVEL_CVT; |
| 2019 | if (drm_gtf2_hbreak(edid)) |
| 2020 | return LEVEL_GTF2; |
| 2021 | return LEVEL_GTF; |
| 2022 | } |
| 2023 | return LEVEL_DMT; |
| 2024 | } |
| 2025 | |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 2026 | /* |
| 2027 | * 0 is reserved. The spec says 0x01 fill for unused timings. Some old |
| 2028 | * monitors fill with ascii space (0x20) instead. |
| 2029 | */ |
| 2030 | static int |
| 2031 | bad_std_timing(u8 a, u8 b) |
| 2032 | { |
| 2033 | return (a == 0x00 && b == 0x00) || |
| 2034 | (a == 0x01 && b == 0x01) || |
| 2035 | (a == 0x20 && b == 0x20); |
| 2036 | } |
| 2037 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2038 | /** |
| 2039 | * drm_mode_std - convert standard mode info (width, height, refresh) into mode |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 2040 | * @connector: connector of for the EDID block |
| 2041 | * @edid: EDID block to scan |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2042 | * @t: standard timing params |
| 2043 | * |
| 2044 | * Take the standard timing params (in this case width, aspect, and refresh) |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2045 | * and convert them into a real mode using CVT/GTF/DMT. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2046 | */ |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2047 | static struct drm_display_mode * |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2048 | drm_mode_std(struct drm_connector *connector, struct edid *edid, |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2049 | struct std_timing *t) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2050 | { |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2051 | struct drm_device *dev = connector->dev; |
| 2052 | struct drm_display_mode *m, *mode = NULL; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2053 | int hsize, vsize; |
| 2054 | int vrefresh_rate; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2055 | unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK) |
| 2056 | >> EDID_TIMING_ASPECT_SHIFT; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2057 | unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK) |
| 2058 | >> EDID_TIMING_VFREQ_SHIFT; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2059 | int timing_level = standard_timing_level(edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2060 | |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 2061 | if (bad_std_timing(t->hsize, t->vfreq_aspect)) |
| 2062 | return NULL; |
| 2063 | |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2064 | /* According to the EDID spec, the hdisplay = hsize * 8 + 248 */ |
| 2065 | hsize = t->hsize * 8 + 248; |
| 2066 | /* vrefresh_rate = vfreq + 60 */ |
| 2067 | vrefresh_rate = vfreq + 60; |
| 2068 | /* the vdisplay is calculated based on the aspect ratio */ |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2069 | if (aspect_ratio == 0) { |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2070 | if (edid->revision < 3) |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2071 | vsize = hsize; |
| 2072 | else |
| 2073 | vsize = (hsize * 10) / 16; |
| 2074 | } else if (aspect_ratio == 1) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2075 | vsize = (hsize * 3) / 4; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2076 | else if (aspect_ratio == 2) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2077 | vsize = (hsize * 4) / 5; |
| 2078 | else |
| 2079 | vsize = (hsize * 9) / 16; |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2080 | |
| 2081 | /* HDTV hack, part 1 */ |
| 2082 | if (vrefresh_rate == 60 && |
| 2083 | ((hsize == 1360 && vsize == 765) || |
| 2084 | (hsize == 1368 && vsize == 769))) { |
| 2085 | hsize = 1366; |
| 2086 | vsize = 768; |
| 2087 | } |
| 2088 | |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2089 | /* |
| 2090 | * If this connector already has a mode for this size and refresh |
| 2091 | * rate (because it came from detailed or CVT info), use that |
| 2092 | * instead. This way we don't have to guess at interlace or |
| 2093 | * reduced blanking. |
| 2094 | */ |
Adam Jackson | 522032d | 2010-04-09 16:52:49 +0000 | [diff] [blame] | 2095 | list_for_each_entry(m, &connector->probed_modes, head) |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2096 | if (m->hdisplay == hsize && m->vdisplay == vsize && |
| 2097 | drm_mode_vrefresh(m) == vrefresh_rate) |
| 2098 | return NULL; |
| 2099 | |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2100 | /* HDTV hack, part 2 */ |
| 2101 | if (hsize == 1366 && vsize == 768 && vrefresh_rate == 60) { |
| 2102 | mode = drm_cvt_mode(dev, 1366, 768, vrefresh_rate, 0, 0, |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 2103 | false); |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2104 | mode->hdisplay = 1366; |
Adam Jackson | a4967de6 | 2010-07-28 07:40:32 +1000 | [diff] [blame] | 2105 | mode->hsync_start = mode->hsync_start - 1; |
| 2106 | mode->hsync_end = mode->hsync_end - 1; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2107 | return mode; |
| 2108 | } |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2109 | |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2110 | /* check whether it can be found in default mode table */ |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2111 | if (drm_monitor_supports_rb(edid)) { |
| 2112 | mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, |
| 2113 | true); |
| 2114 | if (mode) |
| 2115 | return mode; |
| 2116 | } |
| 2117 | mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, false); |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2118 | if (mode) |
| 2119 | return mode; |
| 2120 | |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2121 | /* okay, generate it */ |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2122 | switch (timing_level) { |
| 2123 | case LEVEL_DMT: |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2124 | break; |
| 2125 | case LEVEL_GTF: |
| 2126 | mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); |
| 2127 | break; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2128 | case LEVEL_GTF2: |
| 2129 | /* |
| 2130 | * This is potentially wrong if there's ever a monitor with |
| 2131 | * more than one ranges section, each claiming a different |
| 2132 | * secondary GTF curve. Please don't do that. |
| 2133 | */ |
| 2134 | mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); |
Takashi Iwai | fc48f16 | 2012-04-20 12:59:33 +0100 | [diff] [blame] | 2135 | if (!mode) |
| 2136 | return NULL; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2137 | if (drm_mode_hsync(mode) > drm_gtf2_hbreak(edid)) { |
Sascha Hauer | aefd330 | 2012-02-01 11:38:21 +0100 | [diff] [blame] | 2138 | drm_mode_destroy(dev, mode); |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2139 | mode = drm_gtf_mode_complex(dev, hsize, vsize, |
| 2140 | vrefresh_rate, 0, 0, |
| 2141 | drm_gtf2_m(edid), |
| 2142 | drm_gtf2_2c(edid), |
| 2143 | drm_gtf2_k(edid), |
| 2144 | drm_gtf2_2j(edid)); |
| 2145 | } |
| 2146 | break; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2147 | case LEVEL_CVT: |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 2148 | mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0, |
| 2149 | false); |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2150 | break; |
| 2151 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2152 | return mode; |
| 2153 | } |
| 2154 | |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2155 | /* |
| 2156 | * EDID is delightfully ambiguous about how interlaced modes are to be |
| 2157 | * encoded. Our internal representation is of frame height, but some |
| 2158 | * HDTV detailed timings are encoded as field height. |
| 2159 | * |
| 2160 | * The format list here is from CEA, in frame size. Technically we |
| 2161 | * should be checking refresh rate too. Whatever. |
| 2162 | */ |
| 2163 | static void |
| 2164 | drm_mode_do_interlace_quirk(struct drm_display_mode *mode, |
| 2165 | struct detailed_pixel_timing *pt) |
| 2166 | { |
| 2167 | int i; |
| 2168 | static const struct { |
| 2169 | int w, h; |
| 2170 | } cea_interlaced[] = { |
| 2171 | { 1920, 1080 }, |
| 2172 | { 720, 480 }, |
| 2173 | { 1440, 480 }, |
| 2174 | { 2880, 480 }, |
| 2175 | { 720, 576 }, |
| 2176 | { 1440, 576 }, |
| 2177 | { 2880, 576 }, |
| 2178 | }; |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2179 | |
| 2180 | if (!(pt->misc & DRM_EDID_PT_INTERLACED)) |
| 2181 | return; |
| 2182 | |
Kulikov Vasiliy | 3c58141 | 2010-06-28 15:54:52 +0400 | [diff] [blame] | 2183 | for (i = 0; i < ARRAY_SIZE(cea_interlaced); i++) { |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2184 | if ((mode->hdisplay == cea_interlaced[i].w) && |
| 2185 | (mode->vdisplay == cea_interlaced[i].h / 2)) { |
| 2186 | mode->vdisplay *= 2; |
| 2187 | mode->vsync_start *= 2; |
| 2188 | mode->vsync_end *= 2; |
| 2189 | mode->vtotal *= 2; |
| 2190 | mode->vtotal |= 1; |
| 2191 | } |
| 2192 | } |
| 2193 | |
| 2194 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
| 2195 | } |
| 2196 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2197 | /** |
| 2198 | * drm_mode_detailed - create a new mode from an EDID detailed timing section |
| 2199 | * @dev: DRM device (needed to create new mode) |
| 2200 | * @edid: EDID block |
| 2201 | * @timing: EDID detailed timing info |
| 2202 | * @quirks: quirks to apply |
| 2203 | * |
| 2204 | * An EDID detailed timing block contains enough info for us to create and |
| 2205 | * return a new struct drm_display_mode. |
| 2206 | */ |
| 2207 | static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, |
| 2208 | struct edid *edid, |
| 2209 | struct detailed_timing *timing, |
| 2210 | u32 quirks) |
| 2211 | { |
| 2212 | struct drm_display_mode *mode; |
| 2213 | struct detailed_pixel_timing *pt = &timing->data.pixel_data; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2214 | unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo; |
| 2215 | unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo; |
| 2216 | unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo; |
| 2217 | unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo; |
Michel Dänzer | e14cbee | 2009-06-23 12:36:32 +0200 | [diff] [blame] | 2218 | unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | pt->hsync_offset_lo; |
| 2219 | unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) << 4 | pt->hsync_pulse_width_lo; |
Torsten Duwe | 16dad1d | 2013-03-23 15:38:22 +0100 | [diff] [blame] | 2220 | unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) << 2 | pt->vsync_offset_pulse_width_lo >> 4; |
Michel Dänzer | e14cbee | 2009-06-23 12:36:32 +0200 | [diff] [blame] | 2221 | unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 4 | (pt->vsync_offset_pulse_width_lo & 0xf); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2222 | |
Adam Jackson | fc43896 | 2009-06-04 10:20:34 +1000 | [diff] [blame] | 2223 | /* ignore tiny modes */ |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2224 | if (hactive < 64 || vactive < 64) |
Adam Jackson | fc43896 | 2009-06-04 10:20:34 +1000 | [diff] [blame] | 2225 | return NULL; |
| 2226 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2227 | if (pt->misc & DRM_EDID_PT_STEREO) { |
Egbert Eich | c7d015f3 | 2013-06-13 21:01:19 +0200 | [diff] [blame] | 2228 | DRM_DEBUG_KMS("stereo mode not supported\n"); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2229 | return NULL; |
| 2230 | } |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2231 | if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) { |
Egbert Eich | c7d015f3 | 2013-06-13 21:01:19 +0200 | [diff] [blame] | 2232 | DRM_DEBUG_KMS("composite sync not supported\n"); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2233 | } |
| 2234 | |
Zhao Yakui | fcb4561 | 2009-10-14 09:11:25 +0800 | [diff] [blame] | 2235 | /* it is incorrect if hsync/vsync width is zero */ |
| 2236 | if (!hsync_pulse_width || !vsync_pulse_width) { |
| 2237 | DRM_DEBUG_KMS("Incorrect Detailed timing. " |
| 2238 | "Wrong Hsync/Vsync pulse width\n"); |
| 2239 | return NULL; |
| 2240 | } |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2241 | |
| 2242 | if (quirks & EDID_QUIRK_FORCE_REDUCED_BLANKING) { |
| 2243 | mode = drm_cvt_mode(dev, hactive, vactive, 60, true, false, false); |
| 2244 | if (!mode) |
| 2245 | return NULL; |
| 2246 | |
| 2247 | goto set_size; |
| 2248 | } |
| 2249 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2250 | mode = drm_mode_create(dev); |
| 2251 | if (!mode) |
| 2252 | return NULL; |
| 2253 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2254 | if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH) |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2255 | timing->pixel_clock = cpu_to_le16(1088); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2256 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2257 | mode->clock = le16_to_cpu(timing->pixel_clock) * 10; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2258 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2259 | mode->hdisplay = hactive; |
| 2260 | mode->hsync_start = mode->hdisplay + hsync_offset; |
| 2261 | mode->hsync_end = mode->hsync_start + hsync_pulse_width; |
| 2262 | mode->htotal = mode->hdisplay + hblank; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2263 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2264 | mode->vdisplay = vactive; |
| 2265 | mode->vsync_start = mode->vdisplay + vsync_offset; |
| 2266 | mode->vsync_end = mode->vsync_start + vsync_pulse_width; |
| 2267 | mode->vtotal = mode->vdisplay + vblank; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2268 | |
Jesse Barnes | 7064fef | 2009-11-05 10:12:54 -0800 | [diff] [blame] | 2269 | /* Some EDIDs have bogus h/vtotal values */ |
| 2270 | if (mode->hsync_end > mode->htotal) |
| 2271 | mode->htotal = mode->hsync_end + 1; |
| 2272 | if (mode->vsync_end > mode->vtotal) |
| 2273 | mode->vtotal = mode->vsync_end + 1; |
| 2274 | |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2275 | drm_mode_do_interlace_quirk(mode, pt); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2276 | |
| 2277 | if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) { |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2278 | pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2279 | } |
| 2280 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2281 | mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? |
| 2282 | DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; |
| 2283 | mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? |
| 2284 | DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2285 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2286 | set_size: |
Michel Dänzer | e14cbee | 2009-06-23 12:36:32 +0200 | [diff] [blame] | 2287 | mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4; |
| 2288 | mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2289 | |
| 2290 | if (quirks & EDID_QUIRK_DETAILED_IN_CM) { |
| 2291 | mode->width_mm *= 10; |
| 2292 | mode->height_mm *= 10; |
| 2293 | } |
| 2294 | |
| 2295 | if (quirks & EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { |
| 2296 | mode->width_mm = edid->width_cm * 10; |
| 2297 | mode->height_mm = edid->height_cm * 10; |
| 2298 | } |
| 2299 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2300 | mode->type = DRM_MODE_TYPE_DRIVER; |
Torsten Duwe | c19b3b0f | 2013-03-23 15:39:34 +0100 | [diff] [blame] | 2301 | mode->vrefresh = drm_mode_vrefresh(mode); |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2302 | drm_mode_set_name(mode); |
| 2303 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2304 | return mode; |
| 2305 | } |
| 2306 | |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2307 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2308 | mode_in_hsync_range(const struct drm_display_mode *mode, |
| 2309 | struct edid *edid, u8 *t) |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2310 | { |
| 2311 | int hsync, hmin, hmax; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2312 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2313 | hmin = t[7]; |
| 2314 | if (edid->revision >= 4) |
| 2315 | hmin += ((t[4] & 0x04) ? 255 : 0); |
| 2316 | hmax = t[8]; |
| 2317 | if (edid->revision >= 4) |
| 2318 | hmax += ((t[4] & 0x08) ? 255 : 0); |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2319 | hsync = drm_mode_hsync(mode); |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2320 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2321 | return (hsync <= hmax && hsync >= hmin); |
| 2322 | } |
| 2323 | |
| 2324 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2325 | mode_in_vsync_range(const struct drm_display_mode *mode, |
| 2326 | struct edid *edid, u8 *t) |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2327 | { |
| 2328 | int vsync, vmin, vmax; |
| 2329 | |
| 2330 | vmin = t[5]; |
| 2331 | if (edid->revision >= 4) |
| 2332 | vmin += ((t[4] & 0x01) ? 255 : 0); |
| 2333 | vmax = t[6]; |
| 2334 | if (edid->revision >= 4) |
| 2335 | vmax += ((t[4] & 0x02) ? 255 : 0); |
| 2336 | vsync = drm_mode_vrefresh(mode); |
| 2337 | |
| 2338 | return (vsync <= vmax && vsync >= vmin); |
| 2339 | } |
| 2340 | |
| 2341 | static u32 |
| 2342 | range_pixel_clock(struct edid *edid, u8 *t) |
| 2343 | { |
| 2344 | /* unspecified */ |
| 2345 | if (t[9] == 0 || t[9] == 255) |
| 2346 | return 0; |
| 2347 | |
| 2348 | /* 1.4 with CVT support gives us real precision, yay */ |
| 2349 | if (edid->revision >= 4 && t[10] == 0x04) |
| 2350 | return (t[9] * 10000) - ((t[12] >> 2) * 250); |
| 2351 | |
| 2352 | /* 1.3 is pathetic, so fuzz up a bit */ |
| 2353 | return t[9] * 10000 + 5001; |
| 2354 | } |
| 2355 | |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2356 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2357 | mode_in_range(const struct drm_display_mode *mode, struct edid *edid, |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2358 | struct detailed_timing *timing) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2359 | { |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2360 | u32 max_clock; |
| 2361 | u8 *t = (u8 *)timing; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2362 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2363 | if (!mode_in_hsync_range(mode, edid, t)) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2364 | return false; |
| 2365 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2366 | if (!mode_in_vsync_range(mode, edid, t)) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2367 | return false; |
| 2368 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2369 | if ((max_clock = range_pixel_clock(edid, t))) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2370 | if (mode->clock > max_clock) |
| 2371 | return false; |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2372 | |
| 2373 | /* 1.4 max horizontal check */ |
| 2374 | if (edid->revision >= 4 && t[10] == 0x04) |
| 2375 | if (t[13] && mode->hdisplay > 8 * (t[13] + (256 * (t[12]&0x3)))) |
| 2376 | return false; |
| 2377 | |
| 2378 | if (mode_is_rb(mode) && !drm_monitor_supports_rb(edid)) |
| 2379 | return false; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2380 | |
| 2381 | return true; |
| 2382 | } |
| 2383 | |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2384 | static bool valid_inferred_mode(const struct drm_connector *connector, |
| 2385 | const struct drm_display_mode *mode) |
| 2386 | { |
Ville Syrjälä | 85f8fcd | 2015-09-07 18:22:56 +0300 | [diff] [blame] | 2387 | const struct drm_display_mode *m; |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2388 | bool ok = false; |
| 2389 | |
| 2390 | list_for_each_entry(m, &connector->probed_modes, head) { |
| 2391 | if (mode->hdisplay == m->hdisplay && |
| 2392 | mode->vdisplay == m->vdisplay && |
| 2393 | drm_mode_vrefresh(mode) == drm_mode_vrefresh(m)) |
| 2394 | return false; /* duplicated */ |
| 2395 | if (mode->hdisplay <= m->hdisplay && |
| 2396 | mode->vdisplay <= m->vdisplay) |
| 2397 | ok = true; |
| 2398 | } |
| 2399 | return ok; |
| 2400 | } |
| 2401 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2402 | static int |
Adam Jackson | cd4cd3d | 2012-04-13 16:33:33 -0400 | [diff] [blame] | 2403 | drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid, |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2404 | struct detailed_timing *timing) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2405 | { |
| 2406 | int i, modes = 0; |
| 2407 | struct drm_display_mode *newmode; |
| 2408 | struct drm_device *dev = connector->dev; |
| 2409 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2410 | for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2411 | if (mode_in_range(drm_dmt_modes + i, edid, timing) && |
| 2412 | valid_inferred_mode(connector, drm_dmt_modes + i)) { |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2413 | newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]); |
| 2414 | if (newmode) { |
| 2415 | drm_mode_probed_add(connector, newmode); |
| 2416 | modes++; |
| 2417 | } |
| 2418 | } |
| 2419 | } |
| 2420 | |
| 2421 | return modes; |
| 2422 | } |
| 2423 | |
Takashi Iwai | c09dedb | 2012-04-23 17:40:33 +0100 | [diff] [blame] | 2424 | /* fix up 1366x768 mode from 1368x768; |
| 2425 | * GFT/CVT can't express 1366 width which isn't dividable by 8 |
| 2426 | */ |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2427 | void drm_mode_fixup_1366x768(struct drm_display_mode *mode) |
Takashi Iwai | c09dedb | 2012-04-23 17:40:33 +0100 | [diff] [blame] | 2428 | { |
| 2429 | if (mode->hdisplay == 1368 && mode->vdisplay == 768) { |
| 2430 | mode->hdisplay = 1366; |
| 2431 | mode->hsync_start--; |
| 2432 | mode->hsync_end--; |
| 2433 | drm_mode_set_name(mode); |
| 2434 | } |
| 2435 | } |
| 2436 | |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2437 | static int |
| 2438 | drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, |
| 2439 | struct detailed_timing *timing) |
| 2440 | { |
| 2441 | int i, modes = 0; |
| 2442 | struct drm_display_mode *newmode; |
| 2443 | struct drm_device *dev = connector->dev; |
| 2444 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2445 | for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2446 | const struct minimode *m = &extra_modes[i]; |
| 2447 | newmode = drm_gtf_mode(dev, m->w, m->h, m->r, 0, 0); |
Takashi Iwai | fc48f16 | 2012-04-20 12:59:33 +0100 | [diff] [blame] | 2448 | if (!newmode) |
| 2449 | return modes; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2450 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2451 | drm_mode_fixup_1366x768(newmode); |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2452 | if (!mode_in_range(newmode, edid, timing) || |
| 2453 | !valid_inferred_mode(connector, newmode)) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2454 | drm_mode_destroy(dev, newmode); |
| 2455 | continue; |
| 2456 | } |
| 2457 | |
| 2458 | drm_mode_probed_add(connector, newmode); |
| 2459 | modes++; |
| 2460 | } |
| 2461 | |
| 2462 | return modes; |
| 2463 | } |
| 2464 | |
| 2465 | static int |
| 2466 | drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid, |
| 2467 | struct detailed_timing *timing) |
| 2468 | { |
| 2469 | int i, modes = 0; |
| 2470 | struct drm_display_mode *newmode; |
| 2471 | struct drm_device *dev = connector->dev; |
| 2472 | bool rb = drm_monitor_supports_rb(edid); |
| 2473 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2474 | for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2475 | const struct minimode *m = &extra_modes[i]; |
| 2476 | newmode = drm_cvt_mode(dev, m->w, m->h, m->r, rb, 0, 0); |
Takashi Iwai | fc48f16 | 2012-04-20 12:59:33 +0100 | [diff] [blame] | 2477 | if (!newmode) |
| 2478 | return modes; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2479 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2480 | drm_mode_fixup_1366x768(newmode); |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2481 | if (!mode_in_range(newmode, edid, timing) || |
| 2482 | !valid_inferred_mode(connector, newmode)) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2483 | drm_mode_destroy(dev, newmode); |
| 2484 | continue; |
| 2485 | } |
| 2486 | |
| 2487 | drm_mode_probed_add(connector, newmode); |
| 2488 | modes++; |
| 2489 | } |
| 2490 | |
| 2491 | return modes; |
| 2492 | } |
| 2493 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2494 | static void |
| 2495 | do_inferred_modes(struct detailed_timing *timing, void *c) |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2496 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2497 | struct detailed_mode_closure *closure = c; |
| 2498 | struct detailed_non_pixel *data = &timing->data.other_data; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2499 | struct detailed_data_monitor_range *range = &data->data.range; |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2500 | |
Adam Jackson | cb21aaf | 2012-04-13 16:33:36 -0400 | [diff] [blame] | 2501 | if (data->type != EDID_DETAIL_MONITOR_RANGE) |
| 2502 | return; |
| 2503 | |
| 2504 | closure->modes += drm_dmt_modes_for_range(closure->connector, |
| 2505 | closure->edid, |
| 2506 | timing); |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2507 | |
| 2508 | if (!version_greater(closure->edid, 1, 1)) |
| 2509 | return; /* GTF not defined yet */ |
| 2510 | |
| 2511 | switch (range->flags) { |
| 2512 | case 0x02: /* secondary gtf, XXX could do more */ |
| 2513 | case 0x00: /* default gtf */ |
| 2514 | closure->modes += drm_gtf_modes_for_range(closure->connector, |
| 2515 | closure->edid, |
| 2516 | timing); |
| 2517 | break; |
| 2518 | case 0x04: /* cvt, only in 1.4+ */ |
| 2519 | if (!version_greater(closure->edid, 1, 3)) |
| 2520 | break; |
| 2521 | |
| 2522 | closure->modes += drm_cvt_modes_for_range(closure->connector, |
| 2523 | closure->edid, |
| 2524 | timing); |
| 2525 | break; |
| 2526 | case 0x01: /* just the ranges, no formula */ |
| 2527 | default: |
| 2528 | break; |
| 2529 | } |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2530 | } |
| 2531 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2532 | static int |
| 2533 | add_inferred_modes(struct drm_connector *connector, struct edid *edid) |
| 2534 | { |
| 2535 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2536 | .connector = connector, |
| 2537 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2538 | }; |
| 2539 | |
| 2540 | if (version_greater(edid, 1, 0)) |
| 2541 | drm_for_each_detailed_block((u8 *)edid, do_inferred_modes, |
| 2542 | &closure); |
| 2543 | |
| 2544 | return closure.modes; |
| 2545 | } |
| 2546 | |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2547 | static int |
| 2548 | drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing) |
| 2549 | { |
| 2550 | int i, j, m, modes = 0; |
| 2551 | struct drm_display_mode *mode; |
Paul Parsons | f3a32d7 | 2016-03-26 13:18:38 +0000 | [diff] [blame] | 2552 | u8 *est = ((u8 *)timing) + 6; |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2553 | |
| 2554 | for (i = 0; i < 6; i++) { |
Ville Syrjälä | 891a746 | 2013-10-14 16:44:26 +0300 | [diff] [blame] | 2555 | for (j = 7; j >= 0; j--) { |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2556 | m = (i * 8) + (7 - j); |
Linus Torvalds | aa9f56b | 2010-08-12 09:21:39 -0700 | [diff] [blame] | 2557 | if (m >= ARRAY_SIZE(est3_modes)) |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2558 | break; |
| 2559 | if (est[i] & (1 << j)) { |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 2560 | mode = drm_mode_find_dmt(connector->dev, |
| 2561 | est3_modes[m].w, |
| 2562 | est3_modes[m].h, |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2563 | est3_modes[m].r, |
| 2564 | est3_modes[m].rb); |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2565 | if (mode) { |
| 2566 | drm_mode_probed_add(connector, mode); |
| 2567 | modes++; |
| 2568 | } |
| 2569 | } |
| 2570 | } |
| 2571 | } |
| 2572 | |
| 2573 | return modes; |
| 2574 | } |
| 2575 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2576 | static void |
| 2577 | do_established_modes(struct detailed_timing *timing, void *c) |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2578 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2579 | struct detailed_mode_closure *closure = c; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2580 | struct detailed_non_pixel *data = &timing->data.other_data; |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2581 | |
| 2582 | if (data->type == EDID_DETAIL_EST_TIMINGS) |
| 2583 | closure->modes += drm_est3_modes(closure->connector, timing); |
| 2584 | } |
| 2585 | |
| 2586 | /** |
| 2587 | * add_established_modes - get est. modes from EDID and add them |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2588 | * @connector: connector to add mode(s) to |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2589 | * @edid: EDID block to scan |
| 2590 | * |
| 2591 | * Each EDID block contains a bitmap of the supported "established modes" list |
| 2592 | * (defined above). Tease them out and add them to the global modes list. |
| 2593 | */ |
| 2594 | static int |
| 2595 | add_established_modes(struct drm_connector *connector, struct edid *edid) |
| 2596 | { |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2597 | struct drm_device *dev = connector->dev; |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2598 | unsigned long est_bits = edid->established_timings.t1 | |
| 2599 | (edid->established_timings.t2 << 8) | |
| 2600 | ((edid->established_timings.mfg_rsvd & 0x80) << 9); |
| 2601 | int i, modes = 0; |
| 2602 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2603 | .connector = connector, |
| 2604 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2605 | }; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2606 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2607 | for (i = 0; i <= EDID_EST_TIMINGS; i++) { |
| 2608 | if (est_bits & (1<<i)) { |
| 2609 | struct drm_display_mode *newmode; |
| 2610 | newmode = drm_mode_duplicate(dev, &edid_est_modes[i]); |
| 2611 | if (newmode) { |
| 2612 | drm_mode_probed_add(connector, newmode); |
| 2613 | modes++; |
| 2614 | } |
| 2615 | } |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2616 | } |
| 2617 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2618 | if (version_greater(edid, 1, 0)) |
| 2619 | drm_for_each_detailed_block((u8 *)edid, |
| 2620 | do_established_modes, &closure); |
| 2621 | |
| 2622 | return modes + closure.modes; |
| 2623 | } |
| 2624 | |
| 2625 | static void |
| 2626 | do_standard_modes(struct detailed_timing *timing, void *c) |
| 2627 | { |
| 2628 | struct detailed_mode_closure *closure = c; |
| 2629 | struct detailed_non_pixel *data = &timing->data.other_data; |
| 2630 | struct drm_connector *connector = closure->connector; |
| 2631 | struct edid *edid = closure->edid; |
| 2632 | |
| 2633 | if (data->type == EDID_DETAIL_STD_MODES) { |
| 2634 | int i; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2635 | for (i = 0; i < 6; i++) { |
| 2636 | struct std_timing *std; |
| 2637 | struct drm_display_mode *newmode; |
| 2638 | |
| 2639 | std = &data->data.timings[i]; |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2640 | newmode = drm_mode_std(connector, edid, std); |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2641 | if (newmode) { |
| 2642 | drm_mode_probed_add(connector, newmode); |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2643 | closure->modes++; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2644 | } |
| 2645 | } |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2646 | } |
| 2647 | } |
| 2648 | |
| 2649 | /** |
| 2650 | * add_standard_modes - get std. modes from EDID and add them |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2651 | * @connector: connector to add mode(s) to |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2652 | * @edid: EDID block to scan |
| 2653 | * |
| 2654 | * Standard modes can be calculated using the appropriate standard (DMT, |
| 2655 | * GTF or CVT. Grab them from @edid and add them to the list. |
| 2656 | */ |
| 2657 | static int |
| 2658 | add_standard_modes(struct drm_connector *connector, struct edid *edid) |
| 2659 | { |
| 2660 | int i, modes = 0; |
| 2661 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2662 | .connector = connector, |
| 2663 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2664 | }; |
| 2665 | |
| 2666 | for (i = 0; i < EDID_STD_TIMINGS; i++) { |
| 2667 | struct drm_display_mode *newmode; |
| 2668 | |
| 2669 | newmode = drm_mode_std(connector, edid, |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2670 | &edid->standard_timings[i]); |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2671 | if (newmode) { |
| 2672 | drm_mode_probed_add(connector, newmode); |
| 2673 | modes++; |
| 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | if (version_greater(edid, 1, 0)) |
| 2678 | drm_for_each_detailed_block((u8 *)edid, do_standard_modes, |
| 2679 | &closure); |
| 2680 | |
| 2681 | /* XXX should also look for standard codes in VTB blocks */ |
| 2682 | |
| 2683 | return modes + closure.modes; |
| 2684 | } |
| 2685 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2686 | static int drm_cvt_modes(struct drm_connector *connector, |
| 2687 | struct detailed_timing *timing) |
| 2688 | { |
| 2689 | int i, j, modes = 0; |
| 2690 | struct drm_display_mode *newmode; |
| 2691 | struct drm_device *dev = connector->dev; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2692 | struct cvt_timing *cvt; |
| 2693 | const int rates[] = { 60, 85, 75, 60, 50 }; |
| 2694 | const u8 empty[3] = { 0, 0, 0 }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2695 | |
| 2696 | for (i = 0; i < 4; i++) { |
| 2697 | int uninitialized_var(width), height; |
| 2698 | cvt = &(timing->data.other_data.data.cvt[i]); |
| 2699 | |
| 2700 | if (!memcmp(cvt->code, empty, 3)) |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2701 | continue; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2702 | |
| 2703 | height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2704 | switch (cvt->code[1] & 0x0c) { |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2705 | case 0x00: |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2706 | width = height * 4 / 3; |
| 2707 | break; |
| 2708 | case 0x04: |
| 2709 | width = height * 16 / 9; |
| 2710 | break; |
| 2711 | case 0x08: |
| 2712 | width = height * 16 / 10; |
| 2713 | break; |
| 2714 | case 0x0c: |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2715 | width = height * 15 / 9; |
| 2716 | break; |
| 2717 | } |
| 2718 | |
| 2719 | for (j = 1; j < 5; j++) { |
| 2720 | if (cvt->code[2] & (1 << j)) { |
| 2721 | newmode = drm_cvt_mode(dev, width, height, |
| 2722 | rates[j], j == 0, |
| 2723 | false, false); |
| 2724 | if (newmode) { |
| 2725 | drm_mode_probed_add(connector, newmode); |
| 2726 | modes++; |
| 2727 | } |
| 2728 | } |
| 2729 | } |
| 2730 | } |
| 2731 | |
| 2732 | return modes; |
| 2733 | } |
| 2734 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2735 | static void |
| 2736 | do_cvt_mode(struct detailed_timing *timing, void *c) |
| 2737 | { |
| 2738 | struct detailed_mode_closure *closure = c; |
| 2739 | struct detailed_non_pixel *data = &timing->data.other_data; |
| 2740 | |
| 2741 | if (data->type == EDID_DETAIL_CVT_3BYTE) |
| 2742 | closure->modes += drm_cvt_modes(closure->connector, timing); |
| 2743 | } |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2744 | |
| 2745 | static int |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2746 | add_cvt_modes(struct drm_connector *connector, struct edid *edid) |
| 2747 | { |
| 2748 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2749 | .connector = connector, |
| 2750 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2751 | }; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2752 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2753 | if (version_greater(edid, 1, 2)) |
| 2754 | drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2755 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2756 | /* XXX should also look for CVT codes in VTB blocks */ |
| 2757 | |
| 2758 | return closure.modes; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2759 | } |
| 2760 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 2761 | static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode); |
| 2762 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2763 | static void |
| 2764 | do_detailed_mode(struct detailed_timing *timing, void *c) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2765 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2766 | struct detailed_mode_closure *closure = c; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2767 | struct drm_display_mode *newmode; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2768 | |
| 2769 | if (timing->pixel_clock) { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2770 | newmode = drm_mode_detailed(closure->connector->dev, |
| 2771 | closure->edid, timing, |
| 2772 | closure->quirks); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2773 | if (!newmode) |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2774 | return; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2775 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2776 | if (closure->preferred) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2777 | newmode->type |= DRM_MODE_TYPE_PREFERRED; |
| 2778 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 2779 | /* |
| 2780 | * Detailed modes are limited to 10kHz pixel clock resolution, |
| 2781 | * so fix up anything that looks like CEA/HDMI mode, but the clock |
| 2782 | * is just slightly off. |
| 2783 | */ |
| 2784 | fixup_detailed_cea_mode_clock(newmode); |
| 2785 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2786 | drm_mode_probed_add(closure->connector, newmode); |
| 2787 | closure->modes++; |
| 2788 | closure->preferred = 0; |
Zhao Yakui | 882f021 | 2009-08-26 18:20:49 +0800 | [diff] [blame] | 2789 | } |
Ma Ling | 167f3a0 | 2009-03-20 14:09:48 +0800 | [diff] [blame] | 2790 | } |
| 2791 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2792 | /* |
| 2793 | * add_detailed_modes - Add modes from detailed timings |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2794 | * @connector: attached connector |
| 2795 | * @edid: EDID block to scan |
| 2796 | * @quirks: quirks to apply |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2797 | */ |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2798 | static int |
| 2799 | add_detailed_modes(struct drm_connector *connector, struct edid *edid, |
| 2800 | u32 quirks) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2801 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2802 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2803 | .connector = connector, |
| 2804 | .edid = edid, |
| 2805 | .preferred = 1, |
| 2806 | .quirks = quirks, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2807 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2808 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2809 | if (closure.preferred && !version_greater(edid, 1, 3)) |
| 2810 | closure.preferred = |
| 2811 | (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); |
Adam Jackson | a327f6b | 2010-03-29 21:43:25 +0000 | [diff] [blame] | 2812 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2813 | drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2814 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2815 | return closure.modes; |
Zhao Yakui | 882f021 | 2009-08-26 18:20:49 +0800 | [diff] [blame] | 2816 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2817 | |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2818 | #define AUDIO_BLOCK 0x01 |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 2819 | #define VIDEO_BLOCK 0x02 |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 2820 | #define VENDOR_BLOCK 0x03 |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 2821 | #define SPEAKER_BLOCK 0x04 |
Shashank Sharma | 87563fc | 2017-07-13 21:03:10 +0530 | [diff] [blame] | 2822 | #define USE_EXTENDED_TAG 0x07 |
| 2823 | #define EXT_VIDEO_CAPABILITY_BLOCK 0x00 |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 2824 | #define EXT_VIDEO_DATA_BLOCK_420 0x0E |
| 2825 | #define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2826 | #define EDID_BASIC_AUDIO (1 << 6) |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 2827 | #define EDID_CEA_YCRCB444 (1 << 5) |
| 2828 | #define EDID_CEA_YCRCB422 (1 << 4) |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 2829 | #define EDID_CEA_VCDB_QS (1 << 6) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2830 | |
Lespiau, Damien | d4e4a31 | 2013-08-19 16:58:52 +0100 | [diff] [blame] | 2831 | /* |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2832 | * Search EDID for CEA extension block. |
| 2833 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2834 | static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2835 | { |
| 2836 | u8 *edid_ext = NULL; |
| 2837 | int i; |
| 2838 | |
| 2839 | /* No EDID or EDID extensions */ |
| 2840 | if (edid == NULL || edid->extensions == 0) |
| 2841 | return NULL; |
| 2842 | |
| 2843 | /* Find CEA extension */ |
| 2844 | for (i = 0; i < edid->extensions; i++) { |
| 2845 | edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2846 | if (edid_ext[0] == ext_id) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2847 | break; |
| 2848 | } |
| 2849 | |
| 2850 | if (i == edid->extensions) |
| 2851 | return NULL; |
| 2852 | |
| 2853 | return edid_ext; |
| 2854 | } |
| 2855 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2856 | static u8 *drm_find_cea_extension(const struct edid *edid) |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2857 | { |
| 2858 | return drm_find_edid_extension(edid, CEA_EXT); |
| 2859 | } |
| 2860 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2861 | static u8 *drm_find_displayid_extension(const struct edid *edid) |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2862 | { |
| 2863 | return drm_find_edid_extension(edid, DISPLAYID_EXT); |
| 2864 | } |
| 2865 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2866 | /* |
| 2867 | * Calculate the alternate clock for the CEA mode |
| 2868 | * (60Hz vs. 59.94Hz etc.) |
| 2869 | */ |
| 2870 | static unsigned int |
| 2871 | cea_mode_alternate_clock(const struct drm_display_mode *cea_mode) |
| 2872 | { |
| 2873 | unsigned int clock = cea_mode->clock; |
| 2874 | |
| 2875 | if (cea_mode->vrefresh % 6 != 0) |
| 2876 | return clock; |
| 2877 | |
| 2878 | /* |
| 2879 | * edid_cea_modes contains the 59.94Hz |
| 2880 | * variant for 240 and 480 line modes, |
| 2881 | * and the 60Hz variant otherwise. |
| 2882 | */ |
| 2883 | if (cea_mode->vdisplay == 240 || cea_mode->vdisplay == 480) |
Ville Syrjälä | 9afd808 | 2015-10-08 11:43:33 +0300 | [diff] [blame] | 2884 | clock = DIV_ROUND_CLOSEST(clock * 1001, 1000); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2885 | else |
Ville Syrjälä | 9afd808 | 2015-10-08 11:43:33 +0300 | [diff] [blame] | 2886 | clock = DIV_ROUND_CLOSEST(clock * 1000, 1001); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2887 | |
| 2888 | return clock; |
| 2889 | } |
| 2890 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2891 | static bool |
| 2892 | cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode) |
| 2893 | { |
| 2894 | /* |
| 2895 | * For certain VICs the spec allows the vertical |
| 2896 | * front porch to vary by one or two lines. |
| 2897 | * |
| 2898 | * cea_modes[] stores the variant with the shortest |
| 2899 | * vertical front porch. We can adjust the mode to |
| 2900 | * get the other variants by simply increasing the |
| 2901 | * vertical front porch length. |
| 2902 | */ |
| 2903 | BUILD_BUG_ON(edid_cea_modes[8].vtotal != 262 || |
| 2904 | edid_cea_modes[9].vtotal != 262 || |
| 2905 | edid_cea_modes[12].vtotal != 262 || |
| 2906 | edid_cea_modes[13].vtotal != 262 || |
| 2907 | edid_cea_modes[23].vtotal != 312 || |
| 2908 | edid_cea_modes[24].vtotal != 312 || |
| 2909 | edid_cea_modes[27].vtotal != 312 || |
| 2910 | edid_cea_modes[28].vtotal != 312); |
| 2911 | |
| 2912 | if (((vic == 8 || vic == 9 || |
| 2913 | vic == 12 || vic == 13) && mode->vtotal < 263) || |
| 2914 | ((vic == 23 || vic == 24 || |
| 2915 | vic == 27 || vic == 28) && mode->vtotal < 314)) { |
| 2916 | mode->vsync_start++; |
| 2917 | mode->vsync_end++; |
| 2918 | mode->vtotal++; |
| 2919 | |
| 2920 | return true; |
| 2921 | } |
| 2922 | |
| 2923 | return false; |
| 2924 | } |
| 2925 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2926 | static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match, |
| 2927 | unsigned int clock_tolerance) |
| 2928 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2929 | u8 vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2930 | |
| 2931 | if (!to_match->clock) |
| 2932 | return 0; |
| 2933 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2934 | for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2935 | struct drm_display_mode cea_mode = edid_cea_modes[vic]; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2936 | unsigned int clock1, clock2; |
| 2937 | |
| 2938 | /* Check both 60Hz and 59.94Hz */ |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2939 | clock1 = cea_mode.clock; |
| 2940 | clock2 = cea_mode_alternate_clock(&cea_mode); |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2941 | |
| 2942 | if (abs(to_match->clock - clock1) > clock_tolerance && |
| 2943 | abs(to_match->clock - clock2) > clock_tolerance) |
| 2944 | continue; |
| 2945 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2946 | do { |
| 2947 | if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode)) |
| 2948 | return vic; |
| 2949 | } while (cea_mode_alternate_timings(vic, &cea_mode)); |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2950 | } |
| 2951 | |
| 2952 | return 0; |
| 2953 | } |
| 2954 | |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 2955 | /** |
| 2956 | * drm_match_cea_mode - look for a CEA mode matching given mode |
| 2957 | * @to_match: display mode |
| 2958 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2959 | * Return: The CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861 |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 2960 | * mode. |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2961 | */ |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 2962 | u8 drm_match_cea_mode(const struct drm_display_mode *to_match) |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2963 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2964 | u8 vic; |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2965 | |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 2966 | if (!to_match->clock) |
| 2967 | return 0; |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2968 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2969 | for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2970 | struct drm_display_mode cea_mode = edid_cea_modes[vic]; |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 2971 | unsigned int clock1, clock2; |
| 2972 | |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 2973 | /* Check both 60Hz and 59.94Hz */ |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2974 | clock1 = cea_mode.clock; |
| 2975 | clock2 = cea_mode_alternate_clock(&cea_mode); |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 2976 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2977 | if (KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock1) && |
| 2978 | KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock2)) |
| 2979 | continue; |
| 2980 | |
| 2981 | do { |
| 2982 | if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode)) |
| 2983 | return vic; |
| 2984 | } while (cea_mode_alternate_timings(vic, &cea_mode)); |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2985 | } |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2986 | |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2987 | return 0; |
| 2988 | } |
| 2989 | EXPORT_SYMBOL(drm_match_cea_mode); |
| 2990 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2991 | static bool drm_valid_cea_vic(u8 vic) |
| 2992 | { |
| 2993 | return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes); |
| 2994 | } |
| 2995 | |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 2996 | /** |
| 2997 | * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to |
| 2998 | * the input VIC from the CEA mode list |
| 2999 | * @video_code: ID given to each of the CEA modes |
| 3000 | * |
| 3001 | * Returns picture aspect ratio |
| 3002 | */ |
| 3003 | enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code) |
| 3004 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3005 | return edid_cea_modes[video_code].picture_aspect_ratio; |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 3006 | } |
| 3007 | EXPORT_SYMBOL(drm_get_cea_aspect_ratio); |
| 3008 | |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3009 | /* |
| 3010 | * Calculate the alternate clock for HDMI modes (those from the HDMI vendor |
| 3011 | * specific block). |
| 3012 | * |
| 3013 | * It's almost like cea_mode_alternate_clock(), we just need to add an |
| 3014 | * exception for the VIC 4 mode (4096x2160@24Hz): no alternate clock for this |
| 3015 | * one. |
| 3016 | */ |
| 3017 | static unsigned int |
| 3018 | hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode) |
| 3019 | { |
| 3020 | if (hdmi_mode->vdisplay == 4096 && hdmi_mode->hdisplay == 2160) |
| 3021 | return hdmi_mode->clock; |
| 3022 | |
| 3023 | return cea_mode_alternate_clock(hdmi_mode); |
| 3024 | } |
| 3025 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3026 | static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match, |
| 3027 | unsigned int clock_tolerance) |
| 3028 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3029 | u8 vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3030 | |
| 3031 | if (!to_match->clock) |
| 3032 | return 0; |
| 3033 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3034 | for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { |
| 3035 | const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3036 | unsigned int clock1, clock2; |
| 3037 | |
| 3038 | /* Make sure to also match alternate clocks */ |
| 3039 | clock1 = hdmi_mode->clock; |
| 3040 | clock2 = hdmi_mode_alternate_clock(hdmi_mode); |
| 3041 | |
| 3042 | if (abs(to_match->clock - clock1) > clock_tolerance && |
| 3043 | abs(to_match->clock - clock2) > clock_tolerance) |
| 3044 | continue; |
| 3045 | |
| 3046 | if (drm_mode_equal_no_clocks(to_match, hdmi_mode)) |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3047 | return vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3048 | } |
| 3049 | |
| 3050 | return 0; |
| 3051 | } |
| 3052 | |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3053 | /* |
| 3054 | * drm_match_hdmi_mode - look for a HDMI mode matching given mode |
| 3055 | * @to_match: display mode |
| 3056 | * |
| 3057 | * An HDMI mode is one defined in the HDMI vendor specific block. |
| 3058 | * |
| 3059 | * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one. |
| 3060 | */ |
| 3061 | static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) |
| 3062 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3063 | u8 vic; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3064 | |
| 3065 | if (!to_match->clock) |
| 3066 | return 0; |
| 3067 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3068 | for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { |
| 3069 | const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3070 | unsigned int clock1, clock2; |
| 3071 | |
| 3072 | /* Make sure to also match alternate clocks */ |
| 3073 | clock1 = hdmi_mode->clock; |
| 3074 | clock2 = hdmi_mode_alternate_clock(hdmi_mode); |
| 3075 | |
| 3076 | if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || |
| 3077 | KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && |
Damien Lespiau | f2ecf2e3 | 2013-09-25 16:45:27 +0100 | [diff] [blame] | 3078 | drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode)) |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3079 | return vic; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3080 | } |
| 3081 | return 0; |
| 3082 | } |
| 3083 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3084 | static bool drm_valid_hdmi_vic(u8 vic) |
| 3085 | { |
| 3086 | return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes); |
| 3087 | } |
| 3088 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3089 | static int |
| 3090 | add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid) |
| 3091 | { |
| 3092 | struct drm_device *dev = connector->dev; |
| 3093 | struct drm_display_mode *mode, *tmp; |
| 3094 | LIST_HEAD(list); |
| 3095 | int modes = 0; |
| 3096 | |
| 3097 | /* Don't add CEA modes if the CEA extension block is missing */ |
| 3098 | if (!drm_find_cea_extension(edid)) |
| 3099 | return 0; |
| 3100 | |
| 3101 | /* |
| 3102 | * Go through all probed modes and create a new mode |
| 3103 | * with the alternate clock for certain CEA modes. |
| 3104 | */ |
| 3105 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3106 | const struct drm_display_mode *cea_mode = NULL; |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3107 | struct drm_display_mode *newmode; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3108 | u8 vic = drm_match_cea_mode(mode); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3109 | unsigned int clock1, clock2; |
| 3110 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3111 | if (drm_valid_cea_vic(vic)) { |
| 3112 | cea_mode = &edid_cea_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3113 | clock2 = cea_mode_alternate_clock(cea_mode); |
| 3114 | } else { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3115 | vic = drm_match_hdmi_mode(mode); |
| 3116 | if (drm_valid_hdmi_vic(vic)) { |
| 3117 | cea_mode = &edid_4k_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3118 | clock2 = hdmi_mode_alternate_clock(cea_mode); |
| 3119 | } |
| 3120 | } |
| 3121 | |
| 3122 | if (!cea_mode) |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3123 | continue; |
| 3124 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3125 | clock1 = cea_mode->clock; |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3126 | |
| 3127 | if (clock1 == clock2) |
| 3128 | continue; |
| 3129 | |
| 3130 | if (mode->clock != clock1 && mode->clock != clock2) |
| 3131 | continue; |
| 3132 | |
| 3133 | newmode = drm_mode_duplicate(dev, cea_mode); |
| 3134 | if (!newmode) |
| 3135 | continue; |
| 3136 | |
Damien Lespiau | 2713021 | 2013-09-25 16:45:28 +0100 | [diff] [blame] | 3137 | /* Carry over the stereo flags */ |
| 3138 | newmode->flags |= mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 3139 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3140 | /* |
| 3141 | * The current mode could be either variant. Make |
| 3142 | * sure to pick the "other" clock for the new mode. |
| 3143 | */ |
| 3144 | if (mode->clock != clock1) |
| 3145 | newmode->clock = clock1; |
| 3146 | else |
| 3147 | newmode->clock = clock2; |
| 3148 | |
| 3149 | list_add_tail(&newmode->head, &list); |
| 3150 | } |
| 3151 | |
| 3152 | list_for_each_entry_safe(mode, tmp, &list, head) { |
| 3153 | list_del(&mode->head); |
| 3154 | drm_mode_probed_add(connector, mode); |
| 3155 | modes++; |
| 3156 | } |
| 3157 | |
| 3158 | return modes; |
| 3159 | } |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3160 | |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 3161 | static u8 svd_to_vic(u8 svd) |
| 3162 | { |
| 3163 | /* 0-6 bit vic, 7th bit native mode indicator */ |
| 3164 | if ((svd >= 1 && svd <= 64) || (svd >= 129 && svd <= 192)) |
| 3165 | return svd & 127; |
| 3166 | |
| 3167 | return svd; |
| 3168 | } |
| 3169 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3170 | static struct drm_display_mode * |
| 3171 | drm_display_mode_from_vic_index(struct drm_connector *connector, |
| 3172 | const u8 *video_db, u8 video_len, |
| 3173 | u8 video_index) |
| 3174 | { |
| 3175 | struct drm_device *dev = connector->dev; |
| 3176 | struct drm_display_mode *newmode; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3177 | u8 vic; |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3178 | |
| 3179 | if (video_db == NULL || video_index >= video_len) |
| 3180 | return NULL; |
| 3181 | |
| 3182 | /* CEA modes are numbered 1..127 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 3183 | vic = svd_to_vic(video_db[video_index]); |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3184 | if (!drm_valid_cea_vic(vic)) |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3185 | return NULL; |
| 3186 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3187 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]); |
Damien Lespiau | 409bbf1 | 2014-03-03 23:59:07 +0000 | [diff] [blame] | 3188 | if (!newmode) |
| 3189 | return NULL; |
| 3190 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3191 | newmode->vrefresh = 0; |
| 3192 | |
| 3193 | return newmode; |
| 3194 | } |
| 3195 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3196 | /* |
| 3197 | * do_y420vdb_modes - Parse YCBCR 420 only modes |
| 3198 | * @connector: connector corresponding to the HDMI sink |
| 3199 | * @svds: start of the data block of CEA YCBCR 420 VDB |
| 3200 | * @len: length of the CEA YCBCR 420 VDB |
| 3201 | * |
| 3202 | * Parse the CEA-861-F YCBCR 420 Video Data Block (Y420VDB) |
| 3203 | * which contains modes which can be supported in YCBCR 420 |
| 3204 | * output format only. |
| 3205 | */ |
| 3206 | static int do_y420vdb_modes(struct drm_connector *connector, |
| 3207 | const u8 *svds, u8 svds_len) |
| 3208 | { |
| 3209 | int modes = 0, i; |
| 3210 | struct drm_device *dev = connector->dev; |
| 3211 | struct drm_display_info *info = &connector->display_info; |
| 3212 | struct drm_hdmi_info *hdmi = &info->hdmi; |
| 3213 | |
| 3214 | for (i = 0; i < svds_len; i++) { |
| 3215 | u8 vic = svd_to_vic(svds[i]); |
| 3216 | struct drm_display_mode *newmode; |
| 3217 | |
| 3218 | if (!drm_valid_cea_vic(vic)) |
| 3219 | continue; |
| 3220 | |
| 3221 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]); |
| 3222 | if (!newmode) |
| 3223 | break; |
| 3224 | bitmap_set(hdmi->y420_vdb_modes, vic, 1); |
| 3225 | drm_mode_probed_add(connector, newmode); |
| 3226 | modes++; |
| 3227 | } |
| 3228 | |
| 3229 | if (modes > 0) |
| 3230 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3231 | return modes; |
| 3232 | } |
| 3233 | |
| 3234 | /* |
| 3235 | * drm_add_cmdb_modes - Add a YCBCR 420 mode into bitmap |
| 3236 | * @connector: connector corresponding to the HDMI sink |
| 3237 | * @vic: CEA vic for the video mode to be added in the map |
| 3238 | * |
| 3239 | * Makes an entry for a videomode in the YCBCR 420 bitmap |
| 3240 | */ |
| 3241 | static void |
| 3242 | drm_add_cmdb_modes(struct drm_connector *connector, u8 svd) |
| 3243 | { |
| 3244 | u8 vic = svd_to_vic(svd); |
| 3245 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
| 3246 | |
| 3247 | if (!drm_valid_cea_vic(vic)) |
| 3248 | return; |
| 3249 | |
| 3250 | bitmap_set(hdmi->y420_cmdb_modes, vic, 1); |
| 3251 | } |
| 3252 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3253 | static int |
Lespiau, Damien | 13ac3f5 | 2013-08-19 16:58:53 +0100 | [diff] [blame] | 3254 | do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len) |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3255 | { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3256 | int i, modes = 0; |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3257 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3258 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3259 | for (i = 0; i < len; i++) { |
| 3260 | struct drm_display_mode *mode; |
| 3261 | mode = drm_display_mode_from_vic_index(connector, db, len, i); |
| 3262 | if (mode) { |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3263 | /* |
| 3264 | * YCBCR420 capability block contains a bitmap which |
| 3265 | * gives the index of CEA modes from CEA VDB, which |
| 3266 | * can support YCBCR 420 sampling output also (apart |
| 3267 | * from RGB/YCBCR444 etc). |
| 3268 | * For example, if the bit 0 in bitmap is set, |
| 3269 | * first mode in VDB can support YCBCR420 output too. |
| 3270 | * Add YCBCR420 modes only if sink is HDMI 2.0 capable. |
| 3271 | */ |
| 3272 | if (i < 64 && hdmi->y420_cmdb_map & (1ULL << i)) |
| 3273 | drm_add_cmdb_modes(connector, db[i]); |
| 3274 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3275 | drm_mode_probed_add(connector, mode); |
| 3276 | modes++; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3277 | } |
| 3278 | } |
| 3279 | |
| 3280 | return modes; |
| 3281 | } |
| 3282 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3283 | struct stereo_mandatory_mode { |
| 3284 | int width, height, vrefresh; |
| 3285 | unsigned int flags; |
| 3286 | }; |
| 3287 | |
| 3288 | static const struct stereo_mandatory_mode stereo_mandatory_modes[] = { |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3289 | { 1920, 1080, 24, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3290 | { 1920, 1080, 24, DRM_MODE_FLAG_3D_FRAME_PACKING }, |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3291 | { 1920, 1080, 50, |
| 3292 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, |
| 3293 | { 1920, 1080, 60, |
| 3294 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3295 | { 1280, 720, 50, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3296 | { 1280, 720, 50, DRM_MODE_FLAG_3D_FRAME_PACKING }, |
| 3297 | { 1280, 720, 60, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3298 | { 1280, 720, 60, DRM_MODE_FLAG_3D_FRAME_PACKING } |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3299 | }; |
| 3300 | |
| 3301 | static bool |
| 3302 | stereo_match_mandatory(const struct drm_display_mode *mode, |
| 3303 | const struct stereo_mandatory_mode *stereo_mode) |
| 3304 | { |
| 3305 | unsigned int interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; |
| 3306 | |
| 3307 | return mode->hdisplay == stereo_mode->width && |
| 3308 | mode->vdisplay == stereo_mode->height && |
| 3309 | interlaced == (stereo_mode->flags & DRM_MODE_FLAG_INTERLACE) && |
| 3310 | drm_mode_vrefresh(mode) == stereo_mode->vrefresh; |
| 3311 | } |
| 3312 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3313 | static int add_hdmi_mandatory_stereo_modes(struct drm_connector *connector) |
| 3314 | { |
| 3315 | struct drm_device *dev = connector->dev; |
| 3316 | const struct drm_display_mode *mode; |
| 3317 | struct list_head stereo_modes; |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3318 | int modes = 0, i; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3319 | |
| 3320 | INIT_LIST_HEAD(&stereo_modes); |
| 3321 | |
| 3322 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3323 | for (i = 0; i < ARRAY_SIZE(stereo_mandatory_modes); i++) { |
| 3324 | const struct stereo_mandatory_mode *mandatory; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3325 | struct drm_display_mode *new_mode; |
| 3326 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3327 | if (!stereo_match_mandatory(mode, |
| 3328 | &stereo_mandatory_modes[i])) |
| 3329 | continue; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3330 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3331 | mandatory = &stereo_mandatory_modes[i]; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3332 | new_mode = drm_mode_duplicate(dev, mode); |
| 3333 | if (!new_mode) |
| 3334 | continue; |
| 3335 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3336 | new_mode->flags |= mandatory->flags; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3337 | list_add_tail(&new_mode->head, &stereo_modes); |
| 3338 | modes++; |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3339 | } |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3340 | } |
| 3341 | |
| 3342 | list_splice_tail(&stereo_modes, &connector->probed_modes); |
| 3343 | |
| 3344 | return modes; |
| 3345 | } |
| 3346 | |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3347 | static int add_hdmi_mode(struct drm_connector *connector, u8 vic) |
| 3348 | { |
| 3349 | struct drm_device *dev = connector->dev; |
| 3350 | struct drm_display_mode *newmode; |
| 3351 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3352 | if (!drm_valid_hdmi_vic(vic)) { |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3353 | DRM_ERROR("Unknown HDMI VIC: %d\n", vic); |
| 3354 | return 0; |
| 3355 | } |
| 3356 | |
| 3357 | newmode = drm_mode_duplicate(dev, &edid_4k_modes[vic]); |
| 3358 | if (!newmode) |
| 3359 | return 0; |
| 3360 | |
| 3361 | drm_mode_probed_add(connector, newmode); |
| 3362 | |
| 3363 | return 1; |
| 3364 | } |
| 3365 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3366 | static int add_3d_struct_modes(struct drm_connector *connector, u16 structure, |
| 3367 | const u8 *video_db, u8 video_len, u8 video_index) |
| 3368 | { |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3369 | struct drm_display_mode *newmode; |
| 3370 | int modes = 0; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3371 | |
| 3372 | if (structure & (1 << 0)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3373 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3374 | video_len, |
| 3375 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3376 | if (newmode) { |
| 3377 | newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING; |
| 3378 | drm_mode_probed_add(connector, newmode); |
| 3379 | modes++; |
| 3380 | } |
| 3381 | } |
| 3382 | if (structure & (1 << 6)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3383 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3384 | video_len, |
| 3385 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3386 | if (newmode) { |
| 3387 | newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; |
| 3388 | drm_mode_probed_add(connector, newmode); |
| 3389 | modes++; |
| 3390 | } |
| 3391 | } |
| 3392 | if (structure & (1 << 8)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3393 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3394 | video_len, |
| 3395 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3396 | if (newmode) { |
Thomas Wood | 89570ee | 2013-11-28 15:35:04 +0000 | [diff] [blame] | 3397 | newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3398 | drm_mode_probed_add(connector, newmode); |
| 3399 | modes++; |
| 3400 | } |
| 3401 | } |
| 3402 | |
| 3403 | return modes; |
| 3404 | } |
| 3405 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3406 | /* |
| 3407 | * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block |
| 3408 | * @connector: connector corresponding to the HDMI sink |
| 3409 | * @db: start of the CEA vendor specific block |
| 3410 | * @len: length of the CEA block payload, ie. one can access up to db[len] |
| 3411 | * |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3412 | * Parses the HDMI VSDB looking for modes to add to @connector. This function |
| 3413 | * also adds the stereo 3d modes when applicable. |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3414 | */ |
| 3415 | static int |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3416 | do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len, |
| 3417 | const u8 *video_db, u8 video_len) |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3418 | { |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 3419 | struct drm_display_info *info = &connector->display_info; |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3420 | int modes = 0, offset = 0, i, multi_present = 0, multi_len; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3421 | u8 vic_len, hdmi_3d_len = 0; |
| 3422 | u16 mask; |
| 3423 | u16 structure_all; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3424 | |
| 3425 | if (len < 8) |
| 3426 | goto out; |
| 3427 | |
| 3428 | /* no HDMI_Video_Present */ |
| 3429 | if (!(db[8] & (1 << 5))) |
| 3430 | goto out; |
| 3431 | |
| 3432 | /* Latency_Fields_Present */ |
| 3433 | if (db[8] & (1 << 7)) |
| 3434 | offset += 2; |
| 3435 | |
| 3436 | /* I_Latency_Fields_Present */ |
| 3437 | if (db[8] & (1 << 6)) |
| 3438 | offset += 2; |
| 3439 | |
| 3440 | /* the declared length is not long enough for the 2 first bytes |
| 3441 | * of additional video format capabilities */ |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3442 | if (len < (8 + offset + 2)) |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3443 | goto out; |
| 3444 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3445 | /* 3D_Present */ |
| 3446 | offset++; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3447 | if (db[8 + offset] & (1 << 7)) { |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3448 | modes += add_hdmi_mandatory_stereo_modes(connector); |
| 3449 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3450 | /* 3D_Multi_present */ |
| 3451 | multi_present = (db[8 + offset] & 0x60) >> 5; |
| 3452 | } |
| 3453 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3454 | offset++; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3455 | vic_len = db[8 + offset] >> 5; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3456 | hdmi_3d_len = db[8 + offset] & 0x1f; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3457 | |
| 3458 | for (i = 0; i < vic_len && len >= (9 + offset + i); i++) { |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3459 | u8 vic; |
| 3460 | |
| 3461 | vic = db[9 + offset + i]; |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3462 | modes += add_hdmi_mode(connector, vic); |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3463 | } |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3464 | offset += 1 + vic_len; |
| 3465 | |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3466 | if (multi_present == 1) |
| 3467 | multi_len = 2; |
| 3468 | else if (multi_present == 2) |
| 3469 | multi_len = 4; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3470 | else |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3471 | multi_len = 0; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3472 | |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3473 | if (len < (8 + offset + hdmi_3d_len - 1)) |
| 3474 | goto out; |
| 3475 | |
| 3476 | if (hdmi_3d_len < multi_len) |
| 3477 | goto out; |
| 3478 | |
| 3479 | if (multi_present == 1 || multi_present == 2) { |
| 3480 | /* 3D_Structure_ALL */ |
| 3481 | structure_all = (db[8 + offset] << 8) | db[9 + offset]; |
| 3482 | |
| 3483 | /* check if 3D_MASK is present */ |
| 3484 | if (multi_present == 2) |
| 3485 | mask = (db[10 + offset] << 8) | db[11 + offset]; |
| 3486 | else |
| 3487 | mask = 0xffff; |
| 3488 | |
| 3489 | for (i = 0; i < 16; i++) { |
| 3490 | if (mask & (1 << i)) |
| 3491 | modes += add_3d_struct_modes(connector, |
| 3492 | structure_all, |
| 3493 | video_db, |
| 3494 | video_len, i); |
| 3495 | } |
| 3496 | } |
| 3497 | |
| 3498 | offset += multi_len; |
| 3499 | |
| 3500 | for (i = 0; i < (hdmi_3d_len - multi_len); i++) { |
| 3501 | int vic_index; |
| 3502 | struct drm_display_mode *newmode = NULL; |
| 3503 | unsigned int newflag = 0; |
| 3504 | bool detail_present; |
| 3505 | |
| 3506 | detail_present = ((db[8 + offset + i] & 0x0f) > 7); |
| 3507 | |
| 3508 | if (detail_present && (i + 1 == hdmi_3d_len - multi_len)) |
| 3509 | break; |
| 3510 | |
| 3511 | /* 2D_VIC_order_X */ |
| 3512 | vic_index = db[8 + offset + i] >> 4; |
| 3513 | |
| 3514 | /* 3D_Structure_X */ |
| 3515 | switch (db[8 + offset + i] & 0x0f) { |
| 3516 | case 0: |
| 3517 | newflag = DRM_MODE_FLAG_3D_FRAME_PACKING; |
| 3518 | break; |
| 3519 | case 6: |
| 3520 | newflag = DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; |
| 3521 | break; |
| 3522 | case 8: |
| 3523 | /* 3D_Detail_X */ |
| 3524 | if ((db[9 + offset + i] >> 4) == 1) |
| 3525 | newflag = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; |
| 3526 | break; |
| 3527 | } |
| 3528 | |
| 3529 | if (newflag != 0) { |
| 3530 | newmode = drm_display_mode_from_vic_index(connector, |
| 3531 | video_db, |
| 3532 | video_len, |
| 3533 | vic_index); |
| 3534 | |
| 3535 | if (newmode) { |
| 3536 | newmode->flags |= newflag; |
| 3537 | drm_mode_probed_add(connector, newmode); |
| 3538 | modes++; |
| 3539 | } |
| 3540 | } |
| 3541 | |
| 3542 | if (detail_present) |
| 3543 | i++; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3544 | } |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3545 | |
| 3546 | out: |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 3547 | if (modes > 0) |
| 3548 | info->has_hdmi_infoframe = true; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3549 | return modes; |
| 3550 | } |
| 3551 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3552 | static int |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3553 | cea_db_payload_len(const u8 *db) |
| 3554 | { |
| 3555 | return db[0] & 0x1f; |
| 3556 | } |
| 3557 | |
| 3558 | static int |
Shashank Sharma | 87563fc | 2017-07-13 21:03:10 +0530 | [diff] [blame] | 3559 | cea_db_extended_tag(const u8 *db) |
| 3560 | { |
| 3561 | return db[1]; |
| 3562 | } |
| 3563 | |
| 3564 | static int |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3565 | cea_db_tag(const u8 *db) |
| 3566 | { |
| 3567 | return db[0] >> 5; |
| 3568 | } |
| 3569 | |
| 3570 | static int |
| 3571 | cea_revision(const u8 *cea) |
| 3572 | { |
| 3573 | return cea[1]; |
| 3574 | } |
| 3575 | |
| 3576 | static int |
| 3577 | cea_db_offsets(const u8 *cea, int *start, int *end) |
| 3578 | { |
| 3579 | /* Data block offset in CEA extension block */ |
| 3580 | *start = 4; |
| 3581 | *end = cea[2]; |
| 3582 | if (*end == 0) |
| 3583 | *end = 127; |
| 3584 | if (*end < 4 || *end > 127) |
| 3585 | return -ERANGE; |
| 3586 | return 0; |
| 3587 | } |
| 3588 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3589 | static bool cea_db_is_hdmi_vsdb(const u8 *db) |
| 3590 | { |
| 3591 | int hdmi_id; |
| 3592 | |
| 3593 | if (cea_db_tag(db) != VENDOR_BLOCK) |
| 3594 | return false; |
| 3595 | |
| 3596 | if (cea_db_payload_len(db) < 5) |
| 3597 | return false; |
| 3598 | |
| 3599 | hdmi_id = db[1] | (db[2] << 8) | (db[3] << 16); |
| 3600 | |
Lespiau, Damien | 6cb3b7f | 2013-08-19 16:59:05 +0100 | [diff] [blame] | 3601 | return hdmi_id == HDMI_IEEE_OUI; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3602 | } |
| 3603 | |
Thierry Reding | 50dd1bd | 2017-03-13 16:54:00 +0530 | [diff] [blame] | 3604 | static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) |
| 3605 | { |
| 3606 | unsigned int oui; |
| 3607 | |
| 3608 | if (cea_db_tag(db) != VENDOR_BLOCK) |
| 3609 | return false; |
| 3610 | |
| 3611 | if (cea_db_payload_len(db) < 7) |
| 3612 | return false; |
| 3613 | |
| 3614 | oui = db[3] << 16 | db[2] << 8 | db[1]; |
| 3615 | |
| 3616 | return oui == HDMI_FORUM_IEEE_OUI; |
| 3617 | } |
| 3618 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3619 | static bool cea_db_is_y420cmdb(const u8 *db) |
| 3620 | { |
| 3621 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3622 | return false; |
| 3623 | |
| 3624 | if (!cea_db_payload_len(db)) |
| 3625 | return false; |
| 3626 | |
| 3627 | if (cea_db_extended_tag(db) != EXT_VIDEO_CAP_BLOCK_Y420CMDB) |
| 3628 | return false; |
| 3629 | |
| 3630 | return true; |
| 3631 | } |
| 3632 | |
| 3633 | static bool cea_db_is_y420vdb(const u8 *db) |
| 3634 | { |
| 3635 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3636 | return false; |
| 3637 | |
| 3638 | if (!cea_db_payload_len(db)) |
| 3639 | return false; |
| 3640 | |
| 3641 | if (cea_db_extended_tag(db) != EXT_VIDEO_DATA_BLOCK_420) |
| 3642 | return false; |
| 3643 | |
| 3644 | return true; |
| 3645 | } |
| 3646 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3647 | #define for_each_cea_db(cea, i, start, end) \ |
| 3648 | for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1) |
| 3649 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3650 | static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, |
| 3651 | const u8 *db) |
| 3652 | { |
| 3653 | struct drm_display_info *info = &connector->display_info; |
| 3654 | struct drm_hdmi_info *hdmi = &info->hdmi; |
| 3655 | u8 map_len = cea_db_payload_len(db) - 1; |
| 3656 | u8 count; |
| 3657 | u64 map = 0; |
| 3658 | |
| 3659 | if (map_len == 0) { |
| 3660 | /* All CEA modes support ycbcr420 sampling also.*/ |
| 3661 | hdmi->y420_cmdb_map = U64_MAX; |
| 3662 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3663 | return; |
| 3664 | } |
| 3665 | |
| 3666 | /* |
| 3667 | * This map indicates which of the existing CEA block modes |
| 3668 | * from VDB can support YCBCR420 output too. So if bit=0 is |
| 3669 | * set, first mode from VDB can support YCBCR420 output too. |
| 3670 | * We will parse and keep this map, before parsing VDB itself |
| 3671 | * to avoid going through the same block again and again. |
| 3672 | * |
| 3673 | * Spec is not clear about max possible size of this block. |
| 3674 | * Clamping max bitmap block size at 8 bytes. Every byte can |
| 3675 | * address 8 CEA modes, in this way this map can address |
| 3676 | * 8*8 = first 64 SVDs. |
| 3677 | */ |
| 3678 | if (WARN_ON_ONCE(map_len > 8)) |
| 3679 | map_len = 8; |
| 3680 | |
| 3681 | for (count = 0; count < map_len; count++) |
| 3682 | map |= (u64)db[2 + count] << (8 * count); |
| 3683 | |
| 3684 | if (map) |
| 3685 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3686 | |
| 3687 | hdmi->y420_cmdb_map = map; |
| 3688 | } |
| 3689 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3690 | static int |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3691 | add_cea_modes(struct drm_connector *connector, struct edid *edid) |
| 3692 | { |
Lespiau, Damien | 13ac3f5 | 2013-08-19 16:58:53 +0100 | [diff] [blame] | 3693 | const u8 *cea = drm_find_cea_extension(edid); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3694 | const u8 *db, *hdmi = NULL, *video = NULL; |
| 3695 | u8 dbl, hdmi_len, video_len = 0; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3696 | int modes = 0; |
| 3697 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3698 | if (cea && cea_revision(cea) >= 3) { |
| 3699 | int i, start, end; |
| 3700 | |
| 3701 | if (cea_db_offsets(cea, &start, &end)) |
| 3702 | return 0; |
| 3703 | |
| 3704 | for_each_cea_db(cea, i, start, end) { |
| 3705 | db = &cea[i]; |
| 3706 | dbl = cea_db_payload_len(db); |
| 3707 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3708 | if (cea_db_tag(db) == VIDEO_BLOCK) { |
| 3709 | video = db + 1; |
| 3710 | video_len = dbl; |
| 3711 | modes += do_cea_modes(connector, video, dbl); |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3712 | } else if (cea_db_is_hdmi_vsdb(db)) { |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3713 | hdmi = db; |
| 3714 | hdmi_len = dbl; |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3715 | } else if (cea_db_is_y420vdb(db)) { |
| 3716 | const u8 *vdb420 = &db[2]; |
| 3717 | |
| 3718 | /* Add 4:2:0(only) modes present in EDID */ |
| 3719 | modes += do_y420vdb_modes(connector, |
| 3720 | vdb420, |
| 3721 | dbl - 1); |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3722 | } |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3723 | } |
| 3724 | } |
| 3725 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3726 | /* |
| 3727 | * We parse the HDMI VSDB after having added the cea modes as we will |
| 3728 | * be patching their flags when the sink supports stereo 3D. |
| 3729 | */ |
| 3730 | if (hdmi) |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3731 | modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, |
| 3732 | video_len); |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3733 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3734 | return modes; |
| 3735 | } |
| 3736 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3737 | static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode) |
| 3738 | { |
| 3739 | const struct drm_display_mode *cea_mode; |
| 3740 | int clock1, clock2, clock; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3741 | u8 vic; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3742 | const char *type; |
| 3743 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3744 | /* |
| 3745 | * allow 5kHz clock difference either way to account for |
| 3746 | * the 10kHz clock resolution limit of detailed timings. |
| 3747 | */ |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3748 | vic = drm_match_cea_mode_clock_tolerance(mode, 5); |
| 3749 | if (drm_valid_cea_vic(vic)) { |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3750 | type = "CEA"; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3751 | cea_mode = &edid_cea_modes[vic]; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3752 | clock1 = cea_mode->clock; |
| 3753 | clock2 = cea_mode_alternate_clock(cea_mode); |
| 3754 | } else { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3755 | vic = drm_match_hdmi_mode_clock_tolerance(mode, 5); |
| 3756 | if (drm_valid_hdmi_vic(vic)) { |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3757 | type = "HDMI"; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3758 | cea_mode = &edid_4k_modes[vic]; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3759 | clock1 = cea_mode->clock; |
| 3760 | clock2 = hdmi_mode_alternate_clock(cea_mode); |
| 3761 | } else { |
| 3762 | return; |
| 3763 | } |
| 3764 | } |
| 3765 | |
| 3766 | /* pick whichever is closest */ |
| 3767 | if (abs(mode->clock - clock1) < abs(mode->clock - clock2)) |
| 3768 | clock = clock1; |
| 3769 | else |
| 3770 | clock = clock2; |
| 3771 | |
| 3772 | if (mode->clock == clock) |
| 3773 | return; |
| 3774 | |
| 3775 | DRM_DEBUG("detailed mode matches %s VIC %d, adjusting clock %d -> %d\n", |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3776 | type, vic, mode->clock, clock); |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3777 | mode->clock = clock; |
| 3778 | } |
| 3779 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3780 | static void |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 3781 | drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db) |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3782 | { |
Ville Syrjälä | 8504072 | 2012-08-16 14:55:05 +0000 | [diff] [blame] | 3783 | u8 len = cea_db_payload_len(db); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3784 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3785 | if (len >= 6 && (db[6] & (1 << 7))) |
| 3786 | connector->eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_SUPPORTS_AI; |
Ville Syrjälä | 8504072 | 2012-08-16 14:55:05 +0000 | [diff] [blame] | 3787 | if (len >= 8) { |
| 3788 | connector->latency_present[0] = db[8] >> 7; |
| 3789 | connector->latency_present[1] = (db[8] >> 6) & 1; |
| 3790 | } |
| 3791 | if (len >= 9) |
| 3792 | connector->video_latency[0] = db[9]; |
| 3793 | if (len >= 10) |
| 3794 | connector->audio_latency[0] = db[10]; |
| 3795 | if (len >= 11) |
| 3796 | connector->video_latency[1] = db[11]; |
| 3797 | if (len >= 12) |
| 3798 | connector->audio_latency[1] = db[12]; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3799 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 3800 | DRM_DEBUG_KMS("HDMI: latency present %d %d, " |
| 3801 | "video latency %d %d, " |
| 3802 | "audio latency %d %d\n", |
| 3803 | connector->latency_present[0], |
| 3804 | connector->latency_present[1], |
| 3805 | connector->video_latency[0], |
| 3806 | connector->video_latency[1], |
| 3807 | connector->audio_latency[0], |
| 3808 | connector->audio_latency[1]); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3809 | } |
| 3810 | |
| 3811 | static void |
| 3812 | monitor_name(struct detailed_timing *t, void *data) |
| 3813 | { |
| 3814 | if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME) |
| 3815 | *(u8 **)data = t->data.other_data.data.str.str; |
| 3816 | } |
| 3817 | |
Jim Bride | 59f7c0f | 2016-04-14 10:18:35 -0700 | [diff] [blame] | 3818 | static int get_monitor_name(struct edid *edid, char name[13]) |
| 3819 | { |
| 3820 | char *edid_name = NULL; |
| 3821 | int mnl; |
| 3822 | |
| 3823 | if (!edid || !name) |
| 3824 | return 0; |
| 3825 | |
| 3826 | drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name); |
| 3827 | for (mnl = 0; edid_name && mnl < 13; mnl++) { |
| 3828 | if (edid_name[mnl] == 0x0a) |
| 3829 | break; |
| 3830 | |
| 3831 | name[mnl] = edid_name[mnl]; |
| 3832 | } |
| 3833 | |
| 3834 | return mnl; |
| 3835 | } |
| 3836 | |
| 3837 | /** |
| 3838 | * drm_edid_get_monitor_name - fetch the monitor name from the edid |
| 3839 | * @edid: monitor EDID information |
| 3840 | * @name: pointer to a character array to hold the name of the monitor |
| 3841 | * @bufsize: The size of the name buffer (should be at least 14 chars.) |
| 3842 | * |
| 3843 | */ |
| 3844 | void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize) |
| 3845 | { |
| 3846 | int name_length; |
| 3847 | char buf[13]; |
| 3848 | |
| 3849 | if (bufsize <= 0) |
| 3850 | return; |
| 3851 | |
| 3852 | name_length = min(get_monitor_name(edid, buf), bufsize - 1); |
| 3853 | memcpy(name, buf, name_length); |
| 3854 | name[name_length] = '\0'; |
| 3855 | } |
| 3856 | EXPORT_SYMBOL(drm_edid_get_monitor_name); |
| 3857 | |
Jani Nikula | 42750d3 | 2017-11-01 16:21:00 +0200 | [diff] [blame] | 3858 | static void clear_eld(struct drm_connector *connector) |
| 3859 | { |
| 3860 | memset(connector->eld, 0, sizeof(connector->eld)); |
| 3861 | |
| 3862 | connector->latency_present[0] = false; |
| 3863 | connector->latency_present[1] = false; |
| 3864 | connector->video_latency[0] = 0; |
| 3865 | connector->audio_latency[0] = 0; |
| 3866 | connector->video_latency[1] = 0; |
| 3867 | connector->audio_latency[1] = 0; |
| 3868 | } |
| 3869 | |
Jani Nikula | 79436a1 | 2017-11-01 16:21:03 +0200 | [diff] [blame] | 3870 | /* |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3871 | * drm_edid_to_eld - build ELD from EDID |
| 3872 | * @connector: connector corresponding to the HDMI/DP sink |
| 3873 | * @edid: EDID to parse |
| 3874 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 3875 | * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The |
Jani Nikula | 1d1c366 | 2017-11-01 16:20:58 +0200 | [diff] [blame] | 3876 | * HDCP and Port_ID ELD fields are left for the graphics driver to fill in. |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3877 | */ |
Jani Nikula | 79436a1 | 2017-11-01 16:21:03 +0200 | [diff] [blame] | 3878 | static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3879 | { |
| 3880 | uint8_t *eld = connector->eld; |
| 3881 | u8 *cea; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3882 | u8 *db; |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3883 | int total_sad_count = 0; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3884 | int mnl; |
| 3885 | int dbl; |
| 3886 | |
Jani Nikula | 42750d3 | 2017-11-01 16:21:00 +0200 | [diff] [blame] | 3887 | clear_eld(connector); |
Ville Syrjälä | 85c9158 | 2016-09-28 16:51:34 +0300 | [diff] [blame] | 3888 | |
Jani Nikula | e9bd0b8 | 2017-02-17 17:20:52 +0200 | [diff] [blame] | 3889 | if (!edid) |
| 3890 | return; |
| 3891 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3892 | cea = drm_find_cea_extension(edid); |
| 3893 | if (!cea) { |
| 3894 | DRM_DEBUG_KMS("ELD: no CEA Extension found\n"); |
| 3895 | return; |
| 3896 | } |
| 3897 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3898 | mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); |
| 3899 | DRM_DEBUG_KMS("ELD monitor %s\n", &eld[DRM_ELD_MONITOR_NAME_STRING]); |
Jim Bride | 59f7c0f | 2016-04-14 10:18:35 -0700 | [diff] [blame] | 3900 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3901 | eld[DRM_ELD_CEA_EDID_VER_MNL] = cea[1] << DRM_ELD_CEA_EDID_VER_SHIFT; |
| 3902 | eld[DRM_ELD_CEA_EDID_VER_MNL] |= mnl; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3903 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3904 | eld[DRM_ELD_VER] = DRM_ELD_VER_CEA861D; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3905 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3906 | eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0]; |
| 3907 | eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1]; |
| 3908 | eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0]; |
| 3909 | eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1]; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3910 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3911 | if (cea_revision(cea) >= 3) { |
| 3912 | int i, start, end; |
| 3913 | |
| 3914 | if (cea_db_offsets(cea, &start, &end)) { |
| 3915 | start = 0; |
| 3916 | end = 0; |
| 3917 | } |
| 3918 | |
| 3919 | for_each_cea_db(cea, i, start, end) { |
| 3920 | db = &cea[i]; |
| 3921 | dbl = cea_db_payload_len(db); |
| 3922 | |
| 3923 | switch (cea_db_tag(db)) { |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3924 | int sad_count; |
| 3925 | |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 3926 | case AUDIO_BLOCK: |
| 3927 | /* Audio Data Block, contains SADs */ |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3928 | sad_count = min(dbl / 3, 15 - total_sad_count); |
| 3929 | if (sad_count >= 1) |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3930 | memcpy(&eld[DRM_ELD_CEA_SAD(mnl, total_sad_count)], |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3931 | &db[1], sad_count * 3); |
| 3932 | total_sad_count += sad_count; |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 3933 | break; |
| 3934 | case SPEAKER_BLOCK: |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3935 | /* Speaker Allocation Data Block */ |
| 3936 | if (dbl >= 1) |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3937 | eld[DRM_ELD_SPEAKER] = db[1]; |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 3938 | break; |
| 3939 | case VENDOR_BLOCK: |
| 3940 | /* HDMI Vendor-Specific Data Block */ |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 3941 | if (cea_db_is_hdmi_vsdb(db)) |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 3942 | drm_parse_hdmi_vsdb_audio(connector, db); |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 3943 | break; |
| 3944 | default: |
| 3945 | break; |
| 3946 | } |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3947 | } |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3948 | } |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3949 | eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= total_sad_count << DRM_ELD_SAD_COUNT_SHIFT; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3950 | |
Jani Nikula | 1d1c366 | 2017-11-01 16:20:58 +0200 | [diff] [blame] | 3951 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 3952 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 3953 | eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_DP; |
| 3954 | else |
| 3955 | eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_HDMI; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3956 | |
Jani Nikula | 938fd8a | 2014-10-28 16:20:48 +0200 | [diff] [blame] | 3957 | eld[DRM_ELD_BASELINE_ELD_LEN] = |
| 3958 | DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4); |
| 3959 | |
| 3960 | DRM_DEBUG_KMS("ELD size %d, SAD count %d\n", |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3961 | drm_eld_size(eld), total_sad_count); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3962 | } |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3963 | |
| 3964 | /** |
Rafał Miłecki | fe21416 | 2013-04-19 19:01:25 +0200 | [diff] [blame] | 3965 | * drm_edid_to_sad - extracts SADs from EDID |
| 3966 | * @edid: EDID to parse |
| 3967 | * @sads: pointer that will be set to the extracted SADs |
| 3968 | * |
| 3969 | * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it. |
Rafał Miłecki | fe21416 | 2013-04-19 19:01:25 +0200 | [diff] [blame] | 3970 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 3971 | * Note: The returned pointer needs to be freed using kfree(). |
| 3972 | * |
| 3973 | * Return: The number of found SADs or negative number on error. |
Rafał Miłecki | fe21416 | 2013-04-19 19:01:25 +0200 | [diff] [blame] | 3974 | */ |
| 3975 | int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) |
| 3976 | { |
| 3977 | int count = 0; |
| 3978 | int i, start, end, dbl; |
| 3979 | u8 *cea; |
| 3980 | |
| 3981 | cea = drm_find_cea_extension(edid); |
| 3982 | if (!cea) { |
| 3983 | DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); |
| 3984 | return -ENOENT; |
| 3985 | } |
| 3986 | |
| 3987 | if (cea_revision(cea) < 3) { |
| 3988 | DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); |
| 3989 | return -ENOTSUPP; |
| 3990 | } |
| 3991 | |
| 3992 | if (cea_db_offsets(cea, &start, &end)) { |
| 3993 | DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); |
| 3994 | return -EPROTO; |
| 3995 | } |
| 3996 | |
| 3997 | for_each_cea_db(cea, i, start, end) { |
| 3998 | u8 *db = &cea[i]; |
| 3999 | |
| 4000 | if (cea_db_tag(db) == AUDIO_BLOCK) { |
| 4001 | int j; |
| 4002 | dbl = cea_db_payload_len(db); |
| 4003 | |
| 4004 | count = dbl / 3; /* SAD is 3B */ |
| 4005 | *sads = kcalloc(count, sizeof(**sads), GFP_KERNEL); |
| 4006 | if (!*sads) |
| 4007 | return -ENOMEM; |
| 4008 | for (j = 0; j < count; j++) { |
| 4009 | u8 *sad = &db[1 + j * 3]; |
| 4010 | |
| 4011 | (*sads)[j].format = (sad[0] & 0x78) >> 3; |
| 4012 | (*sads)[j].channels = sad[0] & 0x7; |
| 4013 | (*sads)[j].freq = sad[1] & 0x7F; |
| 4014 | (*sads)[j].byte2 = sad[2]; |
| 4015 | } |
| 4016 | break; |
| 4017 | } |
| 4018 | } |
| 4019 | |
| 4020 | return count; |
| 4021 | } |
| 4022 | EXPORT_SYMBOL(drm_edid_to_sad); |
| 4023 | |
| 4024 | /** |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4025 | * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID |
| 4026 | * @edid: EDID to parse |
| 4027 | * @sadb: pointer to the speaker block |
| 4028 | * |
| 4029 | * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it. |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4030 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4031 | * Note: The returned pointer needs to be freed using kfree(). |
| 4032 | * |
| 4033 | * Return: The number of found Speaker Allocation Blocks or negative number on |
| 4034 | * error. |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4035 | */ |
| 4036 | int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) |
| 4037 | { |
| 4038 | int count = 0; |
| 4039 | int i, start, end, dbl; |
| 4040 | const u8 *cea; |
| 4041 | |
| 4042 | cea = drm_find_cea_extension(edid); |
| 4043 | if (!cea) { |
| 4044 | DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); |
| 4045 | return -ENOENT; |
| 4046 | } |
| 4047 | |
| 4048 | if (cea_revision(cea) < 3) { |
| 4049 | DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); |
| 4050 | return -ENOTSUPP; |
| 4051 | } |
| 4052 | |
| 4053 | if (cea_db_offsets(cea, &start, &end)) { |
| 4054 | DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); |
| 4055 | return -EPROTO; |
| 4056 | } |
| 4057 | |
| 4058 | for_each_cea_db(cea, i, start, end) { |
| 4059 | const u8 *db = &cea[i]; |
| 4060 | |
| 4061 | if (cea_db_tag(db) == SPEAKER_BLOCK) { |
| 4062 | dbl = cea_db_payload_len(db); |
| 4063 | |
| 4064 | /* Speaker Allocation Data Block */ |
| 4065 | if (dbl == 3) { |
Benoit Taine | 89086bc | 2014-05-26 17:21:22 +0200 | [diff] [blame] | 4066 | *sadb = kmemdup(&db[1], dbl, GFP_KERNEL); |
Alex Deucher | 618e377 | 2013-09-27 18:46:09 -0400 | [diff] [blame] | 4067 | if (!*sadb) |
| 4068 | return -ENOMEM; |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4069 | count = dbl; |
| 4070 | break; |
| 4071 | } |
| 4072 | } |
| 4073 | } |
| 4074 | |
| 4075 | return count; |
| 4076 | } |
| 4077 | EXPORT_SYMBOL(drm_edid_to_speaker_allocation); |
| 4078 | |
| 4079 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4080 | * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4081 | * @connector: connector associated with the HDMI/DP sink |
| 4082 | * @mode: the display mode |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4083 | * |
| 4084 | * Return: The HDMI/DP sink's audio-video sync delay in milliseconds or 0 if |
| 4085 | * the sink doesn't support audio or video. |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4086 | */ |
| 4087 | int drm_av_sync_delay(struct drm_connector *connector, |
Ville Syrjälä | 3a818d3 | 2015-09-07 18:22:58 +0300 | [diff] [blame] | 4088 | const struct drm_display_mode *mode) |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4089 | { |
| 4090 | int i = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); |
| 4091 | int a, v; |
| 4092 | |
| 4093 | if (!connector->latency_present[0]) |
| 4094 | return 0; |
| 4095 | if (!connector->latency_present[1]) |
| 4096 | i = 0; |
| 4097 | |
| 4098 | a = connector->audio_latency[i]; |
| 4099 | v = connector->video_latency[i]; |
| 4100 | |
| 4101 | /* |
| 4102 | * HDMI/DP sink doesn't support audio or video? |
| 4103 | */ |
| 4104 | if (a == 255 || v == 255) |
| 4105 | return 0; |
| 4106 | |
| 4107 | /* |
| 4108 | * Convert raw EDID values to millisecond. |
| 4109 | * Treat unknown latency as 0ms. |
| 4110 | */ |
| 4111 | if (a) |
| 4112 | a = min(2 * (a - 1), 500); |
| 4113 | if (v) |
| 4114 | v = min(2 * (v - 1), 500); |
| 4115 | |
| 4116 | return max(v - a, 0); |
| 4117 | } |
| 4118 | EXPORT_SYMBOL(drm_av_sync_delay); |
| 4119 | |
| 4120 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4121 | * drm_detect_hdmi_monitor - detect whether monitor is HDMI |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4122 | * @edid: monitor EDID information |
| 4123 | * |
| 4124 | * Parse the CEA extension according to CEA-861-B. |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4125 | * |
| 4126 | * Return: True if the monitor is HDMI, false if not or unknown. |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4127 | */ |
| 4128 | bool drm_detect_hdmi_monitor(struct edid *edid) |
| 4129 | { |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4130 | u8 *edid_ext; |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4131 | int i; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4132 | int start_offset, end_offset; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4133 | |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4134 | edid_ext = drm_find_cea_extension(edid); |
| 4135 | if (!edid_ext) |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4136 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4137 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4138 | if (cea_db_offsets(edid_ext, &start_offset, &end_offset)) |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4139 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4140 | |
| 4141 | /* |
| 4142 | * Because HDMI identifier is in Vendor Specific Block, |
| 4143 | * search it from all data blocks of CEA extension. |
| 4144 | */ |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4145 | for_each_cea_db(edid_ext, i, start_offset, end_offset) { |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4146 | if (cea_db_is_hdmi_vsdb(&edid_ext[i])) |
| 4147 | return true; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4148 | } |
| 4149 | |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4150 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4151 | } |
| 4152 | EXPORT_SYMBOL(drm_detect_hdmi_monitor); |
| 4153 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4154 | /** |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4155 | * drm_detect_monitor_audio - check monitor audio capability |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 4156 | * @edid: EDID block to scan |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4157 | * |
| 4158 | * Monitor should have CEA extension block. |
| 4159 | * If monitor has 'basic audio', but no CEA audio blocks, it's 'basic |
| 4160 | * audio' only. If there is any audio extension block and supported |
| 4161 | * audio format, assume at least 'basic audio' support, even if 'basic |
| 4162 | * audio' is not defined in EDID. |
| 4163 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4164 | * Return: True if the monitor supports audio, false otherwise. |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4165 | */ |
| 4166 | bool drm_detect_monitor_audio(struct edid *edid) |
| 4167 | { |
| 4168 | u8 *edid_ext; |
| 4169 | int i, j; |
| 4170 | bool has_audio = false; |
| 4171 | int start_offset, end_offset; |
| 4172 | |
| 4173 | edid_ext = drm_find_cea_extension(edid); |
| 4174 | if (!edid_ext) |
| 4175 | goto end; |
| 4176 | |
| 4177 | has_audio = ((edid_ext[3] & EDID_BASIC_AUDIO) != 0); |
| 4178 | |
| 4179 | if (has_audio) { |
| 4180 | DRM_DEBUG_KMS("Monitor has basic audio support\n"); |
| 4181 | goto end; |
| 4182 | } |
| 4183 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4184 | if (cea_db_offsets(edid_ext, &start_offset, &end_offset)) |
| 4185 | goto end; |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4186 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4187 | for_each_cea_db(edid_ext, i, start_offset, end_offset) { |
| 4188 | if (cea_db_tag(&edid_ext[i]) == AUDIO_BLOCK) { |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4189 | has_audio = true; |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4190 | for (j = 1; j < cea_db_payload_len(&edid_ext[i]) + 1; j += 3) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4191 | DRM_DEBUG_KMS("CEA audio format %d\n", |
| 4192 | (edid_ext[i + j] >> 3) & 0xf); |
| 4193 | goto end; |
| 4194 | } |
| 4195 | } |
| 4196 | end: |
| 4197 | return has_audio; |
| 4198 | } |
| 4199 | EXPORT_SYMBOL(drm_detect_monitor_audio); |
| 4200 | |
| 4201 | /** |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 4202 | * drm_rgb_quant_range_selectable - is RGB quantization range selectable? |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 4203 | * @edid: EDID block to scan |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 4204 | * |
| 4205 | * Check whether the monitor reports the RGB quantization range selection |
| 4206 | * as supported. The AVI infoframe can then be used to inform the monitor |
| 4207 | * which quantization range (full or limited) is used. |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4208 | * |
| 4209 | * Return: True if the RGB quantization range is selectable, false otherwise. |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 4210 | */ |
| 4211 | bool drm_rgb_quant_range_selectable(struct edid *edid) |
| 4212 | { |
| 4213 | u8 *edid_ext; |
| 4214 | int i, start, end; |
| 4215 | |
| 4216 | edid_ext = drm_find_cea_extension(edid); |
| 4217 | if (!edid_ext) |
| 4218 | return false; |
| 4219 | |
| 4220 | if (cea_db_offsets(edid_ext, &start, &end)) |
| 4221 | return false; |
| 4222 | |
| 4223 | for_each_cea_db(edid_ext, i, start, end) { |
Shashank Sharma | 87563fc | 2017-07-13 21:03:10 +0530 | [diff] [blame] | 4224 | if (cea_db_tag(&edid_ext[i]) == USE_EXTENDED_TAG && |
| 4225 | cea_db_payload_len(&edid_ext[i]) == 2 && |
| 4226 | cea_db_extended_tag(&edid_ext[i]) == |
| 4227 | EXT_VIDEO_CAPABILITY_BLOCK) { |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 4228 | DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", edid_ext[i + 2]); |
| 4229 | return edid_ext[i + 2] & EDID_CEA_VCDB_QS; |
| 4230 | } |
| 4231 | } |
| 4232 | |
| 4233 | return false; |
| 4234 | } |
| 4235 | EXPORT_SYMBOL(drm_rgb_quant_range_selectable); |
| 4236 | |
Ville Syrjälä | c8127cf0 | 2017-01-11 16:18:35 +0200 | [diff] [blame] | 4237 | /** |
| 4238 | * drm_default_rgb_quant_range - default RGB quantization range |
| 4239 | * @mode: display mode |
| 4240 | * |
| 4241 | * Determine the default RGB quantization range for the mode, |
| 4242 | * as specified in CEA-861. |
| 4243 | * |
| 4244 | * Return: The default RGB quantization range for the mode |
| 4245 | */ |
| 4246 | enum hdmi_quantization_range |
| 4247 | drm_default_rgb_quant_range(const struct drm_display_mode *mode) |
| 4248 | { |
| 4249 | /* All CEA modes other than VIC 1 use limited quantization range. */ |
| 4250 | return drm_match_cea_mode(mode) > 1 ? |
| 4251 | HDMI_QUANTIZATION_RANGE_LIMITED : |
| 4252 | HDMI_QUANTIZATION_RANGE_FULL; |
| 4253 | } |
| 4254 | EXPORT_SYMBOL(drm_default_rgb_quant_range); |
| 4255 | |
Shashank Sharma | e6a9a2c | 2017-07-13 21:03:13 +0530 | [diff] [blame] | 4256 | static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector, |
| 4257 | const u8 *db) |
| 4258 | { |
| 4259 | u8 dc_mask; |
| 4260 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
| 4261 | |
| 4262 | dc_mask = db[7] & DRM_EDID_YCBCR420_DC_MASK; |
| 4263 | hdmi->y420_dc_modes |= dc_mask; |
| 4264 | } |
| 4265 | |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4266 | static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector, |
| 4267 | const u8 *hf_vsdb) |
| 4268 | { |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 4269 | struct drm_display_info *display = &connector->display_info; |
| 4270 | struct drm_hdmi_info *hdmi = &display->hdmi; |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4271 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4272 | display->has_hdmi_infoframe = true; |
| 4273 | |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4274 | if (hf_vsdb[6] & 0x80) { |
| 4275 | hdmi->scdc.supported = true; |
| 4276 | if (hf_vsdb[6] & 0x40) |
| 4277 | hdmi->scdc.read_request = true; |
| 4278 | } |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 4279 | |
| 4280 | /* |
| 4281 | * All HDMI 2.0 monitors must support scrambling at rates > 340 MHz. |
| 4282 | * And as per the spec, three factors confirm this: |
| 4283 | * * Availability of a HF-VSDB block in EDID (check) |
| 4284 | * * Non zero Max_TMDS_Char_Rate filed in HF-VSDB (let's check) |
| 4285 | * * SCDC support available (let's check) |
| 4286 | * Lets check it out. |
| 4287 | */ |
| 4288 | |
| 4289 | if (hf_vsdb[5]) { |
| 4290 | /* max clock is 5000 KHz times block value */ |
| 4291 | u32 max_tmds_clock = hf_vsdb[5] * 5000; |
| 4292 | struct drm_scdc *scdc = &hdmi->scdc; |
| 4293 | |
| 4294 | if (max_tmds_clock > 340000) { |
| 4295 | display->max_tmds_clock = max_tmds_clock; |
| 4296 | DRM_DEBUG_KMS("HF-VSDB: max TMDS clock %d kHz\n", |
| 4297 | display->max_tmds_clock); |
| 4298 | } |
| 4299 | |
| 4300 | if (scdc->supported) { |
| 4301 | scdc->scrambling.supported = true; |
| 4302 | |
| 4303 | /* Few sinks support scrambling for cloks < 340M */ |
| 4304 | if ((hf_vsdb[6] & 0x8)) |
| 4305 | scdc->scrambling.low_rates = true; |
| 4306 | } |
| 4307 | } |
Shashank Sharma | e6a9a2c | 2017-07-13 21:03:13 +0530 | [diff] [blame] | 4308 | |
| 4309 | drm_parse_ycbcr420_deep_color_info(connector, hf_vsdb); |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4310 | } |
| 4311 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4312 | static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector, |
| 4313 | const u8 *hdmi) |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4314 | { |
Ville Syrjälä | 1826750 | 2016-09-28 16:51:38 +0300 | [diff] [blame] | 4315 | struct drm_display_info *info = &connector->display_info; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4316 | unsigned int dc_bpc = 0; |
| 4317 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4318 | /* HDMI supports at least 8 bpc */ |
| 4319 | info->bpc = 8; |
| 4320 | |
| 4321 | if (cea_db_payload_len(hdmi) < 6) |
| 4322 | return; |
| 4323 | |
| 4324 | if (hdmi[6] & DRM_EDID_HDMI_DC_30) { |
| 4325 | dc_bpc = 10; |
| 4326 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_30; |
| 4327 | DRM_DEBUG("%s: HDMI sink does deep color 30.\n", |
| 4328 | connector->name); |
| 4329 | } |
| 4330 | |
| 4331 | if (hdmi[6] & DRM_EDID_HDMI_DC_36) { |
| 4332 | dc_bpc = 12; |
| 4333 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_36; |
| 4334 | DRM_DEBUG("%s: HDMI sink does deep color 36.\n", |
| 4335 | connector->name); |
| 4336 | } |
| 4337 | |
| 4338 | if (hdmi[6] & DRM_EDID_HDMI_DC_48) { |
| 4339 | dc_bpc = 16; |
| 4340 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_48; |
| 4341 | DRM_DEBUG("%s: HDMI sink does deep color 48.\n", |
| 4342 | connector->name); |
| 4343 | } |
| 4344 | |
| 4345 | if (dc_bpc == 0) { |
| 4346 | DRM_DEBUG("%s: No deep color support on this HDMI sink.\n", |
| 4347 | connector->name); |
| 4348 | return; |
| 4349 | } |
| 4350 | |
| 4351 | DRM_DEBUG("%s: Assigning HDMI sink color depth as %d bpc.\n", |
| 4352 | connector->name, dc_bpc); |
| 4353 | info->bpc = dc_bpc; |
| 4354 | |
| 4355 | /* |
| 4356 | * Deep color support mandates RGB444 support for all video |
| 4357 | * modes and forbids YCRCB422 support for all video modes per |
| 4358 | * HDMI 1.3 spec. |
| 4359 | */ |
| 4360 | info->color_formats = DRM_COLOR_FORMAT_RGB444; |
| 4361 | |
| 4362 | /* YCRCB444 is optional according to spec. */ |
| 4363 | if (hdmi[6] & DRM_EDID_HDMI_DC_Y444) { |
| 4364 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4365 | DRM_DEBUG("%s: HDMI sink does YCRCB444 in deep color.\n", |
| 4366 | connector->name); |
| 4367 | } |
| 4368 | |
| 4369 | /* |
| 4370 | * Spec says that if any deep color mode is supported at all, |
| 4371 | * then deep color 36 bit must be supported. |
| 4372 | */ |
| 4373 | if (!(hdmi[6] & DRM_EDID_HDMI_DC_36)) { |
| 4374 | DRM_DEBUG("%s: HDMI sink should do DC_36, but does not!\n", |
| 4375 | connector->name); |
| 4376 | } |
| 4377 | } |
| 4378 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4379 | static void |
| 4380 | drm_parse_hdmi_vsdb_video(struct drm_connector *connector, const u8 *db) |
| 4381 | { |
| 4382 | struct drm_display_info *info = &connector->display_info; |
| 4383 | u8 len = cea_db_payload_len(db); |
| 4384 | |
| 4385 | if (len >= 6) |
| 4386 | info->dvi_dual = db[6] & 1; |
| 4387 | if (len >= 7) |
| 4388 | info->max_tmds_clock = db[7] * 5000; |
| 4389 | |
| 4390 | DRM_DEBUG_KMS("HDMI: DVI dual %d, " |
| 4391 | "max TMDS clock %d kHz\n", |
| 4392 | info->dvi_dual, |
| 4393 | info->max_tmds_clock); |
| 4394 | |
| 4395 | drm_parse_hdmi_deep_color_info(connector, db); |
| 4396 | } |
| 4397 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4398 | static void drm_parse_cea_ext(struct drm_connector *connector, |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4399 | const struct edid *edid) |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4400 | { |
| 4401 | struct drm_display_info *info = &connector->display_info; |
| 4402 | const u8 *edid_ext; |
| 4403 | int i, start, end; |
| 4404 | |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4405 | edid_ext = drm_find_cea_extension(edid); |
| 4406 | if (!edid_ext) |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4407 | return; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4408 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4409 | info->cea_rev = edid_ext[1]; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4410 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4411 | /* The existence of a CEA block should imply RGB support */ |
| 4412 | info->color_formats = DRM_COLOR_FORMAT_RGB444; |
| 4413 | if (edid_ext[3] & EDID_CEA_YCRCB444) |
| 4414 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4415 | if (edid_ext[3] & EDID_CEA_YCRCB422) |
| 4416 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4417 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4418 | if (cea_db_offsets(edid_ext, &start, &end)) |
| 4419 | return; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4420 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4421 | for_each_cea_db(edid_ext, i, start, end) { |
| 4422 | const u8 *db = &edid_ext[i]; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4423 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4424 | if (cea_db_is_hdmi_vsdb(db)) |
| 4425 | drm_parse_hdmi_vsdb_video(connector, db); |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4426 | if (cea_db_is_hdmi_forum_vsdb(db)) |
| 4427 | drm_parse_hdmi_forum_vsdb(connector, db); |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 4428 | if (cea_db_is_y420cmdb(db)) |
| 4429 | drm_parse_y420cmdb_bitmap(connector, db); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4430 | } |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4431 | } |
| 4432 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4433 | /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset |
| 4434 | * all of the values which would have been set from EDID |
| 4435 | */ |
| 4436 | void |
| 4437 | drm_reset_display_info(struct drm_connector *connector) |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4438 | { |
Ville Syrjälä | 1826750 | 2016-09-28 16:51:38 +0300 | [diff] [blame] | 4439 | struct drm_display_info *info = &connector->display_info; |
Jesse Barnes | ebec9a7b | 2011-08-03 09:22:54 -0700 | [diff] [blame] | 4440 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4441 | info->width_mm = 0; |
| 4442 | info->height_mm = 0; |
| 4443 | |
| 4444 | info->bpc = 0; |
| 4445 | info->color_formats = 0; |
| 4446 | info->cea_rev = 0; |
| 4447 | info->max_tmds_clock = 0; |
| 4448 | info->dvi_dual = false; |
| 4449 | info->has_hdmi_infoframe = false; |
| 4450 | |
| 4451 | info->non_desktop = 0; |
| 4452 | } |
| 4453 | EXPORT_SYMBOL_GPL(drm_reset_display_info); |
| 4454 | |
| 4455 | u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid) |
| 4456 | { |
| 4457 | struct drm_display_info *info = &connector->display_info; |
| 4458 | |
| 4459 | u32 quirks = edid_get_quirks(edid); |
| 4460 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4461 | info->width_mm = edid->width_cm * 10; |
| 4462 | info->height_mm = edid->height_cm * 10; |
| 4463 | |
| 4464 | /* driver figures it out in this case */ |
| 4465 | info->bpc = 0; |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 4466 | info->color_formats = 0; |
Ville Syrjälä | 011acce | 2016-09-28 16:51:40 +0300 | [diff] [blame] | 4467 | info->cea_rev = 0; |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4468 | info->max_tmds_clock = 0; |
| 4469 | info->dvi_dual = false; |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4470 | info->has_hdmi_infoframe = false; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4471 | |
Dave Airlie | 66660d4 | 2017-10-16 05:08:09 +0100 | [diff] [blame] | 4472 | info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP); |
| 4473 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4474 | DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop); |
| 4475 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4476 | if (edid->revision < 3) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4477 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4478 | |
| 4479 | if (!(edid->input & DRM_EDID_INPUT_DIGITAL)) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4480 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4481 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4482 | drm_parse_cea_ext(connector, edid); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4483 | |
Mario Kleiner | 210a021 | 2016-07-06 12:05:48 +0200 | [diff] [blame] | 4484 | /* |
| 4485 | * Digital sink with "DFP 1.x compliant TMDS" according to EDID 1.3? |
| 4486 | * |
| 4487 | * For such displays, the DFP spec 1.0, section 3.10 "EDID support" |
| 4488 | * tells us to assume 8 bpc color depth if the EDID doesn't have |
| 4489 | * extensions which tell otherwise. |
| 4490 | */ |
| 4491 | if ((info->bpc == 0) && (edid->revision < 4) && |
| 4492 | (edid->input & DRM_EDID_DIGITAL_TYPE_DVI)) { |
| 4493 | info->bpc = 8; |
| 4494 | DRM_DEBUG("%s: Assigning DFP sink color depth as %d bpc.\n", |
| 4495 | connector->name, info->bpc); |
| 4496 | } |
| 4497 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4498 | /* Only defined for 1.4 with digital displays */ |
| 4499 | if (edid->revision < 4) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4500 | return quirks; |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4501 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4502 | switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) { |
| 4503 | case DRM_EDID_DIGITAL_DEPTH_6: |
| 4504 | info->bpc = 6; |
| 4505 | break; |
| 4506 | case DRM_EDID_DIGITAL_DEPTH_8: |
| 4507 | info->bpc = 8; |
| 4508 | break; |
| 4509 | case DRM_EDID_DIGITAL_DEPTH_10: |
| 4510 | info->bpc = 10; |
| 4511 | break; |
| 4512 | case DRM_EDID_DIGITAL_DEPTH_12: |
| 4513 | info->bpc = 12; |
| 4514 | break; |
| 4515 | case DRM_EDID_DIGITAL_DEPTH_14: |
| 4516 | info->bpc = 14; |
| 4517 | break; |
| 4518 | case DRM_EDID_DIGITAL_DEPTH_16: |
| 4519 | info->bpc = 16; |
| 4520 | break; |
| 4521 | case DRM_EDID_DIGITAL_DEPTH_UNDEF: |
| 4522 | default: |
| 4523 | info->bpc = 0; |
| 4524 | break; |
| 4525 | } |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 4526 | |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4527 | DRM_DEBUG("%s: Assigning EDID-1.4 digital sink color depth as %d bpc.\n", |
Jani Nikula | 2593382 | 2014-06-03 14:56:20 +0300 | [diff] [blame] | 4528 | connector->name, info->bpc); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4529 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4530 | info->color_formats |= DRM_COLOR_FORMAT_RGB444; |
Lars-Peter Clausen | ee58808 | 2012-04-16 15:16:18 +0200 | [diff] [blame] | 4531 | if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444) |
| 4532 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4533 | if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422) |
| 4534 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4535 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4536 | } |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4537 | EXPORT_SYMBOL_GPL(drm_add_display_info); |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4538 | |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 4539 | static int validate_displayid(u8 *displayid, int length, int idx) |
| 4540 | { |
| 4541 | int i; |
| 4542 | u8 csum = 0; |
| 4543 | struct displayid_hdr *base; |
| 4544 | |
| 4545 | base = (struct displayid_hdr *)&displayid[idx]; |
| 4546 | |
| 4547 | DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n", |
| 4548 | base->rev, base->bytes, base->prod_id, base->ext_count); |
| 4549 | |
| 4550 | if (base->bytes + 5 > length - idx) |
| 4551 | return -EINVAL; |
| 4552 | for (i = idx; i <= base->bytes + 5; i++) { |
| 4553 | csum += displayid[i]; |
| 4554 | } |
| 4555 | if (csum) { |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 4556 | DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum); |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 4557 | return -EINVAL; |
| 4558 | } |
| 4559 | return 0; |
| 4560 | } |
| 4561 | |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 4562 | static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev, |
| 4563 | struct displayid_detailed_timings_1 *timings) |
| 4564 | { |
| 4565 | struct drm_display_mode *mode; |
| 4566 | unsigned pixel_clock = (timings->pixel_clock[0] | |
| 4567 | (timings->pixel_clock[1] << 8) | |
| 4568 | (timings->pixel_clock[2] << 16)); |
| 4569 | unsigned hactive = (timings->hactive[0] | timings->hactive[1] << 8) + 1; |
| 4570 | unsigned hblank = (timings->hblank[0] | timings->hblank[1] << 8) + 1; |
| 4571 | unsigned hsync = (timings->hsync[0] | (timings->hsync[1] & 0x7f) << 8) + 1; |
| 4572 | unsigned hsync_width = (timings->hsw[0] | timings->hsw[1] << 8) + 1; |
| 4573 | unsigned vactive = (timings->vactive[0] | timings->vactive[1] << 8) + 1; |
| 4574 | unsigned vblank = (timings->vblank[0] | timings->vblank[1] << 8) + 1; |
| 4575 | unsigned vsync = (timings->vsync[0] | (timings->vsync[1] & 0x7f) << 8) + 1; |
| 4576 | unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1; |
| 4577 | bool hsync_positive = (timings->hsync[1] >> 7) & 0x1; |
| 4578 | bool vsync_positive = (timings->vsync[1] >> 7) & 0x1; |
| 4579 | mode = drm_mode_create(dev); |
| 4580 | if (!mode) |
| 4581 | return NULL; |
| 4582 | |
| 4583 | mode->clock = pixel_clock * 10; |
| 4584 | mode->hdisplay = hactive; |
| 4585 | mode->hsync_start = mode->hdisplay + hsync; |
| 4586 | mode->hsync_end = mode->hsync_start + hsync_width; |
| 4587 | mode->htotal = mode->hdisplay + hblank; |
| 4588 | |
| 4589 | mode->vdisplay = vactive; |
| 4590 | mode->vsync_start = mode->vdisplay + vsync; |
| 4591 | mode->vsync_end = mode->vsync_start + vsync_width; |
| 4592 | mode->vtotal = mode->vdisplay + vblank; |
| 4593 | |
| 4594 | mode->flags = 0; |
| 4595 | mode->flags |= hsync_positive ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; |
| 4596 | mode->flags |= vsync_positive ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; |
| 4597 | mode->type = DRM_MODE_TYPE_DRIVER; |
| 4598 | |
| 4599 | if (timings->flags & 0x80) |
| 4600 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 4601 | mode->vrefresh = drm_mode_vrefresh(mode); |
| 4602 | drm_mode_set_name(mode); |
| 4603 | |
| 4604 | return mode; |
| 4605 | } |
| 4606 | |
| 4607 | static int add_displayid_detailed_1_modes(struct drm_connector *connector, |
| 4608 | struct displayid_block *block) |
| 4609 | { |
| 4610 | struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block; |
| 4611 | int i; |
| 4612 | int num_timings; |
| 4613 | struct drm_display_mode *newmode; |
| 4614 | int num_modes = 0; |
| 4615 | /* blocks must be multiple of 20 bytes length */ |
| 4616 | if (block->num_bytes % 20) |
| 4617 | return 0; |
| 4618 | |
| 4619 | num_timings = block->num_bytes / 20; |
| 4620 | for (i = 0; i < num_timings; i++) { |
| 4621 | struct displayid_detailed_timings_1 *timings = &det->timings[i]; |
| 4622 | |
| 4623 | newmode = drm_mode_displayid_detailed(connector->dev, timings); |
| 4624 | if (!newmode) |
| 4625 | continue; |
| 4626 | |
| 4627 | drm_mode_probed_add(connector, newmode); |
| 4628 | num_modes++; |
| 4629 | } |
| 4630 | return num_modes; |
| 4631 | } |
| 4632 | |
| 4633 | static int add_displayid_detailed_modes(struct drm_connector *connector, |
| 4634 | struct edid *edid) |
| 4635 | { |
| 4636 | u8 *displayid; |
| 4637 | int ret; |
| 4638 | int idx = 1; |
| 4639 | int length = EDID_LENGTH; |
| 4640 | struct displayid_block *block; |
| 4641 | int num_modes = 0; |
| 4642 | |
| 4643 | displayid = drm_find_displayid_extension(edid); |
| 4644 | if (!displayid) |
| 4645 | return 0; |
| 4646 | |
| 4647 | ret = validate_displayid(displayid, length, idx); |
| 4648 | if (ret) |
| 4649 | return 0; |
| 4650 | |
| 4651 | idx += sizeof(struct displayid_hdr); |
| 4652 | while (block = (struct displayid_block *)&displayid[idx], |
| 4653 | idx + sizeof(struct displayid_block) <= length && |
| 4654 | idx + sizeof(struct displayid_block) + block->num_bytes <= length && |
| 4655 | block->num_bytes > 0) { |
| 4656 | idx += block->num_bytes + sizeof(struct displayid_block); |
| 4657 | switch (block->tag) { |
| 4658 | case DATA_BLOCK_TYPE_1_DETAILED_TIMING: |
| 4659 | num_modes += add_displayid_detailed_1_modes(connector, block); |
| 4660 | break; |
| 4661 | } |
| 4662 | } |
| 4663 | return num_modes; |
| 4664 | } |
| 4665 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4666 | /** |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4667 | * drm_add_edid_modes - add modes from EDID data, if available |
| 4668 | * @connector: connector we're probing |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4669 | * @edid: EDID data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4670 | * |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 4671 | * Add the specified modes to the connector's mode list. Also fills out the |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4672 | * &drm_display_info structure and ELD in @connector with any information which |
| 4673 | * can be derived from the edid. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4674 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4675 | * Return: The number of modes added or 0 if we couldn't find any. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4676 | */ |
| 4677 | int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) |
| 4678 | { |
| 4679 | int num_modes = 0; |
| 4680 | u32 quirks; |
| 4681 | |
| 4682 | if (edid == NULL) { |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4683 | clear_eld(connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4684 | return 0; |
| 4685 | } |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 4686 | if (!drm_edid_is_valid(edid)) { |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4687 | clear_eld(connector); |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 4688 | dev_warn(connector->dev->dev, "%s: EDID invalid.\n", |
Jani Nikula | 2593382 | 2014-06-03 14:56:20 +0300 | [diff] [blame] | 4689 | connector->name); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4690 | return 0; |
| 4691 | } |
| 4692 | |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4693 | drm_edid_to_eld(connector, edid); |
| 4694 | |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4695 | /* |
Shashank Sharma | 0f0f870 | 2017-07-13 21:03:09 +0530 | [diff] [blame] | 4696 | * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. |
| 4697 | * To avoid multiple parsing of same block, lets parse that map |
| 4698 | * from sink info, before parsing CEA modes. |
| 4699 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4700 | quirks = drm_add_display_info(connector, edid); |
Shashank Sharma | 0f0f870 | 2017-07-13 21:03:09 +0530 | [diff] [blame] | 4701 | |
| 4702 | /* |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4703 | * EDID spec says modes should be preferred in this order: |
| 4704 | * - preferred detailed mode |
| 4705 | * - other detailed modes from base block |
| 4706 | * - detailed modes from extension blocks |
| 4707 | * - CVT 3-byte code modes |
| 4708 | * - standard timing codes |
| 4709 | * - established timing codes |
| 4710 | * - modes inferred from GTF or CVT range information |
| 4711 | * |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 4712 | * We get this pretty much right. |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4713 | * |
| 4714 | * XXX order for additional mode types in extension blocks? |
| 4715 | */ |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 4716 | num_modes += add_detailed_modes(connector, edid, quirks); |
| 4717 | num_modes += add_cvt_modes(connector, edid); |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4718 | num_modes += add_standard_modes(connector, edid); |
| 4719 | num_modes += add_established_modes(connector, edid); |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 4720 | num_modes += add_cea_modes(connector, edid); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 4721 | num_modes += add_alternate_cea_modes(connector, edid); |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 4722 | num_modes += add_displayid_detailed_modes(connector, edid); |
Ville Syrjälä | 4d53dc0 | 2015-05-08 17:45:07 +0300 | [diff] [blame] | 4723 | if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) |
| 4724 | num_modes += add_inferred_modes(connector, edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4725 | |
| 4726 | if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) |
| 4727 | edid_fixup_preferred(connector, quirks); |
| 4728 | |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 4729 | if (quirks & EDID_QUIRK_FORCE_6BPC) |
| 4730 | connector->display_info.bpc = 6; |
| 4731 | |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 4732 | if (quirks & EDID_QUIRK_FORCE_8BPC) |
| 4733 | connector->display_info.bpc = 8; |
| 4734 | |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 4735 | if (quirks & EDID_QUIRK_FORCE_10BPC) |
| 4736 | connector->display_info.bpc = 10; |
| 4737 | |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 4738 | if (quirks & EDID_QUIRK_FORCE_12BPC) |
| 4739 | connector->display_info.bpc = 12; |
| 4740 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4741 | return num_modes; |
| 4742 | } |
| 4743 | EXPORT_SYMBOL(drm_add_edid_modes); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4744 | |
| 4745 | /** |
| 4746 | * drm_add_modes_noedid - add modes for the connectors without EDID |
| 4747 | * @connector: connector we're probing |
| 4748 | * @hdisplay: the horizontal display limit |
| 4749 | * @vdisplay: the vertical display limit |
| 4750 | * |
| 4751 | * Add the specified modes to the connector's mode list. Only when the |
| 4752 | * hdisplay/vdisplay is not beyond the given limit, it will be added. |
| 4753 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4754 | * Return: The number of modes added or 0 if we couldn't find any. |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4755 | */ |
| 4756 | int drm_add_modes_noedid(struct drm_connector *connector, |
| 4757 | int hdisplay, int vdisplay) |
| 4758 | { |
| 4759 | int i, count, num_modes = 0; |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 4760 | struct drm_display_mode *mode; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4761 | struct drm_device *dev = connector->dev; |
| 4762 | |
Daniel Vetter | fbb40b2 | 2015-08-10 11:55:37 +0200 | [diff] [blame] | 4763 | count = ARRAY_SIZE(drm_dmt_modes); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4764 | if (hdisplay < 0) |
| 4765 | hdisplay = 0; |
| 4766 | if (vdisplay < 0) |
| 4767 | vdisplay = 0; |
| 4768 | |
| 4769 | for (i = 0; i < count; i++) { |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 4770 | const struct drm_display_mode *ptr = &drm_dmt_modes[i]; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4771 | if (hdisplay && vdisplay) { |
| 4772 | /* |
| 4773 | * Only when two are valid, they will be used to check |
| 4774 | * whether the mode should be added to the mode list of |
| 4775 | * the connector. |
| 4776 | */ |
| 4777 | if (ptr->hdisplay > hdisplay || |
| 4778 | ptr->vdisplay > vdisplay) |
| 4779 | continue; |
| 4780 | } |
Adam Jackson | f985ded | 2009-11-23 14:23:04 -0500 | [diff] [blame] | 4781 | if (drm_mode_vrefresh(ptr) > 61) |
| 4782 | continue; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4783 | mode = drm_mode_duplicate(dev, ptr); |
| 4784 | if (mode) { |
| 4785 | drm_mode_probed_add(connector, mode); |
| 4786 | num_modes++; |
| 4787 | } |
| 4788 | } |
| 4789 | return num_modes; |
| 4790 | } |
| 4791 | EXPORT_SYMBOL(drm_add_modes_noedid); |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4792 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4793 | /** |
| 4794 | * drm_set_preferred_mode - Sets the preferred mode of a connector |
| 4795 | * @connector: connector whose mode list should be processed |
| 4796 | * @hpref: horizontal resolution of preferred mode |
| 4797 | * @vpref: vertical resolution of preferred mode |
| 4798 | * |
| 4799 | * Marks a mode as preferred if it matches the resolution specified by @hpref |
| 4800 | * and @vpref. |
| 4801 | */ |
Gerd Hoffmann | 3cf70da | 2013-10-11 10:01:08 +0200 | [diff] [blame] | 4802 | void drm_set_preferred_mode(struct drm_connector *connector, |
| 4803 | int hpref, int vpref) |
| 4804 | { |
| 4805 | struct drm_display_mode *mode; |
| 4806 | |
| 4807 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4808 | if (mode->hdisplay == hpref && |
Daniel Vetter | 9d3de13 | 2014-01-23 16:27:56 +0100 | [diff] [blame] | 4809 | mode->vdisplay == vpref) |
Gerd Hoffmann | 3cf70da | 2013-10-11 10:01:08 +0200 | [diff] [blame] | 4810 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 4811 | } |
| 4812 | } |
| 4813 | EXPORT_SYMBOL(drm_set_preferred_mode); |
| 4814 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4815 | /** |
| 4816 | * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with |
| 4817 | * data from a DRM display mode |
| 4818 | * @frame: HDMI AVI infoframe |
| 4819 | * @mode: DRM display mode |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 4820 | * @is_hdmi2_sink: Sink is HDMI 2.0 compliant |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4821 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4822 | * Return: 0 on success or a negative error code on failure. |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4823 | */ |
| 4824 | int |
| 4825 | drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 4826 | const struct drm_display_mode *mode, |
| 4827 | bool is_hdmi2_sink) |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4828 | { |
| 4829 | int err; |
| 4830 | |
| 4831 | if (!frame || !mode) |
| 4832 | return -EINVAL; |
| 4833 | |
| 4834 | err = hdmi_avi_infoframe_init(frame); |
| 4835 | if (err < 0) |
| 4836 | return err; |
| 4837 | |
Damien Lespiau | bf02db9 | 2013-08-06 20:32:22 +0100 | [diff] [blame] | 4838 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 4839 | frame->pixel_repeat = 1; |
| 4840 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4841 | frame->video_code = drm_match_cea_mode(mode); |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4842 | |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 4843 | /* |
| 4844 | * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but |
| 4845 | * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we |
| 4846 | * have to make sure we dont break HDMI 1.4 sinks. |
| 4847 | */ |
| 4848 | if (!is_hdmi2_sink && frame->video_code > 64) |
| 4849 | frame->video_code = 0; |
| 4850 | |
| 4851 | /* |
| 4852 | * HDMI spec says if a mode is found in HDMI 1.4b 4K modes |
| 4853 | * we should send its VIC in vendor infoframes, else send the |
| 4854 | * VIC in AVI infoframes. Lets check if this mode is present in |
| 4855 | * HDMI 1.4b 4K modes |
| 4856 | */ |
| 4857 | if (frame->video_code) { |
| 4858 | u8 vendor_if_vic = drm_match_hdmi_mode(mode); |
| 4859 | bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 4860 | |
| 4861 | if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d) |
| 4862 | frame->video_code = 0; |
| 4863 | } |
| 4864 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4865 | frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 4866 | |
Vandana Kannan | 69ab6d3 | 2014-06-05 14:45:29 +0530 | [diff] [blame] | 4867 | /* |
| 4868 | * Populate picture aspect ratio from either |
| 4869 | * user input (if specified) or from the CEA mode list. |
| 4870 | */ |
| 4871 | if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 || |
| 4872 | mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9) |
| 4873 | frame->picture_aspect = mode->picture_aspect_ratio; |
| 4874 | else if (frame->video_code > 0) |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 4875 | frame->picture_aspect = drm_get_cea_aspect_ratio( |
| 4876 | frame->video_code); |
| 4877 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4878 | frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; |
Daniel Drake | 24d01805 | 2014-02-27 09:19:30 -0600 | [diff] [blame] | 4879 | frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN; |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4880 | |
| 4881 | return 0; |
| 4882 | } |
| 4883 | EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode); |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4884 | |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4885 | /** |
| 4886 | * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe |
| 4887 | * quantization range information |
| 4888 | * @frame: HDMI AVI infoframe |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 4889 | * @mode: DRM display mode |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4890 | * @rgb_quant_range: RGB quantization range (Q) |
| 4891 | * @rgb_quant_range_selectable: Sink support selectable RGB quantization range (QS) |
Daniel Vetter | 7cdeb37 | 2017-12-14 21:30:50 +0100 | [diff] [blame] | 4892 | * @is_hdmi2_sink: HDMI 2.0 sink, which has different default recommendations |
| 4893 | * |
| 4894 | * Note that @is_hdmi2_sink can be derived by looking at the |
| 4895 | * &drm_scdc.supported flag stored in &drm_hdmi_info.scdc, |
| 4896 | * &drm_display_info.hdmi, which can be found in &drm_connector.display_info. |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4897 | */ |
| 4898 | void |
| 4899 | drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame, |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 4900 | const struct drm_display_mode *mode, |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4901 | enum hdmi_quantization_range rgb_quant_range, |
Ville Syrjälä | 9271c0c | 2017-11-08 17:25:04 +0200 | [diff] [blame] | 4902 | bool rgb_quant_range_selectable, |
| 4903 | bool is_hdmi2_sink) |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4904 | { |
| 4905 | /* |
| 4906 | * CEA-861: |
| 4907 | * "A Source shall not send a non-zero Q value that does not correspond |
| 4908 | * to the default RGB Quantization Range for the transmitted Picture |
| 4909 | * unless the Sink indicates support for the Q bit in a Video |
| 4910 | * Capabilities Data Block." |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 4911 | * |
| 4912 | * HDMI 2.0 recommends sending non-zero Q when it does match the |
| 4913 | * default RGB quantization range for the mode, even when QS=0. |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4914 | */ |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 4915 | if (rgb_quant_range_selectable || |
| 4916 | rgb_quant_range == drm_default_rgb_quant_range(mode)) |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4917 | frame->quantization_range = rgb_quant_range; |
| 4918 | else |
| 4919 | frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 4920 | |
| 4921 | /* |
| 4922 | * CEA-861-F: |
| 4923 | * "When transmitting any RGB colorimetry, the Source should set the |
| 4924 | * YQ-field to match the RGB Quantization Range being transmitted |
| 4925 | * (e.g., when Limited Range RGB, set YQ=0 or when Full Range RGB, |
| 4926 | * set YQ=1) and the Sink shall ignore the YQ-field." |
Ville Syrjälä | 9271c0c | 2017-11-08 17:25:04 +0200 | [diff] [blame] | 4927 | * |
| 4928 | * Unfortunate certain sinks (eg. VIZ Model 67/E261VA) get confused |
| 4929 | * by non-zero YQ when receiving RGB. There doesn't seem to be any |
| 4930 | * good way to tell which version of CEA-861 the sink supports, so |
| 4931 | * we limit non-zero YQ to HDMI 2.0 sinks only as HDMI 2.0 is based |
| 4932 | * on on CEA-861-F. |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 4933 | */ |
Ville Syrjälä | 9271c0c | 2017-11-08 17:25:04 +0200 | [diff] [blame] | 4934 | if (!is_hdmi2_sink || |
| 4935 | rgb_quant_range == HDMI_QUANTIZATION_RANGE_LIMITED) |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 4936 | frame->ycc_quantization_range = |
| 4937 | HDMI_YCC_QUANTIZATION_RANGE_LIMITED; |
| 4938 | else |
| 4939 | frame->ycc_quantization_range = |
| 4940 | HDMI_YCC_QUANTIZATION_RANGE_FULL; |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 4941 | } |
| 4942 | EXPORT_SYMBOL(drm_hdmi_avi_infoframe_quant_range); |
| 4943 | |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 4944 | static enum hdmi_3d_structure |
| 4945 | s3d_structure_from_display_mode(const struct drm_display_mode *mode) |
| 4946 | { |
| 4947 | u32 layout = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 4948 | |
| 4949 | switch (layout) { |
| 4950 | case DRM_MODE_FLAG_3D_FRAME_PACKING: |
| 4951 | return HDMI_3D_STRUCTURE_FRAME_PACKING; |
| 4952 | case DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE: |
| 4953 | return HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE; |
| 4954 | case DRM_MODE_FLAG_3D_LINE_ALTERNATIVE: |
| 4955 | return HDMI_3D_STRUCTURE_LINE_ALTERNATIVE; |
| 4956 | case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL: |
| 4957 | return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL; |
| 4958 | case DRM_MODE_FLAG_3D_L_DEPTH: |
| 4959 | return HDMI_3D_STRUCTURE_L_DEPTH; |
| 4960 | case DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH: |
| 4961 | return HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH; |
| 4962 | case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM: |
| 4963 | return HDMI_3D_STRUCTURE_TOP_AND_BOTTOM; |
| 4964 | case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: |
| 4965 | return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF; |
| 4966 | default: |
| 4967 | return HDMI_3D_STRUCTURE_INVALID; |
| 4968 | } |
| 4969 | } |
| 4970 | |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4971 | /** |
| 4972 | * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with |
| 4973 | * data from a DRM display mode |
| 4974 | * @frame: HDMI vendor infoframe |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4975 | * @connector: the connector |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4976 | * @mode: DRM display mode |
| 4977 | * |
| 4978 | * Note that there's is a need to send HDMI vendor infoframes only when using a |
| 4979 | * 4k or stereoscopic 3D mode. So when giving any other mode as input this |
| 4980 | * function will return -EINVAL, error that can be safely ignored. |
| 4981 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4982 | * Return: 0 on success or a negative error code on failure. |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4983 | */ |
| 4984 | int |
| 4985 | drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4986 | struct drm_connector *connector, |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4987 | const struct drm_display_mode *mode) |
| 4988 | { |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4989 | /* |
| 4990 | * FIXME: sil-sii8620 doesn't have a connector around when |
| 4991 | * we need one, so we have to be prepared for a NULL connector. |
| 4992 | */ |
| 4993 | bool has_hdmi_infoframe = connector ? |
| 4994 | connector->display_info.has_hdmi_infoframe : false; |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4995 | int err; |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 4996 | u32 s3d_flags; |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 4997 | u8 vic; |
| 4998 | |
| 4999 | if (!frame || !mode) |
| 5000 | return -EINVAL; |
| 5001 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5002 | if (!has_hdmi_infoframe) |
| 5003 | return -EINVAL; |
| 5004 | |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5005 | vic = drm_match_hdmi_mode(mode); |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5006 | s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 5007 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5008 | /* |
| 5009 | * Even if it's not absolutely necessary to send the infoframe |
| 5010 | * (ie.vic==0 and s3d_struct==0) we will still send it if we |
| 5011 | * know that the sink can handle it. This is based on a |
| 5012 | * suggestion in HDMI 2.0 Appendix F. Apparently some sinks |
| 5013 | * have trouble realizing that they shuld switch from 3D to 2D |
| 5014 | * mode if the source simply stops sending the infoframe when |
| 5015 | * it wants to switch from 3D to 2D. |
| 5016 | */ |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5017 | |
| 5018 | if (vic && s3d_flags) |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5019 | return -EINVAL; |
| 5020 | |
| 5021 | err = hdmi_vendor_infoframe_init(frame); |
| 5022 | if (err < 0) |
| 5023 | return err; |
| 5024 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5025 | frame->vic = vic; |
| 5026 | frame->s3d_struct = s3d_structure_from_display_mode(mode); |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5027 | |
| 5028 | return 0; |
| 5029 | } |
| 5030 | EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5031 | |
Dave Airlie | 5e546cd | 2016-05-03 15:31:12 +1000 | [diff] [blame] | 5032 | static int drm_parse_tiled_block(struct drm_connector *connector, |
| 5033 | struct displayid_block *block) |
| 5034 | { |
| 5035 | struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block; |
| 5036 | u16 w, h; |
| 5037 | u8 tile_v_loc, tile_h_loc; |
| 5038 | u8 num_v_tile, num_h_tile; |
| 5039 | struct drm_tile_group *tg; |
| 5040 | |
| 5041 | w = tile->tile_size[0] | tile->tile_size[1] << 8; |
| 5042 | h = tile->tile_size[2] | tile->tile_size[3] << 8; |
| 5043 | |
| 5044 | num_v_tile = (tile->topo[0] & 0xf) | (tile->topo[2] & 0x30); |
| 5045 | num_h_tile = (tile->topo[0] >> 4) | ((tile->topo[2] >> 2) & 0x30); |
| 5046 | tile_v_loc = (tile->topo[1] & 0xf) | ((tile->topo[2] & 0x3) << 4); |
| 5047 | tile_h_loc = (tile->topo[1] >> 4) | (((tile->topo[2] >> 2) & 0x3) << 4); |
| 5048 | |
| 5049 | connector->has_tile = true; |
| 5050 | if (tile->tile_cap & 0x80) |
| 5051 | connector->tile_is_single_monitor = true; |
| 5052 | |
| 5053 | connector->num_h_tile = num_h_tile + 1; |
| 5054 | connector->num_v_tile = num_v_tile + 1; |
| 5055 | connector->tile_h_loc = tile_h_loc; |
| 5056 | connector->tile_v_loc = tile_v_loc; |
| 5057 | connector->tile_h_size = w + 1; |
| 5058 | connector->tile_v_size = h + 1; |
| 5059 | |
| 5060 | DRM_DEBUG_KMS("tile cap 0x%x\n", tile->tile_cap); |
| 5061 | DRM_DEBUG_KMS("tile_size %d x %d\n", w + 1, h + 1); |
| 5062 | DRM_DEBUG_KMS("topo num tiles %dx%d, location %dx%d\n", |
| 5063 | num_h_tile + 1, num_v_tile + 1, tile_h_loc, tile_v_loc); |
| 5064 | DRM_DEBUG_KMS("vend %c%c%c\n", tile->topology_id[0], tile->topology_id[1], tile->topology_id[2]); |
| 5065 | |
| 5066 | tg = drm_mode_get_tile_group(connector->dev, tile->topology_id); |
| 5067 | if (!tg) { |
| 5068 | tg = drm_mode_create_tile_group(connector->dev, tile->topology_id); |
| 5069 | } |
| 5070 | if (!tg) |
| 5071 | return -ENOMEM; |
| 5072 | |
| 5073 | if (connector->tile_group != tg) { |
| 5074 | /* if we haven't got a pointer, |
| 5075 | take the reference, drop ref to old tile group */ |
| 5076 | if (connector->tile_group) { |
| 5077 | drm_mode_put_tile_group(connector->dev, connector->tile_group); |
| 5078 | } |
| 5079 | connector->tile_group = tg; |
| 5080 | } else |
| 5081 | /* if same tile group, then release the ref we just took. */ |
| 5082 | drm_mode_put_tile_group(connector->dev, tg); |
| 5083 | return 0; |
| 5084 | } |
| 5085 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5086 | static int drm_parse_display_id(struct drm_connector *connector, |
| 5087 | u8 *displayid, int length, |
| 5088 | bool is_edid_extension) |
| 5089 | { |
| 5090 | /* if this is an EDID extension the first byte will be 0x70 */ |
| 5091 | int idx = 0; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5092 | struct displayid_block *block; |
Dave Airlie | 5e546cd | 2016-05-03 15:31:12 +1000 | [diff] [blame] | 5093 | int ret; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5094 | |
| 5095 | if (is_edid_extension) |
| 5096 | idx = 1; |
| 5097 | |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 5098 | ret = validate_displayid(displayid, length, idx); |
| 5099 | if (ret) |
| 5100 | return ret; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5101 | |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5102 | idx += sizeof(struct displayid_hdr); |
| 5103 | while (block = (struct displayid_block *)&displayid[idx], |
| 5104 | idx + sizeof(struct displayid_block) <= length && |
| 5105 | idx + sizeof(struct displayid_block) + block->num_bytes <= length && |
| 5106 | block->num_bytes > 0) { |
| 5107 | idx += block->num_bytes + sizeof(struct displayid_block); |
| 5108 | DRM_DEBUG_KMS("block id 0x%x, rev %d, len %d\n", |
| 5109 | block->tag, block->rev, block->num_bytes); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5110 | |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5111 | switch (block->tag) { |
| 5112 | case DATA_BLOCK_TILED_DISPLAY: |
| 5113 | ret = drm_parse_tiled_block(connector, block); |
| 5114 | if (ret) |
| 5115 | return ret; |
| 5116 | break; |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 5117 | case DATA_BLOCK_TYPE_1_DETAILED_TIMING: |
| 5118 | /* handled in mode gathering code. */ |
| 5119 | break; |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5120 | default: |
| 5121 | DRM_DEBUG_KMS("found DisplayID tag 0x%x, unhandled\n", block->tag); |
| 5122 | break; |
| 5123 | } |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5124 | } |
| 5125 | return 0; |
| 5126 | } |
| 5127 | |
| 5128 | static void drm_get_displayid(struct drm_connector *connector, |
| 5129 | struct edid *edid) |
| 5130 | { |
| 5131 | void *displayid = NULL; |
| 5132 | int ret; |
| 5133 | connector->has_tile = false; |
| 5134 | displayid = drm_find_displayid_extension(edid); |
| 5135 | if (!displayid) { |
| 5136 | /* drop reference to any tile group we had */ |
| 5137 | goto out_drop_ref; |
| 5138 | } |
| 5139 | |
| 5140 | ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, true); |
| 5141 | if (ret < 0) |
| 5142 | goto out_drop_ref; |
| 5143 | if (!connector->has_tile) |
| 5144 | goto out_drop_ref; |
| 5145 | return; |
| 5146 | out_drop_ref: |
| 5147 | if (connector->tile_group) { |
| 5148 | drm_mode_put_tile_group(connector->dev, connector->tile_group); |
| 5149 | connector->tile_group = NULL; |
| 5150 | } |
| 5151 | return; |
| 5152 | } |