Subversion Repositories Kolibri OS

Rev

Rev 1123 | Rev 1221 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1123 Rev 1179
Line 27... Line 27...
27
#include "drm_crtc_helper.h"
27
#include "drm_crtc_helper.h"
28
#include "radeon_drm.h"
28
#include "radeon_drm.h"
29
#include "radeon.h"
29
#include "radeon.h"
30
#include "atom.h"
30
#include "atom.h"
Line 31... Line -...
31
 
-
 
32
 
31
 
33
static void radeon_legacy_rmx_mode_set(struct drm_encoder *encoder,
-
 
34
				       struct drm_display_mode *mode,
-
 
35
				       struct drm_display_mode *adjusted_mode)
32
static void radeon_legacy_encoder_disable(struct drm_encoder *encoder)
36
{
-
 
37
	struct drm_device *dev = encoder->dev;
-
 
38
	struct radeon_device *rdev = dev->dev_private;
33
{
39
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-
 
40
	int    xres = mode->hdisplay;
-
 
41
	int    yres = mode->vdisplay;
-
 
42
	bool   hscale = true, vscale = true;
-
 
43
	int    hsync_wid;
-
 
44
	int    vsync_wid;
-
 
45
	int    hsync_start;
-
 
46
	uint32_t scale, inc;
-
 
47
	uint32_t fp_horz_stretch, fp_vert_stretch, crtc_more_cntl, fp_horz_vert_active;
-
 
48
	uint32_t fp_h_sync_strt_wid, fp_v_sync_strt_wid, fp_crtc_h_total_disp, fp_crtc_v_total_disp;
-
 
49
	struct radeon_native_mode *native_mode = &radeon_encoder->native_mode;
-
 
50
 
-
 
51
	DRM_DEBUG("\n");
-
 
52
 
-
 
53
	fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH) &
-
 
54
		(RADEON_VERT_STRETCH_RESERVED |
-
 
55
		 RADEON_VERT_AUTO_RATIO_INC);
-
 
56
	fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH) &
-
 
57
		(RADEON_HORZ_FP_LOOP_STRETCH |
-
 
58
		 RADEON_HORZ_AUTO_RATIO_INC);
-
 
59
 
-
 
60
	crtc_more_cntl = 0;
-
 
61
	if ((rdev->family == CHIP_RS100) ||
-
 
62
	    (rdev->family == CHIP_RS200)) {
-
 
63
		/* This is to workaround the asic bug for RMX, some versions
-
 
64
		   of BIOS dosen't have this register initialized correctly. */
-
 
65
		crtc_more_cntl |= RADEON_CRTC_H_CUTOFF_ACTIVE_EN;
-
 
66
	}
-
 
67
 
-
 
68
 
-
 
69
	fp_crtc_h_total_disp = ((((mode->crtc_htotal / 8) - 1) & 0x3ff)
-
 
70
				| ((((mode->crtc_hdisplay / 8) - 1) & 0x1ff) << 16));
-
 
71
 
-
 
72
	hsync_wid = (mode->crtc_hsync_end - mode->crtc_hsync_start) / 8;
-
 
73
	if (!hsync_wid)
-
 
74
		hsync_wid = 1;
-
 
75
	hsync_start = mode->crtc_hsync_start - 8;
-
 
76
 
-
 
77
	fp_h_sync_strt_wid = ((hsync_start & 0x1fff)
-
 
78
			      | ((hsync_wid & 0x3f) << 16)
-
 
79
			      | ((mode->flags & DRM_MODE_FLAG_NHSYNC)
-
 
80
				 ? RADEON_CRTC_H_SYNC_POL
-
 
81
				 : 0));
-
 
82
 
-
 
83
	fp_crtc_v_total_disp = (((mode->crtc_vtotal - 1) & 0xffff)
-
 
84
				| ((mode->crtc_vdisplay - 1) << 16));
-
 
85
 
-
 
86
	vsync_wid = mode->crtc_vsync_end - mode->crtc_vsync_start;
-
 
87
	if (!vsync_wid)
-
 
88
		vsync_wid = 1;
-
 
89
 
-
 
90
	fp_v_sync_strt_wid = (((mode->crtc_vsync_start - 1) & 0xfff)
-
 
91
			      | ((vsync_wid & 0x1f) << 16)
-
 
92
			      | ((mode->flags & DRM_MODE_FLAG_NVSYNC)
-
 
93
				 ? RADEON_CRTC_V_SYNC_POL
-
 
94
				 : 0));
-
 
95
 
-
 
96
	fp_horz_vert_active = 0;
-
 
97
 
-
 
98
	if (native_mode->panel_xres == 0 ||
-
 
99
	    native_mode->panel_yres == 0) {
-
 
100
		hscale = false;
-
 
101
		vscale = false;
-
 
102
	} else {
-
 
103
		if (xres > native_mode->panel_xres)
-
 
104
			xres = native_mode->panel_xres;
-
 
105
		if (yres > native_mode->panel_yres)
-
 
106
			yres = native_mode->panel_yres;
-
 
107
 
-
 
108
		if (xres == native_mode->panel_xres)
-
 
109
			hscale = false;
-
 
110
		if (yres == native_mode->panel_yres)
-
 
111
			vscale = false;
-
 
112
	}
-
 
113
 
34
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
114
	if (radeon_encoder->flags & RADEON_USE_RMX) {
-
 
115
		if (radeon_encoder->rmx_type != RMX_CENTER) {
-
 
116
			if (!hscale)
-
 
117
				fp_horz_stretch |= ((xres/8-1) << 16);
-
 
118
			else {
-
 
119
				inc = (fp_horz_stretch & RADEON_HORZ_AUTO_RATIO_INC) ? 1 : 0;
-
 
120
				scale = ((xres + inc) * RADEON_HORZ_STRETCH_RATIO_MAX)
-
 
121
					/ native_mode->panel_xres + 1;
-
 
122
				fp_horz_stretch |= (((scale) & RADEON_HORZ_STRETCH_RATIO_MASK) |
-
 
123
						    RADEON_HORZ_STRETCH_BLEND |
-
 
124
						    RADEON_HORZ_STRETCH_ENABLE |
-
 
125
						    ((native_mode->panel_xres/8-1) << 16));
-
 
126
			}
-
 
127
 
-
 
128
			if (!vscale)
-
 
129
				fp_vert_stretch |= ((yres-1) << 12);
-
 
130
			else {
-
 
131
				inc = (fp_vert_stretch & RADEON_VERT_AUTO_RATIO_INC) ? 1 : 0;
-
 
132
				scale = ((yres + inc) * RADEON_VERT_STRETCH_RATIO_MAX)
-
 
133
					/ native_mode->panel_yres + 1;
-
 
134
				fp_vert_stretch |= (((scale) & RADEON_VERT_STRETCH_RATIO_MASK) |
-
 
135
						    RADEON_VERT_STRETCH_ENABLE |
-
 
136
						    RADEON_VERT_STRETCH_BLEND |
-
 
137
						    ((native_mode->panel_yres-1) << 12));
-
 
138
			}
-
 
139
		} else if (radeon_encoder->rmx_type == RMX_CENTER) {
-
 
140
			int    blank_width;
-
 
141
 
-
 
142
			fp_horz_stretch |= ((xres/8-1) << 16);
-
 
143
			fp_vert_stretch |= ((yres-1) << 12);
-
 
144
 
-
 
145
			crtc_more_cntl |= (RADEON_CRTC_AUTO_HORZ_CENTER_EN |
-
 
146
					   RADEON_CRTC_AUTO_VERT_CENTER_EN);
-
 
147
 
-
 
148
			blank_width = (mode->crtc_hblank_end - mode->crtc_hblank_start) / 8;
-
 
149
			if (blank_width > 110)
-
 
150
				blank_width = 110;
-
 
151
 
-
 
152
			fp_crtc_h_total_disp = (((blank_width) & 0x3ff)
-
 
153
						| ((((mode->crtc_hdisplay / 8) - 1) & 0x1ff) << 16));
-
 
154
 
-
 
155
			hsync_wid = (mode->crtc_hsync_end - mode->crtc_hsync_start) / 8;
-
 
156
			if (!hsync_wid)
-
 
157
				hsync_wid = 1;
-
 
158
 
-
 
159
			fp_h_sync_strt_wid = ((((mode->crtc_hsync_start - mode->crtc_hblank_start) / 8) & 0x1fff)
-
 
160
					      | ((hsync_wid & 0x3f) << 16)
-
 
161
					      | ((mode->flags & DRM_MODE_FLAG_NHSYNC)
-
 
162
						 ? RADEON_CRTC_H_SYNC_POL
-
 
163
						 : 0));
-
 
164
 
-
 
165
			fp_crtc_v_total_disp = (((mode->crtc_vblank_end - mode->crtc_vblank_start) & 0xffff)
-
 
166
						| ((mode->crtc_vdisplay - 1) << 16));
-
 
167
 
-
 
168
			vsync_wid = mode->crtc_vsync_end - mode->crtc_vsync_start;
-
 
169
			if (!vsync_wid)
-
 
170
				vsync_wid = 1;
-
 
171
 
-
 
172
			fp_v_sync_strt_wid = ((((mode->crtc_vsync_start - mode->crtc_vblank_start) & 0xfff)
-
 
173
					       | ((vsync_wid & 0x1f) << 16)
-
 
174
					       | ((mode->flags & DRM_MODE_FLAG_NVSYNC)
-
 
175
						  ? RADEON_CRTC_V_SYNC_POL
-
 
176
						  : 0)));
-
 
177
 
-
 
178
			fp_horz_vert_active = (((native_mode->panel_yres) & 0xfff) |
-
 
179
					       (((native_mode->panel_xres / 8) & 0x1ff) << 16));
-
 
180
		}
-
 
181
	} else {
-
 
182
		fp_horz_stretch |= ((xres/8-1) << 16);
-
 
183
		fp_vert_stretch |= ((yres-1) << 12);
-
 
184
	}
-
 
185
 
-
 
186
	WREG32(RADEON_FP_HORZ_STRETCH,      fp_horz_stretch);
-
 
187
	WREG32(RADEON_FP_VERT_STRETCH,      fp_vert_stretch);
-
 
188
	WREG32(RADEON_CRTC_MORE_CNTL,       crtc_more_cntl);
-
 
189
	WREG32(RADEON_FP_HORZ_VERT_ACTIVE,  fp_horz_vert_active);
-
 
190
	WREG32(RADEON_FP_H_SYNC_STRT_WID,   fp_h_sync_strt_wid);
-
 
191
	WREG32(RADEON_FP_V_SYNC_STRT_WID,   fp_v_sync_strt_wid);
-
 
192
	WREG32(RADEON_FP_CRTC_H_TOTAL_DISP, fp_crtc_h_total_disp);
-
 
Line -... Line 35...
-
 
35
	struct drm_encoder_helper_funcs *encoder_funcs;
-
 
36
 
-
 
37
	encoder_funcs = encoder->helper_private;
193
	WREG32(RADEON_FP_CRTC_V_TOTAL_DISP, fp_crtc_v_total_disp);
38
	encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
Line 194... Line 39...
194
 
39
	radeon_encoder->active_device = 0;
195
}
40
}
196
 
41
 
Line 260... Line 105...
260
	if (rdev->is_atom_bios)
105
	if (rdev->is_atom_bios)
261
		radeon_atom_output_lock(encoder, true);
106
		radeon_atom_output_lock(encoder, true);
262
	else
107
	else
263
		radeon_combios_output_lock(encoder, true);
108
		radeon_combios_output_lock(encoder, true);
264
	radeon_legacy_lvds_dpms(encoder, DRM_MODE_DPMS_OFF);
109
	radeon_legacy_lvds_dpms(encoder, DRM_MODE_DPMS_OFF);
-
 
110
 
-
 
111
	radeon_encoder_set_active_device(encoder);
265
}
112
}
Line 266... Line 113...
266
 
113
 
