diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index a88d09258f588bc12fa8c45862c06ee37fb88add..f12ed095712614e9b2976c7e859d63b2bd0047a3 100644 (file)
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
unsigned w;
unsigned h;
- vector<DumbFramebuffer*> fbs;
+ vector<MappedFramebuffer*> fbs;
};
struct OutputInfo
Plane* primary_plane;
Videomode mode;
bool user_set_crtc;
- vector<DumbFramebuffer*> fbs;
+ vector<MappedFramebuffer*> fbs;
vector<PlaneInfo> planes;
};
@@ -148,38 +148,27 @@ static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output)
bool ilace = sm[5].matched ? true : false;
float refresh = sm[6].matched ? stof(sm[6]) : 0;
- bool found_mode = false;
-
if (s_cvt) {
output.mode = videomode_from_cvt(w, h, refresh, ilace, s_cvt_v2, s_cvt_vid_opt);
- found_mode = true;
- }
-
- if (!found_mode) {
- try {
- output.mode = output.connector->get_mode(w, h, refresh, ilace);
- found_mode = true;
- } catch (exception& e) { }
- }
-
- if (!found_mode && s_use_dmt) {
+ } else if (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) {
+ } catch (exception& e) {
+ EXIT("Mode not found from DMT tables\n");
+ }
+ } else if (s_use_cea) {
try {
output.mode = find_cea(w, h, refresh, ilace);
- found_mode = true;
- printf("Found mode from CEA\n");
- } catch (exception& e) { }
+ } catch (exception& e) {
+ EXIT("Mode not found from CEA tables\n");
+ }
+ } else {
+ try {
+ output.mode = output.connector->get_mode(w, h, refresh, ilace);
+ } catch (exception& e) {
+ EXIT("Mode not found from the connector\n");
+ }
}
-
- if (!found_mode)
- throw invalid_argument("Mode not found");
} else if (regex_match(crtc_str, sm, modeline_re)) {
if (sm[2].matched) {
bool use_id = sm[1].length() == 1;
@@ -299,9 +288,9 @@ static void parse_plane(Card& card, const string& plane_str, const OutputInfo& o
pinfo.y = output.mode.vdisplay / 2 - pinfo.h / 2;
}
-static vector<DumbFramebuffer*> get_default_fb(Card& card, unsigned width, unsigned height)
+static vector<MappedFramebuffer*> get_default_fb(Card& card, unsigned width, unsigned height)
{
- vector<DumbFramebuffer*> v;
+ vector<MappedFramebuffer*> v;
for (unsigned i = 0; i < s_num_buffers; ++i)
v.push_back(new DumbFramebuffer(card, width, height, PixelFormat::XRGB8888));
@@ -309,7 +298,7 @@ static vector<DumbFramebuffer*> get_default_fb(Card& card, unsigned width, unsig
return v;
}
-static vector<DumbFramebuffer*> parse_fb(Card& card, const string& fb_str, unsigned def_w, unsigned def_h)
+static vector<MappedFramebuffer*> parse_fb(Card& card, const string& fb_str, unsigned def_w, unsigned def_h)
{
unsigned w = def_w;
unsigned h = def_h;
@@ -334,7 +323,7 @@ static vector<DumbFramebuffer*> parse_fb(Card& card, const string& fb_str, unsig
format = FourCCToPixelFormat(sm[3]);
}
- vector<DumbFramebuffer*> v;
+ vector<MappedFramebuffer*> v;
for (unsigned i = 0; i < s_num_buffers; ++i)
v.push_back(new DumbFramebuffer(card, w, h, format));
@@ -588,7 +577,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, const vector<Arg>& outpu
// create default framebuffers if needed
for (OutputInfo& o : outputs) {
if (!o.crtc) {
- get_default_crtc(card, *current_output);
+ get_default_crtc(card, o);
o.user_set_crtc = true;
}
queue_next();
}
- static unsigned get_bar_pos(DumbFramebuffer* fb, unsigned frame_num)
+ static unsigned get_bar_pos(MappedFramebuffer* fb, unsigned frame_num)
{
return (frame_num * bar_speed) % (fb->width() - bar_width + 1);
}
- static void draw_bar(DumbFramebuffer* fb, unsigned frame_num)
+ static void draw_bar(MappedFramebuffer* fb, unsigned frame_num)
{
int old_xpos = frame_num < s_num_buffers ? -1 : get_bar_pos(fb, frame_num - s_num_buffers);
int new_xpos = get_bar_pos(fb, frame_num);
vector<OutputInfo> outputs = setups_to_outputs(card, output_args);
+ ResourceManager resman(card);
+
if (card.has_atomic()) {
for (OutputInfo& o : outputs) {
- o.primary_plane = o.crtc->get_primary_plane();
+ o.primary_plane = resman.reserve_primary_plane(o.crtc);
if (!o.fbs.empty() && !o.primary_plane)
EXIT("Could not get primary plane for crtc '%u'", o.crtc->id());