diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/xfree86/utils/cvt/cvt.c | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/xfree86/utils/cvt/cvt.c')
-rw-r--r-- | xorg-server/hw/xfree86/utils/cvt/cvt.c | 236 |
1 files changed, 236 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c new file mode 100644 index 000000000..fee4f7c3e --- /dev/null +++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c @@ -0,0 +1,236 @@ +/* + * Copyright 2005-2006 Luc Verhaegen. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +/* Standalone VESA CVT standard timing modelines generator. */ + +#include "xf86.h" + +/* + * Quickly check wether this is a CVT standard mode. + */ +static Bool +CVTCheckStandard(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, + Bool Verbose) +{ + 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))) + ; + 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) + fprintf(stderr, "Warning: Refresh Rate is not CVT standard " + "(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. + */ +static void +PrintUsage(char *Name) +{ + fprintf(stderr, "\n"); + fprintf(stderr, "usage: %s [-v|--verbose] [-r|--reduced] X Y [refresh]\n", + Name); + fprintf(stderr, "\n"); + fprintf(stderr, " -v|--verbose : Warn about CVT standard adherance.\n"); + fprintf(stderr, " -r|--reduced : Create a mode with reduced blanking " + "(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, "\n"); + + fprintf(stderr, "Calculates VESA CVT (Coordinated Video Timing) modelines" + " for use with X.\n"); +} + + +/* + * + */ +static void +PrintComment(DisplayModeRec *Mode, Bool CVT, Bool Reduced) +{ + printf("# %dx%d %.2f Hz ", Mode->HDisplay, Mode->VDisplay, Mode->VRefresh); + + if (CVT) { + printf("(CVT %.2fM", + ((float) Mode->HDisplay * Mode->VDisplay) / 1000000.0); + + if (!(Mode->VDisplay % 3) && + ((Mode->VDisplay * 4 / 3) == Mode->HDisplay)) + printf("3"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 16 / 9) == Mode->HDisplay)) + printf("9"); + else if (!(Mode->VDisplay % 10) && + ((Mode->VDisplay * 16 / 10) == Mode->HDisplay)) + printf("A"); + else if (!(Mode->VDisplay % 4) && + ((Mode->VDisplay * 5 / 4) == Mode->HDisplay)) + printf("4"); + else if (!(Mode->VDisplay % 9) && + ((Mode->VDisplay * 15 / 9) == Mode->HDisplay)) + printf("9"); + + if (Reduced) + printf("-R"); + + printf(") "); + } else + printf("(CVT) "); + + printf("hsync: %.2f kHz; ", Mode->HSync); + printf("pclk: %.2f MHz", ((float ) Mode->Clock) / 1000.0); + + printf("\n"); +} + + +/* + * Originally grabbed from xf86Mode.c. + * + * Ignoring the actual Mode->name, as the user will want something solid + * to grab hold of. + */ +static void +PrintModeline(DisplayModePtr Mode, int HDisplay, int VDisplay, float VRefresh, + Bool Reduced) +{ + if (Reduced) + printf("Modeline \"%dx%dR\" ", HDisplay, VDisplay); + 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); + + if (Mode->Flags & V_INTERLACE) + printf(" interlace"); + if (Mode->Flags & V_PHSYNC) + printf(" +hsync"); + if (Mode->Flags & V_NHSYNC) + printf(" -hsync"); + if (Mode->Flags & V_PVSYNC) + printf(" +vsync"); + if (Mode->Flags & V_NVSYNC) + printf(" -vsync"); + + printf("\n"); +} + + +/* + * + */ +int +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; + + if ((argc < 3) || (argc > 7)) { + PrintUsage(argv[0]); + return 0; + } + + /* This doesn't filter out bad flags properly. Bad flags get passed down + * to atoi/atof, which then return 0, so that these variables can get + * filled next time round. So this is just a cosmetic problem. + */ + for (n = 1; n < argc; n++) { + if (!strcmp(argv[n], "-r") || !strcmp(argv[n], "--reduced")) + Reduced = TRUE; + else if (!strcmp(argv[n], "-i") || !strcmp(argv[n], "--interlaced")) + Interlaced = TRUE; + else if (!strcmp(argv[n], "-v") || !strcmp(argv[n], "--verbose")) + Verbose = TRUE; + else if (!strcmp(argv[n], "-h") || !strcmp(argv[n], "--help")) { + PrintUsage(argv[0]); + return 0; + } else if (!HDisplay) + HDisplay = atoi(argv[n]); + else if (!VDisplay) + VDisplay = atoi(argv[n]); + else if (!VRefresh) + VRefresh = atof(argv[n]); + else { + PrintUsage(argv[0]); + return 0; + } + } + + if (!HDisplay || !VDisplay) { + PrintUsage(argv[0]); + return 0; + } + + /* Default to 60.0Hz */ + if (!VRefresh) + VRefresh = 60.0; + + /* Horizontal timing is always a multiple of 8: round up. */ + if (HDisplay & 0x07) { + HDisplay &= ~0x07; + HDisplay += 8; + } + + if (Reduced && (VRefresh != 60.0)) { + fprintf(stderr, "\nERROR: 60Hz refresh rate required for reduced" + " blanking.\n"); + PrintUsage(argv[0]); + return 0; + } + + IsCVT = CVTCheckStandard(HDisplay, VDisplay, VRefresh, Reduced, Verbose); + + Mode = xf86CVTMode(HDisplay, VDisplay, VRefresh, Reduced, Interlaced); + + PrintComment(Mode, IsCVT, Reduced); + PrintModeline(Mode, HDisplay, VDisplay, VRefresh, Reduced); + + return 0; +} |