summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/fbtest.cpp6
-rw-r--r--utils/kmsblank.cpp33
-rw-r--r--utils/kmscapture.cpp69
-rw-r--r--utils/kmsprint.cpp106
-rw-r--r--utils/kmstest.cpp314
-rw-r--r--utils/kmstouch.cpp50
-rw-r--r--utils/kmsview.cpp25
-rw-r--r--utils/wbcap.cpp69
-rw-r--r--utils/wbm2m.cpp40
9 files changed, 317 insertions, 395 deletions
diff --git a/utils/fbtest.cpp b/utils/fbtest.cpp
index 1c9a5f1..fba7ba7 100644
--- a/utils/fbtest.cpp
+++ b/utils/fbtest.cpp
@@ -34,9 +34,9 @@ int main(int argc, char** argv)
FAIL_IF(r, "FBIOGET_FSCREENINFO failed");
uint8_t* ptr = (uint8_t*)mmap(NULL,
- var.yres_virtual * fix.line_length,
- PROT_WRITE | PROT_READ,
- MAP_SHARED, fd, 0);
+ var.yres_virtual * fix.line_length,
+ PROT_WRITE | PROT_READ,
+ MAP_SHARED, fd, 0);
FAIL_IF(ptr == MAP_FAILED, "mmap failed");
diff --git a/utils/kmsblank.cpp b/utils/kmsblank.cpp
index 286c7f7..d9a3460 100644
--- a/utils/kmsblank.cpp
+++ b/utils/kmsblank.cpp
@@ -9,23 +9,22 @@ using namespace std;
using namespace kms;
static const char* usage_str =
- "Usage: kmsblank [OPTION]...\n\n"
- "Blank screen(s)\n\n"
- "Options:\n"
- " --device=DEVICE DEVICE is the path to DRM card to open\n"
- " -c, --connector=CONN CONN is <connector>\n"
- " -t, --time=TIME blank/unblank in TIME intervals\n"
- "\n"
- "<connector> can be given by index (<idx>) or id (@<id>).\n"
- "<connector> can also be given by name.\n"
- ;
+ "Usage: kmsblank [OPTION]...\n\n"
+ "Blank screen(s)\n\n"
+ "Options:\n"
+ " --device=DEVICE DEVICE is the path to DRM card to open\n"
+ " -c, --connector=CONN CONN is <connector>\n"
+ " -t, --time=TIME blank/unblank in TIME intervals\n"
+ "\n"
+ "<connector> can be given by index (<idx>) or id (@<id>).\n"
+ "<connector> can also be given by name.\n";
static void usage()
{
puts(usage_str);
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
string dev_path;
@@ -33,20 +32,16 @@ int main(int argc, char **argv)
uint32_t time = 0;
OptionSet optionset = {
- Option("|device=", [&dev_path](string s)
- {
+ Option("|device=", [&dev_path](string s) {
dev_path = s;
}),
- Option("c|connector=", [&conn_strs](string str)
- {
+ Option("c|connector=", [&conn_strs](string str) {
conn_strs.push_back(str);
}),
- Option("t|time=", [&time](string str)
- {
+ Option("t|time=", [&time](string str) {
time = stoul(str);
}),
- Option("h|help", []()
- {
+ Option("h|help", []() {
usage();
exit(-1);
}),
diff --git a/utils/kmscapture.cpp b/utils/kmscapture.cpp
index a36b355..099d40f 100644
--- a/utils/kmscapture.cpp
+++ b/utils/kmscapture.cpp
@@ -11,8 +11,8 @@
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
-#define CAMERA_BUF_QUEUE_SIZE 3
-#define MAX_CAMERA 9
+#define CAMERA_BUF_QUEUE_SIZE 3
+#define MAX_CAMERA 9
using namespace std;
using namespace kms;
@@ -33,12 +33,13 @@ public:
CameraPipeline(const CameraPipeline& other) = delete;
CameraPipeline& operator=(const CameraPipeline& other) = delete;
- void show_next_frame(AtomicReq &req);
+ void show_next_frame(AtomicReq& req);
int fd() const { return m_fd; }
void start_streaming();
+
private:
DmabufFramebuffer* GetDmabufFrameBuffer(Card& card, uint32_t i, PixelFormat pixfmt);
- int m_fd; /* camera file descriptor */
+ int m_fd; /* camera file descriptor */
Crtc* m_crtc;
Plane* m_plane;
BufferProvider m_buffer_provider;
@@ -50,7 +51,7 @@ private:
uint32_t m_out_x, m_out_y;
};
-static int buffer_export(int v4lfd, enum v4l2_buf_type bt, uint32_t index, int *dmafd)
+static int buffer_export(int v4lfd, enum v4l2_buf_type bt, uint32_t index, int* dmafd)
{
struct v4l2_exportbuffer expbuf;
@@ -77,12 +78,12 @@ DmabufFramebuffer* CameraPipeline::GetDmabufFrameBuffer(Card& card, uint32_t i,
const PixelFormatInfo& format_info = get_pixel_format_info(pixfmt);
ASSERT(format_info.num_planes == 1);
- vector<int> fds { dmafd };
- vector<uint32_t> pitches { m_in_width * (format_info.planes[0].bitspp / 8) };
- vector<uint32_t> offsets { 0 };
+ vector<int> fds{ dmafd };
+ vector<uint32_t> pitches{ m_in_width * (format_info.planes[0].bitspp / 8) };
+ vector<uint32_t> offsets{ 0 };
return new DmabufFramebuffer(card, m_in_width, m_in_height, pixfmt,
- fds, pitches, offsets);
+ fds, pitches, offsets);
}
bool inline better_size(struct v4l2_frmsize_discrete* v4ldisc,
@@ -96,17 +97,16 @@ bool inline better_size(struct v4l2_frmsize_discrete* v4ldisc,
return false;
}
-CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane, uint32_t x, uint32_t y,
+CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc* crtc, Plane* plane, uint32_t x, uint32_t y,
uint32_t iw, uint32_t ih, PixelFormat pixfmt,
BufferProvider buffer_provider)
: m_fd(cam_fd), m_crtc(crtc), m_buffer_provider(buffer_provider), m_prev_fb_index(-1)
{
-
int r;
uint32_t best_w = 320;
uint32_t best_h = 240;
- struct v4l2_frmsizeenum v4lfrms = { };
+ struct v4l2_frmsizeenum v4lfrms = {};
v4lfrms.pixel_format = (uint32_t)pixfmt;
while (ioctl(m_fd, VIDIOC_ENUM_FRAMESIZES, &v4lfrms) == 0) {
if (v4lfrms.type != V4L2_FRMSIZE_TYPE_DISCRETE) {
@@ -137,7 +137,7 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
printf("Capture: %ux%u\n", best_w, best_h);
- struct v4l2_format v4lfmt = { };
+ struct v4l2_format v4lfmt = {};
v4lfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
r = ioctl(m_fd, VIDIOC_G_FMT, &v4lfmt);
ASSERT(r == 0);
@@ -156,7 +156,7 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
else
v4l_mem = V4L2_MEMORY_DMABUF;
- struct v4l2_requestbuffers v4lreqbuf = { };
+ struct v4l2_requestbuffers v4lreqbuf = {};
v4lreqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4lreqbuf.memory = v4l_mem;
v4lreqbuf.count = CAMERA_BUF_QUEUE_SIZE;
@@ -164,12 +164,12 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
ASSERT(r == 0);
ASSERT(v4lreqbuf.count == CAMERA_BUF_QUEUE_SIZE);
- struct v4l2_buffer v4lbuf = { };
+ struct v4l2_buffer v4lbuf = {};
v4lbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4lbuf.memory = v4l_mem;
for (unsigned i = 0; i < CAMERA_BUF_QUEUE_SIZE; i++) {
- Framebuffer *fb;
+ Framebuffer* fb;
if (m_buffer_provider == BufferProvider::V4L2)
fb = GetDmabufFrameBuffer(card, i, pixfmt);
@@ -192,7 +192,7 @@ CameraPipeline::CameraPipeline(int cam_fd, Card& card, Crtc *crtc, Plane* plane,
// set the FB when page flipping
AtomicReq req(card);
- Framebuffer *fb = m_fb[0];
+ Framebuffer* fb = m_fb[0];
req.add(m_plane, "CRTC_ID", m_crtc->id());
req.add(m_plane, "FB_ID", fb->id());
@@ -237,7 +237,7 @@ void CameraPipeline::show_next_frame(AtomicReq& req)
else
v4l_mem = V4L2_MEMORY_DMABUF;
- struct v4l2_buffer v4l2buf = { };
+ struct v4l2_buffer v4l2buf = {};
v4l2buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2buf.memory = v4l_mem;
r = ioctl(m_fd, VIDIOC_DQBUF, &v4l2buf);
@@ -248,7 +248,7 @@ void CameraPipeline::show_next_frame(AtomicReq& req)
unsigned fb_index = v4l2buf.index;
- Framebuffer *fb = m_fb[fb_index];
+ Framebuffer* fb = m_fb[fb_index];
req.add(m_plane, "FB_ID", fb->id());
@@ -261,7 +261,6 @@ void CameraPipeline::show_next_frame(AtomicReq& req)
v4l2buf.m.fd = m_fb[m_prev_fb_index]->prime_fd(0);
r = ioctl(m_fd, VIDIOC_QBUF, &v4l2buf);
ASSERT(r == 0);
-
}
m_prev_fb_index = fb_index;
@@ -269,7 +268,7 @@ void CameraPipeline::show_next_frame(AtomicReq& req)
static bool is_capture_dev(int fd)
{
- struct v4l2_capability cap = { };
+ struct v4l2_capability cap = {};
int r = ioctl(fd, VIDIOC_QUERYCAP, &cap);
ASSERT(r == 0);
return cap.capabilities & V4L2_CAP_VIDEO_CAPTURE;
@@ -280,19 +279,18 @@ std::vector<std::string> glob(const std::string& pat)
glob_t glob_result;
glob(pat.c_str(), 0, NULL, &glob_result);
vector<string> ret;
- for(unsigned i = 0; i < glob_result.gl_pathc; ++i)
+ for (unsigned i = 0; i < glob_result.gl_pathc; ++i)
ret.push_back(string(glob_result.gl_pathv[i]));
globfree(&glob_result);
return ret;
}
static const char* usage_str =
- "Usage: kmscapture [OPTIONS]\n\n"
- "Options:\n"
- " -s, --single Single camera mode. Open only /dev/video0\n"
- " --buffer-type=<drm|v4l> Use DRM or V4L provided buffers. Default: DRM\n"
- " -h, --help Print this help\n"
- ;
+ "Usage: kmscapture [OPTIONS]\n\n"
+ "Options:\n"
+ " -s, --single Single camera mode. Open only /dev/video0\n"
+ " --buffer-type=<drm|v4l> Use DRM or V4L provided buffers. Default: DRM\n"
+ " -h, --help Print this help\n";
int main(int argc, char** argv)
{
@@ -300,12 +298,10 @@ int main(int argc, char** argv)
bool single_cam = false;
OptionSet optionset = {
- Option("s|single", [&]()
- {
+ Option("s|single", [&]() {
single_cam = true;
}),
- Option("|buffer-type=", [&](string s)
- {
+ Option("|buffer-type=", [&](string s) {
if (s == "v4l")
buffer_provider = BufferProvider::V4L2;
else if (s == "drm")
@@ -313,8 +309,7 @@ int main(int argc, char** argv)
else
FAIL("Invalid buffer provider: %s", s.c_str());
}),
- Option("h|help", [&]()
- {
+ Option("h|help", [&]() {
puts(usage_str);
exit(-1);
}),
@@ -334,7 +329,7 @@ int main(int argc, char** argv)
auto conn = card.get_first_connected_connector();
auto crtc = conn->get_current_crtc();
printf("Display: %dx%d\n", crtc->width(), crtc->height());
- printf("Buffer provider: %s\n", buffer_provider == BufferProvider::V4L2? "V4L" : "DRM");
+ printf("Buffer provider: %s\n", buffer_provider == BufferProvider::V4L2 ? "V4L" : "DRM");
vector<int> camera_fds;
@@ -389,10 +384,10 @@ int main(int argc, char** argv)
for (unsigned i = 0; i < nr_cameras; i++) {
fds[i].fd = cameras[i]->fd();
- fds[i].events = POLLIN;
+ fds[i].events = POLLIN;
}
fds[nr_cameras].fd = 0;
- fds[nr_cameras].events = POLLIN;
+ fds[nr_cameras].events = POLLIN;
for (auto cam : cameras)
cam->start_streaming();
diff --git a/utils/kmsprint.cpp b/utils/kmsprint.cpp
index 9d3d7cc..7469b47 100644
--- a/utils/kmsprint.cpp
+++ b/utils/kmsprint.cpp
@@ -27,13 +27,13 @@ static string format_mode(const Videomode& m, unsigned idx)
if (s_opts.x_modeline) {
str += fmt::format("{:12} {:6} {:4} {:4} {:4} {:4} {:4} {:4} {:4} {:4} {:3} {:#x} {:#x}",
- m.name,
- m.clock,
- m.hdisplay, m.hsync_start, m.hsync_end, m.htotal,
- m.vdisplay, m.vsync_start, m.vsync_end, m.vtotal,
- m.vrefresh,
- m.flags,
- m.type);
+ m.name,
+ m.clock,
+ m.hdisplay, m.hsync_start, m.hsync_end, m.htotal,
+ m.vdisplay, m.vsync_start, m.vsync_end, m.vtotal,
+ m.vrefresh,
+ m.flags,
+ m.type);
} else {
str += m.to_string_long_padded();
}
@@ -51,7 +51,7 @@ static string format_connector(Connector& c)
string str;
str = fmt::format("Connector {} ({}) {}",
- c.idx(), c.id(), c.fullname());
+ c.idx(), c.id(), c.fullname());
switch (c.connector_status()) {
case ConnectorStatus::Connected:
@@ -71,7 +71,7 @@ static string format_connector(Connector& c)
static string format_encoder(Encoder& e)
{
return fmt::format("Encoder {} ({}) {}",
- e.idx(), e.id(), e.get_encoder_type());
+ e.idx(), e.id(), e.get_encoder_type());
}
static string format_crtc(Crtc& c)
@@ -101,14 +101,14 @@ static string format_plane(Plane& p)
if (p.card().has_atomic()) {
str += fmt::format(" {},{} {}x{} -> {},{} {}x{}",
- (uint32_t)p.get_prop_value("SRC_X") >> 16,
- (uint32_t)p.get_prop_value("SRC_Y") >> 16,
- (uint32_t)p.get_prop_value("SRC_W") >> 16,
- (uint32_t)p.get_prop_value("SRC_H") >> 16,
- (uint32_t)p.get_prop_value("CRTC_X"),
- (uint32_t)p.get_prop_value("CRTC_Y"),
- (uint32_t)p.get_prop_value("CRTC_W"),
- (uint32_t)p.get_prop_value("CRTC_H"));
+ (uint32_t)p.get_prop_value("SRC_X") >> 16,
+ (uint32_t)p.get_prop_value("SRC_Y") >> 16,
+ (uint32_t)p.get_prop_value("SRC_W") >> 16,
+ (uint32_t)p.get_prop_value("SRC_H") >> 16,
+ (uint32_t)p.get_prop_value("CRTC_X"),
+ (uint32_t)p.get_prop_value("CRTC_Y"),
+ (uint32_t)p.get_prop_value("CRTC_W"),
+ (uint32_t)p.get_prop_value("CRTC_H"));
}
string fmts = join<PixelFormat>(p.get_formats(), " ", [](PixelFormat fmt) { return PixelFormatToFourCC(fmt); });
@@ -121,7 +121,7 @@ static string format_plane(Plane& p)
static string format_fb(Framebuffer& fb)
{
return fmt::format("FB {} {}x{}",
- fb.id(), fb.width(), fb.height());
+ fb.id(), fb.width(), fb.height());
}
static string format_property(const Property* prop, uint64_t val)
@@ -129,8 +129,7 @@ static string format_property(const Property* prop, uint64_t val)
string ret = fmt::format("{} ({}) = ", prop->name(), prop->id());
switch (prop->type()) {
- case PropertyType::Bitmask:
- {
+ case PropertyType::Bitmask: {
vector<string> v, vall;
for (auto kvp : prop->get_enums()) {
@@ -145,8 +144,7 @@ static string format_property(const Property* prop, uint64_t val)
break;
}
- case PropertyType::Blob:
- {
+ case PropertyType::Blob: {
uint32_t blob_id = (uint32_t)val;
if (blob_id) {
@@ -161,8 +159,7 @@ static string format_property(const Property* prop, uint64_t val)
break;
}
- case PropertyType::Enum:
- {
+ case PropertyType::Enum: {
string cur;
vector<string> vall;
@@ -177,32 +174,28 @@ static string format_property(const Property* prop, uint64_t val)
break;
}
- case PropertyType::Object:
- {
+ case PropertyType::Object: {
ret += fmt::format("object id {}", val);
break;
}
- case PropertyType::Range:
- {
+ case PropertyType::Range: {
auto values = prop->get_values();
ret += fmt::format("{} [{} - {}]",
- val, values[0], values[1]);
+ val, values[0], values[1]);
break;
}
- case PropertyType::SignedRange:
- {
+ case PropertyType::SignedRange: {
auto values = prop->get_values();
ret += fmt::format("{} [{} - {}]",
- (int64_t)val, (int64_t)values[0], (int64_t)values[1]);
+ (int64_t)val, (int64_t)values[0], (int64_t)values[1]);
break;
}
-
}
if (prop->is_pending())
@@ -247,15 +240,14 @@ vector<T> filter(const vector<T>& sequence, function<bool(T)> predicate)
{
vector<T> result;
- for(auto it = sequence.begin(); it != sequence.end(); ++it)
- if(predicate(*it))
+ for (auto it = sequence.begin(); it != sequence.end(); ++it)
+ if (predicate(*it))
result.push_back(*it);
return result;
}
-struct Entry
-{
+struct Entry {
string title;
vector<string> lines;
vector<Entry> children;
@@ -345,7 +337,7 @@ static void print_entry(const Entry& e, const string& prefix, bool is_child, boo
static void print_entries(const vector<Entry>& entries, const string& prefix)
{
- for (const Entry& e: entries) {
+ for (const Entry& e : entries) {
print_entry(e, "", false, false);
}
}
@@ -356,7 +348,6 @@ static void append(vector<DrmObject*>& dst, const vector<T*>& src)
dst.insert(dst.end(), src.begin(), src.end());
}
-
static void print_as_list(Card& card)
{
vector<DrmPropObject*> obs;
@@ -386,7 +377,7 @@ static void print_as_list(Card& card)
}
}
- for (DrmPropObject* ob: obs) {
+ for (DrmPropObject* ob : obs) {
fmt::print("{}\n", format_ob(ob));
if (s_opts.print_props) {
@@ -395,7 +386,7 @@ static void print_as_list(Card& card)
}
}
- for (Framebuffer* fb: fbs) {
+ for (Framebuffer* fb : fbs) {
fmt::print("{}\n", format_ob(fb));
}
}
@@ -411,7 +402,6 @@ static void print_as_tree(Card& card)
e1.lines = format_props(conn);
for (Encoder* enc : conn->get_encoders()) {
-
Entry& e2 = add_entry(e1.children);
e2.title = format_ob(enc);
if (s_opts.print_props)
@@ -470,46 +460,40 @@ static void print_modes(Card& card)
}
static const char* usage_str =
- "Usage: kmsprint [OPTIONS]\n\n"
- "Options:\n"
- " --device=DEVICE DEVICE is the path to DRM card to open\n"
- " -l, --list Print list instead of tree\n"
- " -m, --modes Print modes\n"
- " --xmode Print modes using X modeline\n"
- " -p, --props Print properties\n"
- ;
+ "Usage: kmsprint [OPTIONS]\n\n"
+ "Options:\n"
+ " --device=DEVICE DEVICE is the path to DRM card to open\n"
+ " -l, --list Print list instead of tree\n"
+ " -m, --modes Print modes\n"
+ " --xmode Print modes using X modeline\n"
+ " -p, --props Print properties\n";
static void usage()
{
puts(usage_str);
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
string dev_path;
OptionSet optionset = {
- Option("|device=", [&dev_path](string s)
- {
+ Option("|device=", [&dev_path](string s) {
dev_path = s;
}),
- Option("l|list", []()
- {
+ Option("l|list", []() {
s_opts.print_list = true;
}),
- Option("m|modes", []()
- {
+ Option("m|modes", []() {
s_opts.print_modes = true;
}),
- Option("p|props", []()
- {
+ Option("p|props", []() {
s_opts.print_props = true;
}),
Option("|xmode", []() {
s_opts.x_modeline = true;
}),
- Option("h|help", []()
- {
+ Option("h|help", []() {
usage();
exit(-1);
}),
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index b4bf24b..981a2fd 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -21,15 +21,15 @@ using namespace std;
using namespace kms;
struct PropInfo {
- PropInfo(string n, uint64_t v) : prop(NULL), name(n), val(v) {}
+ PropInfo(string n, uint64_t v)
+ : prop(NULL), name(n), val(v) {}
- Property *prop;
+ Property* prop;
string name;
uint64_t val;
};
-struct PlaneInfo
-{
+struct PlaneInfo {
Plane* plane;
unsigned x;
@@ -47,8 +47,7 @@ struct PlaneInfo
vector<PropInfo> props;
};
-struct OutputInfo
-{
+struct OutputInfo {
Connector* connector;
Crtc* crtc;
@@ -72,8 +71,7 @@ static bool s_cvt_vid_opt;
static unsigned s_max_flips;
static bool s_print_crc;
-__attribute__ ((unused))
-static void print_regex_match(smatch sm)
+__attribute__((unused)) static void print_regex_match(smatch sm)
{
for (unsigned i = 0; i < sm.size(); ++i) {
string str = sm[i].str();
@@ -100,11 +98,10 @@ static void get_default_crtc(ResourceManager& resman, OutputInfo& output)
EXIT("Could not find available crtc");
}
-
-static PlaneInfo *add_default_planeinfo(OutputInfo* output)
+static PlaneInfo* add_default_planeinfo(OutputInfo* output)
{
- output->planes.push_back(PlaneInfo { });
- PlaneInfo *ret = &output->planes.back();
+ output->planes.push_back(PlaneInfo{});
+ PlaneInfo* ret = &output->planes.back();
ret->w = output->mode.hdisplay;
ret->h = output->mode.vdisplay;
return ret;
@@ -115,16 +112,16 @@ static void parse_crtc(ResourceManager& resman, Card& card, const string& crtc_s
// @12:1920x1200i@60
// @12:33000000,800/210/30/16/-,480/22/13/10/-,i
- const regex modename_re("(?:(@?)(\\d+):)?" // @12:
- "(?:(\\d+)x(\\d+)(i)?)" // 1920x1200i
- "(?:@([\\d\\.]+))?"); // @60
+ const regex modename_re("(?:(@?)(\\d+):)?" // @12:
+ "(?:(\\d+)x(\\d+)(i)?)" // 1920x1200i
+ "(?:@([\\d\\.]+))?"); // @60
- const regex modeline_re("(?:(@?)(\\d+):)?" // @12:
- "(\\d+)," // 33000000,
- "(\\d+)/(\\d+)/(\\d+)/(\\d+)/([+-])," // 800/210/30/16/-,
- "(\\d+)/(\\d+)/(\\d+)/(\\d+)/([+-])" // 480/22/13/10/-
- "(?:,([i]+))?" // ,i
- );
+ const regex modeline_re("(?:(@?)(\\d+):)?" // @12:
+ "(\\d+)," // 33000000,
+ "(\\d+)/(\\d+)/(\\d+)/(\\d+)/([+-])," // 800/210/30/16/-,
+ "(\\d+)/(\\d+)/(\\d+)/(\\d+)/([+-])" // 480/22/13/10/-
+ "(?:,([i]+))?" // ,i
+ );
smatch sm;
if (regex_match(crtc_str, sm, modename_re)) {
@@ -246,9 +243,9 @@ static void parse_crtc(ResourceManager& resman, Card& card, const string& crtc_s
static void parse_plane(ResourceManager& resman, Card& card, const string& plane_str, const OutputInfo& output, PlaneInfo& pinfo)
{
// 3:400,400-400x400
- const regex plane_re("(?:(@?)(\\d+):)?" // 3:
- "(?:(\\d+),(\\d+)-)?" // 400,400-
- "(\\d+)x(\\d+)"); // 400x400
+ const regex plane_re("(?:(@?)(\\d+):)?" // 3:
+ "(?:(\\d+),(\\d+)-)?" // 400,400-
+ "(\\d+)x(\\d+)"); // 400x400
smatch sm;
if (!regex_match(plane_str, sm, plane_re))
@@ -292,7 +289,7 @@ static void parse_plane(ResourceManager& resman, Card& card, const string& plane
pinfo.y = output.mode.vdisplay / 2 - pinfo.h / 2;
}
-static void parse_prop(const string& prop_str, vector<PropInfo> &props)
+static void parse_prop(const string& prop_str, vector<PropInfo>& props)
{
string name, val;
@@ -302,12 +299,12 @@ static void parse_prop(const string& prop_str, vector<PropInfo> &props)
EXIT("Equal sign ('=') not found in %s", prop_str.c_str());
name = prop_str.substr(0, split);
- val = prop_str.substr(split+1);
+ val = prop_str.substr(split + 1);
props.push_back(PropInfo(name, stoull(val, 0, 0)));
}
-static void get_props(Card& card, vector<PropInfo> &props, const DrmPropObject* propobj)
+static void get_props(Card& card, vector<PropInfo>& props, const DrmPropObject* propobj)
{
for (auto& pi : props)
pi.prop = propobj->get_prop(pi.name);
@@ -339,9 +336,9 @@ static void parse_fb(Card& card, const string& fb_str, OutputInfo* output, Plane
if (!fb_str.empty()) {
// XXX the regexp is not quite correct
// 400x400-NV12
- const regex fb_re("(?:(\\d+)x(\\d+))?" // 400x400
- "(?:-)?" // -
- "(\\w\\w\\w\\w)?"); // NV12
+ const regex fb_re("(?:(\\d+)x(\\d+))?" // 400x400
+ "(?:-)?" // -
+ "(\\w\\w\\w\\w)?"); // NV12
smatch sm;
if (!regex_match(fb_str, sm, fb_re))
@@ -368,7 +365,7 @@ static void parse_fb(Card& card, const string& fb_str, OutputInfo* output, Plane
static void parse_view(const string& view_str, PlaneInfo& pinfo)
{
- const regex view_re("(\\d+),(\\d+)-(\\d+)x(\\d+)"); // 400,400-400x400
+ const regex view_re("(\\d+),(\\d+)-(\\d+)x(\\d+)"); // 400,400-400x400
smatch sm;
if (!regex_match(view_str, sm, view_re))
@@ -381,56 +378,54 @@ static void parse_view(const string& view_str, PlaneInfo& pinfo)
}
static const char* usage_str =
- "Usage: kmstest [OPTION]...\n\n"
- "Show a test pattern on a display or plane\n\n"
- "Options:\n"
- " --device=DEVICE DEVICE is the path to DRM card to open\n"
- " -c, --connector=CONN CONN is <connector>\n"
- " -r, --crtc=CRTC CRTC is [<crtc>:]<w>x<h>[@<Hz>]\n"
- " or\n"
- " [<crtc>:]<pclk>,<hact>/<hfp>/<hsw>/<hbp>/<hsp>,<vact>/<vfp>/<vsw>/<vbp>/<vsp>[,i]\n"
- " -p, --plane=PLANE PLANE is [<plane>:][<x>,<y>-]<w>x<h>\n"
- " -f, --fb=FB FB is [<w>x<h>][-][<4cc>]\n"
- " -v, --view=VIEW VIEW is <x>,<y>-<w>x<h>\n"
- " -P, --property=PROP=VAL Set PROP to VAL in the previous DRM object\n"
- " --dmt Search for the given mode from DMT tables\n"
- " --cea Search for the given mode from CEA tables\n"
- " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n"
- " --flip[=max] Do page flipping for each output with an optional maximum flips count\n"
- " --sync Synchronize page flipping\n"
- " --crc Print CRC16 for framebuffer contents\n"
- "\n"
- "<connector>, <crtc> and <plane> can be given by index (<idx>) or id (@<id>).\n"
- "<connector> can also be given by name.\n"
- "\n"
- "Options can be given multiple times to set up multiple displays or planes.\n"
- "Options may apply to previous options, e.g. a plane will be set on a crtc set in\n"
- "an earlier option.\n"
- "If you omit parameters, kmstest tries to guess what you mean\n"
- "\n"
- "Examples:\n"
- "\n"
- "Set eDP-1 mode to 1920x1080@60, show XR24 framebuffer on the crtc, and a 400x400 XB24 plane:\n"
- " kmstest -c eDP-1 -r 1920x1080@60 -f XR24 -p 400x400 -f XB24\n\n"
- "XR24 framebuffer on first connected connector in the default mode:\n"
- " kmstest -f XR24\n\n"
- "XR24 framebuffer on a 400x400 plane on the first connected connector in the default mode:\n"
- " kmstest -p 400x400 -f XR24\n\n"
- "Test pattern on the second connector with default mode:\n"
- " kmstest -c 1\n"
- "\n"
- "Environmental variables:\n"
- " KMSXX_DISABLE_UNIVERSAL_PLANES Don't enable universal planes even if available\n"
- " KMSXX_DISABLE_ATOMIC Don't enable atomic modesetting even if available\n"
- ;
+ "Usage: kmstest [OPTION]...\n\n"
+ "Show a test pattern on a display or plane\n\n"
+ "Options:\n"
+ " --device=DEVICE DEVICE is the path to DRM card to open\n"
+ " -c, --connector=CONN CONN is <connector>\n"
+ " -r, --crtc=CRTC CRTC is [<crtc>:]<w>x<h>[@<Hz>]\n"
+ " or\n"
+ " [<crtc>:]<pclk>,<hact>/<hfp>/<hsw>/<hbp>/<hsp>,<vact>/<vfp>/<vsw>/<vbp>/<vsp>[,i]\n"
+ " -p, --plane=PLANE PLANE is [<plane>:][<x>,<y>-]<w>x<h>\n"
+ " -f, --fb=FB FB is [<w>x<h>][-][<4cc>]\n"
+ " -v, --view=VIEW VIEW is <x>,<y>-<w>x<h>\n"
+ " -P, --property=PROP=VAL Set PROP to VAL in the previous DRM object\n"
+ " --dmt Search for the given mode from DMT tables\n"
+ " --cea Search for the given mode from CEA tables\n"
+ " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n"
+ " --flip[=max] Do page flipping for each output with an optional maximum flips count\n"
+ " --sync Synchronize page flipping\n"
+ " --crc Print CRC16 for framebuffer contents\n"
+ "\n"
+ "<connector>, <crtc> and <plane> can be given by index (<idx>) or id (@<id>).\n"
+ "<connector> can also be given by name.\n"
+ "\n"
+ "Options can be given multiple times to set up multiple displays or planes.\n"
+ "Options may apply to previous options, e.g. a plane will be set on a crtc set in\n"
+ "an earlier option.\n"
+ "If you omit parameters, kmstest tries to guess what you mean\n"
+ "\n"
+ "Examples:\n"
+ "\n"
+ "Set eDP-1 mode to 1920x1080@60, show XR24 framebuffer on the crtc, and a 400x400 XB24 plane:\n"
+ " kmstest -c eDP-1 -r 1920x1080@60 -f XR24 -p 400x400 -f XB24\n\n"
+ "XR24 framebuffer on first connected connector in the default mode:\n"
+ " kmstest -f XR24\n\n"
+ "XR24 framebuffer on a 400x400 plane on the first connected connector in the default mode:\n"
+ " kmstest -p 400x400 -f XR24\n\n"
+ "Test pattern on the second connector with default mode:\n"
+ " kmstest -c 1\n"
+ "\n"
+ "Environmental variables:\n"
+ " KMSXX_DISABLE_UNIVERSAL_PLANES Don't enable universal planes even if available\n"
+ " KMSXX_DISABLE_ATOMIC Don't enable atomic modesetting even if available\n";
static void usage()
{
puts(usage_str);
}
-enum class ArgType
-{
+enum class ArgType {
Connector,
Crtc,
Plane,
@@ -439,70 +434,57 @@ enum class ArgType
Property,
};
-struct Arg
-{
+struct Arg {
ArgType type;
string arg;
};
static string s_device_path;
-static vector<Arg> parse_cmdline(int argc, char **argv)
+static vector<Arg> parse_cmdline(int argc, char** argv)
{
vector<Arg> args;
OptionSet optionset = {
Option("|device=",
- [&](string s)
- {
- s_device_path = s;
- }),
+ [&](string s) {
+ s_device_path = s;
+ }),
Option("c|connector=",
- [&](string s)
- {
- args.push_back(Arg { ArgType::Connector, s });
- }),
- Option("r|crtc=", [&](string s)
- {
- args.push_back(Arg { ArgType::Crtc, s });
+ [&](string s) {
+ args.push_back(Arg{ ArgType::Connector, s });
+ }),
+ Option("r|crtc=", [&](string s) {
+ args.push_back(Arg{ ArgType::Crtc, s });
}),
- Option("p|plane=", [&](string s)
- {
- args.push_back(Arg { ArgType::Plane, s });
+ Option("p|plane=", [&](string s) {
+ args.push_back(Arg{ ArgType::Plane, s });
}),
- Option("f|fb=", [&](string s)
- {
- args.push_back(Arg { ArgType::Framebuffer, s });
+ Option("f|fb=", [&](string s) {
+ args.push_back(Arg{ ArgType::Framebuffer, s });
}),
- Option("v|view=", [&](string s)
- {
- args.push_back(Arg { ArgType::View, s });
+ Option("v|view=", [&](string s) {
+ args.push_back(Arg{ ArgType::View, s });
}),
- Option("P|property=", [&](string s)
- {
- args.push_back(Arg { ArgType::Property, s });
+ Option("P|property=", [&](string s) {
+ args.push_back(Arg{ ArgType::Property, s });
}),
- Option("|dmt", []()
- {
+ Option("|dmt", []() {
s_use_dmt = true;
}),
- Option("|cea", []()
- {
+ Option("|cea", []() {
s_use_cea = true;
}),
- Option("|flip?", [&](string s)
- {
+ Option("|flip?", [&](string s) {
s_flip_mode = true;
s_num_buffers = 2;
if (!s.empty())
s_max_flips = stoi(s);
}),
- Option("|sync", []()
- {
+ Option("|sync", []() {
s_flip_sync = true;
}),
- Option("|cvt=", [&](string s)
- {
+ Option("|cvt=", [&](string s) {
if (s == "v1")
s_cvt = true;
else if (s == "v2")
@@ -517,8 +499,7 @@ static vector<Arg> parse_cmdline(int argc, char **argv)
Option("|crc", []() {
s_print_crc = true;
}),
- Option("h|help", [&]()
- {
+ Option("h|help", [&]() {
usage();
exit(-1);
}),
@@ -543,9 +524,8 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
for (auto& arg : output_args) {
switch (arg.type) {
- case ArgType::Connector:
- {
- outputs.push_back(OutputInfo { });
+ case ArgType::Connector: {
+ outputs.push_back(OutputInfo{});
current_output = &outputs.back();
get_connector(resman, *current_output, arg.arg);
@@ -554,10 +534,9 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
break;
}
- case ArgType::Crtc:
- {
+ case ArgType::Crtc: {
if (!current_output) {
- outputs.push_back(OutputInfo { });
+ outputs.push_back(OutputInfo{});
current_output = &outputs.back();
}
@@ -571,10 +550,9 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
break;
}
- case ArgType::Plane:
- {
+ case ArgType::Plane: {
if (!current_output) {
- outputs.push_back(OutputInfo { });
+ outputs.push_back(OutputInfo{});
current_output = &outputs.back();
}
@@ -591,10 +569,9 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
break;
}
- case ArgType::Framebuffer:
- {
+ case ArgType::Framebuffer: {
if (!current_output) {
- outputs.push_back(OutputInfo { });
+ outputs.push_back(OutputInfo{});
current_output = &outputs.back();
}
@@ -612,8 +589,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
break;
}
- case ArgType::View:
- {
+ case ArgType::View: {
if (!current_plane || current_plane->fbs.empty())
EXIT("'view' parameter requires a plane and a fb");
@@ -621,8 +597,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
break;
}
- case ArgType::Property:
- {
+ case ArgType::Property: {
if (!current_output)
EXIT("No object to which set the property");
@@ -646,7 +621,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
if (!conn->connected())
continue;
- OutputInfo output = { };
+ OutputInfo output = {};
output.connector = resman.reserve_connector(conn);
EXIT_IF(!output.connector, "Failed to reserve connector %s", conn->fullname().c_str());
output.crtc = resman.reserve_crtc(conn);
@@ -676,7 +651,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
o.legacy_fbs = get_default_fb(card, o.mode.hdisplay, o.mode.vdisplay);
}
- for (PlaneInfo &p : o.planes) {
+ for (PlaneInfo& p : o.planes) {
if (p.fbs.empty())
p.fbs = get_default_fb(card, p.w, p.h);
}
@@ -704,7 +679,7 @@ static uint16_t crc16(uint16_t crc, uint8_t data)
for (uint8_t i = 0; i < 8; i++) {
if (((crc & 0x8000) >> 8) ^ (data & 0x80))
- crc = (crc << 1) ^ CRC16_IBM;
+ crc = (crc << 1) ^ CRC16_IBM;
else
crc = (crc << 1);
@@ -714,16 +689,16 @@ static uint16_t crc16(uint16_t crc, uint8_t data)
return crc;
}
-static string fb_crc(IFramebuffer *fb)
+static string fb_crc(IFramebuffer* fb)
{
- uint8_t *p = fb->map(0);
+ uint8_t* p = fb->map(0);
uint16_t r, g, b;
r = g = b = 0;
for (unsigned y = 0; y < fb->height(); ++y) {
for (unsigned x = 0; x < fb->width(); ++x) {
- uint32_t *p32 = (uint32_t*)(p + fb->stride(0) * y + x * 4);
+ uint32_t* p32 = (uint32_t*)(p + fb->stride(0) * y + x * 4);
RGB rgb(*p32);
r = crc16(r, rgb.r);
@@ -748,12 +723,12 @@ static void print_outputs(const vector<OutputInfo>& outputs)
fmt::print("Connector {}/@{}: {}", o.connector->idx(), o.connector->id(),
o.connector->fullname());
- for (const PropInfo &prop: o.conn_props)
+ for (const PropInfo& prop : o.conn_props)
fmt::print(" {}={}", prop.prop->name(), prop.val);
fmt::print("\n Crtc {}/@{}", o.crtc->idx(), o.crtc->id());
- for (const PropInfo &prop: o.crtc_props)
+ for (const PropInfo& prop : o.crtc_props)
fmt::print(" {}={}", prop.prop->name(), prop.val);
fmt::print(": {}\n", o.mode.to_string_long());
@@ -768,7 +743,7 @@ static void print_outputs(const vector<OutputInfo>& outputs)
auto fb = p.fbs[0];
fmt::print(" Plane {}/@{}: {},{}-{}x{}", p.plane->idx(), p.plane->id(),
p.x, p.y, p.w, p.h);
- for (const PropInfo &prop: p.props)
+ for (const PropInfo& prop : p.props)
fmt::print(" {}={}", prop.prop->name(), prop.val);
fmt::print("\n");
@@ -833,8 +808,8 @@ static void set_crtcs_n_planes_legacy(Card& card, const vector<OutputInfo>& outp
auto fb = p.fbs[0];
r = crtc->set_plane(p.plane, *fb,
- p.x, p.y, p.w, p.h,
- 0, 0, fb->width(), fb->height());
+ p.x, p.y, p.w, p.h,
+ 0, 0, fb->width(), fb->height());
if (r)
fmt::print(stderr, "crtc->set_plane() failed for plane {}: {}\n",
p.plane->id(), strerror(-r));
@@ -858,22 +833,21 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
// continue;
disable_req.add(crtc, {
- { "ACTIVE", 0 },
- });
+ { "ACTIVE", 0 },
+ });
}
// Disable unused planes
for (Plane* plane : card.get_planes())
disable_req.add(plane, {
- { "FB_ID", 0 },
- { "CRTC_ID", 0 },
- });
+ { "FB_ID", 0 },
+ { "CRTC_ID", 0 },
+ });
r = disable_req.commit_sync(true);
if (r)
EXIT("Atomic commit failed when disabling: %d\n", r);
-
// Keep blobs here so that we keep ref to them until we have committed the req
vector<unique_ptr<Blob>> blobs;
@@ -887,37 +861,37 @@ static void set_crtcs_n_planes_atomic(Card& card, const vector<OutputInfo>& outp
Blob* mode_blob = blobs.back().get();
req.add(conn, {
- { "CRTC_ID", crtc->id() },
- });
+ { "CRTC_ID", crtc->id() },
+ });
- for (const PropInfo &prop: o.conn_props)
+ for (const PropInfo& prop : o.conn_props)
req.add(conn, prop.prop, prop.val);
req.add(crtc, {
- { "ACTIVE", 1 },
- { "MODE_ID", mode_blob->id() },
- });
+ { "ACTIVE", 1 },
+ { "MODE_ID", mode_blob->id() },
+ });
- for (const PropInfo &prop: o.crtc_props)
+ for (const PropInfo& prop : o.crtc_props)
req.add(crtc, prop.prop, prop.val);
for (const PlaneInfo& p : o.planes) {
auto fb = p.fbs[0];
req.add(p.plane, {
- { "FB_ID", fb->id() },
- { "CRTC_ID", crtc->id() },
- { "SRC_X", (p.view_x ?: 0) << 16 },
- { "SRC_Y", (p.view_y ?: 0) << 16 },
- { "SRC_W", (p.view_w ?: fb->width()) << 16 },
- { "SRC_H", (p.view_h ?: fb->height()) << 16 },
- { "CRTC_X", p.x },
- { "CRTC_Y", p.y },
- { "CRTC_W", p.w },
- { "CRTC_H", p.h },
- });
-
- for (const PropInfo &prop: p.props)
+ { "FB_ID", fb->id() },
+ { "CRTC_ID", crtc->id() },
+ { "SRC_X", (p.view_x ?: 0) << 16 },
+ { "SRC_Y", (p.view_y ?: 0) << 16 },
+ { "SRC_W", (p.view_w ?: fb->width()) << 16 },
+ { "SRC_H", (p.view_h ?: fb->height()) << 16 },
+ { "CRTC_X", p.x },
+ { "CRTC_Y", p.y },
+ { "CRTC_W", p.w },
+ { "CRTC_H", p.h },
+ });
+
+ for (const PropInfo& prop : p.props)
req.add(p.plane, prop.prop, prop.val);
}
}
@@ -977,7 +951,7 @@ private:
if (diff > m_slowest_frame)
m_slowest_frame = diff;
- if (m_frame_num % 100 == 0) {
+ if (m_frame_num % 100 == 0) {
std::chrono::duration<float> fsec = now - m_prev_print;
fmt::print("Connector {}: fps {:.2f}, slowest {:.2f} ms\n",
m_name.c_str(),
@@ -1016,8 +990,8 @@ private:
draw_bar(fb, frame_num);
req.add(p.plane, {
- { "FB_ID", fb->id() },
- });
+ { "FB_ID", fb->id() },
+ });
}
}
@@ -1129,7 +1103,7 @@ static void main_flip(Card& card, const vector<OutputInfo>& outputs)
}
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
vector<Arg> output_args = parse_cmdline(argc, argv);
diff --git a/utils/kmstouch.cpp b/utils/kmstouch.cpp
index b7ac420..fbe0f3d 100644
--- a/utils/kmstouch.cpp
+++ b/utils/kmstouch.cpp
@@ -16,14 +16,13 @@ using namespace std;
using namespace kms;
static const char* usage_str =
- "Usage: kmstouch [OPTION]...\n\n"
- "Simple touchscreen tester\n\n"
- "Options:\n"
- " --input=DEVICE DEVICE is the path to input device to open\n"
- " --device=DEVICE DEVICE is the path to DRM card to open\n"
- " -c, --connector=CONN CONN is <connector>\n"
- "\n"
- ;
+ "Usage: kmstouch [OPTION]...\n\n"
+ "Simple touchscreen tester\n\n"
+ "Options:\n"
+ " --input=DEVICE DEVICE is the path to input device to open\n"
+ " --device=DEVICE DEVICE is the path to DRM card to open\n"
+ " -c, --connector=CONN CONN is <connector>\n"
+ "\n";
static void usage()
{
@@ -39,9 +38,9 @@ static map<int, pair<int32_t, int32_t>> s_abs_map;
// axis -> value
static map<int, int32_t> s_abs_vals;
-static void print_abs_bits(struct libevdev *dev, int axis)
+static void print_abs_bits(struct libevdev* dev, int axis)
{
- const struct input_absinfo *abs;
+ const struct input_absinfo* abs;
if (!libevdev_has_event_code(dev, EV_ABS, axis))
return;
@@ -59,7 +58,7 @@ static void print_abs_bits(struct libevdev *dev, int axis)
printf(" Resolution %6d\n", abs->resolution);
}
-static void print_code_bits(struct libevdev *dev, unsigned int type, unsigned int max)
+static void print_code_bits(struct libevdev* dev, unsigned int type, unsigned int max)
{
for (uint32_t i = 0; i <= max; i++) {
if (!libevdev_has_event_code(dev, type, i))
@@ -71,7 +70,7 @@ static void print_code_bits(struct libevdev *dev, unsigned int type, unsigned in
}
}
-static void print_bits(struct libevdev *dev)
+static void print_bits(struct libevdev* dev)
{
printf("Supported events:\n");
@@ -81,7 +80,7 @@ static void print_bits(struct libevdev *dev)
printf(" Event type %d (%s)\n", i, libevdev_event_type_get_name(i));
- switch(i) {
+ switch (i) {
case EV_KEY:
print_code_bits(dev, EV_KEY, KEY_MAX);
break;
@@ -104,7 +103,7 @@ static void collect_current(struct libevdev* dev)
if (!libevdev_has_event_code(dev, EV_ABS, i))
continue;
- const struct input_absinfo *abs;
+ const struct input_absinfo* abs;
abs = libevdev_get_abs_info(dev, i);
@@ -113,7 +112,7 @@ static void collect_current(struct libevdev* dev)
}
}
-static void print_props(struct libevdev *dev)
+static void print_props(struct libevdev* dev)
{
printf("Properties:\n");
@@ -194,27 +193,23 @@ static void handle_event(struct input_event& ev, DumbFramebuffer* fb)
}
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
string drm_dev_path = "/dev/dri/card0";
string input_dev_path = "/dev/input/event0";
string conn_name;
OptionSet optionset = {
- Option("i|input=", [&input_dev_path](string s)
- {
+ Option("i|input=", [&input_dev_path](string s) {
input_dev_path = s;
}),
- Option("|device=", [&drm_dev_path](string s)
- {
+ Option("|device=", [&drm_dev_path](string s) {
drm_dev_path = s;
}),
- Option("c|connector=", [&conn_name](string s)
- {
+ Option("c|connector=", [&conn_name](string s) {
conn_name = s;
}),
- Option("h|help", []()
- {
+ Option("h|help", []() {
usage();
exit(-1);
}),
@@ -227,8 +222,7 @@ int main(int argc, char **argv)
exit(-1);
}
-
- struct libevdev *dev = nullptr;
+ struct libevdev* dev = nullptr;
int fd = open(input_dev_path.c_str(), O_RDONLY | O_NONBLOCK);
FAIL_IF(fd < 0, "Failed to open input device %s: %s\n", input_dev_path.c_str(), strerror(errno));
@@ -252,7 +246,6 @@ int main(int argc, char **argv)
collect_current(dev);
-
Card card(drm_dev_path);
ResourceManager resman(card);
@@ -288,7 +281,8 @@ int main(int argc, char **argv)
FAIL_IF(r, "initial plane setup failed");
do {
- struct input_event ev {};
+ struct input_event ev {
+ };
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
if (rc == 0)
handle_event(ev, fb);
diff --git a/utils/kmsview.cpp b/utils/kmsview.cpp
index eea9dde..952c643 100644
--- a/utils/kmsview.cpp
+++ b/utils/kmsview.cpp
@@ -24,11 +24,10 @@ static void read_frame(ifstream& is, DumbFramebuffer* fb, Crtc* crtc, Plane* pla
}
static const char* usage_str =
- "Usage: kmsview [options] <file> <width> <height> <fourcc>\n\n"
- "Options:\n"
- " -c, --connector <name> Output connector\n"
- " -t, --time <ms> Milliseconds to sleep between frames\n"
- ;
+ "Usage: kmsview [options] <file> <width> <height> <fourcc>\n\n"
+ "Options:\n"
+ " -c, --connector <name> Output connector\n"
+ " -t, --time <ms> Milliseconds to sleep between frames\n";
static void usage()
{
@@ -42,20 +41,16 @@ int main(int argc, char** argv)
string conn_name;
OptionSet optionset = {
- Option("c|connector=", [&conn_name](string s)
- {
+ Option("c|connector=", [&conn_name](string s) {
conn_name = s;
}),
- Option("|device=", [&dev_path](string s)
- {
+ Option("|device=", [&dev_path](string s) {
dev_path = s;
}),
- Option("t|time=", [&time](const string& str)
- {
+ Option("t|time=", [&time](const string& str) {
time = stoul(str);
}),
- Option("h|help", []()
- {
+ Option("h|help", []() {
usage();
exit(-1);
}),
@@ -83,7 +78,6 @@ int main(int argc, char** argv)
unsigned fsize = is.tellg();
is.seekg(0);
-
Card card(dev_path);
ResourceManager res(card);
@@ -102,7 +96,8 @@ 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", i); fflush(stdout);
+ printf("frame %d", i);
+ fflush(stdout);
read_frame(is, fb, crtc, plane);
if (!time) {
getchar();
diff --git a/utils/wbcap.cpp b/utils/wbcap.cpp
index 886fe36..8033869 100644
--- a/utils/wbcap.cpp
+++ b/utils/wbcap.cpp
@@ -213,19 +213,19 @@ private:
draw_bar(fb, m_frame_num);
req.add(m_plane, {
- { "CRTC_ID", m_crtc->id() },
- { "FB_ID", fb->id() },
+ { "CRTC_ID", m_crtc->id() },
+ { "FB_ID", fb->id() },
- { "CRTC_X", 0 },
- { "CRTC_Y", 0 },
- { "CRTC_W", min((uint32_t)m_crtc->mode().hdisplay, fb->width()) },
- { "CRTC_H", min((uint32_t)m_crtc->mode().vdisplay, fb->height()) },
+ { "CRTC_X", 0 },
+ { "CRTC_Y", 0 },
+ { "CRTC_W", min((uint32_t)m_crtc->mode().hdisplay, fb->width()) },
+ { "CRTC_H", min((uint32_t)m_crtc->mode().vdisplay, fb->height()) },
- { "SRC_X", 0 },
- { "SRC_Y", 0 },
- { "SRC_W", fb->width() << 16 },
- { "SRC_H", fb->height() << 16 },
- });
+ { "SRC_X", 0 },
+ { "SRC_Y", 0 },
+ { "SRC_W", fb->width() << 16 },
+ { "SRC_H", fb->height() << 16 },
+ });
int r = req.commit(this);
if (r)
@@ -247,16 +247,15 @@ private:
};
static const char* usage_str =
- "Usage: wbcap [OPTIONS]\n\n"
- "Options:\n"
- " -s, --src=CONN Source connector\n"
- " -d, --dst=CONN Destination connector\n"
- " -m, --smode=MODE Source connector videomode\n"
- " -M, --dmode=MODE Destination connector videomode\n"
- " -f, --format=4CC Format\n"
- " -w, --write Write captured frames to wbcap.raw file\n"
- " -h, --help Print this help\n"
- ;
+ "Usage: wbcap [OPTIONS]\n\n"
+ "Options:\n"
+ " -s, --src=CONN Source connector\n"
+ " -d, --dst=CONN Destination connector\n"
+ " -m, --smode=MODE Source connector videomode\n"
+ " -M, --dmode=MODE Destination connector videomode\n"
+ " -f, --format=4CC Format\n"
+ " -w, --write Write captured frames to wbcap.raw file\n"
+ " -h, --help Print this help\n";
int main(int argc, char** argv)
{
@@ -268,32 +267,25 @@ int main(int argc, char** argv)
bool write_file = false;
OptionSet optionset = {
- Option("s|src=", [&](string s)
- {
+ Option("s|src=", [&](string s) {
src_conn_name = s;
}),
- Option("m|smode=", [&](string s)
- {
+ Option("m|smode=", [&](string s) {
src_mode_name = s;
}),
- Option("d|dst=", [&](string s)
- {
+ Option("d|dst=", [&](string s) {
dst_conn_name = s;
}),
- Option("M|dmode=", [&](string s)
- {
+ Option("M|dmode=", [&](string s) {
dst_mode_name = s;
}),
- Option("f|format=", [&](string s)
- {
+ Option("f|format=", [&](string s) {
pixfmt = FourCCToPixelFormat(s);
}),
- Option("w|write", [&]()
- {
+ Option("w|write", [&]() {
write_file = true;
}),
- Option("h|help", [&]()
- {
+ Option("h|help", [&]() {
puts(usage_str);
exit(-1);
}),
@@ -326,7 +318,6 @@ int main(int argc, char** argv)
Videomode src_mode = src_mode_name.empty() ? src_conn->get_default_mode() : src_conn->get_mode(src_mode_name);
src_crtc->set_mode(src_conn, src_mode);
-
auto dst_conn = resman.reserve_connector(dst_conn_name);
auto dst_crtc = resman.reserve_crtc(dst_conn);
auto dst_plane = resman.reserve_overlay_plane(dst_crtc, pixfmt);
@@ -371,11 +362,11 @@ int main(int argc, char** argv)
vector<pollfd> fds(3);
fds[0].fd = 0;
- fds[0].events = POLLIN;
+ fds[0].events = POLLIN;
fds[1].fd = wb.fd();
- fds[1].events = POLLIN;
+ fds[1].events = POLLIN;
fds[2].fd = card.fd();
- fds[2].events = POLLIN;
+ fds[2].events = POLLIN;
uint32_t dst_frame_num = 0;
diff --git a/utils/wbm2m.cpp b/utils/wbm2m.cpp
index 71a26a5..a00fab2 100644
--- a/utils/wbm2m.cpp
+++ b/utils/wbm2m.cpp
@@ -12,19 +12,18 @@
#include <kms++util/kms++util.h>
#include <kms++util/videodevice.h>
-const uint32_t NUM_SRC_BUFS=2;
-const uint32_t NUM_DST_BUFS=2;
+const uint32_t NUM_SRC_BUFS = 2;
+const uint32_t NUM_DST_BUFS = 2;
using namespace std;
using namespace kms;
static const char* usage_str =
- "Usage: wbm2m [OPTIONS]\n\n"
- "Options:\n"
- " -f, --format=4CC Output format\n"
- " -c, --crop=CROP CROP is <x>,<y>-<w>x<h>\n"
- " -h, --help Print this help\n"
- ;
+ "Usage: wbm2m [OPTIONS]\n\n"
+ "Options:\n"
+ " -f, --format=4CC Output format\n"
+ " -c, --crop=CROP CROP is <x>,<y>-<w>x<h>\n"
+ " -h, --help Print this help\n";
const int bar_speed = 4;
const int bar_width = 10;
@@ -51,7 +50,7 @@ static void read_frame(DumbFramebuffer* fb, unsigned frame_num)
static void parse_crop(const string& crop_str, uint32_t& c_left, uint32_t& c_top,
uint32_t& c_width, uint32_t& c_height)
{
- const regex crop_re("(\\d+),(\\d+)-(\\d+)x(\\d+)"); // 400,400-400x400
+ const regex crop_re("(\\d+),(\\d+)-(\\d+)x(\\d+)"); // 400,400-400x400
smatch sm;
if (!regex_match(crop_str, sm, crop_re))
@@ -79,17 +78,14 @@ int main(int argc, char** argv)
bool use_selection = false;
OptionSet optionset = {
- Option("f|format=", [&](string s)
- {
+ Option("f|format=", [&](string s) {
dst_fmt = FourCCToPixelFormat(s);
}),
- Option("c|crop=", [&](string s)
- {
+ Option("c|crop=", [&](string s) {
parse_crop(s, c_left, c_top, c_width, c_height);
use_selection = true;
}),
- Option("h|help", [&]()
- {
+ Option("h|help", [&]() {
puts(usage_str);
exit(-1);
}),
@@ -106,7 +102,7 @@ int main(int argc, char** argv)
dst_width, dst_height, PixelFormatToFourCC(dst_fmt).c_str());
const string filename = fmt::format("wb-out-{}x{}-{}.raw", dst_width, dst_height,
- PixelFormatToFourCC(dst_fmt));
+ PixelFormatToFourCC(dst_fmt));
printf("writing to %s\n", filename.c_str());
@@ -131,7 +127,6 @@ int main(int argc, char** argv)
out->set_queue_size(NUM_SRC_BUFS);
in->set_queue_size(NUM_DST_BUFS);
-
for (unsigned i = 0; i < min(NUM_SRC_BUFS, num_src_frames); ++i) {
auto fb = new DumbFramebuffer(card, src_width, src_height, src_fmt);
@@ -148,11 +143,11 @@ int main(int argc, char** argv)
vector<pollfd> fds(3);
fds[0].fd = 0;
- fds[0].events = POLLIN;
+ fds[0].events = POLLIN;
fds[1].fd = vid.fd();
- fds[1].events = POLLIN;
+ fds[1].events = POLLIN;
fds[2].fd = card.fd();
- fds[2].events = POLLIN;
+ fds[2].events = POLLIN;
ofstream os(filename, ofstream::binary);
@@ -169,9 +164,8 @@ int main(int argc, char** argv)
if (fds[1].revents) {
fds[1].revents = 0;
-
try {
- DumbFramebuffer *dst_fb = in->dequeue();
+ DumbFramebuffer* dst_fb = in->dequeue();
printf("Writing frame %u\n", dst_frame_num);
for (unsigned i = 0; i < dst_fb->num_planes(); ++i)
os.write((char*)dst_fb->map(i), dst_fb->size(i));
@@ -189,7 +183,7 @@ int main(int argc, char** argv)
break;
}
- DumbFramebuffer *src_fb = out->dequeue();
+ DumbFramebuffer* src_fb = out->dequeue();
if (src_frame_num < num_src_frames) {
read_frame(src_fb, src_frame_num++);