summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-07 15:48:11 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-07 17:02:08 +0300
commit75ac8699ec029b1fe4f6b1518be628e498ef30cc (patch)
tree10dc21fa2a268ea6f6f1dab7b53a9f0a77774018 /utils
parentf8fdcc208e8cbd0843842ca097ac15e5a8d74547 (diff)
kmsview: small improvements
Diffstat (limited to 'utils')
-rw-r--r--utils/kmsview.cpp68
1 files changed, 54 insertions, 14 deletions
diff --git a/utils/kmsview.cpp b/utils/kmsview.cpp
index ebe0297..b59e004 100644
--- a/utils/kmsview.cpp
+++ b/utils/kmsview.cpp
@@ -4,6 +4,7 @@
#include <kms++.h>
#include <kms++util.h>
+#include <opts.h>
using namespace std;
using namespace kms;
@@ -23,21 +24,54 @@ static void read_frame(ifstream& is, DumbFramebuffer* fb, Crtc* crtc, Plane* pla
ASSERT(r == 0);
}
+static const char* usage_str =
+ "Usage: kmsview [-t <ms>] <file> <width> <height> <fourcc>\n\n"
+ "Options:\n"
+ " -t, --time Milliseconds to sleep between frames\n"
+ ;
+
+static void usage()
+{
+ puts(usage_str);
+}
+
int main(int argc, char** argv)
{
- if (argc != 5) {
- printf("Usage: %s <file> <width> <height> <fourcc>\n", argv[0]);
- return -1;
+ uint32_t time = 0;
+ string dev_path = "/dev/dri/card0";
+
+ OptionSet optionset = {
+ Option("|device=", [&dev_path](string s)
+ {
+ dev_path = s;
+ }),
+ Option("t|time=", [&time](const string& str)
+ {
+ time = stoul(str);
+ }),
+ Option("h|help", []()
+ {
+ usage();
+ exit(-1);
+ }),
+ };
+
+ optionset.parse(argc, argv);
+
+ vector<string> params = optionset.params();
+
+ if (params.size() != 4) {
+ usage();
+ exit(-1);
}
- string filename = argv[1];
- uint32_t w = stoi(argv[2]);
- uint32_t h = stoi(argv[3]);
- string modestr = argv[4];
+ string filename = params[0];
+ uint32_t w = stoi(params[1]);
+ uint32_t h = stoi(params[2]);
+ string modestr = params[3];
auto pixfmt = FourCCToPixelFormat(modestr);
-
ifstream is(filename, ifstream::binary);
is.seekg(0, std::ios::end);
@@ -45,7 +79,7 @@ int main(int argc, char** argv)
is.seekg(0);
- Card card;
+ Card card(dev_path);
auto conn = card.get_first_connected_connector();
auto crtc = conn->get_current_crtc();
@@ -76,16 +110,22 @@ int main(int argc, char** argv)
printf("file size %u, frame size %u, frames %u\n", fsize, frame_size, num_frames);
for (unsigned i = 0; i < num_frames; ++i) {
- printf("frame %d\n", i);
+ printf("frame %d", i); fflush(stdout);
read_frame(is, fb, crtc, plane);
- usleep(1000*50);
+ if (!time) {
+ getchar();
+ } else {
+ usleep(time * 1000);
+ printf("\n");
+ }
}
- printf("press enter to exit\n");
-
is.close();
- getchar();
+ if (time) {
+ printf("press enter to exit\n");
+ getchar();
+ }
delete fb;
}