2 * Copyright 2007-8 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
23 * Authors: Dave Airlie
27 #include "radeon_drm.h"
31 #include "atom-bits.h"
33 /* from radeon_encoder.c */
35 radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device,
37 extern void radeon_link_encoder_connector(struct drm_device *dev);
39 radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id,
40 uint32_t supported_device);
42 /* from radeon_connector.c */
44 radeon_add_atom_connector(struct drm_device *dev,
45 uint32_t connector_id,
46 uint32_t supported_device,
48 struct radeon_i2c_bus_rec *i2c_bus,
49 bool linkb, uint32_t igp_lane_info,
50 uint16_t connector_object_id,
51 struct radeon_hpd *hpd);
53 /* from radeon_legacy_encoder.c */
55 radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
56 uint32_t supported_device);
58 union atom_supported_devices {
59 struct _ATOM_SUPPORTED_DEVICES_INFO info;
60 struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
61 struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1;
64 static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev,
67 struct atom_context *ctx = rdev->mode_info.atom_context;
68 ATOM_GPIO_I2C_ASSIGMENT *gpio;
69 struct radeon_i2c_bus_rec i2c;
70 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
71 struct _ATOM_GPIO_I2C_INFO *i2c_info;
72 uint16_t data_offset, size;
75 memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
78 if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
79 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
81 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
82 sizeof(ATOM_GPIO_I2C_ASSIGMENT);
84 for (i = 0; i < num_indices; i++) {
85 gpio = &i2c_info->asGPIO_Info[i];
87 if (gpio->sucI2cId.ucAccess == id) {
88 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
89 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
90 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
91 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
92 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
93 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
94 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
95 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
96 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
97 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
98 i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
99 i2c.en_data_mask = (1 << gpio->ucDataEnShift);
100 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
101 i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
102 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
103 i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
105 if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
106 i2c.hw_capable = true;
108 i2c.hw_capable = false;
110 if (gpio->sucI2cId.ucAccess == 0xa0)
115 i2c.i2c_id = gpio->sucI2cId.ucAccess;
126 static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev,
129 struct atom_context *ctx = rdev->mode_info.atom_context;
130 struct radeon_gpio_rec gpio;
131 int index = GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT);
132 struct _ATOM_GPIO_PIN_LUT *gpio_info;
133 ATOM_GPIO_PIN_ASSIGNMENT *pin;
134 u16 data_offset, size;
137 memset(&gpio, 0, sizeof(struct radeon_gpio_rec));
140 if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
141 gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset);
143 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
144 sizeof(ATOM_GPIO_PIN_ASSIGNMENT);
146 for (i = 0; i < num_indices; i++) {
147 pin = &gpio_info->asGPIO_Pin[i];
148 if (id == pin->ucGPIO_ID) {
149 gpio.id = pin->ucGPIO_ID;
150 gpio.reg = pin->usGpioPin_AIndex * 4;
151 gpio.mask = (1 << pin->ucGpioPinBitShift);
161 static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device *rdev,
162 struct radeon_gpio_rec *gpio)
164 struct radeon_hpd hpd;
167 if (ASIC_IS_DCE4(rdev))
168 reg = EVERGREEN_DC_GPIO_HPD_A;
170 reg = AVIVO_DC_GPIO_HPD_A;
173 if (gpio->reg == reg) {
176 hpd.hpd = RADEON_HPD_1;
179 hpd.hpd = RADEON_HPD_2;
182 hpd.hpd = RADEON_HPD_3;
185 hpd.hpd = RADEON_HPD_4;
188 hpd.hpd = RADEON_HPD_5;
191 hpd.hpd = RADEON_HPD_6;
194 hpd.hpd = RADEON_HPD_NONE;
198 hpd.hpd = RADEON_HPD_NONE;
202 static bool radeon_atom_apply_quirks(struct drm_device *dev,
203 uint32_t supported_device,
205 struct radeon_i2c_bus_rec *i2c_bus,
207 struct radeon_hpd *hpd)
210 /* Asus M2A-VM HDMI board lists the DVI port as HDMI */
211 if ((dev->pdev->device == 0x791e) &&
212 (dev->pdev->subsystem_vendor == 0x1043) &&
213 (dev->pdev->subsystem_device == 0x826d)) {
214 if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) &&
215 (supported_device == ATOM_DEVICE_DFP3_SUPPORT))
216 *connector_type = DRM_MODE_CONNECTOR_DVID;
219 /* Asrock RS600 board lists the DVI port as HDMI */
220 if ((dev->pdev->device == 0x7941) &&
221 (dev->pdev->subsystem_vendor == 0x1849) &&
222 (dev->pdev->subsystem_device == 0x7941)) {
223 if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) &&
224 (supported_device == ATOM_DEVICE_DFP3_SUPPORT))
225 *connector_type = DRM_MODE_CONNECTOR_DVID;
228 /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */
229 if ((dev->pdev->device == 0x7941) &&
230 (dev->pdev->subsystem_vendor == 0x147b) &&
231 (dev->pdev->subsystem_device == 0x2412)) {
232 if (*connector_type == DRM_MODE_CONNECTOR_DVII)
236 /* Falcon NW laptop lists vga ddc line for LVDS */
237 if ((dev->pdev->device == 0x5653) &&
238 (dev->pdev->subsystem_vendor == 0x1462) &&
239 (dev->pdev->subsystem_device == 0x0291)) {
240 if (*connector_type == DRM_MODE_CONNECTOR_LVDS) {
241 i2c_bus->valid = false;
246 /* HIS X1300 is DVI+VGA, not DVI+DVI */
247 if ((dev->pdev->device == 0x7146) &&
248 (dev->pdev->subsystem_vendor == 0x17af) &&
249 (dev->pdev->subsystem_device == 0x2058)) {
250 if (supported_device == ATOM_DEVICE_DFP1_SUPPORT)
254 /* Gigabyte X1300 is DVI+VGA, not DVI+DVI */
255 if ((dev->pdev->device == 0x7142) &&
256 (dev->pdev->subsystem_vendor == 0x1458) &&
257 (dev->pdev->subsystem_device == 0x2134)) {
258 if (supported_device == ATOM_DEVICE_DFP1_SUPPORT)
264 if ((dev->pdev->device == 0x71C5) &&
265 (dev->pdev->subsystem_vendor == 0x106b) &&
266 (dev->pdev->subsystem_device == 0x0080)) {
267 if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) ||
268 (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
270 if (supported_device == ATOM_DEVICE_CRT2_SUPPORT)
274 /* ASUS HD 3600 XT board lists the DVI port as HDMI */
275 if ((dev->pdev->device == 0x9598) &&
276 (dev->pdev->subsystem_vendor == 0x1043) &&
277 (dev->pdev->subsystem_device == 0x01da)) {
278 if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
279 *connector_type = DRM_MODE_CONNECTOR_DVII;
283 /* ASUS HD 3600 board lists the DVI port as HDMI */
284 if ((dev->pdev->device == 0x9598) &&
285 (dev->pdev->subsystem_vendor == 0x1043) &&
286 (dev->pdev->subsystem_device == 0x01e4)) {
287 if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
288 *connector_type = DRM_MODE_CONNECTOR_DVII;
292 /* ASUS HD 3450 board lists the DVI port as HDMI */
293 if ((dev->pdev->device == 0x95C5) &&
294 (dev->pdev->subsystem_vendor == 0x1043) &&
295 (dev->pdev->subsystem_device == 0x01e2)) {
296 if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
297 *connector_type = DRM_MODE_CONNECTOR_DVII;
301 /* some BIOSes seem to report DAC on HDMI - usually this is a board with
302 * HDMI + VGA reporting as HDMI
304 if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) {
305 if (supported_device & (ATOM_DEVICE_CRT_SUPPORT)) {
306 *connector_type = DRM_MODE_CONNECTOR_VGA;
311 /* Acer laptop reports DVI-D as DVI-I */
312 if ((dev->pdev->device == 0x95c4) &&
313 (dev->pdev->subsystem_vendor == 0x1025) &&
314 (dev->pdev->subsystem_device == 0x013c)) {
315 if ((*connector_type == DRM_MODE_CONNECTOR_DVII) &&
316 (supported_device == ATOM_DEVICE_DFP1_SUPPORT))
317 *connector_type = DRM_MODE_CONNECTOR_DVID;
320 /* XFX Pine Group device rv730 reports no VGA DDC lines
321 * even though they are wired up to record 0x93
323 if ((dev->pdev->device == 0x9498) &&
324 (dev->pdev->subsystem_vendor == 0x1682) &&
325 (dev->pdev->subsystem_device == 0x2452)) {
326 struct radeon_device *rdev = dev->dev_private;
327 *i2c_bus = radeon_lookup_i2c_gpio(rdev, 0x93);
332 const int supported_devices_connector_convert[] = {
333 DRM_MODE_CONNECTOR_Unknown,
334 DRM_MODE_CONNECTOR_VGA,
335 DRM_MODE_CONNECTOR_DVII,
336 DRM_MODE_CONNECTOR_DVID,
337 DRM_MODE_CONNECTOR_DVIA,
338 DRM_MODE_CONNECTOR_SVIDEO,
339 DRM_MODE_CONNECTOR_Composite,
340 DRM_MODE_CONNECTOR_LVDS,
341 DRM_MODE_CONNECTOR_Unknown,
342 DRM_MODE_CONNECTOR_Unknown,
343 DRM_MODE_CONNECTOR_HDMIA,
344 DRM_MODE_CONNECTOR_HDMIB,
345 DRM_MODE_CONNECTOR_Unknown,
346 DRM_MODE_CONNECTOR_Unknown,
347 DRM_MODE_CONNECTOR_9PinDIN,
348 DRM_MODE_CONNECTOR_DisplayPort
351 const uint16_t supported_devices_connector_object_id_convert[] = {
352 CONNECTOR_OBJECT_ID_NONE,
353 CONNECTOR_OBJECT_ID_VGA,
354 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, /* not all boards support DL */
355 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D, /* not all boards support DL */
356 CONNECTOR_OBJECT_ID_VGA, /* technically DVI-A */
357 CONNECTOR_OBJECT_ID_COMPOSITE,
358 CONNECTOR_OBJECT_ID_SVIDEO,
359 CONNECTOR_OBJECT_ID_LVDS,
360 CONNECTOR_OBJECT_ID_9PIN_DIN,
361 CONNECTOR_OBJECT_ID_9PIN_DIN,
362 CONNECTOR_OBJECT_ID_DISPLAYPORT,
363 CONNECTOR_OBJECT_ID_HDMI_TYPE_A,
364 CONNECTOR_OBJECT_ID_HDMI_TYPE_B,
365 CONNECTOR_OBJECT_ID_SVIDEO
368 const int object_connector_convert[] = {
369 DRM_MODE_CONNECTOR_Unknown,
370 DRM_MODE_CONNECTOR_DVII,
371 DRM_MODE_CONNECTOR_DVII,
372 DRM_MODE_CONNECTOR_DVID,
373 DRM_MODE_CONNECTOR_DVID,
374 DRM_MODE_CONNECTOR_VGA,
375 DRM_MODE_CONNECTOR_Composite,
376 DRM_MODE_CONNECTOR_SVIDEO,
377 DRM_MODE_CONNECTOR_Unknown,
378 DRM_MODE_CONNECTOR_Unknown,
379 DRM_MODE_CONNECTOR_9PinDIN,
380 DRM_MODE_CONNECTOR_Unknown,
381 DRM_MODE_CONNECTOR_HDMIA,
382 DRM_MODE_CONNECTOR_HDMIB,
383 DRM_MODE_CONNECTOR_LVDS,
384 DRM_MODE_CONNECTOR_9PinDIN,
385 DRM_MODE_CONNECTOR_Unknown,
386 DRM_MODE_CONNECTOR_Unknown,
387 DRM_MODE_CONNECTOR_Unknown,
388 DRM_MODE_CONNECTOR_DisplayPort,
389 DRM_MODE_CONNECTOR_eDP,
390 DRM_MODE_CONNECTOR_Unknown
393 bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
395 struct radeon_device *rdev = dev->dev_private;
396 struct radeon_mode_info *mode_info = &rdev->mode_info;
397 struct atom_context *ctx = mode_info->atom_context;
398 int index = GetIndexIntoMasterTable(DATA, Object_Header);
399 u16 size, data_offset;
401 ATOM_CONNECTOR_OBJECT_TABLE *con_obj;
402 ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
403 ATOM_OBJECT_HEADER *obj_header;
404 int i, j, path_size, device_support;
406 u16 igp_lane_info, conn_id, connector_object_id;
408 struct radeon_i2c_bus_rec ddc_bus;
409 struct radeon_gpio_rec gpio;
410 struct radeon_hpd hpd;
412 if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
418 obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset);
419 path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *)
420 (ctx->bios + data_offset +
421 le16_to_cpu(obj_header->usDisplayPathTableOffset));
422 con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *)
423 (ctx->bios + data_offset +
424 le16_to_cpu(obj_header->usConnectorObjectTableOffset));
425 device_support = le16_to_cpu(obj_header->usDeviceSupport);
428 for (i = 0; i < path_obj->ucNumOfDispPath; i++) {
429 uint8_t *addr = (uint8_t *) path_obj->asDispPath;
430 ATOM_DISPLAY_OBJECT_PATH *path;
432 path = (ATOM_DISPLAY_OBJECT_PATH *) addr;
433 path_size += le16_to_cpu(path->usSize);
435 if (device_support & le16_to_cpu(path->usDeviceTag)) {
436 uint8_t con_obj_id, con_obj_num, con_obj_type;
439 (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK)
442 (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK)
445 (le16_to_cpu(path->usConnObjectId) &
446 OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
448 /* TODO CV support */
449 if (le16_to_cpu(path->usDeviceTag) ==
450 ATOM_DEVICE_CV_SUPPORT)
454 if ((rdev->flags & RADEON_IS_IGP) &&
456 CONNECTOR_OBJECT_ID_PCIE_CONNECTOR)) {
457 uint16_t igp_offset = 0;
458 ATOM_INTEGRATED_SYSTEM_INFO_V2 *igp_obj;
461 GetIndexIntoMasterTable(DATA,
462 IntegratedSystemInfo);
464 if (atom_parse_data_header(ctx, index, &size, &frev,
465 &crev, &igp_offset)) {
469 (ATOM_INTEGRATED_SYSTEM_INFO_V2
470 *) (ctx->bios + igp_offset);
473 uint32_t slot_config, ct;
475 if (con_obj_num == 1)
484 ct = (slot_config >> 16) & 0xff;
486 object_connector_convert
488 connector_object_id = ct;
490 slot_config & 0xffff;
498 object_connector_convert[con_obj_id];
499 connector_object_id = con_obj_id;
504 object_connector_convert[con_obj_id];
505 connector_object_id = con_obj_id;
508 if (connector_type == DRM_MODE_CONNECTOR_Unknown)
511 for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2);
513 uint8_t enc_obj_id, enc_obj_num, enc_obj_type;
516 (le16_to_cpu(path->usGraphicObjIds[j]) &
517 OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
519 (le16_to_cpu(path->usGraphicObjIds[j]) &
520 ENUM_ID_MASK) >> ENUM_ID_SHIFT;
522 (le16_to_cpu(path->usGraphicObjIds[j]) &
523 OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT;
525 /* FIXME: add support for router objects */
526 if (enc_obj_type == GRAPH_OBJECT_TYPE_ENCODER) {
527 if (enc_obj_num == 2)
532 radeon_add_atom_encoder(dev,
541 /* look up gpio for ddc, hpd */
542 ddc_bus.valid = false;
543 hpd.hpd = RADEON_HPD_NONE;
544 if ((le16_to_cpu(path->usDeviceTag) &
545 (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) == 0) {
546 for (j = 0; j < con_obj->ucNumberOfObjects; j++) {
547 if (le16_to_cpu(path->usConnObjectId) ==
548 le16_to_cpu(con_obj->asObjects[j].
550 ATOM_COMMON_RECORD_HEADER
552 (ATOM_COMMON_RECORD_HEADER
554 (ctx->bios + data_offset +
555 le16_to_cpu(con_obj->
558 ATOM_I2C_RECORD *i2c_record;
559 ATOM_HPD_INT_RECORD *hpd_record;
560 ATOM_I2C_ID_CONFIG_ACCESS *i2c_config;
561 hpd.hpd = RADEON_HPD_NONE;
563 while (record->ucRecordType > 0
566 ATOM_MAX_OBJECT_RECORD_NUMBER) {
567 switch (record->ucRecordType) {
568 case ATOM_I2C_RECORD_TYPE:
573 (ATOM_I2C_ID_CONFIG_ACCESS *)
574 &i2c_record->sucI2cId;
575 ddc_bus = radeon_lookup_i2c_gpio(rdev,
579 case ATOM_HPD_INT_RECORD_TYPE:
581 (ATOM_HPD_INT_RECORD *)
583 gpio = radeon_lookup_gpio(rdev,
584 hpd_record->ucHPDIntGPIOID);
585 hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio);
586 hpd.plugged_state = hpd_record->ucPlugged_PinState;
590 (ATOM_COMMON_RECORD_HEADER
601 /* needed for aux chan transactions */
602 ddc_bus.hpd_id = hpd.hpd ? (hpd.hpd - 1) : 0;
604 conn_id = le16_to_cpu(path->usConnObjectId);
606 if (!radeon_atom_apply_quirks
607 (dev, le16_to_cpu(path->usDeviceTag), &connector_type,
608 &ddc_bus, &conn_id, &hpd))
611 radeon_add_atom_connector(dev,
615 connector_type, &ddc_bus,
616 linkb, igp_lane_info,
623 radeon_link_encoder_connector(dev);
628 static uint16_t atombios_get_connector_object_id(struct drm_device *dev,
632 struct radeon_device *rdev = dev->dev_private;
634 if (rdev->flags & RADEON_IS_IGP) {
635 return supported_devices_connector_object_id_convert
637 } else if (((connector_type == DRM_MODE_CONNECTOR_DVII) ||
638 (connector_type == DRM_MODE_CONNECTOR_DVID)) &&
639 (devices & ATOM_DEVICE_DFP2_SUPPORT)) {
640 struct radeon_mode_info *mode_info = &rdev->mode_info;
641 struct atom_context *ctx = mode_info->atom_context;
642 int index = GetIndexIntoMasterTable(DATA, XTMDS_Info);
643 uint16_t size, data_offset;
645 ATOM_XTMDS_INFO *xtmds;
647 if (atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset)) {
648 xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset);
650 if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) {
651 if (connector_type == DRM_MODE_CONNECTOR_DVII)
652 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
654 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
656 if (connector_type == DRM_MODE_CONNECTOR_DVII)
657 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
659 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
662 return supported_devices_connector_object_id_convert
665 return supported_devices_connector_object_id_convert
670 struct bios_connector {
675 struct radeon_i2c_bus_rec ddc_bus;
676 struct radeon_hpd hpd;
679 bool radeon_get_atom_connector_info_from_supported_devices_table(struct
683 struct radeon_device *rdev = dev->dev_private;
684 struct radeon_mode_info *mode_info = &rdev->mode_info;
685 struct atom_context *ctx = mode_info->atom_context;
686 int index = GetIndexIntoMasterTable(DATA, SupportedDevicesInfo);
687 uint16_t size, data_offset;
689 uint16_t device_support;
691 union atom_supported_devices *supported_devices;
692 int i, j, max_device;
693 struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
695 if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
699 (union atom_supported_devices *)(ctx->bios + data_offset);
701 device_support = le16_to_cpu(supported_devices->info.usDeviceSupport);
704 max_device = ATOM_MAX_SUPPORTED_DEVICE;
706 max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO;
708 for (i = 0; i < max_device; i++) {
709 ATOM_CONNECTOR_INFO_I2C ci =
710 supported_devices->info.asConnInfo[i];
712 bios_connectors[i].valid = false;
714 if (!(device_support & (1 << i))) {
718 if (i == ATOM_DEVICE_CV_INDEX) {
719 DRM_DEBUG("Skipping Component Video\n");
723 bios_connectors[i].connector_type =
724 supported_devices_connector_convert[ci.sucConnectorInfo.
728 if (bios_connectors[i].connector_type ==
729 DRM_MODE_CONNECTOR_Unknown)
732 dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC;
734 bios_connectors[i].line_mux =
735 ci.sucI2cId.ucAccess;
737 /* give tv unique connector ids */
738 if (i == ATOM_DEVICE_TV1_INDEX) {
739 bios_connectors[i].ddc_bus.valid = false;
740 bios_connectors[i].line_mux = 50;
741 } else if (i == ATOM_DEVICE_TV2_INDEX) {
742 bios_connectors[i].ddc_bus.valid = false;
743 bios_connectors[i].line_mux = 51;
744 } else if (i == ATOM_DEVICE_CV_INDEX) {
745 bios_connectors[i].ddc_bus.valid = false;
746 bios_connectors[i].line_mux = 52;
748 bios_connectors[i].ddc_bus =
749 radeon_lookup_i2c_gpio(rdev,
750 bios_connectors[i].line_mux);
752 if ((crev > 1) && (frev > 1)) {
753 u8 isb = supported_devices->info_2d1.asIntSrcInfo[i].ucIntSrcBitmap;
756 bios_connectors[i].hpd.hpd = RADEON_HPD_1;
759 bios_connectors[i].hpd.hpd = RADEON_HPD_2;
762 bios_connectors[i].hpd.hpd = RADEON_HPD_NONE;
766 if (i == ATOM_DEVICE_DFP1_INDEX)
767 bios_connectors[i].hpd.hpd = RADEON_HPD_1;
768 else if (i == ATOM_DEVICE_DFP2_INDEX)
769 bios_connectors[i].hpd.hpd = RADEON_HPD_2;
771 bios_connectors[i].hpd.hpd = RADEON_HPD_NONE;
774 /* Always set the connector type to VGA for CRT1/CRT2. if they are
775 * shared with a DVI port, we'll pick up the DVI connector when we
776 * merge the outputs. Some bioses incorrectly list VGA ports as DVI.
778 if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX)
779 bios_connectors[i].connector_type =
780 DRM_MODE_CONNECTOR_VGA;
782 if (!radeon_atom_apply_quirks
783 (dev, (1 << i), &bios_connectors[i].connector_type,
784 &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux,
785 &bios_connectors[i].hpd))
788 bios_connectors[i].valid = true;
789 bios_connectors[i].devices = (1 << i);
791 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom)
792 radeon_add_atom_encoder(dev,
793 radeon_get_encoder_id(dev,
798 radeon_add_legacy_encoder(dev,
799 radeon_get_encoder_id(dev,
805 /* combine shared connectors */
806 for (i = 0; i < max_device; i++) {
807 if (bios_connectors[i].valid) {
808 for (j = 0; j < max_device; j++) {
809 if (bios_connectors[j].valid && (i != j)) {
810 if (bios_connectors[i].line_mux ==
811 bios_connectors[j].line_mux) {
812 /* make sure not to combine LVDS */
813 if (bios_connectors[i].devices & (ATOM_DEVICE_LCD_SUPPORT)) {
814 bios_connectors[i].line_mux = 53;
815 bios_connectors[i].ddc_bus.valid = false;
818 if (bios_connectors[j].devices & (ATOM_DEVICE_LCD_SUPPORT)) {
819 bios_connectors[j].line_mux = 53;
820 bios_connectors[j].ddc_bus.valid = false;
823 /* combine analog and digital for DVI-I */
824 if (((bios_connectors[i].devices & (ATOM_DEVICE_DFP_SUPPORT)) &&
825 (bios_connectors[j].devices & (ATOM_DEVICE_CRT_SUPPORT))) ||
826 ((bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) &&
827 (bios_connectors[i].devices & (ATOM_DEVICE_CRT_SUPPORT)))) {
828 bios_connectors[i].devices |=
829 bios_connectors[j].devices;
830 bios_connectors[i].connector_type =
831 DRM_MODE_CONNECTOR_DVII;
832 if (bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT))
833 bios_connectors[i].hpd =
834 bios_connectors[j].hpd;
835 bios_connectors[j].valid = false;
843 /* add the connectors */
844 for (i = 0; i < max_device; i++) {
845 if (bios_connectors[i].valid) {
846 uint16_t connector_object_id =
847 atombios_get_connector_object_id(dev,
848 bios_connectors[i].connector_type,
849 bios_connectors[i].devices);
850 radeon_add_atom_connector(dev,
851 bios_connectors[i].line_mux,
852 bios_connectors[i].devices,
855 &bios_connectors[i].ddc_bus,
858 &bios_connectors[i].hpd);
862 radeon_link_encoder_connector(dev);
867 union firmware_info {
868 ATOM_FIRMWARE_INFO info;
869 ATOM_FIRMWARE_INFO_V1_2 info_12;
870 ATOM_FIRMWARE_INFO_V1_3 info_13;
871 ATOM_FIRMWARE_INFO_V1_4 info_14;
872 ATOM_FIRMWARE_INFO_V2_1 info_21;
875 bool radeon_atom_get_clock_info(struct drm_device *dev)
877 struct radeon_device *rdev = dev->dev_private;
878 struct radeon_mode_info *mode_info = &rdev->mode_info;
879 int index = GetIndexIntoMasterTable(DATA, FirmwareInfo);
880 union firmware_info *firmware_info;
882 struct radeon_pll *p1pll = &rdev->clock.p1pll;
883 struct radeon_pll *p2pll = &rdev->clock.p2pll;
884 struct radeon_pll *dcpll = &rdev->clock.dcpll;
885 struct radeon_pll *spll = &rdev->clock.spll;
886 struct radeon_pll *mpll = &rdev->clock.mpll;
887 uint16_t data_offset;
889 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
890 &frev, &crev, &data_offset)) {
892 (union firmware_info *)(mode_info->atom_context->bios +
895 p1pll->reference_freq =
896 le16_to_cpu(firmware_info->info.usReferenceClock);
897 p1pll->reference_div = 0;
901 le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output);
904 le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output);
906 le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output);
909 p1pll->lcd_pll_out_min =
910 le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100;
911 if (p1pll->lcd_pll_out_min == 0)
912 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
913 p1pll->lcd_pll_out_max =
914 le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100;
915 if (p1pll->lcd_pll_out_max == 0)
916 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
918 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
919 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
922 if (p1pll->pll_out_min == 0) {
923 if (ASIC_IS_AVIVO(rdev))
924 p1pll->pll_out_min = 64800;
926 p1pll->pll_out_min = 20000;
927 } else if (p1pll->pll_out_min > 64800) {
928 /* Limiting the pll output range is a good thing generally as
929 * it limits the number of possible pll combinations for a given
930 * frequency presumably to the ones that work best on each card.
931 * However, certain duallink DVI monitors seem to like
932 * pll combinations that would be limited by this at least on
933 * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per
937 p1pll->pll_out_min = 64800;
941 le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input);
943 le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input);
948 spll->reference_freq =
949 le16_to_cpu(firmware_info->info.usReferenceClock);
950 spll->reference_div = 0;
953 le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output);
955 le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output);
958 if (spll->pll_out_min == 0) {
959 if (ASIC_IS_AVIVO(rdev))
960 spll->pll_out_min = 64800;
962 spll->pll_out_min = 20000;
966 le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input);
968 le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input);
971 mpll->reference_freq =
972 le16_to_cpu(firmware_info->info.usReferenceClock);
973 mpll->reference_div = 0;
976 le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output);
978 le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output);
981 if (mpll->pll_out_min == 0) {
982 if (ASIC_IS_AVIVO(rdev))
983 mpll->pll_out_min = 64800;
985 mpll->pll_out_min = 20000;
989 le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input);
991 le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input);
993 rdev->clock.default_sclk =
994 le32_to_cpu(firmware_info->info.ulDefaultEngineClock);
995 rdev->clock.default_mclk =
996 le32_to_cpu(firmware_info->info.ulDefaultMemoryClock);
998 if (ASIC_IS_DCE4(rdev)) {
999 rdev->clock.default_dispclk =
1000 le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq);
1001 if (rdev->clock.default_dispclk == 0)
1002 rdev->clock.default_dispclk = 60000; /* 600 Mhz */
1003 rdev->clock.dp_extclk =
1004 le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq);
1015 struct _ATOM_INTEGRATED_SYSTEM_INFO info;
1016 struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2;
1019 bool radeon_atombios_sideport_present(struct radeon_device *rdev)
1021 struct radeon_mode_info *mode_info = &rdev->mode_info;
1022 int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo);
1023 union igp_info *igp_info;
1027 /* sideport is AMD only */
1028 if (rdev->family == CHIP_RS600)
1031 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1032 &frev, &crev, &data_offset)) {
1033 igp_info = (union igp_info *)(mode_info->atom_context->bios +
1037 if (igp_info->info.ulBootUpMemoryClock)
1041 if (igp_info->info_2.ucMemoryType & 0x0f)
1045 DRM_ERROR("Unsupported IGP table: %d %d\n", frev, crev);
1052 bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder,
1053 struct radeon_encoder_int_tmds *tmds)
1055 struct drm_device *dev = encoder->base.dev;
1056 struct radeon_device *rdev = dev->dev_private;
1057 struct radeon_mode_info *mode_info = &rdev->mode_info;
1058 int index = GetIndexIntoMasterTable(DATA, TMDS_Info);
1059 uint16_t data_offset;
1060 struct _ATOM_TMDS_INFO *tmds_info;
1065 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1066 &frev, &crev, &data_offset)) {
1068 (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
1071 maxfreq = le16_to_cpu(tmds_info->usMaxFrequency);
1072 for (i = 0; i < 4; i++) {
1073 tmds->tmds_pll[i].freq =
1074 le16_to_cpu(tmds_info->asMiscInfo[i].usFrequency);
1075 tmds->tmds_pll[i].value =
1076 tmds_info->asMiscInfo[i].ucPLL_ChargePump & 0x3f;
1077 tmds->tmds_pll[i].value |=
1078 (tmds_info->asMiscInfo[i].
1079 ucPLL_VCO_Gain & 0x3f) << 6;
1080 tmds->tmds_pll[i].value |=
1081 (tmds_info->asMiscInfo[i].
1082 ucPLL_DutyCycle & 0xf) << 12;
1083 tmds->tmds_pll[i].value |=
1084 (tmds_info->asMiscInfo[i].
1085 ucPLL_VoltageSwing & 0xf) << 16;
1087 DRM_DEBUG("TMDS PLL From ATOMBIOS %u %x\n",
1088 tmds->tmds_pll[i].freq,
1089 tmds->tmds_pll[i].value);
1091 if (maxfreq == tmds->tmds_pll[i].freq) {
1092 tmds->tmds_pll[i].freq = 0xffffffff;
1101 static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
1106 struct drm_device *dev = encoder->base.dev;
1107 struct radeon_device *rdev = dev->dev_private;
1108 struct radeon_mode_info *mode_info = &rdev->mode_info;
1109 int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info);
1110 uint16_t data_offset;
1111 struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info;
1113 struct radeon_atom_ss *ss = NULL;
1116 if (id > ATOM_MAX_SS_ENTRY)
1119 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1120 &frev, &crev, &data_offset)) {
1122 (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
1125 kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
1130 for (i = 0; i < ATOM_MAX_SS_ENTRY; i++) {
1131 if (ss_info->asSS_Info[i].ucSS_Id == id) {
1133 le16_to_cpu(ss_info->asSS_Info[i].usSpreadSpectrumPercentage);
1134 ss->type = ss_info->asSS_Info[i].ucSpreadSpectrumType;
1135 ss->step = ss_info->asSS_Info[i].ucSS_Step;
1136 ss->delay = ss_info->asSS_Info[i].ucSS_Delay;
1137 ss->range = ss_info->asSS_Info[i].ucSS_Range;
1138 ss->refdiv = ss_info->asSS_Info[i].ucRecommendedRef_Div;
1147 struct _ATOM_LVDS_INFO info;
1148 struct _ATOM_LVDS_INFO_V12 info_12;
1151 struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
1155 struct drm_device *dev = encoder->base.dev;
1156 struct radeon_device *rdev = dev->dev_private;
1157 struct radeon_mode_info *mode_info = &rdev->mode_info;
1158 int index = GetIndexIntoMasterTable(DATA, LVDS_Info);
1159 uint16_t data_offset, misc;
1160 union lvds_info *lvds_info;
1162 struct radeon_encoder_atom_dig *lvds = NULL;
1164 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1165 &frev, &crev, &data_offset)) {
1167 (union lvds_info *)(mode_info->atom_context->bios + data_offset);
1169 kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL);
1174 lvds->native_mode.clock =
1175 le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10;
1176 lvds->native_mode.hdisplay =
1177 le16_to_cpu(lvds_info->info.sLCDTiming.usHActive);
1178 lvds->native_mode.vdisplay =
1179 le16_to_cpu(lvds_info->info.sLCDTiming.usVActive);
1180 lvds->native_mode.htotal = lvds->native_mode.hdisplay +
1181 le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time);
1182 lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
1183 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset);
1184 lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
1185 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth);
1186 lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
1187 le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time);
1188 lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
1189 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncOffset);
1190 lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
1191 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
1192 lvds->panel_pwr_delay =
1193 le16_to_cpu(lvds_info->info.usOffDelayInMs);
1194 lvds->lvds_misc = lvds_info->info.ucLVDS_Misc;
1196 misc = le16_to_cpu(lvds_info->info.sLCDTiming.susModeMiscInfo.usAccess);
1197 if (misc & ATOM_VSYNC_POLARITY)
1198 lvds->native_mode.flags |= DRM_MODE_FLAG_NVSYNC;
1199 if (misc & ATOM_HSYNC_POLARITY)
1200 lvds->native_mode.flags |= DRM_MODE_FLAG_NHSYNC;
1201 if (misc & ATOM_COMPOSITESYNC)
1202 lvds->native_mode.flags |= DRM_MODE_FLAG_CSYNC;
1203 if (misc & ATOM_INTERLACE)
1204 lvds->native_mode.flags |= DRM_MODE_FLAG_INTERLACE;
1205 if (misc & ATOM_DOUBLE_CLOCK_MODE)
1206 lvds->native_mode.flags |= DRM_MODE_FLAG_DBLSCAN;
1208 /* set crtc values */
1209 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1211 lvds->ss = radeon_atombios_get_ss_info(encoder, lvds_info->info.ucSS_Id);
1213 if (ASIC_IS_AVIVO(rdev)) {
1214 if (radeon_new_pll == 0)
1215 lvds->pll_algo = PLL_ALGO_LEGACY;
1217 lvds->pll_algo = PLL_ALGO_NEW;
1219 if (radeon_new_pll == 1)
1220 lvds->pll_algo = PLL_ALGO_NEW;
1222 lvds->pll_algo = PLL_ALGO_LEGACY;
1225 encoder->native_mode = lvds->native_mode;
1230 struct radeon_encoder_primary_dac *
1231 radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder)
1233 struct drm_device *dev = encoder->base.dev;
1234 struct radeon_device *rdev = dev->dev_private;
1235 struct radeon_mode_info *mode_info = &rdev->mode_info;
1236 int index = GetIndexIntoMasterTable(DATA, CompassionateData);
1237 uint16_t data_offset;
1238 struct _COMPASSIONATE_DATA *dac_info;
1241 struct radeon_encoder_primary_dac *p_dac = NULL;
1243 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1244 &frev, &crev, &data_offset)) {
1245 dac_info = (struct _COMPASSIONATE_DATA *)
1246 (mode_info->atom_context->bios + data_offset);
1248 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL);
1253 bg = dac_info->ucDAC1_BG_Adjustment;
1254 dac = dac_info->ucDAC1_DAC_Adjustment;
1255 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
1261 bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
1262 struct drm_display_mode *mode)
1264 struct radeon_mode_info *mode_info = &rdev->mode_info;
1265 ATOM_ANALOG_TV_INFO *tv_info;
1266 ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2;
1267 ATOM_DTD_FORMAT *dtd_timings;
1268 int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info);
1270 u16 data_offset, misc;
1272 if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL,
1273 &frev, &crev, &data_offset))
1278 tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
1279 if (index >= MAX_SUPPORTED_TV_TIMING)
1282 mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total);
1283 mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp);
1284 mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart);
1285 mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) +
1286 le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth);
1288 mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total);
1289 mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp);
1290 mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart);
1291 mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) +
1292 le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth);
1295 misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess);
1296 if (misc & ATOM_VSYNC_POLARITY)
1297 mode->flags |= DRM_MODE_FLAG_NVSYNC;
1298 if (misc & ATOM_HSYNC_POLARITY)
1299 mode->flags |= DRM_MODE_FLAG_NHSYNC;
1300 if (misc & ATOM_COMPOSITESYNC)
1301 mode->flags |= DRM_MODE_FLAG_CSYNC;
1302 if (misc & ATOM_INTERLACE)
1303 mode->flags |= DRM_MODE_FLAG_INTERLACE;
1304 if (misc & ATOM_DOUBLE_CLOCK_MODE)
1305 mode->flags |= DRM_MODE_FLAG_DBLSCAN;
1307 mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10;
1310 /* PAL timings appear to have wrong values for totals */
1311 mode->crtc_htotal -= 1;
1312 mode->crtc_vtotal -= 1;
1316 tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset);
1317 if (index >= MAX_SUPPORTED_TV_TIMING_V1_2)
1320 dtd_timings = &tv_info_v1_2->aModeTimings[index];
1321 mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) +
1322 le16_to_cpu(dtd_timings->usHBlanking_Time);
1323 mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive);
1324 mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) +
1325 le16_to_cpu(dtd_timings->usHSyncOffset);
1326 mode->crtc_hsync_end = mode->crtc_hsync_start +
1327 le16_to_cpu(dtd_timings->usHSyncWidth);
1329 mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) +
1330 le16_to_cpu(dtd_timings->usVBlanking_Time);
1331 mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive);
1332 mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) +
1333 le16_to_cpu(dtd_timings->usVSyncOffset);
1334 mode->crtc_vsync_end = mode->crtc_vsync_start +
1335 le16_to_cpu(dtd_timings->usVSyncWidth);
1338 misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess);
1339 if (misc & ATOM_VSYNC_POLARITY)
1340 mode->flags |= DRM_MODE_FLAG_NVSYNC;
1341 if (misc & ATOM_HSYNC_POLARITY)
1342 mode->flags |= DRM_MODE_FLAG_NHSYNC;
1343 if (misc & ATOM_COMPOSITESYNC)
1344 mode->flags |= DRM_MODE_FLAG_CSYNC;
1345 if (misc & ATOM_INTERLACE)
1346 mode->flags |= DRM_MODE_FLAG_INTERLACE;
1347 if (misc & ATOM_DOUBLE_CLOCK_MODE)
1348 mode->flags |= DRM_MODE_FLAG_DBLSCAN;
1350 mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10;
1357 radeon_atombios_get_tv_info(struct radeon_device *rdev)
1359 struct radeon_mode_info *mode_info = &rdev->mode_info;
1360 int index = GetIndexIntoMasterTable(DATA, AnalogTV_Info);
1361 uint16_t data_offset;
1363 struct _ATOM_ANALOG_TV_INFO *tv_info;
1364 enum radeon_tv_std tv_std = TV_STD_NTSC;
1366 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1367 &frev, &crev, &data_offset)) {
1369 tv_info = (struct _ATOM_ANALOG_TV_INFO *)
1370 (mode_info->atom_context->bios + data_offset);
1372 switch (tv_info->ucTV_BootUpDefaultStandard) {
1374 tv_std = TV_STD_NTSC;
1375 DRM_INFO("Default TV standard: NTSC\n");
1378 tv_std = TV_STD_NTSC_J;
1379 DRM_INFO("Default TV standard: NTSC-J\n");
1382 tv_std = TV_STD_PAL;
1383 DRM_INFO("Default TV standard: PAL\n");
1386 tv_std = TV_STD_PAL_M;
1387 DRM_INFO("Default TV standard: PAL-M\n");
1390 tv_std = TV_STD_PAL_N;
1391 DRM_INFO("Default TV standard: PAL-N\n");
1394 tv_std = TV_STD_PAL_CN;
1395 DRM_INFO("Default TV standard: PAL-CN\n");
1398 tv_std = TV_STD_PAL_60;
1399 DRM_INFO("Default TV standard: PAL-60\n");
1402 tv_std = TV_STD_SECAM;
1403 DRM_INFO("Default TV standard: SECAM\n");
1406 tv_std = TV_STD_NTSC;
1407 DRM_INFO("Unknown TV standard; defaulting to NTSC\n");
1414 struct radeon_encoder_tv_dac *
1415 radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
1417 struct drm_device *dev = encoder->base.dev;
1418 struct radeon_device *rdev = dev->dev_private;
1419 struct radeon_mode_info *mode_info = &rdev->mode_info;
1420 int index = GetIndexIntoMasterTable(DATA, CompassionateData);
1421 uint16_t data_offset;
1422 struct _COMPASSIONATE_DATA *dac_info;
1425 struct radeon_encoder_tv_dac *tv_dac = NULL;
1427 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1428 &frev, &crev, &data_offset)) {
1430 dac_info = (struct _COMPASSIONATE_DATA *)
1431 (mode_info->atom_context->bios + data_offset);
1433 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
1438 bg = dac_info->ucDAC2_CRT2_BG_Adjustment;
1439 dac = dac_info->ucDAC2_CRT2_DAC_Adjustment;
1440 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
1442 bg = dac_info->ucDAC2_PAL_BG_Adjustment;
1443 dac = dac_info->ucDAC2_PAL_DAC_Adjustment;
1444 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
1446 bg = dac_info->ucDAC2_NTSC_BG_Adjustment;
1447 dac = dac_info->ucDAC2_NTSC_DAC_Adjustment;
1448 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
1450 tv_dac->tv_std = radeon_atombios_get_tv_info(rdev);
1455 static const char *thermal_controller_names[] = {
1466 static const char *pp_lib_thermal_controller_names[] = {
1480 struct _ATOM_POWERPLAY_INFO info;
1481 struct _ATOM_POWERPLAY_INFO_V2 info_2;
1482 struct _ATOM_POWERPLAY_INFO_V3 info_3;
1483 struct _ATOM_PPLIB_POWERPLAYTABLE info_4;
1486 void radeon_atombios_get_power_modes(struct radeon_device *rdev)
1488 struct radeon_mode_info *mode_info = &rdev->mode_info;
1489 int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
1492 u32 misc, misc2 = 0, sclk, mclk;
1493 union power_info *power_info;
1494 struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info;
1495 struct _ATOM_PPLIB_STATE *power_state;
1496 int num_modes = 0, i, j;
1497 int state_index = 0, mode_index = 0;
1498 struct radeon_i2c_bus_rec i2c_bus;
1500 rdev->pm.default_power_state = NULL;
1502 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1503 &frev, &crev, &data_offset)) {
1504 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
1506 /* add the i2c bus for thermal/fan chip */
1507 if (power_info->info.ucOverdriveThermalController > 0) {
1508 DRM_INFO("Possible %s thermal controller at 0x%02x\n",
1509 thermal_controller_names[power_info->info.ucOverdriveThermalController],
1510 power_info->info.ucOverdriveControllerAddress >> 1);
1511 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine);
1512 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
1514 num_modes = power_info->info.ucNumOfPowerModeEntries;
1515 if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK)
1516 num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
1517 for (i = 0; i < num_modes; i++) {
1518 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
1521 rdev->pm.power_state[state_index].num_clock_modes = 1;
1522 rdev->pm.power_state[state_index].clock_info[0].mclk =
1523 le16_to_cpu(power_info->info.asPowerPlayInfo[i].usMemoryClock);
1524 rdev->pm.power_state[state_index].clock_info[0].sclk =
1525 le16_to_cpu(power_info->info.asPowerPlayInfo[i].usEngineClock);
1526 /* skip invalid modes */
1527 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
1528 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
1530 /* skip overclock modes for now */
1531 if ((rdev->pm.power_state[state_index].clock_info[0].mclk >
1532 rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) ||
1533 (rdev->pm.power_state[state_index].clock_info[0].sclk >
1534 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN))
1536 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
1537 power_info->info.asPowerPlayInfo[i].ucNumPciELanes;
1538 misc = le32_to_cpu(power_info->info.asPowerPlayInfo[i].ulMiscInfo);
1539 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) {
1540 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1542 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio =
1543 radeon_lookup_gpio(rdev,
1544 power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex);
1545 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
1546 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1549 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1551 } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) {
1552 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1554 rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id =
1555 power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex;
1557 /* order matters! */
1558 if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
1559 rdev->pm.power_state[state_index].type =
1560 POWER_STATE_TYPE_POWERSAVE;
1561 if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
1562 rdev->pm.power_state[state_index].type =
1563 POWER_STATE_TYPE_BATTERY;
1564 if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
1565 rdev->pm.power_state[state_index].type =
1566 POWER_STATE_TYPE_BATTERY;
1567 if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
1568 rdev->pm.power_state[state_index].type =
1569 POWER_STATE_TYPE_BALANCED;
1570 if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
1571 rdev->pm.power_state[state_index].type =
1572 POWER_STATE_TYPE_PERFORMANCE;
1573 if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) {
1574 rdev->pm.power_state[state_index].type =
1575 POWER_STATE_TYPE_DEFAULT;
1576 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
1577 rdev->pm.power_state[state_index].default_clock_mode =
1578 &rdev->pm.power_state[state_index].clock_info[0];
1583 rdev->pm.power_state[state_index].num_clock_modes = 1;
1584 rdev->pm.power_state[state_index].clock_info[0].mclk =
1585 le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMemoryClock);
1586 rdev->pm.power_state[state_index].clock_info[0].sclk =
1587 le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulEngineClock);
1588 /* skip invalid modes */
1589 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
1590 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
1592 /* skip overclock modes for now */
1593 if ((rdev->pm.power_state[state_index].clock_info[0].mclk >
1594 rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) ||
1595 (rdev->pm.power_state[state_index].clock_info[0].sclk >
1596 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN))
1598 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
1599 power_info->info_2.asPowerPlayInfo[i].ucNumPciELanes;
1600 misc = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo);
1601 misc2 = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo2);
1602 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) {
1603 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1605 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio =
1606 radeon_lookup_gpio(rdev,
1607 power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex);
1608 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
1609 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1612 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1614 } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) {
1615 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1617 rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id =
1618 power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex;
1620 /* order matters! */
1621 if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
1622 rdev->pm.power_state[state_index].type =
1623 POWER_STATE_TYPE_POWERSAVE;
1624 if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
1625 rdev->pm.power_state[state_index].type =
1626 POWER_STATE_TYPE_BATTERY;
1627 if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
1628 rdev->pm.power_state[state_index].type =
1629 POWER_STATE_TYPE_BATTERY;
1630 if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
1631 rdev->pm.power_state[state_index].type =
1632 POWER_STATE_TYPE_BALANCED;
1633 if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
1634 rdev->pm.power_state[state_index].type =
1635 POWER_STATE_TYPE_PERFORMANCE;
1636 if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)
1637 rdev->pm.power_state[state_index].type =
1638 POWER_STATE_TYPE_BALANCED;
1639 if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) {
1640 rdev->pm.power_state[state_index].type =
1641 POWER_STATE_TYPE_DEFAULT;
1642 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
1643 rdev->pm.power_state[state_index].default_clock_mode =
1644 &rdev->pm.power_state[state_index].clock_info[0];
1649 rdev->pm.power_state[state_index].num_clock_modes = 1;
1650 rdev->pm.power_state[state_index].clock_info[0].mclk =
1651 le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMemoryClock);
1652 rdev->pm.power_state[state_index].clock_info[0].sclk =
1653 le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulEngineClock);
1654 /* skip invalid modes */
1655 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
1656 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
1658 /* skip overclock modes for now */
1659 if ((rdev->pm.power_state[state_index].clock_info[0].mclk >
1660 rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) ||
1661 (rdev->pm.power_state[state_index].clock_info[0].sclk >
1662 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN))
1664 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
1665 power_info->info_3.asPowerPlayInfo[i].ucNumPciELanes;
1666 misc = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo);
1667 misc2 = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo2);
1668 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) {
1669 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1671 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio =
1672 radeon_lookup_gpio(rdev,
1673 power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex);
1674 if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
1675 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1678 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
1680 } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) {
1681 rdev->pm.power_state[state_index].clock_info[0].voltage.type =
1683 rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id =
1684 power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex;
1685 if (misc2 & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN) {
1686 rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_enabled =
1688 rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_id =
1689 power_info->info_3.asPowerPlayInfo[i].ucVDDCI_VoltageDropIndex;
1692 /* order matters! */
1693 if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
1694 rdev->pm.power_state[state_index].type =
1695 POWER_STATE_TYPE_POWERSAVE;
1696 if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
1697 rdev->pm.power_state[state_index].type =
1698 POWER_STATE_TYPE_BATTERY;
1699 if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
1700 rdev->pm.power_state[state_index].type =
1701 POWER_STATE_TYPE_BATTERY;
1702 if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
1703 rdev->pm.power_state[state_index].type =
1704 POWER_STATE_TYPE_BALANCED;
1705 if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
1706 rdev->pm.power_state[state_index].type =
1707 POWER_STATE_TYPE_PERFORMANCE;
1708 if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)
1709 rdev->pm.power_state[state_index].type =
1710 POWER_STATE_TYPE_BALANCED;
1711 if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) {
1712 rdev->pm.power_state[state_index].type =
1713 POWER_STATE_TYPE_DEFAULT;
1714 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
1715 rdev->pm.power_state[state_index].default_clock_mode =
1716 &rdev->pm.power_state[state_index].clock_info[0];
1722 } else if (frev == 4) {
1723 /* add the i2c bus for thermal/fan chip */
1724 /* no support for internal controller yet */
1725 if (power_info->info_4.sThermalController.ucType > 0) {
1726 if ((power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) ||
1727 (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV770)) {
1728 DRM_INFO("Internal thermal controller %s fan control\n",
1729 (power_info->info_4.sThermalController.ucFanParameters &
1730 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
1732 DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n",
1733 pp_lib_thermal_controller_names[power_info->info_4.sThermalController.ucType],
1734 power_info->info_4.sThermalController.ucI2cAddress >> 1,
1735 (power_info->info_4.sThermalController.ucFanParameters &
1736 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
1737 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info_4.sThermalController.ucI2cLine);
1738 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
1741 for (i = 0; i < power_info->info_4.ucNumStates; i++) {
1743 power_state = (struct _ATOM_PPLIB_STATE *)
1744 (mode_info->atom_context->bios +
1746 le16_to_cpu(power_info->info_4.usStateArrayOffset) +
1747 i * power_info->info_4.ucStateEntrySize);
1748 non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
1749 (mode_info->atom_context->bios +
1751 le16_to_cpu(power_info->info_4.usNonClockInfoArrayOffset) +
1752 (power_state->ucNonClockStateIndex *
1753 power_info->info_4.ucNonClockSize));
1754 for (j = 0; j < (power_info->info_4.ucStateEntrySize - 1); j++) {
1755 if (rdev->flags & RADEON_IS_IGP) {
1756 struct _ATOM_PPLIB_RS780_CLOCK_INFO *clock_info =
1757 (struct _ATOM_PPLIB_RS780_CLOCK_INFO *)
1758 (mode_info->atom_context->bios +
1760 le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) +
1761 (power_state->ucClockStateIndices[j] *
1762 power_info->info_4.ucClockInfoSize));
1763 sclk = le16_to_cpu(clock_info->usLowEngineClockLow);
1764 sclk |= clock_info->ucLowEngineClockHigh << 16;
1765 rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk;
1766 /* skip invalid modes */
1767 if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)
1769 /* skip overclock modes for now */
1770 if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk >
1771 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)
1773 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type =
1775 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage =
1779 struct _ATOM_PPLIB_R600_CLOCK_INFO *clock_info =
1780 (struct _ATOM_PPLIB_R600_CLOCK_INFO *)
1781 (mode_info->atom_context->bios +
1783 le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) +
1784 (power_state->ucClockStateIndices[j] *
1785 power_info->info_4.ucClockInfoSize));
1786 sclk = le16_to_cpu(clock_info->usEngineClockLow);
1787 sclk |= clock_info->ucEngineClockHigh << 16;
1788 mclk = le16_to_cpu(clock_info->usMemoryClockLow);
1789 mclk |= clock_info->ucMemoryClockHigh << 16;
1790 rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk;
1791 rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk;
1792 /* skip invalid modes */
1793 if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk == 0) ||
1794 (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0))
1796 /* skip overclock modes for now */
1797 if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk >
1798 rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) ||
1799 (rdev->pm.power_state[state_index].clock_info[mode_index].sclk >
1800 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN))
1802 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type =
1804 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage =
1809 rdev->pm.power_state[state_index].num_clock_modes = mode_index;
1811 misc = le32_to_cpu(non_clock_info->ulCapsAndSettings);
1812 misc2 = le16_to_cpu(non_clock_info->usClassification);
1813 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
1814 ((misc & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >>
1815 ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;
1816 switch (misc2 & ATOM_PPLIB_CLASSIFICATION_UI_MASK) {
1817 case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY:
1818 rdev->pm.power_state[state_index].type =
1819 POWER_STATE_TYPE_BATTERY;
1821 case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED:
1822 rdev->pm.power_state[state_index].type =
1823 POWER_STATE_TYPE_BALANCED;
1825 case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE:
1826 rdev->pm.power_state[state_index].type =
1827 POWER_STATE_TYPE_PERFORMANCE;
1830 if (misc2 & ATOM_PPLIB_CLASSIFICATION_BOOT) {
1831 rdev->pm.power_state[state_index].type =
1832 POWER_STATE_TYPE_DEFAULT;
1833 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
1834 rdev->pm.power_state[state_index].default_clock_mode =
1835 &rdev->pm.power_state[state_index].clock_info[mode_index - 1];
1842 /* XXX figure out some good default low power mode for cards w/out power tables */
1845 if (rdev->pm.default_power_state == NULL) {
1846 /* add the default mode */
1847 rdev->pm.power_state[state_index].type =
1848 POWER_STATE_TYPE_DEFAULT;
1849 rdev->pm.power_state[state_index].num_clock_modes = 1;
1850 rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
1851 rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
1852 rdev->pm.power_state[state_index].default_clock_mode =
1853 &rdev->pm.power_state[state_index].clock_info[0];
1854 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
1855 if (rdev->asic->get_pcie_lanes)
1856 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
1858 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
1859 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
1862 rdev->pm.num_power_states = state_index;
1864 rdev->pm.current_power_state = rdev->pm.default_power_state;
1865 rdev->pm.current_clock_mode =
1866 rdev->pm.default_power_state->default_clock_mode;
1869 void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable)
1871 DYNAMIC_CLOCK_GATING_PS_ALLOCATION args;
1872 int index = GetIndexIntoMasterTable(COMMAND, DynamicClockGating);
1874 args.ucEnable = enable;
1876 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1879 uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev)
1881 GET_ENGINE_CLOCK_PS_ALLOCATION args;
1882 int index = GetIndexIntoMasterTable(COMMAND, GetEngineClock);
1884 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1885 return args.ulReturnEngineClock;
1888 uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev)
1890 GET_MEMORY_CLOCK_PS_ALLOCATION args;
1891 int index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock);
1893 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1894 return args.ulReturnMemoryClock;
1897 void radeon_atom_set_engine_clock(struct radeon_device *rdev,
1900 SET_ENGINE_CLOCK_PS_ALLOCATION args;
1901 int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock);
1903 args.ulTargetEngineClock = eng_clock; /* 10 khz */
1905 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1908 void radeon_atom_set_memory_clock(struct radeon_device *rdev,
1911 SET_MEMORY_CLOCK_PS_ALLOCATION args;
1912 int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock);
1914 if (rdev->flags & RADEON_IS_IGP)
1917 args.ulTargetMemoryClock = mem_clock; /* 10 khz */
1919 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1922 void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev)
1924 struct radeon_device *rdev = dev->dev_private;
1925 uint32_t bios_2_scratch, bios_6_scratch;
1927 if (rdev->family >= CHIP_R600) {
1928 bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH);
1929 bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
1931 bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH);
1932 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
1935 /* let the bios control the backlight */
1936 bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE;
1938 /* tell the bios not to handle mode switching */
1939 bios_6_scratch |= (ATOM_S6_ACC_BLOCK_DISPLAY_SWITCH | ATOM_S6_ACC_MODE);
1941 if (rdev->family >= CHIP_R600) {
1942 WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch);
1943 WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
1945 WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch);
1946 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
1951 void radeon_save_bios_scratch_regs(struct radeon_device *rdev)
1953 uint32_t scratch_reg;
1956 if (rdev->family >= CHIP_R600)
1957 scratch_reg = R600_BIOS_0_SCRATCH;
1959 scratch_reg = RADEON_BIOS_0_SCRATCH;
1961 for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++)
1962 rdev->bios_scratch[i] = RREG32(scratch_reg + (i * 4));
1965 void radeon_restore_bios_scratch_regs(struct radeon_device *rdev)
1967 uint32_t scratch_reg;
1970 if (rdev->family >= CHIP_R600)
1971 scratch_reg = R600_BIOS_0_SCRATCH;
1973 scratch_reg = RADEON_BIOS_0_SCRATCH;
1975 for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++)
1976 WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]);
1979 void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock)
1981 struct drm_device *dev = encoder->dev;
1982 struct radeon_device *rdev = dev->dev_private;
1983 uint32_t bios_6_scratch;
1985 if (rdev->family >= CHIP_R600)
1986 bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
1988 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
1991 bios_6_scratch |= ATOM_S6_CRITICAL_STATE;
1993 bios_6_scratch &= ~ATOM_S6_CRITICAL_STATE;
1995 if (rdev->family >= CHIP_R600)
1996 WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
1998 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2001 /* at some point we may want to break this out into individual functions */
2003 radeon_atombios_connected_scratch_regs(struct drm_connector *connector,
2004 struct drm_encoder *encoder,
2007 struct drm_device *dev = connector->dev;
2008 struct radeon_device *rdev = dev->dev_private;
2009 struct radeon_connector *radeon_connector =
2010 to_radeon_connector(connector);
2011 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2012 uint32_t bios_0_scratch, bios_3_scratch, bios_6_scratch;
2014 if (rdev->family >= CHIP_R600) {
2015 bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH);
2016 bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH);
2017 bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH);
2019 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
2020 bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH);
2021 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2024 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
2025 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
2027 DRM_DEBUG("TV1 connected\n");
2028 bios_3_scratch |= ATOM_S3_TV1_ACTIVE;
2029 bios_6_scratch |= ATOM_S6_ACC_REQ_TV1;
2031 DRM_DEBUG("TV1 disconnected\n");
2032 bios_0_scratch &= ~ATOM_S0_TV1_MASK;
2033 bios_3_scratch &= ~ATOM_S3_TV1_ACTIVE;
2034 bios_6_scratch &= ~ATOM_S6_ACC_REQ_TV1;
2037 if ((radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) &&
2038 (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT)) {
2040 DRM_DEBUG("CV connected\n");
2041 bios_3_scratch |= ATOM_S3_CV_ACTIVE;
2042 bios_6_scratch |= ATOM_S6_ACC_REQ_CV;
2044 DRM_DEBUG("CV disconnected\n");
2045 bios_0_scratch &= ~ATOM_S0_CV_MASK;
2046 bios_3_scratch &= ~ATOM_S3_CV_ACTIVE;
2047 bios_6_scratch &= ~ATOM_S6_ACC_REQ_CV;
2050 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
2051 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
2053 DRM_DEBUG("LCD1 connected\n");
2054 bios_0_scratch |= ATOM_S0_LCD1;
2055 bios_3_scratch |= ATOM_S3_LCD1_ACTIVE;
2056 bios_6_scratch |= ATOM_S6_ACC_REQ_LCD1;
2058 DRM_DEBUG("LCD1 disconnected\n");
2059 bios_0_scratch &= ~ATOM_S0_LCD1;
2060 bios_3_scratch &= ~ATOM_S3_LCD1_ACTIVE;
2061 bios_6_scratch &= ~ATOM_S6_ACC_REQ_LCD1;
2064 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
2065 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
2067 DRM_DEBUG("CRT1 connected\n");
2068 bios_0_scratch |= ATOM_S0_CRT1_COLOR;
2069 bios_3_scratch |= ATOM_S3_CRT1_ACTIVE;
2070 bios_6_scratch |= ATOM_S6_ACC_REQ_CRT1;
2072 DRM_DEBUG("CRT1 disconnected\n");
2073 bios_0_scratch &= ~ATOM_S0_CRT1_MASK;
2074 bios_3_scratch &= ~ATOM_S3_CRT1_ACTIVE;
2075 bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT1;
2078 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
2079 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
2081 DRM_DEBUG("CRT2 connected\n");
2082 bios_0_scratch |= ATOM_S0_CRT2_COLOR;
2083 bios_3_scratch |= ATOM_S3_CRT2_ACTIVE;
2084 bios_6_scratch |= ATOM_S6_ACC_REQ_CRT2;
2086 DRM_DEBUG("CRT2 disconnected\n");
2087 bios_0_scratch &= ~ATOM_S0_CRT2_MASK;
2088 bios_3_scratch &= ~ATOM_S3_CRT2_ACTIVE;
2089 bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT2;
2092 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
2093 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
2095 DRM_DEBUG("DFP1 connected\n");
2096 bios_0_scratch |= ATOM_S0_DFP1;
2097 bios_3_scratch |= ATOM_S3_DFP1_ACTIVE;
2098 bios_6_scratch |= ATOM_S6_ACC_REQ_DFP1;
2100 DRM_DEBUG("DFP1 disconnected\n");
2101 bios_0_scratch &= ~ATOM_S0_DFP1;
2102 bios_3_scratch &= ~ATOM_S3_DFP1_ACTIVE;
2103 bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP1;
2106 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
2107 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
2109 DRM_DEBUG("DFP2 connected\n");
2110 bios_0_scratch |= ATOM_S0_DFP2;
2111 bios_3_scratch |= ATOM_S3_DFP2_ACTIVE;
2112 bios_6_scratch |= ATOM_S6_ACC_REQ_DFP2;
2114 DRM_DEBUG("DFP2 disconnected\n");
2115 bios_0_scratch &= ~ATOM_S0_DFP2;
2116 bios_3_scratch &= ~ATOM_S3_DFP2_ACTIVE;
2117 bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP2;
2120 if ((radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) &&
2121 (radeon_connector->devices & ATOM_DEVICE_DFP3_SUPPORT)) {
2123 DRM_DEBUG("DFP3 connected\n");
2124 bios_0_scratch |= ATOM_S0_DFP3;
2125 bios_3_scratch |= ATOM_S3_DFP3_ACTIVE;
2126 bios_6_scratch |= ATOM_S6_ACC_REQ_DFP3;
2128 DRM_DEBUG("DFP3 disconnected\n");
2129 bios_0_scratch &= ~ATOM_S0_DFP3;
2130 bios_3_scratch &= ~ATOM_S3_DFP3_ACTIVE;
2131 bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP3;
2134 if ((radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) &&
2135 (radeon_connector->devices & ATOM_DEVICE_DFP4_SUPPORT)) {
2137 DRM_DEBUG("DFP4 connected\n");
2138 bios_0_scratch |= ATOM_S0_DFP4;
2139 bios_3_scratch |= ATOM_S3_DFP4_ACTIVE;
2140 bios_6_scratch |= ATOM_S6_ACC_REQ_DFP4;
2142 DRM_DEBUG("DFP4 disconnected\n");
2143 bios_0_scratch &= ~ATOM_S0_DFP4;
2144 bios_3_scratch &= ~ATOM_S3_DFP4_ACTIVE;
2145 bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP4;
2148 if ((radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) &&
2149 (radeon_connector->devices & ATOM_DEVICE_DFP5_SUPPORT)) {
2151 DRM_DEBUG("DFP5 connected\n");
2152 bios_0_scratch |= ATOM_S0_DFP5;
2153 bios_3_scratch |= ATOM_S3_DFP5_ACTIVE;
2154 bios_6_scratch |= ATOM_S6_ACC_REQ_DFP5;
2156 DRM_DEBUG("DFP5 disconnected\n");
2157 bios_0_scratch &= ~ATOM_S0_DFP5;
2158 bios_3_scratch &= ~ATOM_S3_DFP5_ACTIVE;
2159 bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP5;
2163 if (rdev->family >= CHIP_R600) {
2164 WREG32(R600_BIOS_0_SCRATCH, bios_0_scratch);
2165 WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch);
2166 WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch);
2168 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
2169 WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch);
2170 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2175 radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
2177 struct drm_device *dev = encoder->dev;
2178 struct radeon_device *rdev = dev->dev_private;
2179 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2180 uint32_t bios_3_scratch;
2182 if (rdev->family >= CHIP_R600)
2183 bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH);
2185 bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH);
2187 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
2188 bios_3_scratch &= ~ATOM_S3_TV1_CRTC_ACTIVE;
2189 bios_3_scratch |= (crtc << 18);
2191 if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) {
2192 bios_3_scratch &= ~ATOM_S3_CV_CRTC_ACTIVE;
2193 bios_3_scratch |= (crtc << 24);
2195 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
2196 bios_3_scratch &= ~ATOM_S3_CRT1_CRTC_ACTIVE;
2197 bios_3_scratch |= (crtc << 16);
2199 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
2200 bios_3_scratch &= ~ATOM_S3_CRT2_CRTC_ACTIVE;
2201 bios_3_scratch |= (crtc << 20);
2203 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
2204 bios_3_scratch &= ~ATOM_S3_LCD1_CRTC_ACTIVE;
2205 bios_3_scratch |= (crtc << 17);
2207 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
2208 bios_3_scratch &= ~ATOM_S3_DFP1_CRTC_ACTIVE;
2209 bios_3_scratch |= (crtc << 19);
2211 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
2212 bios_3_scratch &= ~ATOM_S3_DFP2_CRTC_ACTIVE;
2213 bios_3_scratch |= (crtc << 23);
2215 if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) {
2216 bios_3_scratch &= ~ATOM_S3_DFP3_CRTC_ACTIVE;
2217 bios_3_scratch |= (crtc << 25);
2220 if (rdev->family >= CHIP_R600)
2221 WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch);
2223 WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch);
2227 radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
2229 struct drm_device *dev = encoder->dev;
2230 struct radeon_device *rdev = dev->dev_private;
2231 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2232 uint32_t bios_2_scratch;
2234 if (rdev->family >= CHIP_R600)
2235 bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH);
2237 bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH);
2239 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
2241 bios_2_scratch &= ~ATOM_S2_TV1_DPMS_STATE;
2243 bios_2_scratch |= ATOM_S2_TV1_DPMS_STATE;
2245 if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) {
2247 bios_2_scratch &= ~ATOM_S2_CV_DPMS_STATE;
2249 bios_2_scratch |= ATOM_S2_CV_DPMS_STATE;
2251 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
2253 bios_2_scratch &= ~ATOM_S2_CRT1_DPMS_STATE;
2255 bios_2_scratch |= ATOM_S2_CRT1_DPMS_STATE;
2257 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
2259 bios_2_scratch &= ~ATOM_S2_CRT2_DPMS_STATE;
2261 bios_2_scratch |= ATOM_S2_CRT2_DPMS_STATE;
2263 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
2265 bios_2_scratch &= ~ATOM_S2_LCD1_DPMS_STATE;
2267 bios_2_scratch |= ATOM_S2_LCD1_DPMS_STATE;
2269 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
2271 bios_2_scratch &= ~ATOM_S2_DFP1_DPMS_STATE;
2273 bios_2_scratch |= ATOM_S2_DFP1_DPMS_STATE;
2275 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
2277 bios_2_scratch &= ~ATOM_S2_DFP2_DPMS_STATE;
2279 bios_2_scratch |= ATOM_S2_DFP2_DPMS_STATE;
2281 if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) {
2283 bios_2_scratch &= ~ATOM_S2_DFP3_DPMS_STATE;
2285 bios_2_scratch |= ATOM_S2_DFP3_DPMS_STATE;
2287 if (radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) {
2289 bios_2_scratch &= ~ATOM_S2_DFP4_DPMS_STATE;
2291 bios_2_scratch |= ATOM_S2_DFP4_DPMS_STATE;
2293 if (radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) {
2295 bios_2_scratch &= ~ATOM_S2_DFP5_DPMS_STATE;
2297 bios_2_scratch |= ATOM_S2_DFP5_DPMS_STATE;
2300 if (rdev->family >= CHIP_R600)
2301 WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch);
2303 WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch);