Lines Matching +full:abs +full:- +full:fuzz
7 * SPDX-License-Identifier: GPL-2.0+
11 * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd
33 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
34 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
35 #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
37 (((edid)->version > (maj)) || \
38 ((edid)->version == (maj) && (edid)->revision > (min)))
63 /* Force reduced-blanking timings for detailed modes */
106 /* Envision Peripherals, Inc. EN-7100e */
118 /* LG Philips LCD LP154W01-A5 */
130 /* Samsung SyncMaster 22[5-6]BW */
134 /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */
143 /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */
146 /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/
151 * Probably taken from CEA-861 spec.
157 * From CEA/CTA-861 spec.
161 /* 1 - 640x480@60Hz */
166 /* 2 - 720x480@60Hz */
171 /* 3 - 720x480@60Hz */
176 /* 4 - 1280x720@60Hz */
181 /* 5 - 1920x1080i@60Hz */
187 /* 6 - 720(1440)x480i@60Hz */
193 /* 7 - 720(1440)x480i@60Hz */
199 /* 8 - 720(1440)x240@60Hz */
205 /* 9 - 720(1440)x240@60Hz */
211 /* 10 - 2880x480i@60Hz */
217 /* 11 - 2880x480i@60Hz */
223 /* 12 - 2880x240@60Hz */
228 /* 13 - 2880x240@60Hz */
233 /* 14 - 1440x480@60Hz */
238 /* 15 - 1440x480@60Hz */
243 /* 16 - 1920x1080@60Hz */
248 /* 17 - 720x576@50Hz */
253 /* 18 - 720x576@50Hz */
258 /* 19 - 1280x720@50Hz */
263 /* 20 - 1920x1080i@50Hz */
269 /* 21 - 720(1440)x576i@50Hz */
275 /* 22 - 720(1440)x576i@50Hz */
281 /* 23 - 720(1440)x288@50Hz */
287 /* 24 - 720(1440)x288@50Hz */
293 /* 25 - 2880x576i@50Hz */
299 /* 26 - 2880x576i@50Hz */
305 /* 27 - 2880x288@50Hz */
310 /* 28 - 2880x288@50Hz */
315 /* 29 - 1440x576@50Hz */
320 /* 30 - 1440x576@50Hz */
325 /* 31 - 1920x1080@50Hz */
330 /* 32 - 1920x1080@24Hz */
335 /* 33 - 1920x1080@25Hz */
340 /* 34 - 1920x1080@30Hz */
345 /* 35 - 2880x480@60Hz */
350 /* 36 - 2880x480@60Hz */
355 /* 37 - 2880x576@50Hz */
360 /* 38 - 2880x576@50Hz */
365 /* 39 - 1920x1080i@50Hz */
371 /* 40 - 1920x1080i@100Hz */
377 /* 41 - 1280x720@100Hz */
382 /* 42 - 720x576@100Hz */
387 /* 43 - 720x576@100Hz */
392 /* 44 - 720(1440)x576i@100Hz */
398 /* 45 - 720(1440)x576i@100Hz */
404 /* 46 - 1920x1080i@120Hz */
410 /* 47 - 1280x720@120Hz */
415 /* 48 - 720x480@120Hz */
420 /* 49 - 720x480@120Hz */
425 /* 50 - 720(1440)x480i@120Hz */
431 /* 51 - 720(1440)x480i@120Hz */
437 /* 52 - 720x576@200Hz */
442 /* 53 - 720x576@200Hz */
447 /* 54 - 720(1440)x576i@200Hz */
453 /* 55 - 720(1440)x576i@200Hz */
459 /* 56 - 720x480@240Hz */
464 /* 57 - 720x480@240Hz */
469 /* 58 - 720(1440)x480i@240 */
475 /* 59 - 720(1440)x480i@240 */
481 /* 60 - 1280x720@24Hz */
486 /* 61 - 1280x720@25Hz */
491 /* 62 - 1280x720@30Hz */
496 /* 63 - 1920x1080@120Hz */
501 /* 64 - 1920x1080@100Hz */
506 /* 65 - 1280x720@24Hz */
511 /* 66 - 1280x720@25Hz */
516 /* 67 - 1280x720@30Hz */
521 /* 68 - 1280x720@50Hz */
526 /* 69 - 1280x720@60Hz */
531 /* 70 - 1280x720@100Hz */
536 /* 71 - 1280x720@120Hz */
541 /* 72 - 1920x1080@24Hz */
546 /* 73 - 1920x1080@25Hz */
551 /* 74 - 1920x1080@30Hz */
556 /* 75 - 1920x1080@50Hz */
561 /* 76 - 1920x1080@60Hz */
566 /* 77 - 1920x1080@100Hz */
571 /* 78 - 1920x1080@120Hz */
576 /* 79 - 1680x720@24Hz */
581 /* 80 - 1680x720@25Hz */
586 /* 81 - 1680x720@30Hz */
591 /* 82 - 1680x720@50Hz */
596 /* 83 - 1680x720@60Hz */
601 /* 84 - 1680x720@100Hz */
606 /* 85 - 1680x720@120Hz */
611 /* 86 - 2560x1080@24Hz */
616 /* 87 - 2560x1080@25Hz */
621 /* 88 - 2560x1080@30Hz */
626 /* 89 - 2560x1080@50Hz */
631 /* 90 - 2560x1080@60Hz */
636 /* 91 - 2560x1080@100Hz */
641 /* 92 - 2560x1080@120Hz */
646 /* 93 - 3840x2160p@24Hz 16:9 */
651 /* 94 - 3840x2160p@25Hz 16:9 */
656 /* 95 - 3840x2160p@30Hz 16:9 */
661 /* 96 - 3840x2160p@50Hz 16:9 */
666 /* 97 - 3840x2160p@60Hz 16:9 */
671 /* 98 - 4096x2160p@24Hz 256:135 */
676 /* 99 - 4096x2160p@25Hz 256:135 */
681 /* 100 - 4096x2160p@30Hz 256:135 */
686 /* 101 - 4096x2160p@50Hz 256:135 */
691 /* 102 - 4096x2160p@60Hz 256:135 */
696 /* 103 - 3840x2160p@24Hz 64:27 */
701 /* 104 - 3840x2160p@25Hz 64:27 */
706 /* 105 - 3840x2160p@30Hz 64:27 */
711 /* 106 - 3840x2160p@50Hz 64:27 */
716 /* 107 - 3840x2160p@60Hz 64:27 */
721 /* 108 - 1280x720@48Hz 16:9 */
726 /* 109 - 1280x720@48Hz 64:27 */
731 /* 110 - 1680x720@48Hz 64:27 */
736 /* 111 - 1920x1080@48Hz 16:9 */
741 /* 112 - 1920x1080@48Hz 64:27 */
746 /* 113 - 2560x1080@48Hz 64:27 */
751 /* 114 - 3840x2160@48Hz 16:9 */
756 /* 115 - 4096x2160@48Hz 256:135 */
761 /* 116 - 3840x2160@48Hz 64:27 */
766 /* 117 - 3840x2160@100Hz 16:9 */
771 /* 118 - 3840x2160@120Hz 16:9 */
776 /* 119 - 3840x2160@100Hz 64:27 */
781 /* 120 - 3840x2160@120Hz 64:27 */
786 /* 121 - 5120x2160@24Hz 64:27 */
791 /* 122 - 5120x2160@25Hz 64:27 */
796 /* 123 - 5120x2160@30Hz 64:27 */
801 /* 124 - 5120x2160@48Hz 64:27 */
806 /* 125 - 5120x2160@50Hz 64:27 */
811 /* 126 - 5120x2160@60Hz 64:27 */
816 /* 127 - 5120x2160@100Hz 64:27 */
824 /* 193 - 5120x2160@120Hz 64:27 */
829 /* 194 - 7680x4320@24Hz 16:9 */
834 /* 195 - 7680x4320@25Hz 16:9 */
839 /* 196 - 7680x4320@30Hz 16:9 */
844 /* 197 - 7680x4320@48Hz 16:9 */
849 /* 198 - 7680x4320@50Hz 16:9 */
854 /* 199 - 7680x4320@60Hz 16:9 */
859 /* 200 - 7680x4320@100Hz 16:9 */
864 /* 201 - 7680x4320@120Hz 16:9 */
869 /* 202 - 7680x4320@24Hz 64:27 */
874 /* 203 - 7680x4320@25Hz 64:27 */
879 /* 204 - 7680x4320@30Hz 64:27 */
884 /* 205 - 7680x4320@48Hz 64:27 */
889 /* 206 - 7680x4320@50Hz 64:27 */
894 /* 207 - 7680x4320@60Hz 64:27 */
899 /* 208 - 7680x4320@100Hz 64:27 */
904 /* 209 - 7680x4320@120Hz 64:27 */
909 /* 210 - 10240x4320@24Hz 64:27 */
914 /* 211 - 10240x4320@25Hz 64:27 */
919 /* 212 - 10240x4320@30Hz 64:27 */
924 /* 213 - 10240x4320@48Hz 64:27 */
929 /* 214 - 10240x4320@50Hz 64:27 */
934 /* 215 - 10240x4320@60Hz 64:27 */
939 /* 216 - 10240x4320@100Hz 64:27 */
944 /* 217 - 10240x4320@120Hz 64:27 */
949 /* 218 - 4096x2160@100Hz 256:135 */
954 /* 219 - 4096x2160@120Hz 256:135 */
965 /* 0 - dummy, VICs start at 1 */
967 /* 1 - 3840x2160@30Hz */
973 /* 2 - 3840x2160@25Hz */
979 /* 3 - 3840x2160@24Hz */
985 /* 4 - 4096x2160@24Hz (SMPTE) */
998 /* 0x01 - 640x350@85Hz */
1002 /* 0x02 - 640x400@85Hz */
1006 /* 0x03 - 720x400@85Hz */
1010 /* 0x04 - 640x480@60Hz */
1014 /* 0x05 - 640x480@72Hz */
1018 /* 0x06 - 640x480@75Hz */
1022 /* 0x07 - 640x480@85Hz */
1026 /* 0x08 - 800x600@56Hz */
1030 /* 0x09 - 800x600@60Hz */
1034 /* 0x0a - 800x600@72Hz */
1038 /* 0x0b - 800x600@75Hz */
1042 /* 0x0c - 800x600@85Hz */
1046 /* 0x0d - 800x600@120Hz RB */
1050 /* 0x0e - 848x480@60Hz */
1054 /* 0x0f - 1024x768@43Hz, interlace */
1059 /* 0x10 - 1024x768@60Hz */
1063 /* 0x11 - 1024x768@70Hz */
1067 /* 0x12 - 1024x768@75Hz */
1071 /* 0x13 - 1024x768@85Hz */
1075 /* 0x14 - 1024x768@120Hz RB */
1079 /* 0x15 - 1152x864@75Hz */
1083 /* 0x55 - 1280x720@60Hz */
1087 /* 0x16 - 1280x768@60Hz RB */
1091 /* 0x17 - 1280x768@60Hz */
1095 /* 0x18 - 1280x768@75Hz */
1099 /* 0x19 - 1280x768@85Hz */
1103 /* 0x1a - 1280x768@120Hz RB */
1107 /* 0x1b - 1280x800@60Hz RB */
1111 /* 0x1c - 1280x800@60Hz */
1115 /* 0x1d - 1280x800@75Hz */
1119 /* 0x1e - 1280x800@85Hz */
1123 /* 0x1f - 1280x800@120Hz RB */
1127 /* 0x20 - 1280x960@60Hz */
1131 /* 0x21 - 1280x960@85Hz */
1135 /* 0x22 - 1280x960@120Hz RB */
1139 /* 0x23 - 1280x1024@60Hz */
1143 /* 0x24 - 1280x1024@75Hz */
1147 /* 0x25 - 1280x1024@85Hz */
1151 /* 0x26 - 1280x1024@120Hz RB */
1155 /* 0x27 - 1360x768@60Hz */
1159 /* 0x28 - 1360x768@120Hz RB */
1163 /* 0x51 - 1366x768@60Hz */
1167 /* 0x56 - 1366x768@60Hz */
1171 /* 0x29 - 1400x1050@60Hz RB */
1175 /* 0x2a - 1400x1050@60Hz */
1179 /* 0x2b - 1400x1050@75Hz */
1183 /* 0x2c - 1400x1050@85Hz */
1187 /* 0x2d - 1400x1050@120Hz RB */
1191 /* 0x2e - 1440x900@60Hz RB */
1195 /* 0x2f - 1440x900@60Hz */
1199 /* 0x30 - 1440x900@75Hz */
1203 /* 0x31 - 1440x900@85Hz */
1207 /* 0x32 - 1440x900@120Hz RB */
1211 /* 0x53 - 1600x900@60Hz */
1215 /* 0x33 - 1600x1200@60Hz */
1219 /* 0x34 - 1600x1200@65Hz */
1223 /* 0x35 - 1600x1200@70Hz */
1227 /* 0x36 - 1600x1200@75Hz */
1231 /* 0x37 - 1600x1200@85Hz */
1235 /* 0x38 - 1600x1200@120Hz RB */
1239 /* 0x39 - 1680x1050@60Hz RB */
1243 /* 0x3a - 1680x1050@60Hz */
1247 /* 0x3b - 1680x1050@75Hz */
1251 /* 0x3c - 1680x1050@85Hz */
1255 /* 0x3d - 1680x1050@120Hz RB */
1259 /* 0x3e - 1792x1344@60Hz */
1263 /* 0x3f - 1792x1344@75Hz */
1267 /* 0x40 - 1792x1344@120Hz RB */
1271 /* 0x41 - 1856x1392@60Hz */
1275 /* 0x42 - 1856x1392@75Hz */
1279 /* 0x43 - 1856x1392@120Hz RB */
1283 /* 0x52 - 1920x1080@60Hz */
1287 /* 0x44 - 1920x1200@60Hz RB */
1291 /* 0x45 - 1920x1200@60Hz */
1295 /* 0x46 - 1920x1200@75Hz */
1299 /* 0x47 - 1920x1200@85Hz */
1303 /* 0x48 - 1920x1200@120Hz RB */
1307 /* 0x49 - 1920x1440@60Hz */
1311 /* 0x4a - 1920x1440@75Hz */
1315 /* 0x4b - 1920x1440@120Hz RB */
1319 /* 0x54 - 2048x1152@60Hz */
1323 /* 0x4c - 2560x1600@60Hz RB */
1327 /* 0x4d - 2560x1600@60Hz */
1331 /* 0x4e - 2560x1600@75Hz */
1335 /* 0x4f - 2560x1600@85Hz */
1339 /* 0x50 - 2560x1600@120Hz RB */
1343 /* 0x57 - 4096x2160@60Hz RB */
1347 /* 0x58 - 4096x2160@59.94Hz RB */
1356 * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
1360 * The DMT modes have been fact-checked; the rest are mild guesses.
1435 /* 0. vic:2 - 720x480@60Hz */
1440 /* 1. vic:3 - 720x480@60Hz */
1449 /* 2. vic:4 - 1280x720@60Hz */
1454 /* 3. vic:5 - 1920x1080i@60Hz */
1460 /* 4. vic:6 - 720(1440)x480i@60Hz */
1466 /* 5. vic:16 - 1920x1080@60Hz */
1471 /* 6. vic:17 - 720x576@50Hz */
1476 /* 7. vic:18 - 720x576@50Hz */
1481 /* 8. vic:19 - 1280x720@50Hz */
1486 /* 9. vic:20 - 1920x1080i@50Hz */
1492 /* 10. vic:21 - 720(1440)x576i@50Hz */
1498 /* 11. vic:31 - 1920x1080@50Hz */
1503 /* 12. vic:32 - 1920x1080@24Hz */
1508 /* 13. vic:33 - 1920x1080@25Hz */
1513 /* 14. vic:34 - 1920x1080@30Hz */
1518 /* 15. vic:39 - 1920x1080i@50Hz */
1524 /* 16. vic:60 - 1280x720@24Hz */
1529 /* 17. vic:61 - 1280x720@25Hz */
1534 /* 18. vic:62 - 1280x720@30Hz */
1539 /* 19. vic:93 - 3840x2160p@24Hz 16:9 */
1544 /* 20. vic:94 - 3840x2160p@25Hz 16:9 */
1549 /* 21. vic:95 - 3840x2160p@30Hz 16:9 */
1554 /* 22. vic:96 - 3840x2160p@50Hz 16:9 */
1559 /* 23. vic:97 - 3840x2160p@60Hz 16:9 */
1564 /* 24. vic:98 - 4096x2160p@24Hz 256:135 */
1569 /* 25. vic:99 - 4096x2160p@25Hz 256:135 */
1574 /* 26. vic:100 - 4096x2160p@30Hz 256:135 */
1579 /* 27. vic:101 - 4096x2160p@50Hz 256:135 */
1584 /* 28. vic:102 - 4096x2160p@60Hz 256:135 */
1589 /* 29. vic:118 - 3840x2160@120Hz 16:9 */
1594 /* 30. vic:196 - 7680x4320@30Hz 16:9 */
1599 /* 31. vic:198 - 7680x4320@50Hz 16:9 */
1604 /* 32. vic:199 - 7680x4320@60Hz 16:9 */
1686 return &edid_cea_modes_1[vic - 1]; in cea_mode_for_vic()
1688 return &edid_cea_modes_193[vic - 193]; in cea_mode_for_vic()
1708 if ((edid_info == NULL) || (edid_info->version == 0)) in edid_check_info()
1709 return -1; in edid_check_info()
1711 if (memcmp(edid_info->header, "\x0\xff\xff\xff\xff\xff\xff\x0", 8)) in edid_check_info()
1712 return -1; in edid_check_info()
1714 if (edid_info->version == 0xff && edid_info->revision == 0xff) in edid_check_info()
1715 return -1; in edid_check_info()
1728 return (checksum == 0) ? 0 : -EINVAL; in edid_check_checksum()
1740 return -1; in edid_get_ranges()
1742 for (i = 0; i < ARRAY_SIZE(edid->monitor_details.descriptor); i++) { in edid_get_ranges()
1743 monitor = &edid->monitor_details.descriptor[i]; in edid_get_ranges()
1744 if (monitor->type == EDID_MONITOR_DESCRIPTOR_RANGE) { in edid_get_ranges()
1745 *hmin = monitor->data.range_data.horizontal_min; in edid_get_ranges()
1746 *hmax = monitor->data.range_data.horizontal_max; in edid_get_ranges()
1747 *vmin = monitor->data.range_data.vertical_min; in edid_get_ranges()
1748 *vmax = monitor->data.range_data.vertical_max; in edid_get_ranges()
1752 return -1; in edid_get_ranges()
1758 entry->min = value; in set_entry()
1759 entry->typ = value; in set_entry()
1760 entry->max = value; in set_entry()
1764 * decode_timing() - Decoding an 18-byte detailed timing record
1777 set_entry(&timing->pixelclock, (buf[0] + (buf[1] << 8)) * 10000); in decode_timing()
1791 set_entry(&timing->hactive, ha); in decode_timing()
1792 set_entry(&timing->hfront_porch, hso); in decode_timing()
1793 set_entry(&timing->hback_porch, hbl - hso - hspw); in decode_timing()
1794 set_entry(&timing->hsync_len, hspw); in decode_timing()
1796 set_entry(&timing->vactive, va); in decode_timing()
1797 set_entry(&timing->vfront_porch, vso); in decode_timing()
1798 set_entry(&timing->vback_porch, vbl - vso - vspw); in decode_timing()
1799 set_entry(&timing->vsync_len, vspw); in decode_timing()
1801 timing->flags = 0; in decode_timing()
1803 timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH; in decode_timing()
1805 timing->flags |= DISPLAY_FLAGS_HSYNC_LOW; in decode_timing()
1807 timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH; in decode_timing()
1809 timing->flags |= DISPLAY_FLAGS_VSYNC_LOW; in decode_timing()
1812 timing->flags = DISPLAY_FLAGS_INTERLACED; in decode_timing()
1817 timing->pixelclock.typ, in decode_timing()
1826 * decode_mode() - Decoding an 18-byte detailed timing record
1852 mode->clock = (buf[0] + (buf[1] << 8)) * 10; in decode_mode()
1853 mode->hdisplay = ha; in decode_mode()
1854 mode->hsync_start = ha + hso; in decode_mode()
1855 mode->hsync_end = ha + hso + hspw; in decode_mode()
1856 mode->htotal = ha + hbl; in decode_mode()
1857 mode->vdisplay = va; in decode_mode()
1858 mode->vsync_start = va + vso; in decode_mode()
1859 mode->vsync_end = va + vso + vspw; in decode_mode()
1860 mode->vtotal = va + vbl; in decode_mode()
1862 mode->flags = EDID_DETAILED_TIMING_FLAG_HSYNC_POLARITY(*t) ? in decode_mode()
1864 mode->flags |= EDID_DETAILED_TIMING_FLAG_VSYNC_POLARITY(*t) ? in decode_mode()
1868 mode->flags |= DRM_MODE_FLAG_INTERLACE; in decode_mode()
1873 mode->clock, in decode_mode()
1874 x_mm, y_mm, mode->flags, in decode_mode()
1875 mode->hdisplay, mode->hsync_start, mode->hsync_end, in decode_mode()
1876 mode->htotal, hborder, in decode_mode()
1877 mode->vdisplay, mode->vsync_start, mode->vsync_end, in decode_mode()
1878 mode->vtotal, vborder); in decode_mode()
1882 * edid_vendor - match a string against EDID's obfuscated vendor field
1892 edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@'; in edid_vendor()
1893 edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) | in edid_vendor()
1894 ((edid->mfg_id[1] & 0xe0) >> 5)) + '@'; in edid_vendor()
1895 edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@'; in edid_vendor()
1910 end = info->dtd_offset; in cea_is_hdmi_vsdb_present()
1912 end = sizeof(info->data); in cea_is_hdmi_vsdb_present()
1913 if (end < 4 || end > sizeof(info->data)) in cea_is_hdmi_vsdb_present()
1915 end -= 4; in cea_is_hdmi_vsdb_present()
1921 u8 *db = &info->data[i + 1]; in cea_is_hdmi_vsdb_present()
1938 if (mode->vrefresh > 0) { in drm_get_vrefresh()
1939 refresh = mode->vrefresh; in drm_get_vrefresh()
1940 } else if (mode->htotal > 0 && mode->vtotal > 0) { in drm_get_vrefresh()
1943 vtotal = mode->vtotal; in drm_get_vrefresh()
1945 calc_val = (mode->clock * 1000); in drm_get_vrefresh()
1946 calc_val /= mode->htotal; in drm_get_vrefresh()
1949 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in drm_get_vrefresh()
1951 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) in drm_get_vrefresh()
1953 if (mode->vscan > 1) in drm_get_vrefresh()
1954 refresh /= mode->vscan; in drm_get_vrefresh()
1968 return -EINVAL; in edid_get_drm_mode()
1973 return -ENOENT; in edid_get_drm_mode()
1981 desc = &edid->monitor_details.descriptor[i]; in edid_get_drm_mode()
1982 if (desc->zero_flag_1 != 0) { in edid_get_drm_mode()
1989 return -EINVAL; in edid_get_drm_mode()
1993 return -ENOSYS; in edid_get_drm_mode()
1995 if (edid->version != 1 || edid->revision < 4) { in edid_get_drm_mode()
1997 __func__, edid->version, edid->revision); in edid_get_drm_mode()
1998 *panel_bits_per_colourp = -1; in edid_get_drm_mode()
2001 ((edid->video_input_definition & 0x70) >> 3) + 4; in edid_get_drm_mode()
2016 return -EINVAL; in edid_get_timing()
2021 return -ENOENT; in edid_get_timing()
2029 desc = &edid->monitor_details.descriptor[i]; in edid_get_timing()
2030 if (desc->zero_flag_1 != 0) { in edid_get_timing()
2037 return -EINVAL; in edid_get_timing()
2041 return -ENOSYS; in edid_get_timing()
2043 if (edid->version != 1 || edid->revision < 4) { in edid_get_timing()
2045 __func__, edid->version, edid->revision); in edid_get_timing()
2046 *panel_bits_per_colourp = -1; in edid_get_timing()
2049 ((edid->video_input_definition & 0x70) >> 3) + 4; in edid_get_timing()
2052 timing->hdmi_monitor = false; in edid_get_timing()
2053 if (edid->extension_flag && (buf_size >= EDID_EXT_SIZE)) { in edid_get_timing()
2057 if (info->extension_tag == EDID_CEA861_EXTENSION_TAG) in edid_get_timing()
2058 timing->hdmi_monitor = cea_is_hdmi_vsdb_present(info); in edid_get_timing()
2079 s = &string[strlen(string) - 1]; in snip()
2083 *(s--) = '\0'; in snip()
2102 if (monitor->type == EDID_MONITOR_DESCRIPTOR_SERIAL) in edid_print_dtd()
2104 snip(monitor->data.string)); in edid_print_dtd()
2105 else if (monitor->type == EDID_MONITOR_DESCRIPTOR_ASCII) in edid_print_dtd()
2107 snip(monitor->data.string)); in edid_print_dtd()
2108 else if (monitor->type == EDID_MONITOR_DESCRIPTOR_NAME) in edid_print_dtd()
2110 snip(monitor->data.string)); in edid_print_dtd()
2111 else if (monitor->type == EDID_MONITOR_DESCRIPTOR_RANGE) in edid_print_dtd()
2113 "%d-%d kHz, vertical refresh: " in edid_print_dtd()
2114 "%d-%d Hz, max pixel clock: " in edid_print_dtd()
2116 monitor->data.range_data.horizontal_min, in edid_print_dtd()
2117 monitor->data.range_data.horizontal_max, in edid_print_dtd()
2118 monitor->data.range_data.vertical_min, in edid_print_dtd()
2119 monitor->data.range_data.vertical_max, in edid_print_dtd()
2120 monitor->data.range_data.pixel_clock_max * 10); in edid_print_dtd()
2151 name[0] = EDID1_INFO_MANUFACTURER_NAME_CHAR1(*edid) + 'A' - 1; in edid_get_manufacturer_name()
2152 name[1] = EDID1_INFO_MANUFACTURER_NAME_CHAR2(*edid) + 'A' - 1; in edid_get_manufacturer_name()
2153 name[2] = EDID1_INFO_MANUFACTURER_NAME_CHAR3(*edid) + 'A' - 1; in edid_get_manufacturer_name()
2170 edid_info->version, edid_info->revision); in edid_print_info()
2180 serial_number -= 0x7000000; in edid_print_info()
2182 serial_number -= 456150000; in edid_print_info()
2184 serial_number -= 640000000; in edid_print_info()
2188 edid_info->week, edid_info->year + 1990); in edid_print_info()
2206 EDID1_INFO_FEATURE_RGB(*edid_info) ? "RGB" : "non-RGB"); in edid_print_info()
2209 edid_info->max_size_horizontal, in edid_print_info()
2210 edid_info->max_size_vertical); in edid_print_info()
2256 for (i = 0; i < ARRAY_SIZE(edid_info->standard_timings); i++) { in edid_print_info()
2290 for (i = 0; i < ARRAY_SIZE(edid_info->monitor_details.descriptor); in edid_print_info()
2292 edid_print_dtd(&edid_info->monitor_details.descriptor[i], in edid_print_info()
2301 * drm_cvt_mode -create a modeline based on the CVT algorithm
2329 /* 1) top/bottom margin size (% of height) - default: 1.8, */ in drm_cvt_mode()
2331 /* 2) character cell horizontal granularity (pixels) - default 8 */ in drm_cvt_mode()
2333 /* 3) Minimum vertical porch (lines) - default 3 */ in drm_cvt_mode()
2335 /* 4) Minimum number of vertical back porch lines - default 6 */ in drm_cvt_mode()
2362 hdisplay_rnd = hdisplay - (hdisplay % CVT_H_GRANULARITY); in drm_cvt_mode()
2368 hmargin -= hmargin % CVT_H_GRANULARITY; in drm_cvt_mode()
2371 drm_mode->hdisplay = hdisplay_rnd + 2 * hmargin; in drm_cvt_mode()
2384 drm_mode->vdisplay = vdisplay + 2 * vmargin; in drm_cvt_mode()
2413 /* 3) Nominal HSync width (% of line period) - default 8 */ in drm_cvt_mode()
2419 tmp1 = HV_FACTOR * 1000000 - in drm_cvt_mode()
2432 * vback_porch = vsyncandback_porch - vsync; in drm_cvt_mode()
2434 drm_mode->vtotal = vdisplay_rnd + 2 * vmargin + in drm_cvt_mode()
2437 /* Gradient (%/kHz) - default 600 */ in drm_cvt_mode()
2439 /* Offset (%) - default 40 */ in drm_cvt_mode()
2441 /* Blanking time scaling factor - default 128 */ in drm_cvt_mode()
2443 /* Scaling factor weighting - default 20 */ in drm_cvt_mode()
2446 #define CVT_C_PRIME ((CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \ in drm_cvt_mode()
2449 hblank_percentage = CVT_C_PRIME * HV_FACTOR - CVT_M_PRIME * in drm_cvt_mode()
2454 hblank = drm_mode->hdisplay * hblank_percentage / in drm_cvt_mode()
2455 (100 * HV_FACTOR - hblank_percentage); in drm_cvt_mode()
2456 hblank -= hblank % (2 * CVT_H_GRANULARITY); in drm_cvt_mode()
2458 drm_mode->htotal = drm_mode->hdisplay + hblank; in drm_cvt_mode()
2459 drm_mode->hsync_end = drm_mode->hdisplay + hblank / 2; in drm_cvt_mode()
2460 drm_mode->hsync_start = drm_mode->hsync_end - in drm_cvt_mode()
2461 (drm_mode->htotal * CVT_HSYNC_PERCENTAGE) / 100; in drm_cvt_mode()
2462 drm_mode->hsync_start += CVT_H_GRANULARITY - in drm_cvt_mode()
2463 drm_mode->hsync_start % CVT_H_GRANULARITY; in drm_cvt_mode()
2465 drm_mode->vsync_start = drm_mode->vdisplay + CVT_MIN_V_PORCH; in drm_cvt_mode()
2466 drm_mode->vsync_end = drm_mode->vsync_start + vsync; in drm_cvt_mode()
2469 /* Minimum vertical blanking interval time - default 460 */ in drm_cvt_mode()
2475 /* Fixed number of lines for vertical front porch - default 3*/ in drm_cvt_mode()
2480 tmp1 = HV_FACTOR * 1000000 - in drm_cvt_mode()
2490 drm_mode->vtotal = vdisplay_rnd + 2 * vmargin + vbilines; in drm_cvt_mode()
2492 drm_mode->htotal = drm_mode->hdisplay + CVT_RB_H_BLANK; in drm_cvt_mode()
2494 drm_mode->hsync_end = drm_mode->hdisplay + CVT_RB_H_BLANK / 2; in drm_cvt_mode()
2495 drm_mode->hsync_start = drm_mode->hsync_end - CVT_RB_H_SYNC; in drm_cvt_mode()
2497 drm_mode->vsync_start = drm_mode->vdisplay + CVT_RB_VFPORCH; in drm_cvt_mode()
2498 drm_mode->vsync_end = drm_mode->vsync_start + vsync; in drm_cvt_mode()
2501 drm_mode->clock = drm_mode->htotal * HV_FACTOR * 1000 / hperiod; in drm_cvt_mode()
2502 drm_mode->clock -= drm_mode->clock % CVT_CLOCK_STEP; in drm_cvt_mode()
2504 /* ignore - just set the mode flag for interlaced */ in drm_cvt_mode()
2506 drm_mode->vtotal *= 2; in drm_cvt_mode()
2507 drm_mode->flags |= DRM_MODE_FLAG_INTERLACE; in drm_cvt_mode()
2511 drm_mode->flags |= (DRM_MODE_FLAG_PHSYNC | in drm_cvt_mode()
2514 drm_mode->flags |= (DRM_MODE_FLAG_PVSYNC | in drm_cvt_mode()
2558 return -ERANGE; in cea_db_offsets()
2645 struct drm_display_mode *mode_buf = data->mode_buf; in drm_add_hdmi_modes()
2647 if (data->modes >= MODE_LEN) in drm_add_hdmi_modes()
2649 mode_buf[(data->modes)++] = *mode; in drm_add_hdmi_modes()
2659 /* 0-6 bit vic, 7th bit native mode indicator */ in svd_to_vic()
2686 newmode->vrefresh = 0; in drm_display_mode_from_vic_index()
2695 int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); in bitmap_set()
2698 while (len - bits_to_set >= 0) { in bitmap_set()
2700 len -= bits_to_set; in bitmap_set()
2719 bitmap_set(hdmi->y420_cmdb_modes, vic, 1); in drm_add_cmdb_modes()
2725 struct drm_hdmi_info *hdmi = &data->display_info.hdmi; in do_cea_modes()
2741 if (i < 64 && hdmi->y420_cmdb_map & (1ULL << i)) in do_cea_modes()
2753 * do_y420vdb_modes - Parse YCBCR 420 only modes
2759 * Parse the CEA-861-F YCBCR 420 Video Data Block (Y420VDB)
2767 struct drm_hdmi_info *hdmi = &data->display_info.hdmi; in do_y420vdb_modes()
2775 bitmap_set(hdmi->y420_vdb_modes, vic, 1); in do_y420vdb_modes()
2805 unsigned int interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE; in stereo_match_mandatory()
2807 return mode->hdisplay == stereo_mode->width && in stereo_match_mandatory()
2808 mode->vdisplay == stereo_mode->height && in stereo_match_mandatory()
2809 interlaced == (stereo_mode->flags & DRM_MODE_FLAG_INTERLACE) && in stereo_match_mandatory()
2810 drm_get_vrefresh(mode) == stereo_mode->vrefresh; in stereo_match_mandatory()
2816 int num = data->modes, modes = 0, i, k; in add_hdmi_mandatory_stereo_modes()
2819 mode = &data->mode_buf[k]; in add_hdmi_mandatory_stereo_modes()
2834 new_mode->flags |= mandatory->flags; in add_hdmi_mandatory_stereo_modes()
2855 newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING; in add_3d_struct_modes()
2866 newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM; in add_3d_struct_modes()
2877 newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; in add_3d_struct_modes()
2900 * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block
2966 if (len < (8 + offset + hdmi_3d_len - 1)) in do_hdmi_vsdb_modes()
2993 for (i = 0; i < (hdmi_3d_len - multi_len); i++) { in do_hdmi_vsdb_modes()
3001 if (detail_present && (i + 1 == hdmi_3d_len - multi_len)) in do_hdmi_vsdb_modes()
3029 newmode->flags |= newflag; in do_hdmi_vsdb_modes()
3045 * edid_get_quirks - return quirk flags for a given EDID
3058 if (edid_vendor(edid, quirk->vendor) && in edid_get_quirks()
3059 (EDID_PRODUCT_ID(edid) == quirk->product_id)) in edid_get_quirks()
3060 return quirk->quirks; in edid_get_quirks()
3069 struct drm_display_info *info = &data->display_info; in drm_parse_y420cmdb_bitmap()
3070 struct drm_hdmi_info *hdmi = &info->hdmi; in drm_parse_y420cmdb_bitmap()
3071 u8 map_len = cea_db_payload_len(db) - 1; in drm_parse_y420cmdb_bitmap()
3077 hdmi->y420_cmdb_map = U64_MAX; in drm_parse_y420cmdb_bitmap()
3078 info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; in drm_parse_y420cmdb_bitmap()
3101 info->color_formats |= DRM_COLOR_FORMAT_YCRCB420; in drm_parse_y420cmdb_bitmap()
3103 hdmi->y420_cmdb_map = map; in drm_parse_y420cmdb_bitmap()
3145 struct drm_hdmi_info *hdmi = &data->display_info.hdmi; in drm_parse_ycbcr420_deep_color_info()
3148 hdmi->y420_dc_modes |= dc_mask; in drm_parse_ycbcr420_deep_color_info()
3154 struct drm_display_info *display = &data->display_info; in drm_parse_hdmi_forum_vsdb()
3155 struct drm_hdmi_info *hdmi = &display->hdmi; in drm_parse_hdmi_forum_vsdb()
3158 hdmi->scdc.supported = true; in drm_parse_hdmi_forum_vsdb()
3160 hdmi->scdc.read_request = true; in drm_parse_hdmi_forum_vsdb()
3166 * * Availability of a HF-VSDB block in EDID (check) in drm_parse_hdmi_forum_vsdb()
3167 * * Non zero Max_TMDS_Char_Rate filed in HF-VSDB (let's check) in drm_parse_hdmi_forum_vsdb()
3175 struct drm_scdc *scdc = &hdmi->scdc; in drm_parse_hdmi_forum_vsdb()
3178 display->max_tmds_clock = max_tmds_clock; in drm_parse_hdmi_forum_vsdb()
3179 debug("HF-VSDB: max TMDS clock %d kHz\n", in drm_parse_hdmi_forum_vsdb()
3180 display->max_tmds_clock); in drm_parse_hdmi_forum_vsdb()
3183 if (scdc->supported) { in drm_parse_hdmi_forum_vsdb()
3184 scdc->scrambling.supported = true; in drm_parse_hdmi_forum_vsdb()
3188 scdc->scrambling.low_rates = true; in drm_parse_hdmi_forum_vsdb()
3196 struct drm_hdmi_dsc_cap *hdmi_dsc = &hdmi->dsc_cap; in drm_parse_hdmi_forum_vsdb()
3200 drm_get_max_frl_rate(max_frl_rate, &hdmi->max_lanes, in drm_parse_hdmi_forum_vsdb()
3201 &hdmi->max_frl_rate_per_lane); in drm_parse_hdmi_forum_vsdb()
3202 hdmi->add_func = hf_vsdb[8]; in drm_parse_hdmi_forum_vsdb()
3203 hdmi_dsc->v_1p2 = hf_vsdb[11] & DRM_EDID_DSC_1P2; in drm_parse_hdmi_forum_vsdb()
3205 if (hdmi_dsc->v_1p2) { in drm_parse_hdmi_forum_vsdb()
3206 hdmi_dsc->native_420 = hf_vsdb[11] & DRM_EDID_DSC_NATIVE_420; in drm_parse_hdmi_forum_vsdb()
3207 hdmi_dsc->all_bpp = hf_vsdb[11] & DRM_EDID_DSC_ALL_BPP; in drm_parse_hdmi_forum_vsdb()
3210 hdmi_dsc->bpc_supported = 16; in drm_parse_hdmi_forum_vsdb()
3212 hdmi_dsc->bpc_supported = 12; in drm_parse_hdmi_forum_vsdb()
3214 hdmi_dsc->bpc_supported = 10; in drm_parse_hdmi_forum_vsdb()
3216 hdmi_dsc->bpc_supported = 0; in drm_parse_hdmi_forum_vsdb()
3219 drm_get_max_frl_rate(dsc_max_frl_rate, &hdmi_dsc->max_lanes, in drm_parse_hdmi_forum_vsdb()
3220 &hdmi_dsc->max_frl_rate_per_lane); in drm_parse_hdmi_forum_vsdb()
3221 hdmi_dsc->total_chunk_kbytes = in drm_parse_hdmi_forum_vsdb()
3227 hdmi_dsc->max_slices = 1; in drm_parse_hdmi_forum_vsdb()
3228 hdmi_dsc->clk_per_slice = 340; in drm_parse_hdmi_forum_vsdb()
3231 hdmi_dsc->max_slices = 2; in drm_parse_hdmi_forum_vsdb()
3232 hdmi_dsc->clk_per_slice = 340; in drm_parse_hdmi_forum_vsdb()
3235 hdmi_dsc->max_slices = 4; in drm_parse_hdmi_forum_vsdb()
3236 hdmi_dsc->clk_per_slice = 340; in drm_parse_hdmi_forum_vsdb()
3239 hdmi_dsc->max_slices = 8; in drm_parse_hdmi_forum_vsdb()
3240 hdmi_dsc->clk_per_slice = 340; in drm_parse_hdmi_forum_vsdb()
3243 hdmi_dsc->max_slices = 8; in drm_parse_hdmi_forum_vsdb()
3244 hdmi_dsc->clk_per_slice = 400; in drm_parse_hdmi_forum_vsdb()
3247 hdmi_dsc->max_slices = 12; in drm_parse_hdmi_forum_vsdb()
3248 hdmi_dsc->clk_per_slice = 400; in drm_parse_hdmi_forum_vsdb()
3251 hdmi_dsc->max_slices = 16; in drm_parse_hdmi_forum_vsdb()
3252 hdmi_dsc->clk_per_slice = 400; in drm_parse_hdmi_forum_vsdb()
3256 hdmi_dsc->max_slices = 0; in drm_parse_hdmi_forum_vsdb()
3257 hdmi_dsc->clk_per_slice = 0; in drm_parse_hdmi_forum_vsdb()
3266 * drm_default_rgb_quant_range - default RGB quantization range
3270 * as specified in CEA-861.
3286 struct drm_display_info *info = &data->display_info; in drm_parse_hdmi_deep_color_info()
3290 info->bpc = 8; in drm_parse_hdmi_deep_color_info()
3297 info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_30; in drm_parse_hdmi_deep_color_info()
3303 info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_36; in drm_parse_hdmi_deep_color_info()
3309 info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_48; in drm_parse_hdmi_deep_color_info()
3319 info->bpc = dc_bpc; in drm_parse_hdmi_deep_color_info()
3323 info->edid_hdmi_dc_modes |= DRM_EDID_HDMI_DC_Y444; in drm_parse_hdmi_deep_color_info()
3344 if (!edid || !edid->extensions) in drm_find_edid_extension()
3348 for (i = 0; i < edid->extensions; i++) { in drm_find_edid_extension()
3354 if (i == edid->extensions) in drm_find_edid_extension()
3372 * drm_detect_hdmi_monitor - detect whether monitor is HDMI
3375 * Parse the CEA extension according to CEA-861-B.
3405 * drm_detect_monitor_audio - check monitor audio capability
3454 struct drm_display_info *info = &data->display_info; in drm_parse_hdmi_vsdb_video()
3458 info->dvi_dual = db[6] & 1; in drm_parse_hdmi_vsdb_video()
3460 info->max_tmds_clock = db[7] * 5000; in drm_parse_hdmi_vsdb_video()
3468 struct drm_display_info *info = &data->display_info; in drm_parse_cea_ext()
3476 info->cea_rev = edid_ext[1]; in drm_parse_cea_ext()
3479 info->color_formats = DRM_COLOR_FORMAT_RGB444; in drm_parse_cea_ext()
3481 info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; in drm_parse_cea_ext()
3483 info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; in drm_parse_cea_ext()
3502 struct drm_display_info *info = &data->display_info; in drm_add_display_info()
3504 info->width_mm = edid->width_cm * 10; in drm_add_display_info()
3505 info->height_mm = edid->height_cm * 10; in drm_add_display_info()
3508 info->bpc = 0; in drm_add_display_info()
3509 info->color_formats = 0; in drm_add_display_info()
3510 info->cea_rev = 0; in drm_add_display_info()
3511 info->max_tmds_clock = 0; in drm_add_display_info()
3512 info->dvi_dual = false; in drm_add_display_info()
3513 info->edid_hdmi_dc_modes = 0; in drm_add_display_info()
3515 memset(&info->hdmi, 0, sizeof(info->hdmi)); in drm_add_display_info()
3517 if (edid->revision < 3) in drm_add_display_info()
3520 if (!(edid->input & DRM_EDID_INPUT_DIGITAL)) in drm_add_display_info()
3532 if ((info->bpc == 0) && (edid->revision < 4) && in drm_add_display_info()
3533 (edid->input & DRM_EDID_DIGITAL_TYPE_DVI)) { in drm_add_display_info()
3534 info->bpc = 8; in drm_add_display_info()
3535 debug("Assigning DFP sink color depth as %d bpc.\n", info->bpc); in drm_add_display_info()
3539 if (edid->revision < 4) in drm_add_display_info()
3542 switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) { in drm_add_display_info()
3544 info->bpc = 6; in drm_add_display_info()
3547 info->bpc = 8; in drm_add_display_info()
3550 info->bpc = 10; in drm_add_display_info()
3553 info->bpc = 12; in drm_add_display_info()
3556 info->bpc = 14; in drm_add_display_info()
3559 info->bpc = 16; in drm_add_display_info()
3563 info->bpc = 0; in drm_add_display_info()
3567 debug("Assigning EDID-1.4 digital sink color depth as %d bpc.\n", in drm_add_display_info()
3568 info->bpc); in drm_add_display_info()
3570 info->color_formats |= DRM_COLOR_FORMAT_RGB444; in drm_add_display_info()
3571 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444) in drm_add_display_info()
3572 info->color_formats |= DRM_COLOR_FORMAT_YCRCB444; in drm_add_display_info()
3573 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422) in drm_add_display_info()
3574 info->color_formats |= DRM_COLOR_FORMAT_YCRCB422; in drm_add_display_info()
3607 dbl - 1); in add_cea_modes()
3635 n = (127 - d) / 18; in cea_for_each_detailed_block()
3663 cb(&edid->detailed_timings[i], closure); in drm_for_each_detailed_block()
3707 if (!(pt->misc & DRM_EDID_PT_INTERLACED)) in drm_mode_do_interlace_quirk()
3711 if ((mode->hdisplay == cea_interlaced[i].w) && in drm_mode_do_interlace_quirk()
3712 (mode->vdisplay == cea_interlaced[i].h / 2)) { in drm_mode_do_interlace_quirk()
3713 mode->vdisplay *= 2; in drm_mode_do_interlace_quirk()
3714 mode->vsync_start *= 2; in drm_mode_do_interlace_quirk()
3715 mode->vsync_end *= 2; in drm_mode_do_interlace_quirk()
3716 mode->vtotal *= 2; in drm_mode_do_interlace_quirk()
3717 mode->vtotal |= 1; in drm_mode_do_interlace_quirk()
3721 mode->flags |= DRM_MODE_FLAG_INTERLACE; in drm_mode_do_interlace_quirk()
3725 * drm_mode_detailed - create a new mode from an EDID detailed timing section
3739 struct detailed_pixel_timing *pt = &timing->data.pixel_data; in drm_mode_detailed()
3740 unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo; in drm_mode_detailed()
3741 unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo; in drm_mode_detailed()
3742 unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo; in drm_mode_detailed()
3743 unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo; in drm_mode_detailed()
3745 (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | in drm_mode_detailed()
3746 pt->hsync_offset_lo; in drm_mode_detailed()
3748 (pt->hsync_vsync_offset_pulse_width_hi & 0x30) << 4 | in drm_mode_detailed()
3749 pt->hsync_pulse_width_lo; in drm_mode_detailed()
3750 unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) << in drm_mode_detailed()
3751 2 | pt->vsync_offset_pulse_width_lo >> 4; in drm_mode_detailed()
3753 (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 4 | in drm_mode_detailed()
3754 (pt->vsync_offset_pulse_width_lo & 0xf); in drm_mode_detailed()
3760 if (pt->misc & DRM_EDID_PT_STEREO) { in drm_mode_detailed()
3764 if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) in drm_mode_detailed()
3787 timing->pixel_clock = cpu_to_le16(1088); in drm_mode_detailed()
3789 mode->clock = le16_to_cpu(timing->pixel_clock) * 10; in drm_mode_detailed()
3791 mode->hdisplay = hactive; in drm_mode_detailed()
3792 mode->hsync_start = mode->hdisplay + hsync_offset; in drm_mode_detailed()
3793 mode->hsync_end = mode->hsync_start + hsync_pulse_width; in drm_mode_detailed()
3794 mode->htotal = mode->hdisplay + hblank; in drm_mode_detailed()
3796 mode->vdisplay = vactive; in drm_mode_detailed()
3797 mode->vsync_start = mode->vdisplay + vsync_offset; in drm_mode_detailed()
3798 mode->vsync_end = mode->vsync_start + vsync_pulse_width; in drm_mode_detailed()
3799 mode->vtotal = mode->vdisplay + vblank; in drm_mode_detailed()
3802 if (mode->hsync_end > mode->htotal) in drm_mode_detailed()
3803 mode->htotal = mode->hsync_end + 1; in drm_mode_detailed()
3804 if (mode->vsync_end > mode->vtotal) in drm_mode_detailed()
3805 mode->vtotal = mode->vsync_end + 1; in drm_mode_detailed()
3810 pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | in drm_mode_detailed()
3813 mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ? in drm_mode_detailed()
3815 mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ? in drm_mode_detailed()
3820 mode->type = DRM_MODE_TYPE_DRIVER; in drm_mode_detailed()
3821 mode->vrefresh = drm_get_vrefresh(mode); in drm_mode_detailed()
3833 unsigned int clock = cea_mode->clock; in cea_mode_alternate_clock()
3835 if (cea_mode->vrefresh % 6 != 0) in cea_mode_alternate_clock()
3843 if (cea_mode->vdisplay == 240 || cea_mode->vdisplay == 480) in cea_mode_alternate_clock()
3852 * drm_mode_equal_no_clocks_no_stereo - test modes for equality
3870 if (mode1->hdisplay == mode2->hdisplay && in drm_mode_equal_no_clocks_no_stereo()
3871 mode1->hsync_start == mode2->hsync_start && in drm_mode_equal_no_clocks_no_stereo()
3872 mode1->hsync_end == mode2->hsync_end && in drm_mode_equal_no_clocks_no_stereo()
3873 mode1->htotal == mode2->htotal && in drm_mode_equal_no_clocks_no_stereo()
3874 mode1->vdisplay == mode2->vdisplay && in drm_mode_equal_no_clocks_no_stereo()
3875 mode1->vsync_start == mode2->vsync_start && in drm_mode_equal_no_clocks_no_stereo()
3876 mode1->vsync_end == mode2->vsync_end && in drm_mode_equal_no_clocks_no_stereo()
3877 mode1->vtotal == mode2->vtotal && in drm_mode_equal_no_clocks_no_stereo()
3878 mode1->vscan == mode2->vscan && in drm_mode_equal_no_clocks_no_stereo()
3879 (mode1->flags & flags_mask) == (mode2->flags & flags_mask)) in drm_mode_equal_no_clocks_no_stereo()
3886 * drm_mode_equal_no_clocks - test modes for equality
3899 if ((mode1->flags & DRM_MODE_FLAG_3D_MASK) != in drm_mode_equal_no_clocks()
3900 (mode2->flags & DRM_MODE_FLAG_3D_MASK)) in drm_mode_equal_no_clocks()
3912 if (!to_match->clock) in drm_match_cea_mode_clock_tolerance()
3920 clock1 = cea_mode->clock; in drm_match_cea_mode_clock_tolerance()
3923 if (abs(to_match->clock - clock1) > clock_tolerance && in drm_match_cea_mode_clock_tolerance()
3924 abs(to_match->clock - clock2) > clock_tolerance) in drm_match_cea_mode_clock_tolerance()
3937 if (hdmi_mode->vdisplay == 4096 && hdmi_mode->hdisplay == 2160) in hdmi_mode_alternate_clock()
3938 return hdmi_mode->clock; in hdmi_mode_alternate_clock()
3949 if (!to_match->clock) in drm_match_hdmi_mode_clock_tolerance()
3957 clock1 = hdmi_mode->clock; in drm_match_hdmi_mode_clock_tolerance()
3960 if (abs(to_match->clock - clock1) > clock_tolerance && in drm_match_hdmi_mode_clock_tolerance()
3961 abs(to_match->clock - clock2) > clock_tolerance) in drm_match_hdmi_mode_clock_tolerance()
3986 clock1 = cea_mode->clock; in fixup_detailed_cea_mode_clock()
3993 clock1 = cea_mode->clock; in fixup_detailed_cea_mode_clock()
4001 if (abs(mode->clock - clock1) < abs(mode->clock - clock2)) in fixup_detailed_cea_mode_clock()
4006 if (mode->clock == clock) in fixup_detailed_cea_mode_clock()
4009 debug("detailed mode matches %s VIC %d, adjusting clock %d -> %d\n", in fixup_detailed_cea_mode_clock()
4010 type, vic, mode->clock, clock); in fixup_detailed_cea_mode_clock()
4011 mode->clock = clock; in fixup_detailed_cea_mode_clock()
4020 if (timing->pixel_clock) { in do_detailed_mode()
4022 closure->edid, timing, in do_detailed_mode()
4023 closure->quirks); in do_detailed_mode()
4027 if (closure->preferred) in do_detailed_mode()
4028 newmode->type |= DRM_MODE_TYPE_PREFERRED; in do_detailed_mode()
4036 drm_add_hdmi_modes(closure->data, newmode); in do_detailed_mode()
4038 closure->modes++; in do_detailed_mode()
4039 closure->preferred = 0; in do_detailed_mode()
4044 * add_detailed_modes - Add modes from detailed timings
4062 (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING); in add_detailed_modes()
4081 cvt = &timing->data.other_data.data.cvt[i]; in drm_cvt_modes()
4083 if (!memcmp(cvt->code, empty, 3)) in drm_cvt_modes()
4086 height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2; in drm_cvt_modes()
4087 switch (cvt->code[1] & 0x0c) { in drm_cvt_modes()
4103 if (cvt->code[2] & (1 << j)) { in drm_cvt_modes()
4123 struct detailed_non_pixel *data = &timing->data.other_data; in do_cvt_mode()
4125 if (data->type == EDID_DETAIL_CVT_3BYTE) in do_cvt_mode()
4126 closure->modes += drm_cvt_modes(closure->data, timing); in do_cvt_mode()
4201 * standard_timing_level - get std. timing level(CVT/GTF/DMT)
4206 if (edid->revision >= 2) { in standard_timing_level()
4207 if (edid->revision >= 4 && in standard_timing_level()
4208 (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)) in standard_timing_level()
4243 if (edid->revision >= 4) { in drm_monitor_supports_rb()
4250 return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0); in drm_monitor_supports_rb()
4256 return (mode->htotal - mode->hdisplay == 160) && in mode_is_rb()
4257 (mode->hsync_end - mode->hdisplay == 80) && in mode_is_rb()
4258 (mode->hsync_end - mode->hsync_start == 32) && in mode_is_rb()
4259 (mode->vsync_start - mode->vdisplay == 3); in mode_is_rb()
4263 * drm_mode_find_dmt - Create a copy of a mode if present in DMT
4267 * @rb: Mode reduced-blanking-ness
4283 if (hsize != ptr->hdisplay) in drm_mode_find_dmt()
4285 if (vsize != ptr->vdisplay) in drm_mode_find_dmt()
4304 { /* 1) top/bottom margin size (% of height) - default: 1.8, */ in drm_gtf_mode_complex()
4306 /* 2) character cell horizontal granularity (pixels) - default 8 */ in drm_gtf_mode_complex()
4308 /* 3) Minimum vertical porch (lines) - default 3 */ in drm_gtf_mode_complex()
4317 #define GTF_C_PRIME ((((GTF_2C - GTF_2J) * GTF_K / 256) + GTF_2J) / 2) in drm_gtf_mode_complex()
4375 tmp1 = (1000000 - MIN_VSYNC_PLUS_BP * vfieldrate_rqd) / 500; in drm_gtf_mode_complex()
4386 * vback_porch = vsync_plus_bp - V_SYNC_RQD; in drm_gtf_mode_complex()
4419 ideal_duty_cycle = GTF_C_PRIME * 1000 - in drm_gtf_mode_complex()
4425 (100000 - ideal_duty_cycle); in drm_gtf_mode_complex()
4443 hfront_porch = hblank / 2 - hsync; in drm_gtf_mode_complex()
4448 drm_mode->hdisplay = hdisplay_rnd; in drm_gtf_mode_complex()
4449 drm_mode->hsync_start = hdisplay_rnd + hfront_porch; in drm_gtf_mode_complex()
4450 drm_mode->hsync_end = drm_mode->hsync_start + hsync; in drm_gtf_mode_complex()
4451 drm_mode->htotal = total_pixels; in drm_gtf_mode_complex()
4452 drm_mode->vdisplay = vdisplay_rnd; in drm_gtf_mode_complex()
4453 drm_mode->vsync_start = vdisplay_rnd + vodd_front_porch_lines; in drm_gtf_mode_complex()
4454 drm_mode->vsync_end = drm_mode->vsync_start + V_SYNC_RQD; in drm_gtf_mode_complex()
4455 drm_mode->vtotal = vtotal_lines; in drm_gtf_mode_complex()
4457 drm_mode->clock = pixel_freq; in drm_gtf_mode_complex()
4460 drm_mode->vtotal *= 2; in drm_gtf_mode_complex()
4461 drm_mode->flags |= DRM_MODE_FLAG_INTERLACE; in drm_gtf_mode_complex()
4465 drm_mode->flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC; in drm_gtf_mode_complex()
4467 drm_mode->flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC; in drm_gtf_mode_complex()
4473 * drm_gtf_mode - create the mode based on the GTF algorithm
4512 /** drm_mode_hsync - get the hsync of a mode
4523 if (mode->htotal < 0) in drm_mode_hsync()
4526 calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */ in drm_mode_hsync()
4534 * drm_mode_std - convert standard mode info (width, height, refresh) into mode
4549 int num = data->modes; in drm_mode_std()
4550 unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK) in drm_mode_std()
4552 unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK) in drm_mode_std()
4556 if (bad_std_timing(t->hsize, t->vfreq_aspect)) in drm_mode_std()
4560 hsize = t->hsize * 8 + 248; in drm_mode_std()
4565 if (edid->revision < 3) in drm_mode_std()
4592 if (data->mode_buf[i].hdisplay == hsize && in drm_mode_std()
4593 data->mode_buf[i].vdisplay == vsize && in drm_mode_std()
4594 drm_get_vrefresh(&data->mode_buf[i]) == vrefresh_rate) in drm_mode_std()
4601 mode->hdisplay = 1366; in drm_mode_std()
4602 mode->hsync_start = mode->hsync_start - 1; in drm_mode_std()
4603 mode->hsync_end = mode->hsync_end - 1; in drm_mode_std()
4658 struct detailed_non_pixel *data = &timing->data.other_data; in do_standard_modes()
4659 struct edid *edid = closure->edid; in do_standard_modes()
4661 if (data->type == EDID_DETAIL_STD_MODES) { in do_standard_modes()
4668 std = &data->data.timings[i]; in do_standard_modes()
4669 newmode = drm_mode_std(closure->data, edid, std); in do_standard_modes()
4671 drm_add_hdmi_modes(closure->data, newmode); in do_standard_modes()
4672 closure->modes++; in do_standard_modes()
4680 * add_standard_modes - get std. modes from EDID and add them
4700 &edid->standard_timings[i]); in add_standard_modes()
4725 for (j = 7; j >= 0; j--) { in drm_est3_modes()
4726 m = (i * 8) + (7 - j); in drm_est3_modes()
4751 struct detailed_non_pixel *data = &timing->data.other_data; in do_established_modes()
4753 if (data->type == EDID_DETAIL_EST_TIMINGS) in do_established_modes()
4754 closure->modes += drm_est3_modes(closure->data, timing); in do_established_modes()
4758 * add_established_modes - get est. modes from EDID and add them
4768 unsigned long est_bits = edid->established_timings.t1 | in add_established_modes()
4769 (edid->established_timings.t2 << 8) | in add_established_modes()
4770 ((edid->established_timings.mfg_rsvd & 0x80) << 9); in add_established_modes()
4800 if (!to_match->clock) in drm_match_hdmi_mode()
4808 clock1 = hdmi_mode->clock; in drm_match_hdmi_mode()
4811 if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || in drm_match_hdmi_mode()
4812 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && in drm_match_hdmi_mode()
4833 num = data->modes; in add_alternate_cea_modes()
4841 mode = &data->mode_buf[i]; in add_alternate_cea_modes()
4858 clock1 = cea_mode->clock; in add_alternate_cea_modes()
4863 if (mode->clock != clock1 && mode->clock != clock2) in add_alternate_cea_modes()
4872 newmode->flags |= mode->flags & DRM_MODE_FLAG_3D_MASK; in add_alternate_cea_modes()
4878 if (mode->clock != clock1) in add_alternate_cea_modes()
4879 newmode->clock = clock1; in add_alternate_cea_modes()
4881 newmode->clock = clock2; in add_alternate_cea_modes()
4905 base->rev, base->bytes, base->prod_id, base->ext_count); in validate_displayid()
4907 if (base->bytes + 5 > length - idx) in validate_displayid()
4908 return -EINVAL; in validate_displayid()
4909 for (i = idx; i <= base->bytes + 5; i++) in validate_displayid()
4913 return -EINVAL; in validate_displayid()
4923 unsigned pixel_clock = (timings->pixel_clock[0] | in drm_displayid_detailed()
4924 (timings->pixel_clock[1] << 8) | in drm_displayid_detailed()
4925 (timings->pixel_clock[2] << 16)); in drm_displayid_detailed()
4926 unsigned hactive = (timings->hactive[0] | timings->hactive[1] << 8) + 1; in drm_displayid_detailed()
4927 unsigned hblank = (timings->hblank[0] | timings->hblank[1] << 8) + 1; in drm_displayid_detailed()
4928 unsigned hsync = (timings->hsync[0] | in drm_displayid_detailed()
4929 (timings->hsync[1] & 0x7f) << 8) + 1; in drm_displayid_detailed()
4930 unsigned hsync_width = (timings->hsw[0] | timings->hsw[1] << 8) + 1; in drm_displayid_detailed()
4931 unsigned vactive = (timings->vactive[0] | in drm_displayid_detailed()
4932 timings->vactive[1] << 8) + 1; in drm_displayid_detailed()
4933 unsigned vblank = (timings->vblank[0] | timings->vblank[1] << 8) + 1; in drm_displayid_detailed()
4934 unsigned vsync = (timings->vsync[0] | in drm_displayid_detailed()
4935 (timings->vsync[1] & 0x7f) << 8) + 1; in drm_displayid_detailed()
4936 unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1; in drm_displayid_detailed()
4937 bool hsync_positive = (timings->hsync[1] >> 7) & 0x1; in drm_displayid_detailed()
4938 bool vsync_positive = (timings->vsync[1] >> 7) & 0x1; in drm_displayid_detailed()
4944 mode->clock = pixel_clock * 10; in drm_displayid_detailed()
4945 mode->hdisplay = hactive; in drm_displayid_detailed()
4946 mode->hsync_start = mode->hdisplay + hsync; in drm_displayid_detailed()
4947 mode->hsync_end = mode->hsync_start + hsync_width; in drm_displayid_detailed()
4948 mode->htotal = mode->hdisplay + hblank; in drm_displayid_detailed()
4950 mode->vdisplay = vactive; in drm_displayid_detailed()
4951 mode->vsync_start = mode->vdisplay + vsync; in drm_displayid_detailed()
4952 mode->vsync_end = mode->vsync_start + vsync_width; in drm_displayid_detailed()
4953 mode->vtotal = mode->vdisplay + vblank; in drm_displayid_detailed()
4955 mode->flags = 0; in drm_displayid_detailed()
4956 mode->flags |= in drm_displayid_detailed()
4958 mode->flags |= in drm_displayid_detailed()
4960 mode->type = DRM_MODE_TYPE_DRIVER; in drm_displayid_detailed()
4962 if (timings->flags & 0x80) in drm_displayid_detailed()
4963 mode->type |= DRM_MODE_TYPE_PREFERRED; in drm_displayid_detailed()
4964 mode->vrefresh = drm_get_vrefresh(mode); in drm_displayid_detailed()
4980 if (block->num_bytes % 20) in add_displayid_detailed_1_modes()
4983 num_timings = block->num_bytes / 20; in add_displayid_detailed_1_modes()
4986 &det->timings[i]; in add_displayid_detailed_1_modes()
5020 idx + sizeof(struct displayid_block) + block->num_bytes <= in add_displayid_detailed_modes()
5021 length && block->num_bytes > 0) { in add_displayid_detailed_modes()
5022 idx += block->num_bytes + sizeof(struct displayid_block); in add_displayid_detailed_modes()
5023 switch (block->tag) { in add_displayid_detailed_modes()
5040 if (edid->revision >= 4) in mode_in_hsync_range()
5043 if (edid->revision >= 4) in mode_in_hsync_range()
5057 if (edid->revision >= 4) in mode_in_vsync_range()
5060 if (edid->revision >= 4) in mode_in_vsync_range()
5075 if (edid->revision >= 4 && t[10] == 0x04) in range_pixel_clock()
5076 return (t[9] * 10000) - ((t[12] >> 2) * 250); in range_pixel_clock()
5078 /* 1.3 is pathetic, so fuzz up a bit */ in range_pixel_clock()
5097 if (mode->clock > max_clock) in mode_in_range()
5101 if (edid->revision >= 4 && t[10] == 0x04) in mode_in_range()
5102 if (t[13] && mode->hdisplay > 8 * in mode_in_range()
5119 for (i = 0; i < data->modes; i++) { in valid_inferred_mode()
5120 m = &data->mode_buf[i]; in valid_inferred_mode()
5121 if (mode->hdisplay == m->hdisplay && in valid_inferred_mode()
5122 mode->vdisplay == m->vdisplay && in valid_inferred_mode()
5125 if (mode->hdisplay <= m->hdisplay && in valid_inferred_mode()
5126 mode->vdisplay <= m->vdisplay) in valid_inferred_mode()
5154 if (mode->hdisplay == 1368 && mode->vdisplay == 768) { in fixup_mode_1366x768()
5155 mode->hdisplay = 1366; in fixup_mode_1366x768()
5156 mode->hsync_start--; in fixup_mode_1366x768()
5157 mode->hsync_end--; in fixup_mode_1366x768()
5171 newmode = drm_gtf_mode(m->w, m->h, m->r, 0, 0); in drm_gtf_modes_for_range()
5201 newmode = drm_cvt_mode(m->w, m->h, m->r, rb, 0, 0); in drm_cvt_modes_for_range()
5224 struct detailed_non_pixel *data = &timing->data.other_data; in do_inferred_modes()
5225 struct detailed_data_monitor_range *range = &data->data.range; in do_inferred_modes()
5227 if (data->type != EDID_DETAIL_MONITOR_RANGE) in do_inferred_modes()
5230 closure->modes += drm_dmt_modes_for_range(closure->data, in do_inferred_modes()
5231 closure->edid, in do_inferred_modes()
5234 if (!version_greater(closure->edid, 1, 1)) in do_inferred_modes()
5237 switch (range->flags) { in do_inferred_modes()
5240 closure->modes += drm_gtf_modes_for_range(closure->data, in do_inferred_modes()
5241 closure->edid, in do_inferred_modes()
5245 if (!version_greater(closure->edid, 1, 3)) in do_inferred_modes()
5248 closure->modes += drm_cvt_modes_for_range(closure->data, in do_inferred_modes()
5249 closure->edid, in do_inferred_modes()
5273 #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay)
5274 #define MODE_REFRESH_DIFF(c, t) (abs((c) - (t)))
5277 * edid_fixup_preferred - set preferred modes based on quirk list
5289 int num = data->modes; in edid_fixup_preferred()
5295 preferred_mode = data->preferred_mode; in edid_fixup_preferred()
5303 cur_mode = &data->mode_buf[i]; in edid_fixup_preferred()
5304 cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED; in edid_fixup_preferred()
5313 cur_vrefresh = cur_mode->vrefresh ? in edid_fixup_preferred()
5314 cur_mode->vrefresh : drm_get_vrefresh(cur_mode); in edid_fixup_preferred()
5315 preferred_vrefresh = preferred_mode->vrefresh ? in edid_fixup_preferred()
5316 preferred_mode->vrefresh : drm_get_vrefresh(preferred_mode); in edid_fixup_preferred()
5324 preferred_mode->type |= DRM_MODE_TYPE_PREFERRED; in edid_fixup_preferred()
5325 data->preferred_mode = preferred_mode; in edid_fixup_preferred()
5333 * drm_edid_header_is_valid - sanity check the header of the base EDID block
5371 * drm_edid_block_valid - Sanity check the EDID block (base or extension)
5402 * fix-up code here will correct the problem, the in drm_edid_block_valid()
5431 /* per-block-type checks */ in drm_edid_block_valid()
5434 if (edid->version != 1) { in drm_edid_block_valid()
5436 edid->version); in drm_edid_block_valid()
5440 if (edid->revision > 4) in drm_edid_block_valid()
5464 * drm_edid_is_valid - sanity check EDID data
5467 * Sanity-check an entire EDID record (including extensions)
5479 for (i = 0; i <= edid->extensions; i++) in drm_edid_is_valid()
5487 * drm_add_edid_modes - add modes from EDID data, if available
5511 if (!data->mode_buf) { in drm_add_edid_modes()
5518 * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks. in drm_add_edid_modes()
5526 * - preferred detailed mode in drm_add_edid_modes()
5527 * - other detailed modes from base block in drm_add_edid_modes()
5528 * - detailed modes from extension blocks in drm_add_edid_modes()
5529 * - CVT 3-byte code modes in drm_add_edid_modes()
5530 * - standard timing codes in drm_add_edid_modes()
5531 * - established timing codes in drm_add_edid_modes()
5532 * - modes inferred from GTF or CVT range information in drm_add_edid_modes()
5546 if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) in drm_add_edid_modes()
5550 data->preferred_mode = &data->mode_buf[0]; in drm_add_edid_modes()
5556 data->display_info.bpc = 6; in drm_add_edid_modes()
5559 data->display_info.bpc = 8; in drm_add_edid_modes()
5562 data->display_info.bpc = 10; in drm_add_edid_modes()
5565 data->display_info.bpc = 12; in drm_add_edid_modes()
5574 if (!to_match->clock) { in drm_match_cea_mode()
5584 clock1 = cea_mode->clock; in drm_match_cea_mode()
5586 if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) || in drm_match_cea_mode()
5587 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) && in drm_match_cea_mode()
5600 return mode->picture_aspect_ratio; in drm_get_cea_aspect_ratio()
5613 return -EINVAL; in drm_hdmi_avi_infoframe_from_display_mode()
5619 if (mode->flags & DRM_MODE_FLAG_DBLCLK) in drm_hdmi_avi_infoframe_from_display_mode()
5620 frame->pixel_repeat = 1; in drm_hdmi_avi_infoframe_from_display_mode()
5622 frame->video_code = drm_match_cea_mode(mode); in drm_hdmi_avi_infoframe_from_display_mode()
5625 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but in drm_hdmi_avi_infoframe_from_display_mode()
5626 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we in drm_hdmi_avi_infoframe_from_display_mode()
5629 if (!is_hdmi2_sink && frame->video_code > 64) in drm_hdmi_avi_infoframe_from_display_mode()
5630 frame->video_code = 0; in drm_hdmi_avi_infoframe_from_display_mode()
5638 if (frame->video_code) { in drm_hdmi_avi_infoframe_from_display_mode()
5640 bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK; in drm_hdmi_avi_infoframe_from_display_mode()
5643 frame->video_code = 0; in drm_hdmi_avi_infoframe_from_display_mode()
5646 frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; in drm_hdmi_avi_infoframe_from_display_mode()
5652 if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 || in drm_hdmi_avi_infoframe_from_display_mode()
5653 mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9) in drm_hdmi_avi_infoframe_from_display_mode()
5654 frame->picture_aspect = mode->picture_aspect_ratio; in drm_hdmi_avi_infoframe_from_display_mode()
5655 else if (frame->video_code > 0) in drm_hdmi_avi_infoframe_from_display_mode()
5656 frame->picture_aspect = drm_get_cea_aspect_ratio( in drm_hdmi_avi_infoframe_from_display_mode()
5657 frame->video_code); in drm_hdmi_avi_infoframe_from_display_mode()
5659 if (frame->picture_aspect > HDMI_PICTURE_ASPECT_16_9) in drm_hdmi_avi_infoframe_from_display_mode()
5660 frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE; in drm_hdmi_avi_infoframe_from_display_mode()
5661 frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE; in drm_hdmi_avi_infoframe_from_display_mode()
5662 frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN; in drm_hdmi_avi_infoframe_from_display_mode()
5668 * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe
5677 frame->type = HDMI_INFOFRAME_TYPE_VENDOR; in hdmi_vendor_infoframe_init()
5678 frame->version = 1; in hdmi_vendor_infoframe_init()
5680 frame->oui = HDMI_IEEE_OUI; in hdmi_vendor_infoframe_init()
5686 frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID; in hdmi_vendor_infoframe_init()
5692 * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
5705 * CEA-861: in drm_hdmi_avi_infoframe_quant_range()
5706 * "A Source shall not send a non-zero Q value that does not correspond in drm_hdmi_avi_infoframe_quant_range()
5711 * HDMI 2.0 recommends sending non-zero Q when it does match the in drm_hdmi_avi_infoframe_quant_range()
5716 frame->quantization_range = rgb_quant_range; in drm_hdmi_avi_infoframe_quant_range()
5718 frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; in drm_hdmi_avi_infoframe_quant_range()
5721 * CEA-861-F: in drm_hdmi_avi_infoframe_quant_range()
5723 * YQ-field to match the RGB Quantization Range being transmitted in drm_hdmi_avi_infoframe_quant_range()
5725 * set YQ=1) and the Sink shall ignore the YQ-field." in drm_hdmi_avi_infoframe_quant_range()
5728 frame->ycc_quantization_range = in drm_hdmi_avi_infoframe_quant_range()
5731 frame->ycc_quantization_range = in drm_hdmi_avi_infoframe_quant_range()
5738 u32 layout = mode->flags & DRM_MODE_FLAG_3D_MASK; in s3d_structure_from_display_mode()
5771 return -EINVAL; in drm_hdmi_vendor_infoframe_from_display_mode()
5775 s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK; in drm_hdmi_vendor_infoframe_from_display_mode()
5778 return -EINVAL; in drm_hdmi_vendor_infoframe_from_display_mode()
5781 return -EINVAL; in drm_hdmi_vendor_infoframe_from_display_mode()
5788 frame->vic = vic; in drm_hdmi_vendor_infoframe_from_display_mode()
5790 frame->s3d_struct = s3d_structure_from_display_mode(mode); in drm_hdmi_vendor_infoframe_from_display_mode()
5804 return 256 - csum; in hdmi_infoframe_checksum()
5815 * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
5824 frame->type = HDMI_INFOFRAME_TYPE_AVI; in hdmi_avi_infoframe_init()
5825 frame->version = 2; in hdmi_avi_infoframe_init()
5826 frame->length = HDMI_AVI_INFOFRAME_SIZE; in hdmi_avi_infoframe_init()
5833 * hdmi_avi_infoframe_pack() - write HDMI AVI infoframe to binary buffer
5852 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_avi_infoframe_pack()
5855 return -ENOSPC; in hdmi_avi_infoframe_pack()
5859 ptr[0] = frame->type; in hdmi_avi_infoframe_pack()
5860 ptr[1] = frame->version; in hdmi_avi_infoframe_pack()
5861 ptr[2] = frame->length; in hdmi_avi_infoframe_pack()
5867 ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3); in hdmi_avi_infoframe_pack()
5873 if (frame->active_aspect & 0xf) in hdmi_avi_infoframe_pack()
5877 if (frame->top_bar || frame->bottom_bar) in hdmi_avi_infoframe_pack()
5880 if (frame->left_bar || frame->right_bar) in hdmi_avi_infoframe_pack()
5883 ptr[1] = ((frame->colorimetry & 0x3) << 6) | in hdmi_avi_infoframe_pack()
5884 ((frame->picture_aspect & 0x3) << 4) | in hdmi_avi_infoframe_pack()
5885 (frame->active_aspect & 0xf); in hdmi_avi_infoframe_pack()
5887 ptr[2] = ((frame->extended_colorimetry & 0x7) << 4) | in hdmi_avi_infoframe_pack()
5888 ((frame->quantization_range & 0x3) << 2) | in hdmi_avi_infoframe_pack()
5889 (frame->nups & 0x3); in hdmi_avi_infoframe_pack()
5891 if (frame->itc) in hdmi_avi_infoframe_pack()
5894 ptr[3] = frame->video_code & 0x7f; in hdmi_avi_infoframe_pack()
5896 ptr[4] = ((frame->ycc_quantization_range & 0x3) << 6) | in hdmi_avi_infoframe_pack()
5897 ((frame->content_type & 0x3) << 4) | in hdmi_avi_infoframe_pack()
5898 (frame->pixel_repeat & 0xf); in hdmi_avi_infoframe_pack()
5900 ptr[5] = frame->top_bar & 0xff; in hdmi_avi_infoframe_pack()
5901 ptr[6] = (frame->top_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack()
5902 ptr[7] = frame->bottom_bar & 0xff; in hdmi_avi_infoframe_pack()
5903 ptr[8] = (frame->bottom_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack()
5904 ptr[9] = frame->left_bar & 0xff; in hdmi_avi_infoframe_pack()
5905 ptr[10] = (frame->left_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack()
5906 ptr[11] = frame->right_bar & 0xff; in hdmi_avi_infoframe_pack()
5907 ptr[12] = (frame->right_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack()
5917 if (frame->type != HDMI_INFOFRAME_TYPE_AVI || in hdmi_avi_infoframe_check_only()
5918 frame->version != 2 || in hdmi_avi_infoframe_check_only()
5919 frame->length != HDMI_AVI_INFOFRAME_SIZE) in hdmi_avi_infoframe_check_only()
5920 return -EINVAL; in hdmi_avi_infoframe_check_only()
5922 if (frame->picture_aspect > HDMI_PICTURE_ASPECT_16_9) in hdmi_avi_infoframe_check_only()
5923 return -EINVAL; in hdmi_avi_infoframe_check_only()
5929 * hdmi_avi_infoframe_check() - check a HDMI AVI infoframe
5944 * hdmi_avi_infoframe_pack_only() - write HDMI AVI infoframe to binary buffer
5968 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_avi_infoframe_pack_only()
5971 return -ENOSPC; in hdmi_avi_infoframe_pack_only()
5975 ptr[0] = frame->type; in hdmi_avi_infoframe_pack_only()
5976 ptr[1] = frame->version; in hdmi_avi_infoframe_pack_only()
5977 ptr[2] = frame->length; in hdmi_avi_infoframe_pack_only()
5983 ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3); in hdmi_avi_infoframe_pack_only()
5989 if (frame->active_aspect & 0xf) in hdmi_avi_infoframe_pack_only()
5993 if (frame->top_bar || frame->bottom_bar) in hdmi_avi_infoframe_pack_only()
5996 if (frame->left_bar || frame->right_bar) in hdmi_avi_infoframe_pack_only()
5999 ptr[1] = ((frame->colorimetry & 0x3) << 6) | in hdmi_avi_infoframe_pack_only()
6000 ((frame->picture_aspect & 0x3) << 4) | in hdmi_avi_infoframe_pack_only()
6001 (frame->active_aspect & 0xf); in hdmi_avi_infoframe_pack_only()
6003 ptr[2] = ((frame->extended_colorimetry & 0x7) << 4) | in hdmi_avi_infoframe_pack_only()
6004 ((frame->quantization_range & 0x3) << 2) | in hdmi_avi_infoframe_pack_only()
6005 (frame->nups & 0x3); in hdmi_avi_infoframe_pack_only()
6007 if (frame->itc) in hdmi_avi_infoframe_pack_only()
6010 ptr[3] = frame->video_code & 0xff; in hdmi_avi_infoframe_pack_only()
6012 ptr[4] = ((frame->ycc_quantization_range & 0x3) << 6) | in hdmi_avi_infoframe_pack_only()
6013 ((frame->content_type & 0x3) << 4) | in hdmi_avi_infoframe_pack_only()
6014 (frame->pixel_repeat & 0xf); in hdmi_avi_infoframe_pack_only()
6016 ptr[5] = frame->top_bar & 0xff; in hdmi_avi_infoframe_pack_only()
6017 ptr[6] = (frame->top_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack_only()
6018 ptr[7] = frame->bottom_bar & 0xff; in hdmi_avi_infoframe_pack_only()
6019 ptr[8] = (frame->bottom_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack_only()
6020 ptr[9] = frame->left_bar & 0xff; in hdmi_avi_infoframe_pack_only()
6021 ptr[10] = (frame->left_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack_only()
6022 ptr[11] = frame->right_bar & 0xff; in hdmi_avi_infoframe_pack_only()
6023 ptr[12] = (frame->right_bar >> 8) & 0xff; in hdmi_avi_infoframe_pack_only()
6032 * hdmi_spd_infoframe_init() - initialize an HDMI SPD infoframe
6044 frame->type = HDMI_INFOFRAME_TYPE_SPD; in hdmi_spd_infoframe_init()
6045 frame->version = 1; in hdmi_spd_infoframe_init()
6046 frame->length = HDMI_SPD_INFOFRAME_SIZE; in hdmi_spd_infoframe_init()
6048 strncpy(frame->vendor, vendor, sizeof(frame->vendor)); in hdmi_spd_infoframe_init()
6049 strncpy(frame->product, product, sizeof(frame->product)); in hdmi_spd_infoframe_init()
6056 * hdmi_spd_infoframe_pack() - write HDMI SPD infoframe to binary buffer
6075 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_spd_infoframe_pack()
6078 return -ENOSPC; in hdmi_spd_infoframe_pack()
6082 ptr[0] = frame->type; in hdmi_spd_infoframe_pack()
6083 ptr[1] = frame->version; in hdmi_spd_infoframe_pack()
6084 ptr[2] = frame->length; in hdmi_spd_infoframe_pack()
6090 memcpy(ptr, frame->vendor, sizeof(frame->vendor)); in hdmi_spd_infoframe_pack()
6091 memcpy(ptr + 8, frame->product, sizeof(frame->product)); in hdmi_spd_infoframe_pack()
6093 ptr[24] = frame->sdi; in hdmi_spd_infoframe_pack()
6102 * hdmi_audio_infoframe_init() - initialize an HDMI audio infoframe
6111 frame->type = HDMI_INFOFRAME_TYPE_AUDIO; in hdmi_audio_infoframe_init()
6112 frame->version = 1; in hdmi_audio_infoframe_init()
6113 frame->length = HDMI_AUDIO_INFOFRAME_SIZE; in hdmi_audio_infoframe_init()
6119 * hdmi_audio_infoframe_pack() - write HDMI audio infoframe to binary buffer
6139 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_audio_infoframe_pack()
6142 return -ENOSPC; in hdmi_audio_infoframe_pack()
6146 if (frame->channels >= 2) in hdmi_audio_infoframe_pack()
6147 channels = frame->channels - 1; in hdmi_audio_infoframe_pack()
6151 ptr[0] = frame->type; in hdmi_audio_infoframe_pack()
6152 ptr[1] = frame->version; in hdmi_audio_infoframe_pack()
6153 ptr[2] = frame->length; in hdmi_audio_infoframe_pack()
6159 ptr[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7); in hdmi_audio_infoframe_pack()
6160 ptr[1] = ((frame->sample_frequency & 0x7) << 2) | in hdmi_audio_infoframe_pack()
6161 (frame->sample_size & 0x3); in hdmi_audio_infoframe_pack()
6162 ptr[2] = frame->coding_type_ext & 0x1f; in hdmi_audio_infoframe_pack()
6163 ptr[3] = frame->channel_allocation; in hdmi_audio_infoframe_pack()
6164 ptr[4] = (frame->level_shift_value & 0xf) << 3; in hdmi_audio_infoframe_pack()
6166 if (frame->downmix_inhibit) in hdmi_audio_infoframe_pack()
6175 * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
6195 if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID) in hdmi_vendor_infoframe_pack()
6196 return -EINVAL; in hdmi_vendor_infoframe_pack()
6199 if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) in hdmi_vendor_infoframe_pack()
6200 return -EINVAL; in hdmi_vendor_infoframe_pack()
6203 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) in hdmi_vendor_infoframe_pack()
6204 frame->length = 6; in hdmi_vendor_infoframe_pack()
6206 frame->length = 5; in hdmi_vendor_infoframe_pack()
6208 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_vendor_infoframe_pack()
6211 return -ENOSPC; in hdmi_vendor_infoframe_pack()
6215 ptr[0] = frame->type; in hdmi_vendor_infoframe_pack()
6216 ptr[1] = frame->version; in hdmi_vendor_infoframe_pack()
6217 ptr[2] = frame->length; in hdmi_vendor_infoframe_pack()
6225 if (frame->vic) { in hdmi_vendor_infoframe_pack()
6227 ptr[8] = frame->vic; in hdmi_vendor_infoframe_pack()
6230 ptr[8] = (frame->s3d_struct & 0xf) << 4; in hdmi_vendor_infoframe_pack()
6231 if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) in hdmi_vendor_infoframe_pack()
6232 ptr[9] = (frame->s3d_ext_data & 0xf) << 4; in hdmi_vendor_infoframe_pack()
6241 * hdmi_drm_infoframe_init() - initialize an HDMI Dynaminc Range and
6251 frame->type = HDMI_INFOFRAME_TYPE_DRM; in hdmi_drm_infoframe_init()
6252 frame->version = 1; in hdmi_drm_infoframe_init()
6258 * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
6277 length = HDMI_INFOFRAME_HEADER_SIZE + frame->length; in hdmi_drm_infoframe_pack()
6280 return -ENOSPC; in hdmi_drm_infoframe_pack()
6284 ptr[0] = frame->type; in hdmi_drm_infoframe_pack()
6285 ptr[1] = frame->version; in hdmi_drm_infoframe_pack()
6286 ptr[2] = frame->length; in hdmi_drm_infoframe_pack()
6292 ptr[0] = frame->eotf; in hdmi_drm_infoframe_pack()
6293 ptr[1] = frame->metadata_type; in hdmi_drm_infoframe_pack()
6295 ptr[2] = frame->display_primaries_x[0] & 0xff; in hdmi_drm_infoframe_pack()
6296 ptr[3] = frame->display_primaries_x[0] >> 8; in hdmi_drm_infoframe_pack()
6298 ptr[4] = frame->display_primaries_x[1] & 0xff; in hdmi_drm_infoframe_pack()
6299 ptr[5] = frame->display_primaries_x[1] >> 8; in hdmi_drm_infoframe_pack()
6301 ptr[6] = frame->display_primaries_x[2] & 0xff; in hdmi_drm_infoframe_pack()
6302 ptr[7] = frame->display_primaries_x[2] >> 8; in hdmi_drm_infoframe_pack()
6304 ptr[9] = frame->display_primaries_y[0] & 0xff; in hdmi_drm_infoframe_pack()
6305 ptr[10] = frame->display_primaries_y[0] >> 8; in hdmi_drm_infoframe_pack()
6307 ptr[11] = frame->display_primaries_y[1] & 0xff; in hdmi_drm_infoframe_pack()
6308 ptr[12] = frame->display_primaries_y[1] >> 8; in hdmi_drm_infoframe_pack()
6310 ptr[13] = frame->display_primaries_y[2] & 0xff; in hdmi_drm_infoframe_pack()
6311 ptr[14] = frame->display_primaries_y[2] >> 8; in hdmi_drm_infoframe_pack()
6313 ptr[15] = frame->white_point_x & 0xff; in hdmi_drm_infoframe_pack()
6314 ptr[16] = frame->white_point_x >> 8; in hdmi_drm_infoframe_pack()
6316 ptr[17] = frame->white_point_y & 0xff; in hdmi_drm_infoframe_pack()
6317 ptr[18] = frame->white_point_y >> 8; in hdmi_drm_infoframe_pack()
6319 ptr[19] = frame->max_mastering_display_luminance & 0xff; in hdmi_drm_infoframe_pack()
6320 ptr[20] = frame->max_mastering_display_luminance >> 8; in hdmi_drm_infoframe_pack()
6322 ptr[21] = frame->min_mastering_display_luminance & 0xff; in hdmi_drm_infoframe_pack()
6323 ptr[22] = frame->min_mastering_display_luminance >> 8; in hdmi_drm_infoframe_pack()
6325 ptr[23] = frame->max_cll & 0xff; in hdmi_drm_infoframe_pack()
6326 ptr[24] = frame->max_cll >> 8; in hdmi_drm_infoframe_pack()
6328 ptr[25] = frame->max_fall & 0xff; in hdmi_drm_infoframe_pack()
6329 ptr[26] = frame->max_fall >> 8; in hdmi_drm_infoframe_pack()
6337 * hdmi_vendor_any_infoframe_pack() - write a vendor infoframe to binary buffer
6344 if (frame->any.oui != HDMI_IEEE_OUI) in hdmi_vendor_any_infoframe_pack()
6345 return -EINVAL; in hdmi_vendor_any_infoframe_pack()
6347 return hdmi_vendor_infoframe_pack(&frame->hdmi, buffer, size); in hdmi_vendor_any_infoframe_pack()
6351 * hdmi_infoframe_pack() - write a HDMI infoframe to binary buffer
6369 switch (frame->any.type) { in hdmi_infoframe_pack()
6371 length = hdmi_avi_infoframe_pack(&frame->avi, buffer, size); in hdmi_infoframe_pack()
6374 length = hdmi_drm_infoframe_pack(&frame->drm, buffer, size); in hdmi_infoframe_pack()
6377 length = hdmi_spd_infoframe_pack(&frame->spd, buffer, size); in hdmi_infoframe_pack()
6380 length = hdmi_audio_infoframe_pack(&frame->audio, buffer, size); in hdmi_infoframe_pack()
6383 length = hdmi_vendor_any_infoframe_pack(&frame->vendor, in hdmi_infoframe_pack()
6387 printf("Bad infoframe type %d\n", frame->any.type); in hdmi_infoframe_pack()
6388 length = -EINVAL; in hdmi_infoframe_pack()
6395 * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
6415 return -EINVAL; in hdmi_avi_infoframe_unpack()
6418 return -EINVAL; in hdmi_avi_infoframe_unpack()
6426 frame->colorspace = (ptr[0] >> 5) & 0x3; in hdmi_avi_infoframe_unpack()
6428 frame->active_aspect = ptr[1] & 0xf; in hdmi_avi_infoframe_unpack()
6430 frame->top_bar = (ptr[5] << 8) + ptr[6]; in hdmi_avi_infoframe_unpack()
6431 frame->bottom_bar = (ptr[7] << 8) + ptr[8]; in hdmi_avi_infoframe_unpack()
6434 frame->left_bar = (ptr[9] << 8) + ptr[10]; in hdmi_avi_infoframe_unpack()
6435 frame->right_bar = (ptr[11] << 8) + ptr[12]; in hdmi_avi_infoframe_unpack()
6437 frame->scan_mode = ptr[0] & 0x3; in hdmi_avi_infoframe_unpack()
6439 frame->colorimetry = (ptr[1] >> 6) & 0x3; in hdmi_avi_infoframe_unpack()
6440 frame->picture_aspect = (ptr[1] >> 4) & 0x3; in hdmi_avi_infoframe_unpack()
6441 frame->active_aspect = ptr[1] & 0xf; in hdmi_avi_infoframe_unpack()
6443 frame->itc = ptr[2] & 0x80 ? true : false; in hdmi_avi_infoframe_unpack()
6444 frame->extended_colorimetry = (ptr[2] >> 4) & 0x7; in hdmi_avi_infoframe_unpack()
6445 frame->quantization_range = (ptr[2] >> 2) & 0x3; in hdmi_avi_infoframe_unpack()
6446 frame->nups = ptr[2] & 0x3; in hdmi_avi_infoframe_unpack()
6448 frame->video_code = ptr[3] & 0x7f; in hdmi_avi_infoframe_unpack()
6449 frame->ycc_quantization_range = (ptr[4] >> 6) & 0x3; in hdmi_avi_infoframe_unpack()
6450 frame->content_type = (ptr[4] >> 4) & 0x3; in hdmi_avi_infoframe_unpack()
6452 frame->pixel_repeat = ptr[4] & 0xf; in hdmi_avi_infoframe_unpack()
6458 * hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe
6478 return -EINVAL; in hdmi_spd_infoframe_unpack()
6482 return -EINVAL; in hdmi_spd_infoframe_unpack()
6490 frame->sdi = ptr[24]; in hdmi_spd_infoframe_unpack()
6496 * hdmi_audio_infoframe_unpack() - unpack binary buffer to a HDMI AUDIO infoframe
6516 return -EINVAL; in hdmi_audio_infoframe_unpack()
6520 return -EINVAL; in hdmi_audio_infoframe_unpack()
6528 frame->channels = ptr[0] & 0x7; in hdmi_audio_infoframe_unpack()
6529 frame->coding_type = (ptr[0] >> 4) & 0xf; in hdmi_audio_infoframe_unpack()
6530 frame->sample_size = ptr[1] & 0x3; in hdmi_audio_infoframe_unpack()
6531 frame->sample_frequency = (ptr[1] >> 2) & 0x7; in hdmi_audio_infoframe_unpack()
6532 frame->coding_type_ext = ptr[2] & 0x1f; in hdmi_audio_infoframe_unpack()
6533 frame->channel_allocation = ptr[3]; in hdmi_audio_infoframe_unpack()
6534 frame->level_shift_value = (ptr[4] >> 3) & 0xf; in hdmi_audio_infoframe_unpack()
6535 frame->downmix_inhibit = ptr[4] & 0x80 ? true : false; in hdmi_audio_infoframe_unpack()
6541 * hdmi_vendor_infoframe_unpack() - unpack binary buffer to a HDMI vendor infoframe
6560 struct hdmi_vendor_infoframe *hvf = &frame->hdmi; in hdmi_vendor_any_infoframe_unpack()
6565 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6571 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6579 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6584 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6590 hvf->length = length; in hdmi_vendor_any_infoframe_unpack()
6594 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6595 hvf->s3d_struct = ptr[4] >> 4; in hdmi_vendor_any_infoframe_unpack()
6596 if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) { in hdmi_vendor_any_infoframe_unpack()
6598 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6599 hvf->s3d_ext_data = ptr[5] >> 4; in hdmi_vendor_any_infoframe_unpack()
6603 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6604 hvf->vic = ptr[4]; in hdmi_vendor_any_infoframe_unpack()
6607 return -EINVAL; in hdmi_vendor_any_infoframe_unpack()
6614 * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe
6632 ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer); in hdmi_infoframe_unpack()
6635 ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer); in hdmi_infoframe_unpack()
6638 ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer); in hdmi_infoframe_unpack()
6641 ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer); in hdmi_infoframe_unpack()
6644 ret = -EINVAL; in hdmi_infoframe_unpack()
6652 * drm_mode_sort - sort mode list
6663 for (i = 0; i < (edid_data->modes - 1); i++) { in drm_mode_sort()
6664 a = &edid_data->mode_buf[i]; in drm_mode_sort()
6665 for (j = i + 1; j < edid_data->modes; j++) { in drm_mode_sort()
6666 b = &edid_data->mode_buf[j]; in drm_mode_sort()
6667 diff = ((b->type & DRM_MODE_TYPE_PREFERRED) != 0) - in drm_mode_sort()
6668 ((a->type & DRM_MODE_TYPE_PREFERRED) != 0); in drm_mode_sort()
6678 diff = b->hdisplay * b->vdisplay in drm_mode_sort()
6679 - a->hdisplay * a->vdisplay; in drm_mode_sort()
6689 diff = b->vrefresh - a->vrefresh; in drm_mode_sort()
6699 diff = b->clock - a->clock; in drm_mode_sort()
6707 edid_data->preferred_mode = &edid_data->mode_buf[0]; in drm_mode_sort()
6711 * drm_mode_prune_invalid - remove invalid modes from mode list
6719 int num = edid_data->modes; in drm_mode_prune_invalid()
6721 struct drm_display_mode *mode_buf = edid_data->mode_buf; in drm_mode_prune_invalid()
6726 for (j = i; j < num - 1; j++) in drm_mode_prune_invalid()
6729 num--; in drm_mode_prune_invalid()
6730 i--; in drm_mode_prune_invalid()
6734 memset(&mode_buf[num], 0, len * (edid_data->modes - num)); in drm_mode_prune_invalid()
6736 edid_data->modes = num; in drm_mode_prune_invalid()
6741 * drm_rk_filter_whitelist - mark modes out of white list from mode list
6751 for (i = 0; i < edid_data->modes; i++) { in drm_rk_filter_whitelist()
6754 &edid_data->mode_buf[i], in drm_rk_filter_whitelist()
6762 edid_data->mode_buf[i].invalid = true; in drm_rk_filter_whitelist()
6770 mode->clock = base_mode->clock; in drm_display_mode_convert()
6771 mode->hdisplay = base_mode->hdisplay; in drm_display_mode_convert()
6772 mode->hsync_start = base_mode->hsync_start; in drm_display_mode_convert()
6773 mode->hsync_end = base_mode->hsync_end; in drm_display_mode_convert()
6774 mode->htotal = base_mode->htotal; in drm_display_mode_convert()
6775 mode->vdisplay = base_mode->vdisplay; in drm_display_mode_convert()
6776 mode->vsync_start = base_mode->vsync_start; in drm_display_mode_convert()
6777 mode->vsync_end = base_mode->vsync_end; in drm_display_mode_convert()
6778 mode->vtotal = base_mode->vtotal; in drm_display_mode_convert()
6779 mode->vrefresh = base_mode->vrefresh; in drm_display_mode_convert()
6780 mode->vscan = base_mode->vscan; in drm_display_mode_convert()
6781 mode->flags = base_mode->flags; in drm_display_mode_convert()
6782 mode->picture_aspect_ratio = base_mode->picture_aspect_ratio; in drm_display_mode_convert()
6796 drm_display_mode_convert(&mode, &screen_info->mode); in drm_rk_select_mode()
6797 for (i = 0; i < edid_data->modes; i++) { in drm_rk_select_mode()
6799 &edid_data->mode_buf[i], in drm_rk_select_mode()
6803 edid_data->preferred_mode = in drm_rk_select_mode()
6804 &edid_data->mode_buf[i]; in drm_rk_select_mode()
6806 if (edid_data->mode_buf[i].picture_aspect_ratio) in drm_rk_select_mode()
6814 * drm_do_probe_ddc_edid() - get EDID information via I2C
6822 * Return: 0 on success or -1 on failure.
6853 if (adap->ops) { in drm_do_probe_ddc_edid()
6854 ret = adap->ops->xfer(adap->i2c_bus, &msgs[3 - xfers], in drm_do_probe_ddc_edid()
6859 ret = adap->ddc_xfer(adap, &msgs[3 - xfers], xfers); in drm_do_probe_ddc_edid()
6861 } while (ret != xfers && --retries); in drm_do_probe_ddc_edid()
6864 return ret == xfers ? 0 : -1; in drm_do_probe_ddc_edid()
6929 return -EFAULT; in drm_do_get_edid()
6949 return adap->ddc_xfer(adap, msgs, ARRAY_SIZE(msgs)); in hdmi_ddc_read()
6966 return -ENOMEM; in hdmi_ddc_write()
6973 err = adap->ddc_xfer(adap, &msg, 1); in hdmi_ddc_write()
6981 * drm_scdc_readb - read a single byte from SCDC
7000 * drm_scdc_writeb - write a single byte to SCDC