~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-mach64-lts-xenial/trusty-updates

« back to all changes in this revision

Viewing changes to src/aticonsole.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2016-05-03 14:02:37 UTC
  • Revision ID: package-import@ubuntu.com-20160503140237-y946gbjc7p6fg9fn
Tags: upstream-6.9.5
ImportĀ upstreamĀ versionĀ 6.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
 
5
 * documentation for any purpose is hereby granted without fee, provided that
 
6
 * the above copyright notice appear in all copies and that both that copyright
 
7
 * notice and this permission notice appear in supporting documentation, and
 
8
 * that the name of Marc Aurele La France not be used in advertising or
 
9
 * publicity pertaining to distribution of the software without specific,
 
10
 * written prior permission.  Marc Aurele La France makes no representations
 
11
 * about the suitability of this software for any purpose.  It is provided
 
12
 * "as-is" without express or implied warranty.
 
13
 *
 
14
 * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
 
16
 * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
20
 * PERFORMANCE OF THIS SOFTWARE.
 
21
 *
 
22
 * DRI support by:
 
23
 *    Manuel Teira
 
24
 *    Leif Delgass <ldelgass@retinalburn.net>
 
25
 */
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include "config.h"
 
29
#endif
 
30
 
 
31
#include "xorgVersion.h"
 
32
#include "ati.h"
 
33
#include "atii2c.h"
 
34
#include "atilock.h"
 
35
#include "atimach64.h"
 
36
#include "atimach64io.h"
 
37
#include "atimode.h"
 
38
#include "atistruct.h"
 
39
#include "ativga.h"
 
40
#include "atividmem.h"
 
41
#include "aticonsole.h"
 
42
 
 
43
#ifdef XF86DRI_DEVEL
 
44
#include "mach64_common.h"
 
45
#include "atidri.h"
 
46
#endif
 
47
 
 
48
#ifdef TV_OUT
 
49
 
 
50
#include "atichip.h"
 
51
#include "atiprint.h"
 
52
#include "atioption.h"
 
53
#include "vbe.h"
 
54
 
 
55
#endif /* TV_OUT */
 
56
 
 
57
/*
 
58
 * ATISaveScreen --
 
59
 *
 
60
 * This function is a screen saver hook for DIX.
 
61
 */
 
62
Bool
 
63
ATISaveScreen
 
64
(
 
65
    ScreenPtr pScreen,
 
66
    int       Mode
 
67
)
 
68
{
 
69
    ScrnInfoPtr pScreenInfo;
 
70
    ATIPtr      pATI;
 
71
 
 
72
    if ((Mode != SCREEN_SAVER_ON) && (Mode != SCREEN_SAVER_CYCLE))
 
73
        SetTimeSinceLastInputEvent();
 
74
 
 
75
    if (!pScreen)
 
76
        return TRUE;
 
77
 
 
78
    pScreenInfo = xf86ScreenToScrn(pScreen);
 
79
    if (!pScreenInfo->vtSema)
 
80
        return TRUE;
 
81
 
 
82
    pATI = ATIPTR(pScreenInfo);
 
83
    {
 
84
            ATIMach64SaveScreen(pATI, Mode);
 
85
    }
 
86
 
 
87
    return TRUE;
 
88
}
 
89
 
 
90
/*
 
91
 * ATISetDPMSMode --
 
92
 *
 
93
 * This function sets the adapter's VESA Display Power Management Signaling
 
94
 * mode.
 
95
 */
 
96
void
 
97
ATISetDPMSMode
 
98
(
 
99
    ScrnInfoPtr pScreenInfo,
 
100
    int         DPMSMode,
 
101
    int         flags
 
102
)
 
103
{
 
104
    ATIPtr pATI;
 
105
 
 
106
    if (!pScreenInfo || !pScreenInfo->vtSema)
 
107
        return;
 
108
 
 
109
    pATI = ATIPTR(pScreenInfo);
 
110
 
 
111
    {
 
112
            ATIMach64SetDPMSMode(pScreenInfo, pATI, DPMSMode);
 
113
    }
 
114
}
 