267
static void radeon_legacy_lvds_commit(struct drm_encoder *encoder)
114
static void radeon_legacy_lvds_commit(struct drm_encoder *encoder)
268
{
115
{
Line 285... Line 132...
285
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
132
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
286
	uint32_t lvds_pll_cntl, lvds_gen_cntl, lvds_ss_gen_cntl;
133
	uint32_t lvds_pll_cntl, lvds_gen_cntl, lvds_ss_gen_cntl;
Line 287... Line 134...
287
 
134
 
Line 288... Line -...
288
	DRM_DEBUG("\n");
-
 
289
 
-
 
290
	if (radeon_crtc->crtc_id == 0)
-
 
291
		radeon_legacy_rmx_mode_set(encoder, mode, adjusted_mode);
135
	DRM_DEBUG("\n");
292
 
136
 
Line 293... Line 137...
293
	lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
137
	lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
294
	lvds_pll_cntl &= ~RADEON_LVDS_PLL_EN;
138
	lvds_pll_cntl &= ~RADEON_LVDS_PLL_EN;
Line 316... Line 160...
316
	if (ASIC_IS_R300(rdev))
160
	if (ASIC_IS_R300(rdev))
317
		lvds_pll_cntl &= ~(R300_LVDS_SRC_SEL_MASK);
161
		lvds_pll_cntl &= ~(R300_LVDS_SRC_SEL_MASK);
Line 318... Line 162...
318
 
162
 
319
	if (radeon_crtc->crtc_id == 0) {
163
	if (radeon_crtc->crtc_id == 0) {
320
		if (ASIC_IS_R300(rdev)) {
164
		if (ASIC_IS_R300(rdev)) {
321
			if (radeon_encoder->flags & RADEON_USE_RMX)
165
			if (radeon_encoder->rmx_type != RMX_OFF)
322
				lvds_pll_cntl |= R300_LVDS_SRC_SEL_RMX;
166
				lvds_pll_cntl |= R300_LVDS_SRC_SEL_RMX;
323
		} else
167
		} else
324
			lvds_gen_cntl &= ~RADEON_LVDS_SEL_CRTC2;
168
			lvds_gen_cntl &= ~RADEON_LVDS_SEL_CRTC2;
325
	} else {
169
	} else {
Line 348... Line 192...
348
{
192
{
349
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
193
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
Line 350... Line 194...
350
 
194
 
Line 351... Line -...
351
	drm_mode_set_crtcinfo(adjusted_mode, 0);
-
 
352
 
-
 
353
	radeon_encoder->flags &= ~RADEON_USE_RMX;
195
	drm_mode_set_crtcinfo(adjusted_mode, 0);
354
 
196
 
Line 355... Line 197...
355
	if (radeon_encoder->rmx_type != RMX_OFF)
197
	if (radeon_encoder->rmx_type != RMX_OFF)
356
		radeon_rmx_mode_fixup(encoder, mode, adjusted_mode);
198
		radeon_rmx_mode_fixup(encoder, mode, adjusted_mode);
Line 362... Line 204...
362
	.dpms = radeon_legacy_lvds_dpms,
204
	.dpms = radeon_legacy_lvds_dpms,
363
	.mode_fixup = radeon_legacy_lvds_mode_fixup,
205
	.mode_fixup = radeon_legacy_lvds_mode_fixup,
364
	.prepare = radeon_legacy_lvds_prepare,
206
	.prepare = radeon_legacy_lvds_prepare,
365
	.mode_set = radeon_legacy_lvds_mode_set,
207
	.mode_set = radeon_legacy_lvds_mode_set,
366
	.commit = radeon_legacy_lvds_commit,
208
	.commit = radeon_legacy_lvds_commit,
-
 
209
	.disable = radeon_legacy_encoder_disable,
367
};
210
};
Line 368... Line 211...
368
 
211
 
369
 
212
 
Line 427... Line 270...
427
	if (rdev->is_atom_bios)
270
	if (rdev->is_atom_bios)
428
		radeon_atom_output_lock(encoder, true);
271
		radeon_atom_output_lock(encoder, true);
429
	else
272
	else
430
		radeon_combios_output_lock(encoder, true);
273
		radeon_combios_output_lock(encoder, true);
431
	radeon_legacy_primary_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
274
	radeon_legacy_primary_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
-
 
275
	radeon_encoder_set_active_device(encoder);
432
}
276
}
Line 433... Line 277...
433
 
277
 
434
static void radeon_legacy_primary_dac_commit(struct drm_encoder *encoder)
278
static void radeon_legacy_primary_dac_commit(struct drm_encoder *encoder)
435
{
279
{
Line 453... Line 297...
453
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
297
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
454
	uint32_t disp_output_cntl, dac_cntl, dac2_cntl, dac_macro_cntl;
298
	uint32_t disp_output_cntl, dac_cntl, dac2_cntl, dac_macro_cntl;
Line 455... Line 299...
455
 
299
 
Line 456... Line -...
456
	DRM_DEBUG("\n");
-
 
457
 
-
 
458
	if (radeon_crtc->crtc_id == 0)
-
 
459
		radeon_legacy_rmx_mode_set(encoder, mode, adjusted_mode);
300
	DRM_DEBUG("\n");
460
 
301
 
461
	if (radeon_crtc->crtc_id == 0) {
302
	if (radeon_crtc->crtc_id == 0) {
462
		if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev)) {
303
		if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev)) {
463
			disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL) &
304
			disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL) &
Line 572... Line 413...
572
	.mode_fixup = radeon_legacy_primary_dac_mode_fixup,
413
	.mode_fixup = radeon_legacy_primary_dac_mode_fixup,
573
	.prepare = radeon_legacy_primary_dac_prepare,
414
	.prepare = radeon_legacy_primary_dac_prepare,
574
	.mode_set = radeon_legacy_primary_dac_mode_set,
415
	.mode_set = radeon_legacy_primary_dac_mode_set,
575
	.commit = radeon_legacy_primary_dac_commit,
416
	.commit = radeon_legacy_primary_dac_commit,
576
	.detect = radeon_legacy_primary_dac_detect,
417
	.detect = radeon_legacy_primary_dac_detect,
-
 
418
	.disable = radeon_legacy_encoder_disable,
577
};
419
};
Line 578... Line 420...
578
 
420
 
579
 
421
 
Line 624... Line 466...
624
	if (rdev->is_atom_bios)
466
	if (rdev->is_atom_bios)
625
		radeon_atom_output_lock(encoder, true);
467
		radeon_atom_output_lock(encoder, true);
626
	else
468
	else
627
		radeon_combios_output_lock(encoder, true);
469
		radeon_combios_output_lock(encoder, true);
628
	radeon_legacy_tmds_int_dpms(encoder, DRM_MODE_DPMS_OFF);
470
	radeon_legacy_tmds_int_dpms(encoder, DRM_MODE_DPMS_OFF);
-
 
471
	radeon_encoder_set_active_device(encoder);
629
}
472
}
Line 630... Line 473...
630
 
473
 
