Subversion Repositories Kolibri OS

Rev

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

Rev 1268 Rev 1321
Line 45... Line 45...
45
			  uint32_t connector_id,
45
			  uint32_t connector_id,
46
			  uint32_t supported_device,
46
			  uint32_t supported_device,
47
			  int connector_type,
47
			  int connector_type,
48
			  struct radeon_i2c_bus_rec *i2c_bus,
48
			  struct radeon_i2c_bus_rec *i2c_bus,
49
			  bool linkb, uint32_t igp_lane_info,
49
			  bool linkb, uint32_t igp_lane_info,
50
			  uint16_t connector_object_id);
50
			  uint16_t connector_object_id,
-
 
51
			  struct radeon_hpd *hpd);
Line 51... Line 52...
51
 
52
 
52
/* from radeon_legacy_encoder.c */
53
/* from radeon_legacy_encoder.c */
53
extern void
54
extern void
54
radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
55
radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
Line 58... Line 59...
58
	struct _ATOM_SUPPORTED_DEVICES_INFO info;
59
	struct _ATOM_SUPPORTED_DEVICES_INFO info;
59
	struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
60
	struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
60
	struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1;
61
	struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1;
61
};
62
};
Line 62... Line 63...
62
 
63
 
63
static inline struct radeon_i2c_bus_rec radeon_lookup_gpio(struct drm_device
64
static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev,
64
							   *dev, uint8_t id)
65
							       uint8_t id)
65
{
-
 
66
	struct radeon_device *rdev = dev->dev_private;
66
{
67
	struct atom_context *ctx = rdev->mode_info.atom_context;
67
	struct atom_context *ctx = rdev->mode_info.atom_context;
68
	ATOM_GPIO_I2C_ASSIGMENT gpio;
68
	ATOM_GPIO_I2C_ASSIGMENT *gpio;
69
	struct radeon_i2c_bus_rec i2c;
69
	struct radeon_i2c_bus_rec i2c;
70
	int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
70
	int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
71
	struct _ATOM_GPIO_I2C_INFO *i2c_info;
71
	struct _ATOM_GPIO_I2C_INFO *i2c_info;
-
 
72
	uint16_t data_offset;
Line 72... Line 73...
72
	uint16_t data_offset;
73
	int i;
73
 
74
 
Line 74... Line 75...
74
	memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
75
	memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
Line 75... Line 76...
75
	i2c.valid = false;
76
	i2c.valid = false;
Line 76... Line -...
76
 
-
 
Line -... Line 77...
-
 
77
 
-
 
78
	atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
-
 
79
 
-
 
80
	i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
77
	atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset);
81
 
78
 
82
 
79
	i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
83
	for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
80
 
84
		gpio = &i2c_info->asGPIO_Info[i];
81
	gpio = i2c_info->asGPIO_Info[id];
85
 
82
 
86
		if (gpio->sucI2cId.ucAccess == id) {
83
	i2c.mask_clk_reg = le16_to_cpu(gpio.usClkMaskRegisterIndex) * 4;
87
			i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
84
	i2c.mask_data_reg = le16_to_cpu(gpio.usDataMaskRegisterIndex) * 4;
88
			i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
85
	i2c.put_clk_reg = le16_to_cpu(gpio.usClkEnRegisterIndex) * 4;
89
			i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
86
	i2c.put_data_reg = le16_to_cpu(gpio.usDataEnRegisterIndex) * 4;
90
			i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
87
	i2c.get_clk_reg = le16_to_cpu(gpio.usClkY_RegisterIndex) * 4;
91
			i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
88
	i2c.get_data_reg = le16_to_cpu(gpio.usDataY_RegisterIndex) * 4;
92
			i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
89
	i2c.a_clk_reg = le16_to_cpu(gpio.usClkA_RegisterIndex) * 4;
93
			i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
90
	i2c.a_data_reg = le16_to_cpu(gpio.usDataA_RegisterIndex) * 4;
94
			i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
91
	i2c.mask_clk_mask = (1 << gpio.ucClkMaskShift);
95
			i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
92
	i2c.mask_data_mask = (1 << gpio.ucDataMaskShift);
96
			i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
-
 
97
			i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
-
 
98
			i2c.en_data_mask = (1 << gpio->ucDataEnShift);
-
 
99
			i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
-
 
100
			i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
-
 
101
			i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
-
 
102
			i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
-
 
103
 
-
 
104
			if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
-
 
105
				i2c.hw_capable = true;
-
 
106
			else
-
 
107
				i2c.hw_capable = false;
-
 
108
 
-
 
109
			if (gpio->sucI2cId.ucAccess == 0xa0)
93
	i2c.put_clk_mask = (1 << gpio.ucClkEnShift);
110
				i2c.mm_i2c = true;
-
 
111
			else
-
 
112
				i2c.mm_i2c = false;
Line 94... Line 113...
94
	i2c.put_data_mask = (1 << gpio.ucDataEnShift);
113
 
95
	i2c.get_clk_mask = (1 << gpio.ucClkY_Shift);
114
			i2c.i2c_id = gpio->sucI2cId.ucAccess;
Line -... Line 115...
-
 
115
 
-
 
116
	i2c.valid = true;
-
 
117
		}
-
 
118
	}
