From ad7d39e1490817064675e148ec8e4cbec9cd5206 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 16 May 2016 13:37:57 +0300 Subject: testpat: add dmt & cea parameters --- tests/testpat.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/testpat.cpp b/tests/testpat.cpp index a6c4bf9..b2d7b12 100644 --- a/tests/testpat.cpp +++ b/tests/testpat.cpp @@ -4,6 +4,7 @@ #include #include "kms++.h" +#include "modedb.h" #include "test.h" #include "opts.h" @@ -35,6 +36,9 @@ struct OutputInfo vector planes; }; +static bool s_use_dmt; +static bool s_use_cea; + static set s_used_crtcs; static set s_used_planes; @@ -153,7 +157,31 @@ static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output) bool ilace = sm[5].matched ? true : false; unsigned refresh = sm[6].matched ? stoul(sm[6]) : 0; - output.mode = output.connector->get_mode(w, h, refresh, ilace); + bool found_mode = false; + + try { + output.mode = output.connector->get_mode(w, h, refresh, ilace); + found_mode = true; + } catch (exception& e) { } + + if (!found_mode && s_use_dmt) { + try { + output.mode = find_dmt(w, h, refresh, ilace); + found_mode = true; + printf("Found mode from DMT\n"); + } catch (exception& e) { } + } + + if (!found_mode && s_use_cea) { + try { + output.mode = find_cea(w, h, refresh, ilace); + found_mode = true; + printf("Found mode from CEA\n"); + } catch (exception& e) { } + } + + if (!found_mode) + throw invalid_argument("Mode not found"); } static void parse_plane(Card& card, const string& plane_str, const OutputInfo& output, PlaneInfo& pinfo) @@ -258,6 +286,8 @@ static const char* usage_str = " -r, --crtc=CRTC CRTC is [:]x[@]\n" " -p, --plane=PLANE PLANE is [:][,-]x\n" " -f, --fb=FB FB is [x][-][<4cc>]\n" + " --dmt Search for the given mode from DMT tables\n" + " --cea Search for the given mode from CEA tables\n" "\n" ", and can be given by id () or index (@).\n" " can also be given by name.\n" @@ -327,6 +357,14 @@ static vector parse_cmdline(int argc, char **argv) { args.push_back(Arg { ObjectType::Framebuffer, s }); }), + Option("|dmt", []() + { + s_use_dmt = true; + }), + Option("|cea", []() + { + s_use_cea = true; + }), Option("h|help", [&]() { usage(); -- cgit v1.2.3