Skip to content

Commit

Permalink
LibEDID: Fix calculating height and refresh rate for interlaced modes
Browse files Browse the repository at this point in the history
The vertical values need to be multiplied with 2 for interlaced modes.
  • Loading branch information
tomuta authored and linusg committed Jan 24, 2022
1 parent e04e521 commit 18fc54f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Userland/Libraries/LibEDID/EDID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,19 @@ u16 Parser::DetailedTiming::horizontal_blanking_pixels() const
return ((u16)high << 8) | (u16)low;
}

u16 Parser::DetailedTiming::vertical_addressable_lines() const
u16 Parser::DetailedTiming::vertical_addressable_lines_raw() const
{
u8 low = m_edid.read_host(&m_detailed_timings.vertical_addressable_lines_low);
u8 high = m_edid.read_host(&m_detailed_timings.vertical_addressable_and_blanking_lines_high) >> 4;
return ((u16)high << 8) | (u16)low;
}

u16 Parser::DetailedTiming::vertical_addressable_lines() const
{
auto lines = vertical_addressable_lines_raw();
return is_interlaced() ? lines * 2 : lines;
}

u16 Parser::DetailedTiming::vertical_blanking_lines() const
{
u8 low = m_edid.read_host(&m_detailed_timings.vertical_blanking_lines_low);
Expand Down Expand Up @@ -745,9 +751,9 @@ bool Parser::DetailedTiming::is_interlaced() const

FixedPoint<16, u32> Parser::DetailedTiming::refresh_rate() const
{
// Blanking = front porch + sync pulse width = back porch
// Blanking = front porch + sync pulse width + back porch
u32 total_horizontal_pixels = (u32)horizontal_addressable_pixels() + (u32)horizontal_blanking_pixels();
u32 total_vertical_lines = (u32)vertical_addressable_lines() + (u32)vertical_blanking_lines();
u32 total_vertical_lines = (u32)vertical_addressable_lines_raw() + (u32)vertical_blanking_lines();
u32 total_pixels = total_horizontal_pixels * total_vertical_lines;
if (total_pixels == 0)
return {};
Expand Down
2 changes: 2 additions & 0 deletions Userland/Libraries/LibEDID/EDID.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ class Parser final {
{
}

u16 vertical_addressable_lines_raw() const;

Parser const& m_edid;
Definitions::DetailedTiming const& m_detailed_timings;
};
Expand Down

0 comments on commit 18fc54f

Please sign in to comment.