Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 162628
Collapse All | Expand All

(-)aty-2.6.18/ati_ids.h (+32 lines)
Lines 31-36 Link Here
31
#define PCI_CHIP_RV360_AR               0x4152
31
#define PCI_CHIP_RV360_AR               0x4152
32
#define PCI_CHIP_RV350_AS               0x4153
32
#define PCI_CHIP_RV350_AS               0x4153
33
#define PCI_CHIP_RV350_AT               0x4154
33
#define PCI_CHIP_RV350_AT               0x4154
34
#define PCI_CHIP_RV350_AU 		0x4155
34
#define PCI_CHIP_RV350_AV               0x4156
35
#define PCI_CHIP_RV350_AV               0x4156
35
#define PCI_CHIP_MACH32			0x4158
36
#define PCI_CHIP_MACH32			0x4158
36
#define PCI_CHIP_RS250_4237		0x4237
37
#define PCI_CHIP_RS250_4237		0x4237
Lines 71-77 Link Here
71
#define PCI_CHIP_R420_JL                0x4A4C
72
#define PCI_CHIP_R420_JL                0x4A4C
72
#define PCI_CHIP_R420_JM                0x4A4D
73
#define PCI_CHIP_R420_JM                0x4A4D
73
#define PCI_CHIP_R420_JN                0x4A4E
74
#define PCI_CHIP_R420_JN                0x4A4E
75
#define PCI_CHIP_R420_JO 		0x4A4F
74
#define PCI_CHIP_R420_JP                0x4A50
76
#define PCI_CHIP_R420_JP                0x4A50
77
#define PCI_CHIP_R420_JT 		0x4A54
78
#define PCI_CHIP_R480_KI 		0x4B49
79
#define PCI_CHIP_R480_KJ 		0x4B4A
80
#define PCI_CHIP_R480_KK                0x4B4B
81
#define PCI_CHIP_R480_KL 		0x4B4C
75
#define PCI_CHIP_MACH64LB		0x4C42
82
#define PCI_CHIP_MACH64LB		0x4C42
76
#define PCI_CHIP_MACH64LD		0x4C44
83
#define PCI_CHIP_MACH64LD		0x4C44
77
#define PCI_CHIP_RAGE128LE		0x4C45
84
#define PCI_CHIP_RAGE128LE		0x4C45
Lines 182-190 Link Here
182
#define PCI_CHIP_R423_UI                0x5549
189
#define PCI_CHIP_R423_UI                0x5549
183
#define PCI_CHIP_R423_UJ                0x554A
190
#define PCI_CHIP_R423_UJ                0x554A
184
#define PCI_CHIP_R423_UK                0x554B
191
#define PCI_CHIP_R423_UK                0x554B
192
#define PCI_CHIP_R423_UL 		0x554C
193
#define PCI_CHIP_R423_UM 		0x554D
194
#define PCI_CHIP_R423_UN 		0x554E
195
#define PCI_CHIP_R423_UO 		0x554F
196
#define PCI_CHIP_R423_UP 	       	0x5550
185
#define PCI_CHIP_R423_UQ                0x5551
197
#define PCI_CHIP_R423_UQ                0x5551
186
#define PCI_CHIP_R423_UR                0x5552
198
#define PCI_CHIP_R423_UR                0x5552
187
#define PCI_CHIP_R423_UT                0x5554
199
#define PCI_CHIP_R423_UT                0x5554
200
#define PCI_CHIP_RV410_VJ 		0x564A
201
#define PCI_CHIP_RV410_VK 		0x564B
202
#define PCI_CHIP_RV410_VO 		0x564F
203
#define PCI_CHIP_RV410_VR 		0x5652
204
#define PCI_CHIP_RV410_VS 		0x5653
188
#define PCI_CHIP_MACH64VT		0x5654
205
#define PCI_CHIP_MACH64VT		0x5654
189
#define PCI_CHIP_MACH64VU		0x5655
206
#define PCI_CHIP_MACH64VU		0x5655
190
#define PCI_CHIP_MACH64VV		0x5656
207
#define PCI_CHIP_MACH64VV		0x5656
Lines 206-212 Link Here
206
#define PCI_CHIP_RV280_5964		0x5964
223
#define PCI_CHIP_RV280_5964		0x5964
207
#define PCI_CHIP_RV280_5C61		0x5C61
224
#define PCI_CHIP_RV280_5C61		0x5C61
208
#define PCI_CHIP_RV280_5C63		0x5C63
225
#define PCI_CHIP_RV280_5C63		0x5C63
226
#define PCI_CHIP_R423_5D48		0x5D48
227
#define PCI_CHIP_R423_5D49		0x5D49
228
#define PCI_CHIP_R423_5D4A		0x5D4A
229
#define PCI_CHIP_R480_5D4C		0x5D4C
230
#define PCI_CHIP_R480_5D4D		0x5D4D
231
#define PCI_CHIP_R480_5D4E		0x5D4E
232
#define PCI_CHIP_R480_5D4F		0x5D4F
233
#define PCI_CHIP_R480_5D50		0x5D50
234
#define PCI_CHIP_R480_5D52		0x5D52
209
#define PCI_CHIP_R423_5D57              0x5D57
235
#define PCI_CHIP_R423_5D57              0x5D57
236
#define PCI_CHIP_RV410_5E48		0x5E48
237
#define PCI_CHIP_RV410_5E4A		0x5E4A
238
#define PCI_CHIP_RV410_5E4B		0x5E4B
239
#define PCI_CHIP_RV410_5E4C		0x5E4C
240
#define PCI_CHIP_RV410_5E4D		0x5E4D
241
#define PCI_CHIP_RV410_5E4F		0x5E4F
210
#define PCI_CHIP_RS350_7834             0x7834
242
#define PCI_CHIP_RS350_7834             0x7834
211
#define PCI_CHIP_RS350_7835             0x7835
243
#define PCI_CHIP_RS350_7835             0x7835
212
244
(-)aty-2.6.18/radeon_accel.c (-12 / +7 lines)
Lines 203-211 Link Here
203
	host_path_cntl = INREG(HOST_PATH_CNTL);
203
	host_path_cntl = INREG(HOST_PATH_CNTL);
204
	rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
204
	rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