631
static void radeon_legacy_tmds_int_commit(struct drm_encoder *encoder)
474
static void radeon_legacy_tmds_int_commit(struct drm_encoder *encoder)
632
{
475
{
Line 651... Line 494...
651
	uint32_t tmp, tmds_pll_cntl, tmds_transmitter_cntl, fp_gen_cntl;
494
	uint32_t tmp, tmds_pll_cntl, tmds_transmitter_cntl, fp_gen_cntl;
652
	int i;
495
	int i;
Line 653... Line 496...
653
 
496
 
Line 654... Line -...
654
	DRM_DEBUG("\n");
-
 
655
 
-
 
656
	if (radeon_crtc->crtc_id == 0)
-
 
657
		radeon_legacy_rmx_mode_set(encoder, mode, adjusted_mode);
497
	DRM_DEBUG("\n");
658
 
498
 
659
	tmp = tmds_pll_cntl = RREG32(RADEON_TMDS_PLL_CNTL);
499
	tmp = tmds_pll_cntl = RREG32(RADEON_TMDS_PLL_CNTL);
660
	tmp &= 0xfffff;
500
	tmp &= 0xfffff;
661
	if (rdev->family == CHIP_RV280) {
501
	if (rdev->family == CHIP_RV280) {
Line 709... Line 549...
709
	    fp_gen_cntl &= ~RADEON_FP_PANEL_FORMAT;/* 18 bit format */
549
	    fp_gen_cntl &= ~RADEON_FP_PANEL_FORMAT;/* 18 bit format */
Line 710... Line 550...
710
 
550
 
711
    if (radeon_crtc->crtc_id == 0) {
551
    if (radeon_crtc->crtc_id == 0) {
712
	    if (ASIC_IS_R300(rdev) || rdev->family == CHIP_R200) {
552
	    if (ASIC_IS_R300(rdev) || rdev->family == CHIP_R200) {
713
		    fp_gen_cntl &= ~R200_FP_SOURCE_SEL_MASK;
553
		    fp_gen_cntl &= ~R200_FP_SOURCE_SEL_MASK;
714
		    if (radeon_encoder->flags & RADEON_USE_RMX)
554
		    if (radeon_encoder->rmx_type != RMX_OFF)
715
			    fp_gen_cntl |= R200_FP_SOURCE_SEL_RMX;
555
			    fp_gen_cntl |= R200_FP_SOURCE_SEL_RMX;
716
		    else
556
		    else
717
			    fp_gen_cntl |= R200_FP_SOURCE_SEL_CRTC1;
557
			    fp_gen_cntl |= R200_FP_SOURCE_SEL_CRTC1;
718
	    } else
558
	    } else
Line 739... Line 579...
739
	.dpms = radeon_legacy_tmds_int_dpms,
579
	.dpms = radeon_legacy_tmds_int_dpms,
740
	.mode_fixup = radeon_legacy_tmds_int_mode_fixup,
580
	.mode_fixup = radeon_legacy_tmds_int_mode_fixup,
741
	.prepare = radeon_legacy_tmds_int_prepare,
581
	.prepare = radeon_legacy_tmds_int_prepare,
742
	.mode_set = radeon_legacy_tmds_int_mode_set,
582
	.mode_set = radeon_legacy_tmds_int_mode_set,
743
	.commit = radeon_legacy_tmds_int_commit,
583
	.commit = radeon_legacy_tmds_int_commit,
-
 
584
	.disable = radeon_legacy_encoder_disable,
744
};
585
};
Line 745... Line 586...
745
 
586
 
746
 
587
 
Line 793... Line 634...
793
	if (rdev->is_atom_bios)
634
	if (rdev->is_atom_bios)
794
		radeon_atom_output_lock(encoder, true);
635
		radeon_atom_output_lock(encoder, true);
795
	else
636
	else
796
		radeon_combios_output_lock(encoder, true);
637
		radeon_combios_output_lock(encoder, true);
797
	radeon_legacy_tmds_ext_dpms(encoder, DRM_MODE_DPMS_OFF);
638
	radeon_legacy_tmds_ext_dpms(encoder, DRM_MODE_DPMS_OFF);
-
 
639
	radeon_encoder_set_active_device(encoder);
798
}
640
}
Line 799... Line 641...
799
 
641
 
800
static void radeon_legacy_tmds_ext_commit(struct drm_encoder *encoder)
642
static void radeon_legacy_tmds_ext_commit(struct drm_encoder *encoder)
801
{
643
{
Line 818... Line 660...
818
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
660
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
819
	uint32_t fp2_gen_cntl;
661
	uint32_t fp2_gen_cntl;
Line 820... Line 662...
820
 
662
 
Line 821... Line -...
821
	DRM_DEBUG("\n");
-
 
822
 
-
 
823
	if (radeon_crtc->crtc_id == 0)
-
 
824
		radeon_legacy_rmx_mode_set(encoder, mode, adjusted_mode);
663
	DRM_DEBUG("\n");
825
 
664
 
826
	if (rdev->is_atom_bios) {
665
	if (rdev->is_atom_bios) {
827
		radeon_encoder->pixel_clock = adjusted_mode->clock;
666
		radeon_encoder->pixel_clock = adjusted_mode->clock;
828
		atombios_external_tmds_setup(encoder, ATOM_ENABLE);
667
		atombios_external_tmds_setup(encoder, ATOM_ENABLE);
Line 854... Line 693...
854
	}
693
	}
Line 855... Line 694...
855
 
694
 
856
	if (radeon_crtc->crtc_id == 0) {
695
	if (radeon_crtc->crtc_id == 0) {
857
		if ((rdev->family == CHIP_R200) || ASIC_IS_R300(rdev)) {
696
		if ((rdev->family == CHIP_R200) || ASIC_IS_R300(rdev)) {
858
			fp2_gen_cntl &= ~R200_FP2_SOURCE_SEL_MASK;
697
			fp2_gen_cntl &= ~R200_FP2_SOURCE_SEL_MASK;
859
			if (radeon_encoder->flags & RADEON_USE_RMX)
698
			if (radeon_encoder->rmx_type != RMX_OFF)
860
				fp2_gen_cntl |= R200_FP2_SOURCE_SEL_RMX;
699
				fp2_gen_cntl |= R200_FP2_SOURCE_SEL_RMX;
861
			else
700
			else
862
				fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC1;
701
				fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC1;
863
		} else
702
		} else
Line 882... Line 721...
882
	.dpms = radeon_legacy_tmds_ext_dpms,
721
	.dpms = radeon_legacy_tmds_ext_dpms,
883
	.mode_fixup = radeon_legacy_tmds_ext_mode_fixup,
722
	.mode_fixup = radeon_legacy_tmds_ext_mode_fixup,
884
	.prepare = radeon_legacy_tmds_ext_prepare,
723
	.prepare = radeon_legacy_tmds_ext_prepare,
885
	.mode_set = radeon_legacy_tmds_ext_mode_set,
724
	.mode_set = radeon_legacy_tmds_ext_mode_set,
886
	.commit = radeon_legacy_tmds_ext_commit,
725
	.commit = radeon_legacy_tmds_ext_commit,
-
 
726
	.disable = radeon_legacy_encoder_disable,
887
};
727
};
Line 888... Line 728...
888
 
728
 
889
 
729
 
Line 903... Line 743...
903
 
743
 
904
static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
744
static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
905
{
745
{
906
	struct drm_device *dev = encoder->dev;
746
	struct drm_device *dev = encoder->dev;
-
 
747
	struct radeon_device *rdev = dev->dev_private;
907
	struct radeon_device *rdev = dev->dev_private;
748
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
908
	uint32_t fp2_gen_cntl = 0, crtc2_gen_cntl = 0, tv_dac_cntl = 0;
749
	uint32_t fp2_gen_cntl = 0, crtc2_gen_cntl = 0, tv_dac_cntl = 0;
909
	/* uint32_t tv_master_cntl = 0; */
750
	uint32_t tv_master_cntl = 0;
910
 
751
	bool is_tv;
Line -... Line 752...
-
 
752
	DRM_DEBUG("\n");
-
 
753
 
911
	DRM_DEBUG("\n");
754
	is_tv = radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT ? true : false;
912
 
755
 
913
	if (rdev->family == CHIP_R200)
756
	if (rdev->family == CHIP_R200)
-
 
757
		fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
-
 
758
	else {
-
 
759
		if (is_tv)
914
		fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
760
			tv_master_cntl = RREG32(RADEON_TV_MASTER_CNTL);
915
	else {
-
 
916
		crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
-
 
917
		/*  FIXME TV */
761
		else
918
		/* tv_master_cntl = RREG32(RADEON_TV_MASTER_CNTL); */
762
		crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
Line 919... Line 763...
919
		tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
763
		tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
920
	}
764
	}
921
 
765
 
922
	switch (mode) {
766
	switch (mode) {
923
	case DRM_MODE_DPMS_ON:
767
	case DRM_MODE_DPMS_ON:
-
 
768
		if (rdev->family == CHIP_R200) {
-
 
769
			fp2_gen_cntl |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN);
-
 
770
		} else {
924
		if (rdev->family == CHIP_R200) {
771
			if (is_tv)
925
			fp2_gen_cntl |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN);
-
 
-
 
772
				tv_master_cntl |= RADEON_TV_ON;
926
		} else {
773
			else
927
			crtc2_gen_cntl |= RADEON_CRTC2_CRT2_ON;
774
			crtc2_gen_cntl |= RADEON_CRTC2_CRT2_ON;
928
			/* tv_master_cntl |= RADEON_TV_ON; */
775
 
929
			if (rdev->family == CHIP_R420 ||
776
			if (rdev->family == CHIP_R420 ||
930
					rdev->family == CHIP_R423 ||
777
					rdev->family == CHIP_R423 ||
Line 944... Line 791...
944
	case DRM_MODE_DPMS_SUSPEND:
791
	case DRM_MODE_DPMS_SUSPEND:
945
	case DRM_MODE_DPMS_OFF:
792
	case DRM_MODE_DPMS_OFF:
946
		if (rdev->family == CHIP_R200)
793
		if (rdev->family == CHIP_R200)
947
			fp2_gen_cntl &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN);
794
			fp2_gen_cntl &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN);
948
		else {
795
		else {
-
 
796
			if (is_tv)
-
 
797
				tv_master_cntl &= ~RADEON_TV_ON;
-
 
798
			else
949
			crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON;
799
			crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON;
950
			/* tv_master_cntl &= ~RADEON_TV_ON; */
-
 
-
 
800
 
951
			if (rdev->family == CHIP_R420 ||
801
			if (rdev->family == CHIP_R420 ||
952
					rdev->family == CHIP_R423 ||
802
					rdev->family == CHIP_R423 ||
953
					rdev->family == CHIP_RV410)
803
					rdev->family == CHIP_RV410)
954
				tv_dac_cntl |= (R420_TV_DAC_RDACPD |
804
				tv_dac_cntl |= (R420_TV_DAC_RDACPD |
955
						R420_TV_DAC_GDACPD |
805
						R420_TV_DAC_GDACPD |
Line 965... Line 815...
965
	}
815
	}
Line 966... Line 816...
966
 
816
 
967
	if (rdev->family == CHIP_R200) {
817
	if (rdev->family == CHIP_R200) {
968
		WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
818
		WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
-
 
819
	} else {
-
 
820
		if (is_tv)
-
 
821
			WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl);
969
	} else {
822
		else
970
		WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
-
 
971
		/* WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl); */
823
		WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
972
		WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
824
		WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
Line 973... Line 825...
973
	}
825
	}
974
 
826
 
Line 985... Line 837...
985
	if (rdev->is_atom_bios)
837
	if (rdev->is_atom_bios)
986
		radeon_atom_output_lock(encoder, true);
838
		radeon_atom_output_lock(encoder, true);
987
	else
839
	else
988
		radeon_combios_output_lock(encoder, true);
840
		radeon_combios_output_lock(encoder, true);
989
	radeon_legacy_tv_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
841
	radeon_legacy_tv_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
-
 
842
	radeon_encoder_set_active_device(encoder);
990
}
843
}
Line 991... Line 844...
991
 
844
 
992
static void radeon_legacy_tv_dac_commit(struct drm_encoder *encoder)
845
static void radeon_legacy_tv_dac_commit(struct drm_encoder *encoder)
993
{
846
{
Line 1007... Line 860...
1007
{
860
{
1008
	struct drm_device *dev = encoder->dev;
861
	struct drm_device *dev = encoder->dev;
1009
	struct radeon_device *rdev = dev->dev_private;
862
	struct radeon_device *rdev = dev->dev_private;
1010
	struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
863
	struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
1011
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
864
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-
 
865
	struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
1012
	uint32_t tv_dac_cntl, gpiopad_a = 0, dac2_cntl, disp_output_cntl = 0;
866
	uint32_t tv_dac_cntl, gpiopad_a = 0, dac2_cntl, disp_output_cntl = 0;
1013
	uint32_t disp_hw_debug = 0, fp2_gen_cntl = 0;
867
	uint32_t disp_hw_debug = 0, fp2_gen_cntl = 0, disp_tv_out_cntl = 0;
-
 
868
	bool is_tv = false;
Line 1014... Line 869...
1014
 
869
 
Line 1015... Line -...
1015
	DRM_DEBUG("\n");
-
 
1016
 
870
	DRM_DEBUG("\n");
Line 1017... Line 871...
1017
	if (radeon_crtc->crtc_id == 0)
871
 
1018
		radeon_legacy_rmx_mode_set(encoder, mode, adjusted_mode);
872
	is_tv = radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT ? true : false;
1019
 
873
 
1020
	if (rdev->family != CHIP_R200) {
874
	if (rdev->family != CHIP_R200) {
Line 1037... Line 891...
1037
					RADEON_TV_DAC_GDACPD |
891
					RADEON_TV_DAC_GDACPD |
1038
					RADEON_TV_DAC_GDACPD);
892
					RADEON_TV_DAC_GDACPD);
1039
		}
893
		}
Line 1040... Line 894...
1040
 
894
 
1041
		/*  FIXME TV */
895
		/*  FIXME TV */
1042
		if (radeon_encoder->enc_priv) {
896
		if (tv_dac) {
1043
			struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
897
			struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
1044
			tv_dac_cntl |= (RADEON_TV_DAC_NBLANK |
898
			tv_dac_cntl |= (RADEON_TV_DAC_NBLANK |
1045
					RADEON_TV_DAC_NHOLD |
899
					RADEON_TV_DAC_NHOLD |
1046
					RADEON_TV_DAC_STD_PS2 |
900
					RADEON_TV_DAC_STD_PS2 |
Line 1054... Line 908...
1054
	}
908
	}
Line 1055... Line 909...
1055
 
909
 
1056
	if (ASIC_IS_R300(rdev)) {
910
	if (ASIC_IS_R300(rdev)) {
1057
		gpiopad_a = RREG32(RADEON_GPIOPAD_A) | 1;
911
		gpiopad_a = RREG32(RADEON_GPIOPAD_A) | 1;
-
 
912
		disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
-
 
913
	}
1058
		disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
914
 
1059
	} else if (rdev->family == CHIP_R200)
915
	if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev))
1060
		fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
916
		disp_tv_out_cntl = RREG32(RADEON_DISP_TV_OUT_CNTL);
1061
	else
917
	else
Line -... Line 918...
-
 
918
		disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG);
-
 
919
 
-
 
920
	if (rdev->family == CHIP_R200)
-
 
921
		fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
-
 
922
 
-
 
923
	if (is_tv) {
-
 
924
		uint32_t dac_cntl;
-
 
925
 
-
 
926
		dac_cntl = RREG32(RADEON_DAC_CNTL);
-
 
927
		dac_cntl &= ~RADEON_DAC_TVO_EN;
-
 
928
		WREG32(RADEON_DAC_CNTL, dac_cntl);
-
 
929
 
-
 
930
		if (ASIC_IS_R300(rdev))
-
 
931
			gpiopad_a = RREG32(RADEON_GPIOPAD_A) & ~1;
-
 
932
 
-
 
933
		dac2_cntl = RREG32(RADEON_DAC_CNTL2) & ~RADEON_DAC2_DAC2_CLK_SEL;
-
 
934
		if (radeon_crtc->crtc_id == 0) {
-
 
935
			if (ASIC_IS_R300(rdev)) {
-
 
936
				disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
-
 
937
				disp_output_cntl |= (RADEON_DISP_TVDAC_SOURCE_CRTC |
-
 
938
						     RADEON_DISP_TV_SOURCE_CRTC);
-
 
939
			}
-
 
940
			if (rdev->family >= CHIP_R200) {
-
 
941
				disp_tv_out_cntl &= ~RADEON_DISP_TV_PATH_SRC_CRTC2;
-
 
942
			} else {
-
 
943
				disp_hw_debug |= RADEON_CRT2_DISP1_SEL;
-
 
944
			}
-
 
945
		} else {
-
 
946
			if (ASIC_IS_R300(rdev)) {
-
 
947
				disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
-
 
948
				disp_output_cntl |= RADEON_DISP_TV_SOURCE_CRTC;
-
 
949
			}
-
 
950
			if (rdev->family >= CHIP_R200) {
-
 
951
				disp_tv_out_cntl |= RADEON_DISP_TV_PATH_SRC_CRTC2;
-
 
952
			} else {
-
 
953
				disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
-
 
954
			}
-
 
955
		}
-
 
956
		WREG32(RADEON_DAC_CNTL2, dac2_cntl);
1062
		disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG);
957
	} else {
Line 1063... Line 958...
1063
 
958
 
1064
	dac2_cntl = RREG32(RADEON_DAC_CNTL2) | RADEON_DAC2_DAC2_CLK_SEL;
959
	dac2_cntl = RREG32(RADEON_DAC_CNTL2) | RADEON_DAC2_DAC2_CLK_SEL;
1065
 
960
 
Line 1081... Line 976...
1081
					  RADEON_FP2_DVO_RATE_SEL_SDR);
976
					  RADEON_FP2_DVO_RATE_SEL_SDR);
1082
			fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC2;
977
			fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC2;
1083
		} else
978
		} else
1084
			disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
979
			disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
1085
	}
980
	}
1086
 
-
 
1087
	WREG32(RADEON_DAC_CNTL2, dac2_cntl);
981
	WREG32(RADEON_DAC_CNTL2, dac2_cntl);
-
 
982
	}
Line 1088... Line 983...
1088
 
983
 
1089
	if (ASIC_IS_R300(rdev)) {
984
	if (ASIC_IS_R300(rdev)) {
1090
		WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
985
		WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
-
 
986
		WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
-
 
987
	}
1091
		WREG32(RADEON_DISP_TV_OUT_CNTL, disp_output_cntl);
988
 
1092
	} else if (rdev->family == CHIP_R200)
989
	if (rdev->family >= CHIP_R200)
1093
		WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
990
		WREG32(RADEON_DISP_TV_OUT_CNTL, disp_tv_out_cntl);
1094
	else
991
	else
Line -... Line 992...
-
 
992
		WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
-
 
993
 
-
 
994
	if (rdev->family == CHIP_R200)
-
 
995
		WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
-
 
996
 
-
 
997
	if (is_tv)
1095
		WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
998
		radeon_legacy_tv_mode_set(encoder, mode, adjusted_mode);
1096
 
999
 
1097
	if (rdev->is_atom_bios)
1000
	if (rdev->is_atom_bios)
1098
		radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
1001
		radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
Line 1099... Line 1002...
1099
	else
1002
	else
Line -... Line 1003...
-
 
1003
		radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
-
 
1004
 
-
 
1005
}
-
 