115
 
 
116
#ifdef TV_OUT
 
117
 
 
118
static void
 
119
ATIProbeAndSetActiveDisplays
 
120
(
 
121
    ScrnInfoPtr pScreenInfo,
 
122
    ATIPtr      pATI
 
123
)
 
124
{
 
125
    vbeInfoPtr pVbe;
 
126
    Bool tv_attached, crt_attached, lcd_attached;
 
127
    int disp_request;
 
128
    ATITVStandard tv_std, tv_std_request;
 
129
 
 
130
    if (xf86GetVerbosity() > 3) {
 
131
        xf86ErrorFVerb(4, "\n Before TV-Out queries\n\n");
 
132
        ATIPrintRegisters(pATI);
 
133
    }
 
134
 
 
135
    pATI->tvActive = FALSE;
 
136
    pVbe = pATI->pVBE;
 
137
    if (pVbe) {
 
138
        /* LT Pro, XL, Mobility specific BIOS functions */
 
139
        if (pATI->Chip == ATI_CHIP_264LTPRO ||
 
140
            pATI->Chip == ATI_CHIP_264XL || 
 
141
            pATI->Chip == ATI_CHIP_MOBILITY) {
 
142
    
 
143
            /* Get attached display(s) - LTPro, XL, Mobility */
 
144
            pVbe->pInt10->num = 0x10;
 
145
            pVbe->pInt10->ax = 0xa083;
 
146
            pVbe->pInt10->cx = 0x0700; /* ch=0x07 - probe all, 0x01 CRT, 0x02 TV, 0x04 LCD */
 
147
            xf86ExecX86int10(pVbe->pInt10);
 
148
 
 
149
            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
150
                       "Attached displays: ax=0x%04x, cx=0x%04x\n",
 
151
                       pVbe->pInt10->ax, pVbe->pInt10->cx);
 
152
 
 
153
            tv_attached = crt_attached = lcd_attached = FALSE;
 
154
            if (pVbe->pInt10->ax & 0xff00) {
 
155
                xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
156
                           "Failed to detect attached displays\n");
 
157
            } else {
 
158
                        
 
159
                if (pVbe->pInt10->cx & 0x3)
 
160
                {
 
161
                        xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
162
                                   "   CRT attached\n");
 
163
                        crt_attached = TRUE;
 
164
                }
 
165
                else
 
166
                    crt_attached = FALSE;
 
167
 
 
168
                if ((pVbe->pInt10->cx >> 2) & 0x3)
 
169
                {
 
170
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
171
                               "   DFP/LCD attached\n");
 
172
                    lcd_attached = TRUE;
 
173
                }
 
174
                else
 
175
                    lcd_attached = FALSE;
 
176
 
 
177
                switch ((pVbe->pInt10->cx >> 4) & 0x3) {
 
178
                case 0:
 
179
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
180
                               "   No TV attached\n");
 
181
                    break;
 
182
                case 1:
 
183
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
184
                               "   TV attached (composite connector)\n");
 
185
                    tv_attached = TRUE;
 
186
                    break;
 
187
                case 2:
 
188
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
189
                               "   TV attached (S-video connector)\n");
 
190
                    tv_attached = TRUE;
 
191
                    break;
 
192
                case 3:
 
193
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
194
                               "   TV attached (S-video/composite connectors)\n");
 
195
                    tv_attached = TRUE;
 
196
                    break;
 
197
                default:
 
198
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
199
                               "Unrecognized return code: 0x%04x\n", 
 
200
                               pVbe->pInt10->cx);
 
201
                }
 
202
 
 
203
            }
 
204
 
 
205
            /* Get active display  - LTPro, XL, Mobility */
 
206
            pVbe->pInt10->num = 0x10;
 
207
            pVbe->pInt10->ax = 0xa084;
 
208
            pVbe->pInt10->bx = 0x0000; /* bh=0x00 get active, bh=0x01 set active */
 