205
205
206
	if (rinfo->family == CHIP_FAMILY_R300 ||
206
	if (IS_R300_VARIANT(rinfo)) {
207
	    rinfo->family == CHIP_FAMILY_R350 ||
208
	    rinfo->family == CHIP_FAMILY_RV350) {
209
		u32 tmp;
207
		u32 tmp;
210
208
211
		OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
209
		OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
Lines 241-249 Link Here
241
	INREG(HOST_PATH_CNTL);
239
	INREG(HOST_PATH_CNTL);
242
	OUTREG(HOST_PATH_CNTL, host_path_cntl);
240
	OUTREG(HOST_PATH_CNTL, host_path_cntl);
243
241
244
	if (rinfo->family != CHIP_FAMILY_R300 ||
242
	if (IS_R300_VARIANT(rinfo))
245
	    rinfo->family != CHIP_FAMILY_R350 ||
246
	    rinfo->family != CHIP_FAMILY_RV350)
247
		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
243
		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
248
244
249
	OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
245
	OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
Lines 254-269 Link Here
254
{
250
{
255
	unsigned long temp;
251
	unsigned long temp;
256
252
257
	/* disable 3D engine */
258
	OUTREG(RB3D_CNTL, 0);
259
260
	radeonfb_engine_reset(rinfo);
253
	radeonfb_engine_reset(rinfo);
261
254
262
	radeon_fifo_wait (1);
255
	radeon_fifo_wait (1);
263
	if ((rinfo->family != CHIP_FAMILY_R300) &&
256
	if (IS_R300_VARIANT(rinfo)) {
264
	    (rinfo->family != CHIP_FAMILY_R350) &&
257
		temp = INREG(RB2D_DSTCACHE_MODE);
265
	    (rinfo->family != CHIP_FAMILY_RV350))
258
		OUTREG(RB2D_DSTCACHE_MODE, temp | (1<<17)); /* FIXME */
259
	} else {
266
		OUTREG(RB2D_DSTCACHE_MODE, 0);
260
		OUTREG(RB2D_DSTCACHE_MODE, 0);
261
	}
267
262
268
	radeon_fifo_wait (3);
263
	radeon_fifo_wait (3);
269
	/* We re-read MC_FB_LOCATION from card as it can have been
264
	/* We re-read MC_FB_LOCATION from card as it can have been
(-)aty-2.6.18/radeon_backlight.c (-2 / +2 lines)
Lines 58-64 Link Here
58
	u32 lvds_gen_cntl, tmpPixclksCntl;
58
	u32 lvds_gen_cntl, tmpPixclksCntl;
59
	int level;
59
	int level;
60
60
61
	if (rinfo->mon1_type != MT_LCD)
61
	if (PRIMARY_MONITOR(rinfo) != MT_LCD)
62
		return 0;
62
		return 0;
63
63
64
	/* We turn off the LCD completely instead of just dimming the
64
	/* We turn off the LCD completely instead of just dimming the
Lines 146-152 Link Here
146
	struct radeon_bl_privdata *pdata;
146
	struct radeon_bl_privdata *pdata;
147
	char name[12];
147
	char name[12];
148
148
149
	if (rinfo->mon1_type != MT_LCD)
149
	if (PRIMARY_MONITOR(rinfo) == MT_LCD) {
150
		return;
150
		return;
151
151
152
#ifdef CONFIG_PMAC_BACKLIGHT
152
#ifdef CONFIG_PMAC_BACKLIGHT
(-)aty-2.6.18/radeon_base.c (-128 / +327 lines)
Lines 3-8 Link Here
3
 *
3
 *
4
 *	framebuffer driver for ATI Radeon chipset video boards
4
 *	framebuffer driver for ATI Radeon chipset video boards
5
 *
5
 *
6
 *	Copyright 2006	Solomon Peachy <pizza@shaftnet.org>
6
 *	Copyright 2003	Ben. Herrenschmidt <benh@kernel.crashing.org>
7
 *	Copyright 2003	Ben. Herrenschmidt <benh@kernel.crashing.org>
7
 *	Copyright 2000	Ani Joshi <ajoshi@kernel.crashing.org>
8
 *	Copyright 2000	Ani Joshi <ajoshi@kernel.crashing.org>
8
 *
9
 *
Lines 50-56 Link Here
50
 */
51
 */
51
52
52
53
53
#define RADEON_VERSION	"0.2.0"
54
#define RADEON_VERSION	"0.3.0"
54
55
55
#include <linux/module.h>
56
#include <linux/module.h>
56
#include <linux/moduleparam.h>
57
#include <linux/moduleparam.h>
Lines 180-185 Link Here
180
	CHIP_DEF(PCI_CHIP_RV360_AR,	RV350,	CHIP_HAS_CRTC2),
181
	CHIP_DEF(PCI_CHIP_RV360_AR,	RV350,	CHIP_HAS_CRTC2),
181
	CHIP_DEF(PCI_CHIP_RV350_AS,	RV350,	CHIP_HAS_CRTC2),
182
	CHIP_DEF(PCI_CHIP_RV350_AS,	RV350,	CHIP_HAS_CRTC2),
182
	CHIP_DEF(PCI_CHIP_RV350_AT,	RV350,	CHIP_HAS_CRTC2),
183
	CHIP_DEF(PCI_CHIP_RV350_AT,	RV350,	CHIP_HAS_CRTC2),
184
	CHIP_DEF(PCI_CHIP_RV350_AU, 	RV350,	CHIP_HAS_CRTC2),
183
	CHIP_DEF(PCI_CHIP_RV350_AV,	RV350,	CHIP_HAS_CRTC2),
185
	CHIP_DEF(PCI_CHIP_RV350_AV,	RV350,	CHIP_HAS_CRTC2),
184
	/* 9800/Pro/FileGL X2 */
186
	/* 9800/Pro/FileGL X2 */
185
	CHIP_DEF(PCI_CHIP_R350_AH,	R350,	CHIP_HAS_CRTC2),
187
	CHIP_DEF(PCI_CHIP_R350_AH,	R350,	CHIP_HAS_CRTC2),
Lines 190-196 Link Here
190
	CHIP_DEF(PCI_CHIP_R350_NI,	R350,	CHIP_HAS_CRTC2),
192
	CHIP_DEF(PCI_CHIP_R350_NI,	R350,	CHIP_HAS_CRTC2),
191
	CHIP_DEF(PCI_CHIP_R360_NJ,	R350,	CHIP_HAS_CRTC2),
193
	CHIP_DEF(PCI_CHIP_R360_NJ,	R350,	CHIP_HAS_CRTC2),
192
	CHIP_DEF(PCI_CHIP_R350_NK,	R350,	CHIP_HAS_CRTC2),
194
	CHIP_DEF(PCI_CHIP_R350_NK,	R350,	CHIP_HAS_CRTC2),
193
	/* Newer stuff */
195
	/* X300/X600 */
194
	CHIP_DEF(PCI_CHIP_RV380_3E50,	RV380,	CHIP_HAS_CRTC2),
196
	CHIP_DEF(PCI_CHIP_RV380_3E50,	RV380,	CHIP_HAS_CRTC2),
195
	CHIP_DEF(PCI_CHIP_RV380_3E54,	RV380,	CHIP_HAS_CRTC2),
197
	CHIP_DEF(PCI_CHIP_RV380_3E54,	RV380,	CHIP_HAS_CRTC2),
196
	CHIP_DEF(PCI_CHIP_RV380_3150,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
198
	CHIP_DEF(PCI_CHIP_RV380_3150,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
Lines 201-206 Link Here
201
	CHIP_DEF(PCI_CHIP_RV370_5B65,	RV380,	CHIP_HAS_CRTC2),
203
	CHIP_DEF(PCI_CHIP_RV370_5B65,	RV380,	CHIP_HAS_CRTC2),
202
	CHIP_DEF(PCI_CHIP_RV370_5460,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
204
	CHIP_DEF(PCI_CHIP_RV370_5460,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
203
	CHIP_DEF(PCI_CHIP_RV370_5464,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
205
	CHIP_DEF(PCI_CHIP_RV370_5464,	RV380,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
206
	/* X700 */
207
	CHIP_DEF(PCI_CHIP_RV410_VJ, 	RV410,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
208
	CHIP_DEF(PCI_CHIP_RV410_VK, 	RV410,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
209
	CHIP_DEF(PCI_CHIP_RV410_VO, 	RV410,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
210
	CHIP_DEF(PCI_CHIP_RV410_VR, 	RV410,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
211
	CHIP_DEF(PCI_CHIP_RV410_VS, 	RV410,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
212
	CHIP_DEF(PCI_CHIP_RV410_5E48,	RV410,	CHIP_HAS_CRTC2),
213
	CHIP_DEF(PCI_CHIP_RV410_5E4A,	RV410,	CHIP_HAS_CRTC2),
214
	CHIP_DEF(PCI_CHIP_RV410_5E4B,	RV410,	CHIP_HAS_CRTC2),
215
	CHIP_DEF(PCI_CHIP_RV410_5E4C,	RV410,	CHIP_HAS_CRTC2),
216
	CHIP_DEF(PCI_CHIP_RV410_5E4D,	RV410,	CHIP_HAS_CRTC2),
217
	CHIP_DEF(PCI_CHIP_RV410_5E4F,	RV410,	CHIP_HAS_CRTC2),
218
	/* X800/X850 */
204
	CHIP_DEF(PCI_CHIP_R420_JH,	R420,	CHIP_HAS_CRTC2),
219
	CHIP_DEF(PCI_CHIP_R420_JH,	R420,	CHIP_HAS_CRTC2),
205
	CHIP_DEF(PCI_CHIP_R420_JI,	R420,	CHIP_HAS_CRTC2),
220
	CHIP_DEF(PCI_CHIP_R420_JI,	R420,	CHIP_HAS_CRTC2),
206
	CHIP_DEF(PCI_CHIP_R420_JJ,	R420,	CHIP_HAS_CRTC2),
221
	CHIP_DEF(PCI_CHIP_R420_JJ,	R420,	CHIP_HAS_CRTC2),
Lines 208-214 Link Here
208
	CHIP_DEF(PCI_CHIP_R420_JL,	R420,	CHIP_HAS_CRTC2),
223
	CHIP_DEF(PCI_CHIP_R420_JL,	R420,	CHIP_HAS_CRTC2),
209
	CHIP_DEF(PCI_CHIP_R420_JM,	R420,	CHIP_HAS_CRTC2),
224
	CHIP_DEF(PCI_CHIP_R420_JM,	R420,	CHIP_HAS_CRTC2),
210
	CHIP_DEF(PCI_CHIP_R420_JN,	R420,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
225
	CHIP_DEF(PCI_CHIP_R420_JN,	R420,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
226
	CHIP_DEF(PCI_CHIP_R420_JO, 	R420,	CHIP_HAS_CRTC2),
211
	CHIP_DEF(PCI_CHIP_R420_JP,	R420,	CHIP_HAS_CRTC2),
227
	CHIP_DEF(PCI_CHIP_R420_JP,	R420,	CHIP_HAS_CRTC2),
228
	CHIP_DEF(PCI_CHIP_R420_JT, 	R420,	CHIP_HAS_CRTC2),
212
	CHIP_DEF(PCI_CHIP_R423_UH,	R420,	CHIP_HAS_CRTC2),
229
	CHIP_DEF(PCI_CHIP_R423_UH,	R420,	CHIP_HAS_CRTC2),
213
	CHIP_DEF(PCI_CHIP_R423_UI,	R420,	CHIP_HAS_CRTC2),
230
	CHIP_DEF(PCI_CHIP_R423_UI,	R420,	CHIP_HAS_CRTC2),
214
	CHIP_DEF(PCI_CHIP_R423_UJ,	R420,	CHIP_HAS_CRTC2),
231
	CHIP_DEF(PCI_CHIP_R423_UJ,	R420,	CHIP_HAS_CRTC2),
Lines 217-222 Link Here
217
	CHIP_DEF(PCI_CHIP_R423_UR,	R420,	CHIP_HAS_CRTC2),
234
	CHIP_DEF(PCI_CHIP_R423_UR,	R420,	CHIP_HAS_CRTC2),
218
	CHIP_DEF(PCI_CHIP_R423_UT,	R420,	CHIP_HAS_CRTC2),
235
	CHIP_DEF(PCI_CHIP_R423_UT,	R420,	CHIP_HAS_CRTC2),
219
	CHIP_DEF(PCI_CHIP_R423_5D57,	R420,	CHIP_HAS_CRTC2),
236
	CHIP_DEF(PCI_CHIP_R423_5D57,	R420,	CHIP_HAS_CRTC2),
237
	CHIP_DEF(PCI_CHIP_R423_UP, 	R420,	CHIP_HAS_CRTC2),
238
	CHIP_DEF(PCI_CHIP_R423_5D49, 	R420,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
239
	CHIP_DEF(PCI_CHIP_R423_5D4A, 	R420,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
240
	CHIP_DEF(PCI_CHIP_R423_5D48, 	R420,	CHIP_HAS_CRTC2 | CHIP_IS_MOBILITY),
241
	CHIP_DEF(PCI_CHIP_R423_UO, 	R420,	CHIP_HAS_CRTC2),
242
	CHIP_DEF(PCI_CHIP_R423_UM, 	R420,	CHIP_HAS_CRTC2),
243
	CHIP_DEF(PCI_CHIP_R423_UN, 	R420,	CHIP_HAS_CRTC2),
244
	CHIP_DEF(PCI_CHIP_R423_UL, 	R420,	CHIP_HAS_CRTC2),
245
	CHIP_DEF(PCI_CHIP_R480_5D4C, 	R420,	CHIP_HAS_CRTC2),
246
	CHIP_DEF(PCI_CHIP_R480_5D50, 	R420,	CHIP_HAS_CRTC2),
247
	CHIP_DEF(PCI_CHIP_R480_5D4E, 	R420,	CHIP_HAS_CRTC2),
248
	CHIP_DEF(PCI_CHIP_R480_5D4F, 	R420,	CHIP_HAS_CRTC2),
249
	CHIP_DEF(PCI_CHIP_R480_5D52, 	R420,	CHIP_HAS_CRTC2),
250
	CHIP_DEF(PCI_CHIP_R480_5D4D, 	R420,	CHIP_HAS_CRTC2),
251
	CHIP_DEF(PCI_CHIP_R480_KJ, 	R420,	CHIP_HAS_CRTC2),
252
	CHIP_DEF(PCI_CHIP_R480_KK,    R420,     CHIP_HAS_CRTC2),
253
	CHIP_DEF(PCI_CHIP_R480_KI, 	R420,	CHIP_HAS_CRTC2),
254
	CHIP_DEF(PCI_CHIP_R480_KL, 	R420,	CHIP_HAS_CRTC2),
220
	/* Original Radeon/7200 */
255
	/* Original Radeon/7200 */
221
	CHIP_DEF(PCI_CHIP_RADEON_QD,	RADEON,	0),
256
	CHIP_DEF(PCI_CHIP_RADEON_QD,	RADEON,	0),
222
	CHIP_DEF(PCI_CHIP_RADEON_QE,	RADEON,	0),
257
	CHIP_DEF(PCI_CHIP_RADEON_QE,	RADEON,	0),
Lines 259-264 Link Here
259
static int default_dynclk = -2;
294
static int default_dynclk = -2;
260
static int nomodeset = 0;
295
static int nomodeset = 0;
261
static int ignore_edid = 0;
296
static int ignore_edid = 0;
297
static int ignore_conntable = 0;
262
static int mirror = 0;
298
static int mirror = 0;
263
static int panel_yres = 0;
299
static int panel_yres = 0;
264
static int force_dfp = 0;
300
static int force_dfp = 0;
Lines 269-274 Link Here
269
static int force_sleep;
305
static int force_sleep;
270
static int ignore_devlist;
306
static int ignore_devlist;
271
307
308
#ifdef CONFIG_FB_RADEON_DEBUG
309
int radeonfb_debug = 1;
310
#else
311
int radeonfb_debug = 0;
312
#endif
313
272
/*
314
/*
273
 * prototypes
315
 * prototypes
274
 */
316
 */
Lines 324-330 Link Here
324
	 * to phase out Open Firmware images.
366
	 * to phase out Open Firmware images.
325
	 *
367
	 *
326
	 * Currently, we only look at the first PCI data, we could iteratre and deal with
368
	 * Currently, we only look at the first PCI data, we could iteratre and deal with
327
	 * them all, and we should use fb_bios_start relative to start of image and not
369
	 * them all, and we should use fp_bios_start relative to start of image and not
328
	 * relative start of ROM, but so far, I never found a dual-image ATI card
370
	 * relative start of ROM, but so far, I never found a dual-image ATI card
329
	 *
371
	 *
330
	 * typedef struct {
372
	 * typedef struct {
Lines 410-416 Link Here
410
 * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device
452
 * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device
411
 * tree. Hopefully, ATI OF driver is kind enough to fill these
453
 * tree. Hopefully, ATI OF driver is kind enough to fill these
412
 */
454
 */
413
static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo)
455
static int __devinit radeon_get_pll_info_openfirmware (struct radeonfb_info *rinfo)
414
{
456
{
415
	struct device_node *dp = rinfo->of_node;
457
	struct device_node *dp = rinfo->of_node;
416
	u32 *val;
458
	u32 *val;
Lines 433-438 Link Here
433
	if (val && *val)
475
	if (val && *val)
434
		rinfo->pll.mclk = (*val) / 10;
476
		rinfo->pll.mclk = (*val) / 10;
435
477
478
	RTRACE("Retrieved PLL infos from Open Firmware\n");
436
       	return 0;
479
       	return 0;
437
}
480
}
438
#endif /* CONFIG_PPC_OF */
481
#endif /* CONFIG_PPC_OF */
Lines 575-584 Link Here
575
	return 0;
618
	return 0;
576
}
619
}
577
620
621
static int __devinit radeon_get_pll_info_legacy(struct radeonfb_info *rinfo)
622
{
623
	u16 pll_info_block;
624
625
	if (!rinfo->bios_seg)
626
		return -EINVAL;
627
628
	pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
629
	
630
	rinfo->pll.sclk		= BIOS_IN16(pll_info_block + 0x08);
631
	rinfo->pll.mclk		= BIOS_IN16(pll_info_block + 0x0a);
632
	rinfo->pll.ref_clk	= BIOS_IN16(pll_info_block + 0x0e);
633
	rinfo->pll.ref_div	= BIOS_IN16(pll_info_block + 0x10);
634
	rinfo->pll.ppll_min	= BIOS_IN32(pll_info_block + 0x12);
635
	rinfo->pll.ppll_max	= BIOS_IN32(pll_info_block + 0x16);
636
637
	RTRACE("Retrieved PLL infos from Legacy BIOS\n");
638
	return 0;
639
}
640
641
642
static int __devinit radeon_get_pll_info_atom(struct radeonfb_info *rinfo)
643
{
644
	u16 pll_info_block;
645
646
	if (!rinfo->bios_seg)
647
		return -EINVAL;
648
649
	pll_info_block = BIOS_IN16(rinfo->atom_data_start + 12);
650
	
651
	rinfo->pll.sclk = BIOS_IN32(pll_info_block + 8);
652
	rinfo->pll.mclk = BIOS_IN32(pll_info_block + 12);
653
	rinfo->pll.ref_clk = BIOS_IN16(pll_info_block + 82);
654
	rinfo->pll.ref_div = 0; /* Have to get it elsewhere */
655
	rinfo->pll.ppll_min = BIOS_IN16(pll_info_block + 78);
656
	rinfo->pll.ppll_max = BIOS_IN32(pll_info_block + 32);
657
658
	RTRACE("Retrieved PLL infos from ATOM BIOS\n");
659
	return 0;
660
}
661
662
static void radeon_detect_bios_type(struct radeonfb_info *rinfo)
663
{
664
#ifdef CONFIG_PPC_OF
665
	  rinfo->is_atom_bios = 0;
666
	  rinfo->get_pll_info = radeon_get_pll_info_openfirmware;
667
	  rinfo->get_lvds_info = radeon_get_lvds_info_openfirmware;
668
	  rinfo->radeon_get_tmds_info = NULL;
669
	  rinfo->get_conn_info = radeon_get_conn_info_openfirmware;
670
#else
671
	  int tmp = rinfo->fp_bios_start + 4;
672
673
	  if ((BIOS_IN8(tmp) == 'A' &&
674
	       BIOS_IN8(tmp+1) == 'T' &&
675
	       BIOS_IN8(tmp+2) == 'O' &&
676
	       BIOS_IN8(tmp+3) == 'M') ||
677
	      (BIOS_IN8(tmp) == 'M' &&
678
	       BIOS_IN8(tmp+1) == 'O' &&
679
	       BIOS_IN8(tmp+2) == 'T' &&
680
	       BIOS_IN8(tmp+3) == 'A')) {
681
		  rinfo->is_atom_bios = 1;
682
683
		  rinfo->atom_data_start = BIOS_IN16(rinfo->fp_bios_start + 32);
684
		  rinfo->radeon_get_pll_info = radeon_get_pll_info_atom;
685
		  rinfo->radeon_get_lvds_info = radeon_get_lvds_info_atom;
686
		  rinfo->radeon_get_conn_info = radeon_get_conn_info_atom;
687
		  rinfo->radeon_get_tmds_info = radeon_get_tmds_info_atom;
688
	  } else {
689
		  rinfo->is_atom_bios = 0;
690
		  rinfo->radeon_get_pll_info = radeon_get_pll_info_legacy;
691
		  rinfo->radeon_get_lvds_info = radeon_get_lvds_info_legacy;
692
		  rinfo->radeon_get_conn_info = radeon_get_conn_info_legacy;
693
		  rinfo->radeon_get_tmds_info = radeon_get_tmds_info_legacy;
694
	  }
695
#endif  /* CONFIG_PPC_OF */
696
697
}
698
578
/*
699
/*
579
 * Retrieve PLL infos by different means (BIOS, Open Firmware, register probing...)
700
 * Retrieve PLL infos by different means (BIOS, Open Firmware, register probing...)
580
 */
701
 */
581
static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
702
static void __devinit radeon_get_pll_info(struct radeonfb_info *rinfo)
582
{
703
{
583
	/*
704
	/*
584
	 * In the case nothing works, these are defaults; they are mostly
705
	 * In the case nothing works, these are defaults; they are mostly
Lines 630-675 Link Here
630
	case PCI_DEVICE_ID_ATI_RADEON_QF:
751
	case PCI_DEVICE_ID_ATI_RADEON_QF:
631
	case PCI_DEVICE_ID_ATI_RADEON_QG:
752
	case PCI_DEVICE_ID_ATI_RADEON_QG:
632
	default:
753
	default:
633
		rinfo->pll.ppll_max = 35000;
754
		if (rinfo->family == CHIP_FAMILY_R420) {
634
		rinfo->pll.ppll_min = 12000;
755
			rinfo->pll.ppll_max = 50000;
756
			rinfo->pll.ppll_min = 20000;
757
		} else {
758
			rinfo->pll.ppll_max = 35000;
759
			rinfo->pll.ppll_min = 12000;
760
		}
635
		rinfo->pll.mclk = 16600;
761
		rinfo->pll.mclk = 16600;
636
		rinfo->pll.sclk = 16600;
762
		rinfo->pll.sclk = 16600;
637
		rinfo->pll.ref_clk = 2700;
763
		rinfo->pll.ref_clk = 2700;
638
		break;
764
		break;
639
	}
765
	}
640
	rinfo->pll.ref_div = INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK;
641
642
766
643
#ifdef CONFIG_PPC_OF
644
	/*
767
	/*
645
	 * Retrieve PLL infos from Open Firmware first
768
	 * If we have a way to retrieve the PLL information, do so.
646
	 */
769
	 */
647
       	if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) {
770
	if (!force_measure_pll && rinfo->radeon_get_pll_info) {
648
       		printk(KERN_INFO "radeonfb: Retrieved PLL infos from Open Firmware\n");
771
		if (!rinfo->radeon_get_pll_info(rinfo)) {
649
		goto found;
772
			goto found;
650
	}
773
		}
651
#endif /* CONFIG_PPC_OF */
652
653
	/*
654
	 * Check out if we have an X86 which gave us some PLL informations
655
	 * and if yes, retrieve them
656
	 */
657
	if (!force_measure_pll && rinfo->bios_seg) {
658
		u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
659
660
		rinfo->pll.sclk		= BIOS_IN16(pll_info_block + 0x08);
661
		rinfo->pll.mclk		= BIOS_IN16(pll_info_block + 0x0a);
662
		rinfo->pll.ref_clk	= BIOS_IN16(pll_info_block + 0x0e);
663
		rinfo->pll.ref_div	= BIOS_IN16(pll_info_block + 0x10);
664
		rinfo->pll.ppll_min	= BIOS_IN32(pll_info_block + 0x12);
665
		rinfo->pll.ppll_max	= BIOS_IN32(pll_info_block + 0x16);
666
667
		printk(KERN_INFO "radeonfb: Retrieved PLL infos from BIOS\n");
668
		goto found;
669
	}
774
	}
670
775
671
	/*
776
	/*
672
	 * We didn't get PLL parameters from either OF or BIOS, we try to
777
	 * If we don't get the PLL parameters handed to us, we try to
673
	 * probe them
778
	 * probe them
674
	 */
779
	 */
675
	if (radeon_probe_pll_params(rinfo) == 0) {
780
	if (radeon_probe_pll_params(rinfo) == 0) {
Lines 683-688 Link Here
683
       	printk(KERN_INFO "radeonfb: Used default PLL infos\n");
788
       	printk(KERN_INFO "radeonfb: Used default PLL infos\n");
684
789
685
found:
790
found:
791
792
	/* Check and fix-up the PLL divisor if necessary */
793
	if (rinfo->pll.ref_div < 2) {
794
		int tmp = INPLL(PPLL_REF_DIV);
795
		if (rinfo->family == CHIP_FAMILY_RS300) {
796
			rinfo->pll.ref_div = (tmp & R300_PPLL_REF_DIV_ACC_MASK) >> R300_PPLL_REF_DIV_ACC_SHIFT;
797
		} else {
798
			rinfo->pll.ref_div = tmp & PPLL_REF_DIV_MASK;
799
		}
800
		
801
		/* Sane default */
802
		if (rinfo->pll.ref_div < 2) {		
803
			rinfo->pll.ref_div = 12;
804
		}
805
	}		
806
686
	/*
807
	/*
687
	 * Some methods fail to retrieve SCLK and MCLK values, we apply default
808
	 * Some methods fail to retrieve SCLK and MCLK values, we apply default
688
	 * settings in this case (200Mhz). If that really happne often, we could
809
	 * settings in this case (200Mhz). If that really happne often, we could
Lines 698-704 Link Here
698
	       rinfo->pll.ref_div,
819
	       rinfo->pll.ref_div,
699
	       rinfo->pll.mclk / 100, rinfo->pll.mclk % 100,
820
	       rinfo->pll.mclk / 100, rinfo->pll.mclk % 100,
700
	       rinfo->pll.sclk / 100, rinfo->pll.sclk % 100);
821
	       rinfo->pll.sclk / 100, rinfo->pll.sclk % 100);
701
	printk("radeonfb: PLL min %d max %d\n", rinfo->pll.ppll_min, rinfo->pll.ppll_max);
822
	RTRACE("PLL min %d max %d\n", rinfo->pll.ppll_min, rinfo->pll.ppll_max);
702
}
823
}
703
824
704
static int radeonfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
825
static int radeonfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info)
Lines 839-845 Link Here
839
        if (rinfo->asleep)
960
        if (rinfo->asleep)
840
        	return 0;
961
        	return 0;
841
962
842
	radeon_fifo_wait(2);
963
	radeon_engine_idle();
843
        OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset)
964
        OUTREG(CRTC_OFFSET, ((var->yoffset * var->xres_virtual + var->xoffset)
844
			     * var->bits_per_pixel / 8) & ~7);
965
			     * var->bits_per_pixel / 8) & ~7);
845
        return 0;
966
        return 0;
Lines 923-928 Link Here
923
        u32 val;
1044
        u32 val;
924
	u32 tmp_pix_clks;
1045
	u32 tmp_pix_clks;
925
	int unblank = 0;
1046
	int unblank = 0;
1047
	int i;
926
1048
927
	if (rinfo->lock_blank)
1049
	if (rinfo->lock_blank)
928
		return 0;
1050
		return 0;
Lines 952-1029 Link Here
952
        }
1074
        }
953
	OUTREG(CRTC_EXT_CNTL, val);
1075
	OUTREG(CRTC_EXT_CNTL, val);
954
1076
1077
	for (i = 0 ; i < RADEON_MAX_CONNECTORS ; i++) {
1078
		if (i == -1) continue;
955
1079
956
	switch (rinfo->mon1_type) {
1080
		switch (rinfo->connectors[rinfo->heads[i]].mon_type) {
957
	case MT_DFP:
1081
		case MT_DFP:
958
		if (unblank)
1082
			if (unblank)
959
			OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN),
1083
				OUTREGP(FP_GEN_CNTL, (FP_FPON | FP_TMDS_EN),
960
				~(FP_FPON | FP_TMDS_EN));
1084
					~(FP_FPON | FP_TMDS_EN));
961
		else {
1085
			else {
962
			if (mode_switch || blank == FB_BLANK_NORMAL)
1086
				if (mode_switch || blank == FB_BLANK_NORMAL)
963
				break;
1087
					break;
964
			OUTREGP(FP_GEN_CNTL, 0, ~(FP_FPON | FP_TMDS_EN));
1088
				OUTREGP(FP_GEN_CNTL, 0, ~(FP_FPON | FP_TMDS_EN));
965
		}
1089
			}
966
		break;
1090
		break;
967
	case MT_LCD:
1091
		case MT_LCD:
968
		del_timer_sync(&rinfo->lvds_timer);
1092
			del_timer_sync(&rinfo->lvds_timer);
969
		val = INREG(LVDS_GEN_CNTL);
1093
			val = INREG(LVDS_GEN_CNTL);
970
		if (unblank) {
1094
			if (unblank) {
971
			u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON
1095
				u32 target_val = (val & ~LVDS_DISPLAY_DIS) | LVDS_BLON | LVDS_ON
972
				| LVDS_EN | (rinfo->init_state.lvds_gen_cntl
1096
					| LVDS_EN | (rinfo->init_state.lvds_gen_cntl
973
					     & (LVDS_DIGON | LVDS_BL_MOD_EN));
1097
						     & (LVDS_DIGON | LVDS_BL_MOD_EN));
974
			if ((val ^ target_val) == LVDS_DISPLAY_DIS)
1098
				if ((val ^ target_val) == LVDS_DISPLAY_DIS)
975
				OUTREG(LVDS_GEN_CNTL, target_val);
976
			else if ((val ^ target_val) != 0) {
977
				OUTREG(LVDS_GEN_CNTL, target_val
978
				       & ~(LVDS_ON | LVDS_BL_MOD_EN));
979
				rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
980
				rinfo->init_state.lvds_gen_cntl |=
981
					target_val & LVDS_STATE_MASK;
982
				if (mode_switch) {
983
					radeon_msleep(rinfo->panel_info.pwr_delay);
984
					OUTREG(LVDS_GEN_CNTL, target_val);
1099
					OUTREG(LVDS_GEN_CNTL, target_val);
1100
				else if ((val ^ target_val) != 0) {
1101
					OUTREG(LVDS_GEN_CNTL, target_val
1102
					       & ~(LVDS_ON | LVDS_BL_MOD_EN));
1103
					rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
1104
					rinfo->init_state.lvds_gen_cntl |=
1105
						target_val & LVDS_STATE_MASK;
1106
					if (mode_switch) {
1107
						radeon_msleep(rinfo->panel_info.pwr_delay);
1108
						OUTREG(LVDS_GEN_CNTL, target_val);
1109
					} else {
1110
						rinfo->pending_lvds_gen_cntl = target_val;
1111
						mod_timer(&rinfo->lvds_timer,
1112
							  jiffies +
1113
							  msecs_to_jiffies(rinfo->panel_info.pwr_delay));
1114
					}
985
				}
1115
				}
986
				else {
1116
			} else {
987
					rinfo->pending_lvds_gen_cntl = target_val;
1117
				val |= LVDS_DISPLAY_DIS;
988
					mod_timer(&rinfo->lvds_timer,
1118
				OUTREG(LVDS_GEN_CNTL, val);
989
					   jiffies +
1119
				
990
					   msecs_to_jiffies(rinfo->panel_info.pwr_delay));
1120
				/* We don't do a full switch-off on a simple mode switch */
991
				}
1121
				if (mode_switch || blank == FB_BLANK_NORMAL)
1122
					break;
1123
				
1124
				/* Asic bug, when turning off LVDS_ON, we have to make sure
1125
				 * RADEON_PIXCLK_LVDS_ALWAYS_ON bit is off
1126
				 */
1127
				tmp_pix_clks = INPLL(PIXCLKS_CNTL);
1128
				if (rinfo->is_mobility || rinfo->is_IGP)
1129
					OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
1130
				val &= ~(LVDS_BL_MOD_EN);
1131
				OUTREG(LVDS_GEN_CNTL, val);
1132
				udelay(100);
1133
				val &= ~(LVDS_ON | LVDS_EN);
1134
				OUTREG(LVDS_GEN_CNTL, val);
1135
				val &= ~LVDS_DIGON;
1136
				rinfo->pending_lvds_gen_cntl = val;
1137
				mod_timer(&rinfo->lvds_timer,
1138
					  jiffies +
1139
					  msecs_to_jiffies(rinfo->panel_info.pwr_delay));
1140
				rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
1141
				rinfo->init_state.lvds_gen_cntl |= val & LVDS_STATE_MASK;
1142
				if (rinfo->is_mobility || rinfo->is_IGP)
1143
					OUTPLL(PIXCLKS_CNTL, tmp_pix_clks);
992
			}
1144
			}
993
		} else {
1145
			break;
994
			val |= LVDS_DISPLAY_DIS;
1146
		case MT_CRT:
995
			OUTREG(LVDS_GEN_CNTL, val);
1147
			// todo: powerdown DAC
996
1148
		default:
997
			/* We don't do a full switch-off on a simple mode switch */
1149
			break;
998
			if (mode_switch || blank == FB_BLANK_NORMAL)
999
				break;
1000
1001
			/* Asic bug, when turning off LVDS_ON, we have to make sure
1002
			 * RADEON_PIXCLK_LVDS_ALWAYS_ON bit is off
1003
			 */
1004
			tmp_pix_clks = INPLL(PIXCLKS_CNTL);
1005
			if (rinfo->is_mobility || rinfo->is_IGP)
1006
				OUTPLLP(PIXCLKS_CNTL, 0, ~PIXCLK_LVDS_ALWAYS_ONb);
1007
			val &= ~(LVDS_BL_MOD_EN);
1008
			OUTREG(LVDS_GEN_CNTL, val);
1009
			udelay(100);
1010
			val &= ~(LVDS_ON | LVDS_EN);
1011
			OUTREG(LVDS_GEN_CNTL, val);
1012
			val &= ~LVDS_DIGON;
1013
			rinfo->pending_lvds_gen_cntl = val;
1014
			mod_timer(&rinfo->lvds_timer,
1015
				  jiffies +
1016
				  msecs_to_jiffies(rinfo->panel_info.pwr_delay));
1017
			rinfo->init_state.lvds_gen_cntl &= ~LVDS_STATE_MASK;
1018
			rinfo->init_state.lvds_gen_cntl |= val & LVDS_STATE_MASK;
1019
			if (rinfo->is_mobility || rinfo->is_IGP)
1020
				OUTPLL(PIXCLKS_CNTL, tmp_pix_clks);
1021
		}
1150
		}
1022
		break;
1023
	case MT_CRT:
1024
		// todo: powerdown DAC
1025
	default:
1026
		break;
1027
	}
1151
	}
1028
1152
1029
	/* let fbcon do a soft blank for us */
1153
	/* let fbcon do a soft blank for us */
Lines 1274-1283 Link Here
1274
	radeon_pll_errata_after_data(rinfo);
1398
	radeon_pll_errata_after_data(rinfo);
1275
1399
1276
	/* Set PPLL ref. div */
1400
	/* Set PPLL ref. div */
1277
	if (rinfo->family == CHIP_FAMILY_R300 ||
1401
	if (IS_R300_VARIANT(rinfo) || (rinfo->family == CHIP_FAMILY_RS300)) {
1278
	    rinfo->family == CHIP_FAMILY_RS300 ||
1279
	    rinfo->family == CHIP_FAMILY_R350 ||
1280
	    rinfo->family == CHIP_FAMILY_RV350) {
1281
		if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
1402
		if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
1282
			/* When restoring console mode, use saved PPLL_REF_DIV
1403
			/* When restoring console mode, use saved PPLL_REF_DIV
1283
			 * setting.
1404
			 * setting.
Lines 1374-1379 Link Here
1374
	OUTREG(CRTC_OFFSET_CNTL, 0);
1495
	OUTREG(CRTC_OFFSET_CNTL, 0);
1375
	OUTREG(CRTC_PITCH, mode->crtc_pitch);
1496
	OUTREG(CRTC_PITCH, mode->crtc_pitch);
1376
	OUTREG(SURFACE_CNTL, mode->surface_cntl);
1497
	OUTREG(SURFACE_CNTL, mode->surface_cntl);
1498
	OUTREG(DISP_MERGE_CNTL, 0xffff0000);
1377
1499
1378
	radeon_write_pll_regs(rinfo, mode);
1500
	radeon_write_pll_regs(rinfo, mode);
1379
1501
Lines 1884-1890 Link Here
1884
        info->fix.ywrapstep = 0;
2006
        info->fix.ywrapstep = 0;
1885
        info->fix.type_aux = 0;
2007
        info->fix.type_aux = 0;
1886
        info->fix.mmio_start = rinfo->mmio_base_phys;
2008
        info->fix.mmio_start = rinfo->mmio_base_phys;
1887
        info->fix.mmio_len = RADEON_REGSIZE;
2009
        info->fix.mmio_len = pci_resource_len(rinfo->pdev, 2);
1888
	info->fix.accel = FB_ACCEL_ATI_RADEON;
2010
	info->fix.accel = FB_ACCEL_ATI_RADEON;
1889
2011
1890
	fb_alloc_cmap(&info->cmap, 256, 0);
2012
	fb_alloc_cmap(&info->cmap, 256, 0);
Lines 1988-1996 Link Here
1988
	u32 tmp;
2110
	u32 tmp;
1989
2111
1990
	/* framebuffer size */
2112
	/* framebuffer size */
1991
        if ((rinfo->family == CHIP_FAMILY_RS100) ||
2113
        if (rinfo->is_IGP) {
1992
            (rinfo->family == CHIP_FAMILY_RS200) ||
1993
            (rinfo->family == CHIP_FAMILY_RS300)) {
1994
          u32 tom = INREG(NB_TOM);
2114
          u32 tom = INREG(NB_TOM);
1995
          tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
2115
          tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);
1996
2116
Lines 2018-2023 Link Here
2018
	/* mem size is bits [28:0], mask off the rest */
2138
	/* mem size is bits [28:0], mask off the rest */
2019
	rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK;
2139
	rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK;
2020
2140
2141
	/* Limit memory to 128 megs for now */
2142
	if (rinfo->video_ram > MAX_VRAM)
2143
		rinfo->video_ram = MAX_VRAM;
2144
2021
	/*
2145
	/*
2022
	 * Hack to get around some busted production M6's
2146
	 * Hack to get around some busted production M6's
2023
	 * reporting no ram
2147
	 * reporting no ram
Lines 2102-2108 Link Here
2102
        struct fb_info *info = pci_get_drvdata(pdev);
2226
        struct fb_info *info = pci_get_drvdata(pdev);
2103
        struct radeonfb_info *rinfo = info->par;
2227
        struct radeonfb_info *rinfo = info->par;
2104
2228
2105
	return radeon_show_one_edid(buf, off, count, rinfo->mon1_EDID);
2229
	return radeon_show_one_edid(buf, off, count, rinfo->connectors[rinfo->heads[0]].edid);
2106
}
2230
}
2107
2231
2108
2232
Lines 2113-2119 Link Here
2113
        struct fb_info *info = pci_get_drvdata(pdev);
2237
        struct fb_info *info = pci_get_drvdata(pdev);
2114
        struct radeonfb_info *rinfo = info->par;
2238
        struct radeonfb_info *rinfo = info->par;
2115
2239
2116
	return radeon_show_one_edid(buf, off, count, rinfo->mon2_EDID);
2240
	return radeon_show_one_edid(buf, off, count, rinfo->connectors[rinfo->heads[1]].edid);
2241
}
2242
2243
static ssize_t radeon_show_edid3(struct kobject *kobj, char *buf, loff_t off, size_t count)
2244
{
2245
	struct device *dev = container_of(kobj, struct device, kobj);
2246
	struct pci_dev *pdev = to_pci_dev(dev);
2247
        struct fb_info *info = pci_get_drvdata(pdev);
2248
        struct radeonfb_info *rinfo = info->par;
2249
2250
	return radeon_show_one_edid(buf, off, count, rinfo->connectors[rinfo->heads[2]].edid);
2251
}
2252
2253
static ssize_t radeon_show_edid4(struct kobject *kobj, char *buf, loff_t off, size_t count)
2254
{
2255
	struct device *dev = container_of(kobj, struct device, kobj);
2256
	struct pci_dev *pdev = to_pci_dev(dev);
2257
        struct fb_info *info = pci_get_drvdata(pdev);
2258
        struct radeonfb_info *rinfo = info->par;
2259
2260
	return radeon_show_one_edid(buf, off, count, rinfo->connectors[rinfo->heads[3]].edid);
2117
}
2261
}
2118
2262
2119
static struct bin_attribute edid1_attr = {
2263
static struct bin_attribute edid1_attr = {
Lines 2136-2141 Link Here
2136
	.read	= radeon_show_edid2,
2280
	.read	= radeon_show_edid2,
2137
};
2281
};
2138
2282
2283
static struct bin_attribute edid3_attr = {
2284
	.attr   = {
2285
		.name	= "edid3",
2286
		.owner	= THIS_MODULE,
2287
		.mode	= 0444,
2288
	},
2289
	.size	= EDID_LENGTH,
2290
	.read	= radeon_show_edid3,
2291
};
2292
2293
static struct bin_attribute edid4_attr = {
2294
	.attr   = {
2295
		.name	= "edid4",
2296
		.owner	= THIS_MODULE,
2297
		.mode	= 0444,
2298
	},
2299
	.size	= EDID_LENGTH,
2300
	.read	= radeon_show_edid4,
2301
};
2139
2302
2140
static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2303
static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2141
				  const struct pci_device_id *ent)
2304
				  const struct pci_device_id *ent)
Lines 2143-2148 Link Here
2143
	struct fb_info *info;
2306
	struct fb_info *info;
2144
	struct radeonfb_info *rinfo;
2307
	struct radeonfb_info *rinfo;
2145
	int ret;
2308
	int ret;
2309
	int i;
2146
2310
2147
	RTRACE("radeonfb_pci_register BEGIN\n");
2311
	RTRACE("radeonfb_pci_register BEGIN\n");
2148
	
2312
	
Lines 2199-2205 Link Here
2199
	}
2363
	}
2200
2364
2201
	/* map the regions */
2365
	/* map the regions */
2202
	rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, RADEON_REGSIZE);
2366
	rinfo->mmio_base = ioremap(rinfo->mmio_base_phys, 
2367
				   pci_resource_len(rinfo->pdev, 2));
2203
	if (!rinfo->mmio_base) {
2368
	if (!rinfo->mmio_base) {
2204
		printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n",
2369
		printk(KERN_ERR "radeonfb (%s): cannot map MMIO\n",
2205
		       pci_name(rinfo->pdev));
2370
		       pci_name(rinfo->pdev));
Lines 2284-2289 Link Here
2284
	 * We probably need to make sure this is the primary display,
2449
	 * We probably need to make sure this is the primary display,
2285
	 * but that is difficult without some arch support.
2450
	 * but that is difficult without some arch support.
2286
	 */
2451
	 */
2452
2287
#ifdef CONFIG_X86
2453
#ifdef CONFIG_X86
2288
	if (rinfo->bios_seg == NULL)
2454
	if (rinfo->bios_seg == NULL)
2289
		radeon_find_mem_vbios(rinfo);
2455
		radeon_find_mem_vbios(rinfo);
Lines 2295-2308 Link Here
2295
	if (rinfo->bios_seg == NULL && rinfo->is_mobility)
2461
	if (rinfo->bios_seg == NULL && rinfo->is_mobility)
2296
		radeon_map_ROM(rinfo, pdev);
2462
		radeon_map_ROM(rinfo, pdev);
2297
2463
2464
	/* Check BIOS Type */
2465
	radeon_detect_bios_type(rinfo);
2466
	
2298
	/* Get informations about the board's PLL */
2467
	/* Get informations about the board's PLL */
2299
	radeon_get_pllinfo(rinfo);
2468
	radeon_get_pll_info(rinfo);
2469
2470
	/* Get informations about internal TMDS controller if any */
2471
	radeon_get_tmds_info(rinfo);
2300
2472
2301
#ifdef CONFIG_FB_RADEON_I2C
2473
#ifdef CONFIG_FB_RADEON_I2C
2302
	/* Register I2C bus */
2474
	/* Register I2C bus */
2303
	radeon_create_i2c_busses(rinfo);
2475
	radeon_create_i2c_busses(rinfo);
2304
#endif
2476
#endif
2305
2477
2478
	/* Get infos about connectors -- need I2C here! */
2479
	radeon_get_conn_info(rinfo, ignore_conntable);
2480
2306
	/* set all the vital stuff */
2481
	/* set all the vital stuff */
2307
	radeon_set_fbinfo (rinfo);
2482
	radeon_set_fbinfo (rinfo);
2308
2483
Lines 2313-2322 Link Here
2313
	radeon_check_modes(rinfo, mode_option);
2488
	radeon_check_modes(rinfo, mode_option);
2314
2489
2315
	/* Register some sysfs stuff (should be done better) */
2490
	/* Register some sysfs stuff (should be done better) */
2316
	if (rinfo->mon1_EDID)
2491
	
2492
	if ((rinfo->heads[0] != -1) && rinfo->connectors[rinfo->heads[0]].edid)
2317
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
2493
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
2318
	if (rinfo->mon2_EDID)
2494
	if ((rinfo->heads[1] != -1) && rinfo->connectors[rinfo->heads[1]].edid)
2319
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
2495
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
2496
	if ((rinfo->heads[2] != -1) && rinfo->connectors[rinfo->heads[2]].edid)
2497
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid3_attr);
2498
	if ((rinfo->heads[3] != -1) && rinfo->connectors[rinfo->heads[3]].edid)
2499
		sysfs_create_bin_file(&rinfo->pdev->dev.kobj, &edid4_attr);
2320
2500
2321
	/* save current mode regs before we switch into the new one
2501
	/* save current mode regs before we switch into the new one
2322
	 * so we can restore this upon __exit
2502
	 * so we can restore this upon __exit
Lines 2361-2370 Link Here
2361
err_unmap_fb:
2541
err_unmap_fb:
2362
	iounmap(rinfo->fb_base);
2542
	iounmap(rinfo->fb_base);
2363
err_unmap_rom:
2543
err_unmap_rom:
2364
	kfree(rinfo->mon1_EDID);
2544
	for (i = 0 ; i < RADEON_MAX_CONNECTORS ; i++) {
2365
	kfree(rinfo->mon2_EDID);
2545
		kfree(rinfo->connectors[i].edid);
2366
	if (rinfo->mon1_modedb)
2546
		if (rinfo->connectors[i].modedb)
2367
		fb_destroy_modedb(rinfo->mon1_modedb);
2547
			fb_destroy_modedb(rinfo->connectors[i].modedb);
2548
	}
2549
2368
	fb_dealloc_cmap(&info->cmap);
2550
	fb_dealloc_cmap(&info->cmap);
2369
#ifdef CONFIG_FB_RADEON_I2C
2551
#ifdef CONFIG_FB_RADEON_I2C
2370
	radeon_delete_i2c_busses(rinfo);
2552
	radeon_delete_i2c_busses(rinfo);
Lines 2389-2406 Link Here
2389
{
2571
{
2390
        struct fb_info *info = pci_get_drvdata(pdev);
2572
        struct fb_info *info = pci_get_drvdata(pdev);
2391
        struct radeonfb_info *rinfo = info->par;
2573
        struct radeonfb_info *rinfo = info->par;
2392
 
2574
2575
	int i;
2576
2393
        if (!rinfo)
2577
        if (!rinfo)
2394
                return;
2578
                return;
2395
2579
2396
	radeonfb_bl_exit(rinfo);
2580
	radeonfb_bl_exit(rinfo);
2397
	radeonfb_pm_exit(rinfo);
2581
	radeonfb_pm_exit(rinfo);
2398
2582
2399
	if (rinfo->mon1_EDID)
2583
	if ((rinfo->heads[0] != -1) && rinfo->connectors[rinfo->heads[0]].edid)
2400
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
2584
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid1_attr);
2401
	if (rinfo->mon2_EDID)
2585
	if ((rinfo->heads[1] != -1) && rinfo->connectors[rinfo->heads[1]].edid)
2402
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
2586
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid2_attr);
2403
2587
	if ((rinfo->heads[2] != -1) && rinfo->connectors[rinfo->heads[2]].edid)
2588
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid3_attr);
2589
	if ((rinfo->heads[3] != -1) && rinfo->connectors[rinfo->heads[3]].edid)
2590
		sysfs_remove_bin_file(&rinfo->pdev->dev.kobj, &edid4_attr);
2591
 
2404
#if 0
2592
#if 0
2405
	/* restore original state
2593
	/* restore original state
2406
	 * 
2594
	 * 
Lines 2426-2435 Link Here
2426
	pci_release_region(pdev, 2);
2614
	pci_release_region(pdev, 2);
2427
	pci_release_region(pdev, 0);
2615
	pci_release_region(pdev, 0);
2428
2616
2429
	kfree(rinfo->mon1_EDID);
2617
	for (i = 0 ; i < RADEON_MAX_CONNECTORS ; i++) {
2430
	kfree(rinfo->mon2_EDID);
2618
		kfree(rinfo->connectors[i].edid);
2431
	if (rinfo->mon1_modedb)
2619
		if (rinfo->connectors[i].modedb)
2432
		fb_destroy_modedb(rinfo->mon1_modedb);
2620
			fb_destroy_modedb(rinfo->connectors[i].modedb);
2621
	}
2433
#ifdef CONFIG_FB_RADEON_I2C
2622
#ifdef CONFIG_FB_RADEON_I2C
2434
	radeon_delete_i2c_busses(rinfo);
2623
	radeon_delete_i2c_busses(rinfo);
2435
#endif        
2624
#endif        
Lines 2479-2490 Link Here
2479
			force_measure_pll = 1;
2668
			force_measure_pll = 1;
2480
		} else if (!strncmp(this_opt, "ignore_edid", 11)) {
2669
		} else if (!strncmp(this_opt, "ignore_edid", 11)) {
2481
			ignore_edid = 1;
2670
			ignore_edid = 1;
2671
		} else if (!strncmp(this_opt, "ignore_conntable", 16)) {
2672
			ignore_conntable = 1;
2673
		} else if (!strncmp( this_opt, "default_dynclk:", 15)) {
2674
			default_dynclk = simple_strtoul((this_opt+15), NULL, 10);
2482
#if defined(CONFIG_PM) && defined(CONFIG_X86)
2675
#if defined(CONFIG_PM) && defined(CONFIG_X86)
2483
	 	} else if (!strncmp(this_opt, "force_sleep", 11)) {
2676
	 	} else if (!strncmp(this_opt, "force_sleep", 11)) {
2484
			force_sleep = 1;
2677
			force_sleep = 1;
2485
		} else if (!strncmp(this_opt, "ignore_devlist", 14)) {
2678
		} else if (!strncmp(this_opt, "ignore_devlist", 14)) {
2486
			ignore_devlist = 1;
2679
			ignore_devlist = 1;
2487
#endif
2680
#endif
2681
		} else if (!strncmp(this_opt, "debug", 5)) {
2682
			radeonfb_debug = 1;
2488
		} else
2683
		} else
2489
			mode_option = this_opt;
2684
			mode_option = this_opt;
2490
	}
2685
	}
Lines 2528-2533 Link Here
2528
MODULE_PARM_DESC(force_dfp, "bool: force display to dfp");
2723
MODULE_PARM_DESC(force_dfp, "bool: force display to dfp");
2529
module_param(ignore_edid, bool, 0);
2724
module_param(ignore_edid, bool, 0);
2530
MODULE_PARM_DESC(ignore_edid, "bool: Ignore EDID data when doing DDC probe");
2725
MODULE_PARM_DESC(ignore_edid, "bool: Ignore EDID data when doing DDC probe");
2726
module_param(ignore_conntable, bool, 0);
2727
MODULE_PARM_DESC(ignore_conntable, "bool: Ignore BIOS Connector table");
2531
module_param(monitor_layout, charp, 0);
2728
module_param(monitor_layout, charp, 0);
2532
MODULE_PARM_DESC(monitor_layout, "Specify monitor mapping (like XFree86)");
2729
MODULE_PARM_DESC(monitor_layout, "Specify monitor mapping (like XFree86)");
2533
module_param(force_measure_pll, bool, 0);
2730
module_param(force_measure_pll, bool, 0);
Lines 2546-2548 Link Here
2546
module_param(ignore_devlist, bool, 0);
2743
module_param(ignore_devlist, bool, 0);
2547
MODULE_PARM_DESC(ignore_devlist, "bool: ignore workarounds for bugs in specific laptops");
2744
MODULE_PARM_DESC(ignore_devlist, "bool: ignore workarounds for bugs in specific laptops");
2548
#endif
2745
#endif
2746
module_param(radeonfb_debug, int, 0);
2747
MODULE_PARM_DESC(radeonfb_debug, "Enable full debugging text");
(-)aty-2.6.18/radeon_i2c.c (-20 / +47 lines)
Lines 169-181 Link Here
169
	return NULL;
169
	return NULL;
170
}
170
}
171
171
172
172
/* Returns 1 if probe unsuccessful. */
173
int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, u8 **out_edid)
173
int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, struct radeon_connector *conn)
174
{
174
{
175
	u32 reg = rinfo->i2c[conn-1].ddc_reg;
175
	u32 reg;
176
	u8 *edid = NULL;
176
	u8 *edid = NULL;
177
	int mon_type = MT_NONE;
178
177
	int i, j;
179
	int i, j;
178
180
181
	if (!conn)
182
		return 1;
183
184
	if (rinfo->is_mobility && (conn->ddc_type == ddc_none) &&
185
	    (INREG(LVDS_GEN_CNTL) & (LVDS_ON|LVDS_EN))) {
186
			RTRACE("radeonfb: I2C (port %d) ... found LVDS panel\n", conn->ddc_type);
187
			mon_type = MT_LCD;
188
			goto done;
189
	}
190
191
	reg = rinfo->i2c[conn->ddc_type].ddc_reg;
192
179
	OUTREG(reg, INREG(reg) & 
193
	OUTREG(reg, INREG(reg) & 
180
			~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
194
			~(VGA_DDC_DATA_OUTPUT | VGA_DDC_CLK_OUTPUT));
181
195
Lines 211-217 Link Here
211
		msleep(15);
225
		msleep(15);
212
226
213
		/* Do the real work */
227
		/* Do the real work */
214
		edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn-1]);
228
		edid = radeon_do_probe_i2c_edid(&rinfo->i2c[conn->ddc_type]);
215
229
216
		OUTREG(reg, INREG(reg) | 
230
		OUTREG(reg, INREG(reg) | 
217
				(VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
231
				(VGA_DDC_DATA_OUT_EN | VGA_DDC_CLK_OUT_EN));
Lines 235-264 Link Here
235
		if (edid)
249
		if (edid)
236
			break;
250
			break;
237
	}
251
	}
252
238
	/* Release the DDC lines when done or the Apple Cinema HD display
253
	/* Release the DDC lines when done or the Apple Cinema HD display
239
	 * will switch off
254
	 * will switch off
240
	 */
255
	 */
241
	OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN | VGA_DDC_DATA_OUT_EN));
256
	OUTREG(reg, INREG(reg) & ~(VGA_DDC_CLK_OUT_EN | VGA_DDC_DATA_OUT_EN));
242
	(void)INREG(reg);
257
	(void)INREG(reg);
243
258
244
	if (out_edid)
245
		*out_edid = edid;
246
	if (!edid) {
259
	if (!edid) {
247
		RTRACE("radeonfb: I2C (port %d) ... not found\n", conn);
260
	  // what about the special case where we are a DFP/LVDS, but have a DDC connection..
248
		return MT_NONE;
261
	  // but no EDID? We should fall back to MT_LCD...?  XXXX
262
		RTRACE("radeonfb: I2C (port %d) ... not found\n", conn->ddc_type);
263
		mon_type = MT_NONE;
264
		goto done;
249
	}
265
	}
250
	if (edid[0x14] & 0x80) {
266
251
		/* Fix detection using BIOS tables */
267
	if ((edid[EDID_STRUCT_DISPLAY] & 0x80) && (conn->ddc_type == ddc_dvi)) {
252
		if (rinfo->is_mobility /*&& conn == ddc_dvi*/ &&
268
		RTRACE("radeonfb: I2C (port %d) ... found TMDS panel\n", conn->ddc_type);
253
		    (INREG(LVDS_GEN_CNTL) & LVDS_ON)) {
269
		mon_type = MT_DFP;
254
			RTRACE("radeonfb: I2C (port %d) ... found LVDS panel\n", conn);
270
		goto done;
255
			return MT_LCD;
271
	}
256
		} else {
272
257
			RTRACE("radeonfb: I2C (port %d) ... found TMDS panel\n", conn);
273
	if (rinfo->is_mobility && 
258
			return MT_DFP;
274
	    (conn->conn_type == conn_lvds) &&
259
		}
275
	    (edid[EDID_STRUCT_DISPLAY] & 0x80) &&  // ie EDID valid and marks us as a DFP... 
276
	    (INREG(LVDS_GEN_CNTL) & (LVDS_ON|LVDS_EN))) {
277
		RTRACE("radeonfb: I2C (port %d) ... found LVDS panel\n", conn->ddc_type);
278
		mon_type = MT_LCD;
279
		goto done;
260
	}
280
	}
261
       	RTRACE("radeonfb: I2C (port %d) ... found CRT display\n", conn);
281
262
	return MT_CRT;
282
       	RTRACE("radeonfb: I2C (port %d) ... found CRT display\n", conn->ddc_type);
283
	mon_type = MT_CRT;
284
285
 done:
286
	conn->edid = edid;
287
	conn->mon_type = mon_type;
288
289
	return (mon_type == MT_NONE);
263
}
290
}
264
291
(-)aty-2.6.18/radeon_monitor.c (-320 / +891 lines)
Lines 1-6 Link Here
1
#include "radeonfb.h"
1
#include "radeonfb.h"
2
#include "../edid.h"
2
#include "../edid.h"
3
3
4
/*
5
 * TMDS PLL configuration table, taken from X.org
6
 */
7
static const struct radeon_tmds_pll_info default_tmds_pll[CHIP_FAMILY_LAST][4] =
8
{
9
    {{0, 0}, {0, 0}, {0, 0}, {0, 0}},				/*CHIP_FAMILY_UNKNOW*/
10
    {{0, 0}, {0, 0}, {0, 0}, {0, 0}},				/*CHIP_FAMILY_LEGACY*/
11
    {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RADEON*/
12
    {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RV100*/
13
    {{0, 0}, {0, 0}, {0, 0}, {0, 0}},				/*CHIP_FAMILY_RS100*/
14
    {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RV200*/
15
    {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RS200*/
16
    {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_R200*/
17
    {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RV250*/
18
    {{0, 0}, {0, 0}, {0, 0}, {0, 0}},				/*CHIP_FAMILY_RS300*/
19
    {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x400f7/*0x40111*/}, {0, 0}},	/*CHIP_FAMILY_RV280*/
20
    {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}},		/*CHIP_FAMILY_R300*/
21
    {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}},		/*CHIP_FAMILY_R350*/
22
    {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RV350*/
23
    {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}},	/*CHIP_FAMILY_RV380*/
24
    {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}},		/*CHIP_FAMILY_R420*/
25
};
26
4
static struct fb_var_screeninfo radeonfb_default_var = {
27
static struct fb_var_screeninfo radeonfb_default_var = {
5
	.xres		= 640,
28
	.xres		= 640,
6
	.yres		= 480,
29
	.yres		= 480,
Lines 23-57 Link Here
23
	.vmode		= FB_VMODE_NONINTERLACED
46
	.vmode		= FB_VMODE_NONINTERLACED
24
};
47
};
25
48
26
static char *radeon_get_mon_name(int type)
27
{
28
	char *pret = NULL;
29
30
	switch (type) {
31
		case MT_NONE:
32
			pret = "no";
33
			break;
34
		case MT_CRT:
35
			pret = "CRT";
36
			break;
37
		case MT_DFP:
38
			pret = "DFP";
39
			break;
40
		case MT_LCD:
41
			pret = "LCD";
42
			break;
43
		case MT_CTV:
44
			pret = "CTV";
45
			break;
46
		case MT_STV:
47
			pret = "STV";
48
			break;
49
	}
50
51
	return pret;
52
}
53
54
55
#ifdef CONFIG_PPC_OF
49
#ifdef CONFIG_PPC_OF
56
/*
50
/*
57
 * Try to find monitor informations & EDID data out of the Open Firmware
51
 * Try to find monitor informations & EDID data out of the Open Firmware
Lines 59-65 Link Here
59
 * models with broken OF probing by hard-coding known EDIDs for some Mac
53
 * models with broken OF probing by hard-coding known EDIDs for some Mac
60
 * laptops internal LVDS panel. (XXX: not done yet)
54
 * laptops internal LVDS panel. (XXX: not done yet)
61
 */
55
 */
62
static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_EDID,
56
static int __devinit radeon_parse_montype_prop(struct device_node *dp,
57
					       struct radeon_connector *conn, 
63
					       int hdno)
58
					       int hdno)
64
{
59
{
65
        static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID",
60
        static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID",
Lines 67-91 Link Here
67
	u8 *pedid = NULL;
62
	u8 *pedid = NULL;
68
	u8 *pmt = NULL;
63
	u8 *pmt = NULL;
69
	u8 *tmp;
64
	u8 *tmp;
70
        int i, mt = MT_NONE;  
65
        int i;  
71
	
66
	
72
	RTRACE("analyzing OF properties...\n");
67
	RTRACE("analyzing OF properties...\n");
73
	pmt = (u8 *)get_property(dp, "display-type", NULL);
68
	pmt = (u8 *)get_property(dp, "display-type", NULL);
74
	if (!pmt)
69
	if (!pmt)
75
		return MT_NONE;
70
		return 1;
76
	RTRACE("display-type: %s\n", pmt);
71
	RTRACE("display-type: %s\n", pmt);
77
	/* OF says "LCD" for DFP as well, we discriminate from the caller of this
72
	if (!strcmp(pmt, "LCD") || !strcmp(pmt, "DFP")) {
78
	 * function
73
		/* OF says "LCD" for DFP as well.*/
79
	 */
74
		if (rinfo->is_mobility) {
80
	if (!strcmp(pmt, "LCD") || !strcmp(pmt, "DFP"))
75
			conn->mon_type = MT_LCD;
81
		mt = MT_DFP;
76
			/* Maybe check for LVDS_GEN_CNTL here ? I need to check out
82
	else if (!strcmp(pmt, "CRT"))
77
			 * what OF does when booting with lid closed
83
		mt = MT_CRT;
78
			 */
84
	else {
79
		} else{
80
			conn->mon_type = MT_DFP;
81
		}
82
	} else if (!strcmp(pmt, "CRT")) {
83
		conn->mon_type = MT_CRT;
84
	} else {
85
		if (strcmp(pmt, "NONE") != 0)
85
		if (strcmp(pmt, "NONE") != 0)
86
			printk(KERN_WARNING "radeonfb: Unknown OF display-type: %s\n",
86
			printk(KERN_WARNING "radeonfb: Unknown OF display-type: %s\n",
87
			       pmt);
87
			       pmt);
88
		return MT_NONE;
88
		return 1;
89
	}
89
	}
90
90
91
	for (i = 0; propnames[i] != NULL; ++i) {
91
	for (i = 0; propnames[i] != NULL; ++i) {
Lines 102-127 Link Here
102
	if (pedid == NULL && dp->parent && (hdno == 0))
102
	if (pedid == NULL && dp->parent && (hdno == 0))
103
		pedid = get_property(dp->parent, "EDID", NULL);
103
		pedid = get_property(dp->parent, "EDID", NULL);
104
	if (pedid == NULL)
104
	if (pedid == NULL)
105
		return mt;
105
		return 1;
106
106
107
	tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
107
	tmp = (u8 *)kmalloc(EDID_LENGTH, GFP_KERNEL);
108
	if (!tmp)
108
	if (tmp) {
109
		return mt;
109
		memcpy(tmp, pedid, EDID_LENGTH);
110
	memcpy(tmp, pedid, EDID_LENGTH);
110
	}
111
	*out_EDID = tmp;
111
112
	return mt;
112
	conn->edid = tmp;
113
114
	{
115
		int found_tmds = 0;
116
		int found_crt = 0;
117
		int ddc_type = ddc_none;
118
		// XXX what about reversed DAC/TMDS??
119
		radeon_fill_conn(conn, conn->mon_type, ddc_type, &found_crt, &found_tmds);
120
	}
121
122
	return 0;
113
}
123
}
114
124
115
static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_no,
125
/* return a 1 on error */
116
					  u8 **out_EDID)
126
static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_no)
127
117
{
128
{
129
	struct radeon_connector *conn;
118
        struct device_node *dp;
130
        struct device_node *dp;
131
	u8 *out_EDID;
119
132
120
	RTRACE("radeon_probe_OF_head\n");
133
	RTRACE("radeon_probe_OF_head\n");
121
134
135
	conn = rinfo->connectors[head_no];
136
122
        dp = rinfo->of_node;
137
        dp = rinfo->of_node;
123
        while (dp == NULL)
138
        if (dp == NULL) 
124
		return MT_NONE;
139
		return 1;
125
140
126
	if (rinfo->has_CRTC2) {
141
	if (rinfo->has_CRTC2) {
127
		char *pname;
142
		char *pname;
Lines 129-180 Link Here
129
144
130
		dp = dp->child;
145
		dp = dp->child;
131
		do {
146
		do {
132
			if (!dp)
147
			if (!dp) 
133
				return MT_NONE;
148
				return 1;
149
134
			pname = (char *)get_property(dp, "name", NULL);
150
			pname = (char *)get_property(dp, "name", NULL);
135
			if (!pname)
151
			if (!pname) 
136
				return MT_NONE;
152
				return 1;
153
137
			len = strlen(pname);
154
			len = strlen(pname);
138
			RTRACE("head: %s (letter: %c, head_no: %d)\n",
155
			RTRACE("head: %s (letter: %c, head_no: %d)\n",
139
			       pname, pname[len-1], head_no);
156
			       pname, pname[len-1], head_no);
140
			if (pname[len-1] == 'A' && head_no == 0) {
157
			if (pname[len-1] == 'A' && head_no == 0) {
141
				int mt = radeon_parse_montype_prop(dp, out_EDID, 0);
158
				return radeon_parse_montype_prop(dp, conn, 0);
142
				/* Maybe check for LVDS_GEN_CNTL here ? I need to check out
159
			} else if (pname[len-1] == 'B' && head_no == 1) {
143
				 * what OF does when booting with lid closed
160
				return radeon_parse_montype_prop(dp, conn, 1);
144
				 */
161
			}
145
				if (mt == MT_DFP && rinfo->is_mobility)
146
					mt = MT_LCD;
147
				return mt;
148
			} else if (pname[len-1] == 'B' && head_no == 1)
149
				return radeon_parse_montype_prop(dp, out_EDID, 1);
150
			second = 1;
162
			second = 1;
151
			dp = dp->sibling;
163
			dp = dp->sibling;
152
		} while(!second);
164
		} while(!second);
153
	} else {
165
	} else {
154
		if (head_no > 0)
166
		if (head_no > 0) {
155
			return MT_NONE;
167
			return 1;
156
		return radeon_parse_montype_prop(dp, out_EDID, -1);
168
		}
169
		return radeon_parse_montype_prop(dp, conn, -1);
157
	}
170
	}
158
        return MT_NONE;
171
	return 1;
159
}
172
}
160
#endif /* CONFIG_PPC_OF */
173
#endif /* CONFIG_PPC_OF */
161
174
162
175
163
static int __devinit radeon_get_panel_info_BIOS(struct radeonfb_info *rinfo)
176
int __devinit radeon_get_lvds_info_atom(struct radeonfb_info *rinfo)
177
{
178
	unsigned long tmp;
179
180
	if (!rinfo->bios_seg)
181
		return -ENODEV;
182
183
	tmp = BIOS_IN16(rinfo->atom_data_start + 16);
184
	if (!tmp) {
185
		RTRACE("No LVDS panel info in ATOM BIOS\n");
186
		rinfo->panel_info.pwr_delay = 200;
187
		return -ENODEV;
188
	}
189
	
190
	rinfo->panel_info.xres = BIOS_IN16(tmp+6);
191
	rinfo->panel_info.yres = BIOS_IN16(tmp+10);
192
	printk("radeonfb: detected LVDS panel size from BIOS: %dx%d\n",
193
	       rinfo->panel_info.xres, rinfo->panel_info.yres);
194
	rinfo->panel_info.pwr_delay = BIOS_IN16(tmp+40);
195
	RTRACE("BIOS provided panel power delay: %d\n", rinfo->panel_info.pwr_delay);
196
	if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay <= 0)
197
		rinfo->panel_info.pwr_delay = 2000;
198
	
199
	/* No special divider combinations? */
200
	
201
	rinfo->panel_info.hblank = BIOS_IN16(tmp+8);
202
	rinfo->panel_info.hOver_plus = BIOS_IN16(tmp+14);
203
	rinfo->panel_info.hSync_width = BIOS_IN16(tmp+16);
204
	rinfo->panel_info.vblank = BIOS_IN16(tmp+12);
205
	rinfo->panel_info.vOver_plus = BIOS_IN16(tmp+18);
206
	rinfo->panel_info.vSync_width = BIOS_IN16(tmp+20);
207
	rinfo->panel_info.clock = BIOS_IN16(tmp+4);
208
	
209
	/* Assume high active syncs for now until ATI tells me more... maybe we
210
	 * can probe register values here ?
211
	 */
212
	rinfo->panel_info.hAct_high = 1;
213
	rinfo->panel_info.vAct_high = 1;
214
	/* Mark panel infos valid */
215
	rinfo->panel_info.valid = 1;
216
	
217
	return 0;
218
}
219
220
int __devinit radeon_get_lvds_info_legacy(struct radeonfb_info *rinfo)
164
{
221
{
165
	unsigned long tmp, tmp0;
222
	unsigned long tmp, tmp0;
166
	char stmp[30];
223
	char stmp[30];
167
	int i;
224
	int i;
168
225
169
	if (!rinfo->bios_seg)
226
	if (!rinfo->bios_seg)
170
		return 0;
227
		return -ENODEV;
171
228
172
	if (!(tmp = BIOS_IN16(rinfo->fp_bios_start + 0x40))) {
229
	if (!(tmp = BIOS_IN16(rinfo->fp_bios_start + 0x40))) {
173
		printk(KERN_ERR "radeonfb: Failed to detect DFP panel info using BIOS\n");
230
		RTRACE("No LVDS panel info in Legacy BIOS\n");
174
		rinfo->panel_info.pwr_delay = 200;
231
		rinfo->panel_info.pwr_delay = 200;
175
		return 0;
232
		return -ENODEV;
176
	}
233
	}
177
234
	
178
	for(i=0; i<24; i++)
235
	for(i=0; i<24; i++)
179
		stmp[i] = BIOS_IN8(tmp+i+1);
236
		stmp[i] = BIOS_IN8(tmp+i+1);
180
	stmp[24] = 0;
237
	stmp[24] = 0;
Lines 182-194 Link Here
182
	rinfo->panel_info.xres = BIOS_IN16(tmp + 25);
239
	rinfo->panel_info.xres = BIOS_IN16(tmp + 25);
183
	rinfo->panel_info.yres = BIOS_IN16(tmp + 27);
240
	rinfo->panel_info.yres = BIOS_IN16(tmp + 27);
184
	printk("radeonfb: detected LVDS panel size from BIOS: %dx%d\n",
241
	printk("radeonfb: detected LVDS panel size from BIOS: %dx%d\n",
185
		rinfo->panel_info.xres, rinfo->panel_info.yres);
242
	       rinfo->panel_info.xres, rinfo->panel_info.yres);
186
243
	
187
	rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44);
244
	rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44);
188
	RTRACE("BIOS provided panel power delay: %d\n", rinfo->panel_info.pwr_delay);
245
	RTRACE("BIOS provided panel power delay: %d\n", rinfo->panel_info.pwr_delay);
189
	if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay <= 0)
246
	if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay <= 0)
190
		rinfo->panel_info.pwr_delay = 2000;
247
		rinfo->panel_info.pwr_delay = 2000;
191
248
	
192
	/*
249
	/*
193
	 * Some panels only work properly with some divider combinations
250
	 * Some panels only work properly with some divider combinations
194
	 */
251
	 */
Lines 203-208 Link Here
203
		RTRACE("post_divider = %x\n", rinfo->panel_info.post_divider);
260
		RTRACE("post_divider = %x\n", rinfo->panel_info.post_divider);
204
		RTRACE("fbk_divider = %x\n", rinfo->panel_info.fbk_divider);
261
		RTRACE("fbk_divider = %x\n", rinfo->panel_info.fbk_divider);
205
	}
262
	}
263
	
206
	RTRACE("Scanning BIOS table ...\n");
264
	RTRACE("Scanning BIOS table ...\n");
207
	for(i=0; i<32; i++) {
265
	for(i=0; i<32; i++) {
208
		tmp0 = BIOS_IN16(tmp+64+i*2);
266
		tmp0 = BIOS_IN16(tmp+64+i*2);
Lines 226-232 Link Here
226
			rinfo->panel_info.vAct_high = 1;
284
			rinfo->panel_info.vAct_high = 1;
227
			/* Mark panel infos valid */
285
			/* Mark panel infos valid */
228
			rinfo->panel_info.valid = 1;
286
			rinfo->panel_info.valid = 1;
229
287
			
230
			RTRACE("Found panel in BIOS table:\n");
288
			RTRACE("Found panel in BIOS table:\n");
231
			RTRACE("  hblank: %d\n", rinfo->panel_info.hblank);
289
			RTRACE("  hblank: %d\n", rinfo->panel_info.hblank);
232
			RTRACE("  hOver_plus: %d\n", rinfo->panel_info.hOver_plus);
290
			RTRACE("  hOver_plus: %d\n", rinfo->panel_info.hOver_plus);
Lines 235-246 Link Here
235
			RTRACE("  vOver_plus: %d\n", rinfo->panel_info.vOver_plus);
293
			RTRACE("  vOver_plus: %d\n", rinfo->panel_info.vOver_plus);
236
			RTRACE("  vSync_width: %d\n", rinfo->panel_info.vSync_width);
294
			RTRACE("  vSync_width: %d\n", rinfo->panel_info.vSync_width);
237
			RTRACE("  clock: %d\n", rinfo->panel_info.clock);
295
			RTRACE("  clock: %d\n", rinfo->panel_info.clock);
238
				
296
			
239
			return 1;
297
			return 0;
240
		}
298
		}
241
	}
299
	}
300
242
	RTRACE("Didn't find panel in BIOS table !\n");
301
	RTRACE("Didn't find panel in BIOS table !\n");
243
302
303
	return -ENODEV;
304
}
305
306
/*
307
 * Get informations about TMDS controllers and their setup at
308
 * different operating frequencies
309
 */
310
void __devinit radeon_get_tmds_info(struct radeonfb_info *rinfo)
311
{
312
	int i;
313
314
	/* Get default TMDS infos for this chip */
315
	for (i=0; i<4; i++) {
316
		rinfo->tmds_pll[i].value =
317
			default_tmds_pll[rinfo->family][i].value;
318
		rinfo->tmds_pll[i].freq =
319
			default_tmds_pll[rinfo->family][i].freq;
320
	}
321
322
	/* Get whatever the firmware provides */
323
	if (rinfo->radeon_get_tmds_info) {
324
		rinfo->radeon_get_tmds_info(rinfo);
325
		// XXX Do we care about the return value?
326
	}
327
}
328
329
int __devinit radeon_get_tmds_info_legacy(struct radeonfb_info *rinfo)
330
{
331
	int offset, i, n, rev;
332
333
	offset = BIOS_IN16(rinfo->fp_bios_start + 0x34);
334
	if (offset == 0)
335
		return -ENODEV;
336
337
	rev = BIOS_IN8(offset);
338
	RTRACE("DFP table revision: %d\n", rev);
339
340
	switch(rev) {
341
	case 3:
342
		n = BIOS_IN8(offset + 5) + 1;
343
		if (n > 4)
344
			n = 4;
345
		for (i = 0; i < n; i++) {
346
			/* Looks bogus ... but that's what is in X.org */
347
			rinfo->tmds_pll[i].value =
348
				BIOS_IN32(offset+i*10+0x08);
349
			rinfo->tmds_pll[i].freq =
350
				BIOS_IN16(offset+i*10+0x10);
351
		}
352
		return 0;
353
354
	/* revision 4 has some problem as it appears in RV280,
355
	 * comment it off for now, use default instead
356
	 */
357
#if 0
358
	case 4:
359
		stride = 0;
360
		n = BIOS_IN8(offset  5) + 1;
361
		if (n > 4)
362
			n = 4;
363
		for (i = 0; i < n; i++) {
364
			rinfo->tmds_pll[i].value =
365
				BIOS_IN32(tmp+stride+0x08);
366
			rinfo->tmds_pll[i].freq =
367
				BIOS_IN16(tmp+stride+0x10);
368
			if (i == 0)
369
				stride += 10;
370
			else
371
				stride += 6;
372
		}
373
		return 0;
374
#endif
375
	}
376
	return -ENODEV;
377
}
378
379
int __devinit radeon_get_tmds_info_atom(struct radeonfb_info *rinfo)
380
{
381
	int offset, i, maxfreq;
382
383
	offset = BIOS_IN16(rinfo->atom_data_start + 18);
384
	if (offset == 0)
385
		return -ENODEV;
386
387
	maxfreq = BIOS_IN16(offset + 4);
388
389
	for (i = 0; i < 4; i++) {
390
		rinfo->tmds_pll[i].freq = BIOS_IN16(offset+i*6+6);
391
		/* This assumes each field in TMDS_PLL has 6 bit as
392
		 * in R300/R420
393
		 */
394
		rinfo->tmds_pll[i].value =
395
			((BIOS_IN8(offset+i*6+8) & 0x3f) |
396
			 ((BIOS_IN8(offset+i*6+10) & 0x3f)<<6) |
397
			 ((BIOS_IN8(offset+i*6+9) & 0xf)<<12) |
398
			 ((BIOS_IN8(offset+i*6+11) & 0xf)<<16));
399
		RTRACE("TMDS PLL from BIOS: %ld %x\n",
400
		       rinfo->tmds_pll[i].freq, rinfo->tmds_pll[i].value);
401
402
		if (maxfreq == rinfo->tmds_pll[i].freq) {
403
		    rinfo->tmds_pll[i].freq = 0xffffffff;
404
		    break;
405
		}
406
	}
407
	return 0;
408
}
409
410
411
static const char *conn_type_name[] = {
412
	"NONE", "VGA", "DVI-I", "DVI-D", "DVI-A", "S-Video",
413
	"Composite Video", "Internal Panel", "Digital",
414
	"Unsupported", "Proprietary"
415
};
416
417
static const char *mon_type_name[] = {
418
	"None", "CRT", "LVDS Flat panel",
419
	"DVI Flat panel", "Composite TV", "S-Video TV"
420
};
421
422
static void __devinit radeon_fill_conn(struct radeon_connector *conn, int mon_type, int ddc_type, int *found_tmds, int *found_crt) 
423
{
424
	conn->mon_type = mon_type;
425
	conn->ddc_type = ddc_type;
426
427
	// XXX what about reversed DAC/TMDS??
428
429
	switch(mon_type) {
430
	case MT_CRT:
431
		conn->conn_type = conn_vga;
432
		conn->tmds_type = tmds_unknown;
433
		conn->dac_type = (*found_crt) ? dac_tvdac: dac_primary;
434
		if (ddc_type == ddc_none) conn->ddc_type = (*found_crt) ? ddc_crt2 : ddc_vga;
435
		*found_crt = 1;
436
		break;
437
	case MT_DFP:
438
		conn->conn_type = conn_dvi_i;
439
		conn->tmds_type = (*found_tmds) ? tmds_external: tmds_internal;
440
		conn->dac_type = dac_unknown;
441
		if (ddc_type == ddc_none) conn->ddc_type = ddc_dvi;
442
		*found_tmds = 1;
443
		break;
444
	case MT_LCD:
445
		conn->conn_type = conn_lvds;
446
		conn->tmds_type = tmds_unknown;
447
		conn->dac_type = dac_unknown;
448
		if (ddc_type == ddc_none) conn->ddc_type = ddc_none; //heh
449
		break;
450
	case MT_CTV:
451
		conn->conn_type = conn_ctv;
452
		conn->tmds_type = tmds_unknown;
453
		conn->dac_type = dac_tvdac;
454
		if (ddc_type == ddc_none) conn->ddc_type = ddc_vga; // XXX ddc_crt2?
455
		break;
456
	case MT_STV:
457
		conn->conn_type = conn_stv;
458
		conn->tmds_type = tmds_unknown;
459
		conn->dac_type = dac_tvdac;
460
		if (ddc_type == ddc_none) conn->ddc_type = ddc_vga; // XXX ddc_crt2?
461
		break;
462
	case MT_UNKNOWN:
463
	case MT_NONE:
464
		conn->conn_type = conn_none;
465
		conn->tmds_type = tmds_unknown;
466
		conn->mon_type = MT_NONE;
467
		conn->ddc_type = ddc_none;
468
		conn->dac_type = dac_unknown;
469
		break;
470
	default:
471
		break;
472
	}
473
	// leaves conn_digital, conn_unsupported, conn_propritetary
474
}
475
476
/*
477
 * Get informations about the various connectors on this card. This is
478
 * the most prone to fail function as various firmwares tend to say
479
 * crap or not give any info at all. The Open Firmware version is just
480
 * a table of known cards for now for example. We'll probably need some
481
 * additional module params to force different settings in case of
482
 * misdetection here.
483
 *
484
 * This doesn _not_ try actual probing of whatever is plugged on those
485
 * various connectors. This will be done later. We do store whatever
486
 * probing info the firmware gives us though
487
 */
488
void __devinit radeon_get_conn_info(struct radeonfb_info *rinfo, int ignore_conntable)
489
{
490
	int i;
491
492
	/* Clear table */
493
	for (i = 0; i < RADEON_MAX_CONNECTORS; i++) {
494
		rinfo->connectors[i].conn_type	= conn_none;
495
		rinfo->connectors[i].ddc_type	= ddc_none;
496
		rinfo->connectors[i].dac_type	= dac_unknown;
497
		rinfo->connectors[i].tmds_type	= tmds_unknown;
498
		rinfo->connectors[i].mon_type	= MT_UNKNOWN;
499
		rinfo->connectors[i].head       = -1;
500
		rinfo->heads[i] = -1;
501
	}
502
	rinfo->num_heads = 0;
503
504
	if (ignore_conntable) {	
505
#if defined(CONFIG_FB_RADEON_I2C)
506
		struct radeon_connector conn;
507
		int idx = 0;
508
		int found_tmds = 0;
509
		int found_crt = 0;
510
511
		// XXX what about reversed DAC/TMDS??
512
513
		for (i = 0; i < 4; i++) {
514
			conn.ddc_type = i;
515
			if (!radeon_probe_i2c_connector(rinfo, &conn)) {
516
517
				radeon_fill_conn(&rinfo->connectors[idx++], conn.mon_type, conn.ddc_type, &found_tmds, &found_crt); 
518
			}
519
		}
520
521
		/* If we failed to probe something.. */
522
		if (idx) 
523
			goto found;
524
#endif /* CONFIG_FB_RADEON_I2C */
525
	} else {
526
		/* Try to obtain infos from firmware */
527
		if (rinfo->radeon_get_conn_info) {
528
			if (!rinfo->radeon_get_conn_info(rinfo)) {
529
				goto found;
530
			}
531
		}
532
	}
533
534
	printk(KERN_INFO "radeonfb: No connector infos, using defaults...\n");
535
536
	/* Here, we use defaults that are common enough ... we hope
537
	 * For a mobility chip, we assume LVDS is on primary
538
	 */
539
	if (rinfo->is_mobility) {
540
		rinfo->connectors[0].conn_type	= conn_lvds;
541
		rinfo->connectors[0].ddc_type	= ddc_dvi;
542
		rinfo->connectors[0].dac_type	= dac_primary;
543
		rinfo->connectors[0].tmds_type	= tmds_unknown;
544
		rinfo->connectors[0].mon_type	= MT_UNKNOWN;
545
546
		rinfo->connectors[1].conn_type	= conn_dvi_d;
547
		rinfo->connectors[1].ddc_type	= ddc_vga;
548
		rinfo->connectors[1].dac_type	= dac_primary;
549
		rinfo->connectors[1].tmds_type	= tmds_internal;
550
		rinfo->connectors[1].mon_type	= MT_UNKNOWN;
551
552
		rinfo->connectors[2].conn_type	= conn_stv;
553
		rinfo->connectors[2].ddc_type	= ddc_none;
554
		rinfo->connectors[2].dac_type	= dac_tvdac;
555
		rinfo->connectors[2].tmds_type	= tmds_unknown;
556
		rinfo->connectors[2].mon_type	= MT_UNKNOWN;
557
	} else {
558
		rinfo->connectors[0].conn_type	= conn_dvi_d;
559
		rinfo->connectors[0].ddc_type	= ddc_dvi;
560
		rinfo->connectors[0].dac_type	= dac_tvdac;
561
		rinfo->connectors[0].tmds_type	= tmds_internal;
562
		rinfo->connectors[0].mon_type	= MT_UNKNOWN;
563
564
		rinfo->connectors[1].conn_type	= conn_vga;
565
		rinfo->connectors[1].ddc_type	= ddc_vga;
566
		rinfo->connectors[1].dac_type	= dac_primary;
567
		rinfo->connectors[1].tmds_type	= tmds_unknown;
568
		rinfo->connectors[1].mon_type	= MT_UNKNOWN;
569
		
570
		if (rinfo->has_CRTC2) {
571
			rinfo->connectors[1].conn_type	= conn_vga;
572
			rinfo->connectors[1].ddc_type	= ddc_crt2;
573
			rinfo->connectors[1].dac_type	= dac_tvdac;
574
			rinfo->connectors[1].tmds_type	= tmds_unknown;
575
			rinfo->connectors[1].mon_type	= MT_UNKNOWN;
576
		}
577
	}
578
579
 found:
580
	/* Now, we do additional fixups */
581
582
	/* RS300 has only one DAC, force TV-DAC on VGA port */
583
	if (rinfo->family == CHIP_FAMILY_RS300) {
584
		for (i = 0; i < RADEON_MAX_CONNECTORS; i++) {
585
			if (rinfo->connectors[i].conn_type == conn_vga)
586
				rinfo->connectors[i].dac_type = dac_tvdac;
587
			else if (rinfo->connectors[i].dac_type != dac_unknown)
588
				rinfo->connectors[i].dac_type = dac_primary;
589
		}
590
	}
591
592
	/* Single head chips all use primary DAC */
593
	if (!rinfo->has_CRTC2)
594
		rinfo->connectors[0].dac_type = dac_primary;
595
596
	return;
597
 }
598
599
#ifdef CONFIG_PPC_OF
600
int __devinit radeon_get_conn_info_openfirmware(struct radeonfb_info *rinfo)
601
{
602
	int i;
603
	int not_found = 1;
604
605
	for(i = 0 ; < 2 ; i++) {  /* Only two heads for OF! */
606
		if (!radeon_probe_OF_head(rinfo, i)) found = 0;
607
	}
608
	return found;
609
}
610
#endif /* CONFIG_PPC_OF */
611
612
int __devinit radeon_get_conn_info_atom(struct radeonfb_info *rinfo)
613
{
614
	int i, j, offset, valids;
615
	int ids[RADEON_MAX_CONNECTORS];
616
	u16 portinfo, tmp0;
617
	int conn_index = 0;
618
	int conn_add = 2;
619
	int idx = 0;
620
	int ddc_type, dac_type, conn_type, tmds_type, port_id;
621
	int connector_found = 0;
622
	
623
	offset = BIOS_IN16(rinfo->atom_data_start + 22);
624
	if (offset == 0)
625
		return -ENODEV;
626
627
	/* Again, I slightly modified X.org algorithm. I assign "primary" outputs
628
	 * to entries 0 and 1, and anything else goes after 2.
629
	 *
630
	 * Also, I keep an array of all port IDs matching connectors[] array,
631
	 * unlike X which limits itself to "crtc"'s
632
	 */
633
	for (i = 0; i < RADEON_MAX_CONNECTORS; i++)
634
		ids[i] = -1;
635
636
	valids = BIOS_IN16(offset + 4);
637
	for (i = 0; i < 8; i++) {
638
		if (!(valids & (1 << i)))
639
			continue;
640
		portinfo = BIOS_IN16(offset + 6 + i*2);
641
642
		conn_type = (portinfo >> 4) & 0xf;
643
		dac_type = (portinfo & 0xf) - 1;
644
		port_id = (portinfo >> 8) & 0xf;
645
		ddc_type = ddc_none;
646
647
		if ((tmp0 = BIOS_IN16(rinfo->atom_data_start + 24))) {
648
			switch(BIOS_IN16(tmp0 + 4 + (27 * port_id)) * 4) {
649
			case GPIO_MONID:
650
				ddc_type = ddc_monid;
651
				break;
652
			case GPIO_DVI_DDC:
653
				ddc_type = ddc_dvi;
654
				break;
655
			case GPIO_VGA_DDC:
656
				ddc_type = ddc_vga;
657
				break;
658
			case GPIO_CRT2_DDC:
659
				ddc_type = ddc_crt2;
660
				break;
661
			default:
662
				ddc_type = ddc_none;
663
				break;
664
			}
665
		}
666
667
		if (i == 3)
668
			tmds_type = tmds_internal;
669
		else if (i == 7)
670
			tmds_type = tmds_external;
671
		else
672
			tmds_type = tmds_unknown;
673
674
		RTRACE("index %d port %d conn %d dac %d ddc %d tmds %d\n", i, port_id, conn_type, dac_type, ddc_type, tmds_type);
675
		
676
		/* Ok, now we have the port ID, look for an existing port
677
		 * already using this ID
678
		 */
679
		for (j = 0; j < RADEON_MAX_CONNECTORS; j++) {
680
			if (port_id != ids[j])
681
				continue;
682
			/* Gotcha, just "update" values */
683
			if (tmds_type != tmds_unknown)
684
				rinfo->connectors[j].tmds_type = tmds_type;
685
			if (rinfo->connectors[j].dac_type == dac_unknown)
686
				rinfo->connectors[j].dac_type = dac_type;
687
			if (rinfo->connectors[j].ddc_type == dac_unknown)
688
				rinfo->connectors[j].ddc_type = dac_type;
689
			continue;
690
		}
691
692
		conn_index = (ddc_type == ddc_dvi || conn_index == 1) ? 0 : 1;
693
694
		/* if the port is a TV port, or both connectors are already
695
		 * assigned, assign it after further in the table
696
		 */
697
		if (conn_type == conn_ctv || conn_type == conn_stv ||
698
		    (rinfo->connectors[0].conn_type != conn_none &&
699
		     rinfo->connectors[1].conn_type))
700
			idx = conn_add++;
701
		else
702
			idx = conn_index;
703
704
		rinfo->connectors[idx].tmds_type = tmds_type;
705
		rinfo->connectors[idx].dac_type = dac_type;
706
		rinfo->connectors[idx].ddc_type = ddc_type;
707
		rinfo->connectors[idx].conn_type = conn_type;
708
709
		/* increment connector_found for primary connectors only */
710
		if (idx < 2)
711
			connector_found += (idx + 1);
712
	}
713
714
	if (connector_found == 0)
715
		return -ENODEV;
716
244
	return 0;
717
	return 0;
245
}
718
}
246
719
Lines 248-291 Link Here
248
 * doesn't quite work yet, but it's output is still useful for
721
 * doesn't quite work yet, but it's output is still useful for
249
 * debugging
722
 * debugging
250
 */
723
 */
251
static void __devinit radeon_parse_connector_info(struct radeonfb_info *rinfo)
724
int __devinit radeon_get_conn_info_legacy(struct radeonfb_info *rinfo)
252
{
725
{
253
	int offset, chips, connectors, tmp, i, conn, type;
726
	int offset, i, entry, tmp;
254
727
	int ddc_type, dac_type, conn_type, tmds_type;
255
	static char* __conn_type_table[16] = {
728
	int conn_index = 0;
256
		"NONE", "Proprietary", "CRT", "DVI-I", "DVI-D", "Unknown", "Unknown",
729
	int conn_add = 2;
257
		"Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown",
730
	int idx = 0;
258
		"Unknown", "Unknown", "Unknown"
731
732
	/* Convert legacy to real connector types */
733
	const enum radeon_conn_type legacy_conn_to_type[] = {
734
		conn_none,
735
		conn_proprietary,
736
		conn_vga,
737
		conn_dvi_i,
738
		conn_dvi_d,
739
		conn_ctv,
740
		conn_stv,
741
		conn_unsupported,
259
	};
742
	};
260
743
261
	if (!rinfo->bios_seg)
744
	/* Some laptops only have one connector (VGA) listed in the connector
262
		return;
745
	 * table, we need to add LVDS in as a non-DDC display.
746
	 * Note, we can't assume the listed VGA will be filled in PortInfo[0],
747
	 * when walking through connector table. connector_found has following
748
	 * meaning:
749
	 * 0 -- nothing found,
750
	 * 1 -- only connectors[0] filled,
751
	 * 2 -- only connectors[1] filled,
752
	 * 3 -- both are filled.
753
	 *
754
	 * Note: I modified X.org algorithm to add additional entries if any
755
	 * after the second table slot. Those entries do not affect the value
756
	 * of connector_found. --BenH.
757
	 */
758
	int connector_found = 0;
263
759
264
	offset = BIOS_IN16(rinfo->fp_bios_start + 0x50);
760
	offset = BIOS_IN16(rinfo->fp_bios_start + 0x50);
265
	if (offset == 0) {
761
	if (offset == 0)
266
		printk(KERN_WARNING "radeonfb: No connector info table detected\n");
762
		return -ENODEV;
267
		return;
763
268
	}
764
	for (i = 1; i < 4; i++) {
269
765
		entry = offset + i*2;
270
	/* Don't do much more at this point but displaying the data if
766
271
	 * DEBUG is enabled
767
		/* End of table */
272
	 */
768
		if (!BIOS_IN8(entry) && i > 1)
273
	chips = BIOS_IN8(offset++) >> 4;
769
			break;
274
	RTRACE("%d chips in connector info\n", chips);
770
275
	for (i = 0; i < chips; i++) {
771
		/* Read table entry, check connector type */
276
		tmp = BIOS_IN8(offset++);
772
		tmp = BIOS_IN16(entry);
277
		connectors = tmp & 0x0f;
773
		conn_type = (tmp >> 12) & 0xf;
278
		RTRACE(" - chip %d has %d connectors\n", tmp >> 4, connectors);
774
		if (conn_type == legacy_conn_none)
279
		for (conn = 0; ; conn++) {
775
			continue;
280
			tmp = BIOS_IN16(offset);
776
		ddc_type = (tmp >> 8) & 0xf;
281
			if (tmp == 0)
777
		dac_type = (tmp & 0x01) ? dac_tvdac : dac_primary;
282
				break;
778
		tmds_type = (tmp & 0x10) ? tmds_external : tmds_internal;
283
			offset += 2;
779
284
			type = (tmp >> 12) & 0x0f;
780
		/* same connector */
285
			RTRACE("  * connector %d of type %d (%s) : %04x\n",
781
		if (connector_found > 0) {
286
			       conn, type, __conn_type_table[type], tmp);
782
			if (rinfo->connectors[conn_index].ddc_type == ddc_type)
783
				continue;
287
		}
784
		}
785
786
		/* sanity checks */
787
		if (ddc_type > ddc_crt2)
788
			ddc_type = ddc_none;
789
		if (conn_type > legacy_conn_unsupported)
790
			conn_type = legacy_conn_unsupported;
791
		if (conn_type != legacy_conn_dvi_d &&
792
		    conn_type != legacy_conn_dvi_i &&
793
		    tmds_type == tmds_internal)
794
			tmds_type= tmds_unknown;
795
796
		/* convert connector type */
797
		conn_type = legacy_conn_to_type[conn_type];
798
799
		/* internal DDC_DVI port will get assigned to connector[0], or
800
		 * if there is no DDC_DVI (like in some IGPs).
801
		 */
802
		conn_index = (ddc_type == ddc_dvi || conn_index == 1) ? 0 : 1;
803
804
		/* if the port is a TV port, or both connectors are already
805
		 * assigned, assign it after further in the table
806
		 */
807
		if (conn_type == conn_ctv || conn_type == conn_stv ||
808
		    (rinfo->connectors[0].conn_type != conn_none &&
809
		     rinfo->connectors[1].conn_type))
810
			idx = conn_add++;
811
		else
812
			idx = conn_index;
813
814
		/* if table full, exit */
815
		if (idx >= RADEON_MAX_CONNECTORS) {
816
			printk(KERN_WARNING "radeonfb: Connector table full !\n");
817
			break;
818
		}
819
		rinfo->connectors[idx].conn_type	= conn_type;
820
		rinfo->connectors[idx].ddc_type		= ddc_type;
821
		rinfo->connectors[idx].dac_type		= dac_type;
822
		rinfo->connectors[idx].tmds_type	= tmds_type;
823
824
		/* increment connector_found for primary connectors only */
825
		if (idx < 2)
826
			connector_found += (idx + 1);
827
	}
828
829
	if (rinfo->is_mobility) {
830
	    /* For the cases where only one VGA connector is found,
831
	     * we assume LVDS is not listed in the connector table,
832
	     * add it in here as the first port.
833
	     *
834
	     * TODO: Check what's up with laptops that have a DVI output
835
	     * and no LVDS entry in the table. I suspect some thinkpads
836
	     * may play trick with us here... We may want to check the
837
	     * presence of a panel via LVDS_GEN_CNTL to be sure...
838
	     */
839
	    if ((connector_found < 3) &&
840
		(rinfo->connectors[idx].conn_type == conn_vga)) {
841
		    if (connector_found == 1) {
842
			    memcpy(&rinfo->connectors[1],
843
				   &rinfo->connectors[0],
844
				   sizeof(struct radeon_connector));
845
		    }
846
		    /* Fixme: TV DAC is probably elsewhere ... */
847
		    rinfo->connectors[0].dac_type = dac_tvdac;
848
		    rinfo->connectors[0].tmds_type = tmds_unknown;
849
		    rinfo->connectors[0].ddc_type = ddc_none;
850
		    rinfo->connectors[0].conn_type = conn_proprietary;
851
852
		    printk(KERN_WARNING "radeonfb: LVDS port is not in connector table, added in.\n");
853
		    if (connector_found == 0)
854
			    connector_found = 1;
855
		    else
856
			    connector_found = 3;
857
	    }
858
859
	    /* Check for LCD DDC info table */
860
	    if ((offset = BIOS_IN16(rinfo->fp_bios_start + 0x42))) {
861
		    if ((tmp = BIOS_IN16(offset + 0x15))) {
862
			    if ((ddc_type = BIOS_IN8(tmp+2) & 0x07)) {
863
				    rinfo->connectors[0].ddc_type = ddc_type;
864
				    printk(KERN_WARNING "radeonfb: LCD DDC Info Table found, "
865
						"forcing primary port to %d\n",
866
						ddc_type);
867
			    }
868
		    }
869
	    }
870
	} else if (connector_found == 2) {
871
		memcpy(&rinfo->connectors[0], &rinfo->connectors[1],
872
			sizeof (struct radeon_connector));
873
		rinfo->connectors[1].dac_type = dac_unknown;
874
		rinfo->connectors[1].tmds_type = tmds_unknown;
875
		rinfo->connectors[1].ddc_type = ddc_none;
876
		rinfo->connectors[1].conn_type = conn_none;
877
		connector_found = 1;
288
	}
878
	}
879
880
	if (connector_found == 0)
881
		return -ENODEV;
882
883
	/* External TMDS Table, not used now */
884
	return 0;
289
}
885
}
290
886
291
887
Lines 362-367 Link Here
362
    return connected ? MT_CRT : MT_NONE;
958
    return connected ? MT_CRT : MT_NONE;
363
}
959
}
364
960
961
/* Find if the desired connector and monitor are compatible */
962
static int __devinit radeon_conn_monitor_compatible(int mon_type, int conn_type) 
963
{
964
	switch(mon_type) {
965
	case MT_CRT:
966
		return ((conn_type == conn_vga) || (conn_type == conn_dvi_a));
967
	case MT_DFP:
968
		return ((conn_type == conn_dvi_i) || (conn_type == conn_dvi_d));
969
	case MT_LCD:
970
		return (conn_type == conn_lvds);
971
	case MT_CTV:
972
		return (conn_type == conn_ctv);
973
	case MT_STV:
974
		return (conn_type == conn_stv);
975
	case MT_UNKNOWN:
976
	case MT_NONE:
977
	default:
978
		return 0;
979
	}
980
	// leaves conn_digital, conn_unsupported, conn_propritetary
981
}
982
983
/* Find a suitable connector for this display type */
984
static int __devinit radeon_find_connector_for_mon(struct radeonfb_info *rinfo, int mon_type)
985
{
986
	int i;
987
	
988
	if (mon_type <= MT_NONE) return 0;
989
	
990
	for (i = 0; i < RADEON_MAX_CONNECTORS ; i++) {
991
		if (radeon_conn_monitor_compatible(mon_type, rinfo->connectors[i].conn_type) && 
992
		    (rinfo->connectors[i].mon_type <= MT_NONE)) {
993
			rinfo->connectors[i].mon_type = mon_type;
994
			rinfo->connectors[i].head = rinfo->num_heads;
995
			rinfo->heads[rinfo->num_heads] = i;
996
			rinfo->num_heads++;
997
			return 0;
998
		}
999
	}
1000
1001
	printk(KERN_INFO "radeonfb: couldn't find a connector for monitor %d\n", mon_type);
1002
	return -1;
1003
}
1004
365
/*
1005
/*
366
 * Parse the "monitor_layout" string if any. This code is mostly
1006
 * Parse the "monitor_layout" string if any. This code is mostly
367
 * copied from XFree's radeon driver
1007
 * copied from XFree's radeon driver
Lines 407-425 Link Here
407
		s1[i] = 0;
1047
		s1[i] = 0;
408
		s2[0] = 0;
1048
		s2[0] = 0;
409
	}
1049
	}
1050
410
	if (strcmp(s1, "CRT") == 0)
1051
	if (strcmp(s1, "CRT") == 0)
411
		rinfo->mon1_type = MT_CRT;
1052
		radeon_find_connector_for_mon(rinfo, MT_CRT);
412
	else if (strcmp(s1, "TMDS") == 0)
1053
	else if (strcmp(s1, "TMDS") == 0)
413
		rinfo->mon1_type = MT_DFP;
1054
		radeon_find_connector_for_mon(rinfo, MT_DFP);
414
	else if (strcmp(s1, "LVDS") == 0)
1055
	else if (strcmp(s1, "LVDS") == 0)
415
		rinfo->mon1_type = MT_LCD;
1056
		radeon_find_connector_for_mon(rinfo, MT_LCD);
416
1057
417
	if (strcmp(s2, "CRT") == 0)
1058
	if (strcmp(s2, "CRT") == 0)
418
		rinfo->mon2_type = MT_CRT;
1059
		radeon_find_connector_for_mon(rinfo, MT_CRT);
419
	else if (strcmp(s2, "TMDS") == 0)
1060
	else if (strcmp(s2, "TMDS") == 0)
420
		rinfo->mon2_type = MT_DFP;
1061
		radeon_find_connector_for_mon(rinfo, MT_DFP);
421
	else if (strcmp(s2, "LVDS") == 0)
1062
	else if (strcmp(s2, "LVDS") == 0)
422
		rinfo->mon2_type = MT_LCD;
1063
		radeon_find_connector_for_mon(rinfo, MT_LCD);
423
1064
424
	return 1;
1065
	return 1;
425
}
1066
}
Lines 433-444 Link Here
433
void __devinit radeon_probe_screens(struct radeonfb_info *rinfo,
1074
void __devinit radeon_probe_screens(struct radeonfb_info *rinfo,
434
				    const char *monitor_layout, int ignore_edid)
1075
				    const char *monitor_layout, int ignore_edid)
435
{
1076
{
436
#ifdef CONFIG_FB_RADEON_I2C
1077
	int i;
437
	int ddc_crt2_used = 0;	
438
#endif
439
	int tmp, i;
440
441
	radeon_parse_connector_info(rinfo);
442
1078
443
	if (radeon_parse_monitor_layout(rinfo, monitor_layout)) {
1079
	if (radeon_parse_monitor_layout(rinfo, monitor_layout)) {
444
1080
Lines 449-478 Link Here
449
		 * a layout for each card ?
1085
		 * a layout for each card ?
450
		 */
