mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 12:30:31 +00:00
LibEDID: Add a library to parse EDID blobs
This library can be used (for the most part) by kernel drivers as well as user mode. For this reason FixedPoint is used rather than floating point, but kept to a minimum.
This commit is contained in:
parent
c468a9cc2d
commit
8184870f93
Notes:
sideshowbarker
2024-07-17 22:01:16 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/8184870f935 Pull-request: https://github.com/SerenityOS/serenity/pull/11439 Reviewed-by: https://github.com/kleinesfilmroellchen Reviewed-by: https://github.com/linusg ✅
11 changed files with 2519 additions and 0 deletions
|
@ -4,6 +4,7 @@ add_subdirectory(LibC)
|
|||
add_subdirectory(LibCompress)
|
||||
add_subdirectory(LibCore)
|
||||
add_subdirectory(LibCpp)
|
||||
add_subdirectory(LibEDID)
|
||||
add_subdirectory(LibELF)
|
||||
add_subdirectory(LibGfx)
|
||||
add_subdirectory(LibGL)
|
||||
|
|
7
Tests/LibEDID/CMakeLists.txt
Normal file
7
Tests/LibEDID/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
set(TEST_SOURCES
|
||||
TestEDID.cpp
|
||||
)
|
||||
|
||||
foreach(source IN LISTS TEST_SOURCES)
|
||||
serenity_test("${source}" LibEDID LIBS LibEDID)
|
||||
endforeach()
|
408
Tests/LibEDID/TestEDID.cpp
Normal file
408
Tests/LibEDID/TestEDID.cpp
Normal file
|
@ -0,0 +1,408 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibEDID/DMT.h>
|
||||
#include <LibEDID/EDID.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
static const u8 edid1_bin[] = {
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x49, 0x14, 0x34, 0x12,
|
||||
0x00, 0x00, 0x00, 0x00, 0x2a, 0x18, 0x01, 0x04, 0xa5, 0x1a, 0x13, 0x78,
|
||||
0x06, 0xee, 0x91, 0xa3, 0x54, 0x4c, 0x99, 0x26, 0x0f, 0x50, 0x54, 0x21,
|
||||
0x08, 0x00, 0xe1, 0xc0, 0xd1, 0xc0, 0xd1, 0x00, 0xa9, 0x40, 0xb3, 0x00,
|
||||
0x95, 0x00, 0x81, 0x80, 0x81, 0x40, 0x25, 0x20, 0x00, 0x66, 0x41, 0x00,
|
||||
0x1a, 0x30, 0x00, 0x1e, 0x33, 0x40, 0x04, 0xc3, 0x10, 0x00, 0x00, 0x18,
|
||||
0x00, 0x00, 0x00, 0xfd, 0x00, 0x32, 0x7d, 0x1e, 0xa0, 0x78, 0x01, 0x0a,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x51,
|
||||
0x45, 0x4d, 0x55, 0x20, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0a,
|
||||
0x00, 0x00, 0x00, 0xf7, 0x00, 0x0a, 0x00, 0x40, 0x82, 0x00, 0x28, 0x20,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc4, 0x02, 0x03, 0x0a, 0x00,
|
||||
0x45, 0x7d, 0x65, 0x60, 0x59, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xf2
|
||||
};
|
||||
|
||||
TEST_CASE(edid1)
|
||||
{
|
||||
auto edid_load_result = EDID::Parser::from_bytes({ edid1_bin, sizeof(edid1_bin) });
|
||||
EXPECT(!edid_load_result.is_error());
|
||||
auto edid = edid_load_result.release_value();
|
||||
EXPECT(edid.legacy_manufacturer_id() == "RHT");
|
||||
EXPECT(!edid.aspect_ratio().has_value());
|
||||
auto screen_size = edid.screen_size();
|
||||
EXPECT(screen_size.has_value());
|
||||
EXPECT(screen_size.value().horizontal_cm() == 26);
|
||||
EXPECT(screen_size.value().vertical_cm() == 19);
|
||||
auto gamma = edid.gamma();
|
||||
EXPECT(gamma.has_value());
|
||||
EXPECT(gamma.value() >= 2.19f && gamma.value() <= 2.21f);
|
||||
EXPECT(edid.display_product_name() == "QEMU Monitor");
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
EDID::Parser::EstablishedTiming::Source source;
|
||||
u8 dmt_id { 0 };
|
||||
} expected_established_timings[] = {
|
||||
{ 640, 480, 60, EDID::Parser::EstablishedTiming::Source::IBM, 0x4 },
|
||||
{ 800, 600, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x9 },
|
||||
{ 1024, 768, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x10 },
|
||||
{ 1280, 768, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x17 },
|
||||
{ 1360, 768, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x27 },
|
||||
{ 1400, 1050, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x2a },
|
||||
{ 1792, 1344, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x3e },
|
||||
{ 1856, 1392, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x41 },
|
||||
{ 1920, 1440, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x49 }
|
||||
};
|
||||
static constexpr size_t expected_established_timings_count = sizeof(expected_established_timings) / sizeof(expected_established_timings[0]);
|
||||
size_t established_timings_found = 0;
|
||||
auto result = edid.for_each_established_timing([&](auto& established_timings) {
|
||||
EXPECT(established_timings_found < expected_established_timings_count);
|
||||
auto& expected_timings = expected_established_timings[established_timings_found];
|
||||
EXPECT(established_timings.width() == expected_timings.width);
|
||||
EXPECT(established_timings.height() == expected_timings.height);
|
||||
EXPECT(established_timings.refresh_rate() == expected_timings.refresh_rate);
|
||||
EXPECT(established_timings.source() == expected_timings.source);
|
||||
EXPECT(established_timings.dmt_id() == expected_timings.dmt_id);
|
||||
established_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(established_timings_found == expected_established_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
u8 dmt_id { 0 };
|
||||
} expected_standard_established_timings[] = {
|
||||
{ 2048, 1152, 60, 0x54 },
|
||||
{ 1920, 1080, 60, 0x52 },
|
||||
{ 1920, 1200, 60, 0x45 },
|
||||
{ 1600, 1200, 60, 0x33 },
|
||||
{ 1680, 1050, 60, 0x3a },
|
||||
{ 1440, 900, 60, 0x2f },
|
||||
{ 1280, 1024, 60, 0x23 },
|
||||
{ 1280, 960, 60, 0x20 }
|
||||
};
|
||||
static constexpr size_t expected_standard_timings_count = sizeof(expected_standard_established_timings) / sizeof(expected_standard_established_timings[0]);
|
||||
size_t standard_timings_found = 0;
|
||||
auto result = edid.for_each_standard_timing([&](auto& standard_timings) {
|
||||
EXPECT(standard_timings_found < expected_standard_timings_count);
|
||||
auto& expected_timings = expected_standard_established_timings[standard_timings_found];
|
||||
EXPECT(standard_timings.dmt_id() == expected_timings.dmt_id);
|
||||
EXPECT(standard_timings.width() == expected_timings.width);
|
||||
EXPECT(standard_timings.height() == expected_timings.height);
|
||||
EXPECT(standard_timings.refresh_rate() == expected_timings.refresh_rate);
|
||||
standard_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(standard_timings_found == expected_standard_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned block_id;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
} expected_detailed_timings[] = {
|
||||
{ 0, 1024, 768, 75 }
|
||||
};
|
||||
static constexpr size_t expected_detailed_timings_count = sizeof(expected_detailed_timings) / sizeof(expected_detailed_timings[0]);
|
||||
size_t detailed_timings_found = 0;
|
||||
auto result = edid.for_each_detailed_timing([&](auto& detailed_timing, unsigned block_id) {
|
||||
EXPECT(detailed_timings_found < expected_detailed_timings_count);
|
||||
auto& expected_timings = expected_detailed_timings[detailed_timings_found];
|
||||
EXPECT(block_id == expected_timings.block_id);
|
||||
EXPECT(detailed_timing.horizontal_addressable_pixels() == expected_timings.width);
|
||||
EXPECT(detailed_timing.vertical_addressable_lines() == expected_timings.height);
|
||||
EXPECT(detailed_timing.refresh_rate().lround() == expected_timings.refresh_rate);
|
||||
detailed_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(detailed_timings_found == expected_detailed_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr u8 expected_vic_ids[] = { 125, 101, 96, 89, 31 };
|
||||
static constexpr size_t expected_vic_ids_count = sizeof(expected_vic_ids) / sizeof(expected_vic_ids[0]);
|
||||
size_t vic_ids_found = 0;
|
||||
auto result = edid.for_each_short_video_descriptor([&](unsigned block_id, bool is_native, EDID::VIC::Details const& vic) {
|
||||
EXPECT(vic_ids_found < expected_vic_ids_count);
|
||||
EXPECT(block_id == 1);
|
||||
EXPECT(!is_native); // none are marked as native
|
||||
EXPECT(vic.vic_id == expected_vic_ids[vic_ids_found]);
|
||||
vic_ids_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(vic_ids_found == expected_vic_ids_count);
|
||||
}
|
||||
|
||||
{
|
||||
// This edid has one CEA861 extension block only
|
||||
size_t extension_blocks_found = 0;
|
||||
auto result = edid.for_each_extension_block([&](unsigned block_id, u8 tag, u8 revision, ReadonlyBytes) {
|
||||
EXPECT(block_id == 1);
|
||||
EXPECT(tag == 0x2);
|
||||
EXPECT(revision == 3);
|
||||
extension_blocks_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(extension_blocks_found == 1);
|
||||
}
|
||||
}
|
||||
|
||||
static const u8 edid2_bin[] = {
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x04, 0x72, 0x1d, 0x08,
|
||||
0xd2, 0x02, 0x96, 0x49, 0x20, 0x1e, 0x01, 0x04, 0xb5, 0x3c, 0x22, 0x78,
|
||||
0x3b, 0xff, 0x15, 0xa6, 0x53, 0x4a, 0x98, 0x26, 0x0f, 0x50, 0x54, 0xbf,
|
||||
0xef, 0x80, 0xd1, 0xc0, 0xb3, 0x00, 0x95, 0x00, 0x81, 0x80, 0x81, 0x40,
|
||||
0x81, 0xc0, 0x01, 0x01, 0x01, 0x01, 0x86, 0x6f, 0x00, 0x3c, 0xa0, 0xa0,
|
||||
0x0f, 0x50, 0x08, 0x20, 0x35, 0x00, 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e,
|
||||
0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0, 0x29, 0x50, 0x30, 0x20, 0x35, 0x00,
|
||||
0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x30,
|
||||
0x4b, 0x78, 0x78, 0x1e, 0x01, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x00, 0x00, 0x00, 0xfc, 0x00, 0x43, 0x42, 0x32, 0x37, 0x32, 0x55, 0x0a,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0xc5, 0x02, 0x03, 0x33, 0x71,
|
||||
0x4c, 0x12, 0x13, 0x04, 0x1f, 0x90, 0x14, 0x05, 0x01, 0x11, 0x02, 0x03,
|
||||
0x4a, 0x23, 0x09, 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0xe2, 0x00, 0xc0,
|
||||
0x67, 0x03, 0x0c, 0x00, 0x10, 0x00, 0x38, 0x3c, 0xe3, 0x05, 0xe3, 0x01,
|
||||
0xe3, 0x0f, 0x00, 0x00, 0xe6, 0x06, 0x07, 0x01, 0x60, 0x60, 0x45, 0x01,
|
||||
0x1d, 0x00, 0x72, 0x51, 0xd0, 0x1e, 0x20, 0x6e, 0x28, 0x55, 0x00, 0x55,
|
||||
0x50, 0x21, 0x00, 0x00, 0x1e, 0x01, 0x1d, 0x00, 0xbc, 0x52, 0xd0, 0x1e,
|
||||
0x20, 0xb8, 0x28, 0x55, 0x40, 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0x56,
|
||||
0x5e, 0x00, 0xa0, 0xa0, 0xa0, 0x29, 0x50, 0x30, 0x20, 0x35, 0x00, 0x55,
|
||||
0x50, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xe1
|
||||
};
|
||||
|
||||
TEST_CASE(edid2)
|
||||
{
|
||||
auto edid_load_result = EDID::Parser::from_bytes({ edid2_bin, sizeof(edid2_bin) });
|
||||
EXPECT(!edid_load_result.is_error());
|
||||
auto edid = edid_load_result.release_value();
|
||||
EXPECT(edid.legacy_manufacturer_id() == "ACR");
|
||||
EXPECT(edid.serial_number() == 1234567890);
|
||||
auto digital_interface = edid.digital_display();
|
||||
EXPECT(digital_interface.has_value());
|
||||
EXPECT(digital_interface.value().color_bit_depth() == EDID::Parser::DigitalDisplay::ColorBitDepth::BPP_10);
|
||||
EXPECT(digital_interface.value().supported_interface() == EDID::Parser::DigitalDisplay::SupportedInterface::DisplayPort);
|
||||
EXPECT(!digital_interface.value().features().supports_standby());
|
||||
EXPECT(!digital_interface.value().features().supports_suspend());
|
||||
EXPECT(digital_interface.value().features().supports_off());
|
||||
EXPECT(digital_interface.value().features().preferred_timing_mode_includes_pixel_format_and_refresh_rate());
|
||||
EXPECT(!digital_interface.value().features().srgb_is_default_color_space());
|
||||
EXPECT(digital_interface.value().features().frequency() == EDID::Parser::DigitalDisplayFeatures::Frequency::Continuous);
|
||||
EXPECT(digital_interface.value().features().supported_color_encodings() == EDID::Parser::DigitalDisplayFeatures::SupportedColorEncodings::RGB444_YCrCb444_YCrCb422);
|
||||
EXPECT(!edid.aspect_ratio().has_value());
|
||||
auto screen_size = edid.screen_size();
|
||||
EXPECT(screen_size.has_value());
|
||||
EXPECT(screen_size.value().horizontal_cm() == 60);
|
||||
EXPECT(screen_size.value().vertical_cm() == 34);
|
||||
auto gamma = edid.gamma();
|
||||
EXPECT(gamma.has_value());
|
||||
EXPECT(gamma.value() >= 2.19f && gamma.value() <= 2.21f);
|
||||
EXPECT(edid.display_product_name() == "CB272U");
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
EDID::Parser::EstablishedTiming::Source source;
|
||||
u8 dmt_id { 0 };
|
||||
} expected_established_timings[] = {
|
||||
{ 720, 400, 70, EDID::Parser::EstablishedTiming::Source::IBM },
|
||||
{ 640, 480, 60, EDID::Parser::EstablishedTiming::Source::IBM, 0x4 },
|
||||
{ 640, 480, 67, EDID::Parser::EstablishedTiming::Source::Apple },
|
||||
{ 640, 480, 73, EDID::Parser::EstablishedTiming::Source::VESA, 0x5 },
|
||||
{ 640, 480, 75, EDID::Parser::EstablishedTiming::Source::VESA, 0x6 },
|
||||
{ 800, 600, 56, EDID::Parser::EstablishedTiming::Source::VESA, 0x8 },
|
||||
{ 800, 600, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x9 },
|
||||
{ 800, 600, 72, EDID::Parser::EstablishedTiming::Source::VESA, 0xa },
|
||||
{ 800, 600, 75, EDID::Parser::EstablishedTiming::Source::VESA, 0xb },
|
||||
{ 832, 624, 75, EDID::Parser::EstablishedTiming::Source::Apple },
|
||||
{ 1024, 768, 60, EDID::Parser::EstablishedTiming::Source::VESA, 0x10 },
|
||||
{ 1024, 768, 70, EDID::Parser::EstablishedTiming::Source::VESA, 0x11 },
|
||||
{ 1024, 768, 75, EDID::Parser::EstablishedTiming::Source::VESA, 0x12 },
|
||||
{ 1280, 1024, 75, EDID::Parser::EstablishedTiming::Source::VESA, 0x24 },
|
||||
{ 1152, 870, 75, EDID::Parser::EstablishedTiming::Source::Apple }
|
||||
};
|
||||
static constexpr size_t expected_established_timings_count = sizeof(expected_established_timings) / sizeof(expected_established_timings[0]);
|
||||
size_t established_timings_found = 0;
|
||||
auto result = edid.for_each_established_timing([&](auto& established_timings) {
|
||||
EXPECT(established_timings_found < expected_established_timings_count);
|
||||
auto& expected_timings = expected_established_timings[established_timings_found];
|
||||
EXPECT(established_timings.width() == expected_timings.width);
|
||||
EXPECT(established_timings.height() == expected_timings.height);
|
||||
EXPECT(established_timings.refresh_rate() == expected_timings.refresh_rate);
|
||||
EXPECT(established_timings.source() == expected_timings.source);
|
||||
EXPECT(established_timings.dmt_id() == expected_timings.dmt_id);
|
||||
established_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(established_timings_found == expected_established_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
u8 dmt_id { 0 };
|
||||
} expected_standard_established_timings[] = {
|
||||
{ 1920, 1080, 60, 0x52 },
|
||||
{ 1680, 1050, 60, 0x3a },
|
||||
{ 1440, 900, 60, 0x2f },
|
||||
{ 1280, 1024, 60, 0x23 },
|
||||
{ 1280, 960, 60, 0x20 },
|
||||
{ 1280, 720, 60, 0x55 },
|
||||
};
|
||||
static constexpr size_t expected_standard_timings_count = sizeof(expected_standard_established_timings) / sizeof(expected_standard_established_timings[0]);
|
||||
size_t standard_timings_found = 0;
|
||||
auto result = edid.for_each_standard_timing([&](auto& standard_timings) {
|
||||
EXPECT(standard_timings_found < expected_standard_timings_count);
|
||||
auto& expected_timings = expected_standard_established_timings[standard_timings_found];
|
||||
EXPECT(standard_timings.dmt_id() == expected_timings.dmt_id);
|
||||
EXPECT(standard_timings.width() == expected_timings.width);
|
||||
EXPECT(standard_timings.height() == expected_timings.height);
|
||||
EXPECT(standard_timings.refresh_rate() == expected_timings.refresh_rate);
|
||||
standard_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(standard_timings_found == expected_standard_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr struct {
|
||||
unsigned block_id;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned refresh_rate;
|
||||
} expected_detailed_timings[] = {
|
||||
{ 0, 2560, 1440, 75 },
|
||||
{ 0, 2560, 1440, 60 },
|
||||
{ 1, 1280, 720, 60 },
|
||||
{ 1, 1280, 720, 50 },
|
||||
{ 1, 2560, 1440, 60 }
|
||||
};
|
||||
static constexpr size_t expected_detailed_timings_count = sizeof(expected_detailed_timings) / sizeof(expected_detailed_timings[0]);
|
||||
size_t detailed_timings_found = 0;
|
||||
auto result = edid.for_each_detailed_timing([&](auto& detailed_timing, unsigned block_id) {
|
||||
EXPECT(detailed_timings_found < expected_detailed_timings_count);
|
||||
auto& expected_timings = expected_detailed_timings[detailed_timings_found];
|
||||
EXPECT(block_id == expected_timings.block_id);
|
||||
EXPECT(detailed_timing.horizontal_addressable_pixels() == expected_timings.width);
|
||||
EXPECT(detailed_timing.vertical_addressable_lines() == expected_timings.height);
|
||||
EXPECT(detailed_timing.refresh_rate().lround() == expected_timings.refresh_rate);
|
||||
detailed_timings_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(detailed_timings_found == expected_detailed_timings_count);
|
||||
}
|
||||
|
||||
{
|
||||
static constexpr u8 expected_vic_ids[] = { 18, 19, 4, 31, 16, 20, 5, 1, 17, 2, 3, 74 };
|
||||
static constexpr size_t expected_vic_ids_count = sizeof(expected_vic_ids) / sizeof(expected_vic_ids[0]);
|
||||
size_t vic_ids_found = 0;
|
||||
auto result = edid.for_each_short_video_descriptor([&](unsigned block_id, bool is_native, EDID::VIC::Details const& vic) {
|
||||
EXPECT(vic_ids_found < expected_vic_ids_count);
|
||||
EXPECT(block_id == 1);
|
||||
EXPECT(is_native == (vic_ids_found == 4)); // the 5th value is marked native
|
||||
EXPECT(vic.vic_id == expected_vic_ids[vic_ids_found]);
|
||||
vic_ids_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(vic_ids_found == expected_vic_ids_count);
|
||||
}
|
||||
|
||||
{
|
||||
// This edid has one CEA861 extension block only
|
||||
size_t extension_blocks_found = 0;
|
||||
auto result = edid.for_each_extension_block([&](unsigned block_id, u8 tag, u8 revision, ReadonlyBytes) {
|
||||
EXPECT(block_id == 1);
|
||||
EXPECT(tag == 0x2);
|
||||
EXPECT(revision == 3);
|
||||
extension_blocks_found++;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
EXPECT(!result.is_error());
|
||||
EXPECT(result.value() == IterationDecision::Continue);
|
||||
EXPECT(extension_blocks_found == 1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(dmt_find_std_id)
|
||||
{
|
||||
auto* dmt = EDID::DMT::find_timing_by_std_id(0xd1, 0xf);
|
||||
EXPECT(dmt);
|
||||
EXPECT(dmt->dmt_id == 0x46);
|
||||
EXPECT(dmt->horizontal_pixels == 1920 && dmt->vertical_lines == 1200);
|
||||
}
|
||||
|
||||
TEST_CASE(dmt_frequency)
|
||||
{
|
||||
auto* dmt = EDID::DMT::find_timing_by_dmt_id(0x4);
|
||||
EXPECT(dmt);
|
||||
static constexpr FixedPoint<16, u32> expected_vertical_frequency(59.940);
|
||||
EXPECT(dmt->vertical_frequency_hz() == expected_vertical_frequency);
|
||||
static constexpr FixedPoint<16, u32> expected_horizontal_frequency(31.469);
|
||||
EXPECT(dmt->horizontal_frequency_khz() == expected_horizontal_frequency);
|
||||
}
|
||||
|
||||
TEST_CASE(vic)
|
||||
{
|
||||
EXPECT(!EDID::VIC::find_details_by_vic_id(0)); // invalid
|
||||
EXPECT(!EDID::VIC::find_details_by_vic_id(160)); // forbidden range
|
||||
EXPECT(!EDID::VIC::find_details_by_vic_id(250)); // reserved
|
||||
auto* vic_def_32 = EDID::VIC::find_details_by_vic_id(32);
|
||||
EXPECT(vic_def_32);
|
||||
EXPECT(vic_def_32->vic_id == 32);
|
||||
auto* vic_def_200 = EDID::VIC::find_details_by_vic_id(200);
|
||||
EXPECT(vic_def_200);
|
||||
EXPECT(vic_def_200->vic_id == 200);
|
||||
|
||||
for (unsigned vic_id = 0; vic_id <= 0xff; vic_id++) {
|
||||
auto* vic_def = EDID::VIC::find_details_by_vic_id((u8)vic_id);
|
||||
if (vic_def) {
|
||||
EXPECT((vic_id >= 1 && vic_id <= 127) || (vic_id >= 193 && vic_id <= 219));
|
||||
EXPECT(vic_def->vic_id == vic_id);
|
||||
} else {
|
||||
EXPECT(vic_id == 0 || (vic_id >= 128 && vic_id <= 192) || (vic_id >= 220));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ add_subdirectory(LibDeviceTree)
|
|||
add_subdirectory(LibDiff)
|
||||
add_subdirectory(LibDl)
|
||||
add_subdirectory(LibDSP)
|
||||
add_subdirectory(LibEDID)
|
||||
add_subdirectory(LibELF)
|
||||
add_subdirectory(LibFileSystemAccessClient)
|
||||
add_subdirectory(LibGemini)
|
||||
|
|
8
Userland/Libraries/LibEDID/CMakeLists.txt
Normal file
8
Userland/Libraries/LibEDID/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
set(SOURCES
|
||||
DMT.cpp
|
||||
EDID.cpp
|
||||
VIC.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibEDID edid)
|
||||
target_link_libraries(LibEDID LibC)
|
163
Userland/Libraries/LibEDID/DMT.cpp
Normal file
163
Userland/Libraries/LibEDID/DMT.cpp
Normal file
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibEDID/DMT.h>
|
||||
|
||||
namespace EDID {
|
||||
|
||||
// Monitor timings as per Display Monitor Timing Standard (DMT) 1.0 rev 13
|
||||
static constexpr DMT::MonitorTiming s_monitor_timings[] = {
|
||||
{ 0x1, {}, 8, 640, 350, 37861, 85080, 31500, 32, 32, 192, 95, 64, 3 },
|
||||
{ 0x2, { 0x31, 0x19 }, 8, 640, 400, 37861, 85080, 31500, 32, 1, 192, 45, 64, 3 },
|
||||
{ 0x3, {}, 9, 720, 400, 37927, 85039, 35500, 36, 1, 216, 46, 72, 3 },
|
||||
{ 0x4, { 0x31, 0x40 }, 8, 640, 480, 31469, 59940, 25175, 8, 2, 144, 29, 96, 2 },
|
||||
{ 0x5, { 0x31, 0x4c }, 8, 640, 480, 37861, 72809, 31500, 16, 1, 176, 24, 40, 3 },
|
||||
{ 0x6, { 0x31, 0x4f }, 8, 640, 480, 37500, 75000, 31500, 16, 1, 200, 20, 64, 3 },
|
||||
{ 0x7, { 0x31, 0x59 }, 8, 640, 480, 43269, 85008, 36000, 56, 1, 192, 29, 56, 3 },
|
||||
{ 0x8, {}, 8, 800, 600, 35156, 56250, 36000, 24, 1, 224, 25, 72, 2 },
|
||||
{ 0x9, { 0x45, 0x40 }, 8, 800, 600, 37879, 60317, 40000, 40, 1, 256, 28, 128, 4 },
|
||||
{ 0xa, { 0x45, 0x4c }, 8, 800, 600, 48077, 72188, 50000, 56, 37, 240, 66, 120, 6 },
|
||||
{ 0xb, { 0x45, 0x4f }, 8, 800, 600, 46875, 75000, 49500, 16, 1, 256, 25, 80, 3 },
|
||||
{ 0xc, { 0x45, 0x59 }, 8, 800, 600, 53674, 85061, 56250, 32, 1, 248, 31, 64, 3 },
|
||||
{ 0xd, {}, 8, 800, 600, 76302, 119972, 73250, 48, 3, 160, 36, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0xe, {}, 8, 848, 480, 31020, 60000, 33750, 16, 6, 240, 37, 112, 8 },
|
||||
{ 0xf, {}, 8, 1024, 768, 35522, 86957, 44900, 8, 0, 240, 24, 176, 4, DMT::MonitorTiming::CVTCompliance::NotCompliant, {}, DMT::MonitorTiming::ScanType::Interlaced },
|
||||
{ 0x10, { 0x61, 0x40 }, 8, 1024, 768, 48363, 60004, 65000, 24, 3, 320, 38, 136, 6 },
|
||||
{ 0x11, { 0x61, 0x4a }, 8, 1024, 768, 56476, 70069, 75000, 24, 3, 304, 38, 136, 6 },
|
||||
{ 0x12, { 0x61, 0x4f }, 8, 1024, 768, 60023, 75029, 78750, 16, 1, 288, 32, 96, 3 },
|
||||
{ 0x13, { 0x61, 0x59 }, 8, 1024, 768, 68677, 84997, 94500, 48, 1, 352, 40, 96, 3 },
|
||||
{ 0x14, {}, 8, 1024, 768, 97551, 119989, 115500, 48, 3, 160, 45, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x15, { 0x71, 0x4f }, 8, 1152, 864, 67500, 75000, 108000, 64, 1, 448, 36, 128, 3 },
|
||||
{ 0x55, { 0x81, 0xc0 }, 1, 1280, 720, 45000, 60000, 74250, 110, 5, 370, 30, 40, 5 },
|
||||
{ 0x16, {}, 8, 1280, 768, 47396, 59995, 68250, 48, 3, 160, 22, 32, 7, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0x7f, 0x1c, 0x22 } },
|
||||
{ 0x17, {}, 8, 1280, 768, 47776, 59870, 79500, 64, 3, 384, 30, 128, 7, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x7f, 0x1c, 0x28 } },
|
||||
{ 0x18, {}, 8, 1280, 768, 60289, 74893, 102250, 80, 3, 416, 37, 128, 7, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x7f, 0x1c, 0x44 } },
|
||||
{ 0x19, {}, 8, 1280, 768, 68633, 84837, 117500, 80, 3, 432, 41, 136, 7, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x7f, 0x1c, 0x62 } },
|
||||
{ 0x1a, {}, 8, 1280, 768, 97396, 119798, 140250, 48, 3, 160, 45, 32, 7, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x1b, {}, 8, 1280, 800, 49306, 59910, 71000, 48, 3, 160, 23, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0x8f, 0x18, 0x21 } },
|
||||
{ 0x1c, { 0x81, 0x0 }, 8, 1280, 800, 49702, 59810, 83500, 72, 3, 400, 31, 128, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x8f, 0x18, 0x28 } },
|
||||
{ 0x1d, { 0x81, 0xf }, 8, 1280, 800, 62795, 74934, 106500, 80, 3, 416, 38, 128, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x8f, 0x18, 0x44 } },
|
||||
{ 0x1e, { 0x81, 0x19 }, 8, 1280, 800, 71554, 84880, 122500, 80, 3, 432, 43, 136, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x8f, 0x18, 0x62 } },
|
||||
{ 0x1f, {}, 8, 1280, 800, 101563, 119909, 146250, 48, 3, 160, 47, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x20, { 0x81, 0x40 }, 8, 1280, 960, 60000, 60000, 108000, 96, 1, 520, 40, 112, 3 },
|
||||
{ 0x21, { 0x81, 0x59 }, 8, 1280, 960, 85938, 85002, 148500, 64, 1, 448, 3, 160, 3 },
|
||||
{ 0x22, {}, 8, 1280, 960, 121875, 119838, 175500, 48, 3, 160, 57, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x23, { 0x81, 0x80 }, 8, 1280, 1024, 63981, 60020, 108000, 48, 1, 408, 42, 112, 3 },
|
||||
{ 0x24, { 0x81, 0x8f }, 8, 1280, 1024, 79976, 75025, 135000, 16, 1, 408, 42, 144, 3 },
|
||||
{ 0x25, { 0x81, 0x99 }, 8, 1280, 1024, 91146, 85024, 157500, 64, 1, 448, 48, 160, 3 },
|
||||
{ 0x26, {}, 8, 1280, 1024, 130035, 119958, 187250, 48, 3, 160, 60, 32, 7, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x27, {}, 8, 1360, 768, 47712, 60015, 85500, 64, 3, 432, 27, 112, 6 },
|
||||
{ 0x28, {}, 8, 1360, 768, 97533, 119967, 148250, 48, 5, 160, 45, 32, 5, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x51, {}, 1, 1366, 768, 57712, 59790, 85500, 70, 3, 426, 30, 143, 3 },
|
||||
{ 0x56, {}, 1, 1366, 768, 48000, 60000, 72000, 14, 1, 134, 32, 56, 3 },
|
||||
{ 0x29, {}, 8, 1400, 1050, 64744, 59948, 101000, 48, 3, 160, 30, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0x0c, 0x20, 0x21 } },
|
||||
{ 0x2a, { 0x90, 0x40 }, 8, 1400, 1050, 65317, 59978, 121750, 88, 3, 464, 39, 144, 4, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x20, 0x28 } },
|
||||
{ 0x2b, { 0x90, 0x4f }, 8, 1400, 1050, 82278, 74867, 156000, 104, 3, 496, 49, 144, 4, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x20, 0x44 } },
|
||||
{ 0x2c, { 0x90, 0x59 }, 8, 1400, 1050, 93881, 84960, 179500, 104, 3, 512, 55, 152, 4, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x20, 0x62 } },
|
||||
{ 0x2d, {}, 8, 1400, 1050, 133333, 119904, 208000, 48, 3, 160, 62, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x2e, {}, 8, 1440, 900, 55469, 59901, 88750, 48, 3, 160, 26, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0xc1, 0x18, 0x21 } },
|
||||
{ 0x2f, { 0x95, 0x0 }, 8, 1440, 900, 55935, 59887, 106500, 80, 3, 464, 34, 152, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0xc1, 0x18, 0x28 } },
|
||||
{ 0x30, { 0x95, 0xf }, 8, 1440, 900, 70635, 74984, 136750, 96, 3, 496, 42, 152, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0xc1, 0x18, 0x44 } },
|
||||
{ 0x31, { 0x95, 0x19 }, 8, 1440, 900, 80430, 84842, 157000, 104, 3, 512, 48, 152, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0xc1, 0x18, 0x68 } },
|
||||
{ 0x32, {}, 8, 1440, 900, 114219, 119852, 182750, 48, 3, 160, 53, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x53, { 0xa9, 0xc0 }, 8, 1600, 900, 60000, 60000, 108000, 24, 1, 200, 100, 80, 3 },
|
||||
{ 0x33, { 0xa9, 0x40 }, 8, 1600, 1200, 75000, 60000, 162000, 64, 1, 560, 50, 192, 3 },
|
||||
{ 0x34, { 0xa9, 0x45 }, 8, 1600, 1200, 81250, 65000, 175500, 64, 1, 560, 50, 192, 3 },
|
||||
{ 0x35, { 0xa9, 0x4a }, 8, 1600, 1200, 87500, 70000, 189000, 64, 1, 560, 50, 192, 3 },
|
||||
{ 0x36, { 0xa9, 0x4f }, 8, 1600, 1200, 93750, 75000, 202500, 64, 1, 560, 50, 192, 3 },
|
||||
{ 0x37, { 0xa9, 0x59 }, 8, 1600, 1200, 106250, 85000, 229500, 64, 1, 560, 50, 192, 3 },
|
||||
{ 0x38, {}, 8, 1600, 1200, 152415, 119917, 268250, 48, 3, 160, 71, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x39, {}, 8, 1680, 1050, 64674, 59883, 119000, 48, 3, 160, 30, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0x0c, 0x28, 0x21 } },
|
||||
{ 0x3a, { 0xb3, 0x0 }, 8, 1680, 1050, 65290, 59954, 146250, 104, 3, 560, 39, 176, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x28, 0x28 } },
|
||||
{ 0x3b, { 0xb3, 0xf }, 8, 1680, 1050, 82306, 74892, 187000, 120, 3, 592, 49, 176, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x28, 0x44 } },
|
||||
{ 0x3c, { 0xb3, 0x19 }, 8, 1680, 1050, 93859, 84941, 214750, 128, 3, 608, 55, 176, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x0c, 0x28, 0x68 } },
|
||||
{ 0x3d, {}, 8, 1680, 1050, 133424, 119986, 245500, 48, 3, 160, 62, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x3e, { 0xc1, 0x40 }, 8, 1792, 1344, 83640, 60000, 204750, 128, 1, 656, 50, 200, 3 },
|
||||
{ 0x3f, { 0xc1, 0x4f }, 8, 1792, 1344, 106270, 74997, 261000, 96, 1, 664, 73, 216, 3 },
|
||||
{ 0x40, {}, 8, 1792, 1344, 170722, 119974, 333250, 48, 3, 160, 79, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x41, { 0xc9, 0x40 }, 8, 1856, 1392, 86333, 59995, 218250, 96, 1, 672, 47, 224, 3 },
|
||||
{ 0x42, { 0xc9, 0x4f }, 8, 1856, 1392, 112500, 75000, 288000, 128, 1, 704, 108, 224, 3 },
|
||||
{ 0x43, {}, 8, 1856, 1392, 176835, 119970, 356500, 48, 3, 160, 82, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x52, { 0xd1, 0xc0 }, 4, 1920, 1080, 67500, 60000, 148500, 88, 4, 280, 45, 44, 5 },
|
||||
{ 0x44, {}, 8, 1920, 1200, 74038, 59950, 154000, 48, 3, 160, 35, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking, { 0x57, 0x28, 0x21 } },
|
||||
{ 0x45, { 0xd1, 0x0 }, 8, 1920, 1200, 74556, 59885, 193250, 136, 3, 672, 45, 200, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x57, 0x28, 0x28 } },
|
||||
{ 0x46, { 0xd1, 0xf }, 8, 1920, 1200, 94038, 74930, 245250, 136, 3, 688, 55, 208, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x57, 0x28, 0x44 } },
|
||||
{ 0x47, { 0xd1, 0x19 }, 8, 1920, 1200, 107184, 84932, 281250, 144, 3, 704, 62, 208, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x57, 0x28, 0x62 } },
|
||||
{ 0x48, {}, 8, 1920, 1200, 152404, 119909, 317000, 48, 3, 160, 71, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x49, { 0xd1, 0x40 }, 8, 1920, 1440, 90000, 60000, 234000, 128, 1, 680, 60, 208, 3 },
|
||||
{ 0x4a, { 0xd1, 0x4f }, 8, 1920, 1440, 112500, 75000, 297000, 144, 1, 720, 60, 224, 3 },
|
||||
{ 0x4b, {}, 8, 1920, 1440, 182933, 119956, 380500, 48, 3, 160, 85, 32, 4, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x54, { 0xe1, 0xc0 }, 1, 2048, 1152, 72000, 60000, 162000, 26, 1, 202, 48, 80, 3 },
|
||||
{ 0x4c, {}, 8, 2560, 1600, 98713, 59972, 268500, 48, 3, 160, 46, 32, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x1f, 0x38, 0x21 } },
|
||||
{ 0x4d, {}, 8, 2650, 1600, 99458, 59987, 348500, 192, 3, 944, 58, 280, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x1f, 0x38, 0x28 } },
|
||||
{ 0x4e, {}, 8, 2560, 1600, 125354, 74972, 443250, 208, 3, 976, 72, 280, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x1f, 0x38, 0x44 } },
|
||||
{ 0x4f, {}, 8, 2560, 1600, 142887, 84951, 505250, 208, 3, 976, 82, 280, 6, DMT::MonitorTiming::CVTCompliance::Compliant, { 0x1f, 0x38, 0x62 } },
|
||||
{ 0x50, {}, 8, 2560, 1600, 203217, 119963, 552750, 48, 3, 160, 94, 32, 6, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlanking },
|
||||
{ 0x57, {}, 1, 4096, 2160, 133320, 60000, 556744, 8, 48, 80, 62, 32, 8, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlankingV2 },
|
||||
{ 0x58, {}, 1, 4096, 2160, 133187, 59940, 556188, 8, 48, 80, 62, 32, 8, DMT::MonitorTiming::CVTCompliance::CompliantReducedBlankingV2 },
|
||||
};
|
||||
|
||||
FixedPoint<16, u32> DMT::MonitorTiming::horizontal_frequency_khz() const
|
||||
{
|
||||
return FixedPoint<16, u32>(horizontal_frequency_hz) / 1000;
|
||||
}
|
||||
|
||||
FixedPoint<16, u32> DMT::MonitorTiming::vertical_frequency_hz() const
|
||||
{
|
||||
return FixedPoint<16, u32>(vertical_frequency_millihz) / 1000;
|
||||
}
|
||||
|
||||
u32 DMT::MonitorTiming::refresh_rate_hz() const
|
||||
{
|
||||
return vertical_frequency_hz().ltrunk();
|
||||
}
|
||||
|
||||
String DMT::MonitorTiming::name() const
|
||||
{
|
||||
if (scan_type == ScanType::Interlaced)
|
||||
return String::formatted("{} x {} @ {}Hz (Interlaced)", horizontal_pixels, vertical_lines, refresh_rate_hz());
|
||||
return String::formatted("{} x {} @ {}Hz", horizontal_pixels, vertical_lines, refresh_rate_hz());
|
||||
}
|
||||
|
||||
auto DMT::find_timing_by_dmt_id(u8 dmt_id) -> MonitorTiming const*
|
||||
{
|
||||
if (dmt_id == 0)
|
||||
return nullptr;
|
||||
|
||||
for (auto& monitor_timing : s_monitor_timings) {
|
||||
if (monitor_timing.dmt_id == dmt_id)
|
||||
return &monitor_timing;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto DMT::find_timing_by_std_id(u8 std_id_byte1, u8 std_id_byte2) -> MonitorTiming const*
|
||||
{
|
||||
for (auto& monitor_timing : s_monitor_timings) {
|
||||
if (!monitor_timing.has_std())
|
||||
continue;
|
||||
if (monitor_timing.std_bytes[0] == std_id_byte1 && monitor_timing.std_bytes[1] == std_id_byte2)
|
||||
return &monitor_timing;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto DMT::find_timing_by_cvt(CVT cvt) -> MonitorTiming const*
|
||||
{
|
||||
for (auto& monitor_timing : s_monitor_timings) {
|
||||
if (!monitor_timing.has_cvt())
|
||||
continue;
|
||||
if (monitor_timing.cvt_bytes[0] == cvt.bytes[0] && monitor_timing.cvt_bytes[1] == cvt.bytes[1] && monitor_timing.cvt_bytes[2] == cvt.bytes[2])
|
||||
return &monitor_timing;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
64
Userland/Libraries/LibEDID/DMT.h
Normal file
64
Userland/Libraries/LibEDID/DMT.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedPoint.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace EDID {
|
||||
|
||||
class DMT final {
|
||||
public:
|
||||
struct CVT {
|
||||
u8 bytes[3];
|
||||
};
|
||||
struct MonitorTiming {
|
||||
enum class ScanType : u8 {
|
||||
NonInterlaced,
|
||||
Interlaced
|
||||
};
|
||||
enum class CVTCompliance : u8 {
|
||||
NotCompliant,
|
||||
Compliant,
|
||||
CompliantReducedBlanking,
|
||||
CompliantReducedBlankingV2,
|
||||
};
|
||||
|
||||
u8 dmt_id;
|
||||
u8 std_bytes[2];
|
||||
u8 char_width_pixels;
|
||||
u16 horizontal_pixels;
|
||||
u16 vertical_lines;
|
||||
u32 horizontal_frequency_hz;
|
||||
u32 vertical_frequency_millihz;
|
||||
u32 pixel_clock_khz;
|
||||
u8 horizontal_front_porch_pixels;
|
||||
u8 vertical_front_porch_lines;
|
||||
u16 horizontal_blank_pixels;
|
||||
u16 vertical_blank_lines;
|
||||
u16 horizontal_sync_time_pixels;
|
||||
u8 vertical_sync_time_lines;
|
||||
CVTCompliance cvt_compliance { CVTCompliance::NotCompliant };
|
||||
u8 cvt_bytes[3] {};
|
||||
ScanType scan_type { ScanType::NonInterlaced };
|
||||
|
||||
ALWAYS_INLINE bool has_std() const { return std_bytes[0] != 0; }
|
||||
ALWAYS_INLINE bool has_cvt() const { return cvt_bytes[0] != 0; }
|
||||
|
||||
FixedPoint<16, u32> horizontal_frequency_khz() const;
|
||||
FixedPoint<16, u32> vertical_frequency_hz() const;
|
||||
u32 refresh_rate_hz() const;
|
||||
String name() const;
|
||||
};
|
||||
|
||||
static MonitorTiming const* find_timing_by_dmt_id(u8);
|
||||
static MonitorTiming const* find_timing_by_std_id(u8, u8);
|
||||
static MonitorTiming const* find_timing_by_cvt(CVT);
|
||||
};
|
||||
|
||||
}
|
1190
Userland/Libraries/LibEDID/EDID.cpp
Normal file
1190
Userland/Libraries/LibEDID/EDID.cpp
Normal file
File diff suppressed because it is too large
Load diff
436
Userland/Libraries/LibEDID/EDID.h
Normal file
436
Userland/Libraries/LibEDID/EDID.h
Normal file
|
@ -0,0 +1,436 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteReader.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/FixedPoint.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibEDID/DMT.h>
|
||||
#include <LibEDID/VIC.h>
|
||||
|
||||
namespace EDID {
|
||||
|
||||
namespace Definitions {
|
||||
struct EDID;
|
||||
struct DetailedTiming;
|
||||
struct DisplayDescriptor;
|
||||
struct ExtensionBlock;
|
||||
}
|
||||
|
||||
class Parser final {
|
||||
friend class CEA861ExtensionBlock;
|
||||
|
||||
public:
|
||||
static constexpr size_t BufferSize = 128;
|
||||
using RawBytes = unsigned char[BufferSize];
|
||||
|
||||
protected:
|
||||
class DisplayFeatures {
|
||||
public:
|
||||
bool supports_standby() const { return (m_features & (1 << 7)) != 0; }
|
||||
bool supports_suspend() const { return (m_features & (1 << 6)) != 0; }
|
||||
bool supports_off() const { return (m_features & (1 << 5)) != 0; }
|
||||
|
||||
bool preferred_timing_mode_includes_pixel_format_and_refresh_rate() const
|
||||
{
|
||||
if (m_edid_revision < 4)
|
||||
return true; // Bit 1 must be set to 1
|
||||
return (m_features & (1 << 1)) != 0;
|
||||
}
|
||||
|
||||
bool srgb_is_default_color_space() const { return (m_features & (1 << 2)) != 0; }
|
||||
|
||||
enum class Frequency : u8 {
|
||||
Continuous,
|
||||
NonContinuous,
|
||||
DefaultGTF,
|
||||
VESA_DMT
|
||||
};
|
||||
Frequency frequency() const
|
||||
{
|
||||
if (m_edid_revision < 4)
|
||||
return ((m_features & 1) != 0) ? Frequency::DefaultGTF : Frequency::VESA_DMT;
|
||||
return ((m_features & 1) != 0) ? Frequency::Continuous : Frequency::NonContinuous;
|
||||
}
|
||||
|
||||
protected:
|
||||
DisplayFeatures(u8 features, u8 edid_revision)
|
||||
: m_features(features)
|
||||
, m_edid_revision(edid_revision)
|
||||
{
|
||||
}
|
||||
|
||||
u8 m_features { 0 };
|
||||
u8 m_edid_revision { 0 };
|
||||
};
|
||||
|
||||
public:
|
||||
static ErrorOr<Parser> from_bytes(ReadonlyBytes);
|
||||
static ErrorOr<Parser> from_bytes(ByteBuffer&&);
|
||||
|
||||
String legacy_manufacturer_id() const;
|
||||
u16 product_code() const;
|
||||
u32 serial_number() const;
|
||||
|
||||
class DigitalDisplayFeatures final : public DisplayFeatures {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class SupportedColorEncodings : u8 {
|
||||
RGB444,
|
||||
RGB444_YCrCb444,
|
||||
RGB444_YCrCb422,
|
||||
RGB444_YCrCb444_YCrCb422
|
||||
};
|
||||
|
||||
SupportedColorEncodings supported_color_encodings() const { return (SupportedColorEncodings)((m_features >> 3) & 3); }
|
||||
|
||||
private:
|
||||
DigitalDisplayFeatures(u8 features, u8 edid_revision)
|
||||
: DisplayFeatures(features, edid_revision)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class AnalogDisplayFeatures final : public DisplayFeatures {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class DisplayColorType : u8 {
|
||||
MonochromeOrGrayscale,
|
||||
RGB,
|
||||
NonRGB,
|
||||
Undefined
|
||||
};
|
||||
|
||||
DisplayColorType display_color_type() const { return (DisplayColorType)((m_features >> 3) & 3); }
|
||||
|
||||
private:
|
||||
AnalogDisplayFeatures(u8 features, u8 edid_revision)
|
||||
: DisplayFeatures(features, edid_revision)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class DigitalDisplay final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class ColorBitDepth : u8 {
|
||||
Undefined = 0,
|
||||
BPP_6,
|
||||
BPP_8,
|
||||
BPP_10,
|
||||
BPP_12,
|
||||
BPP_14,
|
||||
BPP_16,
|
||||
Reserved
|
||||
};
|
||||
enum class SupportedInterface : u8 {
|
||||
Undefined = 0,
|
||||
DVI,
|
||||
HDMI_A,
|
||||
HDMI_B,
|
||||
MDDI,
|
||||
DisplayPort,
|
||||
Reserved
|
||||
};
|
||||
|
||||
ColorBitDepth color_bit_depth() const { return (ColorBitDepth)((m_video_input_definition >> 4) & 7); }
|
||||
SupportedInterface supported_interface() const { return ((m_video_input_definition & 0xf) <= 5) ? (SupportedInterface)(m_video_input_definition & 0xf) : SupportedInterface::Reserved; }
|
||||
|
||||
DigitalDisplayFeatures const& features() { return m_features; }
|
||||
|
||||
private:
|
||||
DigitalDisplay(u8 video_input_definition, u8 features, u8 edid_revision)
|
||||
: m_video_input_definition(video_input_definition)
|
||||
, m_features(features, edid_revision)
|
||||
{
|
||||
}
|
||||
|
||||
u8 m_video_input_definition { 0 };
|
||||
DigitalDisplayFeatures m_features;
|
||||
};
|
||||
Optional<DigitalDisplay> digital_display() const;
|
||||
|
||||
class AnalogDisplay final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
bool separate_sync_h_and_v_supported() const { return (m_video_input_definition & (1 << 3)) != 0; }
|
||||
|
||||
private:
|
||||
AnalogDisplay(u8 video_input_definition, u8 features, u8 edid_revision)
|
||||
: m_video_input_definition(video_input_definition)
|
||||
, m_features(features, edid_revision)
|
||||
{
|
||||
}
|
||||
|
||||
u8 m_video_input_definition { 0 };
|
||||
AnalogDisplayFeatures m_features;
|
||||
};
|
||||
Optional<AnalogDisplay> analog_display() const;
|
||||
|
||||
class ScreenSize final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
unsigned horizontal_cm() const { return m_horizontal_cm; }
|
||||
unsigned vertical_cm() const { return m_vertical_cm; }
|
||||
|
||||
private:
|
||||
ScreenSize(u8 horizontal_cm, u8 vertical_cm)
|
||||
: m_horizontal_cm(horizontal_cm)
|
||||
, m_vertical_cm(vertical_cm)
|
||||
{
|
||||
}
|
||||
|
||||
u8 m_horizontal_cm { 0 };
|
||||
u8 m_vertical_cm { 0 };
|
||||
};
|
||||
Optional<ScreenSize> screen_size() const;
|
||||
|
||||
class ScreenAspectRatio final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class Orientation {
|
||||
Landscape,
|
||||
Portrait
|
||||
};
|
||||
|
||||
Orientation orientation() const { return m_orientation; }
|
||||
auto ratio() const { return m_ratio; }
|
||||
|
||||
private:
|
||||
ScreenAspectRatio(Orientation orientation, FixedPoint<16> ratio)
|
||||
: m_orientation(orientation)
|
||||
, m_ratio(ratio)
|
||||
{
|
||||
}
|
||||
|
||||
Orientation m_orientation { Orientation::Landscape };
|
||||
FixedPoint<16> m_ratio {};
|
||||
};
|
||||
Optional<ScreenAspectRatio> aspect_ratio() const;
|
||||
|
||||
Optional<FixedPoint<16>> gamma() const;
|
||||
|
||||
class EstablishedTiming final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class Source {
|
||||
IBM,
|
||||
Apple,
|
||||
VESA,
|
||||
Manufacturer
|
||||
};
|
||||
|
||||
ALWAYS_INLINE Source source() const { return m_source; }
|
||||
ALWAYS_INLINE unsigned width() const { return m_width; };
|
||||
ALWAYS_INLINE unsigned height() const { return m_height; }
|
||||
|
||||
ALWAYS_INLINE unsigned refresh_rate() const
|
||||
{
|
||||
if (m_source == Source::Manufacturer)
|
||||
return 0;
|
||||
return m_refresh_rate_or_manufacturer_specific;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u8 manufacturer_specific() const
|
||||
{
|
||||
VERIFY(m_source == Source::Manufacturer);
|
||||
return m_refresh_rate_or_manufacturer_specific;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE u8 dmt_id() const { return m_dmt_id; }
|
||||
|
||||
private:
|
||||
constexpr EstablishedTiming(Source source, u16 width, u16 height, u8 refresh_rate_or_manufacturer_specific, u8 dmt_id = 0)
|
||||
: m_source(source)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
, m_refresh_rate_or_manufacturer_specific(refresh_rate_or_manufacturer_specific)
|
||||
, m_dmt_id(dmt_id)
|
||||
{
|
||||
}
|
||||
|
||||
Source m_source { Source::IBM };
|
||||
u16 m_width { 0 };
|
||||
u16 m_height { 0 };
|
||||
u8 m_refresh_rate_or_manufacturer_specific { 0 };
|
||||
u8 m_dmt_id { 0 };
|
||||
};
|
||||
|
||||
ErrorOr<IterationDecision> for_each_established_timing(Function<IterationDecision(EstablishedTiming const&)>) const;
|
||||
|
||||
class StandardTiming final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class AspectRatio {
|
||||
AR_16_10,
|
||||
AR_4_3,
|
||||
AR_5_4,
|
||||
AR_16_9
|
||||
};
|
||||
unsigned width() const { return m_width; }
|
||||
unsigned height() const { return m_height; }
|
||||
unsigned refresh_rate() const { return m_refresh_rate; }
|
||||
AspectRatio aspect_ratio() const { return m_aspect_ratio; }
|
||||
u8 dmt_id() const { return m_dmt_id; }
|
||||
|
||||
private:
|
||||
constexpr StandardTiming(u16 width, u16 height, u8 refresh_rate, AspectRatio aspect_ratio, u8 dmt_id)
|
||||
: m_width(width)
|
||||
, m_height(height)
|
||||
, m_refresh_rate(refresh_rate)
|
||||
, m_aspect_ratio(aspect_ratio)
|
||||
, m_dmt_id(dmt_id)
|
||||
{
|
||||
}
|
||||
|
||||
u16 m_width { 0 };
|
||||
u16 m_height { 0 };
|
||||
u8 m_refresh_rate { 0 };
|
||||
AspectRatio m_aspect_ratio { AspectRatio::AR_16_10 };
|
||||
u8 m_dmt_id { 0 };
|
||||
};
|
||||
|
||||
ErrorOr<IterationDecision> for_each_standard_timing(Function<IterationDecision(StandardTiming const&)>) const;
|
||||
|
||||
class DetailedTiming final {
|
||||
friend class Parser;
|
||||
friend class CEA861ExtensionBlock;
|
||||
|
||||
public:
|
||||
u32 pixel_clock_khz() const;
|
||||
u16 horizontal_addressable_pixels() const;
|
||||
u16 horizontal_blanking_pixels() const;
|
||||
u16 vertical_addressable_lines() const;
|
||||
u16 vertical_blanking_lines() const;
|
||||
u16 horizontal_front_porch_pixels() const;
|
||||
ALWAYS_INLINE u16 horizontal_back_porch_pixels() const { return horizontal_blanking_pixels() - horizontal_sync_pulse_width_pixels() - horizontal_front_porch_pixels(); }
|
||||
u16 horizontal_sync_pulse_width_pixels() const;
|
||||
u16 vertical_front_porch_lines() const;
|
||||
ALWAYS_INLINE u16 vertical_back_porch_lines() const { return vertical_blanking_lines() - vertical_sync_pulse_width_lines() - vertical_front_porch_lines(); }
|
||||
u16 vertical_sync_pulse_width_lines() const;
|
||||
u16 horizontal_image_size_mm() const;
|
||||
u16 vertical_image_size_mm() const;
|
||||
u8 horizontal_right_or_left_border_pixels() const;
|
||||
u8 vertical_top_or_bottom_border_lines() const;
|
||||
|
||||
bool is_interlaced() const;
|
||||
FixedPoint<16, u32> refresh_rate() const;
|
||||
|
||||
private:
|
||||
DetailedTiming(Parser const& edid, Definitions::DetailedTiming const* detailed_timings)
|
||||
: m_edid(edid)
|
||||
, m_detailed_timings(*detailed_timings)
|
||||
{
|
||||
}
|
||||
|
||||
Parser const& m_edid;
|
||||
Definitions::DetailedTiming const& m_detailed_timings;
|
||||
};
|
||||
|
||||
ErrorOr<IterationDecision> for_each_detailed_timing(Function<IterationDecision(DetailedTiming const&, unsigned)>) const;
|
||||
Optional<DetailedTiming> detailed_timing(size_t) const;
|
||||
|
||||
String display_product_name() const;
|
||||
String display_product_serial_number() const;
|
||||
|
||||
ErrorOr<IterationDecision> for_each_short_video_descriptor(Function<IterationDecision(unsigned, bool, VIC::Details const&)>) const;
|
||||
|
||||
class CoordinatedVideoTiming final {
|
||||
friend class Parser;
|
||||
|
||||
public:
|
||||
enum class AspectRatio : u8 {
|
||||
AR_4_3 = 0,
|
||||
AR_16_9 = 1,
|
||||
AR_16_10 = 2,
|
||||
AR_15_9 = 3
|
||||
};
|
||||
|
||||
u16 horizontal_addressable_pixels() const;
|
||||
u16 vertical_addressable_lines() const;
|
||||
AspectRatio aspect_ratio() const;
|
||||
u16 preferred_refresh_rate();
|
||||
|
||||
ALWAYS_INLINE DMT::CVT cvt_code() const { return m_cvt; }
|
||||
|
||||
private:
|
||||
CoordinatedVideoTiming(DMT::CVT const& cvt)
|
||||
: m_cvt(cvt)
|
||||
{
|
||||
}
|
||||
|
||||
DMT::CVT m_cvt;
|
||||
};
|
||||
|
||||
ErrorOr<IterationDecision> for_each_coordinated_video_timing(Function<IterationDecision(CoordinatedVideoTiming const&)>) const;
|
||||
|
||||
ErrorOr<IterationDecision> for_each_extension_block(Function<IterationDecision(unsigned, u8, u8, ReadonlyBytes)>) const;
|
||||
|
||||
struct SupportedResolution {
|
||||
unsigned width { 0 };
|
||||
unsigned height { 0 };
|
||||
struct RefreshRate {
|
||||
FixedPoint<16, u32> rate;
|
||||
bool preferred { false };
|
||||
|
||||
bool operator<(RefreshRate const& rhs) const { return rate < rhs.rate; }
|
||||
};
|
||||
Vector<RefreshRate, 4> refresh_rates;
|
||||
};
|
||||
ErrorOr<Vector<SupportedResolution>> supported_resolutions() const;
|
||||
|
||||
Parser() = default;
|
||||
Parser(Parser&&) = default;
|
||||
Parser(Parser const&);
|
||||
Parser& operator=(Parser&&);
|
||||
Parser& operator=(Parser const&);
|
||||
|
||||
bool operator==(Parser const& other) const;
|
||||
|
||||
String version() const;
|
||||
|
||||
auto bytes() const { return m_bytes; }
|
||||
|
||||
private:
|
||||
Parser(ReadonlyBytes);
|
||||
Parser(ByteBuffer&&);
|
||||
|
||||
ErrorOr<void> parse();
|
||||
|
||||
template<typename T>
|
||||
T read_host(T const*) const;
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T read_le(T const*)
|
||||
const;
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T read_be(T const*)
|
||||
const;
|
||||
|
||||
Definitions::EDID const& raw_edid() const;
|
||||
ErrorOr<IterationDecision> for_each_display_descriptor(Function<IterationDecision(u8, Definitions::DisplayDescriptor const&)>) const;
|
||||
|
||||
ByteBuffer m_bytes_buffer;
|
||||
ReadonlyBytes m_bytes;
|
||||
u8 m_revision { 0 };
|
||||
};
|
||||
|
||||
}
|
199
Userland/Libraries/LibEDID/VIC.cpp
Normal file
199
Userland/Libraries/LibEDID/VIC.cpp
Normal file
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibEDID/VIC.h>
|
||||
|
||||
namespace EDID {
|
||||
|
||||
// Video ID Code details as per CTA-861-G revised 2018 Table 3
|
||||
static constexpr VIC::Details s_vic_details[] = {
|
||||
{ 1, 640, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 2, 720, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 3, 720, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 4, 1280, 720, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 5, 1920, 1080, 59940, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 6, 1440, 480, 59940, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 7, 1440, 480, 59940, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 8, 1440, 240, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 9, 1440, 240, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 10, 2880, 480, 59940, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 11, 2880, 480, 59940, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 12, 2880, 240, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 13, 2880, 240, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 14, 1440, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 15, 1440, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 16, 1920, 180, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 17, 720, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 18, 720, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 19, 1280, 720, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 20, 1920, 1080, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 21, 1440, 576, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 22, 1440, 576, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 23, 1440, 288, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 24, 1440, 288, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 25, 2880, 576, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 26, 2880, 576, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 27, 2880, 288, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 28, 2880, 288, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 29, 1440, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 30, 1440, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 31, 1920, 1080, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 32, 1920, 1080, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 33, 1920, 1080, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 34, 1920, 1080, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 35, 2880, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 36, 2880, 480, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 37, 2880, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 38, 2880, 576, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 39, 1920, 1080, 50000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 40, 1920, 1080, 100000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 41, 1280, 720, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 42, 720, 576, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 43, 720, 576, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 44, 1440, 576, 100000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 45, 1440, 576, 100000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 46, 1920, 1080, 119880, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 47, 1280, 720, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 48, 720, 480, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 49, 720, 480, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 50, 1440, 480, 119880, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 51, 1440, 480, 119880, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 52, 720, 576, 200000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 53, 720, 576, 200000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 54, 1440, 576, 200000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 55, 1440, 576, 200000, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 56, 720, 480, 239760, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 57, 720, 480, 239760, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 58, 1440, 480, 239760, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_4_3 },
|
||||
{ 59, 1440, 480, 239760, VIC::Details::ScanType::Interlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 60, 1280, 720, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 61, 1280, 720, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 62, 1280, 720, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 63, 1920, 1080, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 64, 1920, 1080, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 65, 1280, 720, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 66, 1280, 720, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 67, 1280, 720, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 68, 1280, 720, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 69, 1280, 720, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 70, 1280, 720, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 71, 1280, 720, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 72, 1920, 1080, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 73, 1920, 1080, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 74, 1920, 1080, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 75, 1920, 1080, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 76, 1920, 1080, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 77, 1920, 1080, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 78, 1920, 1080, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 79, 1680, 720, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 80, 1680, 720, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 81, 1680, 720, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 82, 1680, 720, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 83, 1680, 720, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 84, 1680, 720, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 85, 1680, 720, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 86, 2560, 1080, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 87, 2560, 1080, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 88, 2560, 1080, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 89, 2560, 1080, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 90, 2560, 1080, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 91, 2560, 1080, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 92, 2560, 1080, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 93, 3840, 2160, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 94, 3840, 2160, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 95, 3840, 2160, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 96, 3840, 2160, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 97, 3840, 2160, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 98, 4096, 2160, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 99, 4096, 2160, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 100, 4096, 2160, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 101, 4096, 2160, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 102, 4096, 2160, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 103, 3840, 2160, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 104, 3840, 2160, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 105, 3840, 2160, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 106, 3840, 2160, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 107, 3840, 2160, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 108, 1280, 720, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 109, 1280, 720, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 110, 1680, 720, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 111, 1920, 1080, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 112, 1920, 1080, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 113, 2560, 1080, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 114, 3840, 2160, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 115, 4096, 2160, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 116, 3840, 2160, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 117, 3840, 2160, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 118, 3840, 2160, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 119, 3840, 2160, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 120, 3840, 2160, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 121, 5120, 2160, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 122, 5120, 2160, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 123, 5120, 2160, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 124, 5120, 2160, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 125, 5120, 2160, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 126, 5120, 2160, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 127, 5120, 2160, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
// 128...192 forbidden range
|
||||
{ 193, 5120, 2160, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 194, 7680, 4320, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 195, 7680, 4320, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 196, 7680, 4320, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 197, 7680, 4320, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 198, 7680, 4320, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 199, 7680, 4320, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 200, 7680, 4320, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 201, 7680, 4320, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_16_9 },
|
||||
{ 202, 7680, 4320, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 203, 7680, 4320, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 204, 7680, 4320, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 205, 7680, 4320, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 206, 7680, 4320, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 207, 7680, 4320, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 208, 7680, 4320, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 209, 7680, 4320, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 210, 10240, 4320, 23980, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 211, 10240, 4320, 25000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 212, 10240, 4320, 29970, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 213, 10240, 4320, 47950, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 214, 10240, 4320, 50000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 215, 10240, 4320, 59940, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 216, 10240, 4320, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 217, 10240, 4320, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_64_27 },
|
||||
{ 218, 4096, 2160, 100000, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
{ 219, 4096, 2160, 119880, VIC::Details::ScanType::NonInterlaced, VIC::Details::AspectRatio::AR_256_135 },
|
||||
// 220...255 reserved
|
||||
};
|
||||
|
||||
static constexpr size_t s_vic_details_count = sizeof(s_vic_details) / sizeof(s_vic_details[0]);
|
||||
static constexpr u8 s_reserved_vic_id_start = 220;
|
||||
static_assert(s_vic_details[s_vic_details_count - 1].vic_id == s_reserved_vic_id_start - 1);
|
||||
|
||||
FixedPoint<16, u32> VIC::Details::refresh_rate_hz() const
|
||||
{
|
||||
return FixedPoint<16, u32>(refresh_rate_millihz) / 1000;
|
||||
}
|
||||
|
||||
auto VIC::find_details_by_vic_id(u8 vic_id) -> Details const*
|
||||
{
|
||||
if (vic_id == 0 || (vic_id >= 128 && vic_id <= 192) || vic_id >= s_reserved_vic_id_start)
|
||||
return nullptr;
|
||||
|
||||
u8 table_index = vic_id - 1;
|
||||
if (table_index < 128) {
|
||||
// Before the forbidden block (128...192)
|
||||
VERIFY(s_vic_details[table_index].vic_id == vic_id);
|
||||
return &s_vic_details[table_index];
|
||||
}
|
||||
|
||||
// After the forbidden block range (128...192)
|
||||
table_index = table_index - 192 + 128 - 1;
|
||||
VERIFY(s_vic_details[table_index].vic_id == vic_id);
|
||||
return &s_vic_details[table_index];
|
||||
}
|
||||
|
||||
}
|
42
Userland/Libraries/LibEDID/VIC.h
Normal file
42
Userland/Libraries/LibEDID/VIC.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FixedPoint.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace EDID {
|
||||
|
||||
class VIC final {
|
||||
public:
|
||||
struct Details {
|
||||
enum class ScanType : u8 {
|
||||
NonInterlaced,
|
||||
Interlaced
|
||||
};
|
||||
enum class AspectRatio : u8 {
|
||||
AR_4_3,
|
||||
AR_16_9,
|
||||
AR_64_27,
|
||||
AR_256_135,
|
||||
};
|
||||
|
||||
u8 vic_id;
|
||||
u16 horizontal_pixels;
|
||||
u16 vertical_lines;
|
||||
u32 refresh_rate_millihz;
|
||||
ScanType scan_type;
|
||||
AspectRatio aspect_ratio;
|
||||
|
||||
FixedPoint<16, u32> refresh_rate_hz() const;
|
||||
};
|
||||
|
||||
static Details const* find_details_by_vic_id(u8);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue