summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/CMakeLists.txt3
-rw-r--r--utils/fbtestpat.cpp6
-rw-r--r--utils/kmsprint.cpp14
-rw-r--r--utils/testpat.cpp49
4 files changed, 30 insertions, 42 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index dd95f70..0b15481 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -24,3 +24,6 @@ target_link_libraries(wbcap kms++ kms++util ${LIBDRM_LIBRARIES})
add_executable (wbm2m wbm2m.cpp)
target_link_libraries(wbm2m kms++ kms++util ${LIBDRM_LIBRARIES})
+
+install(TARGETS testpat kmsprint fbtestpat
+ DESTINATION bin)
diff --git a/utils/fbtestpat.cpp b/utils/fbtestpat.cpp
index 4fe0d41..1c9a5f1 100644
--- a/utils/fbtestpat.cpp
+++ b/utils/fbtestpat.cpp
@@ -40,7 +40,8 @@ int main(int argc, char** argv)
FAIL_IF(ptr == MAP_FAILED, "mmap failed");
- ExtCPUFramebuffer buf(var.xres, var.yres_virtual, PixelFormat::XRGB8888, ptr, fix.line_length);
+ ExtCPUFramebuffer buf(var.xres, var.yres, PixelFormat::XRGB8888,
+ ptr, var.yres_virtual * fix.line_length, fix.line_length, 0);
printf("%s: res %dx%d, virtual %dx%d, line_len %d\n",
fbdev,
@@ -51,9 +52,6 @@ int main(int argc, char** argv)
draw_test_pattern(buf);
draw_text(buf, buf.width() / 2, 0, fbdev, RGB(255, 255, 255));
- for (unsigned y = 0; y < var.yres_virtual; ++y)
- memcpy(ptr + fix.line_length * y, buf.map(0) + buf.stride(0) * y, buf.stride(0));
-
close(fd);
return 0;
diff --git a/utils/kmsprint.cpp b/utils/kmsprint.cpp
index fe1280e..e6a4be4 100644
--- a/utils/kmsprint.cpp
+++ b/utils/kmsprint.cpp
@@ -25,7 +25,7 @@ static string format_mode(const Videomode& m, unsigned idx)
str = sformat(" %2u ", idx);
if (s_opts.x_modeline) {
- str += sformat("%12s %6d %4u %4u %4u %4u %4u %4u %4u %4u %2u %#x %#x",
+ str += sformat("%12s %6u %4u %4u %4u %4u %4u %4u %4u %4u %2u %#x %#x",
m.name.c_str(),
m.clock,
m.hdisplay, m.hsync_start, m.hsync_end, m.htotal,
@@ -37,11 +37,11 @@ static string format_mode(const Videomode& m, unsigned idx)
string h = sformat("%u/%u/%u/%u", m.hdisplay, m.hfp(), m.hsw(), m.hbp());
string v = sformat("%u/%u/%u/%u", m.vdisplay, m.vfp(), m.vsw(), m.vbp());
- str += sformat("%-12s %6d %-16s %-16s %2u %#10x %#6x",
+ str += sformat("%-12s %7.3f %-16s %-16s %2u (%.2f) %#10x %#6x",
m.name.c_str(),
- m.clock,
+ m.clock / 1000.0,
h.c_str(), v.c_str(),
- m.vrefresh,
+ m.vrefresh, m.calculated_vrefresh(),
m.flags,
m.type);
}
@@ -54,11 +54,11 @@ static string format_mode_short(const Videomode& m)
string h = sformat("%u/%u/%u/%u", m.hdisplay, m.hfp(), m.hsw(), m.hbp());
string v = sformat("%u/%u/%u/%u", m.vdisplay, m.vfp(), m.vsw(), m.vbp());
- return sformat("%s %d %s %s %u",
+ return sformat("%s %.3f %s %s %u (%.2f)",
m.name.c_str(),
- m.clock,
+ m.clock / 1000.0,
h.c_str(), v.c_str(),
- m.vrefresh);
+ m.vrefresh, m.calculated_vrefresh());
}
static string format_connector(Connector& c)
diff --git a/utils/testpat.cpp b/utils/testpat.cpp
index 7208105..ccddccb 100644
--- a/utils/testpat.cpp
+++ b/utils/testpat.cpp
@@ -102,7 +102,7 @@ static void get_default_crtc(Card& card, OutputInfo& output)
static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output)
{
// @12:1920x1200@60
- const regex mode_re("(?:(@?)(\\d+):)?(?:(\\d+)x(\\d+)(i)?)(?:@(\\d+))?");
+ const regex mode_re("(?:(@?)(\\d+):)?(?:(\\d+)x(\\d+)(i)?)(?:@([\\d\\.]+))?");
smatch sm;
if (!regex_match(crtc_str, sm, mode_re))
@@ -133,7 +133,7 @@ static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output)
unsigned w = stoul(sm[3]);
unsigned h = stoul(sm[4]);
bool ilace = sm[5].matched ? true : false;
- unsigned refresh = sm[6].matched ? stoul(sm[6]) : 0;
+ float refresh = sm[6].matched ? stof(sm[6]) : 0;
bool found_mode = false;
@@ -507,29 +507,18 @@ static vector<OutputInfo> setups_to_outputs(Card& card, const vector<Arg>& outpu
return outputs;
}
-static std::string videomode_to_string(const Videomode& mode)
+static std::string videomode_to_string(const Videomode& m)
{
- unsigned hfp = mode.hsync_start - mode.hdisplay;
- unsigned hsw = mode.hsync_end - mode.hsync_start;
- unsigned hbp = mode.htotal - mode.hsync_end;
-
- unsigned vfp = mode.vsync_start - mode.vdisplay;
- unsigned vsw = mode.vsync_end - mode.vsync_start;
- unsigned vbp = mode.vtotal - mode.vsync_end;
-
- float hz = (mode.clock * 1000.0) / (mode.htotal * mode.vtotal);
- if (mode.flags & (1<<4)) // XXX interlace
- hz *= 2;
-
- char buf[256];
-
- sprintf(buf, "%.2f MHz %u/%u/%u/%u %u/%u/%u/%u %uHz (%.2fHz)",
- mode.clock / 1000.0,
- mode.hdisplay, hfp, hsw, hbp,
- mode.vdisplay, vfp, vsw, vbp,
- mode.vrefresh, hz);
-
- return std::string(buf);
+ string h = sformat("%u/%u/%u/%u", m.hdisplay, m.hfp(), m.hsw(), m.hbp());
+ string v = sformat("%u/%u/%u/%u", m.vdisplay, m.vfp(), m.vsw(), m.vbp());
+
+ return sformat("%s %.3f %s %s %u (%.2f) %#x %#x",
+ m.name.c_str(),
+ m.clock / 1000.0,
+ h.c_str(), v.c_str(),
+ m.vrefresh, m.calculated_vrefresh(),
+ m.flags,
+ m.type);
}
static void print_outputs(const vector<OutputInfo>& outputs)
@@ -537,14 +526,12 @@ static void print_outputs(const vector<OutputInfo>& outputs)
for (unsigned i = 0; i < outputs.size(); ++i) {
const OutputInfo& o = outputs[i];
- printf("Connector %u/@%u: %s\n", o.connector->id(), o.connector->idx(),
+ printf("Connector %u/@%u: %s\n", o.connector->idx(), o.connector->id(),
o.connector->fullname().c_str());
- printf(" Crtc %u/@%u", o.crtc->id(), o.crtc->idx());
+ printf(" Crtc %u/@%u", o.crtc->idx(), o.crtc->id());
if (o.primary_plane)
- printf(" (plane %u/@%u)", o.primary_plane->id(), o.primary_plane->idx());
- printf(": %ux%u-%u (%s)\n",
- o.mode.hdisplay, o.mode.vdisplay, o.mode.vrefresh,
- videomode_to_string(o.mode).c_str());
+ printf(" (plane %u/@%u)", o.primary_plane->idx(), o.primary_plane->id());
+ printf(": %s\n", videomode_to_string(o.mode).c_str());
if (!o.fbs.empty()) {
auto fb = o.fbs[0];
printf(" Fb %u %ux%u-%s\n", fb->id(), fb->width(), fb->height(),
@@ -554,7 +541,7 @@ static void print_outputs(const vector<OutputInfo>& outputs)
for (unsigned j = 0; j < o.planes.size(); ++j) {
const PlaneInfo& p = o.planes[j];
auto fb = p.fbs[0];
- printf(" Plane %u/@%u: %u,%u-%ux%u\n", p.plane->id(), p.plane->idx(),
+ printf(" Plane %u/@%u: %u,%u-%ux%u\n", p.plane->idx(), p.plane->id(),
p.x, p.y, p.w, p.h);
printf(" Fb %u %ux%u-%s\n", fb->id(), fb->width(), fb->height(),
PixelFormatToFourCC(fb->format()).c_str());