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 | */ |
Jani Nikula | 9c79ede | 2019-05-06 12:52:48 +0300 | [diff] [blame] | 30 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 31 | #include <linux/hdmi.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 32 | #include <linux/i2c.h> |
Jani Nikula | 9c79ede | 2019-05-06 12:52:48 +0300 | [diff] [blame] | 33 | #include <linux/kernel.h> |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 34 | #include <linux/module.h> |
Jani Nikula | 9c79ede | 2019-05-06 12:52:48 +0300 | [diff] [blame] | 35 | #include <linux/slab.h> |
Lukas Wunner | 5cb8eaa2 | 2016-01-11 20:09:20 +0100 | [diff] [blame] | 36 | #include <linux/vga_switcheroo.h> |
Jani Nikula | 9c79ede | 2019-05-06 12:52:48 +0300 | [diff] [blame] | 37 | |
| 38 | #include <drm/drm_displayid.h> |
| 39 | #include <drm/drm_drv.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 40 | #include <drm/drm_edid.h> |
Laurent Pinchart | 9338203 | 2016-11-28 20:51:09 +0200 | [diff] [blame] | 41 | #include <drm/drm_encoder.h> |
Jani Nikula | 9c79ede | 2019-05-06 12:52:48 +0300 | [diff] [blame] | 42 | #include <drm/drm_print.h> |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 43 | #include <drm/drm_scdc_helper.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 44 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 45 | #include "drm_crtc_internal.h" |
| 46 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 47 | #define version_greater(edid, maj, min) \ |
| 48 | (((edid)->version > (maj)) || \ |
| 49 | ((edid)->version == (maj) && (edid)->revision > (min))) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 50 | |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 51 | #define EDID_EST_TIMINGS 16 |
| 52 | #define EDID_STD_TIMINGS 8 |
| 53 | #define EDID_DETAILED_TIMINGS 4 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * EDID blocks out in the wild have a variety of bugs, try to collect |
| 57 | * them here (note that userspace may work around broken monitors first, |
| 58 | * but fixes should make their way here so that the kernel "just works" |
| 59 | * on as many displays as possible). |
| 60 | */ |
| 61 | |
| 62 | /* First detailed mode wrong, use largest 60Hz mode */ |
| 63 | #define EDID_QUIRK_PREFER_LARGE_60 (1 << 0) |
| 64 | /* Reported 135MHz pixel clock is too high, needs adjustment */ |
| 65 | #define EDID_QUIRK_135_CLOCK_TOO_HIGH (1 << 1) |
| 66 | /* Prefer the largest mode at 75 Hz */ |
| 67 | #define EDID_QUIRK_PREFER_LARGE_75 (1 << 2) |
| 68 | /* Detail timing is in cm not mm */ |
| 69 | #define EDID_QUIRK_DETAILED_IN_CM (1 << 3) |
| 70 | /* Detailed timing descriptors have bogus size values, so just take the |
| 71 | * maximum size and use that. |
| 72 | */ |
| 73 | #define EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE (1 << 4) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 74 | /* use +hsync +vsync for detailed mode */ |
| 75 | #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 76 | /* Force reduced-blanking timings for detailed modes */ |
| 77 | #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7) |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 78 | /* Force 8bpc */ |
| 79 | #define EDID_QUIRK_FORCE_8BPC (1 << 8) |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 80 | /* Force 12bpc */ |
| 81 | #define EDID_QUIRK_FORCE_12BPC (1 << 9) |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 82 | /* Force 6bpc */ |
| 83 | #define EDID_QUIRK_FORCE_6BPC (1 << 10) |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 84 | /* Force 10bpc */ |
| 85 | #define EDID_QUIRK_FORCE_10BPC (1 << 11) |
Dave Airlie | 66660d4 | 2017-10-16 05:08:09 +0100 | [diff] [blame] | 86 | /* Non desktop display (i.e. HMD) */ |
| 87 | #define EDID_QUIRK_NON_DESKTOP (1 << 12) |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 88 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 89 | struct detailed_mode_closure { |
| 90 | struct drm_connector *connector; |
| 91 | struct edid *edid; |
| 92 | bool preferred; |
| 93 | u32 quirks; |
| 94 | int modes; |
| 95 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 96 | |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 97 | #define LEVEL_DMT 0 |
| 98 | #define LEVEL_GTF 1 |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 99 | #define LEVEL_GTF2 2 |
| 100 | #define LEVEL_CVT 3 |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 101 | |
Jani Nikula | 23c4cfb | 2016-12-28 13:06:26 +0200 | [diff] [blame] | 102 | static const struct edid_quirk { |
Ian Pilcher | c51a3fd6 | 2012-04-22 11:40:26 -0500 | [diff] [blame] | 103 | char vendor[4]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 104 | int product_id; |
| 105 | u32 quirks; |
| 106 | } edid_quirk_list[] = { |
| 107 | /* Acer AL1706 */ |
| 108 | { "ACR", 44358, EDID_QUIRK_PREFER_LARGE_60 }, |
| 109 | /* Acer F51 */ |
| 110 | { "API", 0x7602, EDID_QUIRK_PREFER_LARGE_60 }, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 111 | |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 112 | /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ |
| 113 | { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, |
| 114 | |
Kai-Heng Feng | 0711a43 | 2018-10-02 23:29:11 +0800 | [diff] [blame] | 115 | /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ |
| 116 | { "BOE", 0x78b, EDID_QUIRK_FORCE_6BPC }, |
| 117 | |
Kai-Heng Feng | 06998a75 | 2018-02-18 16:53:59 +0800 | [diff] [blame] | 118 | /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ |
| 119 | { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC }, |
| 120 | |
Kai-Heng Feng | 25da750 | 2018-08-23 05:53:32 +0000 | [diff] [blame] | 121 | /* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ |
| 122 | { "SDC", 0x3652, EDID_QUIRK_FORCE_6BPC }, |
| 123 | |
Lee, Shawn C | 922dcef | 2018-10-28 22:49:33 -0700 | [diff] [blame] | 124 | /* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ |
| 125 | { "BOE", 0x0771, EDID_QUIRK_FORCE_6BPC }, |
| 126 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 127 | /* Belinea 10 15 55 */ |
| 128 | { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, |
| 129 | { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, |
| 130 | |
| 131 | /* Envision Peripherals, Inc. EN-7100e */ |
| 132 | { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH }, |
Adam Jackson | ba1163d | 2010-04-06 16:11:00 +0000 | [diff] [blame] | 133 | /* Envision EN2028 */ |
| 134 | { "EPI", 8232, EDID_QUIRK_PREFER_LARGE_60 }, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 135 | |
| 136 | /* Funai Electronics PM36B */ |
| 137 | { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | |
| 138 | EDID_QUIRK_DETAILED_IN_CM }, |
| 139 | |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 140 | /* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ |
| 141 | { "LGD", 764, EDID_QUIRK_FORCE_10BPC }, |
| 142 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 143 | /* LG Philips LCD LP154W01-A5 */ |
| 144 | { "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, |
| 145 | { "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, |
| 146 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 147 | /* Samsung SyncMaster 205BW. Note: irony */ |
| 148 | { "SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP }, |
| 149 | /* Samsung SyncMaster 22[5-6]BW */ |
| 150 | { "SAM", 596, EDID_QUIRK_PREFER_LARGE_60 }, |
| 151 | { "SAM", 638, EDID_QUIRK_PREFER_LARGE_60 }, |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 152 | |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 153 | /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ |
| 154 | { "SNY", 0x2541, EDID_QUIRK_FORCE_12BPC }, |
| 155 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 156 | /* ViewSonic VA2026w */ |
| 157 | { "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING }, |
Alex Deucher | 118bdbd | 2013-08-12 11:04:29 -0400 | [diff] [blame] | 158 | |
| 159 | /* Medion MD 30217 PG */ |
| 160 | { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 161 | |
| 162 | /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ |
| 163 | { "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC }, |
Tomeu Vizoso | 36fc579 | 2017-02-20 16:25:45 +0100 | [diff] [blame] | 164 | |
| 165 | /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ |
| 166 | { "ETR", 13896, EDID_QUIRK_FORCE_8BPC }, |
Dave Airlie | acb1d8e | 2017-10-16 05:26:19 +0100 | [diff] [blame] | 167 | |
Andres Rodriguez | 30d62d4 | 2019-05-02 15:31:57 -0400 | [diff] [blame] | 168 | /* Valve Index Headset */ |
| 169 | { "VLV", 0x91a8, EDID_QUIRK_NON_DESKTOP }, |
| 170 | { "VLV", 0x91b0, EDID_QUIRK_NON_DESKTOP }, |
| 171 | { "VLV", 0x91b1, EDID_QUIRK_NON_DESKTOP }, |
| 172 | { "VLV", 0x91b2, EDID_QUIRK_NON_DESKTOP }, |
| 173 | { "VLV", 0x91b3, EDID_QUIRK_NON_DESKTOP }, |
| 174 | { "VLV", 0x91b4, EDID_QUIRK_NON_DESKTOP }, |
| 175 | { "VLV", 0x91b5, EDID_QUIRK_NON_DESKTOP }, |
| 176 | { "VLV", 0x91b6, EDID_QUIRK_NON_DESKTOP }, |
| 177 | { "VLV", 0x91b7, EDID_QUIRK_NON_DESKTOP }, |
| 178 | { "VLV", 0x91b8, EDID_QUIRK_NON_DESKTOP }, |
| 179 | { "VLV", 0x91b9, EDID_QUIRK_NON_DESKTOP }, |
| 180 | { "VLV", 0x91ba, EDID_QUIRK_NON_DESKTOP }, |
| 181 | { "VLV", 0x91bb, EDID_QUIRK_NON_DESKTOP }, |
| 182 | { "VLV", 0x91bc, EDID_QUIRK_NON_DESKTOP }, |
| 183 | { "VLV", 0x91bd, EDID_QUIRK_NON_DESKTOP }, |
| 184 | { "VLV", 0x91be, EDID_QUIRK_NON_DESKTOP }, |
| 185 | { "VLV", 0x91bf, EDID_QUIRK_NON_DESKTOP }, |
| 186 | |
Lubosz Sarnecki | 6931317 | 2018-05-29 13:52:15 +0200 | [diff] [blame] | 187 | /* HTC Vive and Vive Pro VR Headsets */ |
Dave Airlie | acb1d8e | 2017-10-16 05:26:19 +0100 | [diff] [blame] | 188 | { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, |
Lubosz Sarnecki | 6931317 | 2018-05-29 13:52:15 +0200 | [diff] [blame] | 189 | { "HVR", 0xaa02, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | b3b12ea | 2018-02-19 18:59:36 +0100 | [diff] [blame] | 190 | |
| 191 | /* Oculus Rift DK1, DK2, and CV1 VR Headsets */ |
| 192 | { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP }, |
| 193 | { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP }, |
| 194 | { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | 90eda8f | 2018-02-19 18:59:37 +0100 | [diff] [blame] | 195 | |
| 196 | /* Windows Mixed Reality Headsets */ |
| 197 | { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP }, |
| 198 | { "HPN", 0x3515, EDID_QUIRK_NON_DESKTOP }, |
| 199 | { "LEN", 0x0408, EDID_QUIRK_NON_DESKTOP }, |
| 200 | { "LEN", 0xb800, EDID_QUIRK_NON_DESKTOP }, |
| 201 | { "FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP }, |
| 202 | { "DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP }, |
| 203 | { "SEC", 0x144a, EDID_QUIRK_NON_DESKTOP }, |
| 204 | { "AUS", 0xc102, EDID_QUIRK_NON_DESKTOP }, |
Philipp Zabel | ccffc9e | 2018-02-19 18:59:38 +0100 | [diff] [blame] | 205 | |
| 206 | /* Sony PlayStation VR Headset */ |
| 207 | { "SNY", 0x0704, EDID_QUIRK_NON_DESKTOP }, |
Ryan Pavlik | 2905423 | 2018-12-03 10:46:44 -0600 | [diff] [blame] | 208 | |
| 209 | /* Sensics VR Headsets */ |
| 210 | { "SEN", 0x1019, EDID_QUIRK_NON_DESKTOP }, |
| 211 | |
| 212 | /* OSVR HDK and HDK2 VR Headsets */ |
| 213 | { "SVR", 0x1019, EDID_QUIRK_NON_DESKTOP }, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 214 | }; |
| 215 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 216 | /* |
| 217 | * Autogenerated from the DMT spec. |
| 218 | * This table is copied from xfree86/modes/xf86EdidModes.c. |
| 219 | */ |
| 220 | static const struct drm_display_mode drm_dmt_modes[] = { |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 221 | /* 0x01 - 640x350@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 222 | { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, |
| 223 | 736, 832, 0, 350, 382, 385, 445, 0, |
| 224 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 225 | /* 0x02 - 640x400@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 226 | { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672, |
| 227 | 736, 832, 0, 400, 401, 404, 445, 0, |
| 228 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 229 | /* 0x03 - 720x400@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 230 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756, |
| 231 | 828, 936, 0, 400, 401, 404, 446, 0, |
| 232 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 233 | /* 0x04 - 640x480@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 234 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 235 | 752, 800, 0, 480, 490, 492, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 236 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 237 | /* 0x05 - 640x480@72Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 238 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, |
| 239 | 704, 832, 0, 480, 489, 492, 520, 0, |
| 240 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 241 | /* 0x06 - 640x480@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 242 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, |
| 243 | 720, 840, 0, 480, 481, 484, 500, 0, |
| 244 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 245 | /* 0x07 - 640x480@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 246 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696, |
| 247 | 752, 832, 0, 480, 481, 484, 509, 0, |
| 248 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 249 | /* 0x08 - 800x600@56Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 250 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, |
| 251 | 896, 1024, 0, 600, 601, 603, 625, 0, |
| 252 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 253 | /* 0x09 - 800x600@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 254 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, |
| 255 | 968, 1056, 0, 600, 601, 605, 628, 0, |
| 256 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 257 | /* 0x0a - 800x600@72Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 258 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, |
| 259 | 976, 1040, 0, 600, 637, 643, 666, 0, |
| 260 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 261 | /* 0x0b - 800x600@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 262 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, |
| 263 | 896, 1056, 0, 600, 601, 604, 625, 0, |
| 264 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 265 | /* 0x0c - 800x600@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 266 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832, |
| 267 | 896, 1048, 0, 600, 601, 604, 631, 0, |
| 268 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 269 | /* 0x0d - 800x600@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 270 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 73250, 800, 848, |
| 271 | 880, 960, 0, 600, 603, 607, 636, 0, |
| 272 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 273 | /* 0x0e - 848x480@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 274 | { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864, |
| 275 | 976, 1088, 0, 480, 486, 494, 517, 0, |
| 276 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 277 | /* 0x0f - 1024x768@43Hz, interlace */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 278 | { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032, |
Paul Parsons | 735b100 | 2016-04-04 20:36:34 +0100 | [diff] [blame] | 279 | 1208, 1264, 0, 768, 768, 776, 817, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 280 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 281 | DRM_MODE_FLAG_INTERLACE) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 282 | /* 0x10 - 1024x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 283 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, |
| 284 | 1184, 1344, 0, 768, 771, 777, 806, 0, |
| 285 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 286 | /* 0x11 - 1024x768@70Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 287 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, |
| 288 | 1184, 1328, 0, 768, 771, 777, 806, 0, |
| 289 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 290 | /* 0x12 - 1024x768@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 291 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, |
| 292 | 1136, 1312, 0, 768, 769, 772, 800, 0, |
| 293 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 294 | /* 0x13 - 1024x768@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 295 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072, |
| 296 | 1168, 1376, 0, 768, 769, 772, 808, 0, |
| 297 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 298 | /* 0x14 - 1024x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 299 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 115500, 1024, 1072, |
| 300 | 1104, 1184, 0, 768, 771, 775, 813, 0, |
| 301 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 302 | /* 0x15 - 1152x864@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 303 | { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, |
| 304 | 1344, 1600, 0, 864, 865, 868, 900, 0, |
| 305 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 306 | /* 0x55 - 1280x720@60Hz */ |
| 307 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 308 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 309 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 310 | /* 0x16 - 1280x768@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 311 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 68250, 1280, 1328, |
| 312 | 1360, 1440, 0, 768, 771, 778, 790, 0, |
| 313 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 314 | /* 0x17 - 1280x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 315 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344, |
| 316 | 1472, 1664, 0, 768, 771, 778, 798, 0, |
| 317 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 318 | /* 0x18 - 1280x768@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 319 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360, |
| 320 | 1488, 1696, 0, 768, 771, 778, 805, 0, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 321 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 322 | /* 0x19 - 1280x768@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 323 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360, |
| 324 | 1496, 1712, 0, 768, 771, 778, 809, 0, |
| 325 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 326 | /* 0x1a - 1280x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 327 | { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 140250, 1280, 1328, |
| 328 | 1360, 1440, 0, 768, 771, 778, 813, 0, |
| 329 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 330 | /* 0x1b - 1280x800@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 331 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 71000, 1280, 1328, |
| 332 | 1360, 1440, 0, 800, 803, 809, 823, 0, |
| 333 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 334 | /* 0x1c - 1280x800@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 335 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352, |
| 336 | 1480, 1680, 0, 800, 803, 809, 831, 0, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 337 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 338 | /* 0x1d - 1280x800@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 339 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360, |
| 340 | 1488, 1696, 0, 800, 803, 809, 838, 0, |
| 341 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 342 | /* 0x1e - 1280x800@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 343 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360, |
| 344 | 1496, 1712, 0, 800, 803, 809, 843, 0, |
| 345 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 346 | /* 0x1f - 1280x800@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 347 | { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 146250, 1280, 1328, |
| 348 | 1360, 1440, 0, 800, 803, 809, 847, 0, |
| 349 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 350 | /* 0x20 - 1280x960@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 351 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376, |
| 352 | 1488, 1800, 0, 960, 961, 964, 1000, 0, |
| 353 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 354 | /* 0x21 - 1280x960@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 355 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344, |
| 356 | 1504, 1728, 0, 960, 961, 964, 1011, 0, |
| 357 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 358 | /* 0x22 - 1280x960@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 359 | { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 175500, 1280, 1328, |
| 360 | 1360, 1440, 0, 960, 963, 967, 1017, 0, |
| 361 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 362 | /* 0x23 - 1280x1024@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 363 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328, |
| 364 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 365 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 366 | /* 0x24 - 1280x1024@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 367 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, |
| 368 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 369 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 370 | /* 0x25 - 1280x1024@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 371 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344, |
| 372 | 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, |
| 373 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 374 | /* 0x26 - 1280x1024@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 375 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 187250, 1280, 1328, |
| 376 | 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, |
| 377 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 378 | /* 0x27 - 1360x768@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 379 | { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424, |
| 380 | 1536, 1792, 0, 768, 771, 777, 795, 0, |
| 381 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 382 | /* 0x28 - 1360x768@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 383 | { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 148250, 1360, 1408, |
| 384 | 1440, 1520, 0, 768, 771, 776, 813, 0, |
| 385 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 386 | /* 0x51 - 1366x768@60Hz */ |
| 387 | { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 85500, 1366, 1436, |
| 388 | 1579, 1792, 0, 768, 771, 774, 798, 0, |
| 389 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
| 390 | /* 0x56 - 1366x768@60Hz */ |
| 391 | { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 72000, 1366, 1380, |
| 392 | 1436, 1500, 0, 768, 769, 772, 800, 0, |
| 393 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 394 | /* 0x29 - 1400x1050@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 395 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 101000, 1400, 1448, |
| 396 | 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, |
| 397 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 398 | /* 0x2a - 1400x1050@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 399 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488, |
| 400 | 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, |
| 401 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 402 | /* 0x2b - 1400x1050@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 403 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504, |
| 404 | 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, |
| 405 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 406 | /* 0x2c - 1400x1050@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 407 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504, |
| 408 | 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, |
| 409 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 410 | /* 0x2d - 1400x1050@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 411 | { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 208000, 1400, 1448, |
| 412 | 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, |
| 413 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 414 | /* 0x2e - 1440x900@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 415 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 88750, 1440, 1488, |
| 416 | 1520, 1600, 0, 900, 903, 909, 926, 0, |
| 417 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 418 | /* 0x2f - 1440x900@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 419 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520, |
| 420 | 1672, 1904, 0, 900, 903, 909, 934, 0, |
| 421 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 422 | /* 0x30 - 1440x900@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 423 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536, |
| 424 | 1688, 1936, 0, 900, 903, 909, 942, 0, |
| 425 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 426 | /* 0x31 - 1440x900@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 427 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544, |
| 428 | 1696, 1952, 0, 900, 903, 909, 948, 0, |
| 429 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 430 | /* 0x32 - 1440x900@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 431 | { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 182750, 1440, 1488, |
| 432 | 1520, 1600, 0, 900, 903, 909, 953, 0, |
| 433 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 434 | /* 0x53 - 1600x900@60Hz */ |
| 435 | { DRM_MODE("1600x900", DRM_MODE_TYPE_DRIVER, 108000, 1600, 1624, |
| 436 | 1704, 1800, 0, 900, 901, 904, 1000, 0, |
| 437 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 438 | /* 0x33 - 1600x1200@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 439 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664, |
| 440 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 441 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 442 | /* 0x34 - 1600x1200@65Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 443 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664, |
| 444 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 445 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 446 | /* 0x35 - 1600x1200@70Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 447 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664, |
| 448 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 449 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 450 | /* 0x36 - 1600x1200@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 451 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 202500, 1600, 1664, |
| 452 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 453 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 454 | /* 0x37 - 1600x1200@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 455 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664, |
| 456 | 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, |
| 457 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 458 | /* 0x38 - 1600x1200@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 459 | { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 268250, 1600, 1648, |
| 460 | 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, |
| 461 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 462 | /* 0x39 - 1680x1050@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 463 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 119000, 1680, 1728, |
| 464 | 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, |
| 465 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 466 | /* 0x3a - 1680x1050@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 467 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784, |
| 468 | 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, |
| 469 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 470 | /* 0x3b - 1680x1050@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 471 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800, |
| 472 | 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, |
| 473 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 474 | /* 0x3c - 1680x1050@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 475 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808, |
| 476 | 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, |
| 477 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 478 | /* 0x3d - 1680x1050@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 479 | { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 245500, 1680, 1728, |
| 480 | 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, |
| 481 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 482 | /* 0x3e - 1792x1344@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 483 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920, |
| 484 | 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, |
| 485 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 486 | /* 0x3f - 1792x1344@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 487 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888, |
| 488 | 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, |
| 489 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 490 | /* 0x40 - 1792x1344@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 491 | { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 333250, 1792, 1840, |
| 492 | 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, |
| 493 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 494 | /* 0x41 - 1856x1392@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 495 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952, |
| 496 | 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, |
| 497 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 498 | /* 0x42 - 1856x1392@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 499 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984, |
Ville Syrjälä | fcf22d0 | 2015-04-02 17:02:09 +0300 | [diff] [blame] | 500 | 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 501 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 502 | /* 0x43 - 1856x1392@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 503 | { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 356500, 1856, 1904, |
| 504 | 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, |
| 505 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 506 | /* 0x52 - 1920x1080@60Hz */ |
| 507 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 508 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 509 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 510 | /* 0x44 - 1920x1200@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 511 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 154000, 1920, 1968, |
| 512 | 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, |
| 513 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 514 | /* 0x45 - 1920x1200@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 515 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056, |
| 516 | 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, |
| 517 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 518 | /* 0x46 - 1920x1200@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 519 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056, |
| 520 | 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, |
| 521 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 522 | /* 0x47 - 1920x1200@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 523 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064, |
| 524 | 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, |
| 525 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 526 | /* 0x48 - 1920x1200@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 527 | { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 317000, 1920, 1968, |
| 528 | 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, |
| 529 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 530 | /* 0x49 - 1920x1440@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 531 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048, |
| 532 | 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, |
| 533 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 534 | /* 0x4a - 1920x1440@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 535 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064, |
| 536 | 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, |
| 537 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 538 | /* 0x4b - 1920x1440@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 539 | { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 380500, 1920, 1968, |
| 540 | 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, |
| 541 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 542 | /* 0x54 - 2048x1152@60Hz */ |
| 543 | { DRM_MODE("2048x1152", DRM_MODE_TYPE_DRIVER, 162000, 2048, 2074, |
| 544 | 2154, 2250, 0, 1152, 1153, 1156, 1200, 0, |
| 545 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 546 | /* 0x4c - 2560x1600@60Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 547 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 268500, 2560, 2608, |
| 548 | 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, |
| 549 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 550 | /* 0x4d - 2560x1600@60Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 551 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752, |
| 552 | 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, |
| 553 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 554 | /* 0x4e - 2560x1600@75Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 555 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768, |
| 556 | 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, |
| 557 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 558 | /* 0x4f - 2560x1600@85Hz */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 559 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768, |
| 560 | 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, |
| 561 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, |
Ville Syrjälä | 24b856b | 2015-04-02 17:02:10 +0300 | [diff] [blame] | 562 | /* 0x50 - 2560x1600@120Hz RB */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 563 | { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 552750, 2560, 2608, |
| 564 | 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, |
| 565 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Ville Syrjälä | bfcd74d | 2015-04-02 17:02:11 +0300 | [diff] [blame] | 566 | /* 0x57 - 4096x2160@60Hz RB */ |
| 567 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556744, 4096, 4104, |
| 568 | 4136, 4176, 0, 2160, 2208, 2216, 2222, 0, |
| 569 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
| 570 | /* 0x58 - 4096x2160@59.94Hz RB */ |
| 571 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556188, 4096, 4104, |
| 572 | 4136, 4176, 0, 2160, 2208, 2216, 2222, 0, |
| 573 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 574 | }; |
| 575 | |
Ville Syrjälä | e7bfa5c | 2013-10-14 16:44:27 +0300 | [diff] [blame] | 576 | /* |
| 577 | * These more or less come from the DMT spec. The 720x400 modes are |
| 578 | * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75 |
| 579 | * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode |
| 580 | * should be 1152x870, again for the Mac, but instead we use the x864 DMT |
| 581 | * mode. |
| 582 | * |
| 583 | * The DMT modes have been fact-checked; the rest are mild guesses. |
| 584 | */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 585 | static const struct drm_display_mode edid_est_modes[] = { |
| 586 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840, |
| 587 | 968, 1056, 0, 600, 601, 605, 628, 0, |
| 588 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */ |
| 589 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824, |
| 590 | 896, 1024, 0, 600, 601, 603, 625, 0, |
| 591 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */ |
| 592 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656, |
| 593 | 720, 840, 0, 480, 481, 484, 500, 0, |
| 594 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */ |
| 595 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 596 | 704, 832, 0, 480, 489, 492, 520, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 597 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */ |
| 598 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704, |
| 599 | 768, 864, 0, 480, 483, 486, 525, 0, |
| 600 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */ |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 601 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 602 | 752, 800, 0, 480, 490, 492, 525, 0, |
| 603 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */ |
| 604 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738, |
| 605 | 846, 900, 0, 400, 421, 423, 449, 0, |
| 606 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */ |
| 607 | { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738, |
| 608 | 846, 900, 0, 400, 412, 414, 449, 0, |
| 609 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */ |
| 610 | { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, |
| 611 | 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, |
| 612 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */ |
Paul Parsons | 87707cf | 2016-04-02 11:08:06 +0100 | [diff] [blame] | 613 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 614 | 1136, 1312, 0, 768, 769, 772, 800, 0, |
| 615 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */ |
| 616 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, |
| 617 | 1184, 1328, 0, 768, 771, 777, 806, 0, |
| 618 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */ |
| 619 | { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048, |
| 620 | 1184, 1344, 0, 768, 771, 777, 806, 0, |
| 621 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */ |
| 622 | { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032, |
| 623 | 1208, 1264, 0, 768, 768, 776, 817, 0, |
| 624 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */ |
| 625 | { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864, |
| 626 | 928, 1152, 0, 624, 625, 628, 667, 0, |
| 627 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */ |
| 628 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816, |
| 629 | 896, 1056, 0, 600, 601, 604, 625, 0, |
| 630 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */ |
| 631 | { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856, |
| 632 | 976, 1040, 0, 600, 637, 643, 666, 0, |
| 633 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */ |
| 634 | { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216, |
| 635 | 1344, 1600, 0, 864, 865, 868, 900, 0, |
| 636 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */ |
| 637 | }; |
| 638 | |
| 639 | struct minimode { |
| 640 | short w; |
| 641 | short h; |
| 642 | short r; |
| 643 | short rb; |
| 644 | }; |
| 645 | |
| 646 | static const struct minimode est3_modes[] = { |
| 647 | /* byte 6 */ |
| 648 | { 640, 350, 85, 0 }, |
| 649 | { 640, 400, 85, 0 }, |
| 650 | { 720, 400, 85, 0 }, |
| 651 | { 640, 480, 85, 0 }, |
| 652 | { 848, 480, 60, 0 }, |
| 653 | { 800, 600, 85, 0 }, |
| 654 | { 1024, 768, 85, 0 }, |
| 655 | { 1152, 864, 75, 0 }, |
| 656 | /* byte 7 */ |
| 657 | { 1280, 768, 60, 1 }, |
| 658 | { 1280, 768, 60, 0 }, |
| 659 | { 1280, 768, 75, 0 }, |
| 660 | { 1280, 768, 85, 0 }, |
| 661 | { 1280, 960, 60, 0 }, |
| 662 | { 1280, 960, 85, 0 }, |
| 663 | { 1280, 1024, 60, 0 }, |
| 664 | { 1280, 1024, 85, 0 }, |
| 665 | /* byte 8 */ |
| 666 | { 1360, 768, 60, 0 }, |
| 667 | { 1440, 900, 60, 1 }, |
| 668 | { 1440, 900, 60, 0 }, |
| 669 | { 1440, 900, 75, 0 }, |
| 670 | { 1440, 900, 85, 0 }, |
| 671 | { 1400, 1050, 60, 1 }, |
| 672 | { 1400, 1050, 60, 0 }, |
| 673 | { 1400, 1050, 75, 0 }, |
| 674 | /* byte 9 */ |
| 675 | { 1400, 1050, 85, 0 }, |
| 676 | { 1680, 1050, 60, 1 }, |
| 677 | { 1680, 1050, 60, 0 }, |
| 678 | { 1680, 1050, 75, 0 }, |
| 679 | { 1680, 1050, 85, 0 }, |
| 680 | { 1600, 1200, 60, 0 }, |
| 681 | { 1600, 1200, 65, 0 }, |
| 682 | { 1600, 1200, 70, 0 }, |
| 683 | /* byte 10 */ |
| 684 | { 1600, 1200, 75, 0 }, |
| 685 | { 1600, 1200, 85, 0 }, |
| 686 | { 1792, 1344, 60, 0 }, |
Ville Syrjälä | c068b32 | 2013-10-14 16:44:25 +0300 | [diff] [blame] | 687 | { 1792, 1344, 75, 0 }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 688 | { 1856, 1392, 60, 0 }, |
| 689 | { 1856, 1392, 75, 0 }, |
| 690 | { 1920, 1200, 60, 1 }, |
| 691 | { 1920, 1200, 60, 0 }, |
| 692 | /* byte 11 */ |
| 693 | { 1920, 1200, 75, 0 }, |
| 694 | { 1920, 1200, 85, 0 }, |
| 695 | { 1920, 1440, 60, 0 }, |
| 696 | { 1920, 1440, 75, 0 }, |
| 697 | }; |
| 698 | |
| 699 | static const struct minimode extra_modes[] = { |
| 700 | { 1024, 576, 60, 0 }, |
| 701 | { 1366, 768, 60, 0 }, |
| 702 | { 1600, 900, 60, 0 }, |
| 703 | { 1680, 945, 60, 0 }, |
| 704 | { 1920, 1080, 60, 0 }, |
| 705 | { 2048, 1152, 60, 0 }, |
| 706 | { 2048, 1536, 60, 0 }, |
| 707 | }; |
| 708 | |
| 709 | /* |
| 710 | * Probably taken from CEA-861 spec. |
| 711 | * This table is converted from xorg's hw/xfree86/modes/xf86EdidModes.c. |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 712 | * |
| 713 | * Index using the VIC. |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 714 | */ |
| 715 | static const struct drm_display_mode edid_cea_modes[] = { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 716 | /* 0 - dummy, VICs start at 1 */ |
| 717 | { }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 718 | /* 1 - 640x480@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 719 | { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656, |
| 720 | 752, 800, 0, 480, 490, 492, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 721 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 722 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 723 | /* 2 - 720x480@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 724 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736, |
| 725 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 726 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 727 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 728 | /* 3 - 720x480@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 729 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736, |
| 730 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 731 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 732 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 733 | /* 4 - 1280x720@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 734 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 735 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 736 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 737 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 738 | /* 5 - 1920x1080i@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 739 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 740 | 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, |
| 741 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 742 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 743 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 744 | /* 6 - 720(1440)x480i@60Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 745 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 746 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 747 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 748 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 749 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 750 | /* 7 - 720(1440)x480i@60Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 751 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 752 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 753 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 754 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 755 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 756 | /* 8 - 720(1440)x240@60Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 757 | { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 758 | 801, 858, 0, 240, 244, 247, 262, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 759 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 760 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 761 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 762 | /* 9 - 720(1440)x240@60Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 763 | { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739, |
| 764 | 801, 858, 0, 240, 244, 247, 262, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 765 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 766 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 767 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 768 | /* 10 - 2880x480i@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 769 | { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 770 | 3204, 3432, 0, 480, 488, 494, 525, 0, |
| 771 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 772 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 773 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 774 | /* 11 - 2880x480i@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 775 | { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 776 | 3204, 3432, 0, 480, 488, 494, 525, 0, |
| 777 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 778 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 779 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 780 | /* 12 - 2880x240@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 781 | { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 782 | 3204, 3432, 0, 240, 244, 247, 262, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 783 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 784 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 785 | /* 13 - 2880x240@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 786 | { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956, |
| 787 | 3204, 3432, 0, 240, 244, 247, 262, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 788 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 789 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 790 | /* 14 - 1440x480@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 791 | { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472, |
| 792 | 1596, 1716, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 793 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 794 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 795 | /* 15 - 1440x480@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 796 | { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472, |
| 797 | 1596, 1716, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 798 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 799 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 800 | /* 16 - 1920x1080@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 801 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 802 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 803 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 804 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 805 | /* 17 - 720x576@50Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 806 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 807 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 808 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 809 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 810 | /* 18 - 720x576@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 811 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 812 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 813 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 814 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 815 | /* 19 - 1280x720@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 816 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720, |
| 817 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 818 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 819 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 820 | /* 20 - 1920x1080i@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 821 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 822 | 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, |
| 823 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 824 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 825 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 826 | /* 21 - 720(1440)x576i@50Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 827 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 828 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 829 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 830 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 831 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 832 | /* 22 - 720(1440)x576i@50Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 833 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 834 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 835 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 836 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 837 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 838 | /* 23 - 720(1440)x288@50Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 839 | { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 840 | 795, 864, 0, 288, 290, 293, 312, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 841 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 842 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 843 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 844 | /* 24 - 720(1440)x288@50Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 845 | { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732, |
| 846 | 795, 864, 0, 288, 290, 293, 312, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 847 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 848 | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 849 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 850 | /* 25 - 2880x576i@50Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 851 | { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 852 | 3180, 3456, 0, 576, 580, 586, 625, 0, |
| 853 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 854 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 855 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 856 | /* 26 - 2880x576i@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 857 | { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 858 | 3180, 3456, 0, 576, 580, 586, 625, 0, |
| 859 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 860 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 861 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 862 | /* 27 - 2880x288@50Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 863 | { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 864 | 3180, 3456, 0, 288, 290, 293, 312, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 865 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 866 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 867 | /* 28 - 2880x288@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 868 | { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928, |
| 869 | 3180, 3456, 0, 288, 290, 293, 312, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 870 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 871 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 872 | /* 29 - 1440x576@50Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 873 | { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464, |
| 874 | 1592, 1728, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 875 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 876 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 877 | /* 30 - 1440x576@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 878 | { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464, |
| 879 | 1592, 1728, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 880 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 881 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 882 | /* 31 - 1920x1080@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 883 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 884 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 885 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 886 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 887 | /* 32 - 1920x1080@24Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 888 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558, |
| 889 | 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 890 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 891 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 892 | /* 33 - 1920x1080@25Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 893 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 894 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 895 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 896 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 897 | /* 34 - 1920x1080@30Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 898 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 899 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 900 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 901 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 902 | /* 35 - 2880x480@60Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 903 | { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944, |
| 904 | 3192, 3432, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 905 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 906 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 907 | /* 36 - 2880x480@60Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 908 | { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944, |
| 909 | 3192, 3432, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 910 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 911 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 912 | /* 37 - 2880x576@50Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 913 | { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928, |
| 914 | 3184, 3456, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 915 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 916 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 917 | /* 38 - 2880x576@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 918 | { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928, |
| 919 | 3184, 3456, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 920 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 921 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 922 | /* 39 - 1920x1080i@50Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 923 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 72000, 1920, 1952, |
| 924 | 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, |
| 925 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 926 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 927 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 928 | /* 40 - 1920x1080i@100Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 929 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 930 | 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, |
| 931 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 932 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 933 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 934 | /* 41 - 1280x720@100Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 935 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720, |
| 936 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 937 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 938 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 939 | /* 42 - 720x576@100Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 940 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 941 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 942 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 943 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 944 | /* 43 - 720x576@100Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 945 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 946 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 947 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 948 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 949 | /* 44 - 720(1440)x576i@100Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 950 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 951 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 952 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 953 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 954 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 955 | /* 45 - 720(1440)x576i@100Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 956 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732, |
| 957 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 958 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 959 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 960 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 961 | /* 46 - 1920x1080i@120Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 962 | { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 963 | 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, |
| 964 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 965 | DRM_MODE_FLAG_INTERLACE), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 966 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 967 | /* 47 - 1280x720@120Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 968 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390, |
| 969 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 970 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 971 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 972 | /* 48 - 720x480@120Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 973 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736, |
| 974 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 975 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 976 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 977 | /* 49 - 720x480@120Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 978 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736, |
| 979 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 980 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 981 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 982 | /* 50 - 720(1440)x480i@120Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 983 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739, |
| 984 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 985 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 986 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 987 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 988 | /* 51 - 720(1440)x480i@120Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 989 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739, |
| 990 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 991 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 992 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 993 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 994 | /* 52 - 720x576@200Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 995 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732, |
| 996 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 997 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 998 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 999 | /* 53 - 720x576@200Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1000 | { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732, |
| 1001 | 796, 864, 0, 576, 581, 586, 625, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1002 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1003 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1004 | /* 54 - 720(1440)x576i@200Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 1005 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 1006 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1007 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1008 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1009 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1010 | /* 55 - 720(1440)x576i@200Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 1011 | { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732, |
| 1012 | 795, 864, 0, 576, 580, 586, 625, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1013 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1014 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1015 | .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1016 | /* 56 - 720x480@240Hz 4:3 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1017 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736, |
| 1018 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1019 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1020 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1021 | /* 57 - 720x480@240Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1022 | { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736, |
| 1023 | 798, 858, 0, 480, 489, 495, 525, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1024 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1025 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1026 | /* 58 - 720(1440)x480i@240Hz 4:3 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 1027 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739, |
| 1028 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1029 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1030 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1031 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1032 | /* 59 - 720(1440)x480i@240Hz 16:9 */ |
Clint Taylor | fb01d28 | 2014-09-02 17:03:35 -0700 | [diff] [blame] | 1033 | { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739, |
| 1034 | 801, 858, 0, 480, 488, 494, 525, 0, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1035 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC | |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1036 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1037 | .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1038 | /* 60 - 1280x720@24Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1039 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040, |
| 1040 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1041 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1042 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1043 | /* 61 - 1280x720@25Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1044 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700, |
| 1045 | 3740, 3960, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1046 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1047 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1048 | /* 62 - 1280x720@30Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1049 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040, |
| 1050 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1051 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 1052 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1053 | /* 63 - 1920x1080@120Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1054 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008, |
| 1055 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1056 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1057 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1058 | /* 64 - 1920x1080@100Hz 16:9 */ |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1059 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448, |
Clint Taylor | 8f0e490 | 2016-08-15 10:31:28 -0700 | [diff] [blame] | 1060 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
Ville Syrjälä | ee7925b | 2013-04-24 19:07:17 +0300 | [diff] [blame] | 1061 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1062 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
| 1063 | /* 65 - 1280x720@24Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1064 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040, |
| 1065 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1066 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1067 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1068 | /* 66 - 1280x720@25Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1069 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700, |
| 1070 | 3740, 3960, 0, 720, 725, 730, 750, 0, |
| 1071 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1072 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1073 | /* 67 - 1280x720@30Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1074 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040, |
| 1075 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1076 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1077 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1078 | /* 68 - 1280x720@50Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1079 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720, |
| 1080 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
| 1081 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1082 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1083 | /* 69 - 1280x720@60Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1084 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390, |
| 1085 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 1086 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1087 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1088 | /* 70 - 1280x720@100Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1089 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720, |
| 1090 | 1760, 1980, 0, 720, 725, 730, 750, 0, |
| 1091 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1092 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1093 | /* 71 - 1280x720@120Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1094 | { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390, |
| 1095 | 1430, 1650, 0, 720, 725, 730, 750, 0, |
| 1096 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1097 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1098 | /* 72 - 1920x1080@24Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1099 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558, |
| 1100 | 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, |
| 1101 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1102 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1103 | /* 73 - 1920x1080@25Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1104 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448, |
| 1105 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1106 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1107 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1108 | /* 74 - 1920x1080@30Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1109 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008, |
| 1110 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1111 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1112 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1113 | /* 75 - 1920x1080@50Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1114 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448, |
| 1115 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1116 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1117 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1118 | /* 76 - 1920x1080@60Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1119 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008, |
| 1120 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1121 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1122 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1123 | /* 77 - 1920x1080@100Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1124 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448, |
| 1125 | 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, |
| 1126 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1127 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1128 | /* 78 - 1920x1080@120Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1129 | { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008, |
| 1130 | 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, |
| 1131 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1132 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1133 | /* 79 - 1680x720@24Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1134 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 3040, |
| 1135 | 3080, 3300, 0, 720, 725, 730, 750, 0, |
| 1136 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1137 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1138 | /* 80 - 1680x720@25Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1139 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2908, |
| 1140 | 2948, 3168, 0, 720, 725, 730, 750, 0, |
| 1141 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1142 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1143 | /* 81 - 1680x720@30Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1144 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2380, |
| 1145 | 2420, 2640, 0, 720, 725, 730, 750, 0, |
| 1146 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1147 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1148 | /* 82 - 1680x720@50Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1149 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 82500, 1680, 1940, |
| 1150 | 1980, 2200, 0, 720, 725, 730, 750, 0, |
| 1151 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1152 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1153 | /* 83 - 1680x720@60Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1154 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 99000, 1680, 1940, |
| 1155 | 1980, 2200, 0, 720, 725, 730, 750, 0, |
| 1156 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1157 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1158 | /* 84 - 1680x720@100Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1159 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 165000, 1680, 1740, |
| 1160 | 1780, 2000, 0, 720, 725, 730, 825, 0, |
| 1161 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1162 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1163 | /* 85 - 1680x720@120Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1164 | { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 198000, 1680, 1740, |
| 1165 | 1780, 2000, 0, 720, 725, 730, 825, 0, |
| 1166 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1167 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1168 | /* 86 - 2560x1080@24Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1169 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 99000, 2560, 3558, |
| 1170 | 3602, 3750, 0, 1080, 1084, 1089, 1100, 0, |
| 1171 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1172 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1173 | /* 87 - 2560x1080@25Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1174 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 90000, 2560, 3008, |
| 1175 | 3052, 3200, 0, 1080, 1084, 1089, 1125, 0, |
| 1176 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1177 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1178 | /* 88 - 2560x1080@30Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1179 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 118800, 2560, 3328, |
| 1180 | 3372, 3520, 0, 1080, 1084, 1089, 1125, 0, |
| 1181 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1182 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1183 | /* 89 - 2560x1080@50Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1184 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 185625, 2560, 3108, |
| 1185 | 3152, 3300, 0, 1080, 1084, 1089, 1125, 0, |
| 1186 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1187 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1188 | /* 90 - 2560x1080@60Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1189 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 198000, 2560, 2808, |
| 1190 | 2852, 3000, 0, 1080, 1084, 1089, 1100, 0, |
| 1191 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1192 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1193 | /* 91 - 2560x1080@100Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1194 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 371250, 2560, 2778, |
| 1195 | 2822, 2970, 0, 1080, 1084, 1089, 1250, 0, |
| 1196 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1197 | .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1198 | /* 92 - 2560x1080@120Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1199 | { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 495000, 2560, 3108, |
| 1200 | 3152, 3300, 0, 1080, 1084, 1089, 1250, 0, |
| 1201 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1202 | .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1203 | /* 93 - 3840x2160@24Hz 16:9 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1204 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, |
| 1205 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1206 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1207 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1208 | /* 94 - 3840x2160@25Hz 16:9 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1209 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896, |
| 1210 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1211 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1212 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1213 | /* 95 - 3840x2160@30Hz 16:9 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1214 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016, |
| 1215 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1216 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1217 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1218 | /* 96 - 3840x2160@50Hz 16:9 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1219 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896, |
| 1220 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1221 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1222 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1223 | /* 97 - 3840x2160@60Hz 16:9 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1224 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, |
| 1225 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1226 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1227 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1228 | /* 98 - 4096x2160@24Hz 256:135 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1229 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5116, |
| 1230 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1231 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1232 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1233 | /* 99 - 4096x2160@25Hz 256:135 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1234 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5064, |
| 1235 | 5152, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1236 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1237 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1238 | /* 100 - 4096x2160@30Hz 256:135 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1239 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 4184, |
| 1240 | 4272, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1241 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1242 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1243 | /* 101 - 4096x2160@50Hz 256:135 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1244 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 5064, |
| 1245 | 5152, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1246 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1247 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1248 | /* 102 - 4096x2160@60Hz 256:135 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1249 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184, |
| 1250 | 4272, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1251 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1252 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1253 | /* 103 - 3840x2160@24Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1254 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116, |
| 1255 | 5204, 5500, 0, 2160, 2168, 2178, 2250, 0, |
| 1256 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1257 | .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1258 | /* 104 - 3840x2160@25Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1259 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896, |
| 1260 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1261 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1262 | .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1263 | /* 105 - 3840x2160@30Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1264 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016, |
| 1265 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1266 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1267 | .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1268 | /* 106 - 3840x2160@50Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1269 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896, |
| 1270 | 4984, 5280, 0, 2160, 2168, 2178, 2250, 0, |
| 1271 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1272 | .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Ville Syrjälä | 7869196 | 2018-05-24 22:20:35 +0300 | [diff] [blame] | 1273 | /* 107 - 3840x2160@60Hz 64:27 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 1274 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, |
| 1275 | 4104, 4400, 0, 2160, 2168, 2178, 2250, 0, |
| 1276 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1277 | .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }, |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1278 | }; |
| 1279 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1280 | /* |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 1281 | * HDMI 1.4 4k modes. Index using the VIC. |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1282 | */ |
| 1283 | static const struct drm_display_mode edid_4k_modes[] = { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 1284 | /* 0 - dummy, VICs start at 1 */ |
| 1285 | { }, |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 1286 | /* 1 - 3840x2160@30Hz */ |
| 1287 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1288 | 3840, 4016, 4104, 4400, 0, |
| 1289 | 2160, 2168, 2178, 2250, 0, |
| 1290 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1291 | .vrefresh = 30, }, |
| 1292 | /* 2 - 3840x2160@25Hz */ |
| 1293 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1294 | 3840, 4896, 4984, 5280, 0, |
| 1295 | 2160, 2168, 2178, 2250, 0, |
| 1296 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1297 | .vrefresh = 25, }, |
| 1298 | /* 3 - 3840x2160@24Hz */ |
| 1299 | { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1300 | 3840, 5116, 5204, 5500, 0, |
| 1301 | 2160, 2168, 2178, 2250, 0, |
| 1302 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1303 | .vrefresh = 24, }, |
| 1304 | /* 4 - 4096x2160@24Hz (SMPTE) */ |
| 1305 | { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, |
| 1306 | 4096, 5116, 5204, 5500, 0, |
| 1307 | 2160, 2168, 2178, 2250, 0, |
| 1308 | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), |
| 1309 | .vrefresh = 24, }, |
| 1310 | }; |
| 1311 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1312 | /*** DDC fetch and block validation ***/ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1313 | |
Adam Jackson | 083ae05 | 2009-09-23 17:30:45 -0400 | [diff] [blame] | 1314 | static const u8 edid_header[] = { |
| 1315 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 |
| 1316 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1317 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1318 | /** |
| 1319 | * drm_edid_header_is_valid - sanity check the header of the base EDID block |
| 1320 | * @raw_edid: pointer to raw base EDID block |
| 1321 | * |
| 1322 | * Sanity check the header of the base EDID block. |
| 1323 | * |
| 1324 | * 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] | 1325 | */ |
| 1326 | int drm_edid_header_is_valid(const u8 *raw_edid) |
| 1327 | { |
| 1328 | int i, score = 0; |
| 1329 | |
| 1330 | for (i = 0; i < sizeof(edid_header); i++) |
| 1331 | if (raw_edid[i] == edid_header[i]) |
| 1332 | score++; |
| 1333 | |
| 1334 | return score; |
| 1335 | } |
| 1336 | EXPORT_SYMBOL(drm_edid_header_is_valid); |
| 1337 | |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 1338 | static int edid_fixup __read_mostly = 6; |
| 1339 | module_param_named(edid_fixup, edid_fixup, int, 0400); |
| 1340 | MODULE_PARM_DESC(edid_fixup, |
| 1341 | "Minimum number of valid EDID header bytes (0-8, default 6)"); |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 1342 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1343 | static void drm_get_displayid(struct drm_connector *connector, |
| 1344 | struct edid *edid); |
Dave Airlie | da9df2f | 2014-12-11 10:12:57 +1000 | [diff] [blame] | 1345 | |
Stefan Brüns | c465bbc | 2014-11-30 19:57:43 +0100 | [diff] [blame] | 1346 | static int drm_edid_block_checksum(const u8 *raw_edid) |
| 1347 | { |
| 1348 | int i; |
| 1349 | u8 csum = 0; |
| 1350 | for (i = 0; i < EDID_LENGTH; i++) |
| 1351 | csum += raw_edid[i]; |
| 1352 | |
| 1353 | return csum; |
| 1354 | } |
| 1355 | |
Stefan Brüns | d6885d6 | 2014-11-30 19:57:41 +0100 | [diff] [blame] | 1356 | static bool drm_edid_is_zero(const u8 *in_edid, int length) |
| 1357 | { |
| 1358 | if (memchr_inv(in_edid, 0, length)) |
| 1359 | return false; |
| 1360 | |
| 1361 | return true; |
| 1362 | } |
| 1363 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1364 | /** |
| 1365 | * drm_edid_block_valid - Sanity check the EDID block (base or extension) |
| 1366 | * @raw_edid: pointer to raw EDID block |
| 1367 | * @block: type of block to validate (0 for base, extension otherwise) |
| 1368 | * @print_bad_edid: if true, dump bad EDID blocks to the console |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1369 | * @edid_corrupt: if true, the header or checksum is invalid |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1370 | * |
| 1371 | * Validate a base or extension EDID block and optionally dump bad blocks to |
| 1372 | * the console. |
| 1373 | * |
| 1374 | * Return: True if the block is valid, false otherwise. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1375 | */ |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1376 | bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
| 1377 | bool *edid_corrupt) |
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 | u8 csum; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1380 | struct edid *edid = (struct edid *)raw_edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1381 | |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1382 | if (WARN_ON(!raw_edid)) |
| 1383 | return false; |
| 1384 | |
Adam Jackson | 47819ba | 2012-05-30 16:42:39 -0400 | [diff] [blame] | 1385 | if (edid_fixup > 8 || edid_fixup < 0) |
| 1386 | edid_fixup = 6; |
| 1387 | |
Adam Jackson | f89ec8a | 2012-04-16 10:40:08 -0400 | [diff] [blame] | 1388 | if (block == 0) { |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 1389 | int score = drm_edid_header_is_valid(raw_edid); |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1390 | if (score == 8) { |
| 1391 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1392 | *edid_corrupt = false; |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1393 | } else if (score >= edid_fixup) { |
| 1394 | /* Displayport Link CTS Core 1.2 rev1.1 test 4.2.2.6 |
| 1395 | * The corrupt flag needs to be set here otherwise, the |
| 1396 | * fix-up code here will correct the problem, the |
| 1397 | * checksum is correct and the test fails |
| 1398 | */ |
| 1399 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1400 | *edid_corrupt = true; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1401 | DRM_DEBUG("Fixing EDID header, your hardware may be failing\n"); |
| 1402 | memcpy(raw_edid, edid_header, sizeof(edid_header)); |
| 1403 | } else { |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1404 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1405 | *edid_corrupt = true; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1406 | goto bad; |
| 1407 | } |
| 1408 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1409 | |
Stefan Brüns | c465bbc | 2014-11-30 19:57:43 +0100 | [diff] [blame] | 1410 | csum = drm_edid_block_checksum(raw_edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1411 | if (csum) { |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1412 | if (edid_corrupt) |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1413 | *edid_corrupt = true; |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1414 | |
Adam Jackson | 4a638b4 | 2010-05-25 16:33:09 -0400 | [diff] [blame] | 1415 | /* allow CEA to slide through, switches mangle this */ |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1416 | if (raw_edid[0] == CEA_EXT) { |
| 1417 | DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum); |
| 1418 | DRM_DEBUG("Assuming a KVM switch modified the CEA block but left the original checksum\n"); |
| 1419 | } else { |
| 1420 | if (print_bad_edid) |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1421 | DRM_NOTE("EDID checksum is invalid, remainder is %d\n", csum); |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1422 | |
Adam Jackson | 4a638b4 | 2010-05-25 16:33:09 -0400 | [diff] [blame] | 1423 | goto bad; |
Tomeu Vizoso | 82d7535 | 2016-12-08 14:11:56 +0100 | [diff] [blame] | 1424 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1425 | } |
| 1426 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1427 | /* per-block-type checks */ |
| 1428 | switch (raw_edid[0]) { |
| 1429 | case 0: /* base */ |
| 1430 | if (edid->version != 1) { |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1431 | 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] | 1432 | goto bad; |
| 1433 | } |
Adam Jackson | 862b89c | 2009-11-23 14:23:06 -0500 | [diff] [blame] | 1434 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1435 | if (edid->revision > 4) |
| 1436 | DRM_DEBUG("EDID minor > 4, assuming backward compatibility\n"); |
| 1437 | break; |
| 1438 | |
| 1439 | default: |
| 1440 | break; |
| 1441 | } |
Adam Jackson | 47ee4ccf | 2009-11-23 14:23:05 -0500 | [diff] [blame] | 1442 | |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1443 | return true; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1444 | |
| 1445 | bad: |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1446 | if (print_bad_edid) { |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1447 | if (drm_edid_is_zero(raw_edid, EDID_LENGTH)) { |
Joe Perches | 499447d | 2017-02-28 04:55:53 -0800 | [diff] [blame] | 1448 | pr_notice("EDID block is all zeroes\n"); |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1449 | } else { |
Joe Perches | 499447d | 2017-02-28 04:55:53 -0800 | [diff] [blame] | 1450 | pr_notice("Raw EDID:\n"); |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 1451 | print_hex_dump(KERN_NOTICE, |
| 1452 | " \t", DUMP_PREFIX_NONE, 16, 1, |
| 1453 | raw_edid, EDID_LENGTH, false); |
Stefan Brüns | da4c07b | 2014-11-30 19:57:42 +0100 | [diff] [blame] | 1454 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1455 | } |
Seung-Woo Kim | fe2ef78 | 2013-07-02 17:57:04 +0900 | [diff] [blame] | 1456 | return false; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1457 | } |
Carsten Emde | da0df92 | 2012-03-18 22:37:33 +0100 | [diff] [blame] | 1458 | EXPORT_SYMBOL(drm_edid_block_valid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1459 | |
| 1460 | /** |
| 1461 | * drm_edid_is_valid - sanity check EDID data |
| 1462 | * @edid: EDID data |
| 1463 | * |
| 1464 | * Sanity-check an entire EDID record (including extensions) |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1465 | * |
| 1466 | * Return: True if the EDID data is valid, false otherwise. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1467 | */ |
| 1468 | bool drm_edid_is_valid(struct edid *edid) |
| 1469 | { |
| 1470 | int i; |
| 1471 | u8 *raw = (u8 *)edid; |
| 1472 | |
| 1473 | if (!edid) |
| 1474 | return false; |
| 1475 | |
| 1476 | for (i = 0; i <= edid->extensions; i++) |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1477 | if (!drm_edid_block_valid(raw + i * EDID_LENGTH, i, true, NULL)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1478 | return false; |
| 1479 | |
| 1480 | return true; |
| 1481 | } |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 1482 | EXPORT_SYMBOL(drm_edid_is_valid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1483 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1484 | #define DDC_SEGMENT_ADDR 0x30 |
| 1485 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1486 | * drm_do_probe_ddc_edid() - get EDID information via I2C |
Thierry Reding | 7c58e87 | 2014-12-03 16:52:18 +0100 | [diff] [blame] | 1487 | * @data: I2C device adapter |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 1488 | * @buf: EDID data buffer to be filled |
| 1489 | * @block: 128 byte EDID block to start fetching from |
| 1490 | * @len: EDID data buffer length to fetch |
| 1491 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1492 | * Try to fetch EDID information by calling I2C driver functions. |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 1493 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1494 | * Return: 0 on success or -1 on failure. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1495 | */ |
| 1496 | static int |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1497 | 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] | 1498 | { |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1499 | struct i2c_adapter *adapter = data; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1500 | unsigned char start = block * EDID_LENGTH; |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1501 | unsigned char segment = block >> 1; |
| 1502 | unsigned char xfers = segment ? 3 : 2; |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1503 | int ret, retries = 5; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1504 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1505 | /* |
| 1506 | * The core I2C driver will automatically retry the transfer if the |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1507 | * adapter reports EAGAIN. However, we find that bit-banging transfers |
| 1508 | * are susceptible to errors under a heavily loaded machine and |
| 1509 | * generate spurious NAKs and timeouts. Retrying the transfer |
| 1510 | * of the individual block a few times seems to overcome this. |
| 1511 | */ |
| 1512 | do { |
| 1513 | struct i2c_msg msgs[] = { |
| 1514 | { |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1515 | .addr = DDC_SEGMENT_ADDR, |
| 1516 | .flags = 0, |
| 1517 | .len = 1, |
| 1518 | .buf = &segment, |
| 1519 | }, { |
Chris Wilson | 4819d2e | 2011-03-15 11:04:41 +0000 | [diff] [blame] | 1520 | .addr = DDC_ADDR, |
| 1521 | .flags = 0, |
| 1522 | .len = 1, |
| 1523 | .buf = &start, |
| 1524 | }, { |
| 1525 | .addr = DDC_ADDR, |
| 1526 | .flags = I2C_M_RD, |
| 1527 | .len = len, |
| 1528 | .buf = buf, |
| 1529 | } |
| 1530 | }; |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1531 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1532 | /* |
| 1533 | * Avoid sending the segment addr to not upset non-compliant |
| 1534 | * DDC monitors. |
| 1535 | */ |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1536 | ret = i2c_transfer(adapter, &msgs[3 - xfers], xfers); |
| 1537 | |
Eugeni Dodonov | 9292f37 | 2012-01-05 09:34:28 -0200 | [diff] [blame] | 1538 | if (ret == -ENXIO) { |
| 1539 | DRM_DEBUG_KMS("drm: skipping non-existent adapter %s\n", |
| 1540 | adapter->name); |
| 1541 | break; |
| 1542 | } |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1543 | } while (ret != xfers && --retries); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1544 | |
Shirish S | cd004b3 | 2012-08-30 07:04:06 +0000 | [diff] [blame] | 1545 | return ret == xfers ? 0 : -1; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1546 | } |
| 1547 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1548 | static void connector_bad_edid(struct drm_connector *connector, |
| 1549 | u8 *edid, int num_blocks) |
| 1550 | { |
| 1551 | int i; |
| 1552 | |
| 1553 | if (connector->bad_edid_counter++ && !(drm_debug & DRM_UT_KMS)) |
| 1554 | return; |
| 1555 | |
| 1556 | dev_warn(connector->dev->dev, |
| 1557 | "%s: EDID is invalid:\n", |
| 1558 | connector->name); |
| 1559 | for (i = 0; i < num_blocks; i++) { |
| 1560 | u8 *block = edid + i * EDID_LENGTH; |
| 1561 | char prefix[20]; |
| 1562 | |
| 1563 | if (drm_edid_is_zero(block, EDID_LENGTH)) |
| 1564 | sprintf(prefix, "\t[%02x] ZERO ", i); |
| 1565 | else if (!drm_edid_block_valid(block, i, false, NULL)) |
| 1566 | sprintf(prefix, "\t[%02x] BAD ", i); |
| 1567 | else |
| 1568 | sprintf(prefix, "\t[%02x] GOOD ", i); |
| 1569 | |
| 1570 | print_hex_dump(KERN_WARNING, |
| 1571 | prefix, DUMP_PREFIX_NONE, 16, 1, |
| 1572 | block, EDID_LENGTH, false); |
| 1573 | } |
| 1574 | } |
| 1575 | |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1576 | /** |
| 1577 | * drm_do_get_edid - get EDID data using a custom EDID block read function |
| 1578 | * @connector: connector we're probing |
| 1579 | * @get_edid_block: EDID block read function |
| 1580 | * @data: private data passed to the block read function |
| 1581 | * |
| 1582 | * When the I2C adapter connected to the DDC bus is hidden behind a device that |
| 1583 | * exposes a different interface to read EDID blocks this function can be used |
| 1584 | * to get EDID data using a custom block read function. |
| 1585 | * |
| 1586 | * As in the general case the DDC bus is accessible by the kernel at the I2C |
| 1587 | * level, drivers must make all reasonable efforts to expose it as an I2C |
| 1588 | * adapter and use drm_get_edid() instead of abusing this function. |
| 1589 | * |
Jani Nikula | 53fd40a | 2017-09-12 11:19:26 +0300 | [diff] [blame] | 1590 | * The EDID may be overridden using debugfs override_edid or firmare EDID |
| 1591 | * (drm_load_edid_firmware() and drm.edid_firmware parameter), in this priority |
| 1592 | * order. Having either of them bypasses actual EDID reads. |
| 1593 | * |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1594 | * Return: Pointer to valid EDID or NULL if we couldn't find any. |
| 1595 | */ |
| 1596 | struct edid *drm_do_get_edid(struct drm_connector *connector, |
| 1597 | int (*get_edid_block)(void *data, u8 *buf, unsigned int block, |
| 1598 | size_t len), |
| 1599 | void *data) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1600 | { |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1601 | int i, j = 0, valid_extensions = 0; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1602 | u8 *edid, *new; |
Jani Nikula | 53fd40a | 2017-09-12 11:19:26 +0300 | [diff] [blame] | 1603 | struct edid *override = NULL; |
| 1604 | |
| 1605 | if (connector->override_edid) |
Ville Syrjälä | 11b83e3 | 2018-02-23 21:25:02 +0200 | [diff] [blame] | 1606 | override = drm_edid_duplicate(connector->edid_blob_ptr->data); |
Jani Nikula | 53fd40a | 2017-09-12 11:19:26 +0300 | [diff] [blame] | 1607 | |
| 1608 | if (!override) |
| 1609 | override = drm_load_edid_firmware(connector); |
| 1610 | |
| 1611 | if (!IS_ERR_OR_NULL(override)) |
| 1612 | return override; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1613 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1614 | if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1615 | return NULL; |
| 1616 | |
| 1617 | /* base block fetch */ |
| 1618 | for (i = 0; i < 4; i++) { |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1619 | if (get_edid_block(data, edid, 0, EDID_LENGTH)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1620 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1621 | if (drm_edid_block_valid(edid, 0, false, |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1622 | &connector->edid_corrupt)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1623 | break; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1624 | if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1625 | connector->null_edid_counter++; |
| 1626 | goto carp; |
| 1627 | } |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1628 | } |
| 1629 | if (i == 4) |
| 1630 | goto carp; |
| 1631 | |
| 1632 | /* if there's no extensions, we're done */ |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1633 | valid_extensions = edid[0x7e]; |
| 1634 | if (valid_extensions == 0) |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1635 | return (struct edid *)edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1636 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1637 | new = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1638 | if (!new) |
| 1639 | goto out; |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1640 | edid = new; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1641 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1642 | for (j = 1; j <= edid[0x7e]; j++) { |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1643 | u8 *block = edid + j * EDID_LENGTH; |
Chris Wilson | a28187c | 2016-10-17 09:35:13 +0100 | [diff] [blame] | 1644 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1645 | for (i = 0; i < 4; i++) { |
Chris Wilson | a28187c | 2016-10-17 09:35:13 +0100 | [diff] [blame] | 1646 | if (get_edid_block(data, block, j, EDID_LENGTH)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1647 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1648 | if (drm_edid_block_valid(block, j, false, NULL)) |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1649 | break; |
| 1650 | } |
Maarten Lankhorst | f934ec8c | 2013-01-29 14:27:39 +0100 | [diff] [blame] | 1651 | |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1652 | if (i == 4) |
| 1653 | valid_extensions--; |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1654 | } |
| 1655 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1656 | if (valid_extensions != edid[0x7e]) { |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1657 | u8 *base; |
| 1658 | |
| 1659 | connector_bad_edid(connector, edid, edid[0x7e] + 1); |
| 1660 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1661 | edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions; |
| 1662 | edid[0x7e] = valid_extensions; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1663 | |
Kees Cook | 6da2ec5 | 2018-06-12 13:55:00 -0700 | [diff] [blame] | 1664 | new = kmalloc_array(valid_extensions + 1, EDID_LENGTH, |
| 1665 | GFP_KERNEL); |
Sam Tygier | 0ea75e2 | 2010-09-23 10:11:01 +0100 | [diff] [blame] | 1666 | if (!new) |
| 1667 | goto out; |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1668 | |
| 1669 | base = new; |
| 1670 | for (i = 0; i <= edid[0x7e]; i++) { |
| 1671 | u8 *block = edid + i * EDID_LENGTH; |
| 1672 | |
| 1673 | if (!drm_edid_block_valid(block, i, false, NULL)) |
| 1674 | continue; |
| 1675 | |
| 1676 | memcpy(base, block, EDID_LENGTH); |
| 1677 | base += EDID_LENGTH; |
| 1678 | } |
| 1679 | |
| 1680 | kfree(edid); |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1681 | edid = new; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1682 | } |
| 1683 | |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1684 | return (struct edid *)edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1685 | |
| 1686 | carp: |
Chris Wilson | 14544d0 | 2016-10-24 12:38:21 +0100 | [diff] [blame] | 1687 | connector_bad_edid(connector, edid, 1); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1688 | out: |
Chris Wilson | f14f368 | 2016-10-17 09:35:12 +0100 | [diff] [blame] | 1689 | kfree(edid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1690 | return NULL; |
| 1691 | } |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1692 | EXPORT_SYMBOL_GPL(drm_do_get_edid); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1693 | |
| 1694 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1695 | * drm_probe_ddc() - probe DDC presence |
| 1696 | * @adapter: I2C adapter to probe |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1697 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1698 | * Return: True on success, false on failure. |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1699 | */ |
Adam Jackson | fbff469 | 2012-09-18 10:58:47 -0400 | [diff] [blame] | 1700 | bool |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1701 | drm_probe_ddc(struct i2c_adapter *adapter) |
| 1702 | { |
| 1703 | unsigned char out; |
| 1704 | |
| 1705 | return (drm_do_probe_ddc_edid(adapter, &out, 0, 1) == 0); |
| 1706 | } |
Adam Jackson | fbff469 | 2012-09-18 10:58:47 -0400 | [diff] [blame] | 1707 | EXPORT_SYMBOL(drm_probe_ddc); |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1708 | |
| 1709 | /** |
| 1710 | * drm_get_edid - get EDID data, if available |
| 1711 | * @connector: connector we're probing |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1712 | * @adapter: I2C adapter to use for DDC |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1713 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1714 | * 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] | 1715 | * attach it to the connector. |
| 1716 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1717 | * 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] | 1718 | */ |
| 1719 | struct edid *drm_get_edid(struct drm_connector *connector, |
| 1720 | struct i2c_adapter *adapter) |
| 1721 | { |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1722 | struct edid *edid; |
| 1723 | |
Jani Nikula | 15f080f | 2017-02-17 17:20:53 +0200 | [diff] [blame] | 1724 | if (connector->force == DRM_FORCE_OFF) |
| 1725 | return NULL; |
| 1726 | |
| 1727 | if (connector->force == DRM_FORCE_UNSPECIFIED && !drm_probe_ddc(adapter)) |
Lars-Peter Clausen | 18df89f | 2012-04-27 11:11:58 +0200 | [diff] [blame] | 1728 | return NULL; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1729 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1730 | edid = drm_do_get_edid(connector, drm_do_probe_ddc_edid, adapter); |
| 1731 | if (edid) |
| 1732 | drm_get_displayid(connector, edid); |
| 1733 | return edid; |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1734 | } |
| 1735 | EXPORT_SYMBOL(drm_get_edid); |
| 1736 | |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1737 | /** |
Lukas Wunner | 5cb8eaa2 | 2016-01-11 20:09:20 +0100 | [diff] [blame] | 1738 | * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output |
| 1739 | * @connector: connector we're probing |
| 1740 | * @adapter: I2C adapter to use for DDC |
| 1741 | * |
| 1742 | * Wrapper around drm_get_edid() for laptops with dual GPUs using one set of |
| 1743 | * outputs. The wrapper adds the requisite vga_switcheroo calls to temporarily |
| 1744 | * switch DDC to the GPU which is retrieving EDID. |
| 1745 | * |
| 1746 | * Return: Pointer to valid EDID or %NULL if we couldn't find any. |
| 1747 | */ |
| 1748 | struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, |
| 1749 | struct i2c_adapter *adapter) |
| 1750 | { |
| 1751 | struct pci_dev *pdev = connector->dev->pdev; |
| 1752 | struct edid *edid; |
| 1753 | |
| 1754 | vga_switcheroo_lock_ddc(pdev); |
| 1755 | edid = drm_get_edid(connector, adapter); |
| 1756 | vga_switcheroo_unlock_ddc(pdev); |
| 1757 | |
| 1758 | return edid; |
| 1759 | } |
| 1760 | EXPORT_SYMBOL(drm_get_edid_switcheroo); |
| 1761 | |
| 1762 | /** |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1763 | * drm_edid_duplicate - duplicate an EDID and the extensions |
| 1764 | * @edid: EDID to duplicate |
| 1765 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 1766 | * Return: Pointer to duplicated EDID or NULL on allocation failure. |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 1767 | */ |
| 1768 | struct edid *drm_edid_duplicate(const struct edid *edid) |
| 1769 | { |
| 1770 | return kmemdup(edid, (edid->extensions + 1) * EDID_LENGTH, GFP_KERNEL); |
| 1771 | } |
| 1772 | EXPORT_SYMBOL(drm_edid_duplicate); |
| 1773 | |
Adam Jackson | 61e57a8 | 2010-03-29 21:43:18 +0000 | [diff] [blame] | 1774 | /*** EDID parsing ***/ |
| 1775 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1776 | /** |
| 1777 | * edid_vendor - match a string against EDID's obfuscated vendor field |
| 1778 | * @edid: EDID to match |
| 1779 | * @vendor: vendor string |
| 1780 | * |
| 1781 | * Returns true if @vendor is in @edid, false otherwise |
| 1782 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 1783 | static bool edid_vendor(const struct edid *edid, const char *vendor) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1784 | { |
| 1785 | char edid_vendor[3]; |
| 1786 | |
| 1787 | edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@'; |
| 1788 | edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) | |
| 1789 | ((edid->mfg_id[1] & 0xe0) >> 5)) + '@'; |
Dave Airlie | 16456c8 | 2009-04-03 09:10:33 +1000 | [diff] [blame] | 1790 | edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@'; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1791 | |
| 1792 | return !strncmp(edid_vendor, vendor, 3); |
| 1793 | } |
| 1794 | |
| 1795 | /** |
| 1796 | * edid_get_quirks - return quirk flags for a given EDID |
| 1797 | * @edid: EDID to process |
| 1798 | * |
| 1799 | * This tells subsequent routines what fixes they need to apply. |
| 1800 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 1801 | static u32 edid_get_quirks(const struct edid *edid) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1802 | { |
Jani Nikula | 23c4cfb | 2016-12-28 13:06:26 +0200 | [diff] [blame] | 1803 | const struct edid_quirk *quirk; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1804 | int i; |
| 1805 | |
| 1806 | for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) { |
| 1807 | quirk = &edid_quirk_list[i]; |
| 1808 | |
| 1809 | if (edid_vendor(edid, quirk->vendor) && |
| 1810 | (EDID_PRODUCT_ID(edid) == quirk->product_id)) |
| 1811 | return quirk->quirks; |
| 1812 | } |
| 1813 | |
| 1814 | return 0; |
| 1815 | } |
| 1816 | |
| 1817 | #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay) |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1818 | #define MODE_REFRESH_DIFF(c,t) (abs((c) - (t))) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1819 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1820 | /** |
| 1821 | * edid_fixup_preferred - set preferred modes based on quirk list |
| 1822 | * @connector: has mode list to fix up |
| 1823 | * @quirks: quirks list |
| 1824 | * |
| 1825 | * Walk the mode list for @connector, clearing the preferred status |
| 1826 | * on existing modes and setting it anew for the right mode ala @quirks. |
| 1827 | */ |
| 1828 | static void edid_fixup_preferred(struct drm_connector *connector, |
| 1829 | u32 quirks) |
| 1830 | { |
| 1831 | struct drm_display_mode *t, *cur_mode, *preferred_mode; |
Dave Airlie | f890607 | 2008-12-18 16:59:02 +1000 | [diff] [blame] | 1832 | int target_refresh = 0; |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1833 | int cur_vrefresh, preferred_vrefresh; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1834 | |
| 1835 | if (list_empty(&connector->probed_modes)) |
| 1836 | return; |
| 1837 | |
| 1838 | if (quirks & EDID_QUIRK_PREFER_LARGE_60) |
| 1839 | target_refresh = 60; |
| 1840 | if (quirks & EDID_QUIRK_PREFER_LARGE_75) |
| 1841 | target_refresh = 75; |
| 1842 | |
| 1843 | preferred_mode = list_first_entry(&connector->probed_modes, |
| 1844 | struct drm_display_mode, head); |
| 1845 | |
| 1846 | list_for_each_entry_safe(cur_mode, t, &connector->probed_modes, head) { |
| 1847 | cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED; |
| 1848 | |
| 1849 | if (cur_mode == preferred_mode) |
| 1850 | continue; |
| 1851 | |
| 1852 | /* Largest mode is preferred */ |
| 1853 | if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode)) |
| 1854 | preferred_mode = cur_mode; |
| 1855 | |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1856 | cur_vrefresh = cur_mode->vrefresh ? |
| 1857 | cur_mode->vrefresh : drm_mode_vrefresh(cur_mode); |
| 1858 | preferred_vrefresh = preferred_mode->vrefresh ? |
| 1859 | preferred_mode->vrefresh : drm_mode_vrefresh(preferred_mode); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1860 | /* At a given size, try to get closest to target refresh */ |
| 1861 | if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) && |
Alex Deucher | 339d202 | 2013-08-15 11:42:14 -0400 | [diff] [blame] | 1862 | MODE_REFRESH_DIFF(cur_vrefresh, target_refresh) < |
| 1863 | MODE_REFRESH_DIFF(preferred_vrefresh, target_refresh)) { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1864 | preferred_mode = cur_mode; |
| 1865 | } |
| 1866 | } |
| 1867 | |
| 1868 | preferred_mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 1869 | } |
| 1870 | |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1871 | static bool |
| 1872 | mode_is_rb(const struct drm_display_mode *mode) |
| 1873 | { |
| 1874 | return (mode->htotal - mode->hdisplay == 160) && |
| 1875 | (mode->hsync_end - mode->hdisplay == 80) && |
| 1876 | (mode->hsync_end - mode->hsync_start == 32) && |
| 1877 | (mode->vsync_start - mode->vdisplay == 3); |
| 1878 | } |
| 1879 | |
Adam Jackson | 33c7531 | 2012-04-13 16:33:29 -0400 | [diff] [blame] | 1880 | /* |
| 1881 | * drm_mode_find_dmt - Create a copy of a mode if present in DMT |
| 1882 | * @dev: Device to duplicate against |
| 1883 | * @hsize: Mode width |
| 1884 | * @vsize: Mode height |
| 1885 | * @fresh: Mode refresh rate |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1886 | * @rb: Mode reduced-blanking-ness |
Adam Jackson | 33c7531 | 2012-04-13 16:33:29 -0400 | [diff] [blame] | 1887 | * |
| 1888 | * 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] | 1889 | * |
| 1890 | * 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] | 1891 | */ |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 1892 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1893 | int hsize, int vsize, int fresh, |
| 1894 | bool rb) |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1895 | { |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 1896 | int i; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1897 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 1898 | for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 1899 | const struct drm_display_mode *ptr = &drm_dmt_modes[i]; |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1900 | if (hsize != ptr->hdisplay) |
| 1901 | continue; |
| 1902 | if (vsize != ptr->vdisplay) |
| 1903 | continue; |
| 1904 | if (fresh != drm_mode_vrefresh(ptr)) |
| 1905 | continue; |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 1906 | if (rb != mode_is_rb(ptr)) |
| 1907 | continue; |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1908 | |
| 1909 | return drm_mode_duplicate(dev, ptr); |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1910 | } |
Adam Jackson | f8b46a0 | 2012-04-13 16:33:30 -0400 | [diff] [blame] | 1911 | |
| 1912 | return NULL; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 1913 | } |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 1914 | EXPORT_SYMBOL(drm_mode_find_dmt); |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 1915 | |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1916 | typedef void detailed_cb(struct detailed_timing *timing, void *closure); |
| 1917 | |
| 1918 | static void |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1919 | cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) |
| 1920 | { |
| 1921 | int i, n = 0; |
Christian Schmidt | 4966b2a | 2011-12-19 20:03:43 +0100 | [diff] [blame] | 1922 | u8 d = ext[0x02]; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1923 | u8 *det_base = ext + d; |
| 1924 | |
Christian Schmidt | 4966b2a | 2011-12-19 20:03:43 +0100 | [diff] [blame] | 1925 | n = (127 - d) / 18; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1926 | for (i = 0; i < n; i++) |
| 1927 | cb((struct detailed_timing *)(det_base + 18 * i), closure); |
| 1928 | } |
| 1929 | |
| 1930 | static void |
Adam Jackson | cbba98f | 2010-08-03 14:38:18 -0400 | [diff] [blame] | 1931 | vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) |
| 1932 | { |
| 1933 | unsigned int i, n = min((int)ext[0x02], 6); |
| 1934 | u8 *det_base = ext + 5; |
| 1935 | |
| 1936 | if (ext[0x01] != 1) |
| 1937 | return; /* unknown version */ |
| 1938 | |
| 1939 | for (i = 0; i < n; i++) |
| 1940 | cb((struct detailed_timing *)(det_base + 18 * i), closure); |
| 1941 | } |
| 1942 | |
| 1943 | static void |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1944 | drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure) |
| 1945 | { |
| 1946 | int i; |
| 1947 | struct edid *edid = (struct edid *)raw_edid; |
| 1948 | |
| 1949 | if (edid == NULL) |
| 1950 | return; |
| 1951 | |
| 1952 | for (i = 0; i < EDID_DETAILED_TIMINGS; i++) |
| 1953 | cb(&(edid->detailed_timings[i]), closure); |
| 1954 | |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1955 | for (i = 1; i <= raw_edid[0x7e]; i++) { |
| 1956 | u8 *ext = raw_edid + (i * EDID_LENGTH); |
| 1957 | switch (*ext) { |
| 1958 | case CEA_EXT: |
| 1959 | cea_for_each_detailed_block(ext, cb, closure); |
| 1960 | break; |
Adam Jackson | cbba98f | 2010-08-03 14:38:18 -0400 | [diff] [blame] | 1961 | case VTB_EXT: |
| 1962 | vtb_for_each_detailed_block(ext, cb, closure); |
| 1963 | break; |
Adam Jackson | 4d76a22 | 2010-08-03 14:38:17 -0400 | [diff] [blame] | 1964 | default: |
| 1965 | break; |
| 1966 | } |
| 1967 | } |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1968 | } |
| 1969 | |
| 1970 | static void |
| 1971 | is_rb(struct detailed_timing *t, void *data) |
| 1972 | { |
| 1973 | u8 *r = (u8 *)t; |
| 1974 | if (r[3] == EDID_DETAIL_MONITOR_RANGE) |
| 1975 | if (r[15] & 0x10) |
| 1976 | *(bool *)data = true; |
| 1977 | } |
| 1978 | |
| 1979 | /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */ |
| 1980 | static bool |
| 1981 | drm_monitor_supports_rb(struct edid *edid) |
| 1982 | { |
| 1983 | if (edid->revision >= 4) { |
Daniel Vetter | b196a49 | 2012-06-19 11:33:06 +0200 | [diff] [blame] | 1984 | bool ret = false; |
Adam Jackson | d1ff640 | 2010-03-29 21:43:26 +0000 | [diff] [blame] | 1985 | drm_for_each_detailed_block((u8 *)edid, is_rb, &ret); |
| 1986 | return ret; |
| 1987 | } |
| 1988 | |
| 1989 | return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0); |
| 1990 | } |
| 1991 | |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 1992 | static void |
| 1993 | find_gtf2(struct detailed_timing *t, void *data) |
| 1994 | { |
| 1995 | u8 *r = (u8 *)t; |
| 1996 | if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02) |
| 1997 | *(u8 **)data = r; |
| 1998 | } |
| 1999 | |
| 2000 | /* Secondary GTF curve kicks in above some break frequency */ |
| 2001 | static int |
| 2002 | drm_gtf2_hbreak(struct edid *edid) |
| 2003 | { |
| 2004 | u8 *r = NULL; |
| 2005 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2006 | return r ? (r[12] * 2) : 0; |
| 2007 | } |
| 2008 | |
| 2009 | static int |
| 2010 | drm_gtf2_2c(struct edid *edid) |
| 2011 | { |
| 2012 | u8 *r = NULL; |
| 2013 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2014 | return r ? r[13] : 0; |
| 2015 | } |
| 2016 | |
| 2017 | static int |
| 2018 | drm_gtf2_m(struct edid *edid) |
| 2019 | { |
| 2020 | u8 *r = NULL; |
| 2021 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2022 | return r ? (r[15] << 8) + r[14] : 0; |
| 2023 | } |
| 2024 | |
| 2025 | static int |
| 2026 | drm_gtf2_k(struct edid *edid) |
| 2027 | { |
| 2028 | u8 *r = NULL; |
| 2029 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2030 | return r ? r[16] : 0; |
| 2031 | } |
| 2032 | |
| 2033 | static int |
| 2034 | drm_gtf2_2j(struct edid *edid) |
| 2035 | { |
| 2036 | u8 *r = NULL; |
| 2037 | drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r); |
| 2038 | return r ? r[17] : 0; |
| 2039 | } |
| 2040 | |
| 2041 | /** |
| 2042 | * standard_timing_level - get std. timing level(CVT/GTF/DMT) |
| 2043 | * @edid: EDID block to scan |
| 2044 | */ |
| 2045 | static int standard_timing_level(struct edid *edid) |
| 2046 | { |
| 2047 | if (edid->revision >= 2) { |
| 2048 | if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) |
| 2049 | return LEVEL_CVT; |
| 2050 | if (drm_gtf2_hbreak(edid)) |
| 2051 | return LEVEL_GTF2; |
| 2052 | return LEVEL_GTF; |
| 2053 | } |
| 2054 | return LEVEL_DMT; |
| 2055 | } |
| 2056 | |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 2057 | /* |
| 2058 | * 0 is reserved. The spec says 0x01 fill for unused timings. Some old |
| 2059 | * monitors fill with ascii space (0x20) instead. |
| 2060 | */ |
| 2061 | static int |
| 2062 | bad_std_timing(u8 a, u8 b) |
| 2063 | { |
| 2064 | return (a == 0x00 && b == 0x00) || |
| 2065 | (a == 0x01 && b == 0x01) || |
| 2066 | (a == 0x20 && b == 0x20); |
| 2067 | } |
| 2068 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2069 | /** |
| 2070 | * drm_mode_std - convert standard mode info (width, height, refresh) into mode |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 2071 | * @connector: connector of for the EDID block |
| 2072 | * @edid: EDID block to scan |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2073 | * @t: standard timing params |
| 2074 | * |
| 2075 | * Take the standard timing params (in this case width, aspect, and refresh) |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2076 | * and convert them into a real mode using CVT/GTF/DMT. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2077 | */ |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2078 | static struct drm_display_mode * |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2079 | drm_mode_std(struct drm_connector *connector, struct edid *edid, |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2080 | struct std_timing *t) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2081 | { |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2082 | struct drm_device *dev = connector->dev; |
| 2083 | struct drm_display_mode *m, *mode = NULL; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2084 | int hsize, vsize; |
| 2085 | int vrefresh_rate; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2086 | unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK) |
| 2087 | >> EDID_TIMING_ASPECT_SHIFT; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2088 | unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK) |
| 2089 | >> EDID_TIMING_VFREQ_SHIFT; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2090 | int timing_level = standard_timing_level(edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2091 | |
Adam Jackson | 23425ca | 2009-09-23 17:30:58 -0400 | [diff] [blame] | 2092 | if (bad_std_timing(t->hsize, t->vfreq_aspect)) |
| 2093 | return NULL; |
| 2094 | |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2095 | /* According to the EDID spec, the hdisplay = hsize * 8 + 248 */ |
| 2096 | hsize = t->hsize * 8 + 248; |
| 2097 | /* vrefresh_rate = vfreq + 60 */ |
| 2098 | vrefresh_rate = vfreq + 60; |
| 2099 | /* the vdisplay is calculated based on the aspect ratio */ |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2100 | if (aspect_ratio == 0) { |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2101 | if (edid->revision < 3) |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2102 | vsize = hsize; |
| 2103 | else |
| 2104 | vsize = (hsize * 10) / 16; |
| 2105 | } else if (aspect_ratio == 1) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2106 | vsize = (hsize * 3) / 4; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2107 | else if (aspect_ratio == 2) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2108 | vsize = (hsize * 4) / 5; |
| 2109 | else |
| 2110 | vsize = (hsize * 9) / 16; |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2111 | |
| 2112 | /* HDTV hack, part 1 */ |
| 2113 | if (vrefresh_rate == 60 && |
| 2114 | ((hsize == 1360 && vsize == 765) || |
| 2115 | (hsize == 1368 && vsize == 769))) { |
| 2116 | hsize = 1366; |
| 2117 | vsize = 768; |
| 2118 | } |
| 2119 | |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2120 | /* |
| 2121 | * If this connector already has a mode for this size and refresh |
| 2122 | * rate (because it came from detailed or CVT info), use that |
| 2123 | * instead. This way we don't have to guess at interlace or |
| 2124 | * reduced blanking. |
| 2125 | */ |
Adam Jackson | 522032d | 2010-04-09 16:52:49 +0000 | [diff] [blame] | 2126 | list_for_each_entry(m, &connector->probed_modes, head) |
Adam Jackson | 7ca6adb | 2010-03-29 21:43:29 +0000 | [diff] [blame] | 2127 | if (m->hdisplay == hsize && m->vdisplay == vsize && |
| 2128 | drm_mode_vrefresh(m) == vrefresh_rate) |
| 2129 | return NULL; |
| 2130 | |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2131 | /* HDTV hack, part 2 */ |
| 2132 | if (hsize == 1366 && vsize == 768 && vrefresh_rate == 60) { |
| 2133 | mode = drm_cvt_mode(dev, 1366, 768, vrefresh_rate, 0, 0, |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 2134 | false); |
Joe Moriarty | a5ef656 | 2018-02-12 14:51:43 -0500 | [diff] [blame] | 2135 | if (!mode) |
| 2136 | return NULL; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2137 | mode->hdisplay = 1366; |
Adam Jackson | a4967de6 | 2010-07-28 07:40:32 +1000 | [diff] [blame] | 2138 | mode->hsync_start = mode->hsync_start - 1; |
| 2139 | mode->hsync_end = mode->hsync_end - 1; |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2140 | return mode; |
| 2141 | } |
Adam Jackson | a0910c8 | 2010-03-29 21:43:28 +0000 | [diff] [blame] | 2142 | |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2143 | /* check whether it can be found in default mode table */ |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2144 | if (drm_monitor_supports_rb(edid)) { |
| 2145 | mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, |
| 2146 | true); |
| 2147 | if (mode) |
| 2148 | return mode; |
| 2149 | } |
| 2150 | mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, false); |
Zhao Yakui | 559ee21 | 2009-09-03 09:33:47 +0800 | [diff] [blame] | 2151 | if (mode) |
| 2152 | return mode; |
| 2153 | |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2154 | /* okay, generate it */ |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2155 | switch (timing_level) { |
| 2156 | case LEVEL_DMT: |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2157 | break; |
| 2158 | case LEVEL_GTF: |
| 2159 | mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); |
| 2160 | break; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2161 | case LEVEL_GTF2: |
| 2162 | /* |
| 2163 | * This is potentially wrong if there's ever a monitor with |
| 2164 | * more than one ranges section, each claiming a different |
| 2165 | * secondary GTF curve. Please don't do that. |
| 2166 | */ |
| 2167 | mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0); |
Takashi Iwai | fc48f16 | 2012-04-20 12:59:33 +0100 | [diff] [blame] | 2168 | if (!mode) |
| 2169 | return NULL; |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2170 | if (drm_mode_hsync(mode) > drm_gtf2_hbreak(edid)) { |
Sascha Hauer | aefd330 | 2012-02-01 11:38:21 +0100 | [diff] [blame] | 2171 | drm_mode_destroy(dev, mode); |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 2172 | mode = drm_gtf_mode_complex(dev, hsize, vsize, |
| 2173 | vrefresh_rate, 0, 0, |
| 2174 | drm_gtf2_m(edid), |
| 2175 | drm_gtf2_2c(edid), |
| 2176 | drm_gtf2_k(edid), |
| 2177 | drm_gtf2_2j(edid)); |
| 2178 | } |
| 2179 | break; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2180 | case LEVEL_CVT: |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 2181 | mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0, |
| 2182 | false); |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2183 | break; |
| 2184 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2185 | return mode; |
| 2186 | } |
| 2187 | |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2188 | /* |
| 2189 | * EDID is delightfully ambiguous about how interlaced modes are to be |
| 2190 | * encoded. Our internal representation is of frame height, but some |
| 2191 | * HDTV detailed timings are encoded as field height. |
| 2192 | * |
| 2193 | * The format list here is from CEA, in frame size. Technically we |
| 2194 | * should be checking refresh rate too. Whatever. |
| 2195 | */ |
| 2196 | static void |
| 2197 | drm_mode_do_interlace_quirk(struct drm_display_mode *mode, |
| 2198 | struct detailed_pixel_timing *pt) |
| 2199 | { |
| 2200 | int i; |
| 2201 | static const struct { |
| 2202 | int w, h; |
| 2203 | } cea_interlaced[] = { |
| 2204 | { 1920, 1080 }, |
| 2205 | { 720, 480 }, |
| 2206 | { 1440, 480 }, |
| 2207 | { 2880, 480 }, |
| 2208 | { 720, 576 }, |
| 2209 | { 1440, 576 }, |
| 2210 | { 2880, 576 }, |
| 2211 | }; |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2212 | |
| 2213 | if (!(pt->misc & DRM_EDID_PT_INTERLACED)) |
| 2214 | return; |
| 2215 | |
Kulikov Vasiliy | 3c58141 | 2010-06-28 15:54:52 +0400 | [diff] [blame] | 2216 | for (i = 0; i < ARRAY_SIZE(cea_interlaced); i++) { |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2217 | if ((mode->hdisplay == cea_interlaced[i].w) && |
| 2218 | (mode->vdisplay == cea_interlaced[i].h / 2)) { |
| 2219 | mode->vdisplay *= 2; |
| 2220 | mode->vsync_start *= 2; |
| 2221 | mode->vsync_end *= 2; |
| 2222 | mode->vtotal *= 2; |
| 2223 | mode->vtotal |= 1; |
| 2224 | } |
| 2225 | } |
| 2226 | |
| 2227 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
| 2228 | } |
| 2229 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2230 | /** |
| 2231 | * drm_mode_detailed - create a new mode from an EDID detailed timing section |
| 2232 | * @dev: DRM device (needed to create new mode) |
| 2233 | * @edid: EDID block |
| 2234 | * @timing: EDID detailed timing info |
| 2235 | * @quirks: quirks to apply |
| 2236 | * |
| 2237 | * An EDID detailed timing block contains enough info for us to create and |
| 2238 | * return a new struct drm_display_mode. |
| 2239 | */ |
| 2240 | static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev, |
| 2241 | struct edid *edid, |
| 2242 | struct detailed_timing *timing, |
| 2243 | u32 quirks) |
| 2244 | { |
| 2245 | struct drm_display_mode *mode; |
| 2246 | struct detailed_pixel_timing *pt = &timing->data.pixel_data; |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2247 | unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo; |
| 2248 | unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo; |
| 2249 | unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo; |
| 2250 | unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo; |
Michel Dänzer | e14cbee | 2009-06-23 12:36:32 +0200 | [diff] [blame] | 2251 | unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | pt->hsync_offset_lo; |
| 2252 | 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] | 2253 | 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] | 2254 | 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] | 2255 | |
Adam Jackson | fc43896 | 2009-06-04 10:20:34 +1000 | [diff] [blame] | 2256 | /* ignore tiny modes */ |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2257 | if (hactive < 64 || vactive < 64) |
Adam Jackson | fc43896 | 2009-06-04 10:20:34 +1000 | [diff] [blame] | 2258 | return NULL; |
| 2259 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2260 | if (pt->misc & DRM_EDID_PT_STEREO) { |
Egbert Eich | c7d015f3 | 2013-06-13 21:01:19 +0200 | [diff] [blame] | 2261 | DRM_DEBUG_KMS("stereo mode not supported\n"); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2262 | return NULL; |
| 2263 | } |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2264 | if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) { |
Egbert Eich | c7d015f3 | 2013-06-13 21:01:19 +0200 | [diff] [blame] | 2265 | DRM_DEBUG_KMS("composite sync not supported\n"); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2266 | } |
| 2267 | |
Zhao Yakui | fcb4561 | 2009-10-14 09:11:25 +0800 | [diff] [blame] | 2268 | /* it is incorrect if hsync/vsync width is zero */ |
| 2269 | if (!hsync_pulse_width || !vsync_pulse_width) { |
| 2270 | DRM_DEBUG_KMS("Incorrect Detailed timing. " |
| 2271 | "Wrong Hsync/Vsync pulse width\n"); |
| 2272 | return NULL; |
| 2273 | } |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2274 | |
| 2275 | if (quirks & EDID_QUIRK_FORCE_REDUCED_BLANKING) { |
| 2276 | mode = drm_cvt_mode(dev, hactive, vactive, 60, true, false, false); |
| 2277 | if (!mode) |
| 2278 | return NULL; |
| 2279 | |
| 2280 | goto set_size; |
| 2281 | } |
| 2282 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2283 | mode = drm_mode_create(dev); |
| 2284 | if (!mode) |
| 2285 | return NULL; |
| 2286 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2287 | if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH) |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2288 | timing->pixel_clock = cpu_to_le16(1088); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2289 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2290 | mode->clock = le16_to_cpu(timing->pixel_clock) * 10; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2291 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2292 | mode->hdisplay = hactive; |
| 2293 | mode->hsync_start = mode->hdisplay + hsync_offset; |
| 2294 | mode->hsync_end = mode->hsync_start + hsync_pulse_width; |
| 2295 | mode->htotal = mode->hdisplay + hblank; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2296 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2297 | mode->vdisplay = vactive; |
| 2298 | mode->vsync_start = mode->vdisplay + vsync_offset; |
| 2299 | mode->vsync_end = mode->vsync_start + vsync_pulse_width; |
| 2300 | mode->vtotal = mode->vdisplay + vblank; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2301 | |
Jesse Barnes | 7064fef | 2009-11-05 10:12:54 -0800 | [diff] [blame] | 2302 | /* Some EDIDs have bogus h/vtotal values */ |
| 2303 | if (mode->hsync_end > mode->htotal) |
| 2304 | mode->htotal = mode->hsync_end + 1; |
| 2305 | if (mode->vsync_end > mode->vtotal) |
| 2306 | mode->vtotal = mode->vsync_end + 1; |
| 2307 | |
Adam Jackson | b58db2c | 2010-02-15 22:15:39 +0000 | [diff] [blame] | 2308 | drm_mode_do_interlace_quirk(mode, pt); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2309 | |
| 2310 | if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) { |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2311 | pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2312 | } |
| 2313 | |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2314 | mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? |
| 2315 | DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; |
| 2316 | mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? |
| 2317 | DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2318 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2319 | set_size: |
Michel Dänzer | e14cbee | 2009-06-23 12:36:32 +0200 | [diff] [blame] | 2320 | mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4; |
| 2321 | 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] | 2322 | |
| 2323 | if (quirks & EDID_QUIRK_DETAILED_IN_CM) { |
| 2324 | mode->width_mm *= 10; |
| 2325 | mode->height_mm *= 10; |
| 2326 | } |
| 2327 | |
| 2328 | if (quirks & EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { |
| 2329 | mode->width_mm = edid->width_cm * 10; |
| 2330 | mode->height_mm = edid->height_cm * 10; |
| 2331 | } |
| 2332 | |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2333 | mode->type = DRM_MODE_TYPE_DRIVER; |
Torsten Duwe | c19b3b0f | 2013-03-23 15:39:34 +0100 | [diff] [blame] | 2334 | mode->vrefresh = drm_mode_vrefresh(mode); |
Adam Jackson | bc42aab | 2012-05-23 16:26:54 -0400 | [diff] [blame] | 2335 | drm_mode_set_name(mode); |
| 2336 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2337 | return mode; |
| 2338 | } |
| 2339 | |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2340 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2341 | mode_in_hsync_range(const struct drm_display_mode *mode, |
| 2342 | struct edid *edid, u8 *t) |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2343 | { |
| 2344 | int hsync, hmin, hmax; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2345 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2346 | hmin = t[7]; |
| 2347 | if (edid->revision >= 4) |
| 2348 | hmin += ((t[4] & 0x04) ? 255 : 0); |
| 2349 | hmax = t[8]; |
| 2350 | if (edid->revision >= 4) |
| 2351 | hmax += ((t[4] & 0x08) ? 255 : 0); |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2352 | hsync = drm_mode_hsync(mode); |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2353 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2354 | return (hsync <= hmax && hsync >= hmin); |
| 2355 | } |
| 2356 | |
| 2357 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2358 | mode_in_vsync_range(const struct drm_display_mode *mode, |
| 2359 | struct edid *edid, u8 *t) |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2360 | { |
| 2361 | int vsync, vmin, vmax; |
| 2362 | |
| 2363 | vmin = t[5]; |
| 2364 | if (edid->revision >= 4) |
| 2365 | vmin += ((t[4] & 0x01) ? 255 : 0); |
| 2366 | vmax = t[6]; |
| 2367 | if (edid->revision >= 4) |
| 2368 | vmax += ((t[4] & 0x02) ? 255 : 0); |
| 2369 | vsync = drm_mode_vrefresh(mode); |
| 2370 | |
| 2371 | return (vsync <= vmax && vsync >= vmin); |
| 2372 | } |
| 2373 | |
| 2374 | static u32 |
| 2375 | range_pixel_clock(struct edid *edid, u8 *t) |
| 2376 | { |
| 2377 | /* unspecified */ |
| 2378 | if (t[9] == 0 || t[9] == 255) |
| 2379 | return 0; |
| 2380 | |
| 2381 | /* 1.4 with CVT support gives us real precision, yay */ |
| 2382 | if (edid->revision >= 4 && t[10] == 0x04) |
| 2383 | return (t[9] * 10000) - ((t[12] >> 2) * 250); |
| 2384 | |
| 2385 | /* 1.3 is pathetic, so fuzz up a bit */ |
| 2386 | return t[9] * 10000 + 5001; |
| 2387 | } |
| 2388 | |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2389 | static bool |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 2390 | mode_in_range(const struct drm_display_mode *mode, struct edid *edid, |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2391 | struct detailed_timing *timing) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2392 | { |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2393 | u32 max_clock; |
| 2394 | u8 *t = (u8 *)timing; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2395 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2396 | if (!mode_in_hsync_range(mode, edid, t)) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2397 | return false; |
| 2398 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2399 | if (!mode_in_vsync_range(mode, edid, t)) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2400 | return false; |
| 2401 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2402 | if ((max_clock = range_pixel_clock(edid, t))) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2403 | if (mode->clock > max_clock) |
| 2404 | return false; |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2405 | |
| 2406 | /* 1.4 max horizontal check */ |
| 2407 | if (edid->revision >= 4 && t[10] == 0x04) |
| 2408 | if (t[13] && mode->hdisplay > 8 * (t[13] + (256 * (t[12]&0x3)))) |
| 2409 | return false; |
| 2410 | |
| 2411 | if (mode_is_rb(mode) && !drm_monitor_supports_rb(edid)) |
| 2412 | return false; |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2413 | |
| 2414 | return true; |
| 2415 | } |
| 2416 | |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2417 | static bool valid_inferred_mode(const struct drm_connector *connector, |
| 2418 | const struct drm_display_mode *mode) |
| 2419 | { |
Ville Syrjälä | 85f8fcd | 2015-09-07 18:22:56 +0300 | [diff] [blame] | 2420 | const struct drm_display_mode *m; |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2421 | bool ok = false; |
| 2422 | |
| 2423 | list_for_each_entry(m, &connector->probed_modes, head) { |
| 2424 | if (mode->hdisplay == m->hdisplay && |
| 2425 | mode->vdisplay == m->vdisplay && |
| 2426 | drm_mode_vrefresh(mode) == drm_mode_vrefresh(m)) |
| 2427 | return false; /* duplicated */ |
| 2428 | if (mode->hdisplay <= m->hdisplay && |
| 2429 | mode->vdisplay <= m->vdisplay) |
| 2430 | ok = true; |
| 2431 | } |
| 2432 | return ok; |
| 2433 | } |
| 2434 | |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2435 | static int |
Adam Jackson | cd4cd3d | 2012-04-13 16:33:33 -0400 | [diff] [blame] | 2436 | drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid, |
Adam Jackson | b17e52e | 2010-03-29 21:43:27 +0000 | [diff] [blame] | 2437 | struct detailed_timing *timing) |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2438 | { |
| 2439 | int i, modes = 0; |
| 2440 | struct drm_display_mode *newmode; |
| 2441 | struct drm_device *dev = connector->dev; |
| 2442 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2443 | for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) { |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2444 | if (mode_in_range(drm_dmt_modes + i, edid, timing) && |
| 2445 | valid_inferred_mode(connector, drm_dmt_modes + i)) { |
Adam Jackson | 07a5e63 | 2009-12-03 17:44:38 -0500 | [diff] [blame] | 2446 | newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]); |
| 2447 | if (newmode) { |
| 2448 | drm_mode_probed_add(connector, newmode); |
| 2449 | modes++; |
| 2450 | } |
| 2451 | } |
| 2452 | } |
| 2453 | |
| 2454 | return modes; |
| 2455 | } |
| 2456 | |
Takashi Iwai | c09dedb | 2012-04-23 17:40:33 +0100 | [diff] [blame] | 2457 | /* fix up 1366x768 mode from 1368x768; |
| 2458 | * GFT/CVT can't express 1366 width which isn't dividable by 8 |
| 2459 | */ |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2460 | void drm_mode_fixup_1366x768(struct drm_display_mode *mode) |
Takashi Iwai | c09dedb | 2012-04-23 17:40:33 +0100 | [diff] [blame] | 2461 | { |
| 2462 | if (mode->hdisplay == 1368 && mode->vdisplay == 768) { |
| 2463 | mode->hdisplay = 1366; |
| 2464 | mode->hsync_start--; |
| 2465 | mode->hsync_end--; |
| 2466 | drm_mode_set_name(mode); |
| 2467 | } |
| 2468 | } |
| 2469 | |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2470 | static int |
| 2471 | drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid, |
| 2472 | struct detailed_timing *timing) |
| 2473 | { |
| 2474 | int i, modes = 0; |
| 2475 | struct drm_display_mode *newmode; |
| 2476 | struct drm_device *dev = connector->dev; |
| 2477 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2478 | for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2479 | const struct minimode *m = &extra_modes[i]; |
| 2480 | 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] | 2481 | if (!newmode) |
| 2482 | return modes; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2483 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2484 | drm_mode_fixup_1366x768(newmode); |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2485 | if (!mode_in_range(newmode, edid, timing) || |
| 2486 | !valid_inferred_mode(connector, newmode)) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2487 | drm_mode_destroy(dev, newmode); |
| 2488 | continue; |
| 2489 | } |
| 2490 | |
| 2491 | drm_mode_probed_add(connector, newmode); |
| 2492 | modes++; |
| 2493 | } |
| 2494 | |
| 2495 | return modes; |
| 2496 | } |
| 2497 | |
| 2498 | static int |
| 2499 | drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid, |
| 2500 | struct detailed_timing *timing) |
| 2501 | { |
| 2502 | int i, modes = 0; |
| 2503 | struct drm_display_mode *newmode; |
| 2504 | struct drm_device *dev = connector->dev; |
| 2505 | bool rb = drm_monitor_supports_rb(edid); |
| 2506 | |
Thierry Reding | a6b2183 | 2012-11-23 15:01:42 +0100 | [diff] [blame] | 2507 | for (i = 0; i < ARRAY_SIZE(extra_modes); i++) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2508 | const struct minimode *m = &extra_modes[i]; |
| 2509 | 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] | 2510 | if (!newmode) |
| 2511 | return modes; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2512 | |
Takashi Iwai | 969218f | 2017-01-17 17:43:29 +0100 | [diff] [blame] | 2513 | drm_mode_fixup_1366x768(newmode); |
Takashi Iwai | 7b668eb | 2012-07-03 11:22:11 +0200 | [diff] [blame] | 2514 | if (!mode_in_range(newmode, edid, timing) || |
| 2515 | !valid_inferred_mode(connector, newmode)) { |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2516 | drm_mode_destroy(dev, newmode); |
| 2517 | continue; |
| 2518 | } |
| 2519 | |
| 2520 | drm_mode_probed_add(connector, newmode); |
| 2521 | modes++; |
| 2522 | } |
| 2523 | |
| 2524 | return modes; |
| 2525 | } |
| 2526 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2527 | static void |
| 2528 | do_inferred_modes(struct detailed_timing *timing, void *c) |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2529 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2530 | struct detailed_mode_closure *closure = c; |
| 2531 | struct detailed_non_pixel *data = &timing->data.other_data; |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2532 | struct detailed_data_monitor_range *range = &data->data.range; |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2533 | |
Adam Jackson | cb21aaf | 2012-04-13 16:33:36 -0400 | [diff] [blame] | 2534 | if (data->type != EDID_DETAIL_MONITOR_RANGE) |
| 2535 | return; |
| 2536 | |
| 2537 | closure->modes += drm_dmt_modes_for_range(closure->connector, |
| 2538 | closure->edid, |
| 2539 | timing); |
Adam Jackson | b309bd3 | 2012-04-13 16:33:40 -0400 | [diff] [blame] | 2540 | |
| 2541 | if (!version_greater(closure->edid, 1, 1)) |
| 2542 | return; /* GTF not defined yet */ |
| 2543 | |
| 2544 | switch (range->flags) { |
| 2545 | case 0x02: /* secondary gtf, XXX could do more */ |
| 2546 | case 0x00: /* default gtf */ |
| 2547 | closure->modes += drm_gtf_modes_for_range(closure->connector, |
| 2548 | closure->edid, |
| 2549 | timing); |
| 2550 | break; |
| 2551 | case 0x04: /* cvt, only in 1.4+ */ |
| 2552 | if (!version_greater(closure->edid, 1, 3)) |
| 2553 | break; |
| 2554 | |
| 2555 | closure->modes += drm_cvt_modes_for_range(closure->connector, |
| 2556 | closure->edid, |
| 2557 | timing); |
| 2558 | break; |
| 2559 | case 0x01: /* just the ranges, no formula */ |
| 2560 | default: |
| 2561 | break; |
| 2562 | } |
Adam Jackson | 9340d8c | 2009-12-03 17:44:40 -0500 | [diff] [blame] | 2563 | } |
| 2564 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2565 | static int |
| 2566 | add_inferred_modes(struct drm_connector *connector, struct edid *edid) |
| 2567 | { |
| 2568 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2569 | .connector = connector, |
| 2570 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2571 | }; |
| 2572 | |
| 2573 | if (version_greater(edid, 1, 0)) |
| 2574 | drm_for_each_detailed_block((u8 *)edid, do_inferred_modes, |
| 2575 | &closure); |
| 2576 | |
| 2577 | return closure.modes; |
| 2578 | } |
| 2579 | |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2580 | static int |
| 2581 | drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing) |
| 2582 | { |
| 2583 | int i, j, m, modes = 0; |
| 2584 | struct drm_display_mode *mode; |
Paul Parsons | f3a32d7 | 2016-03-26 13:18:38 +0000 | [diff] [blame] | 2585 | u8 *est = ((u8 *)timing) + 6; |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2586 | |
| 2587 | for (i = 0; i < 6; i++) { |
Ville Syrjälä | 891a746 | 2013-10-14 16:44:26 +0300 | [diff] [blame] | 2588 | for (j = 7; j >= 0; j--) { |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2589 | m = (i * 8) + (7 - j); |
Linus Torvalds | aa9f56b | 2010-08-12 09:21:39 -0700 | [diff] [blame] | 2590 | if (m >= ARRAY_SIZE(est3_modes)) |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2591 | break; |
| 2592 | if (est[i] & (1 << j)) { |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 2593 | mode = drm_mode_find_dmt(connector->dev, |
| 2594 | est3_modes[m].w, |
| 2595 | est3_modes[m].h, |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2596 | est3_modes[m].r, |
| 2597 | est3_modes[m].rb); |
Adam Jackson | 2255be1 | 2010-03-29 21:43:22 +0000 | [diff] [blame] | 2598 | if (mode) { |
| 2599 | drm_mode_probed_add(connector, mode); |
| 2600 | modes++; |
| 2601 | } |
| 2602 | } |
| 2603 | } |
| 2604 | } |
| 2605 | |
| 2606 | return modes; |
| 2607 | } |
| 2608 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2609 | static void |
| 2610 | do_established_modes(struct detailed_timing *timing, void *c) |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2611 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2612 | struct detailed_mode_closure *closure = c; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2613 | struct detailed_non_pixel *data = &timing->data.other_data; |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2614 | |
| 2615 | if (data->type == EDID_DETAIL_EST_TIMINGS) |
| 2616 | closure->modes += drm_est3_modes(closure->connector, timing); |
| 2617 | } |
| 2618 | |
| 2619 | /** |
| 2620 | * add_established_modes - get est. modes from EDID and add them |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2621 | * @connector: connector to add mode(s) to |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2622 | * @edid: EDID block to scan |
| 2623 | * |
| 2624 | * Each EDID block contains a bitmap of the supported "established modes" list |
| 2625 | * (defined above). Tease them out and add them to the global modes list. |
| 2626 | */ |
| 2627 | static int |
| 2628 | add_established_modes(struct drm_connector *connector, struct edid *edid) |
| 2629 | { |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2630 | struct drm_device *dev = connector->dev; |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2631 | unsigned long est_bits = edid->established_timings.t1 | |
| 2632 | (edid->established_timings.t2 << 8) | |
| 2633 | ((edid->established_timings.mfg_rsvd & 0x80) << 9); |
| 2634 | int i, modes = 0; |
| 2635 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2636 | .connector = connector, |
| 2637 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2638 | }; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2639 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2640 | for (i = 0; i <= EDID_EST_TIMINGS; i++) { |
| 2641 | if (est_bits & (1<<i)) { |
| 2642 | struct drm_display_mode *newmode; |
| 2643 | newmode = drm_mode_duplicate(dev, &edid_est_modes[i]); |
| 2644 | if (newmode) { |
| 2645 | drm_mode_probed_add(connector, newmode); |
| 2646 | modes++; |
| 2647 | } |
| 2648 | } |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2649 | } |
| 2650 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2651 | if (version_greater(edid, 1, 0)) |
| 2652 | drm_for_each_detailed_block((u8 *)edid, |
| 2653 | do_established_modes, &closure); |
| 2654 | |
| 2655 | return modes + closure.modes; |
| 2656 | } |
| 2657 | |
| 2658 | static void |
| 2659 | do_standard_modes(struct detailed_timing *timing, void *c) |
| 2660 | { |
| 2661 | struct detailed_mode_closure *closure = c; |
| 2662 | struct detailed_non_pixel *data = &timing->data.other_data; |
| 2663 | struct drm_connector *connector = closure->connector; |
| 2664 | struct edid *edid = closure->edid; |
| 2665 | |
| 2666 | if (data->type == EDID_DETAIL_STD_MODES) { |
| 2667 | int i; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2668 | for (i = 0; i < 6; i++) { |
| 2669 | struct std_timing *std; |
| 2670 | struct drm_display_mode *newmode; |
| 2671 | |
| 2672 | std = &data->data.timings[i]; |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2673 | newmode = drm_mode_std(connector, edid, std); |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2674 | if (newmode) { |
| 2675 | drm_mode_probed_add(connector, newmode); |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2676 | closure->modes++; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2677 | } |
| 2678 | } |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2679 | } |
| 2680 | } |
| 2681 | |
| 2682 | /** |
| 2683 | * add_standard_modes - get std. modes from EDID and add them |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2684 | * @connector: connector to add mode(s) to |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2685 | * @edid: EDID block to scan |
| 2686 | * |
| 2687 | * Standard modes can be calculated using the appropriate standard (DMT, |
| 2688 | * GTF or CVT. Grab them from @edid and add them to the list. |
| 2689 | */ |
| 2690 | static int |
| 2691 | add_standard_modes(struct drm_connector *connector, struct edid *edid) |
| 2692 | { |
| 2693 | int i, modes = 0; |
| 2694 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2695 | .connector = connector, |
| 2696 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2697 | }; |
| 2698 | |
| 2699 | for (i = 0; i < EDID_STD_TIMINGS; i++) { |
| 2700 | struct drm_display_mode *newmode; |
| 2701 | |
| 2702 | newmode = drm_mode_std(connector, edid, |
Thierry Reding | 464fdec | 2014-04-29 11:44:33 +0200 | [diff] [blame] | 2703 | &edid->standard_timings[i]); |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2704 | if (newmode) { |
| 2705 | drm_mode_probed_add(connector, newmode); |
| 2706 | modes++; |
| 2707 | } |
| 2708 | } |
| 2709 | |
| 2710 | if (version_greater(edid, 1, 0)) |
| 2711 | drm_for_each_detailed_block((u8 *)edid, do_standard_modes, |
| 2712 | &closure); |
| 2713 | |
| 2714 | /* XXX should also look for standard codes in VTB blocks */ |
| 2715 | |
| 2716 | return modes + closure.modes; |
| 2717 | } |
| 2718 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2719 | static int drm_cvt_modes(struct drm_connector *connector, |
| 2720 | struct detailed_timing *timing) |
| 2721 | { |
| 2722 | int i, j, modes = 0; |
| 2723 | struct drm_display_mode *newmode; |
| 2724 | struct drm_device *dev = connector->dev; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2725 | struct cvt_timing *cvt; |
| 2726 | const int rates[] = { 60, 85, 75, 60, 50 }; |
| 2727 | const u8 empty[3] = { 0, 0, 0 }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2728 | |
| 2729 | for (i = 0; i < 4; i++) { |
| 2730 | int uninitialized_var(width), height; |
| 2731 | cvt = &(timing->data.other_data.data.cvt[i]); |
| 2732 | |
| 2733 | if (!memcmp(cvt->code, empty, 3)) |
Michel Dänzer | 0454bea | 2009-06-15 16:56:07 +0200 | [diff] [blame] | 2734 | continue; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2735 | |
| 2736 | height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; |
Zhao Yakui | 5c61259 | 2009-06-22 13:17:10 +0800 | [diff] [blame] | 2737 | switch (cvt->code[1] & 0x0c) { |
Adam Jackson | f066a17 | 2009-09-23 17:31:21 -0400 | [diff] [blame] | 2738 | case 0x00: |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2739 | width = height * 4 / 3; |
| 2740 | break; |
| 2741 | case 0x04: |
| 2742 | width = height * 16 / 9; |
| 2743 | break; |
| 2744 | case 0x08: |
| 2745 | width = height * 16 / 10; |
| 2746 | break; |
| 2747 | case 0x0c: |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2748 | width = height * 15 / 9; |
| 2749 | break; |
| 2750 | } |
| 2751 | |
| 2752 | for (j = 1; j < 5; j++) { |
| 2753 | if (cvt->code[2] & (1 << j)) { |
| 2754 | newmode = drm_cvt_mode(dev, width, height, |
| 2755 | rates[j], j == 0, |
| 2756 | false, false); |
| 2757 | if (newmode) { |
| 2758 | drm_mode_probed_add(connector, newmode); |
| 2759 | modes++; |
| 2760 | } |
| 2761 | } |
| 2762 | } |
| 2763 | } |
| 2764 | |
| 2765 | return modes; |
| 2766 | } |
| 2767 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2768 | static void |
| 2769 | do_cvt_mode(struct detailed_timing *timing, void *c) |
| 2770 | { |
| 2771 | struct detailed_mode_closure *closure = c; |
| 2772 | struct detailed_non_pixel *data = &timing->data.other_data; |
| 2773 | |
| 2774 | if (data->type == EDID_DETAIL_CVT_3BYTE) |
| 2775 | closure->modes += drm_cvt_modes(closure->connector, timing); |
| 2776 | } |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2777 | |
| 2778 | static int |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2779 | add_cvt_modes(struct drm_connector *connector, struct edid *edid) |
| 2780 | { |
| 2781 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2782 | .connector = connector, |
| 2783 | .edid = edid, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2784 | }; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2785 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2786 | if (version_greater(edid, 1, 2)) |
| 2787 | drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2788 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2789 | /* XXX should also look for CVT codes in VTB blocks */ |
| 2790 | |
| 2791 | return closure.modes; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2792 | } |
| 2793 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 2794 | static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode); |
| 2795 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2796 | static void |
| 2797 | do_detailed_mode(struct detailed_timing *timing, void *c) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2798 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2799 | struct detailed_mode_closure *closure = c; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2800 | struct drm_display_mode *newmode; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2801 | |
| 2802 | if (timing->pixel_clock) { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2803 | newmode = drm_mode_detailed(closure->connector->dev, |
| 2804 | closure->edid, timing, |
| 2805 | closure->quirks); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2806 | if (!newmode) |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2807 | return; |
Adam Jackson | 9cf0097 | 2009-12-03 17:44:36 -0500 | [diff] [blame] | 2808 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2809 | if (closure->preferred) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2810 | newmode->type |= DRM_MODE_TYPE_PREFERRED; |
| 2811 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 2812 | /* |
| 2813 | * Detailed modes are limited to 10kHz pixel clock resolution, |
| 2814 | * so fix up anything that looks like CEA/HDMI mode, but the clock |
| 2815 | * is just slightly off. |
| 2816 | */ |
| 2817 | fixup_detailed_cea_mode_clock(newmode); |
| 2818 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2819 | drm_mode_probed_add(closure->connector, newmode); |
| 2820 | closure->modes++; |
Gustavo A. R. Silva | c2925bd | 2018-01-30 04:05:28 -0600 | [diff] [blame] | 2821 | closure->preferred = false; |
Zhao Yakui | 882f021 | 2009-08-26 18:20:49 +0800 | [diff] [blame] | 2822 | } |
Ma Ling | 167f3a0 | 2009-03-20 14:09:48 +0800 | [diff] [blame] | 2823 | } |
| 2824 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2825 | /* |
| 2826 | * add_detailed_modes - Add modes from detailed timings |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2827 | * @connector: attached connector |
| 2828 | * @edid: EDID block to scan |
| 2829 | * @quirks: quirks to apply |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2830 | */ |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2831 | static int |
| 2832 | add_detailed_modes(struct drm_connector *connector, struct edid *edid, |
| 2833 | u32 quirks) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2834 | { |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2835 | struct detailed_mode_closure closure = { |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2836 | .connector = connector, |
| 2837 | .edid = edid, |
Gustavo A. R. Silva | c2925bd | 2018-01-30 04:05:28 -0600 | [diff] [blame] | 2838 | .preferred = true, |
Julia Lawall | d456ea2 | 2014-08-23 18:09:56 +0200 | [diff] [blame] | 2839 | .quirks = quirks, |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2840 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2841 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2842 | if (closure.preferred && !version_greater(edid, 1, 3)) |
| 2843 | closure.preferred = |
| 2844 | (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); |
Adam Jackson | a327f6b | 2010-03-29 21:43:25 +0000 | [diff] [blame] | 2845 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2846 | drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2847 | |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 2848 | return closure.modes; |
Zhao Yakui | 882f021 | 2009-08-26 18:20:49 +0800 | [diff] [blame] | 2849 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2850 | |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2851 | #define AUDIO_BLOCK 0x01 |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 2852 | #define VIDEO_BLOCK 0x02 |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 2853 | #define VENDOR_BLOCK 0x03 |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 2854 | #define SPEAKER_BLOCK 0x04 |
Uma Shankar | e85959d | 2019-05-16 19:40:08 +0530 | [diff] [blame] | 2855 | #define HDR_STATIC_METADATA_BLOCK 0x6 |
Shashank Sharma | 87563fc | 2017-07-13 21:03:10 +0530 | [diff] [blame] | 2856 | #define USE_EXTENDED_TAG 0x07 |
| 2857 | #define EXT_VIDEO_CAPABILITY_BLOCK 0x00 |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 2858 | #define EXT_VIDEO_DATA_BLOCK_420 0x0E |
| 2859 | #define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2860 | #define EDID_BASIC_AUDIO (1 << 6) |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 2861 | #define EDID_CEA_YCRCB444 (1 << 5) |
| 2862 | #define EDID_CEA_YCRCB422 (1 << 4) |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 2863 | #define EDID_CEA_VCDB_QS (1 << 6) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2864 | |
Lespiau, Damien | d4e4a31 | 2013-08-19 16:58:52 +0100 | [diff] [blame] | 2865 | /* |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2866 | * Search EDID for CEA extension block. |
| 2867 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2868 | 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] | 2869 | { |
| 2870 | u8 *edid_ext = NULL; |
| 2871 | int i; |
| 2872 | |
| 2873 | /* No EDID or EDID extensions */ |
| 2874 | if (edid == NULL || edid->extensions == 0) |
| 2875 | return NULL; |
| 2876 | |
| 2877 | /* Find CEA extension */ |
| 2878 | for (i = 0; i < edid->extensions; i++) { |
| 2879 | edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2880 | if (edid_ext[0] == ext_id) |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2881 | break; |
| 2882 | } |
| 2883 | |
| 2884 | if (i == edid->extensions) |
| 2885 | return NULL; |
| 2886 | |
| 2887 | return edid_ext; |
| 2888 | } |
| 2889 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2890 | static u8 *drm_find_cea_extension(const struct edid *edid) |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2891 | { |
| 2892 | return drm_find_edid_extension(edid, CEA_EXT); |
| 2893 | } |
| 2894 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 2895 | static u8 *drm_find_displayid_extension(const struct edid *edid) |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 2896 | { |
| 2897 | return drm_find_edid_extension(edid, DISPLAYID_EXT); |
| 2898 | } |
| 2899 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2900 | /* |
| 2901 | * Calculate the alternate clock for the CEA mode |
| 2902 | * (60Hz vs. 59.94Hz etc.) |
| 2903 | */ |
| 2904 | static unsigned int |
| 2905 | cea_mode_alternate_clock(const struct drm_display_mode *cea_mode) |
| 2906 | { |
| 2907 | unsigned int clock = cea_mode->clock; |
| 2908 | |
| 2909 | if (cea_mode->vrefresh % 6 != 0) |
| 2910 | return clock; |
| 2911 | |
| 2912 | /* |
| 2913 | * edid_cea_modes contains the 59.94Hz |
| 2914 | * variant for 240 and 480 line modes, |
| 2915 | * and the 60Hz variant otherwise. |
| 2916 | */ |
| 2917 | if (cea_mode->vdisplay == 240 || cea_mode->vdisplay == 480) |
Ville Syrjälä | 9afd808 | 2015-10-08 11:43:33 +0300 | [diff] [blame] | 2918 | clock = DIV_ROUND_CLOSEST(clock * 1001, 1000); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2919 | else |
Ville Syrjälä | 9afd808 | 2015-10-08 11:43:33 +0300 | [diff] [blame] | 2920 | clock = DIV_ROUND_CLOSEST(clock * 1000, 1001); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 2921 | |
| 2922 | return clock; |
| 2923 | } |
| 2924 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2925 | static bool |
| 2926 | cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode) |
| 2927 | { |
| 2928 | /* |
| 2929 | * For certain VICs the spec allows the vertical |
| 2930 | * front porch to vary by one or two lines. |
| 2931 | * |
| 2932 | * cea_modes[] stores the variant with the shortest |
| 2933 | * vertical front porch. We can adjust the mode to |
| 2934 | * get the other variants by simply increasing the |
| 2935 | * vertical front porch length. |
| 2936 | */ |
| 2937 | BUILD_BUG_ON(edid_cea_modes[8].vtotal != 262 || |
| 2938 | edid_cea_modes[9].vtotal != 262 || |
| 2939 | edid_cea_modes[12].vtotal != 262 || |
| 2940 | edid_cea_modes[13].vtotal != 262 || |
| 2941 | edid_cea_modes[23].vtotal != 312 || |
| 2942 | edid_cea_modes[24].vtotal != 312 || |
| 2943 | edid_cea_modes[27].vtotal != 312 || |
| 2944 | edid_cea_modes[28].vtotal != 312); |
| 2945 | |
| 2946 | if (((vic == 8 || vic == 9 || |
| 2947 | vic == 12 || vic == 13) && mode->vtotal < 263) || |
| 2948 | ((vic == 23 || vic == 24 || |
| 2949 | vic == 27 || vic == 28) && mode->vtotal < 314)) { |
| 2950 | mode->vsync_start++; |
| 2951 | mode->vsync_end++; |
| 2952 | mode->vtotal++; |
| 2953 | |
| 2954 | return true; |
| 2955 | } |
| 2956 | |
| 2957 | return false; |
| 2958 | } |
| 2959 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2960 | static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match, |
| 2961 | unsigned int clock_tolerance) |
| 2962 | { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 2963 | unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2964 | u8 vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2965 | |
| 2966 | if (!to_match->clock) |
| 2967 | return 0; |
| 2968 | |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 2969 | if (to_match->picture_aspect_ratio) |
| 2970 | match_flags |= DRM_MODE_MATCH_ASPECT_RATIO; |
| 2971 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 2972 | for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2973 | struct drm_display_mode cea_mode = edid_cea_modes[vic]; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2974 | unsigned int clock1, clock2; |
| 2975 | |
| 2976 | /* Check both 60Hz and 59.94Hz */ |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2977 | clock1 = cea_mode.clock; |
| 2978 | clock2 = cea_mode_alternate_clock(&cea_mode); |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2979 | |
| 2980 | if (abs(to_match->clock - clock1) > clock_tolerance && |
| 2981 | abs(to_match->clock - clock2) > clock_tolerance) |
| 2982 | continue; |
| 2983 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2984 | do { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 2985 | if (drm_mode_match(to_match, &cea_mode, match_flags)) |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 2986 | return vic; |
| 2987 | } while (cea_mode_alternate_timings(vic, &cea_mode)); |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 2988 | } |
| 2989 | |
| 2990 | return 0; |
| 2991 | } |
| 2992 | |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 2993 | /** |
| 2994 | * drm_match_cea_mode - look for a CEA mode matching given mode |
| 2995 | * @to_match: display mode |
| 2996 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 2997 | * 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] | 2998 | * mode. |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 2999 | */ |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 3000 | u8 drm_match_cea_mode(const struct drm_display_mode *to_match) |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3001 | { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3002 | unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3003 | u8 vic; |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3004 | |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 3005 | if (!to_match->clock) |
| 3006 | return 0; |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3007 | |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3008 | if (to_match->picture_aspect_ratio) |
| 3009 | match_flags |= DRM_MODE_MATCH_ASPECT_RATIO; |
| 3010 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3011 | for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) { |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 3012 | struct drm_display_mode cea_mode = edid_cea_modes[vic]; |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 3013 | unsigned int clock1, clock2; |
| 3014 | |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 3015 | /* Check both 60Hz and 59.94Hz */ |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 3016 | clock1 = cea_mode.clock; |
| 3017 | clock2 = cea_mode_alternate_clock(&cea_mode); |
Ville Syrjälä | a90b590 | 2013-04-24 19:07:18 +0300 | [diff] [blame] | 3018 | |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 3019 | if (KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock1) && |
| 3020 | KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock2)) |
| 3021 | continue; |
| 3022 | |
| 3023 | do { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3024 | if (drm_mode_match(to_match, &cea_mode, match_flags)) |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 3025 | return vic; |
| 3026 | } while (cea_mode_alternate_timings(vic, &cea_mode)); |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3027 | } |
Ville Syrjälä | c45a4e4 | 2016-11-03 14:53:29 +0200 | [diff] [blame] | 3028 | |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3029 | return 0; |
| 3030 | } |
| 3031 | EXPORT_SYMBOL(drm_match_cea_mode); |
| 3032 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3033 | static bool drm_valid_cea_vic(u8 vic) |
| 3034 | { |
| 3035 | return vic > 0 && vic < ARRAY_SIZE(edid_cea_modes); |
| 3036 | } |
| 3037 | |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 3038 | /** |
| 3039 | * drm_get_cea_aspect_ratio - get the picture aspect ratio corresponding to |
| 3040 | * the input VIC from the CEA mode list |
| 3041 | * @video_code: ID given to each of the CEA modes |
| 3042 | * |
| 3043 | * Returns picture aspect ratio |
| 3044 | */ |
| 3045 | enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code) |
| 3046 | { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3047 | return edid_cea_modes[video_code].picture_aspect_ratio; |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 3048 | } |
| 3049 | EXPORT_SYMBOL(drm_get_cea_aspect_ratio); |
| 3050 | |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3051 | /* |
| 3052 | * Calculate the alternate clock for HDMI modes (those from the HDMI vendor |
| 3053 | * specific block). |
| 3054 | * |
| 3055 | * It's almost like cea_mode_alternate_clock(), we just need to add an |
| 3056 | * exception for the VIC 4 mode (4096x2160@24Hz): no alternate clock for this |
| 3057 | * one. |
| 3058 | */ |
| 3059 | static unsigned int |
| 3060 | hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode) |
| 3061 | { |
| 3062 | if (hdmi_mode->vdisplay == 4096 && hdmi_mode->hdisplay == 2160) |
| 3063 | return hdmi_mode->clock; |
| 3064 | |
| 3065 | return cea_mode_alternate_clock(hdmi_mode); |
| 3066 | } |
| 3067 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3068 | static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match, |
| 3069 | unsigned int clock_tolerance) |
| 3070 | { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3071 | unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3072 | u8 vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3073 | |
| 3074 | if (!to_match->clock) |
| 3075 | return 0; |
| 3076 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3077 | for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { |
| 3078 | const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3079 | unsigned int clock1, clock2; |
| 3080 | |
| 3081 | /* Make sure to also match alternate clocks */ |
| 3082 | clock1 = hdmi_mode->clock; |
| 3083 | clock2 = hdmi_mode_alternate_clock(hdmi_mode); |
| 3084 | |
| 3085 | if (abs(to_match->clock - clock1) > clock_tolerance && |
| 3086 | abs(to_match->clock - clock2) > clock_tolerance) |
| 3087 | continue; |
| 3088 | |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3089 | if (drm_mode_match(to_match, hdmi_mode, match_flags)) |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3090 | return vic; |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3091 | } |
| 3092 | |
| 3093 | return 0; |
| 3094 | } |
| 3095 | |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3096 | /* |
| 3097 | * drm_match_hdmi_mode - look for a HDMI mode matching given mode |
| 3098 | * @to_match: display mode |
| 3099 | * |
| 3100 | * An HDMI mode is one defined in the HDMI vendor specific block. |
| 3101 | * |
| 3102 | * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one. |
| 3103 | */ |
| 3104 | static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) |
| 3105 | { |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3106 | unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3107 | u8 vic; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3108 | |
| 3109 | if (!to_match->clock) |
| 3110 | return 0; |
| 3111 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3112 | for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) { |
| 3113 | const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3114 | unsigned int clock1, clock2; |
| 3115 | |
| 3116 | /* Make sure to also match alternate clocks */ |
| 3117 | clock1 = hdmi_mode->clock; |
| 3118 | clock2 = hdmi_mode_alternate_clock(hdmi_mode); |
| 3119 | |
| 3120 | if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || |
| 3121 | KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && |
Ville Syrjälä | 357768c | 2018-05-08 16:39:38 +0530 | [diff] [blame] | 3122 | drm_mode_match(to_match, hdmi_mode, match_flags)) |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3123 | return vic; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3124 | } |
| 3125 | return 0; |
| 3126 | } |
| 3127 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3128 | static bool drm_valid_hdmi_vic(u8 vic) |
| 3129 | { |
| 3130 | return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes); |
| 3131 | } |
| 3132 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3133 | static int |
| 3134 | add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid) |
| 3135 | { |
| 3136 | struct drm_device *dev = connector->dev; |
| 3137 | struct drm_display_mode *mode, *tmp; |
| 3138 | LIST_HEAD(list); |
| 3139 | int modes = 0; |
| 3140 | |
| 3141 | /* Don't add CEA modes if the CEA extension block is missing */ |
| 3142 | if (!drm_find_cea_extension(edid)) |
| 3143 | return 0; |
| 3144 | |
| 3145 | /* |
| 3146 | * Go through all probed modes and create a new mode |
| 3147 | * with the alternate clock for certain CEA modes. |
| 3148 | */ |
| 3149 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3150 | const struct drm_display_mode *cea_mode = NULL; |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3151 | struct drm_display_mode *newmode; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3152 | u8 vic = drm_match_cea_mode(mode); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3153 | unsigned int clock1, clock2; |
| 3154 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3155 | if (drm_valid_cea_vic(vic)) { |
| 3156 | cea_mode = &edid_cea_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3157 | clock2 = cea_mode_alternate_clock(cea_mode); |
| 3158 | } else { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3159 | vic = drm_match_hdmi_mode(mode); |
| 3160 | if (drm_valid_hdmi_vic(vic)) { |
| 3161 | cea_mode = &edid_4k_modes[vic]; |
Lespiau, Damien | 3f2f653 | 2013-08-19 16:58:55 +0100 | [diff] [blame] | 3162 | clock2 = hdmi_mode_alternate_clock(cea_mode); |
| 3163 | } |
| 3164 | } |
| 3165 | |
| 3166 | if (!cea_mode) |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3167 | continue; |
| 3168 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3169 | clock1 = cea_mode->clock; |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3170 | |
| 3171 | if (clock1 == clock2) |
| 3172 | continue; |
| 3173 | |
| 3174 | if (mode->clock != clock1 && mode->clock != clock2) |
| 3175 | continue; |
| 3176 | |
| 3177 | newmode = drm_mode_duplicate(dev, cea_mode); |
| 3178 | if (!newmode) |
| 3179 | continue; |
| 3180 | |
Damien Lespiau | 2713021 | 2013-09-25 16:45:28 +0100 | [diff] [blame] | 3181 | /* Carry over the stereo flags */ |
| 3182 | newmode->flags |= mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 3183 | |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 3184 | /* |
| 3185 | * The current mode could be either variant. Make |
| 3186 | * sure to pick the "other" clock for the new mode. |
| 3187 | */ |
| 3188 | if (mode->clock != clock1) |
| 3189 | newmode->clock = clock1; |
| 3190 | else |
| 3191 | newmode->clock = clock2; |
| 3192 | |
| 3193 | list_add_tail(&newmode->head, &list); |
| 3194 | } |
| 3195 | |
| 3196 | list_for_each_entry_safe(mode, tmp, &list, head) { |
| 3197 | list_del(&mode->head); |
| 3198 | drm_mode_probed_add(connector, mode); |
| 3199 | modes++; |
| 3200 | } |
| 3201 | |
| 3202 | return modes; |
| 3203 | } |
Stephane Marchesin | a479903 | 2012-11-09 16:21:05 +0000 | [diff] [blame] | 3204 | |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 3205 | static u8 svd_to_vic(u8 svd) |
| 3206 | { |
| 3207 | /* 0-6 bit vic, 7th bit native mode indicator */ |
| 3208 | if ((svd >= 1 && svd <= 64) || (svd >= 129 && svd <= 192)) |
| 3209 | return svd & 127; |
| 3210 | |
| 3211 | return svd; |
| 3212 | } |
| 3213 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3214 | static struct drm_display_mode * |
| 3215 | drm_display_mode_from_vic_index(struct drm_connector *connector, |
| 3216 | const u8 *video_db, u8 video_len, |
| 3217 | u8 video_index) |
| 3218 | { |
| 3219 | struct drm_device *dev = connector->dev; |
| 3220 | struct drm_display_mode *newmode; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3221 | u8 vic; |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3222 | |
| 3223 | if (video_db == NULL || video_index >= video_len) |
| 3224 | return NULL; |
| 3225 | |
| 3226 | /* CEA modes are numbered 1..127 */ |
Shashank Sharma | 8ec6e07 | 2017-07-13 21:03:08 +0530 | [diff] [blame] | 3227 | vic = svd_to_vic(video_db[video_index]); |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3228 | if (!drm_valid_cea_vic(vic)) |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3229 | return NULL; |
| 3230 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3231 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]); |
Damien Lespiau | 409bbf1 | 2014-03-03 23:59:07 +0000 | [diff] [blame] | 3232 | if (!newmode) |
| 3233 | return NULL; |
| 3234 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3235 | newmode->vrefresh = 0; |
| 3236 | |
| 3237 | return newmode; |
| 3238 | } |
| 3239 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3240 | /* |
| 3241 | * do_y420vdb_modes - Parse YCBCR 420 only modes |
| 3242 | * @connector: connector corresponding to the HDMI sink |
| 3243 | * @svds: start of the data block of CEA YCBCR 420 VDB |
| 3244 | * @len: length of the CEA YCBCR 420 VDB |
| 3245 | * |
| 3246 | * Parse the CEA-861-F YCBCR 420 Video Data Block (Y420VDB) |
| 3247 | * which contains modes which can be supported in YCBCR 420 |
| 3248 | * output format only. |
| 3249 | */ |
| 3250 | static int do_y420vdb_modes(struct drm_connector *connector, |
| 3251 | const u8 *svds, u8 svds_len) |
| 3252 | { |
| 3253 | int modes = 0, i; |
| 3254 | struct drm_device *dev = connector->dev; |
| 3255 | struct drm_display_info *info = &connector->display_info; |
| 3256 | struct drm_hdmi_info *hdmi = &info->hdmi; |
| 3257 | |
| 3258 | for (i = 0; i < svds_len; i++) { |
| 3259 | u8 vic = svd_to_vic(svds[i]); |
| 3260 | struct drm_display_mode *newmode; |
| 3261 | |
| 3262 | if (!drm_valid_cea_vic(vic)) |
| 3263 | continue; |
| 3264 | |
| 3265 | newmode = drm_mode_duplicate(dev, &edid_cea_modes[vic]); |
| 3266 | if (!newmode) |
| 3267 | break; |
| 3268 | bitmap_set(hdmi->y420_vdb_modes, vic, 1); |
| 3269 | drm_mode_probed_add(connector, newmode); |
| 3270 | modes++; |
| 3271 | } |
| 3272 | |
| 3273 | if (modes > 0) |
| 3274 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3275 | return modes; |
| 3276 | } |
| 3277 | |
| 3278 | /* |
| 3279 | * drm_add_cmdb_modes - Add a YCBCR 420 mode into bitmap |
| 3280 | * @connector: connector corresponding to the HDMI sink |
| 3281 | * @vic: CEA vic for the video mode to be added in the map |
| 3282 | * |
| 3283 | * Makes an entry for a videomode in the YCBCR 420 bitmap |
| 3284 | */ |
| 3285 | static void |
| 3286 | drm_add_cmdb_modes(struct drm_connector *connector, u8 svd) |
| 3287 | { |
| 3288 | u8 vic = svd_to_vic(svd); |
| 3289 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
| 3290 | |
| 3291 | if (!drm_valid_cea_vic(vic)) |
| 3292 | return; |
| 3293 | |
| 3294 | bitmap_set(hdmi->y420_cmdb_modes, vic, 1); |
| 3295 | } |
| 3296 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3297 | static int |
Lespiau, Damien | 13ac3f5 | 2013-08-19 16:58:53 +0100 | [diff] [blame] | 3298 | do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len) |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3299 | { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3300 | int i, modes = 0; |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3301 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3302 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3303 | for (i = 0; i < len; i++) { |
| 3304 | struct drm_display_mode *mode; |
| 3305 | mode = drm_display_mode_from_vic_index(connector, db, len, i); |
| 3306 | if (mode) { |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3307 | /* |
| 3308 | * YCBCR420 capability block contains a bitmap which |
| 3309 | * gives the index of CEA modes from CEA VDB, which |
| 3310 | * can support YCBCR 420 sampling output also (apart |
| 3311 | * from RGB/YCBCR444 etc). |
| 3312 | * For example, if the bit 0 in bitmap is set, |
| 3313 | * first mode in VDB can support YCBCR420 output too. |
| 3314 | * Add YCBCR420 modes only if sink is HDMI 2.0 capable. |
| 3315 | */ |
| 3316 | if (i < 64 && hdmi->y420_cmdb_map & (1ULL << i)) |
| 3317 | drm_add_cmdb_modes(connector, db[i]); |
| 3318 | |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3319 | drm_mode_probed_add(connector, mode); |
| 3320 | modes++; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3321 | } |
| 3322 | } |
| 3323 | |
| 3324 | return modes; |
| 3325 | } |
| 3326 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3327 | struct stereo_mandatory_mode { |
| 3328 | int width, height, vrefresh; |
| 3329 | unsigned int flags; |
| 3330 | }; |
| 3331 | |
| 3332 | static const struct stereo_mandatory_mode stereo_mandatory_modes[] = { |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3333 | { 1920, 1080, 24, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3334 | { 1920, 1080, 24, DRM_MODE_FLAG_3D_FRAME_PACKING }, |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3335 | { 1920, 1080, 50, |
| 3336 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, |
| 3337 | { 1920, 1080, 60, |
| 3338 | DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF }, |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3339 | { 1280, 720, 50, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3340 | { 1280, 720, 50, DRM_MODE_FLAG_3D_FRAME_PACKING }, |
| 3341 | { 1280, 720, 60, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM }, |
| 3342 | { 1280, 720, 60, DRM_MODE_FLAG_3D_FRAME_PACKING } |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3343 | }; |
| 3344 | |
| 3345 | static bool |
| 3346 | stereo_match_mandatory(const struct drm_display_mode *mode, |
| 3347 | const struct stereo_mandatory_mode *stereo_mode) |
| 3348 | { |
| 3349 | unsigned int interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; |
| 3350 | |
| 3351 | return mode->hdisplay == stereo_mode->width && |
| 3352 | mode->vdisplay == stereo_mode->height && |
| 3353 | interlaced == (stereo_mode->flags & DRM_MODE_FLAG_INTERLACE) && |
| 3354 | drm_mode_vrefresh(mode) == stereo_mode->vrefresh; |
| 3355 | } |
| 3356 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3357 | static int add_hdmi_mandatory_stereo_modes(struct drm_connector *connector) |
| 3358 | { |
| 3359 | struct drm_device *dev = connector->dev; |
| 3360 | const struct drm_display_mode *mode; |
| 3361 | struct list_head stereo_modes; |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3362 | int modes = 0, i; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3363 | |
| 3364 | INIT_LIST_HEAD(&stereo_modes); |
| 3365 | |
| 3366 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3367 | for (i = 0; i < ARRAY_SIZE(stereo_mandatory_modes); i++) { |
| 3368 | const struct stereo_mandatory_mode *mandatory; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3369 | struct drm_display_mode *new_mode; |
| 3370 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3371 | if (!stereo_match_mandatory(mode, |
| 3372 | &stereo_mandatory_modes[i])) |
| 3373 | continue; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3374 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3375 | mandatory = &stereo_mandatory_modes[i]; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3376 | new_mode = drm_mode_duplicate(dev, mode); |
| 3377 | if (!new_mode) |
| 3378 | continue; |
| 3379 | |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3380 | new_mode->flags |= mandatory->flags; |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3381 | list_add_tail(&new_mode->head, &stereo_modes); |
| 3382 | modes++; |
Damien Lespiau | f7e121b | 2013-09-27 12:11:48 +0100 | [diff] [blame] | 3383 | } |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3384 | } |
| 3385 | |
| 3386 | list_splice_tail(&stereo_modes, &connector->probed_modes); |
| 3387 | |
| 3388 | return modes; |
| 3389 | } |
| 3390 | |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3391 | static int add_hdmi_mode(struct drm_connector *connector, u8 vic) |
| 3392 | { |
| 3393 | struct drm_device *dev = connector->dev; |
| 3394 | struct drm_display_mode *newmode; |
| 3395 | |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3396 | if (!drm_valid_hdmi_vic(vic)) { |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3397 | DRM_ERROR("Unknown HDMI VIC: %d\n", vic); |
| 3398 | return 0; |
| 3399 | } |
| 3400 | |
| 3401 | newmode = drm_mode_duplicate(dev, &edid_4k_modes[vic]); |
| 3402 | if (!newmode) |
| 3403 | return 0; |
| 3404 | |
| 3405 | drm_mode_probed_add(connector, newmode); |
| 3406 | |
| 3407 | return 1; |
| 3408 | } |
| 3409 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3410 | static int add_3d_struct_modes(struct drm_connector *connector, u16 structure, |
| 3411 | const u8 *video_db, u8 video_len, u8 video_index) |
| 3412 | { |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3413 | struct drm_display_mode *newmode; |
| 3414 | int modes = 0; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3415 | |
| 3416 | if (structure & (1 << 0)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3417 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3418 | video_len, |
| 3419 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3420 | if (newmode) { |
| 3421 | newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING; |
| 3422 | drm_mode_probed_add(connector, newmode); |
| 3423 | modes++; |
| 3424 | } |
| 3425 | } |
| 3426 | if (structure & (1 << 6)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3427 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3428 | video_len, |
| 3429 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3430 | if (newmode) { |
| 3431 | newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; |
| 3432 | drm_mode_probed_add(connector, newmode); |
| 3433 | modes++; |
| 3434 | } |
| 3435 | } |
| 3436 | if (structure & (1 << 8)) { |
Thomas Wood | aff04ac | 2013-11-29 15:33:27 +0000 | [diff] [blame] | 3437 | newmode = drm_display_mode_from_vic_index(connector, video_db, |
| 3438 | video_len, |
| 3439 | video_index); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3440 | if (newmode) { |
Thomas Wood | 89570ee | 2013-11-28 15:35:04 +0000 | [diff] [blame] | 3441 | newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3442 | drm_mode_probed_add(connector, newmode); |
| 3443 | modes++; |
| 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | return modes; |
| 3448 | } |
| 3449 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3450 | /* |
| 3451 | * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block |
| 3452 | * @connector: connector corresponding to the HDMI sink |
| 3453 | * @db: start of the CEA vendor specific block |
| 3454 | * @len: length of the CEA block payload, ie. one can access up to db[len] |
| 3455 | * |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3456 | * Parses the HDMI VSDB looking for modes to add to @connector. This function |
| 3457 | * also adds the stereo 3d modes when applicable. |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3458 | */ |
| 3459 | static int |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3460 | do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len, |
| 3461 | const u8 *video_db, u8 video_len) |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3462 | { |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 3463 | struct drm_display_info *info = &connector->display_info; |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3464 | int modes = 0, offset = 0, i, multi_present = 0, multi_len; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3465 | u8 vic_len, hdmi_3d_len = 0; |
| 3466 | u16 mask; |
| 3467 | u16 structure_all; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3468 | |
| 3469 | if (len < 8) |
| 3470 | goto out; |
| 3471 | |
| 3472 | /* no HDMI_Video_Present */ |
| 3473 | if (!(db[8] & (1 << 5))) |
| 3474 | goto out; |
| 3475 | |
| 3476 | /* Latency_Fields_Present */ |
| 3477 | if (db[8] & (1 << 7)) |
| 3478 | offset += 2; |
| 3479 | |
| 3480 | /* I_Latency_Fields_Present */ |
| 3481 | if (db[8] & (1 << 6)) |
| 3482 | offset += 2; |
| 3483 | |
| 3484 | /* the declared length is not long enough for the 2 first bytes |
| 3485 | * of additional video format capabilities */ |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3486 | if (len < (8 + offset + 2)) |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3487 | goto out; |
| 3488 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3489 | /* 3D_Present */ |
| 3490 | offset++; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3491 | if (db[8 + offset] & (1 << 7)) { |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3492 | modes += add_hdmi_mandatory_stereo_modes(connector); |
| 3493 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3494 | /* 3D_Multi_present */ |
| 3495 | multi_present = (db[8 + offset] & 0x60) >> 5; |
| 3496 | } |
| 3497 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3498 | offset++; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3499 | vic_len = db[8 + offset] >> 5; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3500 | hdmi_3d_len = db[8 + offset] & 0x1f; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3501 | |
| 3502 | for (i = 0; i < vic_len && len >= (9 + offset + i); i++) { |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3503 | u8 vic; |
| 3504 | |
| 3505 | vic = db[9 + offset + i]; |
Damien Lespiau | 1deee8d | 2013-09-25 16:45:24 +0100 | [diff] [blame] | 3506 | modes += add_hdmi_mode(connector, vic); |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3507 | } |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3508 | offset += 1 + vic_len; |
| 3509 | |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3510 | if (multi_present == 1) |
| 3511 | multi_len = 2; |
| 3512 | else if (multi_present == 2) |
| 3513 | multi_len = 4; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3514 | else |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3515 | multi_len = 0; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3516 | |
Thomas Wood | 0e5083aa | 2013-11-29 18:18:58 +0000 | [diff] [blame] | 3517 | if (len < (8 + offset + hdmi_3d_len - 1)) |
| 3518 | goto out; |
| 3519 | |
| 3520 | if (hdmi_3d_len < multi_len) |
| 3521 | goto out; |
| 3522 | |
| 3523 | if (multi_present == 1 || multi_present == 2) { |
| 3524 | /* 3D_Structure_ALL */ |
| 3525 | structure_all = (db[8 + offset] << 8) | db[9 + offset]; |
| 3526 | |
| 3527 | /* check if 3D_MASK is present */ |
| 3528 | if (multi_present == 2) |
| 3529 | mask = (db[10 + offset] << 8) | db[11 + offset]; |
| 3530 | else |
| 3531 | mask = 0xffff; |
| 3532 | |
| 3533 | for (i = 0; i < 16; i++) { |
| 3534 | if (mask & (1 << i)) |
| 3535 | modes += add_3d_struct_modes(connector, |
| 3536 | structure_all, |
| 3537 | video_db, |
| 3538 | video_len, i); |
| 3539 | } |
| 3540 | } |
| 3541 | |
| 3542 | offset += multi_len; |
| 3543 | |
| 3544 | for (i = 0; i < (hdmi_3d_len - multi_len); i++) { |
| 3545 | int vic_index; |
| 3546 | struct drm_display_mode *newmode = NULL; |
| 3547 | unsigned int newflag = 0; |
| 3548 | bool detail_present; |
| 3549 | |
| 3550 | detail_present = ((db[8 + offset + i] & 0x0f) > 7); |
| 3551 | |
| 3552 | if (detail_present && (i + 1 == hdmi_3d_len - multi_len)) |
| 3553 | break; |
| 3554 | |
| 3555 | /* 2D_VIC_order_X */ |
| 3556 | vic_index = db[8 + offset + i] >> 4; |
| 3557 | |
| 3558 | /* 3D_Structure_X */ |
| 3559 | switch (db[8 + offset + i] & 0x0f) { |
| 3560 | case 0: |
| 3561 | newflag = DRM_MODE_FLAG_3D_FRAME_PACKING; |
| 3562 | break; |
| 3563 | case 6: |
| 3564 | newflag = DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; |
| 3565 | break; |
| 3566 | case 8: |
| 3567 | /* 3D_Detail_X */ |
| 3568 | if ((db[9 + offset + i] >> 4) == 1) |
| 3569 | newflag = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; |
| 3570 | break; |
| 3571 | } |
| 3572 | |
| 3573 | if (newflag != 0) { |
| 3574 | newmode = drm_display_mode_from_vic_index(connector, |
| 3575 | video_db, |
| 3576 | video_len, |
| 3577 | vic_index); |
| 3578 | |
| 3579 | if (newmode) { |
| 3580 | newmode->flags |= newflag; |
| 3581 | drm_mode_probed_add(connector, newmode); |
| 3582 | modes++; |
| 3583 | } |
| 3584 | } |
| 3585 | |
| 3586 | if (detail_present) |
| 3587 | i++; |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3588 | } |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3589 | |
| 3590 | out: |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 3591 | if (modes > 0) |
| 3592 | info->has_hdmi_infoframe = true; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3593 | return modes; |
| 3594 | } |
| 3595 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3596 | static int |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3597 | cea_db_payload_len(const u8 *db) |
| 3598 | { |
| 3599 | return db[0] & 0x1f; |
| 3600 | } |
| 3601 | |
| 3602 | static int |
Shashank Sharma | 87563fc | 2017-07-13 21:03:10 +0530 | [diff] [blame] | 3603 | cea_db_extended_tag(const u8 *db) |
| 3604 | { |
| 3605 | return db[1]; |
| 3606 | } |
| 3607 | |
| 3608 | static int |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3609 | cea_db_tag(const u8 *db) |
| 3610 | { |
| 3611 | return db[0] >> 5; |
| 3612 | } |
| 3613 | |
| 3614 | static int |
| 3615 | cea_revision(const u8 *cea) |
| 3616 | { |
| 3617 | return cea[1]; |
| 3618 | } |
| 3619 | |
| 3620 | static int |
| 3621 | cea_db_offsets(const u8 *cea, int *start, int *end) |
| 3622 | { |
| 3623 | /* Data block offset in CEA extension block */ |
| 3624 | *start = 4; |
| 3625 | *end = cea[2]; |
| 3626 | if (*end == 0) |
| 3627 | *end = 127; |
| 3628 | if (*end < 4 || *end > 127) |
| 3629 | return -ERANGE; |
| 3630 | return 0; |
| 3631 | } |
| 3632 | |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3633 | static bool cea_db_is_hdmi_vsdb(const u8 *db) |
| 3634 | { |
| 3635 | int hdmi_id; |
| 3636 | |
| 3637 | if (cea_db_tag(db) != VENDOR_BLOCK) |
| 3638 | return false; |
| 3639 | |
| 3640 | if (cea_db_payload_len(db) < 5) |
| 3641 | return false; |
| 3642 | |
| 3643 | hdmi_id = db[1] | (db[2] << 8) | (db[3] << 16); |
| 3644 | |
Lespiau, Damien | 6cb3b7f | 2013-08-19 16:59:05 +0100 | [diff] [blame] | 3645 | return hdmi_id == HDMI_IEEE_OUI; |
Lespiau, Damien | 7ebe196 | 2013-08-19 16:58:54 +0100 | [diff] [blame] | 3646 | } |
| 3647 | |
Thierry Reding | 50dd1bd | 2017-03-13 16:54:00 +0530 | [diff] [blame] | 3648 | static bool cea_db_is_hdmi_forum_vsdb(const u8 *db) |
| 3649 | { |
| 3650 | unsigned int oui; |
| 3651 | |
| 3652 | if (cea_db_tag(db) != VENDOR_BLOCK) |
| 3653 | return false; |
| 3654 | |
| 3655 | if (cea_db_payload_len(db) < 7) |
| 3656 | return false; |
| 3657 | |
| 3658 | oui = db[3] << 16 | db[2] << 8 | db[1]; |
| 3659 | |
| 3660 | return oui == HDMI_FORUM_IEEE_OUI; |
| 3661 | } |
| 3662 | |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 3663 | static bool cea_db_is_vcdb(const u8 *db) |
| 3664 | { |
| 3665 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3666 | return false; |
| 3667 | |
| 3668 | if (cea_db_payload_len(db) != 2) |
| 3669 | return false; |
| 3670 | |
| 3671 | if (cea_db_extended_tag(db) != EXT_VIDEO_CAPABILITY_BLOCK) |
| 3672 | return false; |
| 3673 | |
| 3674 | return true; |
| 3675 | } |
| 3676 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3677 | static bool cea_db_is_y420cmdb(const u8 *db) |
| 3678 | { |
| 3679 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3680 | return false; |
| 3681 | |
| 3682 | if (!cea_db_payload_len(db)) |
| 3683 | return false; |
| 3684 | |
| 3685 | if (cea_db_extended_tag(db) != EXT_VIDEO_CAP_BLOCK_Y420CMDB) |
| 3686 | return false; |
| 3687 | |
| 3688 | return true; |
| 3689 | } |
| 3690 | |
| 3691 | static bool cea_db_is_y420vdb(const u8 *db) |
| 3692 | { |
| 3693 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3694 | return false; |
| 3695 | |
| 3696 | if (!cea_db_payload_len(db)) |
| 3697 | return false; |
| 3698 | |
| 3699 | if (cea_db_extended_tag(db) != EXT_VIDEO_DATA_BLOCK_420) |
| 3700 | return false; |
| 3701 | |
| 3702 | return true; |
| 3703 | } |
| 3704 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3705 | #define for_each_cea_db(cea, i, start, end) \ |
| 3706 | for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1) |
| 3707 | |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3708 | static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector, |
| 3709 | const u8 *db) |
| 3710 | { |
| 3711 | struct drm_display_info *info = &connector->display_info; |
| 3712 | struct drm_hdmi_info *hdmi = &info->hdmi; |
| 3713 | u8 map_len = cea_db_payload_len(db) - 1; |
| 3714 | u8 count; |
| 3715 | u64 map = 0; |
| 3716 | |
| 3717 | if (map_len == 0) { |
| 3718 | /* All CEA modes support ycbcr420 sampling also.*/ |
| 3719 | hdmi->y420_cmdb_map = U64_MAX; |
| 3720 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3721 | return; |
| 3722 | } |
| 3723 | |
| 3724 | /* |
| 3725 | * This map indicates which of the existing CEA block modes |
| 3726 | * from VDB can support YCBCR420 output too. So if bit=0 is |
| 3727 | * set, first mode from VDB can support YCBCR420 output too. |
| 3728 | * We will parse and keep this map, before parsing VDB itself |
| 3729 | * to avoid going through the same block again and again. |
| 3730 | * |
| 3731 | * Spec is not clear about max possible size of this block. |
| 3732 | * Clamping max bitmap block size at 8 bytes. Every byte can |
| 3733 | * address 8 CEA modes, in this way this map can address |
| 3734 | * 8*8 = first 64 SVDs. |
| 3735 | */ |
| 3736 | if (WARN_ON_ONCE(map_len > 8)) |
| 3737 | map_len = 8; |
| 3738 | |
| 3739 | for (count = 0; count < map_len; count++) |
| 3740 | map |= (u64)db[2 + count] << (8 * count); |
| 3741 | |
| 3742 | if (map) |
| 3743 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; |
| 3744 | |
| 3745 | hdmi->y420_cmdb_map = map; |
| 3746 | } |
| 3747 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3748 | static int |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3749 | add_cea_modes(struct drm_connector *connector, struct edid *edid) |
| 3750 | { |
Lespiau, Damien | 13ac3f5 | 2013-08-19 16:58:53 +0100 | [diff] [blame] | 3751 | const u8 *cea = drm_find_cea_extension(edid); |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3752 | const u8 *db, *hdmi = NULL, *video = NULL; |
| 3753 | u8 dbl, hdmi_len, video_len = 0; |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3754 | int modes = 0; |
| 3755 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 3756 | if (cea && cea_revision(cea) >= 3) { |
| 3757 | int i, start, end; |
| 3758 | |
| 3759 | if (cea_db_offsets(cea, &start, &end)) |
| 3760 | return 0; |
| 3761 | |
| 3762 | for_each_cea_db(cea, i, start, end) { |
| 3763 | db = &cea[i]; |
| 3764 | dbl = cea_db_payload_len(db); |
| 3765 | |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3766 | if (cea_db_tag(db) == VIDEO_BLOCK) { |
| 3767 | video = db + 1; |
| 3768 | video_len = dbl; |
| 3769 | modes += do_cea_modes(connector, video, dbl); |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3770 | } else if (cea_db_is_hdmi_vsdb(db)) { |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3771 | hdmi = db; |
| 3772 | hdmi_len = dbl; |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 3773 | } else if (cea_db_is_y420vdb(db)) { |
| 3774 | const u8 *vdb420 = &db[2]; |
| 3775 | |
| 3776 | /* Add 4:2:0(only) modes present in EDID */ |
| 3777 | modes += do_y420vdb_modes(connector, |
| 3778 | vdb420, |
| 3779 | dbl - 1); |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3780 | } |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3781 | } |
| 3782 | } |
| 3783 | |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3784 | /* |
| 3785 | * We parse the HDMI VSDB after having added the cea modes as we will |
| 3786 | * be patching their flags when the sink supports stereo 3D. |
| 3787 | */ |
| 3788 | if (hdmi) |
Thomas Wood | fbf4602 | 2013-10-16 15:58:50 +0100 | [diff] [blame] | 3789 | modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video, |
| 3790 | video_len); |
Damien Lespiau | c858cfc | 2013-09-25 16:45:23 +0100 | [diff] [blame] | 3791 | |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 3792 | return modes; |
| 3793 | } |
| 3794 | |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3795 | static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode) |
| 3796 | { |
| 3797 | const struct drm_display_mode *cea_mode; |
| 3798 | int clock1, clock2, clock; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3799 | u8 vic; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3800 | const char *type; |
| 3801 | |
Ville Syrjälä | 4c6bcf4 | 2015-11-16 21:05:12 +0200 | [diff] [blame] | 3802 | /* |
| 3803 | * allow 5kHz clock difference either way to account for |
| 3804 | * the 10kHz clock resolution limit of detailed timings. |
| 3805 | */ |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3806 | vic = drm_match_cea_mode_clock_tolerance(mode, 5); |
| 3807 | if (drm_valid_cea_vic(vic)) { |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3808 | type = "CEA"; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3809 | cea_mode = &edid_cea_modes[vic]; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3810 | clock1 = cea_mode->clock; |
| 3811 | clock2 = cea_mode_alternate_clock(cea_mode); |
| 3812 | } else { |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3813 | vic = drm_match_hdmi_mode_clock_tolerance(mode, 5); |
| 3814 | if (drm_valid_hdmi_vic(vic)) { |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3815 | type = "HDMI"; |
Jani Nikula | d9278b4 | 2016-01-08 13:21:51 +0200 | [diff] [blame] | 3816 | cea_mode = &edid_4k_modes[vic]; |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3817 | clock1 = cea_mode->clock; |
| 3818 | clock2 = hdmi_mode_alternate_clock(cea_mode); |
| 3819 | } else { |
| 3820 | return; |
| 3821 | } |
| 3822 | } |
| 3823 | |
| 3824 | /* pick whichever is closest */ |
| 3825 | if (abs(mode->clock - clock1) < abs(mode->clock - clock2)) |
| 3826 | clock = clock1; |
| 3827 | else |
| 3828 | clock = clock2; |
| 3829 | |
| 3830 | if (mode->clock == clock) |
| 3831 | return; |
| 3832 | |
| 3833 | 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] | 3834 | type, vic, mode->clock, clock); |
Ville Syrjälä | fa3a734 | 2015-10-08 11:43:32 +0300 | [diff] [blame] | 3835 | mode->clock = clock; |
| 3836 | } |
| 3837 | |
Uma Shankar | e85959d | 2019-05-16 19:40:08 +0530 | [diff] [blame] | 3838 | static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db) |
| 3839 | { |
| 3840 | if (cea_db_tag(db) != USE_EXTENDED_TAG) |
| 3841 | return false; |
| 3842 | |
| 3843 | if (db[1] != HDR_STATIC_METADATA_BLOCK) |
| 3844 | return false; |
| 3845 | |
| 3846 | if (cea_db_payload_len(db) < 3) |
| 3847 | return false; |
| 3848 | |
| 3849 | return true; |
| 3850 | } |
| 3851 | |
| 3852 | static uint8_t eotf_supported(const u8 *edid_ext) |
| 3853 | { |
| 3854 | return edid_ext[2] & |
| 3855 | (BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) | |
| 3856 | BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) | |
Ville Syrjälä | b5e3eed | 2019-05-16 19:40:12 +0530 | [diff] [blame] | 3857 | BIT(HDMI_EOTF_SMPTE_ST2084) | |
| 3858 | BIT(HDMI_EOTF_BT_2100_HLG)); |
Uma Shankar | e85959d | 2019-05-16 19:40:08 +0530 | [diff] [blame] | 3859 | } |
| 3860 | |
| 3861 | static uint8_t hdr_metadata_type(const u8 *edid_ext) |
| 3862 | { |
| 3863 | return edid_ext[3] & |
| 3864 | BIT(HDMI_STATIC_METADATA_TYPE1); |
| 3865 | } |
| 3866 | |
| 3867 | static void |
| 3868 | drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db) |
| 3869 | { |
| 3870 | u16 len; |
| 3871 | |
| 3872 | len = cea_db_payload_len(db); |
| 3873 | |
| 3874 | connector->hdr_sink_metadata.hdmi_type1.eotf = |
| 3875 | eotf_supported(db); |
| 3876 | connector->hdr_sink_metadata.hdmi_type1.metadata_type = |
| 3877 | hdr_metadata_type(db); |
| 3878 | |
| 3879 | if (len >= 4) |
| 3880 | connector->hdr_sink_metadata.hdmi_type1.max_cll = db[4]; |
| 3881 | if (len >= 5) |
| 3882 | connector->hdr_sink_metadata.hdmi_type1.max_fall = db[5]; |
| 3883 | if (len >= 6) |
| 3884 | connector->hdr_sink_metadata.hdmi_type1.min_cll = db[6]; |
| 3885 | } |
| 3886 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3887 | static void |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 3888 | drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db) |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3889 | { |
Ville Syrjälä | 8504072 | 2012-08-16 14:55:05 +0000 | [diff] [blame] | 3890 | u8 len = cea_db_payload_len(db); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3891 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 3892 | if (len >= 6 && (db[6] & (1 << 7))) |
| 3893 | 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] | 3894 | if (len >= 8) { |
| 3895 | connector->latency_present[0] = db[8] >> 7; |
| 3896 | connector->latency_present[1] = (db[8] >> 6) & 1; |
| 3897 | } |
| 3898 | if (len >= 9) |
| 3899 | connector->video_latency[0] = db[9]; |
| 3900 | if (len >= 10) |
| 3901 | connector->audio_latency[0] = db[10]; |
| 3902 | if (len >= 11) |
| 3903 | connector->video_latency[1] = db[11]; |
| 3904 | if (len >= 12) |
| 3905 | connector->audio_latency[1] = db[12]; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3906 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 3907 | DRM_DEBUG_KMS("HDMI: latency present %d %d, " |
| 3908 | "video latency %d %d, " |
| 3909 | "audio latency %d %d\n", |
| 3910 | connector->latency_present[0], |
| 3911 | connector->latency_present[1], |
| 3912 | connector->video_latency[0], |
| 3913 | connector->video_latency[1], |
| 3914 | connector->audio_latency[0], |
| 3915 | connector->audio_latency[1]); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3916 | } |
| 3917 | |
| 3918 | static void |
| 3919 | monitor_name(struct detailed_timing *t, void *data) |
| 3920 | { |
| 3921 | if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME) |
| 3922 | *(u8 **)data = t->data.other_data.data.str.str; |
| 3923 | } |
| 3924 | |
Jim Bride | 59f7c0f | 2016-04-14 10:18:35 -0700 | [diff] [blame] | 3925 | static int get_monitor_name(struct edid *edid, char name[13]) |
| 3926 | { |
| 3927 | char *edid_name = NULL; |
| 3928 | int mnl; |
| 3929 | |
| 3930 | if (!edid || !name) |
| 3931 | return 0; |
| 3932 | |
| 3933 | drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name); |
| 3934 | for (mnl = 0; edid_name && mnl < 13; mnl++) { |
| 3935 | if (edid_name[mnl] == 0x0a) |
| 3936 | break; |
| 3937 | |
| 3938 | name[mnl] = edid_name[mnl]; |
| 3939 | } |
| 3940 | |
| 3941 | return mnl; |
| 3942 | } |
| 3943 | |
| 3944 | /** |
| 3945 | * drm_edid_get_monitor_name - fetch the monitor name from the edid |
| 3946 | * @edid: monitor EDID information |
| 3947 | * @name: pointer to a character array to hold the name of the monitor |
| 3948 | * @bufsize: The size of the name buffer (should be at least 14 chars.) |
| 3949 | * |
| 3950 | */ |
| 3951 | void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize) |
| 3952 | { |
| 3953 | int name_length; |
| 3954 | char buf[13]; |
| 3955 | |
| 3956 | if (bufsize <= 0) |
| 3957 | return; |
| 3958 | |
| 3959 | name_length = min(get_monitor_name(edid, buf), bufsize - 1); |
| 3960 | memcpy(name, buf, name_length); |
| 3961 | name[name_length] = '\0'; |
| 3962 | } |
| 3963 | EXPORT_SYMBOL(drm_edid_get_monitor_name); |
| 3964 | |
Jani Nikula | 42750d3 | 2017-11-01 16:21:00 +0200 | [diff] [blame] | 3965 | static void clear_eld(struct drm_connector *connector) |
| 3966 | { |
| 3967 | memset(connector->eld, 0, sizeof(connector->eld)); |
| 3968 | |
| 3969 | connector->latency_present[0] = false; |
| 3970 | connector->latency_present[1] = false; |
| 3971 | connector->video_latency[0] = 0; |
| 3972 | connector->audio_latency[0] = 0; |
| 3973 | connector->video_latency[1] = 0; |
| 3974 | connector->audio_latency[1] = 0; |
| 3975 | } |
| 3976 | |
Jani Nikula | 79436a1 | 2017-11-01 16:21:03 +0200 | [diff] [blame] | 3977 | /* |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3978 | * drm_edid_to_eld - build ELD from EDID |
| 3979 | * @connector: connector corresponding to the HDMI/DP sink |
| 3980 | * @edid: EDID to parse |
| 3981 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 3982 | * 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] | 3983 | * 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] | 3984 | */ |
Jani Nikula | 79436a1 | 2017-11-01 16:21:03 +0200 | [diff] [blame] | 3985 | 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] | 3986 | { |
| 3987 | uint8_t *eld = connector->eld; |
| 3988 | u8 *cea; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3989 | u8 *db; |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 3990 | int total_sad_count = 0; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3991 | int mnl; |
| 3992 | int dbl; |
| 3993 | |
Jani Nikula | 42750d3 | 2017-11-01 16:21:00 +0200 | [diff] [blame] | 3994 | clear_eld(connector); |
Ville Syrjälä | 85c9158 | 2016-09-28 16:51:34 +0300 | [diff] [blame] | 3995 | |
Jani Nikula | e9bd0b8 | 2017-02-17 17:20:52 +0200 | [diff] [blame] | 3996 | if (!edid) |
| 3997 | return; |
| 3998 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 3999 | cea = drm_find_cea_extension(edid); |
| 4000 | if (!cea) { |
| 4001 | DRM_DEBUG_KMS("ELD: no CEA Extension found\n"); |
| 4002 | return; |
| 4003 | } |
| 4004 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4005 | mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]); |
| 4006 | 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] | 4007 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4008 | eld[DRM_ELD_CEA_EDID_VER_MNL] = cea[1] << DRM_ELD_CEA_EDID_VER_SHIFT; |
| 4009 | eld[DRM_ELD_CEA_EDID_VER_MNL] |= mnl; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4010 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4011 | eld[DRM_ELD_VER] = DRM_ELD_VER_CEA861D; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4012 | |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4013 | eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0]; |
| 4014 | eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1]; |
| 4015 | eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0]; |
| 4016 | eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1]; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4017 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4018 | if (cea_revision(cea) >= 3) { |
| 4019 | int i, start, end; |
| 4020 | |
| 4021 | if (cea_db_offsets(cea, &start, &end)) { |
| 4022 | start = 0; |
| 4023 | end = 0; |
| 4024 | } |
| 4025 | |
| 4026 | for_each_cea_db(cea, i, start, end) { |
| 4027 | db = &cea[i]; |
| 4028 | dbl = cea_db_payload_len(db); |
| 4029 | |
| 4030 | switch (cea_db_tag(db)) { |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 4031 | int sad_count; |
| 4032 | |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 4033 | case AUDIO_BLOCK: |
| 4034 | /* Audio Data Block, contains SADs */ |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 4035 | sad_count = min(dbl / 3, 15 - total_sad_count); |
| 4036 | if (sad_count >= 1) |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4037 | memcpy(&eld[DRM_ELD_CEA_SAD(mnl, total_sad_count)], |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 4038 | &db[1], sad_count * 3); |
| 4039 | total_sad_count += sad_count; |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 4040 | break; |
| 4041 | case SPEAKER_BLOCK: |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4042 | /* Speaker Allocation Data Block */ |
| 4043 | if (dbl >= 1) |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4044 | eld[DRM_ELD_SPEAKER] = db[1]; |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 4045 | break; |
| 4046 | case VENDOR_BLOCK: |
| 4047 | /* HDMI Vendor-Specific Data Block */ |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4048 | if (cea_db_is_hdmi_vsdb(db)) |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4049 | drm_parse_hdmi_vsdb_audio(connector, db); |
Christian Schmidt | a0ab734 | 2011-12-19 20:03:38 +0100 | [diff] [blame] | 4050 | break; |
| 4051 | default: |
| 4052 | break; |
| 4053 | } |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4054 | } |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4055 | } |
Jani Nikula | f7da7785 | 2017-11-01 16:20:57 +0200 | [diff] [blame] | 4056 | 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] | 4057 | |
Jani Nikula | 1d1c366 | 2017-11-01 16:20:58 +0200 | [diff] [blame] | 4058 | if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || |
| 4059 | connector->connector_type == DRM_MODE_CONNECTOR_eDP) |
| 4060 | eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_DP; |
| 4061 | else |
| 4062 | eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_HDMI; |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4063 | |
Jani Nikula | 938fd8a | 2014-10-28 16:20:48 +0200 | [diff] [blame] | 4064 | eld[DRM_ELD_BASELINE_ELD_LEN] = |
| 4065 | DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4); |
| 4066 | |
| 4067 | DRM_DEBUG_KMS("ELD size %d, SAD count %d\n", |
Ville Syrjälä | 7c01878 | 2016-03-09 22:07:46 +0200 | [diff] [blame] | 4068 | drm_eld_size(eld), total_sad_count); |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4069 | } |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4070 | |
| 4071 | /** |
Rafał Miłecki | fe21416 | 2013-04-19 19:01:25 +0200 | [diff] [blame] | 4072 | * drm_edid_to_sad - extracts SADs from EDID |
| 4073 | * @edid: EDID to parse |
| 4074 | * @sads: pointer that will be set to the extracted SADs |
| 4075 | * |
| 4076 | * 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] | 4077 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4078 | * Note: The returned pointer needs to be freed using kfree(). |
| 4079 | * |
| 4080 | * Return: The number of found SADs or negative number on error. |
Rafał Miłecki | fe21416 | 2013-04-19 19:01:25 +0200 | [diff] [blame] | 4081 | */ |
| 4082 | int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads) |
| 4083 | { |
| 4084 | int count = 0; |
| 4085 | int i, start, end, dbl; |
| 4086 | u8 *cea; |
| 4087 | |
| 4088 | cea = drm_find_cea_extension(edid); |
| 4089 | if (!cea) { |
| 4090 | DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); |
| 4091 | return -ENOENT; |
| 4092 | } |
| 4093 | |
| 4094 | if (cea_revision(cea) < 3) { |
| 4095 | DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); |
| 4096 | return -ENOTSUPP; |
| 4097 | } |
| 4098 | |
| 4099 | if (cea_db_offsets(cea, &start, &end)) { |
| 4100 | DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); |
| 4101 | return -EPROTO; |
| 4102 | } |
| 4103 | |
| 4104 | for_each_cea_db(cea, i, start, end) { |
| 4105 | u8 *db = &cea[i]; |
| 4106 | |
| 4107 | if (cea_db_tag(db) == AUDIO_BLOCK) { |
| 4108 | int j; |
| 4109 | dbl = cea_db_payload_len(db); |
| 4110 | |
| 4111 | count = dbl / 3; /* SAD is 3B */ |
| 4112 | *sads = kcalloc(count, sizeof(**sads), GFP_KERNEL); |
| 4113 | if (!*sads) |
| 4114 | return -ENOMEM; |
| 4115 | for (j = 0; j < count; j++) { |
| 4116 | u8 *sad = &db[1 + j * 3]; |
| 4117 | |
| 4118 | (*sads)[j].format = (sad[0] & 0x78) >> 3; |
| 4119 | (*sads)[j].channels = sad[0] & 0x7; |
| 4120 | (*sads)[j].freq = sad[1] & 0x7F; |
| 4121 | (*sads)[j].byte2 = sad[2]; |
| 4122 | } |
| 4123 | break; |
| 4124 | } |
| 4125 | } |
| 4126 | |
| 4127 | return count; |
| 4128 | } |
| 4129 | EXPORT_SYMBOL(drm_edid_to_sad); |
| 4130 | |
| 4131 | /** |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4132 | * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID |
| 4133 | * @edid: EDID to parse |
| 4134 | * @sadb: pointer to the speaker block |
| 4135 | * |
| 4136 | * 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] | 4137 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4138 | * Note: The returned pointer needs to be freed using kfree(). |
| 4139 | * |
| 4140 | * Return: The number of found Speaker Allocation Blocks or negative number on |
| 4141 | * error. |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4142 | */ |
| 4143 | int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb) |
| 4144 | { |
| 4145 | int count = 0; |
| 4146 | int i, start, end, dbl; |
| 4147 | const u8 *cea; |
| 4148 | |
| 4149 | cea = drm_find_cea_extension(edid); |
| 4150 | if (!cea) { |
| 4151 | DRM_DEBUG_KMS("SAD: no CEA Extension found\n"); |
| 4152 | return -ENOENT; |
| 4153 | } |
| 4154 | |
| 4155 | if (cea_revision(cea) < 3) { |
| 4156 | DRM_DEBUG_KMS("SAD: wrong CEA revision\n"); |
| 4157 | return -ENOTSUPP; |
| 4158 | } |
| 4159 | |
| 4160 | if (cea_db_offsets(cea, &start, &end)) { |
| 4161 | DRM_DEBUG_KMS("SAD: invalid data block offsets\n"); |
| 4162 | return -EPROTO; |
| 4163 | } |
| 4164 | |
| 4165 | for_each_cea_db(cea, i, start, end) { |
| 4166 | const u8 *db = &cea[i]; |
| 4167 | |
| 4168 | if (cea_db_tag(db) == SPEAKER_BLOCK) { |
| 4169 | dbl = cea_db_payload_len(db); |
| 4170 | |
| 4171 | /* Speaker Allocation Data Block */ |
| 4172 | if (dbl == 3) { |
Benoit Taine | 89086bc | 2014-05-26 17:21:22 +0200 | [diff] [blame] | 4173 | *sadb = kmemdup(&db[1], dbl, GFP_KERNEL); |
Alex Deucher | 618e377 | 2013-09-27 18:46:09 -0400 | [diff] [blame] | 4174 | if (!*sadb) |
| 4175 | return -ENOMEM; |
Alex Deucher | d105f47 | 2013-07-25 15:55:32 -0400 | [diff] [blame] | 4176 | count = dbl; |
| 4177 | break; |
| 4178 | } |
| 4179 | } |
| 4180 | } |
| 4181 | |
| 4182 | return count; |
| 4183 | } |
| 4184 | EXPORT_SYMBOL(drm_edid_to_speaker_allocation); |
| 4185 | |
| 4186 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4187 | * 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] | 4188 | * @connector: connector associated with the HDMI/DP sink |
| 4189 | * @mode: the display mode |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4190 | * |
| 4191 | * Return: The HDMI/DP sink's audio-video sync delay in milliseconds or 0 if |
| 4192 | * the sink doesn't support audio or video. |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4193 | */ |
| 4194 | int drm_av_sync_delay(struct drm_connector *connector, |
Ville Syrjälä | 3a818d3 | 2015-09-07 18:22:58 +0300 | [diff] [blame] | 4195 | const struct drm_display_mode *mode) |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 4196 | { |
| 4197 | int i = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); |
| 4198 | int a, v; |
| 4199 | |
| 4200 | if (!connector->latency_present[0]) |
| 4201 | return 0; |
| 4202 | if (!connector->latency_present[1]) |
| 4203 | i = 0; |
| 4204 | |
| 4205 | a = connector->audio_latency[i]; |
| 4206 | v = connector->video_latency[i]; |
| 4207 | |
| 4208 | /* |
| 4209 | * HDMI/DP sink doesn't support audio or video? |
| 4210 | */ |
| 4211 | if (a == 255 || v == 255) |
| 4212 | return 0; |
| 4213 | |
| 4214 | /* |
| 4215 | * Convert raw EDID values to millisecond. |
| 4216 | * Treat unknown latency as 0ms. |
| 4217 | */ |
| 4218 | if (a) |
| 4219 | a = min(2 * (a - 1), 500); |
| 4220 | if (v) |
| 4221 | v = min(2 * (v - 1), 500); |
| 4222 | |
| 4223 | return max(v - a, 0); |
| 4224 | } |
| 4225 | EXPORT_SYMBOL(drm_av_sync_delay); |
| 4226 | |
| 4227 | /** |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4228 | * drm_detect_hdmi_monitor - detect whether monitor is HDMI |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4229 | * @edid: monitor EDID information |
| 4230 | * |
| 4231 | * Parse the CEA extension according to CEA-861-B. |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4232 | * |
| 4233 | * Return: True if the monitor is HDMI, false if not or unknown. |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4234 | */ |
| 4235 | bool drm_detect_hdmi_monitor(struct edid *edid) |
| 4236 | { |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4237 | u8 *edid_ext; |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4238 | int i; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4239 | int start_offset, end_offset; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4240 | |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4241 | edid_ext = drm_find_cea_extension(edid); |
| 4242 | if (!edid_ext) |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4243 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4244 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4245 | if (cea_db_offsets(edid_ext, &start_offset, &end_offset)) |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4246 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4247 | |
| 4248 | /* |
| 4249 | * Because HDMI identifier is in Vendor Specific Block, |
| 4250 | * search it from all data blocks of CEA extension. |
| 4251 | */ |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4252 | for_each_cea_db(edid_ext, i, start_offset, end_offset) { |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4253 | if (cea_db_is_hdmi_vsdb(&edid_ext[i])) |
| 4254 | return true; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4255 | } |
| 4256 | |
Ville Syrjälä | 14f77fd | 2012-08-16 14:55:06 +0000 | [diff] [blame] | 4257 | return false; |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 4258 | } |
| 4259 | EXPORT_SYMBOL(drm_detect_hdmi_monitor); |
| 4260 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4261 | /** |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4262 | * drm_detect_monitor_audio - check monitor audio capability |
Daniel Vetter | fc66811 | 2014-01-21 12:02:26 +0100 | [diff] [blame] | 4263 | * @edid: EDID block to scan |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4264 | * |
| 4265 | * Monitor should have CEA extension block. |
| 4266 | * If monitor has 'basic audio', but no CEA audio blocks, it's 'basic |
| 4267 | * audio' only. If there is any audio extension block and supported |
| 4268 | * audio format, assume at least 'basic audio' support, even if 'basic |
| 4269 | * audio' is not defined in EDID. |
| 4270 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4271 | * Return: True if the monitor supports audio, false otherwise. |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4272 | */ |
| 4273 | bool drm_detect_monitor_audio(struct edid *edid) |
| 4274 | { |
| 4275 | u8 *edid_ext; |
| 4276 | int i, j; |
| 4277 | bool has_audio = false; |
| 4278 | int start_offset, end_offset; |
| 4279 | |
| 4280 | edid_ext = drm_find_cea_extension(edid); |
| 4281 | if (!edid_ext) |
| 4282 | goto end; |
| 4283 | |
| 4284 | has_audio = ((edid_ext[3] & EDID_BASIC_AUDIO) != 0); |
| 4285 | |
| 4286 | if (has_audio) { |
| 4287 | DRM_DEBUG_KMS("Monitor has basic audio support\n"); |
| 4288 | goto end; |
| 4289 | } |
| 4290 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4291 | if (cea_db_offsets(edid_ext, &start_offset, &end_offset)) |
| 4292 | goto end; |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4293 | |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4294 | for_each_cea_db(edid_ext, i, start_offset, end_offset) { |
| 4295 | if (cea_db_tag(&edid_ext[i]) == AUDIO_BLOCK) { |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 4296 | has_audio = true; |
Ville Syrjälä | 9e50b9d | 2012-08-16 14:55:04 +0000 | [diff] [blame] | 4297 | 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] | 4298 | DRM_DEBUG_KMS("CEA audio format %d\n", |
| 4299 | (edid_ext[i + j] >> 3) & 0xf); |
| 4300 | goto end; |
| 4301 | } |
| 4302 | } |
| 4303 | end: |
| 4304 | return has_audio; |
| 4305 | } |
| 4306 | EXPORT_SYMBOL(drm_detect_monitor_audio); |
| 4307 | |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 4308 | |
Ville Syrjälä | c8127cf0 | 2017-01-11 16:18:35 +0200 | [diff] [blame] | 4309 | /** |
| 4310 | * drm_default_rgb_quant_range - default RGB quantization range |
| 4311 | * @mode: display mode |
| 4312 | * |
| 4313 | * Determine the default RGB quantization range for the mode, |
| 4314 | * as specified in CEA-861. |
| 4315 | * |
| 4316 | * Return: The default RGB quantization range for the mode |
| 4317 | */ |
| 4318 | enum hdmi_quantization_range |
| 4319 | drm_default_rgb_quant_range(const struct drm_display_mode *mode) |
| 4320 | { |
| 4321 | /* All CEA modes other than VIC 1 use limited quantization range. */ |
| 4322 | return drm_match_cea_mode(mode) > 1 ? |
| 4323 | HDMI_QUANTIZATION_RANGE_LIMITED : |
| 4324 | HDMI_QUANTIZATION_RANGE_FULL; |
| 4325 | } |
| 4326 | EXPORT_SYMBOL(drm_default_rgb_quant_range); |
| 4327 | |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 4328 | static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db) |
| 4329 | { |
| 4330 | struct drm_display_info *info = &connector->display_info; |
| 4331 | |
| 4332 | DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", db[2]); |
| 4333 | |
| 4334 | if (db[2] & EDID_CEA_VCDB_QS) |
| 4335 | info->rgb_quant_range_selectable = true; |
| 4336 | } |
| 4337 | |
Shashank Sharma | e6a9a2c | 2017-07-13 21:03:13 +0530 | [diff] [blame] | 4338 | static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector, |
| 4339 | const u8 *db) |
| 4340 | { |
| 4341 | u8 dc_mask; |
| 4342 | struct drm_hdmi_info *hdmi = &connector->display_info.hdmi; |
| 4343 | |
| 4344 | dc_mask = db[7] & DRM_EDID_YCBCR420_DC_MASK; |
Clint Taylor | 9068e02 | 2018-10-05 14:52:15 -0700 | [diff] [blame] | 4345 | hdmi->y420_dc_modes = dc_mask; |
Shashank Sharma | e6a9a2c | 2017-07-13 21:03:13 +0530 | [diff] [blame] | 4346 | } |
| 4347 | |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4348 | static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector, |
| 4349 | const u8 *hf_vsdb) |
| 4350 | { |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 4351 | struct drm_display_info *display = &connector->display_info; |
| 4352 | struct drm_hdmi_info *hdmi = &display->hdmi; |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4353 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 4354 | display->has_hdmi_infoframe = true; |
| 4355 | |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4356 | if (hf_vsdb[6] & 0x80) { |
| 4357 | hdmi->scdc.supported = true; |
| 4358 | if (hf_vsdb[6] & 0x40) |
| 4359 | hdmi->scdc.read_request = true; |
| 4360 | } |
Shashank Sharma | 62c58af | 2017-03-13 16:54:02 +0530 | [diff] [blame] | 4361 | |
| 4362 | /* |
| 4363 | * All HDMI 2.0 monitors must support scrambling at rates > 340 MHz. |
| 4364 | * And as per the spec, three factors confirm this: |
| 4365 | * * Availability of a HF-VSDB block in EDID (check) |
| 4366 | * * Non zero Max_TMDS_Char_Rate filed in HF-VSDB (let's check) |
| 4367 | * * SCDC support available (let's check) |
| 4368 | * Lets check it out. |
| 4369 | */ |
| 4370 | |
| 4371 | if (hf_vsdb[5]) { |
| 4372 | /* max clock is 5000 KHz times block value */ |
| 4373 | u32 max_tmds_clock = hf_vsdb[5] * 5000; |
| 4374 | struct drm_scdc *scdc = &hdmi->scdc; |
| 4375 | |
| 4376 | if (max_tmds_clock > 340000) { |
| 4377 | display->max_tmds_clock = max_tmds_clock; |
| 4378 | DRM_DEBUG_KMS("HF-VSDB: max TMDS clock %d kHz\n", |
| 4379 | display->max_tmds_clock); |
| 4380 | } |
| 4381 | |
| 4382 | if (scdc->supported) { |
| 4383 | scdc->scrambling.supported = true; |
| 4384 | |
| 4385 | /* Few sinks support scrambling for cloks < 340M */ |
| 4386 | if ((hf_vsdb[6] & 0x8)) |
| 4387 | scdc->scrambling.low_rates = true; |
| 4388 | } |
| 4389 | } |
Shashank Sharma | e6a9a2c | 2017-07-13 21:03:13 +0530 | [diff] [blame] | 4390 | |
| 4391 | drm_parse_ycbcr420_deep_color_info(connector, hf_vsdb); |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4392 | } |
| 4393 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4394 | static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector, |
| 4395 | const u8 *hdmi) |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4396 | { |
Ville Syrjälä | 1826750 | 2016-09-28 16:51:38 +0300 | [diff] [blame] | 4397 | struct drm_display_info *info = &connector->display_info; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4398 | unsigned int dc_bpc = 0; |
| 4399 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4400 | /* HDMI supports at least 8 bpc */ |
| 4401 | info->bpc = 8; |
| 4402 | |
| 4403 | if (cea_db_payload_len(hdmi) < 6) |
| 4404 | return; |
| 4405 | |
| 4406 | if (hdmi[6] & DRM_EDID_HDMI_DC_30) { |
| 4407 | dc_bpc = 10; |
| 4408 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_30; |
| 4409 | DRM_DEBUG("%s: HDMI sink does deep color 30.\n", |
| 4410 | connector->name); |
| 4411 | } |
| 4412 | |
| 4413 | if (hdmi[6] & DRM_EDID_HDMI_DC_36) { |
| 4414 | dc_bpc = 12; |
| 4415 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_36; |
| 4416 | DRM_DEBUG("%s: HDMI sink does deep color 36.\n", |
| 4417 | connector->name); |
| 4418 | } |
| 4419 | |
| 4420 | if (hdmi[6] & DRM_EDID_HDMI_DC_48) { |
| 4421 | dc_bpc = 16; |
| 4422 | info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_48; |
| 4423 | DRM_DEBUG("%s: HDMI sink does deep color 48.\n", |
| 4424 | connector->name); |
| 4425 | } |
| 4426 | |
| 4427 | if (dc_bpc == 0) { |
| 4428 | DRM_DEBUG("%s: No deep color support on this HDMI sink.\n", |
| 4429 | connector->name); |
| 4430 | return; |
| 4431 | } |
| 4432 | |
| 4433 | DRM_DEBUG("%s: Assigning HDMI sink color depth as %d bpc.\n", |
| 4434 | connector->name, dc_bpc); |
| 4435 | info->bpc = dc_bpc; |
| 4436 | |
| 4437 | /* |
| 4438 | * Deep color support mandates RGB444 support for all video |
| 4439 | * modes and forbids YCRCB422 support for all video modes per |
| 4440 | * HDMI 1.3 spec. |
| 4441 | */ |
| 4442 | info->color_formats = DRM_COLOR_FORMAT_RGB444; |
| 4443 | |
| 4444 | /* YCRCB444 is optional according to spec. */ |
| 4445 | if (hdmi[6] & DRM_EDID_HDMI_DC_Y444) { |
| 4446 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4447 | DRM_DEBUG("%s: HDMI sink does YCRCB444 in deep color.\n", |
| 4448 | connector->name); |
| 4449 | } |
| 4450 | |
| 4451 | /* |
| 4452 | * Spec says that if any deep color mode is supported at all, |
| 4453 | * then deep color 36 bit must be supported. |
| 4454 | */ |
| 4455 | if (!(hdmi[6] & DRM_EDID_HDMI_DC_36)) { |
| 4456 | DRM_DEBUG("%s: HDMI sink should do DC_36, but does not!\n", |
| 4457 | connector->name); |
| 4458 | } |
| 4459 | } |
| 4460 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4461 | static void |
| 4462 | drm_parse_hdmi_vsdb_video(struct drm_connector *connector, const u8 *db) |
| 4463 | { |
| 4464 | struct drm_display_info *info = &connector->display_info; |
| 4465 | u8 len = cea_db_payload_len(db); |
| 4466 | |
| 4467 | if (len >= 6) |
| 4468 | info->dvi_dual = db[6] & 1; |
| 4469 | if (len >= 7) |
| 4470 | info->max_tmds_clock = db[7] * 5000; |
| 4471 | |
| 4472 | DRM_DEBUG_KMS("HDMI: DVI dual %d, " |
| 4473 | "max TMDS clock %d kHz\n", |
| 4474 | info->dvi_dual, |
| 4475 | info->max_tmds_clock); |
| 4476 | |
| 4477 | drm_parse_hdmi_deep_color_info(connector, db); |
| 4478 | } |
| 4479 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4480 | static void drm_parse_cea_ext(struct drm_connector *connector, |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4481 | const struct edid *edid) |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4482 | { |
| 4483 | struct drm_display_info *info = &connector->display_info; |
| 4484 | const u8 *edid_ext; |
| 4485 | int i, start, end; |
| 4486 | |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4487 | edid_ext = drm_find_cea_extension(edid); |
| 4488 | if (!edid_ext) |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4489 | return; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4490 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4491 | info->cea_rev = edid_ext[1]; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4492 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4493 | /* The existence of a CEA block should imply RGB support */ |
| 4494 | info->color_formats = DRM_COLOR_FORMAT_RGB444; |
| 4495 | if (edid_ext[3] & EDID_CEA_YCRCB444) |
| 4496 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4497 | if (edid_ext[3] & EDID_CEA_YCRCB422) |
| 4498 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4499 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4500 | if (cea_db_offsets(edid_ext, &start, &end)) |
| 4501 | return; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4502 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4503 | for_each_cea_db(edid_ext, i, start, end) { |
| 4504 | const u8 *db = &edid_ext[i]; |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4505 | |
Ville Syrjälä | 23ebf8b | 2016-09-28 16:51:41 +0300 | [diff] [blame] | 4506 | if (cea_db_is_hdmi_vsdb(db)) |
| 4507 | drm_parse_hdmi_vsdb_video(connector, db); |
Shashank Sharma | afa1c76 | 2017-03-13 16:54:01 +0530 | [diff] [blame] | 4508 | if (cea_db_is_hdmi_forum_vsdb(db)) |
| 4509 | drm_parse_hdmi_forum_vsdb(connector, db); |
Shashank Sharma | 832d4f2 | 2017-07-14 16:03:46 +0530 | [diff] [blame] | 4510 | if (cea_db_is_y420cmdb(db)) |
| 4511 | drm_parse_y420cmdb_bitmap(connector, db); |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 4512 | if (cea_db_is_vcdb(db)) |
| 4513 | drm_parse_vcdb(connector, db); |
Uma Shankar | e85959d | 2019-05-16 19:40:08 +0530 | [diff] [blame] | 4514 | if (cea_db_is_hdmi_hdr_metadata_block(db)) |
| 4515 | drm_parse_hdr_metadata_block(connector, db); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4516 | } |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4517 | } |
| 4518 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4519 | /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset |
| 4520 | * all of the values which would have been set from EDID |
| 4521 | */ |
| 4522 | void |
| 4523 | drm_reset_display_info(struct drm_connector *connector) |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4524 | { |
Ville Syrjälä | 1826750 | 2016-09-28 16:51:38 +0300 | [diff] [blame] | 4525 | struct drm_display_info *info = &connector->display_info; |
Jesse Barnes | ebec9a7b | 2011-08-03 09:22:54 -0700 | [diff] [blame] | 4526 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4527 | info->width_mm = 0; |
| 4528 | info->height_mm = 0; |
| 4529 | |
| 4530 | info->bpc = 0; |
| 4531 | info->color_formats = 0; |
| 4532 | info->cea_rev = 0; |
| 4533 | info->max_tmds_clock = 0; |
| 4534 | info->dvi_dual = false; |
| 4535 | info->has_hdmi_infoframe = false; |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 4536 | info->rgb_quant_range_selectable = false; |
Ville Syrjälä | 1f6b8ee | 2018-04-24 16:02:50 +0300 | [diff] [blame] | 4537 | memset(&info->hdmi, 0, sizeof(info->hdmi)); |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4538 | |
| 4539 | info->non_desktop = 0; |
| 4540 | } |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4541 | |
| 4542 | u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid) |
| 4543 | { |
| 4544 | struct drm_display_info *info = &connector->display_info; |
| 4545 | |
| 4546 | u32 quirks = edid_get_quirks(edid); |
| 4547 | |
Ville Syrjälä | 1f6b8ee | 2018-04-24 16:02:50 +0300 | [diff] [blame] | 4548 | drm_reset_display_info(connector); |
| 4549 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4550 | info->width_mm = edid->width_cm * 10; |
| 4551 | info->height_mm = edid->height_cm * 10; |
| 4552 | |
Dave Airlie | 66660d4 | 2017-10-16 05:08:09 +0100 | [diff] [blame] | 4553 | info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP); |
| 4554 | |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4555 | DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop); |
| 4556 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4557 | if (edid->revision < 3) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4558 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4559 | |
| 4560 | if (!(edid->input & DRM_EDID_INPUT_DIGITAL)) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4561 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4562 | |
Ville Syrjälä | 1cea146 | 2016-09-28 16:51:39 +0300 | [diff] [blame] | 4563 | drm_parse_cea_ext(connector, edid); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4564 | |
Mario Kleiner | 210a021 | 2016-07-06 12:05:48 +0200 | [diff] [blame] | 4565 | /* |
| 4566 | * Digital sink with "DFP 1.x compliant TMDS" according to EDID 1.3? |
| 4567 | * |
| 4568 | * For such displays, the DFP spec 1.0, section 3.10 "EDID support" |
| 4569 | * tells us to assume 8 bpc color depth if the EDID doesn't have |
| 4570 | * extensions which tell otherwise. |
| 4571 | */ |
| 4572 | if ((info->bpc == 0) && (edid->revision < 4) && |
| 4573 | (edid->input & DRM_EDID_DIGITAL_TYPE_DVI)) { |
| 4574 | info->bpc = 8; |
| 4575 | DRM_DEBUG("%s: Assigning DFP sink color depth as %d bpc.\n", |
| 4576 | connector->name, info->bpc); |
| 4577 | } |
| 4578 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4579 | /* Only defined for 1.4 with digital displays */ |
| 4580 | if (edid->revision < 4) |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4581 | return quirks; |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4582 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4583 | switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) { |
| 4584 | case DRM_EDID_DIGITAL_DEPTH_6: |
| 4585 | info->bpc = 6; |
| 4586 | break; |
| 4587 | case DRM_EDID_DIGITAL_DEPTH_8: |
| 4588 | info->bpc = 8; |
| 4589 | break; |
| 4590 | case DRM_EDID_DIGITAL_DEPTH_10: |
| 4591 | info->bpc = 10; |
| 4592 | break; |
| 4593 | case DRM_EDID_DIGITAL_DEPTH_12: |
| 4594 | info->bpc = 12; |
| 4595 | break; |
| 4596 | case DRM_EDID_DIGITAL_DEPTH_14: |
| 4597 | info->bpc = 14; |
| 4598 | break; |
| 4599 | case DRM_EDID_DIGITAL_DEPTH_16: |
| 4600 | info->bpc = 16; |
| 4601 | break; |
| 4602 | case DRM_EDID_DIGITAL_DEPTH_UNDEF: |
| 4603 | default: |
| 4604 | info->bpc = 0; |
| 4605 | break; |
| 4606 | } |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 4607 | |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4608 | 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] | 4609 | connector->name, info->bpc); |
Mario Kleiner | d0c9469 | 2014-03-27 19:59:39 +0100 | [diff] [blame] | 4610 | |
Lars-Peter Clausen | a988bc7 | 2012-04-16 15:16:19 +0200 | [diff] [blame] | 4611 | info->color_formats |= DRM_COLOR_FORMAT_RGB444; |
Lars-Peter Clausen | ee58808 | 2012-04-16 15:16:18 +0200 | [diff] [blame] | 4612 | if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444) |
| 4613 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; |
| 4614 | if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422) |
| 4615 | info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4616 | return quirks; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4617 | } |
| 4618 | |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 4619 | static int validate_displayid(u8 *displayid, int length, int idx) |
| 4620 | { |
| 4621 | int i; |
| 4622 | u8 csum = 0; |
| 4623 | struct displayid_hdr *base; |
| 4624 | |
| 4625 | base = (struct displayid_hdr *)&displayid[idx]; |
| 4626 | |
| 4627 | DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n", |
| 4628 | base->rev, base->bytes, base->prod_id, base->ext_count); |
| 4629 | |
| 4630 | if (base->bytes + 5 > length - idx) |
| 4631 | return -EINVAL; |
| 4632 | for (i = idx; i <= base->bytes + 5; i++) { |
| 4633 | csum += displayid[i]; |
| 4634 | } |
| 4635 | if (csum) { |
Chris Wilson | 813a787 | 2017-02-10 19:59:13 +0000 | [diff] [blame] | 4636 | DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum); |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 4637 | return -EINVAL; |
| 4638 | } |
| 4639 | return 0; |
| 4640 | } |
| 4641 | |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 4642 | static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev, |
| 4643 | struct displayid_detailed_timings_1 *timings) |
| 4644 | { |
| 4645 | struct drm_display_mode *mode; |
| 4646 | unsigned pixel_clock = (timings->pixel_clock[0] | |
| 4647 | (timings->pixel_clock[1] << 8) | |
| 4648 | (timings->pixel_clock[2] << 16)); |
| 4649 | unsigned hactive = (timings->hactive[0] | timings->hactive[1] << 8) + 1; |
| 4650 | unsigned hblank = (timings->hblank[0] | timings->hblank[1] << 8) + 1; |
| 4651 | unsigned hsync = (timings->hsync[0] | (timings->hsync[1] & 0x7f) << 8) + 1; |
| 4652 | unsigned hsync_width = (timings->hsw[0] | timings->hsw[1] << 8) + 1; |
| 4653 | unsigned vactive = (timings->vactive[0] | timings->vactive[1] << 8) + 1; |
| 4654 | unsigned vblank = (timings->vblank[0] | timings->vblank[1] << 8) + 1; |
| 4655 | unsigned vsync = (timings->vsync[0] | (timings->vsync[1] & 0x7f) << 8) + 1; |
| 4656 | unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1; |
| 4657 | bool hsync_positive = (timings->hsync[1] >> 7) & 0x1; |
| 4658 | bool vsync_positive = (timings->vsync[1] >> 7) & 0x1; |
| 4659 | mode = drm_mode_create(dev); |
| 4660 | if (!mode) |
| 4661 | return NULL; |
| 4662 | |
| 4663 | mode->clock = pixel_clock * 10; |
| 4664 | mode->hdisplay = hactive; |
| 4665 | mode->hsync_start = mode->hdisplay + hsync; |
| 4666 | mode->hsync_end = mode->hsync_start + hsync_width; |
| 4667 | mode->htotal = mode->hdisplay + hblank; |
| 4668 | |
| 4669 | mode->vdisplay = vactive; |
| 4670 | mode->vsync_start = mode->vdisplay + vsync; |
| 4671 | mode->vsync_end = mode->vsync_start + vsync_width; |
| 4672 | mode->vtotal = mode->vdisplay + vblank; |
| 4673 | |
| 4674 | mode->flags = 0; |
| 4675 | mode->flags |= hsync_positive ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC; |
| 4676 | mode->flags |= vsync_positive ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC; |
| 4677 | mode->type = DRM_MODE_TYPE_DRIVER; |
| 4678 | |
| 4679 | if (timings->flags & 0x80) |
| 4680 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 4681 | mode->vrefresh = drm_mode_vrefresh(mode); |
| 4682 | drm_mode_set_name(mode); |
| 4683 | |
| 4684 | return mode; |
| 4685 | } |
| 4686 | |
| 4687 | static int add_displayid_detailed_1_modes(struct drm_connector *connector, |
| 4688 | struct displayid_block *block) |
| 4689 | { |
| 4690 | struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block; |
| 4691 | int i; |
| 4692 | int num_timings; |
| 4693 | struct drm_display_mode *newmode; |
| 4694 | int num_modes = 0; |
| 4695 | /* blocks must be multiple of 20 bytes length */ |
| 4696 | if (block->num_bytes % 20) |
| 4697 | return 0; |
| 4698 | |
| 4699 | num_timings = block->num_bytes / 20; |
| 4700 | for (i = 0; i < num_timings; i++) { |
| 4701 | struct displayid_detailed_timings_1 *timings = &det->timings[i]; |
| 4702 | |
| 4703 | newmode = drm_mode_displayid_detailed(connector->dev, timings); |
| 4704 | if (!newmode) |
| 4705 | continue; |
| 4706 | |
| 4707 | drm_mode_probed_add(connector, newmode); |
| 4708 | num_modes++; |
| 4709 | } |
| 4710 | return num_modes; |
| 4711 | } |
| 4712 | |
| 4713 | static int add_displayid_detailed_modes(struct drm_connector *connector, |
| 4714 | struct edid *edid) |
| 4715 | { |
| 4716 | u8 *displayid; |
| 4717 | int ret; |
| 4718 | int idx = 1; |
| 4719 | int length = EDID_LENGTH; |
| 4720 | struct displayid_block *block; |
| 4721 | int num_modes = 0; |
| 4722 | |
| 4723 | displayid = drm_find_displayid_extension(edid); |
| 4724 | if (!displayid) |
| 4725 | return 0; |
| 4726 | |
| 4727 | ret = validate_displayid(displayid, length, idx); |
| 4728 | if (ret) |
| 4729 | return 0; |
| 4730 | |
| 4731 | idx += sizeof(struct displayid_hdr); |
| 4732 | while (block = (struct displayid_block *)&displayid[idx], |
| 4733 | idx + sizeof(struct displayid_block) <= length && |
| 4734 | idx + sizeof(struct displayid_block) + block->num_bytes <= length && |
| 4735 | block->num_bytes > 0) { |
| 4736 | idx += block->num_bytes + sizeof(struct displayid_block); |
| 4737 | switch (block->tag) { |
| 4738 | case DATA_BLOCK_TYPE_1_DETAILED_TIMING: |
| 4739 | num_modes += add_displayid_detailed_1_modes(connector, block); |
| 4740 | break; |
| 4741 | } |
| 4742 | } |
| 4743 | return num_modes; |
| 4744 | } |
| 4745 | |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 4746 | /** |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4747 | * drm_add_edid_modes - add modes from EDID data, if available |
| 4748 | * @connector: connector we're probing |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4749 | * @edid: EDID data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4750 | * |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 4751 | * 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] | 4752 | * &drm_display_info structure and ELD in @connector with any information which |
| 4753 | * can be derived from the edid. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4754 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4755 | * 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] | 4756 | */ |
| 4757 | int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) |
| 4758 | { |
| 4759 | int num_modes = 0; |
| 4760 | u32 quirks; |
| 4761 | |
| 4762 | if (edid == NULL) { |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4763 | clear_eld(connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4764 | return 0; |
| 4765 | } |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 4766 | if (!drm_edid_is_valid(edid)) { |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4767 | clear_eld(connector); |
Jordan Crouse | dcdb167 | 2010-05-27 13:40:25 -0600 | [diff] [blame] | 4768 | dev_warn(connector->dev->dev, "%s: EDID invalid.\n", |
Jani Nikula | 2593382 | 2014-06-03 14:56:20 +0300 | [diff] [blame] | 4769 | connector->name); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4770 | return 0; |
| 4771 | } |
| 4772 | |
Jani Nikula | c945b8c | 2017-11-01 16:21:01 +0200 | [diff] [blame] | 4773 | drm_edid_to_eld(connector, edid); |
| 4774 | |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4775 | /* |
Shashank Sharma | 0f0f870 | 2017-07-13 21:03:09 +0530 | [diff] [blame] | 4776 | * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. |
| 4777 | * To avoid multiple parsing of same block, lets parse that map |
| 4778 | * from sink info, before parsing CEA modes. |
| 4779 | */ |
Keith Packard | 170178f | 2017-12-13 00:44:26 -0800 | [diff] [blame] | 4780 | quirks = drm_add_display_info(connector, edid); |
Shashank Sharma | 0f0f870 | 2017-07-13 21:03:09 +0530 | [diff] [blame] | 4781 | |
| 4782 | /* |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4783 | * EDID spec says modes should be preferred in this order: |
| 4784 | * - preferred detailed mode |
| 4785 | * - other detailed modes from base block |
| 4786 | * - detailed modes from extension blocks |
| 4787 | * - CVT 3-byte code modes |
| 4788 | * - standard timing codes |
| 4789 | * - established timing codes |
| 4790 | * - modes inferred from GTF or CVT range information |
| 4791 | * |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 4792 | * We get this pretty much right. |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4793 | * |
| 4794 | * XXX order for additional mode types in extension blocks? |
| 4795 | */ |
Adam Jackson | 1393157 | 2010-08-03 14:38:19 -0400 | [diff] [blame] | 4796 | num_modes += add_detailed_modes(connector, edid, quirks); |
| 4797 | num_modes += add_cvt_modes(connector, edid); |
Adam Jackson | c867df7 | 2010-03-29 21:43:21 +0000 | [diff] [blame] | 4798 | num_modes += add_standard_modes(connector, edid); |
| 4799 | num_modes += add_established_modes(connector, edid); |
Christian Schmidt | 54ac76f | 2011-12-19 14:53:16 +0000 | [diff] [blame] | 4800 | num_modes += add_cea_modes(connector, edid); |
Ville Syrjälä | e6e7920 | 2013-05-31 15:23:41 +0300 | [diff] [blame] | 4801 | num_modes += add_alternate_cea_modes(connector, edid); |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 4802 | num_modes += add_displayid_detailed_modes(connector, edid); |
Ville Syrjälä | 4d53dc0 | 2015-05-08 17:45:07 +0300 | [diff] [blame] | 4803 | if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) |
| 4804 | num_modes += add_inferred_modes(connector, edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4805 | |
| 4806 | if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75)) |
| 4807 | edid_fixup_preferred(connector, quirks); |
| 4808 | |
Mario Kleiner | e10aec6 | 2016-07-06 12:05:44 +0200 | [diff] [blame] | 4809 | if (quirks & EDID_QUIRK_FORCE_6BPC) |
| 4810 | connector->display_info.bpc = 6; |
| 4811 | |
Rafał Miłecki | 49d45a31 | 2013-12-07 13:22:42 +0100 | [diff] [blame] | 4812 | if (quirks & EDID_QUIRK_FORCE_8BPC) |
| 4813 | connector->display_info.bpc = 8; |
| 4814 | |
Mario Kleiner | e345da8 | 2017-04-21 17:05:08 +0200 | [diff] [blame] | 4815 | if (quirks & EDID_QUIRK_FORCE_10BPC) |
| 4816 | connector->display_info.bpc = 10; |
| 4817 | |
Mario Kleiner | bc5b964 | 2014-05-23 21:40:55 +0200 | [diff] [blame] | 4818 | if (quirks & EDID_QUIRK_FORCE_12BPC) |
| 4819 | connector->display_info.bpc = 12; |
| 4820 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 4821 | return num_modes; |
| 4822 | } |
| 4823 | EXPORT_SYMBOL(drm_add_edid_modes); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4824 | |
| 4825 | /** |
| 4826 | * drm_add_modes_noedid - add modes for the connectors without EDID |
| 4827 | * @connector: connector we're probing |
| 4828 | * @hdisplay: the horizontal display limit |
| 4829 | * @vdisplay: the vertical display limit |
| 4830 | * |
| 4831 | * Add the specified modes to the connector's mode list. Only when the |
| 4832 | * hdisplay/vdisplay is not beyond the given limit, it will be added. |
| 4833 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4834 | * 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] | 4835 | */ |
| 4836 | int drm_add_modes_noedid(struct drm_connector *connector, |
| 4837 | int hdisplay, int vdisplay) |
| 4838 | { |
| 4839 | int i, count, num_modes = 0; |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 4840 | struct drm_display_mode *mode; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4841 | struct drm_device *dev = connector->dev; |
| 4842 | |
Daniel Vetter | fbb40b2 | 2015-08-10 11:55:37 +0200 | [diff] [blame] | 4843 | count = ARRAY_SIZE(drm_dmt_modes); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4844 | if (hdisplay < 0) |
| 4845 | hdisplay = 0; |
| 4846 | if (vdisplay < 0) |
| 4847 | vdisplay = 0; |
| 4848 | |
| 4849 | for (i = 0; i < count; i++) { |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 4850 | const struct drm_display_mode *ptr = &drm_dmt_modes[i]; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4851 | if (hdisplay && vdisplay) { |
| 4852 | /* |
| 4853 | * Only when two are valid, they will be used to check |
| 4854 | * whether the mode should be added to the mode list of |
| 4855 | * the connector. |
| 4856 | */ |
| 4857 | if (ptr->hdisplay > hdisplay || |
| 4858 | ptr->vdisplay > vdisplay) |
| 4859 | continue; |
| 4860 | } |
Adam Jackson | f985ded | 2009-11-23 14:23:04 -0500 | [diff] [blame] | 4861 | if (drm_mode_vrefresh(ptr) > 61) |
| 4862 | continue; |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 4863 | mode = drm_mode_duplicate(dev, ptr); |
| 4864 | if (mode) { |
| 4865 | drm_mode_probed_add(connector, mode); |
| 4866 | num_modes++; |
| 4867 | } |
| 4868 | } |
| 4869 | return num_modes; |
| 4870 | } |
| 4871 | EXPORT_SYMBOL(drm_add_modes_noedid); |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4872 | |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4873 | /** |
| 4874 | * drm_set_preferred_mode - Sets the preferred mode of a connector |
| 4875 | * @connector: connector whose mode list should be processed |
| 4876 | * @hpref: horizontal resolution of preferred mode |
| 4877 | * @vpref: vertical resolution of preferred mode |
| 4878 | * |
| 4879 | * Marks a mode as preferred if it matches the resolution specified by @hpref |
| 4880 | * and @vpref. |
| 4881 | */ |
Gerd Hoffmann | 3cf70da | 2013-10-11 10:01:08 +0200 | [diff] [blame] | 4882 | void drm_set_preferred_mode(struct drm_connector *connector, |
| 4883 | int hpref, int vpref) |
| 4884 | { |
| 4885 | struct drm_display_mode *mode; |
| 4886 | |
| 4887 | list_for_each_entry(mode, &connector->probed_modes, head) { |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4888 | if (mode->hdisplay == hpref && |
Daniel Vetter | 9d3de13 | 2014-01-23 16:27:56 +0100 | [diff] [blame] | 4889 | mode->vdisplay == vpref) |
Gerd Hoffmann | 3cf70da | 2013-10-11 10:01:08 +0200 | [diff] [blame] | 4890 | mode->type |= DRM_MODE_TYPE_PREFERRED; |
| 4891 | } |
| 4892 | } |
| 4893 | EXPORT_SYMBOL(drm_set_preferred_mode); |
| 4894 | |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 4895 | static bool is_hdmi2_sink(struct drm_connector *connector) |
| 4896 | { |
| 4897 | /* |
| 4898 | * FIXME: sil-sii8620 doesn't have a connector around when |
| 4899 | * we need one, so we have to be prepared for a NULL connector. |
| 4900 | */ |
| 4901 | if (!connector) |
| 4902 | return true; |
| 4903 | |
| 4904 | return connector->display_info.hdmi.scdc.supported || |
| 4905 | connector->display_info.color_formats & DRM_COLOR_FORMAT_YCRCB420; |
| 4906 | } |
| 4907 | |
Uma Shankar | 2cdbfd6 | 2019-05-16 19:40:09 +0530 | [diff] [blame] | 4908 | static inline bool is_eotf_supported(u8 output_eotf, u8 sink_eotf) |
| 4909 | { |
| 4910 | return sink_eotf & BIT(output_eotf); |
| 4911 | } |
| 4912 | |
| 4913 | /** |
| 4914 | * drm_hdmi_infoframe_set_hdr_metadata() - fill an HDMI DRM infoframe with |
| 4915 | * HDR metadata from userspace |
| 4916 | * @frame: HDMI DRM infoframe |
Sean Paul | 6ac9882 | 2019-05-23 09:54:58 -0400 | [diff] [blame^] | 4917 | * @conn_state: Connector state containing HDR metadata |
Uma Shankar | 2cdbfd6 | 2019-05-16 19:40:09 +0530 | [diff] [blame] | 4918 | * |
| 4919 | * Return: 0 on success or a negative error code on failure. |
| 4920 | */ |
| 4921 | int |
| 4922 | drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame, |
| 4923 | const struct drm_connector_state *conn_state) |
| 4924 | { |
| 4925 | struct drm_connector *connector; |
| 4926 | struct hdr_output_metadata *hdr_metadata; |
| 4927 | int err; |
| 4928 | |
| 4929 | if (!frame || !conn_state) |
| 4930 | return -EINVAL; |
| 4931 | |
| 4932 | connector = conn_state->connector; |
| 4933 | |
| 4934 | if (!conn_state->hdr_output_metadata) |
| 4935 | return -EINVAL; |
| 4936 | |
| 4937 | hdr_metadata = conn_state->hdr_output_metadata->data; |
| 4938 | |
| 4939 | if (!hdr_metadata || !connector) |
| 4940 | return -EINVAL; |
| 4941 | |
| 4942 | /* Sink EOTF is Bit map while infoframe is absolute values */ |
| 4943 | if (!is_eotf_supported(hdr_metadata->hdmi_metadata_type1.eotf, |
| 4944 | connector->hdr_sink_metadata.hdmi_type1.eotf)) { |
| 4945 | DRM_DEBUG_KMS("EOTF Not Supported\n"); |
| 4946 | return -EINVAL; |
| 4947 | } |
| 4948 | |
| 4949 | err = hdmi_drm_infoframe_init(frame); |
| 4950 | if (err < 0) |
| 4951 | return err; |
| 4952 | |
| 4953 | frame->eotf = hdr_metadata->hdmi_metadata_type1.eotf; |
| 4954 | frame->metadata_type = hdr_metadata->hdmi_metadata_type1.metadata_type; |
| 4955 | |
| 4956 | BUILD_BUG_ON(sizeof(frame->display_primaries) != |
| 4957 | sizeof(hdr_metadata->hdmi_metadata_type1.display_primaries)); |
| 4958 | BUILD_BUG_ON(sizeof(frame->white_point) != |
| 4959 | sizeof(hdr_metadata->hdmi_metadata_type1.white_point)); |
| 4960 | |
| 4961 | memcpy(&frame->display_primaries, |
| 4962 | &hdr_metadata->hdmi_metadata_type1.display_primaries, |
| 4963 | sizeof(frame->display_primaries)); |
| 4964 | |
| 4965 | memcpy(&frame->white_point, |
| 4966 | &hdr_metadata->hdmi_metadata_type1.white_point, |
| 4967 | sizeof(frame->white_point)); |
| 4968 | |
| 4969 | frame->max_display_mastering_luminance = |
| 4970 | hdr_metadata->hdmi_metadata_type1.max_display_mastering_luminance; |
| 4971 | frame->min_display_mastering_luminance = |
| 4972 | hdr_metadata->hdmi_metadata_type1.min_display_mastering_luminance; |
| 4973 | frame->max_fall = hdr_metadata->hdmi_metadata_type1.max_fall; |
| 4974 | frame->max_cll = hdr_metadata->hdmi_metadata_type1.max_cll; |
| 4975 | |
| 4976 | return 0; |
| 4977 | } |
| 4978 | EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata); |
| 4979 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4980 | /** |
| 4981 | * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with |
| 4982 | * data from a DRM display mode |
| 4983 | * @frame: HDMI AVI infoframe |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 4984 | * @connector: the connector |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4985 | * @mode: DRM display mode |
| 4986 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 4987 | * Return: 0 on success or a negative error code on failure. |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4988 | */ |
| 4989 | int |
| 4990 | drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 4991 | struct drm_connector *connector, |
| 4992 | const struct drm_display_mode *mode) |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4993 | { |
Ville Syrjälä | a9c266c | 2018-05-08 16:39:39 +0530 | [diff] [blame] | 4994 | enum hdmi_picture_aspect picture_aspect; |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 4995 | int err; |
| 4996 | |
| 4997 | if (!frame || !mode) |
| 4998 | return -EINVAL; |
| 4999 | |
| 5000 | err = hdmi_avi_infoframe_init(frame); |
| 5001 | if (err < 0) |
| 5002 | return err; |
| 5003 | |
Damien Lespiau | bf02db9 | 2013-08-06 20:32:22 +0100 | [diff] [blame] | 5004 | if (mode->flags & DRM_MODE_FLAG_DBLCLK) |
| 5005 | frame->pixel_repeat = 1; |
| 5006 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 5007 | frame->video_code = drm_match_cea_mode(mode); |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 5008 | |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 5009 | /* |
| 5010 | * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but |
| 5011 | * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we |
| 5012 | * have to make sure we dont break HDMI 1.4 sinks. |
| 5013 | */ |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 5014 | if (!is_hdmi2_sink(connector) && frame->video_code > 64) |
Shashank Sharma | 0c1f528 | 2017-07-13 21:03:07 +0530 | [diff] [blame] | 5015 | frame->video_code = 0; |
| 5016 | |
| 5017 | /* |
| 5018 | * HDMI spec says if a mode is found in HDMI 1.4b 4K modes |
| 5019 | * we should send its VIC in vendor infoframes, else send the |
| 5020 | * VIC in AVI infoframes. Lets check if this mode is present in |
| 5021 | * HDMI 1.4b 4K modes |
| 5022 | */ |
| 5023 | if (frame->video_code) { |
| 5024 | u8 vendor_if_vic = drm_match_hdmi_mode(mode); |
| 5025 | bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 5026 | |
| 5027 | if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d) |
| 5028 | frame->video_code = 0; |
| 5029 | } |
| 5030 | |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 5031 | frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 5032 | |
Vandana Kannan | 69ab6d3 | 2014-06-05 14:45:29 +0530 | [diff] [blame] | 5033 | /* |
Stanislav Lisovskiy | 50525c3 | 2018-05-15 16:59:27 +0300 | [diff] [blame] | 5034 | * As some drivers don't support atomic, we can't use connector state. |
| 5035 | * So just initialize the frame with default values, just the same way |
| 5036 | * as it's done with other properties here. |
| 5037 | */ |
| 5038 | frame->content_type = HDMI_CONTENT_TYPE_GRAPHICS; |
| 5039 | frame->itc = 0; |
| 5040 | |
| 5041 | /* |
Vandana Kannan | 69ab6d3 | 2014-06-05 14:45:29 +0530 | [diff] [blame] | 5042 | * Populate picture aspect ratio from either |
| 5043 | * user input (if specified) or from the CEA mode list. |
| 5044 | */ |
Ville Syrjälä | a9c266c | 2018-05-08 16:39:39 +0530 | [diff] [blame] | 5045 | picture_aspect = mode->picture_aspect_ratio; |
| 5046 | if (picture_aspect == HDMI_PICTURE_ASPECT_NONE) |
| 5047 | picture_aspect = drm_get_cea_aspect_ratio(frame->video_code); |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 5048 | |
Ville Syrjälä | a9c266c | 2018-05-08 16:39:39 +0530 | [diff] [blame] | 5049 | /* |
| 5050 | * The infoframe can't convey anything but none, 4:3 |
| 5051 | * and 16:9, so if the user has asked for anything else |
| 5052 | * we can only satisfy it by specifying the right VIC. |
| 5053 | */ |
| 5054 | if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) { |
| 5055 | if (picture_aspect != |
| 5056 | drm_get_cea_aspect_ratio(frame->video_code)) |
| 5057 | return -EINVAL; |
| 5058 | picture_aspect = HDMI_PICTURE_ASPECT_NONE; |
| 5059 | } |
| 5060 | |
| 5061 | frame->picture_aspect = picture_aspect; |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 5062 | frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; |
Daniel Drake | 24d01805 | 2014-02-27 09:19:30 -0600 | [diff] [blame] | 5063 | frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN; |
Thierry Reding | 10a8512 | 2012-11-21 15:31:35 +0100 | [diff] [blame] | 5064 | |
| 5065 | return 0; |
| 5066 | } |
| 5067 | EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode); |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5068 | |
Uma Shankar | 0d68b88 | 2019-02-19 22:43:00 +0530 | [diff] [blame] | 5069 | /* HDMI Colorspace Spec Definitions */ |
| 5070 | #define FULL_COLORIMETRY_MASK 0x1FF |
| 5071 | #define NORMAL_COLORIMETRY_MASK 0x3 |
| 5072 | #define EXTENDED_COLORIMETRY_MASK 0x7 |
| 5073 | #define EXTENDED_ACE_COLORIMETRY_MASK 0xF |
| 5074 | |
| 5075 | #define C(x) ((x) << 0) |
| 5076 | #define EC(x) ((x) << 2) |
| 5077 | #define ACE(x) ((x) << 5) |
| 5078 | |
| 5079 | #define HDMI_COLORIMETRY_NO_DATA 0x0 |
| 5080 | #define HDMI_COLORIMETRY_SMPTE_170M_YCC (C(1) | EC(0) | ACE(0)) |
| 5081 | #define HDMI_COLORIMETRY_BT709_YCC (C(2) | EC(0) | ACE(0)) |
| 5082 | #define HDMI_COLORIMETRY_XVYCC_601 (C(3) | EC(0) | ACE(0)) |
| 5083 | #define HDMI_COLORIMETRY_XVYCC_709 (C(3) | EC(1) | ACE(0)) |
| 5084 | #define HDMI_COLORIMETRY_SYCC_601 (C(3) | EC(2) | ACE(0)) |
| 5085 | #define HDMI_COLORIMETRY_OPYCC_601 (C(3) | EC(3) | ACE(0)) |
| 5086 | #define HDMI_COLORIMETRY_OPRGB (C(3) | EC(4) | ACE(0)) |
| 5087 | #define HDMI_COLORIMETRY_BT2020_CYCC (C(3) | EC(5) | ACE(0)) |
| 5088 | #define HDMI_COLORIMETRY_BT2020_RGB (C(3) | EC(6) | ACE(0)) |
| 5089 | #define HDMI_COLORIMETRY_BT2020_YCC (C(3) | EC(6) | ACE(0)) |
| 5090 | #define HDMI_COLORIMETRY_DCI_P3_RGB_D65 (C(3) | EC(7) | ACE(0)) |
| 5091 | #define HDMI_COLORIMETRY_DCI_P3_RGB_THEATER (C(3) | EC(7) | ACE(1)) |
| 5092 | |
| 5093 | static const u32 hdmi_colorimetry_val[] = { |
| 5094 | [DRM_MODE_COLORIMETRY_NO_DATA] = HDMI_COLORIMETRY_NO_DATA, |
| 5095 | [DRM_MODE_COLORIMETRY_SMPTE_170M_YCC] = HDMI_COLORIMETRY_SMPTE_170M_YCC, |
| 5096 | [DRM_MODE_COLORIMETRY_BT709_YCC] = HDMI_COLORIMETRY_BT709_YCC, |
| 5097 | [DRM_MODE_COLORIMETRY_XVYCC_601] = HDMI_COLORIMETRY_XVYCC_601, |
| 5098 | [DRM_MODE_COLORIMETRY_XVYCC_709] = HDMI_COLORIMETRY_XVYCC_709, |
| 5099 | [DRM_MODE_COLORIMETRY_SYCC_601] = HDMI_COLORIMETRY_SYCC_601, |
| 5100 | [DRM_MODE_COLORIMETRY_OPYCC_601] = HDMI_COLORIMETRY_OPYCC_601, |
| 5101 | [DRM_MODE_COLORIMETRY_OPRGB] = HDMI_COLORIMETRY_OPRGB, |
| 5102 | [DRM_MODE_COLORIMETRY_BT2020_CYCC] = HDMI_COLORIMETRY_BT2020_CYCC, |
| 5103 | [DRM_MODE_COLORIMETRY_BT2020_RGB] = HDMI_COLORIMETRY_BT2020_RGB, |
| 5104 | [DRM_MODE_COLORIMETRY_BT2020_YCC] = HDMI_COLORIMETRY_BT2020_YCC, |
| 5105 | }; |
| 5106 | |
| 5107 | #undef C |
| 5108 | #undef EC |
| 5109 | #undef ACE |
| 5110 | |
| 5111 | /** |
| 5112 | * drm_hdmi_avi_infoframe_colorspace() - fill the HDMI AVI infoframe |
| 5113 | * colorspace information |
| 5114 | * @frame: HDMI AVI infoframe |
| 5115 | * @conn_state: connector state |
| 5116 | */ |
| 5117 | void |
| 5118 | drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame, |
| 5119 | const struct drm_connector_state *conn_state) |
| 5120 | { |
| 5121 | u32 colorimetry_val; |
| 5122 | u32 colorimetry_index = conn_state->colorspace & FULL_COLORIMETRY_MASK; |
| 5123 | |
| 5124 | if (colorimetry_index >= ARRAY_SIZE(hdmi_colorimetry_val)) |
| 5125 | colorimetry_val = HDMI_COLORIMETRY_NO_DATA; |
| 5126 | else |
| 5127 | colorimetry_val = hdmi_colorimetry_val[colorimetry_index]; |
| 5128 | |
| 5129 | frame->colorimetry = colorimetry_val & NORMAL_COLORIMETRY_MASK; |
| 5130 | /* |
| 5131 | * ToDo: Extend it for ACE formats as well. Modify the infoframe |
| 5132 | * structure and extend it in drivers/video/hdmi |
| 5133 | */ |
| 5134 | frame->extended_colorimetry = (colorimetry_val >> 2) & |
| 5135 | EXTENDED_COLORIMETRY_MASK; |
| 5136 | } |
| 5137 | EXPORT_SYMBOL(drm_hdmi_avi_infoframe_colorspace); |
| 5138 | |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5139 | /** |
| 5140 | * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe |
| 5141 | * quantization range information |
| 5142 | * @frame: HDMI AVI infoframe |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 5143 | * @connector: the connector |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 5144 | * @mode: DRM display mode |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5145 | * @rgb_quant_range: RGB quantization range (Q) |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5146 | */ |
| 5147 | void |
| 5148 | drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame, |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 5149 | struct drm_connector *connector, |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 5150 | const struct drm_display_mode *mode, |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 5151 | enum hdmi_quantization_range rgb_quant_range) |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5152 | { |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 5153 | const struct drm_display_info *info = &connector->display_info; |
| 5154 | |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5155 | /* |
| 5156 | * CEA-861: |
| 5157 | * "A Source shall not send a non-zero Q value that does not correspond |
| 5158 | * to the default RGB Quantization Range for the transmitted Picture |
| 5159 | * unless the Sink indicates support for the Q bit in a Video |
| 5160 | * Capabilities Data Block." |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 5161 | * |
| 5162 | * HDMI 2.0 recommends sending non-zero Q when it does match the |
| 5163 | * default RGB quantization range for the mode, even when QS=0. |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5164 | */ |
Ville Syrjälä | 1581b2d | 2019-01-08 19:28:28 +0200 | [diff] [blame] | 5165 | if (info->rgb_quant_range_selectable || |
Ville Syrjälä | 779c4c2 | 2017-01-11 14:57:24 +0200 | [diff] [blame] | 5166 | rgb_quant_range == drm_default_rgb_quant_range(mode)) |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5167 | frame->quantization_range = rgb_quant_range; |
| 5168 | else |
| 5169 | frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 5170 | |
| 5171 | /* |
| 5172 | * CEA-861-F: |
| 5173 | * "When transmitting any RGB colorimetry, the Source should set the |
| 5174 | * YQ-field to match the RGB Quantization Range being transmitted |
| 5175 | * (e.g., when Limited Range RGB, set YQ=0 or when Full Range RGB, |
| 5176 | * set YQ=1) and the Sink shall ignore the YQ-field." |
Ville Syrjälä | 9271c0c | 2017-11-08 17:25:04 +0200 | [diff] [blame] | 5177 | * |
| 5178 | * Unfortunate certain sinks (eg. VIZ Model 67/E261VA) get confused |
| 5179 | * by non-zero YQ when receiving RGB. There doesn't seem to be any |
| 5180 | * good way to tell which version of CEA-861 the sink supports, so |
| 5181 | * we limit non-zero YQ to HDMI 2.0 sinks only as HDMI 2.0 is based |
| 5182 | * on on CEA-861-F. |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 5183 | */ |
Ville Syrjälä | 13d0add | 2019-01-08 19:28:25 +0200 | [diff] [blame] | 5184 | if (!is_hdmi2_sink(connector) || |
Ville Syrjälä | 9271c0c | 2017-11-08 17:25:04 +0200 | [diff] [blame] | 5185 | rgb_quant_range == HDMI_QUANTIZATION_RANGE_LIMITED) |
Ville Syrjälä | fcc8a22 | 2017-01-11 14:57:25 +0200 | [diff] [blame] | 5186 | frame->ycc_quantization_range = |
| 5187 | HDMI_YCC_QUANTIZATION_RANGE_LIMITED; |
| 5188 | else |
| 5189 | frame->ycc_quantization_range = |
| 5190 | HDMI_YCC_QUANTIZATION_RANGE_FULL; |
Ville Syrjälä | a2ce26f | 2017-01-11 14:57:23 +0200 | [diff] [blame] | 5191 | } |
| 5192 | EXPORT_SYMBOL(drm_hdmi_avi_infoframe_quant_range); |
| 5193 | |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5194 | static enum hdmi_3d_structure |
| 5195 | s3d_structure_from_display_mode(const struct drm_display_mode *mode) |
| 5196 | { |
| 5197 | u32 layout = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 5198 | |
| 5199 | switch (layout) { |
| 5200 | case DRM_MODE_FLAG_3D_FRAME_PACKING: |
| 5201 | return HDMI_3D_STRUCTURE_FRAME_PACKING; |
| 5202 | case DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE: |
| 5203 | return HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE; |
| 5204 | case DRM_MODE_FLAG_3D_LINE_ALTERNATIVE: |
| 5205 | return HDMI_3D_STRUCTURE_LINE_ALTERNATIVE; |
| 5206 | case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL: |
| 5207 | return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL; |
| 5208 | case DRM_MODE_FLAG_3D_L_DEPTH: |
| 5209 | return HDMI_3D_STRUCTURE_L_DEPTH; |
| 5210 | case DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH: |
| 5211 | return HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH; |
| 5212 | case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM: |
| 5213 | return HDMI_3D_STRUCTURE_TOP_AND_BOTTOM; |
| 5214 | case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: |
| 5215 | return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF; |
| 5216 | default: |
| 5217 | return HDMI_3D_STRUCTURE_INVALID; |
| 5218 | } |
| 5219 | } |
| 5220 | |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5221 | /** |
| 5222 | * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with |
| 5223 | * data from a DRM display mode |
| 5224 | * @frame: HDMI vendor infoframe |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5225 | * @connector: the connector |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5226 | * @mode: DRM display mode |
| 5227 | * |
| 5228 | * Note that there's is a need to send HDMI vendor infoframes only when using a |
| 5229 | * 4k or stereoscopic 3D mode. So when giving any other mode as input this |
| 5230 | * function will return -EINVAL, error that can be safely ignored. |
| 5231 | * |
Thierry Reding | db6cf833 | 2014-04-29 11:44:34 +0200 | [diff] [blame] | 5232 | * Return: 0 on success or a negative error code on failure. |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5233 | */ |
| 5234 | int |
| 5235 | 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] | 5236 | struct drm_connector *connector, |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5237 | const struct drm_display_mode *mode) |
| 5238 | { |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5239 | /* |
| 5240 | * FIXME: sil-sii8620 doesn't have a connector around when |
| 5241 | * we need one, so we have to be prepared for a NULL connector. |
| 5242 | */ |
| 5243 | bool has_hdmi_infoframe = connector ? |
| 5244 | connector->display_info.has_hdmi_infoframe : false; |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5245 | int err; |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5246 | u32 s3d_flags; |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5247 | u8 vic; |
| 5248 | |
| 5249 | if (!frame || !mode) |
| 5250 | return -EINVAL; |
| 5251 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5252 | if (!has_hdmi_infoframe) |
| 5253 | return -EINVAL; |
| 5254 | |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5255 | vic = drm_match_hdmi_mode(mode); |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5256 | s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK; |
| 5257 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5258 | /* |
| 5259 | * Even if it's not absolutely necessary to send the infoframe |
| 5260 | * (ie.vic==0 and s3d_struct==0) we will still send it if we |
| 5261 | * know that the sink can handle it. This is based on a |
| 5262 | * suggestion in HDMI 2.0 Appendix F. Apparently some sinks |
| 5263 | * have trouble realizing that they shuld switch from 3D to 2D |
| 5264 | * mode if the source simply stops sending the infoframe when |
| 5265 | * it wants to switch from 3D to 2D. |
| 5266 | */ |
Damien Lespiau | 4eed4a0 | 2013-09-25 16:45:26 +0100 | [diff] [blame] | 5267 | |
| 5268 | if (vic && s3d_flags) |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5269 | return -EINVAL; |
| 5270 | |
| 5271 | err = hdmi_vendor_infoframe_init(frame); |
| 5272 | if (err < 0) |
| 5273 | return err; |
| 5274 | |
Ville Syrjälä | f1781e9 | 2017-11-13 19:04:19 +0200 | [diff] [blame] | 5275 | frame->vic = vic; |
| 5276 | frame->s3d_struct = s3d_structure_from_display_mode(mode); |
Lespiau, Damien | 83dd000 | 2013-08-19 16:59:03 +0100 | [diff] [blame] | 5277 | |
| 5278 | return 0; |
| 5279 | } |
| 5280 | EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5281 | |
Dave Airlie | 5e546cd | 2016-05-03 15:31:12 +1000 | [diff] [blame] | 5282 | static int drm_parse_tiled_block(struct drm_connector *connector, |
| 5283 | struct displayid_block *block) |
| 5284 | { |
| 5285 | struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block; |
| 5286 | u16 w, h; |
| 5287 | u8 tile_v_loc, tile_h_loc; |
| 5288 | u8 num_v_tile, num_h_tile; |
| 5289 | struct drm_tile_group *tg; |
| 5290 | |
| 5291 | w = tile->tile_size[0] | tile->tile_size[1] << 8; |
| 5292 | h = tile->tile_size[2] | tile->tile_size[3] << 8; |
| 5293 | |
| 5294 | num_v_tile = (tile->topo[0] & 0xf) | (tile->topo[2] & 0x30); |
| 5295 | num_h_tile = (tile->topo[0] >> 4) | ((tile->topo[2] >> 2) & 0x30); |
| 5296 | tile_v_loc = (tile->topo[1] & 0xf) | ((tile->topo[2] & 0x3) << 4); |
| 5297 | tile_h_loc = (tile->topo[1] >> 4) | (((tile->topo[2] >> 2) & 0x3) << 4); |
| 5298 | |
| 5299 | connector->has_tile = true; |
| 5300 | if (tile->tile_cap & 0x80) |
| 5301 | connector->tile_is_single_monitor = true; |
| 5302 | |
| 5303 | connector->num_h_tile = num_h_tile + 1; |
| 5304 | connector->num_v_tile = num_v_tile + 1; |
| 5305 | connector->tile_h_loc = tile_h_loc; |
| 5306 | connector->tile_v_loc = tile_v_loc; |
| 5307 | connector->tile_h_size = w + 1; |
| 5308 | connector->tile_v_size = h + 1; |
| 5309 | |
| 5310 | DRM_DEBUG_KMS("tile cap 0x%x\n", tile->tile_cap); |
| 5311 | DRM_DEBUG_KMS("tile_size %d x %d\n", w + 1, h + 1); |
| 5312 | DRM_DEBUG_KMS("topo num tiles %dx%d, location %dx%d\n", |
| 5313 | num_h_tile + 1, num_v_tile + 1, tile_h_loc, tile_v_loc); |
| 5314 | DRM_DEBUG_KMS("vend %c%c%c\n", tile->topology_id[0], tile->topology_id[1], tile->topology_id[2]); |
| 5315 | |
| 5316 | tg = drm_mode_get_tile_group(connector->dev, tile->topology_id); |
| 5317 | if (!tg) { |
| 5318 | tg = drm_mode_create_tile_group(connector->dev, tile->topology_id); |
| 5319 | } |
| 5320 | if (!tg) |
| 5321 | return -ENOMEM; |
| 5322 | |
| 5323 | if (connector->tile_group != tg) { |
| 5324 | /* if we haven't got a pointer, |
| 5325 | take the reference, drop ref to old tile group */ |
| 5326 | if (connector->tile_group) { |
| 5327 | drm_mode_put_tile_group(connector->dev, connector->tile_group); |
| 5328 | } |
| 5329 | connector->tile_group = tg; |
| 5330 | } else |
| 5331 | /* if same tile group, then release the ref we just took. */ |
| 5332 | drm_mode_put_tile_group(connector->dev, tg); |
| 5333 | return 0; |
| 5334 | } |
| 5335 | |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5336 | static int drm_parse_display_id(struct drm_connector *connector, |
| 5337 | u8 *displayid, int length, |
| 5338 | bool is_edid_extension) |
| 5339 | { |
| 5340 | /* if this is an EDID extension the first byte will be 0x70 */ |
| 5341 | int idx = 0; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5342 | struct displayid_block *block; |
Dave Airlie | 5e546cd | 2016-05-03 15:31:12 +1000 | [diff] [blame] | 5343 | int ret; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5344 | |
| 5345 | if (is_edid_extension) |
| 5346 | idx = 1; |
| 5347 | |
Dave Airlie | c9729177 | 2016-05-03 15:38:37 +1000 | [diff] [blame] | 5348 | ret = validate_displayid(displayid, length, idx); |
| 5349 | if (ret) |
| 5350 | return ret; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5351 | |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5352 | idx += sizeof(struct displayid_hdr); |
| 5353 | while (block = (struct displayid_block *)&displayid[idx], |
| 5354 | idx + sizeof(struct displayid_block) <= length && |
| 5355 | idx + sizeof(struct displayid_block) + block->num_bytes <= length && |
| 5356 | block->num_bytes > 0) { |
| 5357 | idx += block->num_bytes + sizeof(struct displayid_block); |
| 5358 | DRM_DEBUG_KMS("block id 0x%x, rev %d, len %d\n", |
| 5359 | block->tag, block->rev, block->num_bytes); |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5360 | |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5361 | switch (block->tag) { |
| 5362 | case DATA_BLOCK_TILED_DISPLAY: |
| 5363 | ret = drm_parse_tiled_block(connector, block); |
| 5364 | if (ret) |
| 5365 | return ret; |
| 5366 | break; |
Dave Airlie | a39ed68 | 2016-05-02 08:35:05 +1000 | [diff] [blame] | 5367 | case DATA_BLOCK_TYPE_1_DETAILED_TIMING: |
| 5368 | /* handled in mode gathering code. */ |
| 5369 | break; |
Tomas Bzatek | 3a4a2ea | 2016-05-01 15:02:45 +0200 | [diff] [blame] | 5370 | default: |
| 5371 | DRM_DEBUG_KMS("found DisplayID tag 0x%x, unhandled\n", block->tag); |
| 5372 | break; |
| 5373 | } |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 5374 | } |
| 5375 | return 0; |
| 5376 | } |
| 5377 | |
| 5378 | static void drm_get_displayid(struct drm_connector *connector, |
| 5379 | struct edid *edid) |
| 5380 | { |
| 5381 | void *displayid = NULL; |
| 5382 | int ret; |
| 5383 | connector->has_tile = false; |
| 5384 | displayid = drm_find_displayid_extension(edid); |
| 5385 | if (!displayid) { |
| 5386 | /* drop reference to any tile group we had */ |
| 5387 | goto out_drop_ref; |
| 5388 | } |
| 5389 | |
| 5390 | ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, true); |
| 5391 | if (ret < 0) |
| 5392 | goto out_drop_ref; |
| 5393 | if (!connector->has_tile) |
| 5394 | goto out_drop_ref; |
| 5395 | return; |
| 5396 | out_drop_ref: |
| 5397 | if (connector->tile_group) { |
| 5398 | drm_mode_put_tile_group(connector->dev, connector->tile_group); |
| 5399 | connector->tile_group = NULL; |
| 5400 | } |
| 5401 | return; |
| 5402 | } |