diff options
Diffstat (limited to 'kms++/helpers.cpp')
-rw-r--r-- | kms++/helpers.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/kms++/helpers.cpp b/kms++/helpers.cpp new file mode 100644 index 0000000..715e757 --- /dev/null +++ b/kms++/helpers.cpp @@ -0,0 +1,72 @@ + +#include "connector.h" +#include "helpers.h" +#include <cstring> + +#define CPY(field) dst.field = src.field + +namespace kms +{ +Videomode drm_mode_to_video_mode(const drmModeModeInfo& drmmode) +{ + 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) +{ + 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; +} +} |