209
            xf86ExecX86int10(pVbe->pInt10);
 
210
 
 
211
            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
212
                       "Active displays: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
 
213
                       pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
 
214
 
 
215
            if (pVbe->pInt10->ax & 0xff00) {
 
216
                xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
217
                           "Failed to detect active display\n");
 
218
            } else {
 
219
                if (pVbe->pInt10->bx & 0x1) 
 
220
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,                 
 
221
                               "   DFP/LCD is active\n");
 
222
 
 
223
                if (pVbe->pInt10->bx & 0x2) 
 
224
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
225
                               "   CRT is active\n");
 
226
 
 
227
                if (pVbe->pInt10->bx & 0x4) {
 
228
                    
 
229
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
230
                               "   TV is active\n");
 
231
 
 
232
                    if (!tv_attached) {
 
233
                        /* tv not connected - disable tv */
 
234
                        disp_request = 0x00;
 
235
                        if (crt_attached)
 
236
                            disp_request |= 0x02; /* enable CRT */
 
237
                        if (lcd_attached && pATI->OptionPanelDisplay)
 
238
                            disp_request |= 0x01; /* enable DFP/LCD */
 
239
 
 
240
                        pVbe->pInt10->num = 0x10;
 
241
                        pVbe->pInt10->ax = 0xa084;
 
242
                        pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */
 
243
                        pVbe->pInt10->cx = disp_request; 
 
244
                        xf86ExecX86int10(pVbe->pInt10);
 
245
 
 
246
                        xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
247
                                   "TV not present, disabling: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
 
248
                                   pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
 
249
                        if (pVbe->pInt10->ax & 0xff00) {
 
250
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
251
                                       "Disabling TV failed\n");
 
252
                        }
 
253
                    } else {
 
254
                        pATI->tvActive = TRUE;
 
255
                    }
 
256
 
 
257
                } else if (tv_attached && (pVbe->pInt10->bx & 0x0400)) {
 
258
                    /* tv connected and available - enable TV */
 
259
                    disp_request = 0x04;          /* enable TV */
 
260
 
 
261
#if 0
 
262
                    /* This works, but CRT image is vertically compressed */
 
263
                    if (crt_attached)
 
264
                            disp_request |= 0x02; /* enable CRT */
 
265
                    /* NOTE: For me, LCD+TV does NOT work */
 
266
                    /*if (lcd_attached && pATI->OptionPanelDisplay)
 
267
                            disp_request |= 0x01; * enable DFP/LCD */
 
268
#endif
 
269
 
 
270
                    pVbe->pInt10->num = 0x10;
 
271
                    pVbe->pInt10->ax = 0xa084;
 
272
                    pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */
 
273
                    pVbe->pInt10->cx = disp_request; /* try to activate TV */
 
274
                    xf86ExecX86int10(pVbe->pInt10);
 
275
                    
 
276
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
277
                               "Setting TV active: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
 
278
                               pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
 
279
                    if (pVbe->pInt10->ax & 0xff00) {
 
280
                        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
281
                                   "Setting TV active failed\n");
 
282
                    } else {
 
283
                        pATI->tvActive = TRUE;
 
284
                    }
 
285
                }
 
286
            }
 
287
 
 
288
        } else { /* pATI->Chip < ATI_CHIP_264LTPRO */
 
289
            /* TVOut Hooks - Check for TVOut BIOS/hardware */
 
290
            pVbe->pInt10->num = 0x10;
 
291
            pVbe->pInt10->ax = 0xa019;
 
292
            pVbe->pInt10->cx = 0x0000; /* TVOut BIOS query */
 
293
            xf86ExecX86int10(pVbe->pInt10);
 
294
 
 
295
            tv_attached = FALSE;
 
296
 
 
297
            if (pVbe->pInt10->ax & 0xff00) {
 
298
                xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
299
                           "Failed to detect TV-Out BIOS\n");
 
300
            } else {
 
301
                switch (pVbe->pInt10->ax & 0x0003) {
 
302
                case 3:
 
303
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
304
                               "TV-Out BIOS detected and active\n");
 
305
 
 
306
                    /* TV attached query */
 
307
                    pVbe->pInt10->num = 0x10;
 
308
                    pVbe->pInt10->ax = 0xa070;
 
309
                    pVbe->pInt10->bx = 0x0002; /* Sub-function: return tv attached info */
 
310
                    xf86ExecX86int10(pVbe->pInt10);
 
311
 
 
312
                    if (pVbe->pInt10->ax & 0xff00) {
 
313
                        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
314
                                   "Failed to detect if TV is attached\n");
 
315
                    } else {
 
316
                        switch (pVbe->pInt10->cx & 0x0003) {
 
317
                        case 3:
 
318
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
319
                                       "TV attached to composite and S-video connectors\n");
 
320
                            tv_attached = TRUE;
 
321
                            break;
 
322
                        case 2:
 
323
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
324
                                       "TV attached to S-video connector\n");
 
325
                            tv_attached = TRUE;
 
326
                            break;
 
327
                        case 1:
 
328
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
329
                                       "TV attached to composite connector\n");
 
330
                            tv_attached = TRUE;
 
331
                            break;
 
332
                        default:
 
333
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
334
                                       "TV is not attached\n");
 
335
                        }
 
336
                    }
 
337
                    break;
 
338
                case 1:
 
339
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
340
                               "TV-Out BIOS service is not available due to" 
 
341
                               "a system BIOS error or TV-Out hardware not being installed\n");
 
342
                    break;
 
343
                default:
 
344
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
345
                               "No TV-Out BIOS or hardware detected\n");
 
346
                }
 
347
            }
 
348
        }
 
349
 
 
350
        /* Return TV-Out configuration 
 
351
         * see Programmer's Guide under "TV Out Specific Functions"
 
352
         * It's not clear exactly which adapters support these
 
353
         */
 
354
        pVbe->pInt10->num = 0x10;
 
355
        pVbe->pInt10->ax = 0xa070;
 
356
        pVbe->pInt10->bx = 0x00;
 
357
        xf86ExecX86int10(pVbe->pInt10);
 
358
 
 
359
        xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
360
                   "TV-Out query: ax=0x%04x, bx=0x%04x, cx=0x%04x, dx=0x%04x\n",
 
361
                   pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx, pVbe->pInt10->dx);
 
362
 
 
363
        if (pVbe->pInt10->ax & 0xff00) {
 
364
 
 
365
            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
366
                       "Failed to detect TV-Out configuration.\n");
 
367
 
 
368
        } else if (pVbe->pInt10->bx == 0) {
 
369
            if (pVbe->pInt10->dx == 0) {
 
370
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
371
                           "TV-Out is not detected.\n");
 
372
            } else {
 
373
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
374
                           "TV-Out is detected but not supported.\n");
 
375
            }
 
376
 
 
377
        } else if ((pVbe->pInt10->cx & 0xff) == 0) {
 
378
 
 
379
            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
380
                       "TV-Out is currently disabled.\n");
 
381
            if (tv_attached && pATI->Chip < ATI_CHIP_264LTPRO) {
 
382
                /* Try to enable TV-Out */
 
383
                pVbe->pInt10->num = 0x10;
 
384
                pVbe->pInt10->ax = 0xa070;
 
385
                pVbe->pInt10->bx = 0x0001; /* Sub-function: Select TV Out */
 
386
                /* cl=0x001 enable, cl=0x000 disable, 
 
387
                 * cl=0x080 disable with feature connector bit preserved 
 
388
                 */
 
389
                pVbe->pInt10->cx = 0x0001;
 
390
                        
 
391
                xf86ExecX86int10(pVbe->pInt10);
 
392
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
393
                           "Setting TV active: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
 
394
                           pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
 
395
 
 
396
                if (pVbe->pInt10->ax & 0xff00) {
 
397
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
398
                               "Setting TV active failed\n");
 
399
                } else {
 
400
                    pATI->tvActive = TRUE;
 
401
                }
 
402
            }
 
403
 
 
404
        } else {
 
405
            pATI->tvActive = TRUE;
 
406
 
 
407
            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
408
                       "TV-Out is currently enabled (TV-Out revision code: %d).\n",
 
409
                       (pVbe->pInt10->dx >> 8) & 0xff);
 
410
 
 
411
            switch ((pVbe->pInt10->cx >> 8) & 0xff) {
 
412
            case 0:
 
413
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 29.49892\n");
 
414
                break;
 
415
            case 1:
 
416
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 28.63636\n");
 
417
                break;
 
418
            case 2:
 
419
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 14.31818\n");
 
420
                break;
 
421
            case 3:
 
422
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Reference frequency 27.00000\n");
 
423
                break;
 
424
            default:
 
425
                xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
426
                           "Unknown reference frequency cx=0x%04x\n", pVbe->pInt10->cx);
 
427
                    
 
428
            }
 
429
 
 
430
            /* Return TV standard
 
431
             * see Programmer's Guide under "TV Out Specific Functions"
 
432
             * It's not clear exactly which adapters support these
 
433
             */
 
434
            pVbe->pInt10->num = 0x10;
 
435
            pVbe->pInt10->ax = 0xa071;
 
436
            pVbe->pInt10->bx = 0x00;
 
437
            xf86ExecX86int10(pVbe->pInt10);
 
438
 
 
439
            xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
440
                       "TV standard query result: ax=0x%04x, bx=0x%04x, cx=0x%04x\n",
 
441
                       pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx);
 
442
 
 
443
            if (pVbe->pInt10->ax & 0xff00) {
 
444
 
 
445
                xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
446
                           "Failed to return TV standard.\n");
 
447
            } else {
 
448
                tv_std = pVbe->pInt10->cx & 0x00ff;
 
449
                switch (tv_std) {
 
450
                case ATI_TV_STD_NTSC:
 
451
                case ATI_TV_STD_PAL:
 
452
                case ATI_TV_STD_PALM:
 
453
                case ATI_TV_STD_PAL60:
 
454
                case ATI_TV_STD_NTSCJ:
 
455
                case ATI_TV_STD_PALCN:
 
456
                case ATI_TV_STD_PALN:
 
457
                case ATI_TV_STD_SCARTPAL:
 
458
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, 
 
459
                               "Current TV standard: %s\n", ATITVStandardNames[tv_std]);
 
460
                    break;
 
461
                default:
 
462
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
463
                               "Unrecognized TV standard return code cx=0x%04x\n", 
 
464
                               pVbe->pInt10->cx);
 
465
                }
 
466
 
 
467
                tv_std_request = pATI->OptionTvStd;
 
468
                if (tv_std_request < 0 || 
 
469
                    tv_std_request > ATI_TV_STD_NONE || 
 
470
                    tv_std_request == ATI_TV_STD_RESERVED1 || 
 
471
                    tv_std_request == ATI_TV_STD_RESERVED2) {
 
472
                    xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
473
                               "Invalid TV standard requested, please check configuration file\n");
 
474
                } else if (tv_std_request != ATI_TV_STD_NONE) {
 
475
                    /* Set TV standard if requested (LT Pro not supported) */
 
476
                    if (pATI->Chip != ATI_CHIP_264LTPRO &&
 
477
                        tv_std_request != tv_std) {
 
478
                                
 
479
                        pVbe->pInt10->num = 0x10;
 
480
                        pVbe->pInt10->ax = 0xa070;
 
481
                        pVbe->pInt10->bx = 0x0003; /* sub-function: set TV standard */
 
482
                        pVbe->pInt10->cx = tv_std_request;
 
483
                        xf86ExecX86int10(pVbe->pInt10);
 
484
                        if (pVbe->pInt10->ax & 0xff00)
 
485
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
486
                                       "Failed to set TV standard\n");
 
487
                        else
 
488
                            xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG, 
 
489
                                       "Set TV standard to %s\n", ATITVStandardNames[tv_std_request]);
 
