Lines Matching refs:mode

42  * Calculates the horizontal sync rate of a mode.
45 xf86ModeHSync(const DisplayModeRec *mode)
49 if (mode->HSync > 0.0)
50 hsync = mode->HSync;
51 else if (mode->HTotal > 0)
52 hsync = (float)mode->Clock / (float)mode->HTotal;
58 * Calculates the vertical refresh rate of a mode.
61 xf86ModeVRefresh(const DisplayModeRec *mode)
65 if (mode->VRefresh > 0.0)
66 refresh = mode->VRefresh;
67 else if (mode->HTotal > 0 && mode->VTotal > 0) {
68 refresh = mode->Clock * 1000.0 / mode->HTotal / mode->VTotal;
69 if (mode->Flags & V_INTERLACE)
71 if (mode->Flags & V_DBLSCAN)
73 if (mode->VScan > 1)
74 refresh /= (float)(mode->VScan);
80 xf86ModeWidth (const DisplayModeRec *mode, Rotation rotation)
85 return mode->HDisplay;
88 return mode->VDisplay;
95 xf86ModeHeight (const DisplayModeRec *mode, Rotation rotation)
100 return mode->VDisplay;
103 return mode->HDisplay;
109 /** Calculates the memory bandwidth (in MiB/sec) of a mode. */
111 xf86ModeBandwidth(DisplayModePtr mode, int depth)
116 if (!mode->HTotal || !mode->VTotal || !mode->Clock)
119 a_active = mode->HDisplay * mode->VDisplay;
120 a_total = mode->HTotal * mode->VTotal;
122 pixels_per_second = active_percent * mode->Clock * 1000.0;
127 /** Sets a default mode name of <width>x<height> on a mode. */
129 xf86SetModeDefaultName(DisplayModePtr mode)
131 Bool interlaced = !!(mode->Flags & V_INTERLACE);
133 free(mode->name);
135 XNFasprintf(&mode->name, "%dx%d%s", mode->HDisplay, mode->VDisplay,
142 * Initialises the Crtc parameters for a mode. The initialisation includes
215 * Duplicates every mode in the given list and returns a pointer to the first
216 * mode.
218 * \param modeList doubly-linked mode list
224 DisplayModePtr mode;
226 for (mode = modeList; mode != NULL; mode = mode->next) {
229 new = xf86DuplicateMode(mode);
286 xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
291 if (mode->HSkew) {
292 snprintf(tmp, 256, "hskew %i", mode->HSkew);
295 if (mode->VScan) {
296 snprintf(tmp, 256, "vscan %i", mode->VScan);
299 if (mode->Flags & V_INTERLACE) add(&flags, "interlace");
300 if (mode->Flags & V_CSYNC) add(&flags, "composite");
301 if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan");
302 if (mode->Flags & V_BCAST) add(&flags, "bcast");
303 if (mode->Flags & V_PHSYNC) add(&flags, "+hsync");
304 if (mode->Flags & V_NHSYNC) add(&flags, "-hsync");
305 if (mode->Flags & V_PVSYNC) add(&flags, "+vsync");
306 if (mode->Flags & V_NVSYNC) add(&flags, "-vsync");
307 if (mode->Flags & V_PCSYNC) add(&flags, "+csync");
308 if (mode->Flags & V_NCSYNC) add(&flags, "-csync");
310 if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
315 mode->name, mode->VRefresh, mode->Clock/1000., mode->HDisplay,
316 mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
317 mode->VDisplay, mode->VSyncStart, mode->VSyncEnd,
318 mode->VTotal, flags, xf86ModeHSync(mode));
334 DisplayModePtr mode;
339 for (mode = modeList; mode != NULL; mode = mode->next) {
340 if (mode->Flags & V_INTERLACE && !(flags & V_INTERLACE))
341 mode->status = MODE_NO_INTERLACE;
342 if (mode->Flags & V_DBLSCAN && !(flags & V_DBLSCAN))
343 mode->status = MODE_NO_DBLESCAN;
356 DisplayModePtr mode;
365 for (mode = modeList; mode != NULL; mode = mode->next) {
366 if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
367 xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
368 xf86ModeHeight(mode, RR_Rotate_0) > maxY) &&
369 (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch ||
370 xf86ModeWidth(mode, RR_Rotate_90) > maxX ||
371 xf86ModeHeight(mode, RR_Rotate_90) > maxY)) {
372 if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
373 xf86ModeWidth(mode, RR_Rotate_90) > maxPitch)
374 mode->status = MODE_BAD_WIDTH;
376 if (xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
377 xf86ModeWidth(mode, RR_Rotate_90) > maxX)
378 mode->status = MODE_VIRTUAL_X;
380 if (xf86ModeHeight(mode, RR_Rotate_0) > maxY ||
381 xf86ModeHeight(mode, RR_Rotate_90) > maxY)
382 mode->status = MODE_VIRTUAL_Y;
385 if (mode->next == modeList)
400 DisplayModePtr mode;
402 for (mode = modeList; mode != NULL; mode = mode->next) {
408 if (xf86ModeHSync(mode) >= mon->hsync[i].lo * (1-SYNC_TOLERANCE) &&
409 xf86ModeHSync(mode) <= mon->hsync[i].hi * (1+SYNC_TOLERANCE))
415 mode->status = MODE_HSYNC;
419 if (xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo * (1-SYNC_TOLERANCE) &&
420 xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi * (1+SYNC_TOLERANCE))
426 mode->status = MODE_VSYNC;
428 if (mode->next == modeList)
445 DisplayModePtr mode;
448 for (mode = modeList; mode != NULL; mode = mode->next) {
451 if (mode->Clock >= min[i] * (1-SYNC_TOLERANCE) &&
452 mode->Clock <= max[i] * (1+SYNC_TOLERANCE)) {
458 mode->status = MODE_CLOCK_RANGE;
463 * If the user has specified a set of mode names to use, mark as bad any modes
466 * The user mode names specified are prefixes to names of modes, so "1024x768"
477 DisplayModePtr mode;
482 for (mode = modeList; mode != NULL; mode = mode->next) {
487 if (strncmp(pScrn->display->modes[i], mode->name,
494 mode->status = MODE_BAD;
510 DisplayModePtr mode;
512 for (mode = modeList; mode != NULL; mode = mode->next) {
513 if (xf86ModeBandwidth(mode, depth) > bandwidth)
514 mode->status = MODE_BANDWIDTH;
519 xf86ModeIsReduced(const DisplayModeRec *mode)
521 if ((((mode->HDisplay * 5 / 4) & ~0x07) > mode->HTotal) &&
522 ((mode->HTotal - mode->HDisplay) == 160) &&
523 ((mode->HSyncEnd - mode->HDisplay) == 80) &&
524 ((mode->HSyncEnd - mode->HSyncStart) == 32) &&
525 ((mode->VSyncStart - mode->VDisplay) == 3))
547 * \param verbose determines whether the reason for mode invalidation is
554 DisplayModePtr mode;
556 for (mode = *modeList; mode != NULL;) {
557 DisplayModePtr next = mode->next, first = *modeList;
559 if (mode->status != MODE_OK) {
562 if (mode->type & M_T_BUILTIN)
564 else if (mode->type & M_T_DEFAULT)
567 "Not using %smode \"%s\" (%s)\n", type, mode->name,
568 xf86ModeStatusToString(mode->status));
570 xf86DeleteMode(modeList, mode);
575 mode = next;
580 * Adds the new mode into the mode list, and returns the new list
582 * \param modes doubly-linked mode list.
591 DisplayModePtr mode = modes;
593 while (mode->next)
594 mode = mode->next;
596 mode->next = new;
597 new->prev = mode;
604 * Build a mode list from a list of config file modes
609 DisplayModePtr head = NULL, prev = NULL, mode;
613 mode = calloc(1, sizeof(DisplayModeRec));
614 if (!mode)
616 mode->name = xstrdup(conf_mode->ml_identifier);
617 if (!mode->name)
619 free(mode);
622 mode->type = 0;
623 mode->Clock = conf_mode->ml_clock;
624 mode->HDisplay = conf_mode->ml_hdisplay;
625 mode->HSyncStart = conf_mode->ml_hsyncstart;
626 mode->HSyncEnd = conf_mode->ml_hsyncend;
627 mode->HTotal = conf_mode->ml_htotal;
628 mode->VDisplay = conf_mode->ml_vdisplay;
629 mode->VSyncStart = conf_mode->ml_vsyncstart;
630 mode->VSyncEnd = conf_mode->ml_vsyncend;
631 mode->VTotal = conf_mode->ml_vtotal;
632 mode->Flags = conf_mode->ml_flags;
633 mode->HSkew = conf_mode->ml_hskew;
634 mode->VScan = conf_mode->ml_vscan;
636 mode->prev = prev;
637 mode->next = NULL;
639 prev->next = mode;
641 head = mode;
642 prev = mode;
648 * Build a mode list from a monitor configuration
660 * first we collect the mode lines from the UseModes directive
680 * Build a mode list containing all of the default modes
685 DisplayModePtr head = NULL, mode;
692 mode = xf86DuplicateMode(defMode);
693 head = xf86ModesAdd(head, mode);
699 * Walk a mode list and prune out duplicates. Will preserve the preferred
700 * mode of an otherwise-duplicate pair.
703 * (driver, default, user, etc.), otherwise, which mode gets deleted is