1006
 
-
 
1007
static bool r300_legacy_tv_detect(struct drm_encoder *encoder,
-
 
1008
				  struct drm_connector *connector)
-
 
1009
{
-
 
1010
	struct drm_device *dev = encoder->dev;
-
 
1011
	struct radeon_device *rdev = dev->dev_private;
-
 
1012
	uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
-
 
1013
	uint32_t disp_output_cntl, gpiopad_a, tmp;
-
 
1014
	bool found = false;
-
 
1015
 
-
 
1016
	/* save regs needed */
-
 
1017
	gpiopad_a = RREG32(RADEON_GPIOPAD_A);
-
 
1018
	dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
-
 
1019
	crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
-
 
1020
	dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL);
-
 
1021
	tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
-
 
1022
	disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
-
 
1023
 
-
 
1024
	WREG32_P(RADEON_GPIOPAD_A, 0, ~1);
-
 
1025
 
-
 
1026
	WREG32(RADEON_DAC_CNTL2, RADEON_DAC2_DAC2_CLK_SEL);
-
 
1027
 
-
 
1028
	WREG32(RADEON_CRTC2_GEN_CNTL,
-
 
1029
	       RADEON_CRTC2_CRT2_ON | RADEON_CRTC2_VSYNC_TRISTAT);