1086
		 */
451
1087
452
		RTRACE("Using specified monitor layout: %s", monitor_layout);
1088
		RTRACE("Using specified monitor layout: %s\n", monitor_layout);
453
#ifdef CONFIG_FB_RADEON_I2C
1089
#ifdef CONFIG_FB_RADEON_I2C
454
		if (!ignore_edid) {
1090
		if (!ignore_edid) {
455
			if (rinfo->mon1_type != MT_NONE)
1091
			int mon_type;
456
				if (!radeon_probe_i2c_connector(rinfo, ddc_dvi, &rinfo->mon1_EDID)) {
1092
457
					radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon1_EDID);
1093
			/* If the DDC detection fails, 
458
					ddc_crt2_used = 1;
1094
			   we still want to use the user's specified layout! */
1095
			mon_type = PRIMARY_MONITOR(rinfo);
1096
1097
			if (PRIMARY_MONITOR(rinfo) > MT_NONE)
1098
				if (radeon_probe_i2c_connector(rinfo, &PRIMARY_HEAD(rinfo)))
1099
					PRIMARY_MONITOR(rinfo) = mon_type;
1100
			if (SECONDARY_HEAD_PRESENT(rinfo)) {
1101
				mon_type = SECONDARY_MONITOR(rinfo);
1102
				if (SECONDARY_MONITOR(rinfo) > MT_NONE) {
1103
					if (radeon_probe_i2c_connector(rinfo, &SECONDARY_HEAD(rinfo))) {
1104
						rinfo->connectors[rinfo->heads[1]].mon_type = mon_type;
1105
					}
459
				}
1106
				}
460
			if (rinfo->mon2_type != MT_NONE)
1107
			}
461
				if (!radeon_probe_i2c_connector(rinfo, ddc_vga, &rinfo->mon2_EDID) &&
462
				    !ddc_crt2_used)
463
					radeon_probe_i2c_connector(rinfo, ddc_crt2, &rinfo->mon2_EDID);
464
		}
