From 05bc0a0c4fe88031e72f17b342476d5f7d6775d0 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Tue, 7 Feb 2017 12:56:54 +0200 Subject: kmstest: Add --view option --- utils/kmstest.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp index 557c3e5..733523e 100644 --- a/utils/kmstest.cpp +++ b/utils/kmstest.cpp @@ -25,6 +25,11 @@ struct PlaneInfo unsigned w; unsigned h; + unsigned view_x; + unsigned view_y; + unsigned view_w; + unsigned view_h; + vector fbs; }; @@ -331,6 +336,20 @@ static vector parse_fb(Card& card, const string& fb_str, uns return v; } +static void parse_view(const string& view_str, PlaneInfo& pinfo) +{ + const regex view_re("(\\d+),(\\d+)-(\\d+)x(\\d+)"); // 400,400-400x400 + + smatch sm; + if (!regex_match(view_str, sm, view_re)) + EXIT("Failed to parse view option '%s'", view_str.c_str()); + + pinfo.view_x = stoul(sm[1]); + pinfo.view_y = stoul(sm[2]); + pinfo.view_w = stoul(sm[3]); + pinfo.view_h = stoul(sm[4]); +} + static const char* usage_str = "Usage: kmstest [OPTION]...\n\n" "Show a test pattern on a display or plane\n\n" @@ -342,6 +361,7 @@ static const char* usage_str = " [:],////,////[,i]\n" " -p, --plane=PLANE PLANE is [:][,-]x\n" " -f, --fb=FB FB is [x][-][<4cc>]\n" + " -v, --view=VIEW VIEW is ,-x\n" " --dmt Search for the given mode from DMT tables\n" " --cea Search for the given mode from CEA tables\n" " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n" @@ -379,6 +399,7 @@ enum class ObjectType Crtc, Plane, Framebuffer, + View, }; struct Arg @@ -416,6 +437,10 @@ static vector parse_cmdline(int argc, char **argv) { args.push_back(Arg { ObjectType::Framebuffer, s }); }), + Option("v|view=", [&](string s) + { + args.push_back(Arg { ObjectType::View, s }); + }), Option("|dmt", []() { s_use_dmt = true; @@ -571,6 +596,15 @@ static vector setups_to_outputs(Card& card, const vector& outpu break; } + + case ObjectType::View: + { + if (!current_plane || current_plane->fbs.empty()) + EXIT("'view' parameter requires a plane and a fb"); + + parse_view(arg.arg, *current_plane); + break; + } } } @@ -761,10 +795,10 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector& outp req.add(p.plane, { { "FB_ID", fb->id() }, { "CRTC_ID", crtc->id() }, - { "SRC_X", 0 << 16 }, - { "SRC_Y", 0 << 16 }, - { "SRC_W", fb->width() << 16 }, - { "SRC_H", fb->height() << 16 }, + { "SRC_X", (p.view_x ?: 0) << 16 }, + { "SRC_Y", (p.view_y ?: 0) << 16 }, + { "SRC_W", (p.view_w ?: fb->width()) << 16 }, + { "SRC_H", (p.view_h ?: fb->height()) << 16 }, { "CRTC_X", p.x }, { "CRTC_Y", p.y }, { "CRTC_W", p.w }, -- cgit v1.2.3