aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyri Sarha2018-01-05 03:17:40 -0600
committerTomi Valkeinen2018-01-05 06:02:47 -0600
commit141d80881d1c759d43276375e6381537cdf8d0a4 (patch)
tree73cbc5dab66b684049ac607adb3e8a8857d6d1d6
parent37dfa5c785f7cc48ff9458881d907e2cce7d4fa6 (diff)
downloadexternal-libkmsxx-141d80881d1c759d43276375e6381537cdf8d0a4.tar.gz
external-libkmsxx-141d80881d1c759d43276375e6381537cdf8d0a4.tar.xz
external-libkmsxx-141d80881d1c759d43276375e6381537cdf8d0a4.zip
kmstest: Implement simplistic propery support behind -P flag.
Non atomic modesetting is not supported and there is no translation from various property types to unsigned 64-bit integer. Instead the property values are simply converted from string with stoull(str, 0, 0). Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--utils/kmstest.cpp94
1 files changed, 91 insertions, 3 deletions
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index fee3070..0f763c0 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -4,6 +4,8 @@
4#include <regex> 4#include <regex>
5#include <set> 5#include <set>
6#include <chrono> 6#include <chrono>
7#include <cstdint>
8#include <cinttypes>
7 9
8#include <sys/select.h> 10#include <sys/select.h>
9 11
@@ -16,6 +18,13 @@
16using namespace std; 18using namespace std;
17using namespace kms; 19using namespace kms;
18 20
21struct PropInfo {
22 PropInfo(Property *p, uint64_t v) : prop(p), val(v) {}
23
24 Property *prop;
25 uint64_t val;
26};
27
19struct PlaneInfo 28struct PlaneInfo
20{ 29{
21 Plane* plane; 30 Plane* plane;
@@ -31,6 +40,8 @@ struct PlaneInfo
31 unsigned view_h; 40 unsigned view_h;
32 41
33 vector<Framebuffer*> fbs; 42 vector<Framebuffer*> fbs;
43
44 vector<PropInfo> props;
34}; 45};
35 46
36struct OutputInfo 47struct OutputInfo
@@ -44,6 +55,9 @@ struct OutputInfo
44 vector<Framebuffer*> fbs; 55 vector<Framebuffer*> fbs;
45 56
46 vector<PlaneInfo> planes; 57 vector<PlaneInfo> planes;
58
59 vector<PropInfo> conn_props;
60 vector<PropInfo> crtc_props;
47}; 61};
48 62
49static bool s_use_dmt; 63static bool s_use_dmt;
@@ -267,6 +281,23 @@ static void parse_plane(ResourceManager& resman, Card& card, const string& plane
267 pinfo.y = output.mode.vdisplay / 2 - pinfo.h / 2; 281 pinfo.y = output.mode.vdisplay / 2 - pinfo.h / 2;
268} 282}
269 283
284static void parse_prop(Card& card, const string& prop_str, vector<PropInfo> &props, const DrmPropObject* propobj)
285{
286 string name, val;
287 Property* prop;
288
289 size_t split = prop_str.find("=");
290
291 if (split == string::npos)
292 EXIT("Equal sign ('=') not found in %s", prop_str.c_str());
293
294 name = prop_str.substr(0, split);
295 val = prop_str.substr(split+1);
296 prop = propobj->get_prop(name);
297
298 props.push_back(PropInfo(prop, stoull(val, 0, 0)));
299}
300
270static vector<Framebuffer*> get_default_fb(Card& card, unsigned width, unsigned height) 301static vector<Framebuffer*> get_default_fb(Card& card, unsigned width, unsigned height)
271{ 302{
272 vector<Framebuffer*> v; 303 vector<Framebuffer*> v;
@@ -336,6 +367,7 @@ static const char* usage_str =
336 " -p, --plane=PLANE PLANE is [<plane>:][<x>,<y>-]<w>x<h>\n" 367 " -p, --plane=PLANE PLANE is [<plane>:][<x>,<y>-]<w>x<h>\n"
337 " -f, --fb=FB FB is [<w>x<h>][-][<4cc>]\n" 368 " -f, --fb=FB FB is [<w>x<h>][-][<4cc>]\n"
338 " -v, --view=VIEW VIEW is <x>,<y>-<w>x<h>\n" 369 " -v, --view=VIEW VIEW is <x>,<y>-<w>x<h>\n"
370 " -P, --property=PROP=VAL Set PROP to VAL in the previous DRM object\n"
339 " --dmt Search for the given mode from DMT tables\n" 371 " --dmt Search for the given mode from DMT tables\n"
340 " --cea Search for the given mode from CEA tables\n" 372 " --cea Search for the given mode from CEA tables\n"
341 " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n" 373 " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n"
@@ -378,6 +410,7 @@ enum class ArgType
378 Plane, 410 Plane,
379 Framebuffer, 411 Framebuffer,
380 View, 412 View,
413 Property,
381}; 414};
382 415
383struct Arg 416struct Arg
@@ -419,6 +452,10 @@ static vector<Arg> parse_cmdline(int argc, char **argv)
419 { 452 {
420 args.push_back(Arg { ArgType::View, s }); 453 args.push_back(Arg { ArgType::View, s });
421 }), 454 }),
455 Option("P|property=", [&](string s)
456 {
457 args.push_back(Arg { ArgType::Property, s });
458 }),
422 Option("|dmt", []() 459 Option("|dmt", []()
423 { 460 {
424 s_use_dmt = true; 461 s_use_dmt = true;
@@ -590,6 +627,28 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
590 parse_view(arg.arg, *current_plane); 627 parse_view(arg.arg, *current_plane);
591 break; 628 break;
592 } 629 }
630
631 case ArgType::Property:
632 {
633 if (!current_output)
634 EXIT("No object to which set the property");
635
636 if (current_plane)
637 parse_prop(card, arg.arg, current_plane->props,
638 current_plane->plane);
639 else if (current_output->crtc)
640 parse_prop(card, arg.arg,
641 current_output->crtc_props,
642 current_output->crtc);
643 else if (current_output->connector)
644 parse_prop(card, arg.arg,
645 current_output->conn_props,
646 current_output->connector);
647 else
648 EXIT("no object");
649
650 break;
651 }
593 } 652 }
594 } 653 }
595 654
@@ -631,9 +690,19 @@ static void print_outputs(const vector<OutputInfo>& outputs)
631 for (unsigned i = 0; i < outputs.size(); ++i) { 690 for (unsigned i = 0; i < outputs.size(); ++i) {
632 const OutputInfo& o = outputs[i]; 691 const OutputInfo& o = outputs[i];
633 692
634 printf("Connector %u/@%u: %s\n", o.connector->idx(), o.connector->id(), 693 printf("Connector %u/@%u: %s", o.connector->idx(), o.connector->id(),
635 o.connector->fullname().c_str()); 694 o.connector->fullname().c_str());
636 printf(" Crtc %u/@%u", o.crtc->idx(), o.crtc->id()); 695
696 for (const PropInfo &prop: o.conn_props)
697 printf(" %s=%" PRIu64, prop.prop->name().c_str(),
698 prop.val);
699
700 printf("\n Crtc %u/@%u", o.crtc->idx(), o.crtc->id());
701
702 for (const PropInfo &prop: o.crtc_props)
703 printf(" %s=%" PRIu64, prop.prop->name().c_str(),
704 prop.val);
705
637 if (o.primary_plane) 706 if (o.primary_plane)
638 printf(" (plane %u/@%u)", o.primary_plane->idx(), o.primary_plane->id()); 707 printf(" (plane %u/@%u)", o.primary_plane->idx(), o.primary_plane->id());
639 printf(": %s\n", videomode_to_string(o.mode).c_str()); 708 printf(": %s\n", videomode_to_string(o.mode).c_str());
@@ -646,8 +715,13 @@ static void print_outputs(const vector<OutputInfo>& outputs)
646 for (unsigned j = 0; j < o.planes.size(); ++j) { 715 for (unsigned j = 0; j < o.planes.size(); ++j) {
647 const PlaneInfo& p = o.planes[j]; 716 const PlaneInfo& p = o.planes[j];
648 auto fb = p.fbs[0]; 717 auto fb = p.fbs[0];
649 printf(" Plane %u/@%u: %u,%u-%ux%u\n", p.plane->idx(), p.plane->id(), 718 printf(" Plane %u/@%u: %u,%u-%ux%u", p.plane->idx(), p.plane->id(),
650 p.x, p.y, p.w, p.h); 719 p.x, p.y, p.w, p.h);
720 for (const PropInfo &prop: p.props)
721 printf(" %s=%" PRIu64, prop.prop->name().c_str(),
722 prop.val);
723 printf("\n");
724
651 printf(" Fb %u %ux%u-%s\n", fb->id(), fb->width(), fb->height(), 725 printf(" Fb %u %ux%u-%s\n", fb->id(), fb->width(), fb->height(),
652 PixelFormatToFourCC(fb->format()).c_str()); 726 PixelFormatToFourCC(fb->format()).c_str());
653 } 727 }
@@ -680,6 +754,9 @@ static void set_crtcs_n_planes_legacy(Card& card, const vector<OutputInfo>& outp
680 auto conn = o.connector; 754 auto conn = o.connector;
681 auto crtc = o.crtc; 755 auto crtc = o.crtc;
682 756
757 if (!o.conn_props.empty() || !o.crtc_props.empty())
758 printf("WARNING: properties not set without atomic modesetting");
759
683 if (!o.fbs.empty()) { 760 if (!o.fbs.empty()) {
684 auto fb = o.fbs[0]; 761 auto fb = o.fbs[0];
685 int r = crtc->set_mode(conn, *fb, o.mode); 762 int r = crtc->set_mode(conn, *fb, o.mode);
@@ -696,6 +773,8 @@ static void set_crtcs_n_planes_legacy(Card& card, const vector<OutputInfo>& outp
696 if (r) 773 if (r)
697 printf("crtc->set_plane() failed for plane %u: %s\n", 774 printf("crtc->set_plane() failed for plane %u: %s\n",
698 p.plane->id(), strerror(-r)); 775 p.plane->id(), strerror(-r));
776 if (!p.props.empty())
777 printf("WARNING: properties not set without atomic modesetting");
699 } 778 }
700 } 779 }
701} 780}
@@ -752,11 +831,17 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
752 { "CRTC_ID", crtc->id() }, 831 { "CRTC_ID", crtc->id() },
753 }); 832 });
754 833
834 for (const PropInfo &prop: o.conn_props)
835 req.add(conn, prop.prop, prop.val);
836
755 req.add(crtc, { 837 req.add(crtc, {
756 { "ACTIVE", 1 }, 838 { "ACTIVE", 1 },
757 { "MODE_ID", mode_blob->id() }, 839 { "MODE_ID", mode_blob->id() },
758 }); 840 });
759 841
842 for (const PropInfo &prop: o.crtc_props)
843 req.add(crtc, prop.prop, prop.val);
844
760 if (!o.fbs.empty()) { 845 if (!o.fbs.empty()) {
761 auto fb = o.fbs[0]; 846 auto fb = o.fbs[0];
762 847
@@ -789,6 +874,9 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
789 { "CRTC_W", p.w }, 874 { "CRTC_W", p.w },
790 { "CRTC_H", p.h }, 875 { "CRTC_H", p.h },
791 }); 876 });
877
878 for (const PropInfo &prop: p.props)
879 req.add(p.plane, prop.prop, prop.val);
792 } 880 }
793 } 881 }
794 882