]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/commitdiff
testpat & kmsprint: improve mode prints
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 15 Aug 2016 06:55:24 +0000 (09:55 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 15 Aug 2016 09:28:04 +0000 (12:28 +0300)
kms++/inc/kms++/videomode.h
kms++/src/videomode.cpp
utils/kmsprint.cpp
utils/testpat.cpp

index f9abaf9ff0fad00c37a83a2b9eb413b4a87a7998..ec16969e41d9641ae90118d522da1c7a28d1c5af 100644 (file)
@@ -31,6 +31,9 @@ struct Videomode
        uint16_t vfp() const { return vsync_start - vdisplay; }
        uint16_t vsw() const { return vsync_end - vsync_start; }
        uint16_t vbp() const { return vtotal - vsync_end; }
+
+       bool interlace() const;
+       float calculated_vrefresh() const;
 };
 
 }
index 30d47f8d2ba82d07cfa1487a9a21de813f8871aa..16330bb700dfb5e2c484b79d4dc5d9d2d82dba40 100644 (file)
@@ -16,4 +16,14 @@ unique_ptr<Blob> Videomode::to_blob(Card& card) const
        return unique_ptr<Blob>(new Blob(card, &drm_mode, sizeof(drm_mode)));
 }
 
+bool Videomode::interlace() const
+{
+       return flags & DRM_MODE_FLAG_INTERLACE;
+}
+
+float Videomode::calculated_vrefresh() const
+{
+       return (clock * 1000.0) / (htotal * vtotal) * (interlace() ? 2 : 1);
+}
+
 }
index fe1280eb497a33d7eef29605fdc662a5fdec0f01..e6a4be49ee907b8d214c9d184e1dc54596af47a7 100644 (file)
@@ -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)
index 72081051457f2f97d7253dab416acda99289fa3c..4cde7c1783fe4fe1d3c6e0ade9dfd2520726b0dd 100644 (file)
@@ -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());