Home | History | Annotate | Download | only in src
      1 
      2 #include <kms++/kms++.h>
      3 #include "helpers.h"
      4 #include <cstring>
      5 
      6 #define CPY(field) dst.field = src.field
      7 
      8 namespace kms
      9 {
     10 Videomode drm_mode_to_video_mode(const drmModeModeInfo& drmmode)
     11 {
     12 	Videomode mode = { };
     13 
     14 	auto& src = drmmode;
     15 	auto& dst = mode;
     16 
     17 	CPY(clock);
     18 
     19 	CPY(hdisplay);
     20 	CPY(hsync_start);
     21 	CPY(hsync_end);
     22 	CPY(htotal);
     23 	CPY(hskew);
     24 
     25 	CPY(vdisplay);
     26 	CPY(vsync_start);
     27 	CPY(vsync_end);
     28 	CPY(vtotal);
     29 	CPY(vscan);
     30 
     31 	CPY(vrefresh);
     32 
     33 	CPY(flags);
     34 	CPY(type);
     35 
     36 	mode.name = drmmode.name;
     37 
     38 	return mode;
     39 }
     40 
     41 drmModeModeInfo video_mode_to_drm_mode(const Videomode& mode)
     42 {
     43 	drmModeModeInfo drmmode = { };
     44 
     45 	auto& src = mode;
     46 	auto& dst = drmmode;
     47 
     48 	CPY(clock);
     49 
     50 	CPY(hdisplay);
     51 	CPY(hsync_start);
     52 	CPY(hsync_end);
     53 	CPY(htotal);
     54 	CPY(hskew);
     55 
     56 	CPY(vdisplay);
     57 	CPY(vsync_start);
     58 	CPY(vsync_end);
     59 	CPY(vtotal);
     60 	CPY(vscan);
     61 
     62 	CPY(vrefresh);
     63 
     64 	CPY(flags);
     65 	CPY(type);
     66 
     67 	strncpy(drmmode.name, mode.name.c_str(), sizeof(drmmode.name));
     68 	drmmode.name[sizeof(drmmode.name) - 1] = 0;
     69 
     70 	return drmmode;
     71 }
     72 }
     73