-
 
1030
 
-
 
1031
	tmp = disp_output_cntl & ~RADEON_DISP_TVDAC_SOURCE_MASK;
-
 
1032
	tmp |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
-
 
1033
	WREG32(RADEON_DISP_OUTPUT_CNTL, tmp);
-
 
1034
 
-
 
1035
	WREG32(RADEON_DAC_EXT_CNTL,
-
 
1036
	       RADEON_DAC2_FORCE_BLANK_OFF_EN |
-
 
1037
	       RADEON_DAC2_FORCE_DATA_EN |
-
 
1038
	       RADEON_DAC_FORCE_DATA_SEL_RGB |
-
 
1039
	       (0xec << RADEON_DAC_FORCE_DATA_SHIFT));
-
 
1040
 
-
 
1041
	WREG32(RADEON_TV_DAC_CNTL,
-
 
1042
	       RADEON_TV_DAC_STD_NTSC |
-
 
1043
	       (8 << RADEON_TV_DAC_BGADJ_SHIFT) |
-
 
1044
	       (6 << RADEON_TV_DAC_DACADJ_SHIFT));
-
 
1045
 
-
 
1046
	RREG32(RADEON_TV_DAC_CNTL);
-
 
1047
	mdelay(4);
-
 
1048
 
-
 
1049
	WREG32(RADEON_TV_DAC_CNTL,
-
 
1050
	       RADEON_TV_DAC_NBLANK |
-
 
1051
	       RADEON_TV_DAC_NHOLD |
-
 
1052
	       RADEON_TV_MONITOR_DETECT_EN |
-
 
1053
	       RADEON_TV_DAC_STD_NTSC |
-
 
1054
	       (8 << RADEON_TV_DAC_BGADJ_SHIFT) |
-
 
1055
	       (6 << RADEON_TV_DAC_DACADJ_SHIFT));
