MCPcopy Create free account
hub / github.com/WayfireWM/wayfire / parse_modeline

Function parse_modeline

src/core/output-layout.cpp:172–224  ·  view source on GitHub ↗

from rootston

Source from the content-addressed store, hash-verified

170
171// from rootston
172static bool parse_modeline(const char *modeline, drmModeModeInfo & mode)
173{
174 char hsync[16];
175 char vsync[16];
176 char interlace[16];
177 interlace[0] = '\0';
178 float fclock;
179
180 std::memset(&mode, 0, sizeof(mode));
181 mode.type = DRM_MODE_TYPE_USERDEF;
182
183 if (sscanf(modeline, "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s %15s",
184 &fclock, &mode.hdisplay, &mode.hsync_start, &mode.hsync_end,
185 &mode.htotal, &mode.vdisplay, &mode.vsync_start, &mode.vsync_end,
186 &mode.vtotal, hsync, vsync, interlace) < 11)
187 {
188 return false;
189 }
190
191 mode.clock = fclock * 1000;
192 mode.vrefresh = mode.clock * 1000.0 * 1000.0 / mode.htotal / mode.vtotal;
193 if (strcasecmp(hsync, "+hsync") == 0)
194 {
195 mode.flags |= DRM_MODE_FLAG_PHSYNC;
196 } else if (strcasecmp(hsync, "-hsync") == 0)
197 {
198 mode.flags |= DRM_MODE_FLAG_NHSYNC;
199 } else
200 {
201 return false;
202 }
203
204 if (strcasecmp(vsync, "+vsync") == 0)
205 {
206 mode.flags |= DRM_MODE_FLAG_PVSYNC;
207 } else if (strcasecmp(vsync, "-vsync") == 0)
208 {
209 mode.flags |= DRM_MODE_FLAG_NVSYNC;
210 } else
211 {
212 return false;
213 }
214
215 if (strcasecmp(interlace, "interlace") == 0)
216 {
217 mode.flags |= DRM_MODE_FLAG_INTERLACE;
218 }
219
220 snprintf(mode.name, sizeof(mode.name), "%dx%d@%d",
221 mode.hdisplay, mode.vdisplay, mode.vrefresh / 1000);
222
223 return true;
224}
225
226namespace wf
227{

Callers 1

add_custom_modeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected