]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkms++/helpers.cpp
Videomode cleanup
[android/external-libkmsxx.git] / libkms++ / helpers.cpp
2 #include "connector.h"
3 #include "helpers.h"
4 #include <cstring>
6 #define CPY(field) dst.field = src.field
8 namespace kms
9 {
10 Videomode drm_mode_to_video_mode(const drmModeModeInfo& drmmode)
11 {
12         Videomode mode = { };
14         auto& src = drmmode;
15         auto& dst = mode;
17         CPY(clock);
19         CPY(hdisplay);
20         CPY(hsync_start);
21         CPY(hsync_end);
22         CPY(htotal);
23         CPY(hskew);
25         CPY(vdisplay);
26         CPY(vsync_start);
27         CPY(vsync_end);
28         CPY(vtotal);
29         CPY(vscan);
31         CPY(vrefresh);
33         CPY(flags);
34         CPY(type);
36         mode.name = drmmode.name;
38         return mode;
39 }
41 drmModeModeInfo video_mode_to_drm_mode(const Videomode& mode)
42 {
43         drmModeModeInfo drmmode = { };
45         auto& src = mode;
46         auto& dst = drmmode;
48         CPY(clock);
50         CPY(hdisplay);
51         CPY(hsync_start);
52         CPY(hsync_end);
53         CPY(htotal);
54         CPY(hskew);
56         CPY(vdisplay);
57         CPY(vsync_start);
58         CPY(vsync_end);
59         CPY(vtotal);
60         CPY(vscan);
62         CPY(vrefresh);
64         CPY(flags);
65         CPY(type);
67         strncpy(drmmode.name, mode.name.c_str(), sizeof(drmmode.name));
68         drmmode.name[sizeof(drmmode.name) - 1] = 0;
70         return drmmode;
71 }
72 }