490
                    } else {
 
491
                        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, 
 
492
                                   "Setting TV standard not supported on ATI Rage LT Pro\n");
 
493
                    }
 
494
                }
 
495
            }
 
496
            
 
497
        }
 
498
    } else {
 
499
        xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "VBE module not loaded\n");
 
500
    }
 
501
}
 
502
 
 
503
#endif /* TV_OUT */
 
504
 
 
505
/*
 
506
 * ATIEnterGraphics --
 
507
 *
 
508
 * This function sets the hardware to a graphics video state.
 
509
 */
 
510
Bool
 
511
ATIEnterGraphics
 
512
(
 
513
    ScreenPtr   pScreen,
 
514
    ScrnInfoPtr pScreenInfo,
 
515
    ATIPtr      pATI
 
516
)
 
517
{
 
518
    /* Map apertures */
 
519
    if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI))
 
520
        return FALSE;
 
521
 
 
522
    /* Unlock device */
 
523
    ATIUnlock(pATI);
 
524
 
 
525
    /* Calculate hardware data */
 
526
    if (pScreen &&
 
527
        !ATIModeCalculate(pScreenInfo->scrnIndex, pATI, &pATI->NewHW,
 
528
            pScreenInfo->currentMode))
 
529
        return FALSE;
 
530
 
 
531
    pScreenInfo->vtSema = TRUE;
 
532
 
 
533
#ifdef TV_OUT
 
534
    if (pATI->OptionTvOut) {
 
535
 
 
536
        if (pATI->pVBE) {
 
537
            if (VBEGetVBEMode(pATI->pVBE, &pATI->vbemode)) {
 
538
                xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Saving VESA mode: 0x%x\n", 
 
539
                           pATI->vbemode);
 
540
            }
 
541
        }
 
542
    }
 
543
#endif /* TV_OUT */
 
544
 
 
545
    /* Save current state */
 
546
    ATIModeSave(pScreenInfo, pATI, &pATI->OldHW);
 
547
 
 
548
#ifdef TV_OUT
 
549
    if (pATI->OptionTvOut) 
 
550
        ATIProbeAndSetActiveDisplays(pScreenInfo, pATI);
 
551
#endif /* TV_OUT */
 
552
 
 
553
    /* Set graphics state */
 
554
    ATIModeSet(pScreenInfo, pATI, &pATI->NewHW);
 
555
 
 
556
    /* Possibly blank the screen */
 
557
    if (pScreen)
 
558
       (void)ATISaveScreen(pScreen, SCREEN_SAVER_ON);
 
559
 
 
560
    /* Position the screen */
 
561
    (*pScreenInfo->AdjustFrame)(ADJUST_FRAME_ARGS(pScreenInfo,
 
562
        pScreenInfo->frameX0, pScreenInfo->frameY0));
 
563
 
 
564
    SetTimeSinceLastInputEvent();
 
565
 
 
566
    return TRUE;
 
567
}
 
568
 
 
569
/*
 
570
 * ATILeaveGraphics --
 
571
 *
 
572
 * This function restores the hardware to its previous state.
 
573
 */
 
574
void
 
575
ATILeaveGraphics
 
576
(
 
577
    ScrnInfoPtr pScreenInfo,
 
578
    ATIPtr      pATI
 
579
)
 
