summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-02-07 12:56:54 +0200
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-02-10 07:04:02 +0200
commit05bc0a0c4fe88031e72f17b342476d5f7d6775d0 (patch)
tree07dfbd36faef1f1c7539202b1f155ef90578c756
parent186212dc95965a3e7cbc46dcace9af1d19100096 (diff)
kmstest: Add --view option
-rw-r--r--utils/kmstest.cpp42
1 files 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<MappedFramebuffer*> fbs;
};
@@ -331,6 +336,20 @@ static vector<MappedFramebuffer*> 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 =
" [<crtc>:]<pclk>,<hact>/<hfp>/<hsw>/<hbp>/<hsp>,<vact>/<vfp>/<vsw>/<vbp>/<vsp>[,i]\n"
" -p, --plane=PLANE PLANE is [<plane>:][<x>,<y>-]<w>x<h>\n"
" -f, --fb=FB FB is [<w>x<h>][-][<4cc>]\n"
+ " -v, --view=VIEW VIEW is <x>,<y>-<w>x<h>\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<Arg> 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<OutputInfo> setups_to_outputs(Card& card, const vector<Arg>& 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<OutputInfo>& 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 },