-
 
119
 
-
 
120
	return i2c;
-
 
121
}
-
 
122
 
-
 
123
static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev,
-
 
124
							u8 id)
-
 
125
{
-
 
126
	struct atom_context *ctx = rdev->mode_info.atom_context;
-
 
127
	struct radeon_gpio_rec gpio;
-
 
128
	int index = GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT);
-
 
129
	struct _ATOM_GPIO_PIN_LUT *gpio_info;
-
 
130
	ATOM_GPIO_PIN_ASSIGNMENT *pin;
-
 
131
	u16 data_offset, size;
-
 
132
	int i, num_indices;
-
 
133
 
-
 
134
	memset(&gpio, 0, sizeof(struct radeon_gpio_rec));
-
 
135
	gpio.valid = false;
-
 
136
 
-
 
137
	atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset);
-
 
138
 
-
 
139
	gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset);
-
 
140
 
-
 
141
	num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(ATOM_GPIO_PIN_ASSIGNMENT);
-
 
142
 
-
 
143
	for (i = 0; i < num_indices; i++) {
-
 
144
		pin = &gpio_info->asGPIO_Pin[i];
-
 
145
		if (id == pin->ucGPIO_ID) {
-
 
146
			gpio.id = pin->ucGPIO_ID;
-
 
147
			gpio.reg = pin->usGpioPin_AIndex * 4;
-
 
148
			gpio.mask = (1 << pin->ucGpioPinBitShift);
-
 
149
			gpio.valid = true;
-
 
150
			break;
-
 
151
		}
-
 
152
	}
-
 
153
 
-
 
154
	return gpio;
-
 
155
}
-
 
156
 
-
 
157
static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device *rdev,
-
 
158
							    struct radeon_gpio_rec *gpio)
-
 
159
{
-
 
160
	struct radeon_hpd hpd;
-
 
161
	hpd.gpio = *gpio;
-
 
162
	if (gpio->reg == AVIVO_DC_GPIO_HPD_A) {
-
 
163
		switch(gpio->mask) {
-
 
164
		case (1 << 0):
-
 
165
			hpd.hpd = RADEON_HPD_1;
-
 
166
			break;
-
 
167
		case (1 << 8):
-
 
168
			hpd.hpd = RADEON_HPD_2;
-
 
169
			break;
-
 
170
		case (1 << 16):
-
 
171
			hpd.hpd = RADEON_HPD_3;
-
 
172
			break;
-
 
173
		case (1 << 24):
-
 
174
			hpd.hpd = RADEON_HPD_4;
-
 
175
			break;
-
 
176
		case (1 << 26):
-
 
177
			hpd.hpd = RADEON_HPD_5;
-
 
178
			break;
-
 
179
		case (1 << 28):
-
 
180
			hpd.hpd = RADEON_HPD_6;
-
 
181
			break;
-
 
182
		default:
96
	i2c.get_data_mask = (1 << gpio.ucDataY_Shift);
183
			hpd.hpd = RADEON_HPD_NONE;
97
	i2c.a_clk_mask = (1 << gpio.ucClkA_Shift);
184
			break;
98
	i2c.a_data_mask = (1 << gpio.ucDataA_Shift);
185
		}
99
	i2c.valid = true;
186
	} else
100
 
187
		hpd.hpd = RADEON_HPD_NONE;
-
 
188
	return hpd;
101
	return i2c;
189
}
Line 102... Line 190...
102
}
190
 
103
 
191
static bool radeon_atom_apply_quirks(struct drm_device *dev,
104
static bool radeon_atom_apply_quirks(struct drm_device *dev,
192
				     uint32_t supported_device,
Line 133... Line 221...
133
			i2c_bus->valid = false;
221
			i2c_bus->valid = false;
134
			*line_mux = 53;
222
			*line_mux = 53;
135
		}
223
		}
136
	}
224
	}
Line -... Line 225...
-
 
