aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/modes/xf86cvt.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/modes/xf86cvt.c')
-rw-r--r--xorg-server/hw/xfree86/modes/xf86cvt.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/xorg-server/hw/xfree86/modes/xf86cvt.c b/xorg-server/hw/xfree86/modes/xf86cvt.c
index d5fecccb5..de0784493 100644
--- a/xorg-server/hw/xfree86/modes/xf86cvt.c
+++ b/xorg-server/hw/xfree86/modes/xf86cvt.c
@@ -65,12 +65,12 @@
*/
DisplayModePtr
xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Interlaced)
+ Bool Interlaced)
{
- DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+ DisplayModeRec *Mode = xnfcalloc(1, sizeof(DisplayModeRec));
/* 1) top/bottom margin size (% of height) - default: 1.8 */
-#define CVT_MARGIN_PERCENTAGE 1.8
+#define CVT_MARGIN_PERCENTAGE 1.8
/* 2) character cell horizontal granularity (pixels) - default 8 */
#define CVT_H_GRANULARITY 8
@@ -85,10 +85,10 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
#define CVT_CLOCK_STEP 250
Bool Margins = FALSE;
- float VFieldRate, HPeriod;
- int HDisplayRnd, HMargin;
- int VDisplayRnd, VMargin, VSync;
- float Interlace; /* Please rename this */
+ float VFieldRate, HPeriod;
+ int HDisplayRnd, HMargin;
+ int VDisplayRnd, VMargin, VSync;
+ float Interlace; /* Please rename this */
/* CVT default is 60.0Hz */
if (!VRefresh)
@@ -108,11 +108,12 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* right margin is actually exactly the same as left */
HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
HMargin -= HMargin % CVT_H_GRANULARITY;
- } else
+ }
+ else
HMargin = 0;
/* 4. Find total active pixels */
- Mode->HDisplay = HDisplayRnd + 2*HMargin;
+ Mode->HDisplay = HDisplayRnd + 2 * HMargin;
/* 5. Find number of lines per field */
if (Interlaced)
@@ -128,7 +129,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
else
VMargin = 0;
- Mode->VDisplay = VDisplay + 2*VMargin;
+ Mode->VDisplay = VDisplay + 2 * VMargin;
/* 7. Interlace */
if (Interlaced)
@@ -147,10 +148,10 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
VSync = 7;
else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))
VSync = 7;
- else /* Custom */
+ else /* Custom */
VSync = 10;
- if (!Reduced) { /* simplified GTF calculation */
+ if (!Reduced) { /* simplified GTF calculation */
/* 4) Minimum time of vertical sync + back porch interval (µs)
* default 550.0 */
@@ -159,19 +160,20 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* 3) Nominal HSync width (% of line period) - default 8 */
#define CVT_HSYNC_PERCENTAGE 8
- float HBlankPercentage;
- int VSyncAndBackPorch, VBackPorch;
- int HBlank;
+ float HBlankPercentage;
+ int VSyncAndBackPorch, VBackPorch;
+ int HBlank;
/* 8. Estimated Horizontal period */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
+ HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
(VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace);
/* 9. Find number of lines in sync + backporch */
- if (((int)(CVT_MIN_VSYNC_BP / HPeriod) + 1) < (VSync + CVT_MIN_V_PORCH))
+ if (((int) (CVT_MIN_VSYNC_BP / HPeriod) + 1) <
+ (VSync + CVT_MIN_V_PORCH))
VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH;
else
- VSyncAndBackPorch = (int)(CVT_MIN_VSYNC_BP / HPeriod) + 1;
+ VSyncAndBackPorch = (int) (CVT_MIN_VSYNC_BP / HPeriod) + 1;
/* 10. Find number of lines in back porch */
VBackPorch = VSyncAndBackPorch - VSync;
@@ -198,31 +200,32 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
CVT_J_FACTOR
/* 12. Find ideal blanking duty cycle from formula */
- HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod/1000.0;
+ HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod / 1000.0;
/* 13. Blanking time */
if (HBlankPercentage < 20)
HBlankPercentage = 20;
- HBlank = Mode->HDisplay * HBlankPercentage/(100.0 - HBlankPercentage);
- HBlank -= HBlank % (2*CVT_H_GRANULARITY);
-
+ HBlank = Mode->HDisplay * HBlankPercentage / (100.0 - HBlankPercentage);
+ HBlank -= HBlank % (2 * CVT_H_GRANULARITY);
+
/* 14. Find total number of pixels in a line. */
Mode->HTotal = Mode->HDisplay + HBlank;
/* Fill in HSync values */
Mode->HSyncEnd = Mode->HDisplay + HBlank / 2;
- Mode->HSyncStart = Mode->HSyncEnd -
+ Mode->HSyncStart = Mode->HSyncEnd -
(Mode->HTotal * CVT_HSYNC_PERCENTAGE) / 100;
- Mode->HSyncStart += CVT_H_GRANULARITY -
+ Mode->HSyncStart += CVT_H_GRANULARITY -
Mode->HSyncStart % CVT_H_GRANULARITY;
/* Fill in VSync values */
Mode->VSyncStart = Mode->VDisplay + CVT_MIN_V_PORCH;
Mode->VSyncEnd = Mode->VSyncStart + VSync;
- } else { /* Reduced blanking */
+ }
+ else { /* Reduced blanking */
/* Minimum vertical blanking interval time (µs) - default 460 */
#define CVT_RB_MIN_VBLANK 460.0
@@ -235,11 +238,11 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* Fixed number of lines for vertical front porch - default 3 */
#define CVT_RB_VFPORCH 3
- int VBILines;
+ int VBILines;
/* 8. Estimate Horizontal period. */
- HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
- (VDisplayRnd + 2*VMargin);
+ HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
+ (VDisplayRnd + 2 * VMargin);
/* 9. Find number of lines in vertical blanking */
VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1;
@@ -247,7 +250,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
/* 10. Check if vertical blanking is sufficient */
if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH))
VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH;
-
+
/* 11. Find total number of lines in vertical field */
Mode->VTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines;
@@ -271,7 +274,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
Mode->HSync = ((float) Mode->Clock) / ((float) Mode->HTotal);
/* 17/15. Find actual Field rate */
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
+ Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
((float) (Mode->HTotal * Mode->VTotal));
/* 18/16. Find actual vertical frame frequency */