580
{
 
581
    if (pScreenInfo->vtSema)
 
582
    {
 
583
        /* If not exiting, save graphics video state */
 
584
        if (!xf86ServerIsExiting())
 
585
            ATIModeSave(pScreenInfo, pATI, &pATI->NewHW);
 
586
 
 
587
#ifdef TV_OUT
 
588
        if (pATI->OptionTvOut) 
 
589
            ATIProbeAndSetActiveDisplays(pScreenInfo, pATI);
 
590
#endif /* TV_OUT */
 
591
 
 
592
        /* Restore mode in effect on server entry */
 
593
        ATIModeSet(pScreenInfo, pATI, &pATI->OldHW);
 
594
 
 
595
        pScreenInfo->vtSema = FALSE;
 
596
    }
 
597
 
 
598
    /* Lock device */
 
599
    ATILock(pATI);
 
600
 
 
601
    /* Unmap apertures */
 
602
 
 
603
#ifdef AVOID_DGA
 
604
 
 
605
    if (!pATI->Closeable)
 
606
 
 
607
#else /* AVOID_DGA */
 
608
 
 
609
    if (!pATI->Closeable || !pATI->nDGAMode)
 
610
 
 
611
#endif /* AVOID_DGA */
 
612
 
 
613
        ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
 
614
 
 
615
    SetTimeSinceLastInputEvent();
 
616
}
 
617
 
 
618
/*
 
619
 * ATISwitchMode --
 
620
 *
 
621
 * This function switches to another graphics video state.
 
622
 */
 
623
Bool
 
624
ATISwitchMode(SWITCH_MODE_ARGS_DECL)
 
625
{
 
626
    SCRN_INFO_PTR(arg);
 
627
    ATIPtr      pATI        = ATIPTR(pScreenInfo);
 
628
 
 
629
    /* Calculate new hardware data */
 
630
    if (!ATIModeCalculate(pScreenInfo->scrnIndex, pATI, &pATI->NewHW, pMode))
 
631
        return FALSE;
 
632
 
 
633
    /* Set new hardware state */
 
634
    if (pScreenInfo->vtSema)
 
635
    {
 
636
        pScreenInfo->currentMode = pMode;
 
637
 
 
638
#ifdef XF86DRI_DEVEL
 
639
 
 
640
        if (pATI->directRenderingEnabled) 
 
641
        {
 
642
            DRILock(pScreenInfo->pScreen,0);
 
643
            ATIDRIWaitForIdle(pATI);
 
644
        }
 
645
 
 
646
#endif /* XF86DRI_DEVEL */
 
647
 
 
648
        /* XXX Workaround for X server not hiding the cursor for Xcursor (but
 
649
         * only for core cursor), leaving a 64x64 garbage upper-left.
 
650
         */
 
651
        if (pATI->pCursorInfo)
 
652
            (*pATI->pCursorInfo->HideCursor)(pScreenInfo);
 
653
 
 
654
        ATIModeSet(pScreenInfo, pATI, &pATI->NewHW);
 
655
 
 
656
#ifdef XF86DRI_DEVEL
 
657
 
 
658
        if (pATI->directRenderingEnabled) 
 
659
        {
 
660
            DRIUnlock(pScreenInfo->pScreen);
 
661
        }
 
662
 
 
663
#endif /* XF86DRI_DEVEL */
 
664
 
 
665
    }
 
666
 
 
667
    SetTimeSinceLastInputEvent();
 
668
 
 
669
    return TRUE;
 
670
}
 
671
 
 
672
/*
 
673
 * ATIEnterVT --
 
674
 *
 
675
 * This function sets the server's virtual console to a graphics video state.
 
676
 */
 
677
Bool
 
678
ATIEnterVT(VT_FUNC_ARGS_DECL)
 
