Definitions.h 4.2 KB

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