225
 
-
 
226
	/* HIS X1300 is DVI+VGA, not DVI+DVI */
-
 
227
	if ((dev->pdev->device == 0x7146) &&
-
 
228
	    (dev->pdev->subsystem_vendor == 0x17af) &&
-
 
229
	    (dev->pdev->subsystem_device == 0x2058)) {
-
 
230
		if (supported_device == ATOM_DEVICE_DFP1_SUPPORT)
-
 
231
			return false;
-
 
232
	}
-
 
233
 
-
 
234
	/* Gigabyte X1300 is DVI+VGA, not DVI+DVI */
-
 
235
	if ((dev->pdev->device == 0x7142) &&
-
 
236
	    (dev->pdev->subsystem_vendor == 0x1458) &&
-
 
237
	    (dev->pdev->subsystem_device == 0x2134)) {
-
 
238
		if (supported_device == ATOM_DEVICE_DFP1_SUPPORT)
-
 
239
			return false;
-
 
240
	}
-
 
241
 
137
 
242
 
138
	/* Funky macbooks */
243
	/* Funky macbooks */
139
	if ((dev->pdev->device == 0x71C5) &&
244
	if ((dev->pdev->device == 0x71C5) &&
140
	    (dev->pdev->subsystem_vendor == 0x106b) &&
245
	    (dev->pdev->subsystem_vendor == 0x106b) &&
141
	    (dev->pdev->subsystem_device == 0x0080)) {
246
	    (dev->pdev->subsystem_device == 0x0080)) {
Line 170... Line 275...
170
			*connector_type = DRM_MODE_CONNECTOR_VGA;
275
			*connector_type = DRM_MODE_CONNECTOR_VGA;
171
			*line_mux = 0;
276
			*line_mux = 0;
172
		}
277
		}
173
	}
278
	}
Line -... Line 279...
-
 
279
 
-
 
280
	/* Acer laptop reports DVI-D as DVI-I */
-
 
281
	if ((dev->pdev->device == 0x95c4) &&
-
 
282
	    (dev->pdev->subsystem_vendor == 0x1025) &&
-
 
283
	    (dev->pdev->subsystem_device == 0x013c)) {
-
 
284
		if ((*connector_type == DRM_MODE_CONNECTOR_DVII) &&
-
 
285
		    (supported_device == ATOM_DEVICE_DFP1_SUPPORT))
-
 
286
			*connector_type = DRM_MODE_CONNECTOR_DVID;
-
 
287
	}
174
 
288
 
175
	return true;
289
	return true;
Line 176... Line 290...
176
}
290
}
177
 
291
 
Line 238... Line 352...
238
{
352
{
239
	struct radeon_device *rdev = dev->dev_private;
353
	struct radeon_device *rdev = dev->dev_private;
240
	struct radeon_mode_info *mode_info = &rdev->mode_info;
354
	struct radeon_mode_info *mode_info = &rdev->mode_info;
241
	struct atom_context *ctx = mode_info->atom_context;
355
	struct atom_context *ctx = mode_info->atom_context;
242
	int index = GetIndexIntoMasterTable(DATA, Object_Header);
356
	int index = GetIndexIntoMasterTable(DATA, Object_Header);
243
	uint16_t size, data_offset;
357
	u16 size, data_offset;
244
	uint8_t frev, crev, line_mux = 0;
358
	u8 frev, crev;
245
	ATOM_CONNECTOR_OBJECT_TABLE *con_obj;
359
	ATOM_CONNECTOR_OBJECT_TABLE *con_obj;
246
	ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
360
	ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
247
	ATOM_OBJECT_HEADER *obj_header;
361
	ATOM_OBJECT_HEADER *obj_header;
248
	int i, j, path_size, device_support;
362
	int i, j, path_size, device_support;
249
	int connector_type;
363
	int connector_type;
250
	uint16_t igp_lane_info, conn_id, connector_object_id;
364
	u16 igp_lane_info, conn_id, connector_object_id;
251
	bool linkb;
365
	bool linkb;
252
	struct radeon_i2c_bus_rec ddc_bus;
366
	struct radeon_i2c_bus_rec ddc_bus;
-
 
367
	struct radeon_gpio_rec gpio;
-
 
368
	struct radeon_hpd hpd;
Line 253... Line 369...
253
 
369
 
Line 254... Line 370...
254
	atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
370
	atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
255
 
371
 
Line 274... Line 390...
274
		ATOM_DISPLAY_OBJECT_PATH *path;
390
		ATOM_DISPLAY_OBJECT_PATH *path;
275
		addr += path_size;
391
		addr += path_size;
276
		path = (ATOM_DISPLAY_OBJECT_PATH *) addr;
392
		path = (ATOM_DISPLAY_OBJECT_PATH *) addr;
277
		path_size += le16_to_cpu(path->usSize);
393
		path_size += le16_to_cpu(path->usSize);
278
		linkb = false;
394
		linkb = false;
279
 
-
 
280
		if (device_support & le16_to_cpu(path->usDeviceTag)) {
395
		if (device_support & le16_to_cpu(path->usDeviceTag)) {
281
			uint8_t con_obj_id, con_obj_num, con_obj_type;
396
			uint8_t con_obj_id, con_obj_num, con_obj_type;
Line 282... Line 397...
282
 
397
 
283
			con_obj_id =
398
			con_obj_id =
Line 375... Line 490...
375
								 usDeviceTag));
490
								 usDeviceTag));