-
 
1056
 
-
 
1057
	RREG32(RADEON_TV_DAC_CNTL);
-
 
1058
	mdelay(6);
-
 
1059
 
-
 
1060
	tmp = RREG32(RADEON_TV_DAC_CNTL);
-
 
1061
	if ((tmp & RADEON_TV_DAC_GDACDET) != 0) {
-
 
1062
		found = true;
-
 
1063
		DRM_DEBUG("S-video TV connection detected\n");
-
 
1064
	} else if ((tmp & RADEON_TV_DAC_BDACDET) != 0) {
-
 
1065
		found = true;
-
 
1066
		DRM_DEBUG("Composite TV connection detected\n");
-
 
1067
	}
-
 
1068
 
-
 
1069
	WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
-
 
1070
	WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl);
-
 
1071
	WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
-
 
1072
	WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
-
 
1073
	WREG32(RADEON_DAC_CNTL2, dac_cntl2);
-
 
1074
	WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
-
 
1075
	return found;
-
 
1076
}
-
 
1077
 
-
 
1078
static bool radeon_legacy_tv_detect(struct drm_encoder *encoder,
-
 
1079
				    struct drm_connector *connector)
-
 
1080
{
-
 
1081
	struct drm_device *dev = encoder->dev;
-
 
1082
	struct radeon_device *rdev = dev->dev_private;
-
 
1083
	uint32_t tv_dac_cntl, dac_cntl2;
-
 
1084
	uint32_t config_cntl, tv_pre_dac_mux_cntl, tv_master_cntl, tmp;
-
 
1085
	bool found = false;
-
 
1086
 
-
 
1087
	if (ASIC_IS_R300(rdev))
-
 
1088
		return r300_legacy_tv_detect(encoder, connector);
-
 
1089
 
-
 
1090
	dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
-
 
1091
	tv_master_cntl = RREG32(RADEON_TV_MASTER_CNTL);
-
 
1092
	tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
-
 
1093
	config_cntl = RREG32(RADEON_CONFIG_CNTL);
-
 
1094
	tv_pre_dac_mux_cntl = RREG32(RADEON_TV_PRE_DAC_MUX_CNTL);
-
 
1095
 
-
 
1096
	tmp = dac_cntl2 & ~RADEON_DAC2_DAC2_CLK_SEL;
-
 
1097
	WREG32(RADEON_DAC_CNTL2, tmp);
-
 
1098
 
-
 
1099
	tmp = tv_master_cntl | RADEON_TV_ON;
-
 
1100
	tmp &= ~(RADEON_TV_ASYNC_RST |
-
 
1101
		 RADEON_RESTART_PHASE_FIX |
-
 
1102
		 RADEON_CRT_FIFO_CE_EN |
-
 
1103
		 RADEON_TV_FIFO_CE_EN |
-
 
1104
		 RADEON_RE_SYNC_NOW_SEL_MASK);
-
 
1105
	tmp |= RADEON_TV_FIFO_ASYNC_RST | RADEON_CRT_ASYNC_RST;
-
 
1106
	WREG32(RADEON_TV_MASTER_CNTL, tmp);
-
 
1107
 
-
 
1108
	tmp = RADEON_TV_DAC_NBLANK | RADEON_TV_DAC_NHOLD |
-
 
1109
		RADEON_TV_MONITOR_DETECT_EN | RADEON_TV_DAC_STD_NTSC |
-
 
1110
		(8 << RADEON_TV_DAC_BGADJ_SHIFT);
-
 
1111
 
-
 
1112
	if (config_cntl & RADEON_CFG_ATI_REV_ID_MASK)
-
 
1113
		tmp |= (4 << RADEON_TV_DAC_DACADJ_SHIFT);
-
 
1114
	else
-
 
1115
		tmp |= (8 << RADEON_TV_DAC_DACADJ_SHIFT);
-
 
1116
	WREG32(RADEON_TV_DAC_CNTL, tmp);
-
 
1117
 
-
 
1118
	tmp = RADEON_C_GRN_EN | RADEON_CMP_BLU_EN |
-
 
1119
		RADEON_RED_MX_FORCE_DAC_DATA |
-
 
1120
		RADEON_GRN_MX_FORCE_DAC_DATA |
-
 
1121
		RADEON_BLU_MX_FORCE_DAC_DATA |
-
 
1122
		(0x109 << RADEON_TV_FORCE_DAC_DATA_SHIFT);
-
 
1123
	WREG32(RADEON_TV_PRE_DAC_MUX_CNTL, tmp);
-
 
1124
 
-
 
1125
	mdelay(3);
-
 
1126
	tmp = RREG32(RADEON_TV_DAC_CNTL);
-
 
1127
	if (tmp & RADEON_TV_DAC_GDACDET) {
-
 
1128
		found = true;
-
 
1129
		DRM_DEBUG("S-video TV connection detected\n");
-
 
1130
	} else if ((tmp & RADEON_TV_DAC_BDACDET) != 0) {
-
 
1131
		found = true;
-
 
1132
		DRM_DEBUG("Composite TV connection detected\n");
-
 
1133
	}
-
 
1134
 
-
 
1135
	WREG32(RADEON_TV_PRE_DAC_MUX_CNTL, tv_pre_dac_mux_cntl);
-
 
1136
	WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
-
 
1137
	WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl);
1100
		radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
1138
	WREG32(RADEON_DAC_CNTL2, dac_cntl2);
1101
 
1139
	return found;
1102
}
1140
}
1103
 
1141
 
1104
static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder *encoder,
1142
static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder *encoder,
1105
							     struct drm_connector *connector)
1143
							     struct drm_connector *connector)
1106
{
1144
{
1107
	struct drm_device *dev = encoder->dev;
1145
	struct drm_device *dev = encoder->dev;
-
 
1146
	struct radeon_device *rdev = dev->dev_private;
-
 
1147
	uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
1108
	struct radeon_device *rdev = dev->dev_private;
1148
	uint32_t disp_hw_debug, disp_output_cntl, gpiopad_a, pixclks_cntl, tmp;
Line -... Line 1149...
-
 
1149
	enum drm_connector_status found = connector_status_disconnected;
-
 
1150
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-
 
1151
	struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
1109
	uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
1152
	bool color = true;
-
 
1153
 
-
 
1154
	if (connector->connector_type == DRM_MODE_CONNECTOR_SVIDEO ||
-
 
1155
	    connector->connector_type == DRM_MODE_CONNECTOR_Composite ||
-
 
1156
	    connector->connector_type == DRM_MODE_CONNECTOR_9PinDIN) {
-
 
1157
		bool tv_detect;
-
 
1158
 
-
 
1159
		if (radeon_encoder->active_device && !(radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT))
-
 
1160
			return connector_status_disconnected;
-
 
1161
 
-
 
1162
		tv_detect = radeon_legacy_tv_detect(encoder, connector);
-
 
1163
		if (tv_detect && tv_dac)
-
 
1164
			found = connector_status_connected;
-
 
1165
		return found;
-
 
1166
	}
-
 
1167
 
Line 1110... Line 1168...
1110
	uint32_t disp_hw_debug, disp_output_cntl, gpiopad_a, pixclks_cntl, tmp;
1168
	/* don't probe if the encoder is being used for something else not CRT related */
1111
	enum drm_connector_status found = connector_status_disconnected;
1169
	if (radeon_encoder->active_device && !(radeon_encoder->active_device & ATOM_DEVICE_CRT_SUPPORT)) {
1112
	bool color = true;
1170
		DRM_INFO("not detecting due to %08x\n", radeon_encoder->active_device);
1113
 
1171
		return connector_status_disconnected;
Line 1192... Line 1250...
1192
	} else {
1250
	} else {
1193
		WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1251
		WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1194
	}
1252
	}
1195
	WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
1253
	WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
Line 1196... Line 1254...
1196
 
1254
 
1197
	/* return found; */
-
 
Line 1198... Line 1255...
1198
	return connector_status_disconnected;
1255
	return found;
Line 1199... Line 1256...
1199
 
1256
 
1200
}
1257
}
1201
 