679
{
 
680
    SCRN_INFO_PTR(arg);
 
681
    ScreenPtr   pScreen     = pScreenInfo->pScreen;
 
682
    ATIPtr      pATI        = ATIPTR(pScreenInfo);
 
683
    PixmapPtr   pScreenPixmap;
 
684
#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0))
 
685
    DevUnion    PixmapPrivate;
 
686
#endif
 
687
    Bool        Entered;
 
688
 
 
689
    if (!ATIEnterGraphics(NULL, pScreenInfo, pATI))
 
690
        return FALSE;
 
691
 
 
692
    /* The rest of this isn't needed for shadowfb */
 
693
    if (pATI->OptionShadowFB)
 
694
    {
 
695
 
 
696
#ifdef XF86DRI_DEVEL
 
697
 
 
698
        if (pATI->directRenderingEnabled) 
 
699
        {
 
700
            /* get the Mach64 back into shape after resume */
 
701
            ATIDRIResume(pScreen);
 
702
            DRIUnlock(pScreen);
 
703
        }
 
704
 
 
705
#endif /* XF86DRI_DEVEL */
 
706
 
 
707
        return TRUE;
 
708
    }
 
709
 
 
710
    pScreenPixmap = (*pScreen->GetScreenPixmap)(pScreen);
 
711
 
 
712
#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0))
 
713
    PixmapPrivate = pScreenPixmap->devPrivate;
 
714
    if (!PixmapPrivate.ptr)
 
715
        pScreenPixmap->devPrivate = pScreenInfo->pixmapPrivate;
 
716
#endif
 
717
 
 
718
    /* Tell framebuffer about remapped aperture */
 
719
    Entered = (*pScreen->ModifyPixmapHeader)(pScreenPixmap,
 
720
        -1, -1, -1, -1, -1, pATI->pMemory);
 
721
 
 
722
#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0))
 
723
    if (!PixmapPrivate.ptr)
 
724
    {
 
725
        pScreenInfo->pixmapPrivate = pScreenPixmap->devPrivate;
 
726
        pScreenPixmap->devPrivate.ptr = NULL;
 
727
    }
 
728
#endif
 
729
 
 
730
#ifdef XF86DRI_DEVEL
 
731
 
 
732
    if (pATI->directRenderingEnabled) 
 
733
    {
 
734
        /* get the Mach64 back into shape after resume */
 
735
        ATIDRIResume(pScreen);
 
736
        DRIUnlock(pScreen);
 
737
    }
 
738
 
 
739
#endif /* XF86DRI_DEVEL */
 
740
 
 
741
    return Entered;
 
742
}
 
743
 
 
744
/*
 
745
 * ATILeaveVT --
 
746
 *
 
747
 * This function restores the server's virtual console to its state on server
 
748
 * entry.
 
749
 */
 
750
void
 
751
ATILeaveVT(VT_FUNC_ARGS_DECL)
 
752
{
 
753
    SCRN_INFO_PTR(arg);
 
754
    ScreenPtr   pScreen     = pScreenInfo->pScreen;
 
755
    ATIPtr      pATI        = ATIPTR(pScreenInfo);
 
756
 
 
757
#ifdef XF86DRI_DEVEL
 
758
 
 
759
    if (pATI->directRenderingEnabled) 
 
760
    {
 
761
        DRILock(pScreen,0);
 
762
        ATIDRIWaitForIdle(pATI);
 
763
    }
 
764
 
 
765
#endif /* XF86DRI_DEVEL */
 
766
 
 
767
    ATILeaveGraphics(pScreenInfo, ATIPTR(pScreenInfo));
 
768
}
 
769
 
 
770
/*
 
771
 * ATIFreeScreen --
 
772
 *
 
773
 * This function frees all driver data related to a screen.
 
774
 */
 
775
void
 
776
ATIFreeScreen(FREE_SCREEN_ARGS_DECL)
 
777
{
 
778
    SCRN_INFO_PTR(arg);
 
779
    ATIPtr      pATI        = ATIPTR(pScreenInfo);
 
780
 
 
781
    ATII2CFreeScreen(pScreenInfo->scrnIndex);
 
782
 
 
783
#ifndef AVOID_CPIO
 
784
 
 
785
    free(pATI->OldHW.frame_buffer);
 
786
    free(pATI->NewHW.frame_buffer);
 
787
 
 
788
#endif /* AVOID_CPIO */
 
789
 
 
790
    free(pATI->pShadow);
 
791
 
 
792
#ifndef AVOID_DGA
 
793
 
 
794
    free(pATI->pDGAMode);
 
795
 
 
796
#endif /* AVOID_DGA */
 
797
 
 
798
    free(pATI);
 
799
    pScreenInfo->driverPrivate = NULL;
 
800
}