Line 376... Line 491...
376
 
491
 
377
				}
492
				}
Line 378... Line 493...
378
			}
493
			}
379
 
494
 
380
			/* look up gpio for ddc */
495
			/* look up gpio for ddc, hpd */
381
			if ((le16_to_cpu(path->usDeviceTag) &
-
 
382
			     (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
496
			if ((le16_to_cpu(path->usDeviceTag) &
383
			    == 0) {
497
			     (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) == 0) {
384
				for (j = 0; j < con_obj->ucNumberOfObjects; j++) {
498
				for (j = 0; j < con_obj->ucNumberOfObjects; j++) {
385
					if (le16_to_cpu(path->usConnObjectId) ==
499
					if (le16_to_cpu(path->usConnObjectId) ==
386
					    le16_to_cpu(con_obj->asObjects[j].
500
					    le16_to_cpu(con_obj->asObjects[j].
Line 392... Line 506...
392
						    (ctx->bios + data_offset +
506
						    (ctx->bios + data_offset +
393
						     le16_to_cpu(con_obj->
507
						     le16_to_cpu(con_obj->
394
								 asObjects[j].
508
								 asObjects[j].
395
								 usRecordOffset));
509
								 usRecordOffset));
396
						ATOM_I2C_RECORD *i2c_record;
510
						ATOM_I2C_RECORD *i2c_record;
-
 
511
						ATOM_HPD_INT_RECORD *hpd_record;
-
 
512
						ATOM_I2C_ID_CONFIG_ACCESS *i2c_config;
-
 
513
						hpd.hpd = RADEON_HPD_NONE;
Line 397... Line 514...
397
 
514
 
398
						while (record->ucRecordType > 0
515
						while (record->ucRecordType > 0
399
						       && record->
516
						       && record->
400
						       ucRecordType <=
517
						       ucRecordType <=
401
						       ATOM_MAX_OBJECT_RECORD_NUMBER) {
518
						       ATOM_MAX_OBJECT_RECORD_NUMBER) {
402
							switch (record->
-
 
403
								ucRecordType) {
519
							switch (record->ucRecordType) {
404
							case ATOM_I2C_RECORD_TYPE:
520
							case ATOM_I2C_RECORD_TYPE:
405
								i2c_record =
521
								i2c_record =
406
								    (ATOM_I2C_RECORD
522
								    (ATOM_I2C_RECORD *)
407
								     *) record;
523
									record;
-
 
524
								i2c_config =
-
 
525
									(ATOM_I2C_ID_CONFIG_ACCESS *)
-
 
526
									&i2c_record->sucI2cId;
408
								line_mux =
527
								ddc_bus = radeon_lookup_i2c_gpio(rdev,
409
								    i2c_record->
528
												 i2c_config->
-
 
529
												 ucAccess);
-
 
530
								break;
410
								    sucI2cId.
531
							case ATOM_HPD_INT_RECORD_TYPE:
-
 
532
								hpd_record =
-
 
533
									(ATOM_HPD_INT_RECORD *)
-
 
534
									record;
-
 
535
								gpio = radeon_lookup_gpio(rdev,
-
 
536
											  hpd_record->ucHPDIntGPIOID);
-
 
537
								hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio);
411
								    bfI2C_LineMux;
538
								hpd.plugged_state = hpd_record->ucPlugged_PinState;
412
								break;
539
								break;
413
							}
540
							}
414
							record =
541
							record =
415
							    (ATOM_COMMON_RECORD_HEADER
542
							    (ATOM_COMMON_RECORD_HEADER
Line 419... Line 546...
419
								 ucRecordSize);
546
								 ucRecordSize);
420
						}
547
						}
421
						break;
548
						break;
422
					}
549
					}
423
				}
550
				}
424
			} else
551
			} else {
425
				line_mux = 0;
-
 
426
 
-
 
427
			if ((le16_to_cpu(path->usDeviceTag) ==
-
 
428
			     ATOM_DEVICE_TV1_SUPPORT)
-
 
429
			    || (le16_to_cpu(path->usDeviceTag) ==
-
 
430
				ATOM_DEVICE_TV2_SUPPORT)
552
				hpd.hpd = RADEON_HPD_NONE;
431
			    || (le16_to_cpu(path->usDeviceTag) ==
-
 
432
				ATOM_DEVICE_CV_SUPPORT))
-
 
433
				ddc_bus.valid = false;
553
				ddc_bus.valid = false;
434
			else
554
			}
435
				ddc_bus = radeon_lookup_gpio(dev, line_mux);
-
 
Line 436... Line 555...
436
 
555
 
Line 437... Line 556...
437
			conn_id = le16_to_cpu(path->usConnObjectId);
556
			conn_id = le16_to_cpu(path->usConnObjectId);
438
 
557
 
439
			if (!radeon_atom_apply_quirks
558
			if (!radeon_atom_apply_quirks
440
			    (dev, le16_to_cpu(path->usDeviceTag), &connector_type,
559
			    (dev, le16_to_cpu(path->usDeviceTag), &connector_type,
Line 441... Line 560...
441
			     &ddc_bus, &conn_id))
560
			     &ddc_bus, &conn_id, &hpd))
442
				continue;
561
				continue;
443
 
562
 
444
			radeon_add_atom_connector(dev,
563
			radeon_add_atom_connector(dev,
445
						  conn_id,
564
						  conn_id,
446
						  le16_to_cpu(path->
565
						  le16_to_cpu(path->
447
							      usDeviceTag),
566
							      usDeviceTag),
-
 
567
						  connector_type, &ddc_bus,
Line 448... Line 568...
448
						  connector_type, &ddc_bus,
568
						  linkb, igp_lane_info,
449
						  linkb, igp_lane_info,
569
						  connector_object_id,
Line 450... Line 570...
450
						  connector_object_id);
570
						  &hpd);
Line 500... Line 620...
500
	bool valid;
620
	bool valid;
501
	uint16_t line_mux;
621
	uint16_t line_mux;
502
	uint16_t devices;
622
	uint16_t devices;
503
	int connector_type;
623
	int connector_type;
504
	struct radeon_i2c_bus_rec ddc_bus;
624
	struct radeon_i2c_bus_rec ddc_bus;
-
 
625
	struct radeon_hpd hpd;
505
};
626
};
Line 506... Line 627...
506
 
627
 
507
bool radeon_get_atom_connector_info_from_supported_devices_table(struct
628
bool radeon_get_atom_connector_info_from_supported_devices_table(struct
508
								 drm_device
629
								 drm_device
Line 515... Line 636...
515
	uint16_t size, data_offset;
636
	uint16_t size, data_offset;
516
	uint8_t frev, crev;
637
	uint8_t frev, crev;
517
	uint16_t device_support;
638
	uint16_t device_support;
518
	uint8_t dac;
639
	uint8_t dac;
519
	union atom_supported_devices *supported_devices;
640
	union atom_supported_devices *supported_devices;
520
	int i, j;
641
	int i, j, max_device;
521
	struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
642
	struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
Line 522... Line 643...
522
 
643
 
Line 523... Line 644...
523
	atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
644
	atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset);
524
 
645
 
Line 525... Line 646...
525
	supported_devices =
646
	supported_devices =
Line -... Line 647...
-
 
647
	    (union atom_supported_devices *)(ctx->bios + data_offset);
-
 
648
 
-
 
649
	device_support = le16_to_cpu(supported_devices->info.usDeviceSupport);
526
	    (union atom_supported_devices *)(ctx->bios + data_offset);
650
 
-
 
651
	if (frev > 1)
-
 
652
		max_device = ATOM_MAX_SUPPORTED_DEVICE;
527
 
653
	else
528
	device_support = le16_to_cpu(supported_devices->info.usDeviceSupport);
654
		max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO;
Line 529... Line 655...
529
 
655
 
Line 551... Line 677...
551
		    DRM_MODE_CONNECTOR_Unknown)
677
		    DRM_MODE_CONNECTOR_Unknown)
552
			continue;
678
			continue;
Line 553... Line 679...
553
 
679
 
Line 554... Line -...
554
		dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC;
-
 
555
 
-
 
556
		if ((rdev->family == CHIP_RS690) ||
-
 
557
		    (rdev->family == CHIP_RS740)) {
-
 
558
			if ((i == ATOM_DEVICE_DFP2_INDEX)
680
		dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC;
559
			    && (ci.sucI2cId.sbfAccess.bfI2C_LineMux == 2))
-
 
560
				bios_connectors[i].line_mux =
-
 
561
				    ci.sucI2cId.sbfAccess.bfI2C_LineMux + 1;
-
 
562
			else if ((i == ATOM_DEVICE_DFP3_INDEX)
-
 
563
				 && (ci.sucI2cId.sbfAccess.bfI2C_LineMux == 1))
-
 
564
				bios_connectors[i].line_mux =
-
 
565
				    ci.sucI2cId.sbfAccess.bfI2C_LineMux + 1;
-
 
566
			else
-
 
567
				bios_connectors[i].line_mux =
-
 
568
				    ci.sucI2cId.sbfAccess.bfI2C_LineMux;
-
 
569
		} else
681
 
Line 570... Line 682...
570
			bios_connectors[i].line_mux =
682
				bios_connectors[i].line_mux =
571
			    ci.sucI2cId.sbfAccess.bfI2C_LineMux;
683
			ci.sucI2cId.ucAccess;
572
 
684
 
573
		/* give tv unique connector ids */
685
		/* give tv unique connector ids */
Line 580... Line 692...
580
		} else if (i == ATOM_DEVICE_CV_INDEX) {
692
		} else if (i == ATOM_DEVICE_CV_INDEX) {
581
			bios_connectors[i].ddc_bus.valid = false;
693
			bios_connectors[i].ddc_bus.valid = false;
582
			bios_connectors[i].line_mux = 52;
694
			bios_connectors[i].line_mux = 52;
583
		} else
