~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonfig.c,v 1.12 2003/01/01 19:16:31 tsi Exp $ */
 
2
/*
 
3
 * Copyright 2000 through 2003 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
 
4
 *
 
5
 * Permission to use, copy, modify, distribute, and sell this software and its
 
6
 * documentation for any purpose is hereby granted without fee, provided that
 
7
 * the above copyright notice appear in all copies and that both that copyright
 
8
 * notice and this permission notice appear in supporting documentation, and
 
9
 * that the name of Marc Aurele La France not be used in advertising or
 
10
 * publicity pertaining to distribution of the software without specific,
 
11
 * written prior permission.  Marc Aurele La France makes no representations
 
12
 * about the suitability of this software for any purpose.  It is provided
 
13
 * "as-is" without express or implied warranty.
 
14
 *
 
15
 * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
 
17
 * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
19
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
20
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
21
 * PERFORMANCE OF THIS SOFTWARE.
 
22
 */
 
23
 
 
24
#include "ati.h"
 
25
#include "atiadapter.h"
 
26
#include "atichip.h"
 
27
#include "aticonfig.h"
 
28
#include "aticursor.h"
 
29
#include "atioption.h"
 
30
#include "atistruct.h"
 
31
 
 
32
/*
 
33
 * Non-publicised XF86Config options.
 
34
 */
 
35
typedef enum
 
36
{
 
37
    ATI_OPTION_CRT_SCREEN,      /* Legacy negation of "PanelDisplay" */
 
38
    ATI_OPTION_DEVEL,           /* Intentionally undocumented */
 
39
    ATI_OPTION_BLEND,           /* Force horizontal blending of small modes */
 
40
    ATI_OPTION_SYNC             /* Use XF86Config panel mode porches */
 
41
} ATIPrivateOptionType;
 
42
 
 
43
/*
 
44
 * ATIProcessOptions --
 
45
 *
 
46
 * This function extracts options from what was parsed out of the XF86Config
 
47
 * file.
 
48
 */
 
49
void
 
50
ATIProcessOptions
 
51
(
 
52
    ScrnInfoPtr pScreenInfo,
 
53
    ATIPtr      pATI
 
54
)
 
55
{
 
56
    OptionInfoPtr PublicOption = xnfalloc(ATIPublicOptionSize);
 
57
    OptionInfoRec PrivateOption[] =
 
58
    {
 
59
        {                       /* Negation of "PanelDisplay" public option */
 
60
            ATI_OPTION_CRT_SCREEN,
 
61
            "crtscreen",
 
62
            OPTV_BOOLEAN,
 
63
            {0, },
 
64
            FALSE
 
65
        },
 
66
        {                       /* ON:   Horizontally blend most modes */
 
67
            ATI_OPTION_BLEND,   /* OFF:  Use pixel replication more often */
 
68
            "lcdblend",
 
69
            OPTV_BOOLEAN,
 
70
            {0, },
 
71
            FALSE
 
72
        },
 
73
        {                       /* ON:   Use XF86Config porch timings */
 
74
            ATI_OPTION_SYNC,    /* OFF:  Use porches from mode on entry */
 
75
            "lcdsync",
 
76
            OPTV_BOOLEAN,
 
77
            {0, },
 
78
            FALSE
 
79
        },
 
80
        {                       /* ON:   Ease exploration of loose ends */
 
81
            ATI_OPTION_DEVEL,   /* OFF:  Fit for public consumption */
 
82
            "tsi",
 
83
            OPTV_BOOLEAN,
 
84
            {0, },
 
85
            FALSE
 
86
        },
 
87
        {
 
88
            -1,
 
89
            NULL,
 
90
            OPTV_NONE,
 
91
            {0, },
 
92
            FALSE
 
93
        }
 
94
    };
 
95
 
 
96
    (void)memcpy(PublicOption, ATIPublicOptions, ATIPublicOptionSize);
 
97
 
 
98
#   define Accel        PublicOption[ATI_OPTION_ACCEL].value.bool
 
99
#   define Blend        PrivateOption[ATI_OPTION_BLEND].value.bool
 
100
#   define CRTDisplay   PublicOption[ATI_OPTION_CRT_DISPLAY].value.bool
 
101
#   define CRTScreen    PrivateOption[ATI_OPTION_CRT_SCREEN].value.bool
 
102
#   define CSync        PublicOption[ATI_OPTION_CSYNC].value.bool
 
103
#   define Devel        PrivateOption[ATI_OPTION_DEVEL].value.bool
 
104
#   define HWCursor     PublicOption[ATI_OPTION_HWCURSOR].value.bool
 
105
 
 
106
#ifndef AVOID_CPIO
 
107
 
 
108
#   define Linear       PublicOption[ATI_OPTION_LINEAR].value.bool
 
109
 
 
110
#endif /* AVOID_CPIO */
 
111
 
 
112
#   define CacheMMIO    PublicOption[ATI_OPTION_MMIO_CACHE].value.bool
 
113
#   define PanelDisplay PublicOption[ATI_OPTION_PANEL_DISPLAY].value.bool
 
114
#   define ProbeClocks  PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool
 
115
#   define ShadowFB     PublicOption[ATI_OPTION_SHADOW_FB].value.bool
 
116
#   define SWCursor     PublicOption[ATI_OPTION_SWCURSOR].value.bool
 
117
#   define Sync         PrivateOption[ATI_OPTION_SYNC].value.bool
 
118
 
 
119
#   define ReferenceClock \
 
120
        PublicOption[ATI_OPTION_REFERENCE_CLOCK].value.freq.freq
 
121
 
 
122
    /* Pick up XF86Config options */
 
123
    xf86CollectOptions(pScreenInfo, NULL);
 
124
 
 
125
    /* Set non-zero defaults */
 
126
 
 
127
#ifndef AVOID_CPIO
 
128
 
 
129
    if (pATI->Adapter >= ATI_ADAPTER_MACH64)
 
130
 
 
131
#endif /* AVOID_CPIO */
 
132
 
 
133
    {
 
134
        Accel = CacheMMIO = HWCursor = TRUE;
 
135
 
 
136
#ifndef AVOID_CPIO
 
137
 
 
138
        Linear = TRUE;
 
139
 
 
140
#endif /* AVOID_CPIO */
 
141
 
 
142
    }
 
143
 
 
144
    ReferenceClock = ((double)157500000.0) / ((double)11.0);
 
145
 
 
146
#ifndef AVOID_CPIO
 
147
 
 
148
    if (pATI->PCIInfo)
 
149
 
 
150
#endif /* AVOID_CPIO */
 
151
 
 
152
    {
 
153
        ShadowFB = TRUE;
 
154
    }
 
155
 
 
156
    Blend = PanelDisplay = TRUE;
 
157
 
 
158
    xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
 
159
        PublicOption);
 
