aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorTomi Valkeinen2017-11-22 02:05:53 -0600
committerTomi Valkeinen2017-11-22 04:47:15 -0600
commita4724a1dae7a877ae7bb7082b068bbb12032ff63 (patch)
treeef3264139d2f48c39787d3f692a834da3f8581ea /utils
parent448dec0fa7e398bff2152f5e01671353af03bc8c (diff)
downloadexternal-libkmsxx-a4724a1dae7a877ae7bb7082b068bbb12032ff63.tar.gz
external-libkmsxx-a4724a1dae7a877ae7bb7082b068bbb12032ff63.tar.xz
external-libkmsxx-a4724a1dae7a877ae7bb7082b068bbb12032ff63.zip
kmstest: use resman
Diffstat (limited to 'utils')
-rw-r--r--utils/kmstest.cpp61
1 files changed, 20 insertions, 41 deletions
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index 21309d6..fee3070 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -56,9 +56,6 @@ static bool s_cvt_v2;
56static bool s_cvt_vid_opt; 56static bool s_cvt_vid_opt;
57static unsigned s_max_flips; 57static unsigned s_max_flips;
58 58
59static set<Crtc*> s_used_crtcs;
60static set<Plane*> s_used_planes;
61
62__attribute__ ((unused)) 59__attribute__ ((unused))
63static void print_regex_match(smatch sm) 60static void print_regex_match(smatch sm)
64{ 61{
@@ -82,28 +79,15 @@ static void get_connector(ResourceManager& resman, OutputInfo& output, const str
82 output.mode = output.connector->get_default_mode(); 79 output.mode = output.connector->get_default_mode();
83} 80}
84 81
85static void get_default_crtc(Card& card, OutputInfo& output) 82static void get_default_crtc(ResourceManager& resman, OutputInfo& output)
86{ 83{
87 Crtc* crtc = output.connector->get_current_crtc(); 84 output.crtc = resman.reserve_crtc(output.connector);
88
89 if (crtc && s_used_crtcs.find(crtc) == s_used_crtcs.end()) {
90 s_used_crtcs.insert(crtc);
91 output.crtc = crtc;
92 return;
93 }
94
95 for (const auto& possible : output.connector->get_possible_crtcs()) {
96 if (s_used_crtcs.find(possible) == s_used_crtcs.end()) {
97 s_used_crtcs.insert(possible);
98 output.crtc = possible;
99 return;
100 }
101 }
102 85
103 EXIT("Could not find available crtc"); 86 if (!output.crtc)
87 EXIT("Could not find available crtc");
104} 88}
105 89
106static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output) 90static void parse_crtc(ResourceManager& resman, Card& card, const string& crtc_str, OutputInfo& output)
107{ 91{
108 // @12:1920x1200i@60 92 // @12:1920x1200i@60
109 // @12:33000000,800/210/30/16/-,480/22/13/10/-,i 93 // @12:33000000,800/210/30/16/-,480/22/13/10/-,i
@@ -226,9 +210,12 @@ static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output)
226 } else { 210 } else {
227 EXIT("Failed to parse crtc option '%s'", crtc_str.c_str()); 211 EXIT("Failed to parse crtc option '%s'", crtc_str.c_str());
228 } 212 }
213
214 if (!resman.reserve_crtc(output.crtc))
215 EXIT("Could not find available crtc");
229} 216}
230 217
231static void parse_plane(Card& card, const string& plane_str, const OutputInfo& output, PlaneInfo& pinfo) 218static void parse_plane(ResourceManager& resman, Card& card, const string& plane_str, const OutputInfo& output, PlaneInfo& pinfo)
232{ 219{
233 // 3:400,400-400x400 220 // 3:400,400-400x400
234 const regex plane_re("(?:(@?)(\\d+):)?" // 3: 221 const regex plane_re("(?:(@?)(\\d+):)?" // 3:
@@ -257,22 +244,14 @@ static void parse_plane(Card& card, const string& plane_str, const OutputInfo& o
257 244
258 pinfo.plane = planes[num]; 245 pinfo.plane = planes[num];
259 } 246 }
260 } else {
261 for (Plane* p : output.crtc->get_possible_planes()) {
262 if (s_used_planes.find(p) != s_used_planes.end())
263 continue;
264
265 if (p->plane_type() != PlaneType::Overlay)
266 continue;
267 247
268 pinfo.plane = p; 248 pinfo.plane = resman.reserve_plane(pinfo.plane);
269 } 249 } else {
270 250 pinfo.plane = resman.reserve_overlay_plane(output.crtc);
271 if (!pinfo.plane)
272 EXIT("Failed to find available plane");
273 } 251 }
274 252
275 s_used_planes.insert(pinfo.plane); 253 if (!pinfo.plane)
254 EXIT("Failed to find available plane");
276 255
277 pinfo.w = stoul(sm[5]); 256 pinfo.w = stoul(sm[5]);
278 pinfo.h = stoul(sm[6]); 257 pinfo.h = stoul(sm[6]);
@@ -540,7 +519,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
540 if (!current_output->connector) 519 if (!current_output->connector)
541 get_connector(resman, *current_output); 520 get_connector(resman, *current_output);
542 521
543 parse_crtc(card, arg.arg, *current_output); 522 parse_crtc(resman, card, arg.arg, *current_output);
544 523
545 current_output->user_set_crtc = true; 524 current_output->user_set_crtc = true;
546 525
@@ -560,12 +539,12 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
560 get_connector(resman, *current_output); 539 get_connector(resman, *current_output);
561 540
562 if (!current_output->crtc) 541 if (!current_output->crtc)
563 get_default_crtc(card, *current_output); 542 get_default_crtc(resman, *current_output);
564 543
565 current_output->planes.push_back(PlaneInfo { }); 544 current_output->planes.push_back(PlaneInfo { });
566 current_plane = &current_output->planes.back(); 545 current_plane = &current_output->planes.back();
567 546
568 parse_plane(card, arg.arg, *current_output, *current_plane); 547 parse_plane(resman, card, arg.arg, *current_output, *current_plane);
569 548
570 break; 549 break;
571 } 550 }
@@ -581,7 +560,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
581 get_connector(resman, *current_output); 560 get_connector(resman, *current_output);
582 561
583 if (!current_output->crtc) 562 if (!current_output->crtc)
584 get_default_crtc(card, *current_output); 563 get_default_crtc(resman, *current_output);
585 564
586 int def_w, def_h; 565 int def_w, def_h;
587 566
@@ -617,7 +596,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
617 // create default framebuffers if needed 596 // create default framebuffers if needed
618 for (OutputInfo& o : outputs) { 597 for (OutputInfo& o : outputs) {
619 if (!o.crtc) { 598 if (!o.crtc) {
620 get_default_crtc(card, o); 599 get_default_crtc(resman, o);
621 o.user_set_crtc = true; 600 o.user_set_crtc = true;
622 } 601 }
623 602
@@ -1048,7 +1027,7 @@ int main(int argc, char **argv)
1048 if (o.fbs.empty()) 1027 if (o.fbs.empty())
1049 continue; 1028 continue;
1050 1029
1051 o.primary_plane = resman.reserve_primary_plane(o.crtc); 1030 o.primary_plane = resman.reserve_primary_plane(o.crtc, o.fbs[0]->format());
1052 1031
1053 if (!o.primary_plane) 1032 if (!o.primary_plane)
1054 EXIT("Could not get primary plane for crtc '%u'", o.crtc->id()); 1033 EXIT("Could not get primary plane for crtc '%u'", o.crtc->id());