695
		} else
584
			bios_connectors[i].ddc_bus =
696
			bios_connectors[i].ddc_bus =
585
			    radeon_lookup_gpio(dev,
697
			    radeon_lookup_i2c_gpio(rdev,
586
					       bios_connectors[i].line_mux);
698
					       bios_connectors[i].line_mux);
Line -... Line 699...
-
 
699
 
-
 
700
		if ((crev > 1) && (frev > 1)) {
-
 
701
			u8 isb = supported_devices->info_2d1.asIntSrcInfo[i].ucIntSrcBitmap;
-
 
702
			switch (isb) {
-
 
703
			case 0x4:
-
 
704
				bios_connectors[i].hpd.hpd = RADEON_HPD_1;
-
 
705
				break;
-
 
706
			case 0xa:
-
 
707
				bios_connectors[i].hpd.hpd = RADEON_HPD_2;
-
 
708
				break;
-
 
709
			default:
-
 
710
				bios_connectors[i].hpd.hpd = RADEON_HPD_NONE;
-
 
711
				break;
-
 
712
			}
-
 
713
		} else {
-
 
714
			if (i == ATOM_DEVICE_DFP1_INDEX)
-
 
715
				bios_connectors[i].hpd.hpd = RADEON_HPD_1;
-
 
716
			else if (i == ATOM_DEVICE_DFP2_INDEX)
-
 
717
				bios_connectors[i].hpd.hpd = RADEON_HPD_2;
-
 
718
			else
-
 
719
				bios_connectors[i].hpd.hpd = RADEON_HPD_NONE;
-
 
720
		}