1108
		}
465
#endif /* CONFIG_FB_RADEON_I2C */
1109
#endif /* CONFIG_FB_RADEON_I2C */
466
		if (rinfo->mon1_type == MT_NONE) {
1110
		
467
			if (rinfo->mon2_type != MT_NONE) {
1111
		/* If the user specified a bogus monitor layout... */
468
				rinfo->mon1_type = rinfo->mon2_type;
1112
		if (PRIMARY_MONITOR(rinfo) <= MT_NONE) {
469
				rinfo->mon1_EDID = rinfo->mon2_EDID;
1113
			radeon_find_connector_for_mon(rinfo, MT_CRT);
470
			} else {
1114
			printk(KERN_INFO "radeonfb: No valid monitor, assuming CRT on first port\n");
471
				rinfo->mon1_type = MT_CRT;
472
				printk(KERN_INFO "radeonfb: No valid monitor, assuming CRT on first port\n");
473
			}
474
			rinfo->mon2_type = MT_NONE;
475
			rinfo->mon2_EDID = NULL;
476
		}
1115
		}
477
	} else {
1116
	} else {
478
		/*
1117
		/*
Lines 481-662 Link Here
481
		
1120
		
482
		RTRACE("Starting monitor auto detection...\n");
1121
		RTRACE("Starting monitor auto detection...\n");
483
1122
484
#if DEBUG && defined(CONFIG_FB_RADEON_I2C)
485
		{
486
			u8 *EDIDs[4] = { NULL, NULL, NULL, NULL };
487
			int mon_types[4] = {MT_NONE, MT_NONE, MT_NONE, MT_NONE};
488
			int i;
489
490
			for (i = 0; i < 4; i++)
491
				mon_types[i] = radeon_probe_i2c_connector(rinfo,
492
									  i+1, &EDIDs[i]);
493
		}
494
#endif /* DEBUG */
495
		/*
1123
		/*
496
		 * Old single head cards
1124
		 * Old single head cards
497
		 */
1125
		 */
498
		if (!rinfo->has_CRTC2) {
1126
		if (!rinfo->has_CRTC2) {
499
#ifdef CONFIG_PPC_OF
500
			if (rinfo->mon1_type == MT_NONE)
501
				rinfo->mon1_type = radeon_probe_OF_head(rinfo, 0,
502
									&rinfo->mon1_EDID);
503
#endif /* CONFIG_PPC_OF */
504
#ifdef CONFIG_FB_RADEON_I2C
1127
#ifdef CONFIG_FB_RADEON_I2C
505
			if (rinfo->mon1_type == MT_NONE)
1128
			/* Probe each connector */
506
				rinfo->mon1_type =
1129
			for(i = 0 ; i < RADEON_MAX_CONNECTORS ; i++) {
507
					radeon_probe_i2c_connector(rinfo, ddc_dvi,
1130
				if (PRIMARY_MONITOR(rinfo) > MT_NONE) break;  /* only one head */
508
								   &rinfo->mon1_EDID);
1131
				if (!radeon_probe_i2c_connector(rinfo, &rinfo->connectors[i])) {
509
			if (rinfo->mon1_type == MT_NONE)
1132
					rinfo->heads[rinfo->num_heads] = i;
510
				rinfo->mon1_type =
1133
					rinfo->connectors[i].head = rinfo->num_heads++;
511
					radeon_probe_i2c_connector(rinfo, ddc_vga,
1134
				}
512
								   &rinfo->mon1_EDID);
1135
			}
513
			if (rinfo->mon1_type == MT_NONE)
514
				rinfo->mon1_type =
515
					radeon_probe_i2c_connector(rinfo, ddc_crt2,
516
								   &rinfo->mon1_EDID);	
517
#endif /* CONFIG_FB_RADEON_I2C */
1136
#endif /* CONFIG_FB_RADEON_I2C */
518
			if (rinfo->mon1_type == MT_NONE)
1137
			if (PRIMARY_MONITOR(rinfo) <= MT_NONE) {
519
				rinfo->mon1_type = MT_CRT;
1138
				radeon_find_connector_for_mon(rinfo, MT_CRT);
1139
			}
520
			goto bail;
1140
			goto bail;
521
		}
1141
		}
522
1142
523
		/*
1143
		/* Probe heads */
524
		 * Check for cards with reversed DACs or TMDS controllers using BIOS
1144
#ifdef CONFIG_FB_RADEON_I2C
525
		 */
1145
		/* Probe each connector in turn. */
526
		if (rinfo->bios_seg &&
1146
		for(i = 0 ; i < RADEON_MAX_CONNECTORS ; i++) {
527
		    (tmp = BIOS_IN16(rinfo->fp_bios_start + 0x50))) {
1147
			if (rinfo->connectors[i].mon_type > MT_NONE) continue; /* Don't probe "detected" stuff again */
528
			for (i = 1; i < 4; i++) {
1148
			if (!radeon_probe_i2c_connector(rinfo, &rinfo->connectors[i])) {
529
				unsigned int tmp0;
1149
				rinfo->heads[rinfo->num_heads] = i;
530
1150
				rinfo->connectors[i].head = rinfo->num_heads++;
531
				if (!BIOS_IN8(tmp + i*2) && i > 1)
532
					break;
533
				tmp0 = BIOS_IN16(tmp + i*2);
534
				if ((!(tmp0 & 0x01)) && (((tmp0 >> 8) & 0x0f) == ddc_dvi)) {
535
					rinfo->reversed_DAC = 1;
536
					printk(KERN_INFO "radeonfb: Reversed DACs detected\n");
537
				}
538
				if ((((tmp0 >> 8) & 0x0f) == ddc_dvi) && ((tmp0 >> 4) & 0x01)) {
539
					rinfo->reversed_TMDS = 1;
540
					printk(KERN_INFO "radeonfb: Reversed TMDS detected\n");
541
				}
542
			}
1151
			}
543
		}
1152
		}
1153
	
1154
#endif /* CONFIG_FB_RADEON_I2C */
544
1155
545
		/*
1156
		/* Mobility chips usually have LCDs... */
546
		 * Probe primary head (DVI or laptop internal panel)
1157
		if ((PRIMARY_MONITOR(rinfo) <= MT_NONE) && 
547
		 */
1158
		    rinfo->is_mobility &&
548
#ifdef CONFIG_PPC_OF
1159
		    ((rinfo->bios_seg && (INREG(BIOS_4_SCRATCH) & 4)) ||
549
		if (rinfo->mon1_type == MT_NONE)
1160
		     (INREG(LVDS_GEN_CNTL) & (LVDS_EN|LVDS_ON)))) {
550
			rinfo->mon1_type = radeon_probe_OF_head(rinfo, 0,
1161
			printk(KERN_INFO "radeonfb: Non-DDC laptop panel detected\n");
551
								&rinfo->mon1_EDID);
1162
			radeon_find_connector_for_mon(rinfo, MT_LCD);
552
#endif /* CONFIG_PPC_OF */
1163
			if (rinfo->radeon_get_lvds_info) {
553
#ifdef CONFIG_FB_RADEON_I2C
1164
				rinfo->radeon_get_lvds_info(rinfo);
554
		if (rinfo->mon1_type == MT_NONE)
1165
			}
555
			rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_dvi,
556
								      &rinfo->mon1_EDID);
557
		if (rinfo->mon1_type == MT_NONE) {
558
			rinfo->mon1_type = radeon_probe_i2c_connector(rinfo, ddc_crt2,
559
								      &rinfo->mon1_EDID);
560
			if (rinfo->mon1_type != MT_NONE)
561
				ddc_crt2_used = 1;
562
		}
1166
		}
