diff options
author | Liav A <liavalb@gmail.com> | 2022-03-05 22:08:10 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-08 22:07:59 +0100 |
commit | df5fa20beed27b18d31a018af2113a3870dda926 (patch) | |
tree | a8aa1c9e71814f2c0b619e90315a9142df2c3b38 | |
parent | ebbf977be5df3dcfa23aadb1e1704e31fc424754 (diff) | |
download | serenity-df5fa20beed27b18d31a018af2113a3870dda926.zip |
LibEDID: Fix DetailedTiming::pixel_clock_khz result
The stored value is in units of 10 kHz, which means that to get the
value in kHz, we need to multiply it by 10 and not 10000.
-rw-r--r-- | Userland/Libraries/LibEDID/EDID.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp index 6f7319095b..599df45a45 100644 --- a/Userland/Libraries/LibEDID/EDID.cpp +++ b/Userland/Libraries/LibEDID/EDID.cpp @@ -665,7 +665,9 @@ Optional<FixedPoint<16>> Parser::gamma() const u32 Parser::DetailedTiming::pixel_clock_khz() const { - return (u32)m_edid.read_le(&m_detailed_timings.pixel_clock) * 10000; + // Note: The stored value is in units of 10 kHz, which means that to get the + // value in kHz, we need to multiply it by 10. + return (u32)m_edid.read_le(&m_detailed_timings.pixel_clock) * 10; } u16 Parser::DetailedTiming::horizontal_addressable_pixels() const @@ -768,7 +770,8 @@ FixedPoint<16, u32> Parser::DetailedTiming::refresh_rate() const if (total_pixels == 0) return {}; // Use a bigger fixed point representation due to the large numbers involved and then downcast - return FixedPoint<32, u64>(pixel_clock_khz()) / total_pixels; + // Note: We need to convert the pixel clock from kHz to Hertz to actually calculate this correctly. + return FixedPoint<32, u64>(pixel_clock_khz() * 1000) / total_pixels; } ErrorOr<IterationDecision> Parser::for_each_established_timing(Function<IterationDecision(EstablishedTiming const&)> callback) const |