587
 
721
 
588
		/* Always set the connector type to VGA for CRT1/CRT2. if they are
722
		/* Always set the connector type to VGA for CRT1/CRT2. if they are
589
		 * shared with a DVI port, we'll pick up the DVI connector when we
723
		 * shared with a DVI port, we'll pick up the DVI connector when we
590
		 * merge the outputs.  Some bioses incorrectly list VGA ports as DVI.
724
		 * merge the outputs.  Some bioses incorrectly list VGA ports as DVI.
591
		 */
725
		 */
592
		if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX)
726
		if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX)
593
			bios_connectors[i].connector_type =
727
			bios_connectors[i].connector_type =
Line 594... Line 728...
594
			    DRM_MODE_CONNECTOR_VGA;
728
			    DRM_MODE_CONNECTOR_VGA;
595
 
729
 
596
		if (!radeon_atom_apply_quirks
730
		if (!radeon_atom_apply_quirks
-
 
731
		    (dev, (1 << i), &bios_connectors[i].connector_type,
597
		    (dev, (1 << i), &bios_connectors[i].connector_type,
732
		     &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux,
Line 598... Line 733...
598
		     &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux))
733
		     &bios_connectors[i].hpd))
599
			continue;
734
			continue;
Line 615... Line 750...
615
									dac),