160
    xf86ProcessOptions(pScreenInfo->scrnIndex, pScreenInfo->options,
 
161
        PrivateOption);
 
162
 
 
163
#ifndef AVOID_CPIO
 
164
 
 
165
    /* Disable linear apertures if the OS doesn't support them */
 
166
    if (!xf86LinearVidMem() && Linear)
 
167
    {
 
168
        if (PublicOption[ATI_OPTION_LINEAR].found)
 
169
            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
 
170
                "OS does not support linear apertures.\n");
 
171
        Linear = FALSE;
 
172
    }
 
173
 
 
174
#endif /* AVOID_CPIO */
 
175
 
 
176
    /* Move option values into driver private structure */
 
177
    pATI->OptionAccel = Accel;
 
178
    pATI->OptionBlend = Blend;
 
179
    pATI->OptionCRTDisplay = CRTDisplay;
 
180
    pATI->OptionCSync = CSync;
 
181
    pATI->OptionDevel = Devel;
 
182
 
 
183
#ifndef AVOID_CPIO
 
184
 
 
185
    pATI->OptionLinear = Linear;
 
186
 
 
187
#endif /* AVOID_CPIO */
 
188
 
 
189
    pATI->OptionMMIOCache = CacheMMIO;
 
190
    pATI->OptionProbeClocks = ProbeClocks;
 
191
    pATI->OptionShadowFB = ShadowFB;
 
192
    pATI->OptionSync = Sync;
 
193
 
 
194
    /* "CRTScreen" is now "NoPanelDisplay" */
 
195
    if ((PanelDisplay != CRTScreen) ||
 
196
        PublicOption[ATI_OPTION_PANEL_DISPLAY].found)
 
197
        pATI->OptionPanelDisplay = PanelDisplay;
 
198
    else
 
199
        pATI->OptionPanelDisplay = !CRTScreen;
 
200
 
 
201
    /* Validate and set cursor options */
 
202
    pATI->Cursor = ATI_CURSOR_SOFTWARE;
 
203
    if (SWCursor || !HWCursor)
 
204
    {
 
205
        if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
 
206
            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
 
207
                "Option \"sw_cursor\" overrides Option \"hw_cursor\".\n");
 
208
    }
 
209
    else if (pATI->Chip < ATI_CHIP_264CT)
 
210
    {
 
211
        if (HWCursor && PublicOption[ATI_OPTION_HWCURSOR].found)
 
212
            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
 
213
                "Option \"hw_cursor\" not supported in this configuration.\n");
 
214
    }
 
215
    else
 
216
    {
 
217
        pATI->Cursor = ATI_CURSOR_HARDWARE;
 
218
    }
 
219
 
 
220
    /* Only set the reference clock if it hasn't already been determined */
 
221
    if (!pATI->ReferenceNumerator || !pATI->ReferenceDenominator)
 
222
    {
 
223
        switch ((int)(ReferenceClock / ((double)100000.0)))
 
224
        {
 
225
            case 143:
 
226
                pATI->ReferenceNumerator = 157500;
 
227
                pATI->ReferenceDenominator = 11;
 
228
                break;
 
229
 
 
230
            case 286:
 
231
                pATI->ReferenceNumerator = 315000;
 
232
                pATI->ReferenceDenominator = 11;
 
233
                break;
 
234
 
 
235
            default:
 
236
                pATI->ReferenceNumerator =
 
237
                    (int)(ReferenceClock / ((double)1000.0));
 
238
                pATI->ReferenceDenominator = 1;
 
239
                break;
 
240
        }
 
241
    }
 
242
 
 
243
    xfree(PublicOption);
 
244
}