DMT.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FixedPoint.h>
  8. #include <AK/Optional.h>
  9. #include <AK/Types.h>
  10. namespace EDID {
  11. class DMT final {
  12. public:
  13. struct CVT {
  14. u8 bytes[3];
  15. };
  16. struct MonitorTiming {
  17. enum class ScanType : u8 {
  18. NonInterlaced,
  19. Interlaced
  20. };
  21. enum class CVTCompliance : u8 {
  22. NotCompliant,
  23. Compliant,
  24. CompliantReducedBlanking,
  25. CompliantReducedBlankingV2,
  26. };
  27. u8 dmt_id;
  28. u8 std_bytes[2];
  29. u8 char_width_pixels;
  30. u16 horizontal_pixels;
  31. u16 vertical_lines;
  32. u32 horizontal_frequency_hz;
  33. u32 vertical_frequency_millihz;
  34. u32 pixel_clock_khz;
  35. u8 horizontal_front_porch_pixels;
  36. u8 vertical_front_porch_lines;
  37. u16 horizontal_blank_pixels;
  38. u16 vertical_blank_lines;
  39. u16 horizontal_sync_time_pixels;
  40. u8 vertical_sync_time_lines;
  41. CVTCompliance cvt_compliance { CVTCompliance::NotCompliant };
  42. u8 cvt_bytes[3] {};
  43. ScanType scan_type { ScanType::NonInterlaced };
  44. ALWAYS_INLINE bool has_std() const { return std_bytes[0] != 0; }
  45. ALWAYS_INLINE bool has_cvt() const { return cvt_bytes[0] != 0; }
  46. FixedPoint<16, u32> horizontal_frequency_khz() const;
  47. FixedPoint<16, u32> vertical_frequency_hz() const;
  48. u32 refresh_rate_hz() const;
  49. #ifndef KERNEL
  50. ByteString name() const;
  51. #endif
  52. };
  53. static MonitorTiming const* find_timing_by_dmt_id(u8);
  54. static MonitorTiming const* find_timing_by_std_id(u8, u8);
  55. static MonitorTiming const* find_timing_by_cvt(CVT);
  56. };
  57. }