750
									dac),
616
						  (1 << i));
751
						  (1 << i));
617
	}
752
	}
Line 618... Line 753...
618
 
753
 
619
	/* combine shared connectors */
754
	/* combine shared connectors */
620
	for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
755
	for (i = 0; i < max_device; i++) {
621
		if (bios_connectors[i].valid) {
756
		if (bios_connectors[i].valid) {
622
			for (j = 0; j < ATOM_MAX_SUPPORTED_DEVICE; j++) {
757
			for (j = 0; j < max_device; j++) {
623
				if (bios_connectors[j].valid && (i != j)) {
758
				if (bios_connectors[j].valid && (i != j)) {
624
					if (bios_connectors[i].line_mux ==
759
					if (bios_connectors[i].line_mux ==
625
					    bios_connectors[j].line_mux) {
760
					    bios_connectors[j].line_mux) {
626
						if (((bios_connectors[i].
761
						if (((bios_connectors[i].
Line 641... Line 776...
641
							    bios_connectors[j].
776
							    bios_connectors[j].
642
							    devices;
777
							    devices;
643
							bios_connectors[i].
778
							bios_connectors[i].
644
							    connector_type =
779
							    connector_type =
645
							    DRM_MODE_CONNECTOR_DVII;
780
							    DRM_MODE_CONNECTOR_DVII;
-
 
781
							if (bios_connectors[j].devices &
-
 
782
							    (ATOM_DEVICE_DFP_SUPPORT))
-
 
783
								bios_connectors[i].hpd =
-
 
784
									bios_connectors[j].hpd;
646
							bios_connectors[j].
785
							bios_connectors[j].
647
							    valid = false;
786
							    valid = false;
648
						}
787
						}
649
					}
788
					}
650
				}
789
				}
651
			}
790
			}
652
		}
791
		}
653
	}
792
	}
Line 654... Line 793...
654
 
793
 
655
	/* add the connectors */
794
	/* add the connectors */
656
	for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) {
795
	for (i = 0; i < max_device; i++) {
657
		if (bios_connectors[i].valid) {
796
		if (bios_connectors[i].valid) {
658
			uint16_t connector_object_id =
797
			uint16_t connector_object_id =
659
				atombios_get_connector_object_id(dev,
798
				atombios_get_connector_object_id(dev,
660
						      bios_connectors[i].connector_type,
799
						      bios_connectors[i].connector_type,
Line 664... Line 803...
664
						  bios_connectors[i].devices,
803
						  bios_connectors[i].devices,
665
						  bios_connectors[i].
804
						  bios_connectors[i].
666
						  connector_type,
805
						  connector_type,
667
						  &bios_connectors[i].ddc_bus,
806
						  &bios_connectors[i].ddc_bus,
668
						  false, 0,
807
						  false, 0,
669
						  connector_object_id);
808
						  connector_object_id,
-
 
809
						  &bios_connectors[i].hpd);
670
		}
810
		}
671
	}
811
	}
Line 672... Line 812...
672
 
812
 
Line 729... Line 869...
729
			 * However, certain duallink DVI monitors seem to like
869
			 * However, certain duallink DVI monitors seem to like
730
			 * pll combinations that would be limited by this at least on
870
			 * pll combinations that would be limited by this at least on
731
			 * pre-DCE 3.0 r6xx hardware.  This might need to be adjusted per
871
			 * pre-DCE 3.0 r6xx hardware.  This might need to be adjusted per
732
			 * family.
872
			 * family.
733
			 */
873
			 */
-
 
874
			if (!radeon_new_pll)
734
			p1pll->pll_out_min = 64800;
875
			p1pll->pll_out_min = 64800;
735
		}
876
		}
Line 736... Line 877...
736
 
877
 
737
		p1pll->pll_in_min =
878
		p1pll->pll_in_min =
Line 859... Line 1000...
859
	int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info);
1000
	int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info);
860
	uint16_t data_offset;
1001
	uint16_t data_offset;
861
	struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info;
1002
	struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info;
862
	uint8_t frev, crev;
1003
	uint8_t frev, crev;
863
	struct radeon_atom_ss *ss = NULL;
1004
	struct radeon_atom_ss *ss = NULL;
-
 
1005
	int i;
Line 864... Line 1006...
864
 
1006
 
865
	if (id > ATOM_MAX_SS_ENTRY)
1007
	if (id > ATOM_MAX_SS_ENTRY)
Line 866... Line 1008...
866
		return NULL;
1008
		return NULL;