1258
 
1202
static const struct drm_encoder_helper_funcs radeon_legacy_tv_dac_helper_funcs = {
1259
static const struct drm_encoder_helper_funcs radeon_legacy_tv_dac_helper_funcs = {
1203
	.dpms = radeon_legacy_tv_dac_dpms,
1260
	.dpms = radeon_legacy_tv_dac_dpms,
1204
	.mode_fixup = radeon_legacy_tv_dac_mode_fixup,
1261
	.mode_fixup = radeon_legacy_tv_dac_mode_fixup,
1205
	.prepare = radeon_legacy_tv_dac_prepare,
1262
	.prepare = radeon_legacy_tv_dac_prepare,
-
 
1263
	.mode_set = radeon_legacy_tv_dac_mode_set,
1206
	.mode_set = radeon_legacy_tv_dac_mode_set,
1264
	.commit = radeon_legacy_tv_dac_commit,
Line 1207... Line 1265...
1207
	.commit = radeon_legacy_tv_dac_commit,
1265
	.detect = radeon_legacy_tv_dac_detect,
1208
	.detect = radeon_legacy_tv_dac_detect,
1266
	.disable = radeon_legacy_encoder_disable,
1209
};
1267
};
Line -... Line 1268...
-
 
1268
 
-
 
1269
 
-
 
1270
static const struct drm_encoder_funcs radeon_legacy_tv_dac_enc_funcs = {
-
 
1271
	.destroy = radeon_enc_destroy,
-
 
1272
};
-
 
1273
 
-
 
1274
 
-
 
1275
static struct radeon_encoder_int_tmds *radeon_legacy_get_tmds_info(struct radeon_encoder *encoder)
-
 
1276
{
-
 
1277
	struct drm_device *dev = encoder->base.dev;
-
 
1278
	struct radeon_device *rdev = dev->dev_private;
-
 
1279
	struct radeon_encoder_int_tmds *tmds = NULL;
-
 
1280
	bool ret;
-
 
1281
 
-
 
1282
	tmds = kzalloc(sizeof(struct radeon_encoder_int_tmds), GFP_KERNEL);
-
 
1283
 
-
 
1284
	if (!tmds)
-
 
1285
		return NULL;
-
 
1286
 
-
 
1287
	if (rdev->is_atom_bios)
-
 
1288
		ret = radeon_atombios_get_tmds_info(encoder, tmds);
-
 
1289
	else
-
 
1290
		ret = radeon_legacy_get_tmds_info_from_combios(encoder, tmds);
-
 
1291
 
1210
 
1292
	if (ret == false)
1211
 
1293
		radeon_legacy_get_tmds_info_from_table(encoder, tmds);
1212
static const struct drm_encoder_funcs radeon_legacy_tv_dac_enc_funcs = {
1294
 
1213
	.destroy = radeon_enc_destroy,
1295
	return tmds;
1214
};
1296
}
Line 1241... Line 1323...
1241
 
1323
 
Line 1242... Line 1324...
1242
	radeon_encoder->enc_priv = NULL;
1324
	radeon_encoder->enc_priv = NULL;
1243
 
1325
 
-
 
1326
	radeon_encoder->encoder_id = encoder_id;
Line 1244... Line 1327...
1244
	radeon_encoder->encoder_id = encoder_id;
1327
	radeon_encoder->devices = supported_device;
1245
	radeon_encoder->devices = supported_device;
1328
	radeon_encoder->rmx_type = RMX_OFF;
-
 
1329
 
1246
 
1330
	switch (radeon_encoder->encoder_id) {
1247
	switch (radeon_encoder->encoder_id) {
1331
	case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1248
	case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1332
		encoder->possible_crtcs = 0x1;
1249
		drm_encoder_init(dev, encoder, &radeon_legacy_lvds_enc_funcs, DRM_MODE_ENCODER_LVDS);
1333
		drm_encoder_init(dev, encoder, &radeon_legacy_lvds_enc_funcs, DRM_MODE_ENCODER_LVDS);
1250
		drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs);
1334
		drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs);
Line 1255... Line 1339...
1255
		radeon_encoder->rmx_type = RMX_FULL;
1339
		radeon_encoder->rmx_type = RMX_FULL;
1256
		break;
1340
		break;
1257
	case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1341
	case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
1258
		drm_encoder_init(dev, encoder, &radeon_legacy_tmds_int_enc_funcs, DRM_MODE_ENCODER_TMDS);
1342
		drm_encoder_init(dev, encoder, &radeon_legacy_tmds_int_enc_funcs, DRM_MODE_ENCODER_TMDS);
1259
		drm_encoder_helper_add(encoder, &radeon_legacy_tmds_int_helper_funcs);
1343
		drm_encoder_helper_add(encoder, &radeon_legacy_tmds_int_helper_funcs);
1260
		if (rdev->is_atom_bios)
-
 
1261
			radeon_encoder->enc_priv = radeon_atombios_get_tmds_info(radeon_encoder);
-
 
1262
		else
-
 
1263
			radeon_encoder->enc_priv = radeon_combios_get_tmds_info(radeon_encoder);
1344
		radeon_encoder->enc_priv = radeon_legacy_get_tmds_info(radeon_encoder);
1264
		break;
1345
		break;
1265
	case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1346
	case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1266
		drm_encoder_init(dev, encoder, &radeon_legacy_primary_dac_enc_funcs, DRM_MODE_ENCODER_DAC);
1347
		drm_encoder_init(dev, encoder, &radeon_legacy_primary_dac_enc_funcs, DRM_MODE_ENCODER_DAC);
1267
		drm_encoder_helper_add(encoder, &radeon_legacy_primary_dac_helper_funcs);
1348
		drm_encoder_helper_add(encoder, &radeon_legacy_primary_dac_helper_funcs);
1268
		if (rdev->is_atom_bios)
1349
		if (rdev->is_atom_bios)