summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c146ed6)
raw | patch | inline | side by side (parent: c146ed6)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Fri, 13 Nov 2015 17:24:52 +0000 (19:24 +0200) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Fri, 13 Nov 2015 20:12:41 +0000 (22:12 +0200) |
libkms++/connector.h | patch | blob | history | |
libkms++/helpers.cpp | patch | blob | history | |
libkms++/videomode.h | [new file with mode: 0644] | patch | blob |
diff --git a/libkms++/connector.h b/libkms++/connector.h
index 9776be35258c940609c22d6b3d65ce187ce8631e..a897d31d7d79bfad828b57bfd23298a480d94ac0 100644 (file)
--- a/libkms++/connector.h
+++ b/libkms++/connector.h
#include <vector>
#include "drmobject.h"
#include <vector>
#include "drmobject.h"
+#include "videomode.h"
namespace kms
{
struct ConnectorPriv;
namespace kms
{
struct ConnectorPriv;
-struct Videomode
-{
- uint32_t clock;
- uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
- uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
-
- uint32_t vrefresh;
-
- uint32_t flags;
- uint32_t type;
- char name[32]; // XXX
-};
-
class Connector : public DrmObject
{
friend class Card;
class Connector : public DrmObject
{
friend class Card;
diff --git a/libkms++/helpers.cpp b/libkms++/helpers.cpp
index 7746bdefdb88989bec597ad7e84862fd5d4e1e25..715e757969cc94d5741245e0b2748e6f75344fc5 100644 (file)
--- a/libkms++/helpers.cpp
+++ b/libkms++/helpers.cpp
#include "helpers.h"
#include <cstring>
#include "helpers.h"
#include <cstring>
+#define CPY(field) dst.field = src.field
+
namespace kms
{
Videomode drm_mode_to_video_mode(const drmModeModeInfo& drmmode)
{
namespace kms
{
Videomode drm_mode_to_video_mode(const drmModeModeInfo& drmmode)
{
- // XXX these are the same at the moment
- Videomode mode;
- memcpy(&mode, &drmmode, sizeof(mode));
+ Videomode mode = { };
+
+ auto& src = drmmode;
+ auto& dst = mode;
+
+ CPY(clock);
+
+ CPY(hdisplay);
+ CPY(hsync_start);
+ CPY(hsync_end);
+ CPY(htotal);
+ CPY(hskew);
+
+ CPY(vdisplay);
+ CPY(vsync_start);
+ CPY(vsync_end);
+ CPY(vtotal);
+ CPY(vscan);
+
+ CPY(vrefresh);
+
+ CPY(flags);
+ CPY(type);
+
+ mode.name = drmmode.name;
+
return mode;
}
drmModeModeInfo video_mode_to_drm_mode(const Videomode& mode)
{
return mode;
}
drmModeModeInfo video_mode_to_drm_mode(const Videomode& mode)
{
- // XXX these are the same at the moment
- drmModeModeInfo drmmode;
- memcpy(&drmmode, &mode, sizeof(drmmode));
+ drmModeModeInfo drmmode = { };
+
+ auto& src = mode;
+ auto& dst = drmmode;
+
+ CPY(clock);
+
+ CPY(hdisplay);
+ CPY(hsync_start);
+ CPY(hsync_end);
+ CPY(htotal);
+ CPY(hskew);
+
+ CPY(vdisplay);
+ CPY(vsync_start);
+ CPY(vsync_end);
+ CPY(vtotal);
+ CPY(vscan);
+
+ CPY(vrefresh);
+
+ CPY(flags);
+ CPY(type);
+
+ strncpy(drmmode.name, mode.name.c_str(), sizeof(drmmode.name));
+ drmmode.name[sizeof(drmmode.name) - 1] = 0;
+
return drmmode;
}
}
return drmmode;
}
}
diff --git a/libkms++/videomode.h b/libkms++/videomode.h
--- /dev/null
+++ b/libkms++/videomode.h
@@ -0,0 +1,20 @@
+#pragma once
+
+namespace kms
+{
+
+struct Videomode
+{
+ uint32_t clock;
+ uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
+ uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
+
+ uint32_t vrefresh;
+
+ uint32_t flags; // DRM_MODE_FLAG_*
+ uint32_t type; // DRM_MODE_TYPE_*
+
+ std::string name;
+};
+
+}