Line 876... Line 1018...
876
		    kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
1018
		    kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
Line 877... Line 1019...
877
 
1019
 
878
		if (!ss)
1020
		if (!ss)
Line -... Line 1021...
-
 
1021
			return NULL;
-
 
1022
 
-
 
1023
		for (i = 0; i < ATOM_MAX_SS_ENTRY; i++) {
879
			return NULL;
1024
			if (ss_info->asSS_Info[i].ucSS_Id == id) {
880
 
1025
				ss->percentage =
881
		ss->percentage = le16_to_cpu(ss_info->asSS_Info[id].usSpreadSpectrumPercentage);
1026
					le16_to_cpu(ss_info->asSS_Info[i].usSpreadSpectrumPercentage);
882
		ss->type = ss_info->asSS_Info[id].ucSpreadSpectrumType;
1027
				ss->type = ss_info->asSS_Info[i].ucSpreadSpectrumType;
883
		ss->step = ss_info->asSS_Info[id].ucSS_Step;
1028
				ss->step = ss_info->asSS_Info[i].ucSS_Step;
884
		ss->delay = ss_info->asSS_Info[id].ucSS_Delay;
1029
				ss->delay = ss_info->asSS_Info[i].ucSS_Delay;
-
 
1030
				ss->range = ss_info->asSS_Info[i].ucSS_Range;
-
 
1031
				ss->refdiv = ss_info->asSS_Info[i].ucRecommendedRef_Div;
885
		ss->range = ss_info->asSS_Info[id].ucSS_Range;
1032
	}
886
		ss->refdiv = ss_info->asSS_Info[id].ucRecommendedRef_Div;
1033
		}
887
	}
1034
	}
Line 888... Line 1035...
888
	return ss;
1035
	return ss;
Line 899... Line 1046...
899
{
1046
{
900
	struct drm_device *dev = encoder->base.dev;
1047
	struct drm_device *dev = encoder->base.dev;
901
	struct radeon_device *rdev = dev->dev_private;
1048
	struct radeon_device *rdev = dev->dev_private;
902
	struct radeon_mode_info *mode_info = &rdev->mode_info;
1049
	struct radeon_mode_info *mode_info = &rdev->mode_info;
903
	int index = GetIndexIntoMasterTable(DATA, LVDS_Info);
1050
	int index = GetIndexIntoMasterTable(DATA, LVDS_Info);
904
	uint16_t data_offset;
1051
	uint16_t data_offset, misc;
905
	union lvds_info *lvds_info;
1052
	union lvds_info *lvds_info;
906
	uint8_t frev, crev;
1053
	uint8_t frev, crev;
907
	struct radeon_encoder_atom_dig *lvds = NULL;
1054
	struct radeon_encoder_atom_dig *lvds = NULL;
Line 908... Line 1055...
908
 
1055
 
Line 938... Line 1085...
938
		lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
1085
		lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
939
		    le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
1086
		    le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
940
		lvds->panel_pwr_delay =
1087
		lvds->panel_pwr_delay =
941
		    le16_to_cpu(lvds_info->info.usOffDelayInMs);
1088
		    le16_to_cpu(lvds_info->info.usOffDelayInMs);
942
		lvds->lvds_misc = lvds_info->info.ucLVDS_Misc;
1089
		lvds->lvds_misc = lvds_info->info.ucLVDS_Misc;
-
 
1090
 
-
 
1091
		misc = le16_to_cpu(lvds_info->info.sLCDTiming.susModeMiscInfo.usAccess);
-
 
1092
		if (misc & ATOM_VSYNC_POLARITY)
-
 
1093
			lvds->native_mode.flags |= DRM_MODE_FLAG_NVSYNC;
-
 
1094
		if (misc & ATOM_HSYNC_POLARITY)
-
 
1095
			lvds->native_mode.flags |= DRM_MODE_FLAG_NHSYNC;
-
 
1096
		if (misc & ATOM_COMPOSITESYNC)
-
 
1097
			lvds->native_mode.flags |= DRM_MODE_FLAG_CSYNC;
-
 
1098
		if (misc & ATOM_INTERLACE)
-
 
1099
			lvds->native_mode.flags |= DRM_MODE_FLAG_INTERLACE;
-
 
1100
		if (misc & ATOM_DOUBLE_CLOCK_MODE)
-
 
1101
			lvds->native_mode.flags |= DRM_MODE_FLAG_DBLSCAN;
-
 
1102
 
943
		/* set crtc values */
1103
		/* set crtc values */
944
		drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1104
		drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
Line 945... Line 1105...
945
 
1105