summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2019-09-24 12:52:14 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2019-09-25 14:49:06 +0300
commit40bc9d1095228ab1377625be3479491263d696d7 (patch)
tree68e02263767217c5302788a7c974c3786fb9e44b /utils
parentf887436cebefd30f2bfadcfb7210703baa8ca93c (diff)
videomode to_string improvements
Add to_string_short() and to_string_long() to videomode (using the fmt library) for easy printing of videomodes. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/kmsprint.cpp11
-rw-r--r--utils/kmstest.cpp28
-rw-r--r--utils/wbcap.cpp4
3 files changed, 4 insertions, 39 deletions
diff --git a/utils/kmsprint.cpp b/utils/kmsprint.cpp
index 116fead..01913fb 100644
--- a/utils/kmsprint.cpp
+++ b/utils/kmsprint.cpp
@@ -34,16 +34,7 @@ static string format_mode(const Videomode& m, unsigned idx)
m.flags,
m.type);
} else {
- 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 %7.3f %-16s %-16s %2u (%.2f) %#10x %#6x",
- m.name.c_str(),
- m.clock / 1000.0,
- h.c_str(), v.c_str(),
- m.vrefresh, m.calculated_vrefresh(),
- m.flags,
- m.type);
+ str += m.to_string_long_padded();
}
return str;
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index 8144117..2e3d054 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -691,32 +691,6 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
return outputs;
}
-static char sync_to_char(SyncPolarity pol)
-{
- switch (pol) {
- case SyncPolarity::Positive:
- return '+';
- case SyncPolarity::Negative:
- return '-';
- default:
- return '?';
- }
-}
-
-static std::string videomode_to_string(const Videomode& m)
-{
- string h = sformat("%u/%u/%u/%u/%c", m.hdisplay, m.hfp(), m.hsw(), m.hbp(), sync_to_char(m.hsync()));
- string v = sformat("%u/%u/%u/%u/%c", m.vdisplay, m.vfp(), m.vsw(), m.vbp(), sync_to_char(m.vsync()));
-
- 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)
{
for (unsigned i = 0; i < outputs.size(); ++i) {
@@ -735,7 +709,7 @@ static void print_outputs(const vector<OutputInfo>& outputs)
printf(" %s=%" PRIu64, prop.prop->name().c_str(),
prop.val);
- printf(": %s\n", videomode_to_string(o.mode).c_str());
+ printf(": %s\n", o.mode.to_string_long().c_str());
if (!o.legacy_fbs.empty()) {
auto fb = o.legacy_fbs[0];
diff --git a/utils/wbcap.cpp b/utils/wbcap.cpp
index 5a94a70..886fe36 100644
--- a/utils/wbcap.cpp
+++ b/utils/wbcap.cpp
@@ -342,9 +342,9 @@ int main(int argc, char** argv)
if (src_mode.interlace())
dst_height /= 2;
- printf("src %s, crtc %s\n", src_conn->fullname().c_str(), src_mode.to_string().c_str());
+ printf("src %s, crtc %s\n", src_conn->fullname().c_str(), src_mode.to_string_short().c_str());
- printf("dst %s, crtc %s\n", dst_conn->fullname().c_str(), dst_mode.to_string().c_str());
+ printf("dst %s, crtc %s\n", dst_conn->fullname().c_str(), dst_mode.to_string_short().c_str());
printf("src_fb %ux%u, dst_fb %ux%u\n", src_width, src_height, dst_width, dst_height);