drm_displayid_internal.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright © 2014 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __DRM_DISPLAYID_INTERNAL_H__
  23. #define __DRM_DISPLAYID_INTERNAL_H__
  24. #include <linux/types.h>
  25. #include <linux/bits.h>
  26. struct drm_edid;
  27. #define VESA_IEEE_OUI 0x3a0292
  28. /* DisplayID Structure versions */
  29. #define DISPLAY_ID_STRUCTURE_VER_20 0x20
  30. /* DisplayID Structure v1r2 Data Blocks */
  31. #define DATA_BLOCK_PRODUCT_ID 0x00
  32. #define DATA_BLOCK_DISPLAY_PARAMETERS 0x01
  33. #define DATA_BLOCK_COLOR_CHARACTERISTICS 0x02
  34. #define DATA_BLOCK_TYPE_1_DETAILED_TIMING 0x03
  35. #define DATA_BLOCK_TYPE_2_DETAILED_TIMING 0x04
  36. #define DATA_BLOCK_TYPE_3_SHORT_TIMING 0x05
  37. #define DATA_BLOCK_TYPE_4_DMT_TIMING 0x06
  38. #define DATA_BLOCK_VESA_TIMING 0x07
  39. #define DATA_BLOCK_CEA_TIMING 0x08
  40. #define DATA_BLOCK_VIDEO_TIMING_RANGE 0x09
  41. #define DATA_BLOCK_PRODUCT_SERIAL_NUMBER 0x0a
  42. #define DATA_BLOCK_GP_ASCII_STRING 0x0b
  43. #define DATA_BLOCK_DISPLAY_DEVICE_DATA 0x0c
  44. #define DATA_BLOCK_INTERFACE_POWER_SEQUENCING 0x0d
  45. #define DATA_BLOCK_TRANSFER_CHARACTERISTICS 0x0e
  46. #define DATA_BLOCK_DISPLAY_INTERFACE 0x0f
  47. #define DATA_BLOCK_STEREO_DISPLAY_INTERFACE 0x10
  48. #define DATA_BLOCK_TILED_DISPLAY 0x12
  49. #define DATA_BLOCK_VENDOR_SPECIFIC 0x7f
  50. #define DATA_BLOCK_CTA 0x81
  51. /* DisplayID Structure v2r0 Data Blocks */
  52. #define DATA_BLOCK_2_PRODUCT_ID 0x20
  53. #define DATA_BLOCK_2_DISPLAY_PARAMETERS 0x21
  54. #define DATA_BLOCK_2_TYPE_7_DETAILED_TIMING 0x22
  55. #define DATA_BLOCK_2_TYPE_8_ENUMERATED_TIMING 0x23
  56. #define DATA_BLOCK_2_TYPE_9_FORMULA_TIMING 0x24
  57. #define DATA_BLOCK_2_DYNAMIC_VIDEO_TIMING 0x25
  58. #define DATA_BLOCK_2_DISPLAY_INTERFACE_FEATURES 0x26
  59. #define DATA_BLOCK_2_STEREO_DISPLAY_INTERFACE 0x27
  60. #define DATA_BLOCK_2_TILED_DISPLAY_TOPOLOGY 0x28
  61. #define DATA_BLOCK_2_CONTAINER_ID 0x29
  62. #define DATA_BLOCK_2_TYPE_10_FORMULA_TIMING 0x2a
  63. #define DATA_BLOCK_2_VENDOR_SPECIFIC 0x7e
  64. #define DATA_BLOCK_2_CTA_DISPLAY_ID 0x81
  65. /* DisplayID Structure v1r2 Product Type */
  66. #define PRODUCT_TYPE_EXTENSION 0
  67. #define PRODUCT_TYPE_TEST 1
  68. #define PRODUCT_TYPE_PANEL 2
  69. #define PRODUCT_TYPE_MONITOR 3
  70. #define PRODUCT_TYPE_TV 4
  71. #define PRODUCT_TYPE_REPEATER 5
  72. #define PRODUCT_TYPE_DIRECT_DRIVE 6
  73. /* DisplayID Structure v2r0 Display Product Primary Use Case (~Product Type) */
  74. #define PRIMARY_USE_EXTENSION 0
  75. #define PRIMARY_USE_TEST 1
  76. #define PRIMARY_USE_GENERIC 2
  77. #define PRIMARY_USE_TV 3
  78. #define PRIMARY_USE_DESKTOP_PRODUCTIVITY 4
  79. #define PRIMARY_USE_DESKTOP_GAMING 5
  80. #define PRIMARY_USE_PRESENTATION 6
  81. #define PRIMARY_USE_HEAD_MOUNTED_VR 7
  82. #define PRIMARY_USE_HEAD_MOUNTED_AR 8
  83. struct displayid_header {
  84. u8 rev;
  85. u8 bytes;
  86. u8 prod_id;
  87. u8 ext_count;
  88. } __packed;
  89. struct displayid_block {
  90. u8 tag;
  91. u8 rev;
  92. u8 num_bytes;
  93. } __packed;
  94. struct displayid_tiled_block {
  95. struct displayid_block base;
  96. u8 tile_cap;
  97. u8 topo[3];
  98. u8 tile_size[4];
  99. u8 tile_pixel_bezel[5];
  100. u8 topology_id[8];
  101. } __packed;
  102. struct displayid_detailed_timings_1 {
  103. u8 pixel_clock[3];
  104. u8 flags;
  105. __le16 hactive;
  106. __le16 hblank;
  107. __le16 hsync;
  108. __le16 hsw;
  109. __le16 vactive;
  110. __le16 vblank;
  111. __le16 vsync;
  112. __le16 vsw;
  113. } __packed;
  114. struct displayid_detailed_timing_block {
  115. struct displayid_block base;
  116. struct displayid_detailed_timings_1 timings[];
  117. } __packed;
  118. struct displayid_formula_timings_9 {
  119. u8 flags;
  120. __le16 hactive;
  121. __le16 vactive;
  122. u8 vrefresh;
  123. } __packed;
  124. struct displayid_formula_timing_block {
  125. struct displayid_block base;
  126. struct displayid_formula_timings_9 timings[];
  127. } __packed;
  128. #define DISPLAYID_VESA_MSO_OVERLAP GENMASK(3, 0)
  129. #define DISPLAYID_VESA_MSO_MODE GENMASK(6, 5)
  130. struct displayid_vesa_vendor_specific_block {
  131. struct displayid_block base;
  132. u8 oui[3];
  133. u8 data_structure_type;
  134. u8 mso;
  135. } __packed;
  136. /*
  137. * DisplayID iteration.
  138. *
  139. * Do not access directly, this is private.
  140. */
  141. struct displayid_iter {
  142. const struct drm_edid *drm_edid;
  143. const u8 *section;
  144. int length;
  145. int idx;
  146. int ext_index;
  147. u8 version;
  148. u8 primary_use;
  149. u8 quirks;
  150. };
  151. void displayid_iter_edid_begin(const struct drm_edid *drm_edid,
  152. struct displayid_iter *iter);
  153. const struct displayid_block *
  154. __displayid_iter_next(struct displayid_iter *iter);
  155. #define displayid_iter_for_each(__block, __iter) \
  156. while (((__block) = __displayid_iter_next(__iter)))
  157. void displayid_iter_end(struct displayid_iter *iter);
  158. u8 displayid_version(const struct displayid_iter *iter);
  159. u8 displayid_primary_use(const struct displayid_iter *iter);
  160. #endif