1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
/*
* Integrated TV out support based on the GATOS code by
* Federico Ulivi <fulivi@lycos.com>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <stdio.h>
/* X and server generic header files */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "fbdevhw.h"
#include "vgaHW.h"
#include "xf86Modes.h"
/* Driver data structures */
#include "radeon.h"
#include "radeon_reg.h"
#include "radeon_macros.h"
#include "radeon_probe.h"
#include "radeon_version.h"
#include "radeon_tv.h"
/**********************************************************************
*
* ModeConstants
*
* Storage of constants related to a single video mode
*
**********************************************************************/
typedef struct
{
CARD16 horResolution;
CARD16 verResolution;
TVStd standard;
CARD16 horTotal;
CARD16 verTotal;
CARD16 horStart;
CARD16 horSyncStart;
CARD16 verSyncStart;
unsigned defRestart;
CARD16 crtcPLL_N;
CARD8 crtcPLL_M;
CARD8 crtcPLL_postDiv;
unsigned pixToTV;
} TVModeConstants;
static const CARD16 hor_timing_NTSC[] =
{
0x0007,
0x003f,
0x0263,
0x0a24,
0x2a6b,
0x0a36,
0x126d, /* H_TABLE_POS1 */
0x1bfe,
0x1a8f, /* H_TABLE_POS2 */
0x1ec7,
0x3863,
0x1bfe,
0x1bfe,
0x1a2a,
0x1e95,
0x0e31,
0x201b,
0
};
static const CARD16 vert_timing_NTSC[] =
{
0x2001,
0x200d,
0x1006,
0x0c06,
0x1006,
0x1818,
0x21e3,
0x1006,
0x0c06,
0x1006,
0x1817,
0x21d4,
0x0002,
0
};
static const CARD16 hor_timing_PAL[] =
{
0x0007,
0x0058,
0x027c,
0x0a31,
0x2a77,
0x0a95,
0x124f, /* H_TABLE_POS1 */
0x1bfe,
0x1b22, /* H_TABLE_POS2 */
0x1ef9,
0x387c,
0x1bfe,
0x1bfe,
0x1b31,
0x1eb5,
0x0e43,
0x201b,
0
};
static const CARD16 vert_timing_PAL[] =
{
0x2001,
0x200c,
0x1005,
0x0c05,
0x1005,
0x1401,
0x1821,
0x2240,
0x1005,
0x0c05,
0x1005,
0x1401,
0x1822,
0x2230,
0x0002,
0
};
/**********************************************************************
*
* availableModes
*
* Table of all allowed modes for tv output
*
**********************************************************************/
static const TVModeConstants availableTVModes[] =
{
{
800, /* horResolution */
600, /* verResolution */
TV_STD_NTSC, /* standard */
990, /* horTotal */
740, /* verTotal */
813, /* horStart */
824, /* horSyncStart */
632, /* verSyncStart */
625592, /* defRestart */
592, /* crtcPLL_N */
91, /* crtcPLL_M */
4, /* crtcPLL_postDiv */
1022, /* pixToTV */
},
{
800, /* horResolution */
600, /* verResolution */
TV_STD_PAL, /* standard */
1144, /* horTotal */
706, /* verTotal */
812, /* horStart */
824, /* horSyncStart */
669, /* verSyncStart */
696700, /* defRestart */
1382, /* crtcPLL_N */
231, /* crtcPLL_M */
4, /* crtcPLL_postDiv */
759, /* pixToTV */
}
};
#define N_AVAILABLE_MODES (sizeof(availableModes) / sizeof(availableModes[ 0 ]))
static long YCOEF_value[5] = { 2, 2, 0, 4, 0 };
static long YCOEF_EN_value[5] = { 1, 1, 0, 1, 0 };
static long SLOPE_value[5] = { 1, 2, 2, 4, 8 };
static long SLOPE_limit[5] = { 6, 5, 4, 3, 2 };
/* Compute F,V,H restarts from default restart position and hPos & vPos
* Return TRUE when code timing table was changed
*/
static Bool RADEONInitTVRestarts(xf86OutputPtr output, RADEONSavePtr save,
DisplayModePtr mode)
{
ScrnInfoPtr pScrn = output->scrn;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(pScrn);
int restart;
unsigned hTotal;
unsigned vTotal;
unsigned fTotal;
int vOffset;
int hOffset;
CARD16 p1;
CARD16 p2;
Bool hChanged;
CARD16 hInc;
const TVModeConstants *constPtr;
constPtr = &availableTVModes[radeon_output->tvStd];
hTotal = constPtr->horTotal;
vTotal = constPtr->verTotal;
if (radeon_output->tvStd == TV_STD_NTSC)
fTotal = NTSC_TV_VFTOTAL + 1;
else
fTotal = PAL_TV_VFTOTAL + 1;
/* Adjust positions 1&2 in hor. code timing table */
hOffset = radeon_output->hPos * H_POS_UNIT;
if (radeon_output->tvStd == TV_STD_NTSC) {
p1 = hor_timing_NTSC[ H_TABLE_POS1 ];
p2 = hor_timing_NTSC[ H_TABLE_POS2 ];
} else {
p1 = hor_timing_PAL[ H_TABLE_POS1 ];
p2 = hor_timing_PAL[ H_TABLE_POS2 ];
}
p1 = (CARD16)((int)p1 + hOffset);
p2 = (CARD16)((int)p2 - hOffset);
hChanged = (p1 != save->h_code_timing[ H_TABLE_POS1 ] ||
p2 != save->h_code_timing[ H_TABLE_POS2 ]);
save->h_code_timing[ H_TABLE_POS1 ] = p1;
save->h_code_timing[ H_TABLE_POS2 ] = p2;
/* Convert hOffset from n. of TV clock periods to n. of CRTC clock periods (CRTC pixels) */
hOffset = (hOffset * (int)(constPtr->pixToTV)) / 1000;
/* Adjust restart */
restart = constPtr->defRestart;
/*
* Convert vPos TV lines to n. of CRTC pixels
* Be verrrrry careful when mixing signed & unsigned values in C..
*/
if (radeon_output->tvStd == TV_STD_NTSC)
vOffset = ((int)(vTotal * hTotal) * 2 * radeon_output->vPos) / (int)(NTSC_TV_LINES_PER_FRAME);
else
vOffset = ((int)(vTotal * hTotal) * 2 * radeon_output->vPos) / (int)(PAL_TV_LINES_PER_FRAME);
restart -= vOffset + hOffset;
ErrorF("computeRestarts: def = %u, h = %d, v = %d, p1=%04x, p2=%04x, restart = %d\n",
constPtr->defRestart , radeon_output->hPos , radeon_output->vPos , p1 , p2 , restart);
save->tv_hrestart = restart % hTotal;
restart /= hTotal;
save->tv_vrestart = restart % vTotal;
restart /= vTotal;
save->tv_frestart = restart % fTotal;
ErrorF("computeRestarts: F/H/V=%u,%u,%u\n",
save->tv_frestart , save->tv_vrestart , save->tv_hrestart);
/* Compute H_INC from hSize */
if (radeon_output->tvStd == TV_STD_NTSC)
hInc = (CARD16)((int)(constPtr->horResolution * 4096 * NTSC_TV_CLOCK_T) /
(radeon_output->hSize * (int)(NTSC_TV_H_SIZE_UNIT) + (int)(NTSC_TV_ZERO_H_SIZE)));
else
hInc = (CARD16)((int)(constPtr->horResolution * 4096 * PAL_TV_CLOCK_T) /
(radeon_output->hSize * (int)(PAL_TV_H_SIZE_UNIT) + (int)(PAL_TV_ZERO_H_SIZE)));
save->tv_timing_cntl = (save->tv_timing_cntl & ~RADEON_H_INC_MASK) |
((CARD32)hInc << RADEON_H_INC_SHIFT);
ErrorF("computeRestarts: hSize=%d,hInc=%u\n" , radeon_output->hSize , hInc);
return hChanged;
}
/* intit TV-out regs */
void RADEONInitTVRegisters(xf86OutputPtr output, RADEONSavePtr save,
DisplayModePtr mode, BOOL IsPrimary)
{
ScrnInfoPtr pScrn = output->scrn;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned i;
unsigned long vert_space, flicker_removal;
CARD32 tmp;
const TVModeConstants *constPtr;
const CARD16 *hor_timing;
const CARD16 *vert_timing;
constPtr = &availableTVModes[radeon_output->tvStd];
save->tv_crc_cntl = 0;
save->tv_gain_limit_settings = (0x17f << RADEON_UV_GAIN_LIMIT_SHIFT) |
(0x5ff << RADEON_Y_GAIN_LIMIT_SHIFT);
save->tv_hdisp = constPtr->horResolution - 1;
save->tv_hstart = constPtr->horStart;
save->tv_htotal = constPtr->horTotal - 1;
save->tv_linear_gain_settings = (0x100 << RADEON_UV_GAIN_SHIFT) |
(0x100 << RADEON_Y_GAIN_SHIFT);
save->tv_master_cntl = (RADEON_RESTART_PHASE_FIX
| RADEON_VIN_ASYNC_RST
| RADEON_AUD_ASYNC_RST
| RADEON_DVS_ASYNC_RST
| RADEON_CRT_FIFO_CE_EN
| RADEON_TV_FIFO_CE_EN
| RADEON_TV_ON);
save->tv_modulator_cntl1 = RADEON_SLEW_RATE_LIMIT
| RADEON_SYNC_TIP_LEVEL
| RADEON_YFLT_EN
| RADEON_UVFLT_EN
| (0x3b << RADEON_BLANK_LEVEL_SHIFT)
| (0x6 << RADEON_CY_FILT_BLEND_SHIFT);
if (radeon_output->tvStd == TV_STD_NTSC)
save->tv_modulator_cntl1 |= (0x46 << RADEON_SET_UP_LEVEL_SHIFT);
else
save->tv_modulator_cntl1 |= RADEON_ALT_PHASE_EN
| (0x3b << RADEON_SET_UP_LEVEL_SHIFT);
if (radeon_output->tvStd == TV_STD_NTSC)
save->tv_modulator_cntl2 = 0x00000191;
else
save->tv_modulator_cntl2 = 0x003e01b2;
save->pll_test_cntl = 0;
save->tv_pre_dac_mux_cntl = (RADEON_Y_RED_EN
| RADEON_C_GRN_EN
| RADEON_CMP_BLU_EN
| RADEON_DAC_DITHER_EN);
save->tv_rgb_cntl = (RADEON_RGB_DITHER_EN | RADEON_TVOUT_SCALE_EN
| (0x0b << 16) | (0x07 << 20));
if (IsPrimary) {
if (radeon_output->Flags & RADEON_USE_RMX)
save->tv_rgb_cntl |= RADEON_RGB_SRC_SEL_RMX;
else
save->tv_rgb_cntl |= RADEON_RGB_SRC_SEL_CRTC1;
} else {
save->tv_rgb_cntl |= RADEON_RGB_SRC_SEL_CRTC2;
}
save->tv_sync_cntl = RADEON_SYNC_PUB | RADEON_TV_SYNC_IO_DRIVE;
save->tv_sync_size = constPtr->horResolution + 8;
if (radeon_output->tvStd == TV_STD_NTSC)
vert_space = constPtr->verTotal * 2 * 10000 / NTSC_TV_LINES_PER_FRAME;
else
vert_space = constPtr->verTotal * 2 * 10000 / PAL_TV_LINES_PER_FRAME;
save->tv_vscaler_cntl1 = RADEON_Y_W_EN;
save->tv_vscaler_cntl1 =
(save->tv_vscaler_cntl1 & 0xe3ff0000) | (vert_space * (1 << FRAC_BITS) / 10000);
save->tv_vscaler_cntl1 |= RADEON_RESTART_FIELD;
if (constPtr->horResolution == 1024)
save->tv_vscaler_cntl1 |= (4 << RADEON_Y_DEL_W_SIG_SHIFT);
else
save->tv_vscaler_cntl1 |= (2 << RADEON_Y_DEL_W_SIG_SHIFT);
if (radeon_output->tvStd == TV_STD_NTSC)
flicker_removal =
(float) constPtr->verTotal * 2.0 / NTSC_TV_LINES_PER_FRAME + 0.5;
else
flicker_removal =
(float) constPtr->verTotal * 2.0 / PAL_TV_LINES_PER_FRAME + 0.5;
if (flicker_removal < 3)
flicker_removal = 3;
for (i = 0; i < 6; ++i) {
if (flicker_removal == SLOPE_limit[i])
break;
}
save->tv_y_saw_tooth_cntl =
(vert_space * SLOPE_value[i] * (1 << (FRAC_BITS - 1)) + 5001) / 10000 / 8
| ((SLOPE_value[i] * (1 << (FRAC_BITS - 1)) / 8) << 16);
save->tv_y_fall_cntl =
(YCOEF_EN_value[i] << 17) | ((YCOEF_value[i] * (1 << 8) / 8) << 24) |
RADEON_Y_FALL_PING_PONG | (272 * SLOPE_value[i] / 8) * (1 << (FRAC_BITS - 1)) /
1024;
save->tv_y_rise_cntl =
RADEON_Y_RISE_PING_PONG
| (flicker_removal * 1024 - 272) * SLOPE_value[i] / 8 * (1 << (FRAC_BITS - 1)) / 1024;
save->tv_vscaler_cntl2 = ((save->tv_vscaler_cntl2 & 0x00fffff0)
| (0x10 << 24)
| RADEON_DITHER_MODE
| RADEON_Y_OUTPUT_DITHER_EN
| RADEON_UV_OUTPUT_DITHER_EN
| RADEON_UV_TO_BUF_DITHER_EN);
tmp = (save->tv_vscaler_cntl1 >> RADEON_UV_INC_SHIFT) & RADEON_UV_INC_MASK;
tmp = ((16384 * 256 * 10) / tmp + 5) / 10;
tmp = (tmp << RADEON_UV_OUTPUT_POST_SCALE_SHIFT) | 0x000b0000;
save->tv_timing_cntl = tmp;
/* XXX: taken care of in enabledisplay() */
save->tv_dac_cntl = /*RADEON_TV_DAC_NBLANK | RADEON_TV_DAC_NHOLD
|*/ (8 << 16) | (6 << 20);
if (radeon_output->tvStd == TV_STD_NTSC)
save->tv_dac_cntl |= RADEON_TV_DAC_STD_NTSC;
else
save->tv_dac_cntl |= RADEON_TV_DAC_STD_PAL;
#if 1
/* XXX: taken care of in enabledisplay() */
save->tv_dac_cntl |= (RADEON_TV_DAC_RDACPD | RADEON_TV_DAC_GDACPD
| RADEON_TV_DAC_BDACPD);
if (radeon_output->MonType == MT_CTV) {
save->tv_dac_cntl &= ~RADEON_TV_DAC_BDACPD;
}
if (radeon_output->MonType == MT_STV) {
save->tv_dac_cntl &= ~(RADEON_TV_DAC_RDACPD |
RADEON_TV_DAC_GDACPD);
}
#endif
if (radeon_output->tvStd == TV_STD_NTSC)
save->tv_pll_cntl = (NTSC_TV_PLL_M & RADEON_TV_M0LO_MASK) |
(((NTSC_TV_PLL_M >> 8) & RADEON_TV_M0HI_MASK) << RADEON_TV_M0HI_SHIFT) |
((NTSC_TV_PLL_N & RADEON_TV_N0LO_MASK) << RADEON_TV_N0LO_SHIFT) |
(((NTSC_TV_PLL_N >> 8) & RADEON_TV_N0HI_MASK) << RADEON_TV_N0HI_SHIFT) |
((NTSC_TV_PLL_P & RADEON_TV_P_MASK) << RADEON_TV_P_SHIFT);
else
save->tv_pll_cntl = (PAL_TV_PLL_M & RADEON_TV_M0LO_MASK) |
(((PAL_TV_PLL_M >> 8) & RADEON_TV_M0HI_MASK) << RADEON_TV_M0HI_SHIFT) |
((PAL_TV_PLL_N & RADEON_TV_N0LO_MASK) << RADEON_TV_N0LO_SHIFT) |
(((PAL_TV_PLL_N >> 8) & RADEON_TV_N0HI_MASK) << RADEON_TV_N0HI_SHIFT) |
((PAL_TV_PLL_P & RADEON_TV_P_MASK) << RADEON_TV_P_SHIFT);
save->tv_upsamp_and_gain_cntl = RADEON_YUPSAMP_EN | RADEON_UVUPSAMP_EN;
save->tv_uv_adr = 0xc8;
save->tv_vdisp = constPtr->verResolution - 1;
if (radeon_output->tvStd == TV_STD_NTSC)
save->tv_ftotal = NTSC_TV_VFTOTAL;
else
save->tv_ftotal = PAL_TV_VFTOTAL;
save->tv_vtotal = constPtr->verTotal - 1;
if (radeon_output->tvStd == TV_STD_NTSC) {
hor_timing = hor_timing_NTSC;
vert_timing = vert_timing_NTSC;
} else {
hor_timing = hor_timing_PAL;
vert_timing = vert_timing_PAL;
}
for (i = 0; i < MAX_H_CODE_TIMING_LEN; i++) {
if ((save->h_code_timing[ i ] = hor_timing[ i ]) == 0)
break;
}
for (i = 0; i < MAX_V_CODE_TIMING_LEN; i++) {
if ((save->v_code_timing[ i ] = vert_timing[ i ]) == 0)
break;
}
/*
* This must be called AFTER loading timing tables as they are modified by this function
*/
RADEONInitTVRestarts(output, save, mode);
save->dac_cntl &= ~RADEON_DAC_TVO_EN;
if (IS_R300_VARIANT)
save->gpiopad_a = info->SavedReg.gpiopad_a & ~1;
if (IsPrimary) {
save->disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
save->disp_output_cntl |= (RADEON_DISP_TVDAC_SOURCE_CRTC
| RADEON_DISP_TV_SOURCE_CRTC);
if (info->ChipFamily >= CHIP_FAMILY_R200) {
save->disp_tv_out_cntl &= ~RADEON_DISP_TV_PATH_SRC_CRTC2;
} else {
save->disp_hw_debug |= RADEON_CRT2_DISP1_SEL;
}
} else {
save->disp_output_cntl &= ~RADEON_DISP_DAC_SOURCE_MASK;
save->disp_output_cntl |= RADEON_DISP_TV_SOURCE_CRTC;
if (info->ChipFamily >= CHIP_FAMILY_R200) {
save->disp_tv_out_cntl |= RADEON_DISP_TV_PATH_SRC_CRTC2;
} else {
save->disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
}
}
}
/* Set hw registers for a new h/v position & h size */
static void RADEONUpdateHVPosition(xf86OutputPtr output, DisplayModePtr mode)
{
ScrnInfoPtr pScrn = output->scrn;
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
Bool reloadTable;
RADEONSavePtr restore = &info->ModeReg;
reloadTable = RADEONInitTVRestarts(output, restore, mode);
RADEONRestoreTVRestarts(pScrn, restore);
OUTREG(RADEON_TV_TIMING_CNTL, restore->tv_timing_cntl);
if (reloadTable) {
OUTREG(RADEON_TV_MASTER_CNTL, restore->tv_master_cntl
| RADEON_TV_ASYNC_RST
| RADEON_CRT_ASYNC_RST
| RADEON_RESTART_PHASE_FIX);
RADEONRestoreTVTimingTables(pScrn, restore);
OUTREG(RADEON_TV_MASTER_CNTL, restore->tv_master_cntl);
}
}
void RADEONAdjustCrtcRegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save,
DisplayModePtr mode, xf86OutputPtr output)
{
const TVModeConstants *constPtr;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
constPtr = &availableTVModes[radeon_output->tvStd];
save->crtc_h_total_disp = (((constPtr->horResolution / 8) - 1) << RADEON_CRTC_H_DISP_SHIFT) |
(((constPtr->horTotal / 8) - 1) << RADEON_CRTC_H_TOTAL_SHIFT);
save->crtc_h_sync_strt_wid = (save->crtc_h_sync_strt_wid
& ~(RADEON_CRTC_H_SYNC_STRT_PIX | RADEON_CRTC_H_SYNC_STRT_CHAR)) |
(((constPtr->horSyncStart / 8) - 1) << RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT) |
(constPtr->horSyncStart & 7);
save->crtc_v_total_disp = ((constPtr->verResolution - 1) << RADEON_CRTC_V_DISP_SHIFT) |
((constPtr->verTotal - 1) << RADEON_CRTC_V_TOTAL_SHIFT);
save->crtc_v_sync_strt_wid = (save->crtc_v_sync_strt_wid & ~RADEON_CRTC_V_SYNC_STRT) |
((constPtr->verSyncStart - 1) << RADEON_CRTC_V_SYNC_STRT_SHIFT);
save->disp_merge_cntl |= RADEON_DISP_RGB_OFFSET_EN;
}
void RADEONAdjustPLLRegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save,
DisplayModePtr mode, xf86OutputPtr output)
{
unsigned postDiv;
const TVModeConstants *constPtr;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
constPtr = &availableTVModes[radeon_output->tvStd];
save->htotal_cntl = (constPtr->horTotal & 0x7 /*0xf*/) | RADEON_HTOT_CNTL_VGA_EN;
save->ppll_ref_div = constPtr->crtcPLL_M;
switch (constPtr->crtcPLL_postDiv) {
case 1:
postDiv = 0;
break;
case 2:
postDiv = 1;
break;
case 3:
postDiv = 4;
break;
case 4:
postDiv = 2;
break;
case 6:
postDiv = 6;
break;
case 8:
postDiv = 3;
break;
case 12:
postDiv = 7;
break;
case 16:
default:
postDiv = 5;
break;
}
save->ppll_div_3 = (constPtr->crtcPLL_N & 0x7ff) | (postDiv << 16);
save->pixclks_cntl &= ~(RADEON_PIX2CLK_SRC_SEL_MASK | RADEON_PIXCLK_TV_SRC_SEL);
save->pixclks_cntl |= RADEON_PIX2CLK_SRC_SEL_P2PLLCLK;
}
void RADEONAdjustCrtc2RegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save,
DisplayModePtr mode, xf86OutputPtr output)
{
const TVModeConstants *constPtr;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
constPtr = &availableTVModes[radeon_output->tvStd];
save->crtc2_h_total_disp = (((constPtr->horResolution / 8) - 1) << RADEON_CRTC_H_DISP_SHIFT) |
(((constPtr->horTotal / 8) - 1) << RADEON_CRTC_H_TOTAL_SHIFT);
save->crtc2_h_sync_strt_wid = (save->crtc2_h_sync_strt_wid
& ~(RADEON_CRTC_H_SYNC_STRT_PIX | RADEON_CRTC_H_SYNC_STRT_CHAR)) |
(((constPtr->horSyncStart / 8) - 1) << RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT) |
(constPtr->horSyncStart & 7);
save->crtc2_v_total_disp = ((constPtr->verResolution - 1) << RADEON_CRTC_V_DISP_SHIFT) |
((constPtr->verTotal - 1) << RADEON_CRTC_V_TOTAL_SHIFT);
save->crtc_v_sync_strt_wid = (save->crtc_v_sync_strt_wid & ~RADEON_CRTC_V_SYNC_STRT) |
((constPtr->verSyncStart - 1) << RADEON_CRTC_V_SYNC_STRT_SHIFT);
save->disp2_merge_cntl |= RADEON_DISP2_RGB_OFFSET_EN;
}
void RADEONAdjustPLL2RegistersForTV(ScrnInfoPtr pScrn, RADEONSavePtr save,
DisplayModePtr mode, xf86OutputPtr output)
{
unsigned postDiv;
const TVModeConstants *constPtr;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
constPtr = &availableTVModes[radeon_output->tvStd];
save->htotal_cntl2 = (constPtr->horTotal & 0x7); /* 0xf */
save->p2pll_ref_div = constPtr->crtcPLL_M;
switch (constPtr->crtcPLL_postDiv) {
case 1:
postDiv = 0;
break;
case 2:
postDiv = 1;
break;
case 3:
postDiv = 4;
break;
case 4:
postDiv = 2;
break;
case 6:
postDiv = 6;
break;
case 8:
postDiv = 3;
break;
case 12:
postDiv = 7;
break;
case 16:
default:
postDiv = 5;
break;
}
save->p2pll_div_0 = (constPtr->crtcPLL_N & 0x7ff) | (postDiv << 16);
save->pixclks_cntl &= ~RADEON_PIX2CLK_SRC_SEL_MASK;
save->pixclks_cntl |= (RADEON_PIX2CLK_SRC_SEL_P2PLLCLK
| RADEON_PIXCLK_TV_SRC_SEL);
}
|