563
#endif /* CONFIG_FB_RADEON_I2C */
1167
564
		if (rinfo->mon1_type == MT_NONE && rinfo->is_mobility &&
1168
		/* Probe for monitors on the primary and secondary crtc heads */
565
		    ((rinfo->bios_seg && (INREG(BIOS_4_SCRATCH) & 4))
1169
		if (PRIMARY_MONITOR(rinfo) <= MT_NONE) {
566
		     || (INREG(LVDS_GEN_CNTL) & LVDS_ON))) {
1170
			radeon_find_connector_for_mon(rinfo, radeon_crt_is_connected(rinfo, 1));
567
			rinfo->mon1_type = MT_LCD;
568
			printk("Non-DDC laptop panel detected\n");
569
		}
1171
		}
570
		if (rinfo->mon1_type == MT_NONE)
571
			rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC);
572
1172
573
		/*
1173
		/* If we still haven't found anything, just force it to be on the CRT.. */
574
		 * Probe secondary head (mostly VGA, can be DVI)
1174
		if (PRIMARY_MONITOR(rinfo) <= MT_NONE) {
575
		 */
1175
			radeon_find_connector_for_mon(rinfo, MT_CRT);
576
#ifdef CONFIG_PPC_OF
1176
		}
577
		if (rinfo->mon2_type == MT_NONE)
