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
|
/*
* Copyright © 2007 Red Hat, Inc.
* Copyright 2007 Advanced Micro Devices, Inc.
*
* 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 (including the next
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
*
* Authors:
* Dave Airlie <airlied@redhat.com>
* Alex Deucher <alexdeucher@gmail.com>
*
*/
/*
* avivo output handling functions.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* DPMS */
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
#include <unistd.h>
#include "radeon.h"
#include "radeon_reg.h"
#include "radeon_macros.h"
#include "radeon_atombios.h"
static int
atombios_output_dac1_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
DAC_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = 1;
if (radeon_output->MonType == MT_CRT)
disp_data.ucDacStandard = ATOM_DAC1_PS2;
else if (radeon_output->MonType == MT_CV)
disp_data.ucDacStandard = ATOM_DAC1_CV;
else if (OUTPUT_IS_TV) {
switch (radeon_output->tvStd) {
case TV_STD_NTSC:
case TV_STD_NTSC_J:
case TV_STD_PAL_60:
disp_data.ucDacStandard = ATOM_DAC1_NTSC;
break;
case TV_STD_PAL:
case TV_STD_PAL_M:
case TV_STD_SCART_PAL:
case TV_STD_SECAM:
case TV_STD_PAL_CN:
disp_data.ucDacStandard = ATOM_DAC1_PAL;
break;
default:
disp_data.ucDacStandard = ATOM_DAC1_NTSC;
break;
}
}
disp_data.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, DAC1EncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output DAC1 setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output DAC1 setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_dac2_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
DAC_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = 1;
if (radeon_output->MonType == MT_CRT)
disp_data.ucDacStandard = ATOM_DAC2_PS2;
else if (radeon_output->MonType == MT_CV)
disp_data.ucDacStandard = ATOM_DAC2_CV;
else if (OUTPUT_IS_TV) {
switch (radeon_output->tvStd) {
case TV_STD_NTSC:
case TV_STD_NTSC_J:
case TV_STD_PAL_60:
disp_data.ucDacStandard = ATOM_DAC2_NTSC;
break;
case TV_STD_PAL:
case TV_STD_PAL_M:
case TV_STD_SCART_PAL:
case TV_STD_SECAM:
case TV_STD_PAL_CN:
disp_data.ucDacStandard = ATOM_DAC2_PAL;
break;
default:
disp_data.ucDacStandard = ATOM_DAC2_NTSC;
break;
}
}
disp_data.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, DAC2EncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output DAC2 setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output DAC2 setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_tv1_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
TV_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.sTVEncoder.ucAction = 1;
if (radeon_output->MonType == MT_CV)
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_CV;
else {
switch (radeon_output->tvStd) {
case TV_STD_NTSC:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_NTSC;
break;
case TV_STD_PAL:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_PAL;
break;
case TV_STD_PAL_M:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_PALM;
break;
case TV_STD_PAL_60:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_PAL60;
break;
case TV_STD_NTSC_J:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_NTSCJ;
break;
case TV_STD_SCART_PAL:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_PAL; /* ??? */
break;
case TV_STD_SECAM:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_SECAM;
break;
case TV_STD_PAL_CN:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_PALCN;
break;
default:
disp_data.sTVEncoder.ucTvStandard = ATOM_TV_NTSC;
break;
}
}
disp_data.sTVEncoder.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, TVEncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output TV1 setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output TV1 setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
int
atombios_external_tmds_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONInfoPtr info = RADEONPTR(output->scrn);
ENABLE_EXTERNAL_TMDS_ENCODER_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.sXTmdsEncoder.ucEnable = 1;
if (mode->Clock > 165000)
disp_data.sXTmdsEncoder.ucMisc = 1;
else
disp_data.sXTmdsEncoder.ucMisc = 0;
if (!info->dac6bits)
disp_data.sXTmdsEncoder.ucMisc |= (1 << 1);
data.exec.index = GetIndexIntoMasterTable(COMMAND, DVOEncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("External TMDS setup success\n");
return ATOM_SUCCESS;
}
ErrorF("External TMDS setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_tmds1_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONInfoPtr info = RADEONPTR(output->scrn);
TMDS1_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = 1;
if (mode->Clock > 165000)
disp_data.ucMisc = 1;
else
disp_data.ucMisc = 0;
disp_data.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, TMDS1EncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output TMDS1 setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output TMDS1 setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_tmds2_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONInfoPtr info = RADEONPTR(output->scrn);
TMDS2_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = 1;
if (mode->Clock > 165000)
disp_data.ucMisc = 1;
else
disp_data.ucMisc = 0;
disp_data.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, TMDS2EncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output TMDS2 setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output TMDS2 setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_lvds_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONInfoPtr info = RADEONPTR(output->scrn);
LVDS_ENCODER_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = 1;
if (mode->Clock > 165000)
disp_data.ucMisc = 1;
else
disp_data.ucMisc = 0;
disp_data.usPixelClock = mode->Clock / 10;
data.exec.index = GetIndexIntoMasterTable(COMMAND, LVDSEncoderControl);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output LVDS setup success\n");
return ATOM_SUCCESS;
}
ErrorF("Output LVDS setup failed\n");
return ATOM_NOT_IMPLEMENTED;
}
static int
atombios_output_scaler_setup(xf86OutputPtr output, DisplayModePtr mode)
{
RADEONInfoPtr info = RADEONPTR(output->scrn);
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONCrtcPrivatePtr radeon_crtc = output->crtc->driver_private;
ENABLE_SCALER_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucScaler = radeon_crtc->crtc_id;
if (radeon_output->Flags & RADEON_USE_RMX) {
ErrorF("Using RMX\n");
if (radeon_output->rmx_type == RMX_FULL)
disp_data.ucEnable = ATOM_SCALER_EXPANSION;
else if (radeon_output->rmx_type == RMX_CENTER)
disp_data.ucEnable = ATOM_SCALER_CENTER;
} else {
ErrorF("Not using RMX\n");
disp_data.ucEnable = ATOM_SCALER_DISABLE;
}
data.exec.index = GetIndexIntoMasterTable(COMMAND, EnableScaler);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("scaler %d setup success\n", radeon_crtc->crtc_id);
return ATOM_SUCCESS;
}
ErrorF("scaler %d setup failed\n", radeon_crtc->crtc_id);
return ATOM_NOT_IMPLEMENTED;
}
static AtomBiosResult
atombios_display_device_control(atomBiosHandlePtr atomBIOS, int device, Bool state)
{
DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION disp_data;
AtomBiosArgRec data;
unsigned char *space;
disp_data.ucAction = state;
data.exec.index = device;
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &disp_data;
if (RHDAtomBiosFunc(atomBIOS->scrnIndex, atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Output %d %s success\n", device, state? "enable":"disable");
return ATOM_SUCCESS;
}
ErrorF("Output %d %s failed\n", device, state? "enable":"disable");
return ATOM_NOT_IMPLEMENTED;
}
static void
atombios_device_dpms(xf86OutputPtr output, int device, int mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
int index = 0;
switch (device) {
case ATOM_DEVICE_CRT1_SUPPORT:
case ATOM_DEVICE_CRT2_SUPPORT:
if (radeon_output->DACType == DAC_PRIMARY)
index = GetIndexIntoMasterTable(COMMAND, DAC1OutputControl);
else if (radeon_output->DACType == DAC_TVDAC)
index = GetIndexIntoMasterTable(COMMAND, DAC2OutputControl);
break;
case ATOM_DEVICE_DFP1_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, TMDSAOutputControl);
break;
case ATOM_DEVICE_DFP2_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, DVOOutputControl);
break;
case ATOM_DEVICE_DFP3_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, LVTMAOutputControl);
break;
case ATOM_DEVICE_LCD1_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, LCD1OutputControl);
break;
case ATOM_DEVICE_TV1_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, TV1OutputControl);
break;
case ATOM_DEVICE_CV_SUPPORT:
index = GetIndexIntoMasterTable(COMMAND, CV1OutputControl);
break;
default:
return;
}
switch (mode) {
case DPMSModeOn:
atombios_display_device_control(info->atomBIOS, index, ATOM_ENABLE);
break;
case DPMSModeStandby:
case DPMSModeSuspend:
case DPMSModeOff:
atombios_display_device_control(info->atomBIOS, index, ATOM_DISABLE);
break;
}
}
void
atombios_output_dpms(xf86OutputPtr output, int mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
ErrorF("AGD: output dpms %d\n", mode);
if (radeon_output->MonType == MT_LCD) {
if (radeon_output->devices & ATOM_DEVICE_LCD1_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_LCD1_SUPPORT, mode);
} else if (radeon_output->MonType == MT_DFP) {
ErrorF("AGD: tmds dpms\n");
if (radeon_output->devices & ATOM_DEVICE_DFP1_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_DFP1_SUPPORT, mode);
else if (radeon_output->devices & ATOM_DEVICE_DFP2_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_DFP2_SUPPORT, mode);
else if (radeon_output->devices & ATOM_DEVICE_DFP3_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_DFP3_SUPPORT, mode);
} else if (radeon_output->MonType == MT_CRT) {
ErrorF("AGD: dac dpms\n");
if (radeon_output->devices & ATOM_DEVICE_CRT1_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_CRT1_SUPPORT, mode);
else if (radeon_output->devices & ATOM_DEVICE_CRT2_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_CRT2_SUPPORT, mode);
} else if (radeon_output->MonType == MT_CV) {
ErrorF("AGD: cv dpms\n");
if (radeon_output->devices & ATOM_DEVICE_CV_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_CV_SUPPORT, mode);
} else if (0 /*OUTPUT_IS_TV*/) {
ErrorF("AGD: tv dpms\n");
if (radeon_output->devices & ATOM_DEVICE_TV1_SUPPORT)
atombios_device_dpms(output, ATOM_DEVICE_TV1_SUPPORT, mode);
}
}
static void
atombios_set_output_crtc_source(xf86OutputPtr output)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONCrtcPrivatePtr radeon_crtc = output->crtc->driver_private;
RADEONInfoPtr info = RADEONPTR(output->scrn);
AtomBiosArgRec data;
unsigned char *space;
SELECT_CRTC_SOURCE_PS_ALLOCATION crtc_src_param;
int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source);
int major, minor;
atombios_get_command_table_version(info->atomBIOS, index, &major, &minor);
ErrorF("select crtc source table is %d %d\n", major, minor);
crtc_src_param.ucCRTC = radeon_crtc->crtc_id;
crtc_src_param.ucDevice = 0;
switch(major) {
case 1: {
switch(minor) {
case 0:
case 1:
default:
if (radeon_output->MonType == MT_CRT) {
if (radeon_output->devices & ATOM_DEVICE_CRT1_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_CRT1_INDEX;
else if (radeon_output->devices & ATOM_DEVICE_CRT2_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_CRT2_INDEX;
} else if (radeon_output->MonType == MT_DFP) {
if (radeon_output->devices & ATOM_DEVICE_DFP1_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_DFP1_INDEX;
else if (radeon_output->devices & ATOM_DEVICE_DFP2_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_DFP2_INDEX;
else if (radeon_output->devices & ATOM_DEVICE_DFP3_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_DFP3_INDEX;
} else if (radeon_output->MonType == MT_LCD) {
if (radeon_output->devices & ATOM_DEVICE_LCD1_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_LCD1_INDEX;
} else if (OUTPUT_IS_TV) {
if (radeon_output->devices & ATOM_DEVICE_TV1_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_TV1_INDEX;
} else if (radeon_output->MonType == MT_CV) {
if (radeon_output->devices & ATOM_DEVICE_CV_SUPPORT)
crtc_src_param.ucDevice = ATOM_DEVICE_CV_INDEX;
}
break;
}
break;
}
default:
break;
}
ErrorF("device sourced: 0x%x\n", crtc_src_param.ucDevice);
data.exec.index = index;
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &crtc_src_param;
if (RHDAtomBiosFunc(info->atomBIOS->scrnIndex, info->atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Set CRTC %d Source success\n", radeon_crtc->crtc_id);
return;
}
ErrorF("Set CRTC Source failed\n");
return;
}
void
atombios_output_mode_set(xf86OutputPtr output,
DisplayModePtr mode,
DisplayModePtr adjusted_mode)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
atombios_output_scaler_setup(output, mode);
atombios_set_output_crtc_source(output);
if (radeon_output->MonType == MT_CRT) {
if (radeon_output->devices & ATOM_DEVICE_CRT1_SUPPORT ||
radeon_output->devices & ATOM_DEVICE_CRT2_SUPPORT) {
if (radeon_output->DACType == DAC_PRIMARY)
atombios_output_dac1_setup(output, adjusted_mode);
else if (radeon_output->DACType == DAC_TVDAC)
atombios_output_dac2_setup(output, adjusted_mode);
}
} else if (radeon_output->MonType == MT_DFP) {
if (radeon_output->devices & ATOM_DEVICE_DFP1_SUPPORT)
atombios_output_tmds1_setup(output, adjusted_mode);
else if (radeon_output->devices & ATOM_DEVICE_DFP2_SUPPORT)
atombios_external_tmds_setup(output, adjusted_mode);
else if (radeon_output->devices & ATOM_DEVICE_DFP3_SUPPORT)
atombios_output_tmds2_setup(output, adjusted_mode);
} else if (radeon_output->MonType == MT_LCD) {
if (radeon_output->devices & ATOM_DEVICE_LCD1_SUPPORT)
atombios_output_lvds_setup(output, adjusted_mode);
} else if (OUTPUT_IS_TV || (radeon_output->MonType == MT_CV)) {
if (radeon_output->DACType == DAC_PRIMARY)
atombios_output_dac1_setup(output, adjusted_mode);
else if (radeon_output->DACType == DAC_TVDAC)
atombios_output_dac2_setup(output, adjusted_mode);
atombios_output_tv1_setup(output, adjusted_mode);
}
}
static AtomBiosResult
atom_bios_dac_load_detect(atomBiosHandlePtr atomBIOS, xf86OutputPtr output)
{
RADEONOutputPrivatePtr radeon_output = output->driver_private;
DAC_LOAD_DETECTION_PS_ALLOCATION dac_data;
AtomBiosArgRec data;
unsigned char *space;
if (radeon_output->devices & ATOM_DEVICE_CRT1_SUPPORT) {
dac_data.sDacload.usDeviceID = ATOM_DEVICE_CRT1_SUPPORT;
if (radeon_output->DACType == DAC_PRIMARY)
dac_data.sDacload.ucDacType = ATOM_DAC_A;
else if (radeon_output->DACType == DAC_TVDAC)
dac_data.sDacload.ucDacType = ATOM_DAC_B;
} else if (radeon_output->devices & ATOM_DEVICE_CRT2_SUPPORT) {
dac_data.sDacload.usDeviceID = ATOM_DEVICE_CRT2_SUPPORT;
if (radeon_output->DACType == DAC_PRIMARY)
dac_data.sDacload.ucDacType = ATOM_DAC_A;
else if (radeon_output->DACType == DAC_TVDAC)
dac_data.sDacload.ucDacType = ATOM_DAC_B;
} else if (radeon_output->devices & ATOM_DEVICE_CV_SUPPORT) {
dac_data.sDacload.usDeviceID = ATOM_DEVICE_CV_SUPPORT;
if (radeon_output->DACType == DAC_PRIMARY)
dac_data.sDacload.ucDacType = ATOM_DAC_A;
else if (radeon_output->DACType == DAC_TVDAC)
dac_data.sDacload.ucDacType = ATOM_DAC_B;
} else if (radeon_output->devices & ATOM_DEVICE_TV1_SUPPORT) {
dac_data.sDacload.usDeviceID = ATOM_DEVICE_TV1_SUPPORT;
if (radeon_output->DACType == DAC_PRIMARY)
dac_data.sDacload.ucDacType = ATOM_DAC_A;
else if (radeon_output->DACType == DAC_TVDAC)
dac_data.sDacload.ucDacType = ATOM_DAC_B;
} else {
ErrorF("invalid output device for dac detection\n");
return ATOM_NOT_IMPLEMENTED;
}
dac_data.sDacload.ucMisc = 0;
data.exec.index = GetIndexIntoMasterTable(COMMAND, DAC_LoadDetection);
data.exec.dataSpace = (void *)&space;
data.exec.pspace = &dac_data;
if (RHDAtomBiosFunc(atomBIOS->scrnIndex, atomBIOS, ATOMBIOS_EXEC, &data) == ATOM_SUCCESS) {
ErrorF("Dac detection success\n");
return ATOM_SUCCESS ;
}
ErrorF("DAC detection failed\n");
return ATOM_NOT_IMPLEMENTED;
}
RADEONMonitorType
atombios_dac_detect(ScrnInfoPtr pScrn, xf86OutputPtr output)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
RADEONOutputPrivatePtr radeon_output = output->driver_private;
RADEONMonitorType MonType = MT_NONE;
AtomBiosResult ret;
uint32_t bios_0_scratch;
if (OUTPUT_IS_TV) {
if (xf86ReturnOptValBool(info->Options, OPTION_FORCE_TVOUT, FALSE)) {
if (radeon_output->type == OUTPUT_STV)
return MT_STV;
else
return MT_CTV;
}
}
ret = atom_bios_dac_load_detect(info->atomBIOS, output);
if (ret == ATOM_SUCCESS) {
bios_0_scratch = INREG(RADEON_BIOS_0_SCRATCH);
ErrorF("DAC connect %08X\n", (unsigned int)bios_0_scratch);
if (radeon_output->devices & ATOM_DEVICE_CRT1_SUPPORT) {
if (bios_0_scratch & ATOM_S0_CRT1_MASK)
MonType = MT_CRT;
} else if (radeon_output->devices & ATOM_DEVICE_CRT2_SUPPORT) {
if (bios_0_scratch & ATOM_S0_CRT2_MASK)
MonType = MT_CRT;
} else if (radeon_output->devices & ATOM_DEVICE_CV_SUPPORT) {
if (bios_0_scratch & (ATOM_S0_CV_MASK | ATOM_S0_CV_MASK_A))
MonType = MT_CV;
} else if (radeon_output->devices & ATOM_DEVICE_TV1_SUPPORT) {
if (bios_0_scratch & (ATOM_S0_TV1_COMPOSITE | ATOM_S0_TV1_COMPOSITE_A))
MonType = MT_CTV;
else if (bios_0_scratch & (ATOM_S0_TV1_SVIDEO | ATOM_S0_TV1_SVIDEO_A))
MonType = MT_STV;
}
}
return MonType;
}
|