aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/utils
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/utils')
-rw-r--r--xorg-server/hw/xfree86/utils/cvt/cvt.c100
-rw-r--r--xorg-server/hw/xfree86/utils/gtf/gtf.c324
2 files changed, 190 insertions, 234 deletions
diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c
index 0de5ffea4..9483964e0 100644
--- a/xorg-server/hw/xfree86/utils/cvt/cvt.c
+++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c
@@ -30,6 +30,7 @@ void
FatalError(const char *f, ...)
{
va_list args;
+
va_start(args, f);
vfprintf(stderr, f, args);
va_end(args);
@@ -69,22 +70,21 @@ XNFcalloc(unsigned long n)
*/
static Bool
CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
- Bool Verbose)
+ Bool Verbose)
{
- Bool IsCVT = TRUE;
+ Bool IsCVT = TRUE;
if ((!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay)) ||
(!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay)) ||
(!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay)) ||
(!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay)) ||
- (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)))
- ;
+ (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay)));
else {
if (Verbose)
fprintf(stderr, "Warning: Aspect Ratio is not CVT standard.\n");
IsCVT = FALSE;
}
-
+
if ((VRefresh != 50.0) && (VRefresh != 60.0) &&
(VRefresh != 75.0) && (VRefresh != 85.0)) {
if (Verbose)
@@ -92,11 +92,10 @@ CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
"(50, 60, 75 or 85Hz).\n");
IsCVT = FALSE;
}
-
+
return IsCVT;
}
-
/*
* I'm not documenting --interlaced for obvious reasons, even though I did
* implement it. I also can't deny having looked at gtf here.
@@ -113,20 +112,21 @@ PrintUsage(char *Name)
"(default: normal blanking).\n");
fprintf(stderr, " X : Desired horizontal resolution "
"(multiple of 8, required).\n");
- fprintf(stderr, " Y : Desired vertical resolution (required).\n");
- fprintf(stderr, " refresh : Desired refresh rate (default: 60.0Hz).\n");
+ fprintf(stderr,
+ " Y : Desired vertical resolution (required).\n");
+ fprintf(stderr,
+ " refresh : Desired refresh rate (default: 60.0Hz).\n");
fprintf(stderr, "\n");
fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines"
- " for use with X.\n");
+ " for use with X.\n");
}
-
/*
*
*/
static void
-PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
+PrintComment(DisplayModeRec * Mode, Bool CVT, Bool Reduced)
{
printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh);
@@ -154,16 +154,16 @@ PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced)
printf("-R");
printf(") ");
- } else
+ }
+ else
printf("(CVT) ");
printf("hsync: %.2f kHz; ", Mode->HSync);
- printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0);
+ printf("pclk: %.2f MHz", ((float) Mode->Clock) / 1000.0);
printf("\n");
}
-
/*
* Originally grabbed from xf86Mode.c.
*
@@ -179,9 +179,9 @@ PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
else
printf("Modeline \"%dx%d_%.2f\" ", HDisplay, VDisplay, VRefresh);
- printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock/1000., Mode->HDisplay,
- Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal, Mode->VDisplay,
- Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
+ printf("%6.2f %i %i %i %i %i %i %i %i", Mode->Clock / 1000.,
+ Mode->HDisplay, Mode->HSyncStart, Mode->HSyncEnd, Mode->HTotal,
+ Mode->VDisplay, Mode->VSyncStart, Mode->VSyncEnd, Mode->VTotal);
if (Mode->Flags & V_INTERLACE)
printf(" interlace");
@@ -197,19 +197,18 @@ PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh,
printf("\n");
}
-
/*
*
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- DisplayModeRec *Mode;
- int HDisplay = 0, VDisplay = 0;
- float VRefresh = 0.0;
- Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
- Bool Interlaced = FALSE;
- int n;
+ DisplayModeRec *Mode;
+ int HDisplay = 0, VDisplay = 0;
+ float VRefresh = 0.0;
+ Bool Reduced = FALSE, Verbose = FALSE, IsCVT;
+ Bool Interlaced = FALSE;
+ int n;
if ((argc < 3) || (argc > 7)) {
PrintUsage(argv[0]);
@@ -230,27 +229,28 @@ main (int argc, char *argv[])
else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) {
PrintUsage(argv[0]);
return 0;
- } else if (!HDisplay) {
+ }
+ else if (!HDisplay) {
HDisplay = atoi(argv[n]);
- if (!HDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!HDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else if (!VDisplay) {
VDisplay = atoi(argv[n]);
- if (!VDisplay) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!VDisplay) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else if (!VRefresh) {
VRefresh = atof(argv[n]);
- if (!VRefresh) {
- PrintUsage(argv[0]);
- return 1;
- }
- }
+ if (!VRefresh) {
+ PrintUsage(argv[0]);
+ return 1;
+ }
+ }
else {
PrintUsage(argv[0]);
return 1;
@@ -273,13 +273,13 @@ main (int argc, char *argv[])
}
if (Reduced) {
- if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
- fprintf(stderr,
- "\nERROR: Multiple of 60Hz refresh rate required for "
- " reduced blanking.\n");
- PrintUsage(argv[0]);
- return 0;
- }
+ if ((VRefresh / 60.0) != floor(VRefresh / 60.0)) {
+ fprintf(stderr,
+ "\nERROR: Multiple of 60Hz refresh rate required for "
+ " reduced blanking.\n");
+ PrintUsage(argv[0]);
+ return 0;
+ }
}
IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose);
@@ -288,6 +288,6 @@ main (int argc, char *argv[])
PrintComment(Mode, IsCVT, Reduced);
PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced);
-
+
return 0;
}
diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c
index 87fcb3f0e..15503bb35 100644
--- a/xorg-server/hw/xfree86/utils/gtf/gtf.c
+++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c
@@ -104,7 +104,7 @@
*/
#ifdef HAVE_XORG_CONFIG_H
-# include <xorg-config.h>
+#include <xorg-config.h>
#endif
#include <stdio.h>
@@ -128,38 +128,28 @@
#define C_PRIME (((C - J) * K/256.0) + J)
#define M_PRIME (K/256.0 * M)
-
/* struct definitions */
-typedef struct __mode
-{
+typedef struct __mode {
int hr, hss, hse, hfl;
int vr, vss, vse, vfl;
float pclk, h_freq, v_freq;
} mode;
-
-typedef struct __options
-{
+typedef struct __options {
int x, y;
int xorgmode, fbmode;
float v_freq;
} options;
-
-
-
/* prototypes */
void print_value(int n, const char *name, float val);
-void print_xf86_mode (mode *m);
-void print_fb_mode (mode *m);
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins);
-options *parse_command_line (int argc, char *argv[]);
-
-
-
+void print_xf86_mode(mode * m);
+void print_fb_mode(mode * m);
+mode *vert_refresh(int h_pixels, int v_lines, float freq,
+ int interlaced, int margins);
+options *parse_command_line(int argc, char *argv[]);
/*
* print_value() - print the result of the named computation; this is
@@ -168,34 +158,31 @@ options *parse_command_line (int argc, char *argv[]);
int global_verbose = 0;
-void print_value(int n, const char *name, float val)
+void
+print_value(int n, const char *name, float val)
{
if (global_verbose) {
printf("%2d: %-27s: %15f\n", n, name, val);
}
}
-
-
/* print_xf86_mode() - print the XServer modeline, given mode timings. */
-void print_xf86_mode (mode *m)
+void
+print_xf86_mode(mode * m)
{
- printf ("\n");
- printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
- m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
-
- printf (" Modeline \"%dx%d_%.2f\" %.2f"
- " %d %d %d %d"
- " %d %d %d %d"
- " -HSync +Vsync\n\n",
- m->hr, m->vr, m->v_freq, m->pclk,
- m->hr, m->hss, m->hse, m->hfl,
- m->vr, m->vss, m->vse, m->vfl);
-
-}
+ printf("\n");
+ printf(" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
+ m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
+ printf(" Modeline \"%dx%d_%.2f\" %.2f"
+ " %d %d %d %d"
+ " %d %d %d %d"
+ " -HSync +Vsync\n\n",
+ m->hr, m->vr, m->v_freq, m->pclk,
+ m->hr, m->hss, m->hse, m->hfl, m->vr, m->vss, m->vse, m->vfl);
+}
/*
* print_fb_mode() - print a mode description in fbset(8) format;
@@ -243,31 +230,26 @@ void print_xf86_mode (mode *m)
* to edit the mode description after it's generated.
*/
-void print_fb_mode (mode *m)
+void
+print_fb_mode(mode * m)
{
- printf ("\n");
- printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n",
- m->hr, m->vr, m->v_freq);
- printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
- m->pclk, m->h_freq, m->v_freq);
- printf (" geometry %d %d %d %d 32\n",
- m->hr, m->vr, m->hr, m->vr);
- printf (" timings %d %d %d %d %d %d %d\n",
- (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */
- m->hfl - m->hse, /* left margin (in pixels) */
- m->hss - m->hr, /* right margin (in pixels) */
- m->vfl - m->vse, /* upper margin (in pixel lines) */
- m->vss - m->vr, /* lower margin (in pixel lines) */
- m->hse - m->hss, /* horizontal sync length (pixels) */
- m->vse - m->vss); /* vert sync length (pixel lines) */
- printf (" hsync low\n");
- printf (" vsync high\n");
- printf ("endmode\n\n");
-
-}
-
-
+ printf("\n");
+ printf("mode \"%dx%d %.2fHz 32bit (GTF)\"\n", m->hr, m->vr, m->v_freq);
+ printf(" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
+ m->pclk, m->h_freq, m->v_freq);
+ printf(" geometry %d %d %d %d 32\n", m->hr, m->vr, m->hr, m->vr);
+ printf(" timings %d %d %d %d %d %d %d\n", (int) rint(1000000.0 / m->pclk), /* pixclock in picoseconds */
+ m->hfl - m->hse, /* left margin (in pixels) */
+ m->hss - m->hr, /* right margin (in pixels) */
+ m->vfl - m->vse, /* upper margin (in pixel lines) */
+ m->vss - m->vr, /* lower margin (in pixel lines) */
+ m->hse - m->hss, /* horizontal sync length (pixels) */
+ m->vse - m->vss); /* vert sync length (pixel lines) */
+ printf(" hsync low\n");
+ printf(" vsync high\n");
+ printf("endmode\n\n");
+}
/*
* vert_refresh() - as defined by the GTF Timing Standard, compute the
@@ -282,8 +264,8 @@ void print_fb_mode (mode *m)
* XServer of fbset mode descriptions, from what I can tell).
*/
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins)
+mode *
+vert_refresh(int h_pixels, int v_lines, float freq, int interlaced, int margins)
{
float h_pixels_rnd;
float v_lines_rnd;
@@ -312,9 +294,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
float h_front_porch;
float v_odd_front_porch_lines;
- mode *m = (mode*) malloc (sizeof (mode));
-
-
+ mode *m = (mode *) malloc(sizeof(mode));
+
/* 1. In order to give correct results, the number of horizontal
* pixels requested is first processed to ensure that it is divisible
* by the character size, by rounding it to the nearest character
@@ -322,12 +303,11 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*
* [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
*/
-
+
h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
-
+
print_value(1, "[H PIXELS RND]", h_pixels_rnd);
-
/* 2. If interlace is requested, the number of vertical lines assumed
* by the calculation must be halved, as the computation calculates
* the number of vertical lines per field. In either case, the
@@ -338,12 +318,10 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
v_lines_rnd = interlaced ?
- rint((float) v_lines) / 2.0 :
- rint((float) v_lines);
-
+ rint((float) v_lines) / 2.0 : rint((float) v_lines);
+
print_value(2, "[V LINES RND]", v_lines_rnd);
-
-
+
/* 3. Find the frame rate required:
*
* [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
@@ -353,7 +331,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq);
print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd);
-
/* 4. Find number of lines in Top margin:
*
@@ -365,7 +342,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
print_value(4, "[TOP MARGIN (LINES)]", top_margin);
-
/* 5. Find number of lines in Bottom margin:
*
@@ -374,11 +350,11 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* 0)
*/
- bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
+ bottom_margin =
+ margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
-
/* 6. If interlace is required, then set variable [INTERLACE]=0.5:
*
* [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
@@ -387,7 +363,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
interlace = interlaced ? 0.5 : 0.0;
print_value(6, "[INTERLACE]", interlace);
-
/* 7. Estimate the Horizontal period
*
@@ -396,34 +371,31 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* [MIN PORCH RND]+[INTERLACE]) * 1000000
*/
- h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
- / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
+ h_period_est = (((1.0 / v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP / 1000000.0))
+ / (v_lines_rnd + (2 * top_margin) + MIN_PORCH + interlace)
* 1000000.0);
print_value(7, "[H PERIOD EST]", h_period_est);
-
/* 8. Find the number of lines in V sync + back porch:
*
* [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
*/
- vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
+ vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP / h_period_est);
print_value(8, "[V SYNC+BP]", vsync_plus_bp);
-
-
+
/* 9. Find the number of lines in V back porch alone:
*
* [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND]
*
* XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
*/
-
+
v_back_porch = vsync_plus_bp - V_SYNC_RQD;
-
+
print_value(9, "[V BACK PORCH]", v_back_porch);
-
/* 10. Find the total number of lines in Vertical field period:
*
@@ -434,9 +406,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
interlace + MIN_PORCH;
-
+
print_value(10, "[TOTAL V LINES]", total_v_lines);
-
/* 11. Estimate the Vertical field frequency:
*
@@ -444,9 +415,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
-
+
print_value(11, "[V FIELD RATE EST]", v_field_rate_est);
-
/* 12. Find the actual horizontal period:
*
@@ -454,9 +424,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
-
+
print_value(12, "[H PERIOD]", h_period);
-
/* 13. Find the actual Vertical field frequency:
*
@@ -466,7 +435,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0;
print_value(13, "[V FIELD RATE]", v_field_rate);
-
/* 14. Find the Vertical frame frequency:
*
@@ -476,7 +444,6 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate;
print_value(14, "[V FRAME RATE]", v_frame_rate);
-
/* 15. Find number of pixels in left margin:
*
@@ -489,9 +456,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
left_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin);
-
/* 16. Find number of pixels in right margin:
*
@@ -500,13 +466,12 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
* [CELL GRAN RND]),0)) * [CELL GRAN RND],
* 0))
*/
-
+
right_margin = margins ?
rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
0.0;
-
+
print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin);
-
/* 17. Find total number of active pixels in image and left and right
* margins:
@@ -516,10 +481,9 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
total_active_pixels = h_pixels_rnd + left_margin + right_margin;
-
+
print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels);
-
-
+
/* 18. Find the ideal blanking duty cycle from the blanking duty cycle
* equation:
*
@@ -527,9 +491,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
-
+
print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle);
-
/* 19. Find the number of pixels in the blanking time to the nearest
* double character cell:
@@ -545,9 +508,8 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
ideal_duty_cycle /
(100.0 - ideal_duty_cycle) /
(2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
-
+
print_value(19, "[H BLANK (PIXELS)]", h_blank);
-
/* 20. Find total number of pixels:
*
@@ -555,19 +517,17 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
total_pixels = total_active_pixels + h_blank;
-
+
print_value(20, "[TOTAL PIXELS]", total_pixels);
-
/* 21. Find pixel clock frequency:
*
* [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
*/
-
+
pixel_freq = total_pixels / h_period;
-
+
print_value(21, "[PIXEL FREQ]", pixel_freq);
-
/* 22. Find horizontal frequency:
*
@@ -575,28 +535,24 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
*/
h_freq = 1000.0 / h_period;
-
- print_value(22, "[H FREQ]", h_freq);
-
+ print_value(22, "[H FREQ]", h_freq);
/* Stage 1 computations are now complete; I should really pass
the results to another function and do the Stage 2
computations, but I only need a few more values so I'll just
append the computations here for now */
-
-
/* 17. Find the number of pixels in the horizontal sync period:
*
* [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] /
* [CELL GRAN RND]),0))*[CELL GRAN RND]
*/
- h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
+ h_sync =
+ rint(H_SYNC_PERCENT / 100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
print_value(17, "[H SYNC (PIXELS)]", h_sync);
-
/* 18. Find the number of pixels in the horizontal front porch period:
*
@@ -606,136 +562,136 @@ mode *vert_refresh (int h_pixels, int v_lines, float freq,
h_front_porch = (h_blank / 2.0) - h_sync;
print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch);
-
-
+
/* 36. Find the number of lines in the odd front porch period:
*
* [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
*/
-
+
v_odd_front_porch_lines = MIN_PORCH + interlace;
-
+
print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines);
-
/* finally, pack the results in the mode struct */
-
- m->hr = (int) (h_pixels_rnd);
+
+ m->hr = (int) (h_pixels_rnd);
m->hss = (int) (h_pixels_rnd + h_front_porch);
m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync);
m->hfl = (int) (total_pixels);
- m->vr = (int) (v_lines_rnd);
+ m->vr = (int) (v_lines_rnd);
m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines);
m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
m->vfl = (int) (total_v_lines);
- m->pclk = pixel_freq;
+ m->pclk = pixel_freq;
m->h_freq = h_freq;
m->v_freq = freq;
return m;
-
-}
-
-
+}
/*
* parse_command_line() - parse the command line and return an
* alloced structure containing the results. On error print usage
* and return NULL.
- */
+ */
-options *parse_command_line (int argc, char *argv[])
+options *
+parse_command_line(int argc, char *argv[])
{
int n;
- options *o = (options *) calloc (1, sizeof (options));
+ options *o = (options *) calloc(1, sizeof(options));
- if (argc < 4) goto bad_option;
+ if (argc < 4)
+ goto bad_option;
- o->x = atoi (argv[1]);
- o->y = atoi (argv[2]);
- o->v_freq = atof (argv[3]);
+ o->x = atoi(argv[1]);
+ o->y = atoi(argv[2]);
+ o->v_freq = atof(argv[3]);
/* XXX should check for errors in the above */
-
+
n = 4;
while (n < argc) {
- if ((strcmp (argv[n], "-v") == 0) ||
- (strcmp (argv[n], "--verbose") == 0)) {
+ if ((strcmp(argv[n], "-v") == 0) || (strcmp(argv[n], "--verbose") == 0)) {
global_verbose = 1;
- } else if ((strcmp (argv[n], "-f") == 0) ||
- (strcmp (argv[n], "--fbmode") == 0)) {
+ }
+ else if ((strcmp(argv[n], "-f") == 0) ||
+ (strcmp(argv[n], "--fbmode") == 0)) {
o->fbmode = 1;
- } else if ((strcmp (argv[n], "-x") == 0) ||
- (strcmp (argv[n], "--xorgmode") == 0) ||
- (strcmp (argv[n], "--xf86mode") == 0)) {
+ }
+ else if ((strcmp(argv[n], "-x") == 0) ||
+ (strcmp(argv[n], "--xorgmode") == 0) ||
+ (strcmp(argv[n], "--xf86mode") == 0)) {
o->xorgmode = 1;
- } else {
+ }
+ else {
goto bad_option;
}
-
+
n++;
}
/* if neither xorgmode nor fbmode were requested, default to
xorgmode */
- if (!o->fbmode && !o->xorgmode) o->xorgmode = 1;
-
+ if (!o->fbmode && !o->xorgmode)
+ o->xorgmode = 1;
+
return o;
-
+
bad_option:
- fprintf (stderr, "\n");
- fprintf (stderr, "usage: %s x y refresh [-v|--verbose] "
- "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
-
- fprintf (stderr, "\n");
-
- fprintf (stderr, " x : the desired horizontal "
- "resolution (required)\n");
- fprintf (stderr, " y : the desired vertical "
- "resolution (required)\n");
- fprintf (stderr, " refresh : the desired refresh "
- "rate (required)\n");
- fprintf (stderr, " -v|--verbose : enable verbose printouts "
- "(traces each step of the computation)\n");
- fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode "
- "description\n");
- fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode "
- "description (this is the default\n"
- " if no mode description is requested)\n");
-
- fprintf (stderr, "\n");
-
- free (o);
- return NULL;
+ fprintf(stderr, "\n");
+ fprintf(stderr, "usage: %s x y refresh [-v|--verbose] "
+ "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
-}
+ fprintf(stderr, "\n");
+ fprintf(stderr, " x : the desired horizontal "
+ "resolution (required)\n");
+ fprintf(stderr, " y : the desired vertical "
+ "resolution (required)\n");
+ fprintf(stderr, " refresh : the desired refresh " "rate (required)\n");
+ fprintf(stderr, " -v|--verbose : enable verbose printouts "
+ "(traces each step of the computation)\n");
+ fprintf(stderr, " -f|--fbmode : output an fbset(8)-style mode "
+ "description\n");
+ fprintf(stderr, " -x|--xorgmode : output an " __XSERVERNAME__ "-style mode "
+ "description (this is the default\n"
+ " if no mode description is requested)\n");
+ fprintf(stderr, "\n");
-int main (int argc, char *argv[])
+ free(o);
+ return NULL;
+
+}
+
+int
+main(int argc, char *argv[])
{
mode *m;
options *o;
- o = parse_command_line (argc, argv);
- if (!o) exit (1);
-
- m = vert_refresh (o->x, o->y, o->v_freq, 0, 0);
- if (!m) exit (1);
+ o = parse_command_line(argc, argv);
+ if (!o)
+ exit(1);
+
+ m = vert_refresh(o->x, o->y, o->v_freq, 0, 0);
+ if (!m)
+ exit(1);
if (o->xorgmode)
print_xf86_mode(m);
-
+
if (o->fbmode)
print_fb_mode(m);
-
+
return 0;
-
+
}