578
			rinfo->mon2_type = radeon_probe_OF_head(rinfo, 1,
579
								&rinfo->mon2_EDID);
580
#endif /* CONFIG_PPC_OF */
581
#ifdef CONFIG_FB_RADEON_I2C
582
		if (rinfo->mon2_type == MT_NONE)
583
			rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_vga,
584
								      &rinfo->mon2_EDID);
585
		if (rinfo->mon2_type == MT_NONE && !ddc_crt2_used)
586
			rinfo->mon2_type = radeon_probe_i2c_connector(rinfo, ddc_crt2,
587
								      &rinfo->mon2_EDID);
588
#endif /* CONFIG_FB_RADEON_I2C */
589
		if (rinfo->mon2_type == MT_NONE)
590
			rinfo->mon2_type = radeon_crt_is_connected(rinfo, !rinfo->reversed_DAC);
591
1177
592
		/*
1178
		/* Always keep internal TMDS as primary head */
593
		 * If we only detected port 2, we swap them, if none detected,
1179
		if (SECONDARY_HEAD_PRESENT(rinfo) && (SECONDARY_HEAD(rinfo).tmds_type == tmds_internal) && (SECONDARY_MONITOR(rinfo) == MT_DFP)) {
594
		 * assume CRT (maybe fallback to old BIOS_SCRATCH stuff ? or look
1180
			int head = rinfo->heads[0];
595
		 * at FP registers ?)
1181
			rinfo->heads[0] = rinfo->heads[1];
596
		 */
1182
			rinfo->heads[1] = head;
597
		if (rinfo->mon1_type == MT_NONE) {
598
			if (rinfo->mon2_type != MT_NONE) {
599
				rinfo->mon1_type = rinfo->mon2_type;
600
				rinfo->mon1_EDID = rinfo->mon2_EDID;
601
			} else
602
				rinfo->mon1_type = MT_CRT;
603
			rinfo->mon2_type = MT_NONE;
604
			rinfo->mon2_EDID = NULL;
605
		}
1183
		}
