Definitions.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (c) 2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. namespace EDID {
  9. namespace Definitions {
  10. struct [[gnu::packed]] StandardTimings {
  11. u8 horizontal_8_pixels;
  12. u8 ratio_and_refresh_rate;
  13. };
  14. struct [[gnu::packed]] DetailedTiming {
  15. u16 pixel_clock;
  16. u8 horizontal_addressable_pixels_low;
  17. u8 horizontal_blanking_pixels_low;
  18. u8 horizontal_addressable_and_blanking_pixels_high;
  19. u8 vertical_addressable_lines_low;
  20. u8 vertical_blanking_lines_low;
  21. u8 vertical_addressable_and_blanking_lines_high;
  22. u8 horizontal_front_porch_pixels_low;
  23. u8 horizontal_sync_pulse_width_pixels_low;
  24. u8 vertical_front_porch_and_sync_pulse_width_lines_low;
  25. u8 horizontal_and_vertical_front_porch_sync_pulse_width_high;
  26. u8 horizontal_addressable_image_size_mm_low;
  27. u8 vertical_addressable_image_size_mm_low;
  28. u8 horizontal_vertical_addressable_image_size_mm_high;
  29. u8 right_or_left_horizontal_border_pixels;
  30. u8 top_or_bottom_vertical_border_lines;
  31. u8 features;
  32. };
  33. enum class DisplayDescriptorTag : u8 {
  34. ManufacturerSpecified_First = 0x0,
  35. ManufacturerSpecified_Last = 0xf,
  36. Dummy = 0x10,
  37. EstablishedTimings3 = 0xf7,
  38. CVTTimingCodes = 0xf8,
  39. DisplayColorManagementData = 0xf9,
  40. StandardTimingIdentifications = 0xfa,
  41. ColorPointData = 0xfb,
  42. DisplayProductName = 0xfc,
  43. DisplayRangeLimits = 0xfd,
  44. AlphanumericDataString = 0xfe,
  45. DisplayProductSerialNumber = 0xff
  46. };
  47. struct [[gnu::packed]] DisplayDescriptor {
  48. u16 zero;
  49. u8 reserved1;
  50. u8 tag;
  51. u8 reserved2;
  52. union {
  53. struct [[gnu::packed]] {
  54. u8 ascii_name[13];
  55. } display_product_name;
  56. struct [[gnu::packed]] {
  57. u8 ascii_str[13];
  58. } display_product_serial_number;
  59. struct [[gnu::packed]] {
  60. u8 revision;
  61. u8 dmt_bits[6];
  62. u8 reserved[6];
  63. } established_timings3;
  64. struct [[gnu::packed]] {
  65. u8 version;
  66. u8 cvt[4][3];
  67. } coordinated_video_timings;
  68. };
  69. };
  70. static_assert(sizeof(DetailedTiming) == sizeof(DisplayDescriptor));
  71. struct [[gnu::packed]] EDID {
  72. u64 header;
  73. struct [[gnu::packed]] {
  74. u16 manufacturer_id;
  75. u16 product_code;
  76. u32 serial_number;
  77. u8 week_of_manufacture;
  78. u8 year_of_manufacture;
  79. } vendor;
  80. struct [[gnu::packed]] {
  81. u8 version;
  82. u8 revision;
  83. } version;
  84. struct [[gnu::packed]] {
  85. u8 video_input_definition;
  86. u8 horizontal_size_or_aspect_ratio;
  87. u8 vertical_size_or_aspect_ratio;
  88. u8 display_transfer_characteristics;
  89. u8 feature_support;
  90. } basic_display_parameters;
  91. struct [[gnu::packed]] {
  92. u8 red_green_low_order_bits;
  93. u8 blue_white_low_order_bits;
  94. u8 red_x_high_order_bits;
  95. u8 red_y_high_order_bits;
  96. u8 green_x_high_order_bits;
  97. u8 green_y_high_order_bits;
  98. u8 blue_x_high_order_bits;
  99. u8 blue_y_high_order_bits;
  100. u8 white_x_high_order_bits;
  101. u8 white_y_high_order_bits;
  102. } color_characteristics;
  103. struct [[gnu::packed]] {
  104. u8 timings_1;
  105. u8 timings_2;
  106. u8 manufacturer_reserved;
  107. } established_timings;
  108. StandardTimings standard_timings[8];
  109. union {
  110. DetailedTiming detailed_timing;
  111. DisplayDescriptor display_descriptor;
  112. } detailed_timing_or_display_descriptors[4];
  113. u8 extension_block_count;
  114. u8 checksum;
  115. };
  116. enum class ExtensionBlockTag : u8 {
  117. CEA_861 = 0x2,
  118. VideoTimingBlock = 0x10,
  119. DisplayInformation = 0x40,
  120. LocalizedString = 0x50,
  121. DigitalPacketVideoLink = 0x60,
  122. ExtensionBlockMap = 0xf0,
  123. ManufacturerDefined = 0xff
  124. };
  125. struct [[gnu::packed]] ExtensionBlock {
  126. u8 tag;
  127. union {
  128. struct [[gnu::packed]] {
  129. u8 block_tags[126];
  130. } map;
  131. struct [[gnu::packed]] {
  132. u8 revision;
  133. u8 bytes[125];
  134. } block;
  135. struct [[gnu::packed]] {
  136. u8 revision;
  137. u8 dtd_start_offset;
  138. u8 flags;
  139. union {
  140. u8 bytes[123];
  141. };
  142. } cea861extension;
  143. };
  144. u8 checksum;
  145. };
  146. }
  147. static_assert(sizeof(Definitions::ExtensionBlock) == 128);
  148. }