1184
	}
1185
bail:
606
1186
607
		/*
1187
	/* Dump out the heads we've found so far */
608
		 * Deal with reversed TMDS
1188
	for (i = 0; i < RADEON_MAX_CONNECTORS; i++) {
609
		 */
1189
		
610
		if (rinfo->reversed_TMDS) {
1190
		if (rinfo->connectors[i].conn_type == conn_none)
611
			/* Always keep internal TMDS as primary head */
1191
			continue;
612
			if (rinfo->mon1_type == MT_DFP || rinfo->mon2_type == MT_DFP) {
1192
		printk(KERN_INFO " * Connector %d is %s. Head %d, Monitor: %s ", i+1,
613
				int tmp_type = rinfo->mon1_type;
1193
		       conn_type_name[rinfo->connectors[i].conn_type],
614
				u8 *tmp_EDID = rinfo->mon1_EDID;
1194
		       rinfo->connectors[i].head,
615
				rinfo->mon1_type = rinfo->mon2_type;
1195
		       rinfo->connectors[i].mon_type == MT_UNKNOWN  ?
616
				rinfo->mon1_EDID = rinfo->mon2_EDID;
1196
		         "Not Probed Yet" : 
617
				rinfo->mon2_type = tmp_type;
1197
		         mon_type_name[rinfo->connectors[i].mon_type]);
618
				rinfo->mon2_EDID = tmp_EDID;
1198
		if (rinfo->connectors[i].edid) {
619
				if (rinfo->mon1_type == MT_CRT || rinfo->mon2_type == MT_CRT)
1199
			printk("(EDID probed)\n");
620
					rinfo->reversed_DAC ^= 1;
1200
		} else {
621
			}
1201
			printk("\n");
622
		}
1202
		}
1203
		printk(KERN_INFO "   ddc port: %d, dac: %d, tmds: %d\n",
1204
		       rinfo->connectors[i].ddc_type,
1205
		       rinfo->connectors[i].dac_type,
1206
		       rinfo->connectors[i].tmds_type);
623
	}
1207
	}
624
	if (ignore_edid) {
625
		kfree(rinfo->mon1_EDID);
626
		rinfo->mon1_EDID = NULL;
627
		kfree(rinfo->mon2_EDID);
628
		rinfo->mon2_EDID = NULL;
629
	}
630
631
 bail:
632
	printk(KERN_INFO "radeonfb: Monitor 1 type %s found\n",
633
	       radeon_get_mon_name(rinfo->mon1_type));
634
	if (rinfo->mon1_EDID)
635
		printk(KERN_INFO "radeonfb: EDID probed\n");
636
	if (!rinfo->has_CRTC2)
637
		return;
638
	printk(KERN_INFO "radeonfb: Monitor 2 type %s found\n",
639
	       radeon_get_mon_name(rinfo->mon2_type));
640
	if (rinfo->mon2_EDID)
641
		printk(KERN_INFO "radeonfb: EDID probed\n");
642
}
1208
}
643
1209
644
1210
645
/*
646
 * This functions applyes any arch/model/machine specific fixups
647
 * to the panel info. It may eventually alter EDID block as
648
 * well or whatever is specific to a given model and not probed
649
 * properly by the default code
650
 */
651
static void radeon_fixup_panel_info(struct radeonfb_info *rinfo)
652
{
653
#ifdef CONFIG_PPC_OF
1211
#ifdef CONFIG_PPC_OF
1212
int __devinit radeon_get_lvds_info_openfirmware(struct radeonfb_info *rinfo)
1213
{
1214
654
	/*
1215
	/*
655
	 * LCD Flat panels should use fixed dividers, we enfore that on
1216
	 * LCD Flat panels should use fixed dividers, we enfore that on
656
	 * PPC only for now...
1217
	 * PPC only for now...
657
	 */
1218
	 */
658
	if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type == MT_LCD
1219
	If (!rinfo->panel_info.use_bios_dividers && (PRIMARY_MONITOR(rinfo) == MT_LCD) &&
659
	    && rinfo->is_mobility) {
1220
	    rinfo->is_mobility) {
660
		int ppll_div_sel;
1221
		int ppll_div_sel;
661
		u32 ppll_divn;
1222
		u32 ppll_divn;
662
		ppll_div_sel = INREG8(CLOCK_CNTL_INDEX + 1) & 0x3;
1223
		ppll_div_sel = INREG8(CLOCK_CNTL_INDEX + 1) & 0x3;
Lines 667-681 Link Here
667
		rinfo->panel_info.post_divider = (ppll_divn >> 16) & 0x7;
1228
		rinfo->panel_info.post_divider = (ppll_divn >> 16) & 0x7;
668
		rinfo->panel_info.use_bios_dividers = 1;
1229
		rinfo->panel_info.use_bios_dividers = 1;
669
1230
670
		printk(KERN_DEBUG "radeonfb: Using Firmware dividers 0x%08x "
1231
		printk(KERN_INFO "Using Firmware dividers 0x%08x "
671
		       "from PPLL %d\n",
1232
		       "from PPLL %d\n",
672
		       rinfo->panel_info.fbk_divider |
1233
		       rinfo->panel_info.fbk_divider |
673
		       (rinfo->panel_info.post_divider << 16),
1234
		       (rinfo->panel_info.post_divider << 16),
674
		       ppll_div_sel);
1235
		       ppll_div_sel);
1236
		return 0;
675
	}
1237
	}
676
#endif /* CONFIG_PPC_OF */
1238
	return 1;
677
}
1239
}
678
1240
#endif /* CONFIG_PPC_OF */
679
1241
680
/*
1242
/*
681
 * Fill up panel infos from a mode definition, either returned by the EDID
1243
 * Fill up panel infos from a mode definition, either returned by the EDID
Lines 742-763 Link Here
742
	info->var = radeonfb_default_var;
1304
	info->var = radeonfb_default_var;
743
	INIT_LIST_HEAD(&info->modelist);
1305
	INIT_LIST_HEAD(&info->modelist);
744
1306
745
	/*
1307
	/* If we're an LCD and don't have a valid setup... */
746
	 * First check out what BIOS has to say
1308
	if ((PRIMARY_MONITOR(rinfo) == MT_LCD) &&
747
	 */
1309
	    !rinfo->panel_info.valid && 
748
	if (rinfo->mon1_type == MT_LCD)
1310
	    rinfo->radeon_get_lvds_info) {
749
		radeon_get_panel_info_BIOS(rinfo);
1311
		rinfo->radeon_get_lvds_info(rinfo);
1312
	}
1313
1314
#if 0
1315
	/* If we're a mobility and still haven't detected a screen..? */
1316
	if ((PRIMARY_MONITOR(rinfo) <= MT_NONE) &&
1317
	    rinfo->is_mobility && 
1318
	    rinfo->radeon_get_lvds_info) {
1319
		if (! rinfo->radeon_get_lvds_info(rinfo)) {
1320
			radeon_find_connector_for_mon(rinfo, MT_LCD);
1321
		}
1322
	}
1323
#endif
750
1324
751
	/*
1325
	/*
752
	 * Parse EDID detailed timings and deduce panel infos if any. Right now
1326
	 * Parse EDID detailed timings and deduce panel infos if any. Right now
753
	 * we only deal with first entry returned by parse_EDID, we may do better
1327
	 * we only deal with first entry returned by parse_EDID, we may do better
754
	 * some day...
1328
	 * some day...
755
	 */
1329
	 */
756
	if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type != MT_CRT
1330
	if (!rinfo->panel_info.use_bios_dividers && 
757
	    && rinfo->mon1_EDID) {
1331
	    (PRIMARY_MONITOR(rinfo) != MT_CRT) &&
1332
	    PRIMARY_HEAD(rinfo).edid) {
758
		struct fb_var_screeninfo var;
1333
		struct fb_var_screeninfo var;
759
		RTRACE("Parsing EDID data for panel info\n");
1334
		RTRACE("Parsing EDID data for panel info\n");
760
		if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0) {
1335
		if (fb_parse_edid(PRIMARY_HEAD(rinfo).edid, &var) == 0) {
761
			if (var.xres >= rinfo->panel_info.xres &&
1336
			if (var.xres >= rinfo->panel_info.xres &&
762
			    var.yres >= rinfo->panel_info.yres)
1337
			    var.yres >= rinfo->panel_info.yres)
763
				radeon_var_to_panel_info(rinfo, &var);
1338
				radeon_var_to_panel_info(rinfo, &var);
Lines 765-779 Link Here
765
	}
1340
	}
766
1341
767
	/*
1342
	/*
768
	 * Do any additional platform/arch fixups to the panel infos
769
	 */
770
	radeon_fixup_panel_info(rinfo);
771
772
	/*
773
	 * If we have some valid panel infos, we setup the default mode based on
1343
	 * If we have some valid panel infos, we setup the default mode based on
774
	 * those
1344
	 * those
775
	 */
1345
	 */
776
	if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid) {
1346
	if ((PRIMARY_MONITOR(rinfo) != MT_CRT) && rinfo->panel_info.valid) {
777
		struct fb_var_screeninfo *var = &info->var;
1347
		struct fb_var_screeninfo *var = &info->var;
778
1348
779
		RTRACE("Setting up default mode based on panel info\n");
1349
		RTRACE("Setting up default mode based on panel info\n");
Lines 804-816 Link Here
804
	/*
1374
	/*
805
	 * Now build modedb from EDID
1375
	 * Now build modedb from EDID
806
	 */
1376
	 */
807
	if (rinfo->mon1_EDID) {
1377
	if (PRIMARY_HEAD(rinfo).edid) {
808
		fb_edid_to_monspecs(rinfo->mon1_EDID, &info->monspecs);
1378
		fb_edid_to_monspecs(PRIMARY_HEAD(rinfo).edid, &info->monspecs);
809
		fb_videomode_to_modelist(info->monspecs.modedb,
1379
		fb_videomode_to_modelist(info->monspecs.modedb,
810
					 info->monspecs.modedb_len,
1380
					 info->monspecs.modedb_len,
811
					 &info->modelist);
1381
					 &info->modelist);
812
		rinfo->mon1_modedb = info->monspecs.modedb;
1382
		PRIMARY_HEAD(rinfo).modedb = info->monspecs.modedb;
813
		rinfo->mon1_dbsize = info->monspecs.modedb_len;
1383
		PRIMARY_HEAD(rinfo).modedb_size = info->monspecs.modedb_len;
814
	}
1384
	}
815
1385
816
	
1386
	
Lines 819-825 Link Here
819
	 * we try to read it from card), we try to pick a default mode
1389
	 * we try to read it from card), we try to pick a default mode
820
	 * and create some panel infos. Whatever...
1390
	 * and create some panel infos. Whatever...
821
	 */
1391
	 */
822
	if (rinfo->mon1_type != MT_CRT && !rinfo->panel_info.valid) {
1392
	if ((PRIMARY_MONITOR(rinfo) != MT_CRT) && !rinfo->panel_info.valid) {
823
		struct fb_videomode	*modedb;
1393
		struct fb_videomode	*modedb;
824
		int			dbsize;
1394
		int			dbsize;
825
		char			modename[32];
1395
		char			modename[32];
Lines 833-853 Link Here
833
		}
1403
		}
834
		if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) {
1404
		if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) {
835
			printk(KERN_WARNING "radeonfb: Can't find panel size, going back to CRT\n");
1405
			printk(KERN_WARNING "radeonfb: Can't find panel size, going back to CRT\n");
836
			rinfo->mon1_type = MT_CRT;
1406
			radeon_find_connector_for_mon(rinfo, MT_CRT);
837
			goto pickup_default;
1407
			goto pickup_default;
838
		}
1408
		}
839
		printk(KERN_WARNING "radeonfb: Assuming panel size %dx%d\n",
1409
		printk(KERN_WARNING "radeonfb: Assuming panel size %dx%d\n",
840
		       rinfo->panel_info.xres, rinfo->panel_info.yres);
1410
		       rinfo->panel_info.xres, rinfo->panel_info.yres);
841
		modedb = rinfo->mon1_modedb;
1411
		modedb = PRIMARY_HEAD(rinfo).modedb;
842
		dbsize = rinfo->mon1_dbsize;
1412
		dbsize = PRIMARY_HEAD(rinfo).modedb_size;
843
		snprintf(modename, 31, "%dx%d", rinfo->panel_info.xres, rinfo->panel_info.yres);
1413
		snprintf(modename, 31, "%dx%d", rinfo->panel_info.xres, rinfo->panel_info.yres);
844
		if (fb_find_mode(&info->var, info, modename,
1414
		if (fb_find_mode(&info->var, info, modename,
845
				 modedb, dbsize, NULL, 8) == 0) {
1415
				 modedb, dbsize, NULL, 8) == 0) {
846
			printk(KERN_WARNING "radeonfb: Can't find mode for panel size, going back to CRT\n");
1416
			printk(KERN_WARNING "radeonfb: Can't find mode for panel size, going back to CRT\n");
847
			rinfo->mon1_type = MT_CRT;
1417
			radeon_find_connector_for_mon(rinfo, MT_CRT);
848
			goto pickup_default;
1418
			goto pickup_default;
849
		}
1419
		}
850
		has_default_mode = 1;
1420
		has_default_mode = 1;
1421
		radeon_find_connector_for_mon(rinfo, MT_LCD);
851
		radeon_var_to_panel_info(rinfo, &info->var);
1422
		radeon_var_to_panel_info(rinfo, &info->var);
852
	}
1423
	}
853
1424
Lines 947-960 Link Here
947
	memcpy(dest, src, sizeof(struct fb_var_screeninfo));
1518
	memcpy(dest, src, sizeof(struct fb_var_screeninfo));
948
1519
949
	/* Check if we have a modedb built from EDID */
1520
	/* Check if we have a modedb built from EDID */
950
	if (rinfo->mon1_modedb) {
1521
	if (PRIMARY_HEAD(rinfo).modedb) {
951
		db = rinfo->mon1_modedb;
1522
		db = PRIMARY_HEAD(rinfo).modedb;
952
		dbsize = rinfo->mon1_dbsize;
1523
		dbsize = PRIMARY_HEAD(rinfo).modedb_size;
953
		native_db = 1;
1524
		native_db = 1;
954
	}
1525
	}
955
1526
956
	/* Check if we have a scaler allowing any fancy mode */
1527
	/* Check if we have a scaler allowing any fancy mode */
957
	has_rmx = rinfo->mon1_type == MT_LCD || rinfo->mon1_type == MT_DFP;
1528
	has_rmx = (PRIMARY_MONITOR(rinfo) == MT_LCD) || (PRIMARY_MONITOR(rinfo) == MT_DFP);
958
1529
959
	/* If we have a scaler and are passed FB_ACTIVATE_TEST or
1530
	/* If we have a scaler and are passed FB_ACTIVATE_TEST or
960
	 * FB_ACTIVATE_NOW, just do basic checking and return if the
1531
	 * FB_ACTIVATE_NOW, just do basic checking and return if the
Lines 967-973 Link Here
967
		 * 640x480-60, but I assume userland knows what it's doing here
1538
		 * 640x480-60, but I assume userland knows what it's doing here
968
		 * (though I may be proven wrong...)
1539
		 * (though I may be proven wrong...)
969
		 */
1540
		 */
970
		if (has_rmx == 0 && rinfo->mon1_modedb)
1541
		if (has_rmx == 0 && PRIMARY_HEAD(rinfo).modedb)
971
			if (fb_validate_mode((struct fb_var_screeninfo *)src, rinfo->info))
1542
			if (fb_validate_mode((struct fb_var_screeninfo *)src, rinfo->info))
972
				return -EINVAL;
1543
				return -EINVAL;
973
		return 0;
1544
		return 0;
(-)aty-2.6.18/radeonfb.h (-39 / +124 lines)
Lines 26-31 Link Here
26
 * Most of the definitions here are adapted right from XFree86 *
26
 * Most of the definitions here are adapted right from XFree86 *
27
 ***************************************************************/
27
 ***************************************************************/
28
28
29
/* Sorry, we have to limit video ram to 128M */
30
#define MAX_VRAM		(128*1024*1024)
29
31
30
/*
32
/*
31
 * Chip families. Must fit in the low 16 bits of a long word
33
 * Chip families. Must fit in the low 16 bits of a long word
Lines 47-53 Link Here
47
	CHIP_FAMILY_R350,
49
	CHIP_FAMILY_R350,
48
	CHIP_FAMILY_RV350,
50
	CHIP_FAMILY_RV350,
49
	CHIP_FAMILY_RV380,    /* RV370/RV380/M22/M24 */
51
	CHIP_FAMILY_RV380,    /* RV370/RV380/M22/M24 */
50
	CHIP_FAMILY_R420,     /* R420/R423/M18 */
52
	CHIP_FAMILY_RV410,    /* RV410/M26 */
53
	CHIP_FAMILY_R420,     /* R420/R423/R480/M18 */
51
	CHIP_FAMILY_LAST,
54
	CHIP_FAMILY_LAST,
52
};
55
};
53
56
Lines 64-69 Link Here
64
				((rinfo)->family == CHIP_FAMILY_RV350) || \
67
				((rinfo)->family == CHIP_FAMILY_RV350) || \
65
				((rinfo)->family == CHIP_FAMILY_R350)  || \
68
				((rinfo)->family == CHIP_FAMILY_R350)  || \
66
				((rinfo)->family == CHIP_FAMILY_RV380) || \
69
				((rinfo)->family == CHIP_FAMILY_RV380) || \
70
				((rinfo)->family == CHIP_FAMILY_RV410) || \
67
				((rinfo)->family == CHIP_FAMILY_R420))
71
				((rinfo)->family == CHIP_FAMILY_R420))
68
72
69
/*
73
/*
Lines 86-96 Link Here
86
	CHIP_ERRATA_PLL_DELAY		= 0x00000004,
90
	CHIP_ERRATA_PLL_DELAY		= 0x00000004,
87
};
91
};
88
92
93
/*
94
 * DDC i2c ports
95
 */
96
enum radeon_ddc_type {
97
	ddc_none = -1,
98
	ddc_monid = 0,
99
	ddc_dvi,
100
	ddc_vga,
101
	ddc_crt2,
102
};
103
104
/*
105
 * Connector types
106
 */
107
enum radeon_legacy_conn_type {
108
	legacy_conn_none = 0,
109
	legacy_conn_proprietary,
110
	legacy_conn_crt,
111
	legacy_conn_dvi_i,
112
	legacy_conn_dvi_d,
113
	legacy_conn_ctv,
114
	legacy_conn_stv,
115
	legacy_conn_unsupported,
116
};
117
118
enum radeon_conn_type {
119
	conn_none = 0,
120
	conn_vga,
121
	conn_dvi_i,
122
	conn_dvi_d,
123
	conn_dvi_a,
124
	conn_stv,
125
	conn_ctv,
126
	conn_lvds,
127
	conn_digital,
128
	conn_unsupported,
129
	conn_proprietary,
130
};
89
131
90
/*
132
/*
91
 * Monitor types
133
 * Monitor types
92
 */
134
 */
93
enum radeon_montype {
135
enum radeon_mon_type {
136
	MT_UNKNOWN = -1,
94
	MT_NONE = 0,
137
	MT_NONE = 0,
95
	MT_CRT,		/* CRT */
138
	MT_CRT,		/* CRT */
96
	MT_LCD,		/* LCD */
139
	MT_LCD,		/* LCD */
Lines 100-126 Link Here
100
};
143
};
101
144
102
/*
145
/*
103
 * DDC i2c ports
146
 * DAC types
104
 */
147
 */
105
enum ddc_type {
148
enum radeon_dac_type {
106
	ddc_none,
149
	dac_unknown = -1,
107
	ddc_monid,
150
	dac_primary = 0,
108
	ddc_dvi,
151
	dac_tvdac = 1,
109
	ddc_vga,
110
	ddc_crt2,
111
};
152
};
112
153
113
/*
154
/*
114
 * Connector types
155
 * TMDS types
115
 */
156
 */
116
enum conn_type {
157
enum radeon_tmds_type {
117
	conn_none,
158
	tmds_unknown = -1,
118
	conn_proprietary,
159
	tmds_internal = 0,
119
	conn_crt,
160
	tmds_external = 1,
120
	conn_DVI_I,
121
	conn_DVI_D,
122
};
161
};
123
162
163
/*
164
 * Each connector gets this structure associated with it,
165
 * containing infos about the connector wiring and about
166
 * whatever has been detected on it
167
 */
168
struct radeon_connector {
169
	enum radeon_conn_type	conn_type;
170
	enum radeon_ddc_type	ddc_type;
171
	enum radeon_dac_type	dac_type;
172
	enum radeon_tmds_type	tmds_type;
173
	enum radeon_mon_type	mon_type;
174
	u8			*edid;
175
	struct fb_videomode	*modedb;
176
	unsigned int		modedb_size;
177
178
	int head;
179
};
180
181
/*
182
 * Currently, the driver deals with at most 4 connectors
183
 */
184
#define RADEON_MAX_CONNECTORS	4
124
185
125
/*
186
/*
126
 * PLL infos
187
 * PLL infos
Lines 128-138 Link Here
128
struct pll_info {
189
struct pll_info {
129
	int ppll_max;
190
	int ppll_max;
130
	int ppll_min;
191
	int ppll_min;
131
	int sclk, mclk;
192
	int sclk;
193
	int mclk;
132
	int ref_div;
194
	int ref_div;
133
	int ref_clk;
195
	int ref_clk;
134
};
196
};
135
197
198
/*
199
 * TMDS PLL infos
200
 */
201
struct radeon_tmds_pll_info {
202
	long	freq;
203
	u32	value;
204
};
136
205
137
/*
206
/*
138
 * This structure contains the various registers manipulated by this
207
 * This structure contains the various registers manipulated by this
Lines 299-304 Link Here
299
	void __iomem		*bios_seg;
368
	void __iomem		*bios_seg;
300
	int			fp_bios_start;
369
	int			fp_bios_start;
301
370
371
	int                     is_atom_bios;
372
	int                     atom_data_start;
373
	
374
	/* BIOS Functions */
375
	int                     (*radeon_get_pll_info)(struct radeonfb_info *rinfo);
376
	int                     (*radeon_get_lvds_info)(struct radeonfb_info *rinfo);
377
	int                     (*radeon_get_conn_info)(struct radeonfb_info *rinfo);
378
	int                     (*radeon_get_tmds_info)(struct radeonfb_info *rinfo);
379
380
	/* Connector infos */
381
	struct radeon_connector		connectors[RADEON_MAX_CONNECTORS];
382
	int                     heads[RADEON_MAX_CONNECTORS];  // index into connectors.
383
	int                     num_heads;  // number of heads.
384
302
	u32			pseudo_palette[17];
385
	u32			pseudo_palette[17];
303
	struct { u8 red, green, blue, pad; }
386
	struct { u8 red, green, blue, pad; }
304
				palette[256];
387
				palette[256];
Lines 317-331 Link Here
317
	int			has_CRTC2;
400
	int			has_CRTC2;
318
	int			is_mobility;
401
	int			is_mobility;
319
	int			is_IGP;
402
	int			is_IGP;
320
	int			reversed_DAC;
321
	int			reversed_TMDS;
322
	struct panel_info	panel_info;
403
	struct panel_info	panel_info;
323
	int			mon1_type;
404
	struct radeon_tmds_pll_info	tmds_pll[4];
324
	u8			*mon1_EDID;
325
	struct fb_videomode	*mon1_modedb;
326
	int			mon1_dbsize;
327
	int			mon2_type;
328
	u8		        *mon2_EDID;
329
405
330
	u32			dp_gui_master_cntl;
406
	u32			dp_gui_master_cntl;
331
407
Lines 357-380 Link Here
357
};
433
};
358
434
359
435
360
#define PRIMARY_MONITOR(rinfo)	(rinfo->mon1_type)
436
#define PRIMARY_HEAD(rinfo)      (rinfo->connectors[rinfo->heads[0]])
437
#define SECONDARY_HEAD(rinfo)    (rinfo->connectors[rinfo->heads[1]])
361
438
439
#define SECONDARY_HEAD_PRESENT(rinfo) (rinfo->heads[1] != -1)
440
441
#define PRIMARY_MONITOR(rinfo)	 (rinfo->connectors[rinfo->heads[0]].mon_type)
442
#define SECONDARY_MONITOR(rinfo) ((SECONDARY_HEAD_PRESENT(rinfo) ? (rinfo->connectors[rinfo->heads[1]].mon_type) : MT_NONE))
362
443
363
/*
444
/*
364
 * Debugging stuffs
445
 * Debugging stuffs
365
 */
446
 */
366
#ifdef CONFIG_FB_RADEON_DEBUG
447
extern int radeonfb_debug;
367
#define DEBUG		1
448
#define RTRACE		if(radeonfb_debug) printk
368
#else
369
#define DEBUG		0
370
#endif
371
372
#if DEBUG
373
#define RTRACE		printk
374
#else
375
#define RTRACE		if(0) printk
376
#endif
377
378
449
379
/*
450
/*
380
 * IO macros
451
 * IO macros
Lines 597-603 Link Here
597
/* I2C Functions */
668
/* I2C Functions */
598
extern void radeon_create_i2c_busses(struct radeonfb_info *rinfo);
669
extern void radeon_create_i2c_busses(struct radeonfb_info *rinfo);
599
extern void radeon_delete_i2c_busses(struct radeonfb_info *rinfo);
670
extern void radeon_delete_i2c_busses(struct radeonfb_info *rinfo);
600
extern int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn, u8 **out_edid);
671
extern int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, struct radeon_connector *conn);
601
672
602
/* PM Functions */
673
/* PM Functions */
603
extern int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state);
674
extern int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state);
Lines 635-638 Link Here
635
static inline void radeonfb_bl_exit(struct radeonfb_info *rinfo) {}
706
static inline void radeonfb_bl_exit(struct radeonfb_info *rinfo) {}
636
#endif
707
#endif
637
708
709
/* Bios functions.  Fix this. */
710
extern void __devinit radeon_get_conn_info(struct radeonfb_info *rinfo, int ignore_conntable);
711
extern void __devinit radeon_get_tmds_info(struct radeonfb_info *rinfo);
712
713
extern int __devinit radeon_get_lvds_info_atom(struct radeonfb_info *rinfo);
714
extern int __devinit radeon_get_lvds_info_legacy(struct radeonfb_info *rinfo);
715
extern int __devinit radeon_get_conn_info_atom(struct radeonfb_info *rinfo);
716
extern int __devinit radeon_get_conn_info_legacy(struct radeonfb_info *rinfo);
717
extern int __devinit radeon_get_tmds_info_legacy(struct radeonfb_info *rinfo);
718
extern int __devinit radeon_get_tmds_info_atom(struct radeonfb_info *rinfo);
719
#ifdef CONFIG_PPC_OF
720
extern int __devinit radeon_get_lvds_info_openfirmware(struct radeonfb_info *rinfo);
721
extern int __devinit radeon_get_conn_info_openfirmware(struct radeonfb_info *rinfo);
722
#endif
638
#endif /* __RADEONFB_H__ */
723
#endif /* __RADEONFB_H__ */

Return to bug 162628