Rev 1428 | Rev 1963 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1428 | Rev 1430 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2007-8 Advanced Micro Devices, Inc. |
2 | * Copyright 2007-8 Advanced Micro Devices, Inc. |
3 | * Copyright 2008 Red Hat Inc. |
3 | * Copyright 2008 Red Hat Inc. |
4 | * |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), |
6 | * copy of this software and associated documentation files (the "Software"), |
7 | * to deal in the Software without restriction, including without limitation |
7 | * to deal in the Software without restriction, including without limitation |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
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 |
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: |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * |
11 | * |
12 | * The above copyright notice and this permission notice shall be included in |
12 | * The above copyright notice and this permission notice shall be included in |
13 | * all copies or substantial portions of the Software. |
13 | * all copies or substantial portions of the Software. |
14 | * |
14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
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, |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
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 |
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, |
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 |
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
21 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * OTHER DEALINGS IN THE SOFTWARE. |
22 | * |
22 | * |
23 | * Authors: Dave Airlie |
23 | * Authors: Dave Airlie |
24 | * Alex Deucher |
24 | * Alex Deucher |
25 | */ |
25 | */ |
26 | #include "drmP.h" |
26 | #include "drmP.h" |
27 | #include "radeon_drm.h" |
27 | #include "radeon_drm.h" |
28 | #include "radeon.h" |
28 | #include "radeon.h" |
29 | 29 | ||
30 | #include "atom.h" |
30 | #include "atom.h" |
31 | #include "atom-bits.h" |
31 | #include "atom-bits.h" |
32 | 32 | ||
33 | /* from radeon_encoder.c */ |
33 | /* from radeon_encoder.c */ |
34 | extern uint32_t |
34 | extern uint32_t |
35 | radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device, |
35 | radeon_get_encoder_id(struct drm_device *dev, uint32_t supported_device, |
36 | uint8_t dac); |
36 | uint8_t dac); |
37 | extern void radeon_link_encoder_connector(struct drm_device *dev); |
37 | extern void radeon_link_encoder_connector(struct drm_device *dev); |
38 | extern void |
38 | extern void |
39 | radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, |
39 | radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, |
40 | uint32_t supported_device); |
40 | uint32_t supported_device); |
41 | 41 | ||
42 | /* from radeon_connector.c */ |
42 | /* from radeon_connector.c */ |
43 | extern void |
43 | extern void |
44 | radeon_add_atom_connector(struct drm_device *dev, |
44 | radeon_add_atom_connector(struct drm_device *dev, |
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); |
51 | struct radeon_hpd *hpd); |
52 | 52 | ||
53 | /* from radeon_legacy_encoder.c */ |
53 | /* from radeon_legacy_encoder.c */ |
54 | extern void |
54 | extern void |
55 | 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, |
56 | uint32_t supported_device); |
56 | uint32_t supported_device); |
57 | 57 | ||
58 | union atom_supported_devices { |
58 | union atom_supported_devices { |
59 | struct _ATOM_SUPPORTED_DEVICES_INFO info; |
59 | struct _ATOM_SUPPORTED_DEVICES_INFO info; |
60 | struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; |
60 | struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; |
61 | struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; |
61 | struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; |
62 | }; |
62 | }; |
63 | 63 | ||
64 | static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev, |
64 | static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev, |
65 | uint8_t id) |
65 | uint8_t id) |
66 | { |
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; |
72 | uint16_t data_offset; |
73 | int i; |
73 | int i; |
74 | 74 | ||
75 | memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); |
75 | memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); |
76 | i2c.valid = false; |
76 | i2c.valid = false; |
77 | 77 | ||
78 | atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset); |
78 | atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset); |
79 | 79 | ||
80 | i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); |
80 | i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); |
81 | 81 | ||
82 | 82 | ||
83 | for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) { |
83 | for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) { |
84 | gpio = &i2c_info->asGPIO_Info[i]; |
84 | gpio = &i2c_info->asGPIO_Info[i]; |
85 | 85 | ||
86 | if (gpio->sucI2cId.ucAccess == id) { |
86 | if (gpio->sucI2cId.ucAccess == id) { |
87 | i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; |
87 | i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; |
88 | i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; |
88 | i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; |
89 | i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; |
89 | i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; |
90 | i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; |
90 | i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; |
91 | i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; |
91 | i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; |
92 | i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; |
92 | i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; |
93 | i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; |
93 | i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; |
94 | i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; |
94 | i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; |
95 | i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); |
95 | i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); |
96 | i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); |
96 | i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); |
97 | i2c.en_clk_mask = (1 << gpio->ucClkEnShift); |
97 | i2c.en_clk_mask = (1 << gpio->ucClkEnShift); |
98 | i2c.en_data_mask = (1 << gpio->ucDataEnShift); |
98 | i2c.en_data_mask = (1 << gpio->ucDataEnShift); |
99 | i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); |
99 | i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); |
100 | i2c.y_data_mask = (1 << gpio->ucDataY_Shift); |
100 | i2c.y_data_mask = (1 << gpio->ucDataY_Shift); |
101 | i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); |
101 | i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); |
102 | i2c.a_data_mask = (1 << gpio->ucDataA_Shift); |
102 | i2c.a_data_mask = (1 << gpio->ucDataA_Shift); |
103 | 103 | ||
104 | if (gpio->sucI2cId.sbfAccess.bfHW_Capable) |
104 | if (gpio->sucI2cId.sbfAccess.bfHW_Capable) |
105 | i2c.hw_capable = true; |
105 | i2c.hw_capable = true; |
106 | else |
106 | else |
107 | i2c.hw_capable = false; |
107 | i2c.hw_capable = false; |
108 | 108 | ||
109 | if (gpio->sucI2cId.ucAccess == 0xa0) |
109 | if (gpio->sucI2cId.ucAccess == 0xa0) |
110 | i2c.mm_i2c = true; |
110 | i2c.mm_i2c = true; |
111 | else |
111 | else |
112 | i2c.mm_i2c = false; |
112 | i2c.mm_i2c = false; |
113 | 113 | ||
114 | i2c.i2c_id = gpio->sucI2cId.ucAccess; |
114 | i2c.i2c_id = gpio->sucI2cId.ucAccess; |
115 | 115 | ||
116 | i2c.valid = true; |
116 | i2c.valid = true; |
117 | break; |
117 | break; |
118 | } |
118 | } |
119 | } |
119 | } |
120 | 120 | ||
121 | return i2c; |
121 | return i2c; |
122 | } |
122 | } |
123 | 123 | ||
124 | static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, |
124 | static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rdev, |
125 | u8 id) |
125 | u8 id) |
126 | { |
126 | { |
127 | struct atom_context *ctx = rdev->mode_info.atom_context; |
127 | struct atom_context *ctx = rdev->mode_info.atom_context; |
128 | struct radeon_gpio_rec gpio; |
128 | struct radeon_gpio_rec gpio; |
129 | int index = GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT); |
129 | int index = GetIndexIntoMasterTable(DATA, GPIO_Pin_LUT); |
130 | struct _ATOM_GPIO_PIN_LUT *gpio_info; |
130 | struct _ATOM_GPIO_PIN_LUT *gpio_info; |
131 | ATOM_GPIO_PIN_ASSIGNMENT *pin; |
131 | ATOM_GPIO_PIN_ASSIGNMENT *pin; |
132 | u16 data_offset, size; |
132 | u16 data_offset, size; |
133 | int i, num_indices; |
133 | int i, num_indices; |
134 | 134 | ||
135 | memset(&gpio, 0, sizeof(struct radeon_gpio_rec)); |
135 | memset(&gpio, 0, sizeof(struct radeon_gpio_rec)); |
136 | gpio.valid = false; |
136 | gpio.valid = false; |
137 | 137 | ||
138 | atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset); |
138 | atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset); |
139 | 139 | ||
140 | gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset); |
140 | gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset); |
141 | 141 | ||
142 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(ATOM_GPIO_PIN_ASSIGNMENT); |
142 | num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(ATOM_GPIO_PIN_ASSIGNMENT); |
143 | 143 | ||
144 | for (i = 0; i < num_indices; i++) { |
144 | for (i = 0; i < num_indices; i++) { |
145 | pin = &gpio_info->asGPIO_Pin[i]; |
145 | pin = &gpio_info->asGPIO_Pin[i]; |
146 | if (id == pin->ucGPIO_ID) { |
146 | if (id == pin->ucGPIO_ID) { |
147 | gpio.id = pin->ucGPIO_ID; |
147 | gpio.id = pin->ucGPIO_ID; |
148 | gpio.reg = pin->usGpioPin_AIndex * 4; |
148 | gpio.reg = pin->usGpioPin_AIndex * 4; |
149 | gpio.mask = (1 << pin->ucGpioPinBitShift); |
149 | gpio.mask = (1 << pin->ucGpioPinBitShift); |
150 | gpio.valid = true; |
150 | gpio.valid = true; |
151 | break; |
151 | break; |
152 | } |
152 | } |
153 | } |
153 | } |
154 | 154 | ||
155 | return gpio; |
155 | return gpio; |
156 | } |
156 | } |
157 | 157 | ||
158 | static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device *rdev, |
158 | static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device *rdev, |
159 | struct radeon_gpio_rec *gpio) |
159 | struct radeon_gpio_rec *gpio) |
160 | { |
160 | { |
161 | struct radeon_hpd hpd; |
161 | struct radeon_hpd hpd; |
- | 162 | u32 reg; |
|
- | 163 | ||
- | 164 | if (ASIC_IS_DCE4(rdev)) |
|
- | 165 | reg = EVERGREEN_DC_GPIO_HPD_A; |
|
- | 166 | else |
|
- | 167 | reg = AVIVO_DC_GPIO_HPD_A; |
|
- | 168 | ||
162 | hpd.gpio = *gpio; |
169 | hpd.gpio = *gpio; |
163 | if (gpio->reg == AVIVO_DC_GPIO_HPD_A) { |
170 | if (gpio->reg == reg) { |
164 | switch(gpio->mask) { |
171 | switch(gpio->mask) { |
165 | case (1 << 0): |
172 | case (1 << 0): |
166 | hpd.hpd = RADEON_HPD_1; |
173 | hpd.hpd = RADEON_HPD_1; |
167 | break; |
174 | break; |
168 | case (1 << 8): |
175 | case (1 << 8): |
169 | hpd.hpd = RADEON_HPD_2; |
176 | hpd.hpd = RADEON_HPD_2; |
170 | break; |
177 | break; |
171 | case (1 << 16): |
178 | case (1 << 16): |
172 | hpd.hpd = RADEON_HPD_3; |
179 | hpd.hpd = RADEON_HPD_3; |
173 | break; |
180 | break; |
174 | case (1 << 24): |
181 | case (1 << 24): |
175 | hpd.hpd = RADEON_HPD_4; |
182 | hpd.hpd = RADEON_HPD_4; |
176 | break; |
183 | break; |
177 | case (1 << 26): |
184 | case (1 << 26): |
178 | hpd.hpd = RADEON_HPD_5; |
185 | hpd.hpd = RADEON_HPD_5; |
179 | break; |
186 | break; |
180 | case (1 << 28): |
187 | case (1 << 28): |
181 | hpd.hpd = RADEON_HPD_6; |
188 | hpd.hpd = RADEON_HPD_6; |
182 | break; |
189 | break; |
183 | default: |
190 | default: |
184 | hpd.hpd = RADEON_HPD_NONE; |
191 | hpd.hpd = RADEON_HPD_NONE; |
185 | break; |
192 | break; |
186 | } |
193 | } |
187 | } else |
194 | } else |
188 | hpd.hpd = RADEON_HPD_NONE; |
195 | hpd.hpd = RADEON_HPD_NONE; |
189 | return hpd; |
196 | return hpd; |
190 | } |
197 | } |
191 | 198 | ||
192 | static bool radeon_atom_apply_quirks(struct drm_device *dev, |
199 | static bool radeon_atom_apply_quirks(struct drm_device *dev, |
193 | uint32_t supported_device, |
200 | uint32_t supported_device, |
194 | int *connector_type, |
201 | int *connector_type, |
195 | struct radeon_i2c_bus_rec *i2c_bus, |
202 | struct radeon_i2c_bus_rec *i2c_bus, |
196 | uint16_t *line_mux, |
203 | uint16_t *line_mux, |
197 | struct radeon_hpd *hpd) |
204 | struct radeon_hpd *hpd) |
198 | { |
205 | { |
199 | 206 | ||
200 | /* Asus M2A-VM HDMI board lists the DVI port as HDMI */ |
207 | /* Asus M2A-VM HDMI board lists the DVI port as HDMI */ |
201 | if ((dev->pdev->device == 0x791e) && |
208 | if ((dev->pdev->device == 0x791e) && |
202 | (dev->pdev->subsystem_vendor == 0x1043) && |
209 | (dev->pdev->subsystem_vendor == 0x1043) && |
203 | (dev->pdev->subsystem_device == 0x826d)) { |
210 | (dev->pdev->subsystem_device == 0x826d)) { |
204 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
211 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
205 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
212 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
206 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
213 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
207 | } |
214 | } |
208 | 215 | ||
209 | /* Asrock RS600 board lists the DVI port as HDMI */ |
216 | /* Asrock RS600 board lists the DVI port as HDMI */ |
210 | if ((dev->pdev->device == 0x7941) && |
217 | if ((dev->pdev->device == 0x7941) && |
211 | (dev->pdev->subsystem_vendor == 0x1849) && |
218 | (dev->pdev->subsystem_vendor == 0x1849) && |
212 | (dev->pdev->subsystem_device == 0x7941)) { |
219 | (dev->pdev->subsystem_device == 0x7941)) { |
213 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
220 | if ((*connector_type == DRM_MODE_CONNECTOR_HDMIA) && |
214 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
221 | (supported_device == ATOM_DEVICE_DFP3_SUPPORT)) |
215 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
222 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
216 | } |
223 | } |
217 | 224 | ||
218 | /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */ |
225 | /* a-bit f-i90hd - ciaranm on #radeonhd - this board has no DVI */ |
219 | if ((dev->pdev->device == 0x7941) && |
226 | if ((dev->pdev->device == 0x7941) && |
220 | (dev->pdev->subsystem_vendor == 0x147b) && |
227 | (dev->pdev->subsystem_vendor == 0x147b) && |
221 | (dev->pdev->subsystem_device == 0x2412)) { |
228 | (dev->pdev->subsystem_device == 0x2412)) { |
222 | if (*connector_type == DRM_MODE_CONNECTOR_DVII) |
229 | if (*connector_type == DRM_MODE_CONNECTOR_DVII) |
223 | return false; |
230 | return false; |
224 | } |
231 | } |
225 | 232 | ||
226 | /* Falcon NW laptop lists vga ddc line for LVDS */ |
233 | /* Falcon NW laptop lists vga ddc line for LVDS */ |
227 | if ((dev->pdev->device == 0x5653) && |
234 | if ((dev->pdev->device == 0x5653) && |
228 | (dev->pdev->subsystem_vendor == 0x1462) && |
235 | (dev->pdev->subsystem_vendor == 0x1462) && |
229 | (dev->pdev->subsystem_device == 0x0291)) { |
236 | (dev->pdev->subsystem_device == 0x0291)) { |
230 | if (*connector_type == DRM_MODE_CONNECTOR_LVDS) { |
237 | if (*connector_type == DRM_MODE_CONNECTOR_LVDS) { |
231 | i2c_bus->valid = false; |
238 | i2c_bus->valid = false; |
232 | *line_mux = 53; |
239 | *line_mux = 53; |
233 | } |
240 | } |
234 | } |
241 | } |
235 | 242 | ||
236 | /* HIS X1300 is DVI+VGA, not DVI+DVI */ |
243 | /* HIS X1300 is DVI+VGA, not DVI+DVI */ |
237 | if ((dev->pdev->device == 0x7146) && |
244 | if ((dev->pdev->device == 0x7146) && |
238 | (dev->pdev->subsystem_vendor == 0x17af) && |
245 | (dev->pdev->subsystem_vendor == 0x17af) && |
239 | (dev->pdev->subsystem_device == 0x2058)) { |
246 | (dev->pdev->subsystem_device == 0x2058)) { |
240 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
247 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
241 | return false; |
248 | return false; |
242 | } |
249 | } |
243 | 250 | ||
244 | /* Gigabyte X1300 is DVI+VGA, not DVI+DVI */ |
251 | /* Gigabyte X1300 is DVI+VGA, not DVI+DVI */ |
245 | if ((dev->pdev->device == 0x7142) && |
252 | if ((dev->pdev->device == 0x7142) && |
246 | (dev->pdev->subsystem_vendor == 0x1458) && |
253 | (dev->pdev->subsystem_vendor == 0x1458) && |
247 | (dev->pdev->subsystem_device == 0x2134)) { |
254 | (dev->pdev->subsystem_device == 0x2134)) { |
248 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
255 | if (supported_device == ATOM_DEVICE_DFP1_SUPPORT) |
249 | return false; |
256 | return false; |
250 | } |
257 | } |
251 | 258 | ||
252 | 259 | ||
253 | /* Funky macbooks */ |
260 | /* Funky macbooks */ |
254 | if ((dev->pdev->device == 0x71C5) && |
261 | if ((dev->pdev->device == 0x71C5) && |
255 | (dev->pdev->subsystem_vendor == 0x106b) && |
262 | (dev->pdev->subsystem_vendor == 0x106b) && |
256 | (dev->pdev->subsystem_device == 0x0080)) { |
263 | (dev->pdev->subsystem_device == 0x0080)) { |
257 | if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) || |
264 | if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) || |
258 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) |
265 | (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) |
259 | return false; |
266 | return false; |
260 | } |
267 | } |
261 | 268 | ||
262 | /* ASUS HD 3600 XT board lists the DVI port as HDMI */ |
269 | /* ASUS HD 3600 XT board lists the DVI port as HDMI */ |
263 | if ((dev->pdev->device == 0x9598) && |
270 | if ((dev->pdev->device == 0x9598) && |
264 | (dev->pdev->subsystem_vendor == 0x1043) && |
271 | (dev->pdev->subsystem_vendor == 0x1043) && |
265 | (dev->pdev->subsystem_device == 0x01da)) { |
272 | (dev->pdev->subsystem_device == 0x01da)) { |
266 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
273 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
267 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
274 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
268 | } |
275 | } |
269 | } |
276 | } |
270 | 277 | ||
271 | /* ASUS HD 3450 board lists the DVI port as HDMI */ |
278 | /* ASUS HD 3450 board lists the DVI port as HDMI */ |
272 | if ((dev->pdev->device == 0x95C5) && |
279 | if ((dev->pdev->device == 0x95C5) && |
273 | (dev->pdev->subsystem_vendor == 0x1043) && |
280 | (dev->pdev->subsystem_vendor == 0x1043) && |
274 | (dev->pdev->subsystem_device == 0x01e2)) { |
281 | (dev->pdev->subsystem_device == 0x01e2)) { |
275 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
282 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
276 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
283 | *connector_type = DRM_MODE_CONNECTOR_DVII; |
277 | } |
284 | } |
278 | } |
285 | } |
279 | 286 | ||
280 | /* some BIOSes seem to report DAC on HDMI - usually this is a board with |
287 | /* some BIOSes seem to report DAC on HDMI - usually this is a board with |
281 | * HDMI + VGA reporting as HDMI |
288 | * HDMI + VGA reporting as HDMI |
282 | */ |
289 | */ |
283 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
290 | if (*connector_type == DRM_MODE_CONNECTOR_HDMIA) { |
284 | if (supported_device & (ATOM_DEVICE_CRT_SUPPORT)) { |
291 | if (supported_device & (ATOM_DEVICE_CRT_SUPPORT)) { |
285 | *connector_type = DRM_MODE_CONNECTOR_VGA; |
292 | *connector_type = DRM_MODE_CONNECTOR_VGA; |
286 | *line_mux = 0; |
293 | *line_mux = 0; |
287 | } |
294 | } |
288 | } |
295 | } |
289 | 296 | ||
290 | /* Acer laptop reports DVI-D as DVI-I */ |
297 | /* Acer laptop reports DVI-D as DVI-I */ |
291 | if ((dev->pdev->device == 0x95c4) && |
298 | if ((dev->pdev->device == 0x95c4) && |
292 | (dev->pdev->subsystem_vendor == 0x1025) && |
299 | (dev->pdev->subsystem_vendor == 0x1025) && |
293 | (dev->pdev->subsystem_device == 0x013c)) { |
300 | (dev->pdev->subsystem_device == 0x013c)) { |
294 | if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && |
301 | if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && |
295 | (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) |
302 | (supported_device == ATOM_DEVICE_DFP1_SUPPORT)) |
296 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
303 | *connector_type = DRM_MODE_CONNECTOR_DVID; |
297 | } |
304 | } |
298 | 305 | ||
299 | /* XFX Pine Group device rv730 reports no VGA DDC lines |
306 | /* XFX Pine Group device rv730 reports no VGA DDC lines |
300 | * even though they are wired up to record 0x93 |
307 | * even though they are wired up to record 0x93 |
301 | */ |
308 | */ |
302 | if ((dev->pdev->device == 0x9498) && |
309 | if ((dev->pdev->device == 0x9498) && |
303 | (dev->pdev->subsystem_vendor == 0x1682) && |
310 | (dev->pdev->subsystem_vendor == 0x1682) && |
304 | (dev->pdev->subsystem_device == 0x2452)) { |
311 | (dev->pdev->subsystem_device == 0x2452)) { |
305 | struct radeon_device *rdev = dev->dev_private; |
312 | struct radeon_device *rdev = dev->dev_private; |
306 | *i2c_bus = radeon_lookup_i2c_gpio(rdev, 0x93); |
313 | *i2c_bus = radeon_lookup_i2c_gpio(rdev, 0x93); |
307 | } |
314 | } |
308 | return true; |
315 | return true; |
309 | } |
316 | } |
310 | 317 | ||
311 | const int supported_devices_connector_convert[] = { |
318 | const int supported_devices_connector_convert[] = { |
312 | DRM_MODE_CONNECTOR_Unknown, |
319 | DRM_MODE_CONNECTOR_Unknown, |
313 | DRM_MODE_CONNECTOR_VGA, |
320 | DRM_MODE_CONNECTOR_VGA, |
314 | DRM_MODE_CONNECTOR_DVII, |
321 | DRM_MODE_CONNECTOR_DVII, |
315 | DRM_MODE_CONNECTOR_DVID, |
322 | DRM_MODE_CONNECTOR_DVID, |
316 | DRM_MODE_CONNECTOR_DVIA, |
323 | DRM_MODE_CONNECTOR_DVIA, |
317 | DRM_MODE_CONNECTOR_SVIDEO, |
324 | DRM_MODE_CONNECTOR_SVIDEO, |
318 | DRM_MODE_CONNECTOR_Composite, |
325 | DRM_MODE_CONNECTOR_Composite, |
319 | DRM_MODE_CONNECTOR_LVDS, |
326 | DRM_MODE_CONNECTOR_LVDS, |
320 | DRM_MODE_CONNECTOR_Unknown, |
327 | DRM_MODE_CONNECTOR_Unknown, |
321 | DRM_MODE_CONNECTOR_Unknown, |
328 | DRM_MODE_CONNECTOR_Unknown, |
322 | DRM_MODE_CONNECTOR_HDMIA, |
329 | DRM_MODE_CONNECTOR_HDMIA, |
323 | DRM_MODE_CONNECTOR_HDMIB, |
330 | DRM_MODE_CONNECTOR_HDMIB, |
324 | DRM_MODE_CONNECTOR_Unknown, |
331 | DRM_MODE_CONNECTOR_Unknown, |
325 | DRM_MODE_CONNECTOR_Unknown, |
332 | DRM_MODE_CONNECTOR_Unknown, |
326 | DRM_MODE_CONNECTOR_9PinDIN, |
333 | DRM_MODE_CONNECTOR_9PinDIN, |
327 | DRM_MODE_CONNECTOR_DisplayPort |
334 | DRM_MODE_CONNECTOR_DisplayPort |
328 | }; |
335 | }; |
329 | 336 | ||
330 | const uint16_t supported_devices_connector_object_id_convert[] = { |
337 | const uint16_t supported_devices_connector_object_id_convert[] = { |
331 | CONNECTOR_OBJECT_ID_NONE, |
338 | CONNECTOR_OBJECT_ID_NONE, |
332 | CONNECTOR_OBJECT_ID_VGA, |
339 | CONNECTOR_OBJECT_ID_VGA, |
333 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, /* not all boards support DL */ |
340 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I, /* not all boards support DL */ |
334 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D, /* not all boards support DL */ |
341 | CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D, /* not all boards support DL */ |
335 | CONNECTOR_OBJECT_ID_VGA, /* technically DVI-A */ |
342 | CONNECTOR_OBJECT_ID_VGA, /* technically DVI-A */ |
336 | CONNECTOR_OBJECT_ID_COMPOSITE, |
343 | CONNECTOR_OBJECT_ID_COMPOSITE, |
337 | CONNECTOR_OBJECT_ID_SVIDEO, |
344 | CONNECTOR_OBJECT_ID_SVIDEO, |
338 | CONNECTOR_OBJECT_ID_LVDS, |
345 | CONNECTOR_OBJECT_ID_LVDS, |
339 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
346 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
340 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
347 | CONNECTOR_OBJECT_ID_9PIN_DIN, |
341 | CONNECTOR_OBJECT_ID_DISPLAYPORT, |
348 | CONNECTOR_OBJECT_ID_DISPLAYPORT, |
342 | CONNECTOR_OBJECT_ID_HDMI_TYPE_A, |
349 | CONNECTOR_OBJECT_ID_HDMI_TYPE_A, |
343 | CONNECTOR_OBJECT_ID_HDMI_TYPE_B, |
350 | CONNECTOR_OBJECT_ID_HDMI_TYPE_B, |
344 | CONNECTOR_OBJECT_ID_SVIDEO |
351 | CONNECTOR_OBJECT_ID_SVIDEO |
345 | }; |
352 | }; |
346 | 353 | ||
347 | const int object_connector_convert[] = { |
354 | const int object_connector_convert[] = { |
348 | DRM_MODE_CONNECTOR_Unknown, |
355 | DRM_MODE_CONNECTOR_Unknown, |
349 | DRM_MODE_CONNECTOR_DVII, |
356 | DRM_MODE_CONNECTOR_DVII, |
350 | DRM_MODE_CONNECTOR_DVII, |
357 | DRM_MODE_CONNECTOR_DVII, |
351 | DRM_MODE_CONNECTOR_DVID, |
358 | DRM_MODE_CONNECTOR_DVID, |
352 | DRM_MODE_CONNECTOR_DVID, |
359 | DRM_MODE_CONNECTOR_DVID, |
353 | DRM_MODE_CONNECTOR_VGA, |
360 | DRM_MODE_CONNECTOR_VGA, |
354 | DRM_MODE_CONNECTOR_Composite, |
361 | DRM_MODE_CONNECTOR_Composite, |
355 | DRM_MODE_CONNECTOR_SVIDEO, |
362 | DRM_MODE_CONNECTOR_SVIDEO, |
356 | DRM_MODE_CONNECTOR_Unknown, |
363 | DRM_MODE_CONNECTOR_Unknown, |
357 | DRM_MODE_CONNECTOR_Unknown, |
364 | DRM_MODE_CONNECTOR_Unknown, |
358 | DRM_MODE_CONNECTOR_9PinDIN, |
365 | DRM_MODE_CONNECTOR_9PinDIN, |
359 | DRM_MODE_CONNECTOR_Unknown, |
366 | DRM_MODE_CONNECTOR_Unknown, |
360 | DRM_MODE_CONNECTOR_HDMIA, |
367 | DRM_MODE_CONNECTOR_HDMIA, |
361 | DRM_MODE_CONNECTOR_HDMIB, |
368 | DRM_MODE_CONNECTOR_HDMIB, |
362 | DRM_MODE_CONNECTOR_LVDS, |
369 | DRM_MODE_CONNECTOR_LVDS, |
363 | DRM_MODE_CONNECTOR_9PinDIN, |
370 | DRM_MODE_CONNECTOR_9PinDIN, |
364 | DRM_MODE_CONNECTOR_Unknown, |
371 | DRM_MODE_CONNECTOR_Unknown, |
365 | DRM_MODE_CONNECTOR_Unknown, |
372 | DRM_MODE_CONNECTOR_Unknown, |
366 | DRM_MODE_CONNECTOR_Unknown, |
373 | DRM_MODE_CONNECTOR_Unknown, |
367 | DRM_MODE_CONNECTOR_DisplayPort, |
374 | DRM_MODE_CONNECTOR_DisplayPort, |
368 | DRM_MODE_CONNECTOR_eDP, |
375 | DRM_MODE_CONNECTOR_eDP, |
369 | DRM_MODE_CONNECTOR_Unknown |
376 | DRM_MODE_CONNECTOR_Unknown |
370 | }; |
377 | }; |
371 | 378 | ||
372 | bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) |
379 | bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) |
373 | { |
380 | { |
374 | struct radeon_device *rdev = dev->dev_private; |
381 | struct radeon_device *rdev = dev->dev_private; |
375 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
382 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
376 | struct atom_context *ctx = mode_info->atom_context; |
383 | struct atom_context *ctx = mode_info->atom_context; |
377 | int index = GetIndexIntoMasterTable(DATA, Object_Header); |
384 | int index = GetIndexIntoMasterTable(DATA, Object_Header); |
378 | u16 size, data_offset; |
385 | u16 size, data_offset; |
379 | u8 frev, crev; |
386 | u8 frev, crev; |
380 | ATOM_CONNECTOR_OBJECT_TABLE *con_obj; |
387 | ATOM_CONNECTOR_OBJECT_TABLE *con_obj; |
381 | ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj; |
388 | ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj; |
382 | ATOM_OBJECT_HEADER *obj_header; |
389 | ATOM_OBJECT_HEADER *obj_header; |
383 | int i, j, path_size, device_support; |
390 | int i, j, path_size, device_support; |
384 | int connector_type; |
391 | int connector_type; |
385 | u16 igp_lane_info, conn_id, connector_object_id; |
392 | u16 igp_lane_info, conn_id, connector_object_id; |
386 | bool linkb; |
393 | bool linkb; |
387 | struct radeon_i2c_bus_rec ddc_bus; |
394 | struct radeon_i2c_bus_rec ddc_bus; |
388 | struct radeon_gpio_rec gpio; |
395 | struct radeon_gpio_rec gpio; |
389 | struct radeon_hpd hpd; |
396 | struct radeon_hpd hpd; |
390 | 397 | ||
391 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
398 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
392 | 399 | ||
393 | if (data_offset == 0) |
400 | if (data_offset == 0) |
394 | return false; |
401 | return false; |
395 | 402 | ||
396 | if (crev < 2) |
403 | if (crev < 2) |
397 | return false; |
404 | return false; |
398 | 405 | ||
399 | obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); |
406 | obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset); |
400 | path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *) |
407 | path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *) |
401 | (ctx->bios + data_offset + |
408 | (ctx->bios + data_offset + |
402 | le16_to_cpu(obj_header->usDisplayPathTableOffset)); |
409 | le16_to_cpu(obj_header->usDisplayPathTableOffset)); |
403 | con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *) |
410 | con_obj = (ATOM_CONNECTOR_OBJECT_TABLE *) |
404 | (ctx->bios + data_offset + |
411 | (ctx->bios + data_offset + |
405 | le16_to_cpu(obj_header->usConnectorObjectTableOffset)); |
412 | le16_to_cpu(obj_header->usConnectorObjectTableOffset)); |
406 | device_support = le16_to_cpu(obj_header->usDeviceSupport); |
413 | device_support = le16_to_cpu(obj_header->usDeviceSupport); |
407 | 414 | ||
408 | path_size = 0; |
415 | path_size = 0; |
409 | for (i = 0; i < path_obj->ucNumOfDispPath; i++) { |
416 | for (i = 0; i < path_obj->ucNumOfDispPath; i++) { |
410 | uint8_t *addr = (uint8_t *) path_obj->asDispPath; |
417 | uint8_t *addr = (uint8_t *) path_obj->asDispPath; |
411 | ATOM_DISPLAY_OBJECT_PATH *path; |
418 | ATOM_DISPLAY_OBJECT_PATH *path; |
412 | addr += path_size; |
419 | addr += path_size; |
413 | path = (ATOM_DISPLAY_OBJECT_PATH *) addr; |
420 | path = (ATOM_DISPLAY_OBJECT_PATH *) addr; |
414 | path_size += le16_to_cpu(path->usSize); |
421 | path_size += le16_to_cpu(path->usSize); |
415 | linkb = false; |
422 | linkb = false; |
416 | if (device_support & le16_to_cpu(path->usDeviceTag)) { |
423 | if (device_support & le16_to_cpu(path->usDeviceTag)) { |
417 | uint8_t con_obj_id, con_obj_num, con_obj_type; |
424 | uint8_t con_obj_id, con_obj_num, con_obj_type; |
418 | 425 | ||
419 | con_obj_id = |
426 | con_obj_id = |
420 | (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK) |
427 | (le16_to_cpu(path->usConnObjectId) & OBJECT_ID_MASK) |
421 | >> OBJECT_ID_SHIFT; |
428 | >> OBJECT_ID_SHIFT; |
422 | con_obj_num = |
429 | con_obj_num = |
423 | (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK) |
430 | (le16_to_cpu(path->usConnObjectId) & ENUM_ID_MASK) |
424 | >> ENUM_ID_SHIFT; |
431 | >> ENUM_ID_SHIFT; |
425 | con_obj_type = |
432 | con_obj_type = |
426 | (le16_to_cpu(path->usConnObjectId) & |
433 | (le16_to_cpu(path->usConnObjectId) & |
427 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
434 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
428 | 435 | ||
429 | /* TODO CV support */ |
436 | /* TODO CV support */ |
430 | if (le16_to_cpu(path->usDeviceTag) == |
437 | if (le16_to_cpu(path->usDeviceTag) == |
431 | ATOM_DEVICE_CV_SUPPORT) |
438 | ATOM_DEVICE_CV_SUPPORT) |
432 | continue; |
439 | continue; |
433 | 440 | ||
434 | /* IGP chips */ |
441 | /* IGP chips */ |
435 | if ((rdev->flags & RADEON_IS_IGP) && |
442 | if ((rdev->flags & RADEON_IS_IGP) && |
436 | (con_obj_id == |
443 | (con_obj_id == |
437 | CONNECTOR_OBJECT_ID_PCIE_CONNECTOR)) { |
444 | CONNECTOR_OBJECT_ID_PCIE_CONNECTOR)) { |
438 | uint16_t igp_offset = 0; |
445 | uint16_t igp_offset = 0; |
439 | ATOM_INTEGRATED_SYSTEM_INFO_V2 *igp_obj; |
446 | ATOM_INTEGRATED_SYSTEM_INFO_V2 *igp_obj; |
440 | 447 | ||
441 | index = |
448 | index = |
442 | GetIndexIntoMasterTable(DATA, |
449 | GetIndexIntoMasterTable(DATA, |
443 | IntegratedSystemInfo); |
450 | IntegratedSystemInfo); |
444 | 451 | ||
445 | atom_parse_data_header(ctx, index, &size, &frev, |
452 | atom_parse_data_header(ctx, index, &size, &frev, |
446 | &crev, &igp_offset); |
453 | &crev, &igp_offset); |
447 | 454 | ||
448 | if (crev >= 2) { |
455 | if (crev >= 2) { |
449 | igp_obj = |
456 | igp_obj = |
450 | (ATOM_INTEGRATED_SYSTEM_INFO_V2 |
457 | (ATOM_INTEGRATED_SYSTEM_INFO_V2 |
451 | *) (ctx->bios + igp_offset); |
458 | *) (ctx->bios + igp_offset); |
452 | 459 | ||
453 | if (igp_obj) { |
460 | if (igp_obj) { |
454 | uint32_t slot_config, ct; |
461 | uint32_t slot_config, ct; |
455 | 462 | ||
456 | if (con_obj_num == 1) |
463 | if (con_obj_num == 1) |
457 | slot_config = |
464 | slot_config = |
458 | igp_obj-> |
465 | igp_obj-> |
459 | ulDDISlot1Config; |
466 | ulDDISlot1Config; |
460 | else |
467 | else |
461 | slot_config = |
468 | slot_config = |
462 | igp_obj-> |
469 | igp_obj-> |
463 | ulDDISlot2Config; |
470 | ulDDISlot2Config; |
464 | 471 | ||
465 | ct = (slot_config >> 16) & 0xff; |
472 | ct = (slot_config >> 16) & 0xff; |
466 | connector_type = |
473 | connector_type = |
467 | object_connector_convert |
474 | object_connector_convert |
468 | [ct]; |
475 | [ct]; |
469 | connector_object_id = ct; |
476 | connector_object_id = ct; |
470 | igp_lane_info = |
477 | igp_lane_info = |
471 | slot_config & 0xffff; |
478 | slot_config & 0xffff; |
472 | } else |
479 | } else |
473 | continue; |
480 | continue; |
474 | } else |
481 | } else |
475 | continue; |
482 | continue; |
476 | } else { |
483 | } else { |
477 | igp_lane_info = 0; |
484 | igp_lane_info = 0; |
478 | connector_type = |
485 | connector_type = |
479 | object_connector_convert[con_obj_id]; |
486 | object_connector_convert[con_obj_id]; |
480 | connector_object_id = con_obj_id; |
487 | connector_object_id = con_obj_id; |
481 | } |
488 | } |
482 | 489 | ||
483 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
490 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
484 | continue; |
491 | continue; |
485 | 492 | ||
486 | for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); |
493 | for (j = 0; j < ((le16_to_cpu(path->usSize) - 8) / 2); |
487 | j++) { |
494 | j++) { |
488 | uint8_t enc_obj_id, enc_obj_num, enc_obj_type; |
495 | uint8_t enc_obj_id, enc_obj_num, enc_obj_type; |
489 | 496 | ||
490 | enc_obj_id = |
497 | enc_obj_id = |
491 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
498 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
492 | OBJECT_ID_MASK) >> OBJECT_ID_SHIFT; |
499 | OBJECT_ID_MASK) >> OBJECT_ID_SHIFT; |
493 | enc_obj_num = |
500 | enc_obj_num = |
494 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
501 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
495 | ENUM_ID_MASK) >> ENUM_ID_SHIFT; |
502 | ENUM_ID_MASK) >> ENUM_ID_SHIFT; |
496 | enc_obj_type = |
503 | enc_obj_type = |
497 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
504 | (le16_to_cpu(path->usGraphicObjIds[j]) & |
498 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
505 | OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; |
499 | 506 | ||
500 | /* FIXME: add support for router objects */ |
507 | /* FIXME: add support for router objects */ |
501 | if (enc_obj_type == GRAPH_OBJECT_TYPE_ENCODER) { |
508 | if (enc_obj_type == GRAPH_OBJECT_TYPE_ENCODER) { |
502 | if (enc_obj_num == 2) |
509 | if (enc_obj_num == 2) |
503 | linkb = true; |
510 | linkb = true; |
504 | else |
511 | else |
505 | linkb = false; |
512 | linkb = false; |
506 | 513 | ||
507 | radeon_add_atom_encoder(dev, |
514 | radeon_add_atom_encoder(dev, |
508 | enc_obj_id, |
515 | enc_obj_id, |
509 | le16_to_cpu |
516 | le16_to_cpu |
510 | (path-> |
517 | (path-> |
511 | usDeviceTag)); |
518 | usDeviceTag)); |
512 | 519 | ||
513 | } |
520 | } |
514 | } |
521 | } |
515 | 522 | ||
516 | /* look up gpio for ddc, hpd */ |
523 | /* look up gpio for ddc, hpd */ |
517 | if ((le16_to_cpu(path->usDeviceTag) & |
524 | if ((le16_to_cpu(path->usDeviceTag) & |
518 | (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) == 0) { |
525 | (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) == 0) { |
519 | for (j = 0; j < con_obj->ucNumberOfObjects; j++) { |
526 | for (j = 0; j < con_obj->ucNumberOfObjects; j++) { |
520 | if (le16_to_cpu(path->usConnObjectId) == |
527 | if (le16_to_cpu(path->usConnObjectId) == |
521 | le16_to_cpu(con_obj->asObjects[j]. |
528 | le16_to_cpu(con_obj->asObjects[j]. |
522 | usObjectID)) { |
529 | usObjectID)) { |
523 | ATOM_COMMON_RECORD_HEADER |
530 | ATOM_COMMON_RECORD_HEADER |
524 | *record = |
531 | *record = |
525 | (ATOM_COMMON_RECORD_HEADER |
532 | (ATOM_COMMON_RECORD_HEADER |
526 | *) |
533 | *) |
527 | (ctx->bios + data_offset + |
534 | (ctx->bios + data_offset + |
528 | le16_to_cpu(con_obj-> |
535 | le16_to_cpu(con_obj-> |
529 | asObjects[j]. |
536 | asObjects[j]. |
530 | usRecordOffset)); |
537 | usRecordOffset)); |
531 | ATOM_I2C_RECORD *i2c_record; |
538 | ATOM_I2C_RECORD *i2c_record; |
532 | ATOM_HPD_INT_RECORD *hpd_record; |
539 | ATOM_HPD_INT_RECORD *hpd_record; |
533 | ATOM_I2C_ID_CONFIG_ACCESS *i2c_config; |
540 | ATOM_I2C_ID_CONFIG_ACCESS *i2c_config; |
534 | hpd.hpd = RADEON_HPD_NONE; |
541 | hpd.hpd = RADEON_HPD_NONE; |
535 | 542 | ||
536 | while (record->ucRecordType > 0 |
543 | while (record->ucRecordType > 0 |
537 | && record-> |
544 | && record-> |
538 | ucRecordType <= |
545 | ucRecordType <= |
539 | ATOM_MAX_OBJECT_RECORD_NUMBER) { |
546 | ATOM_MAX_OBJECT_RECORD_NUMBER) { |
540 | switch (record->ucRecordType) { |
547 | switch (record->ucRecordType) { |
541 | case ATOM_I2C_RECORD_TYPE: |
548 | case ATOM_I2C_RECORD_TYPE: |
542 | i2c_record = |
549 | i2c_record = |
543 | (ATOM_I2C_RECORD *) |
550 | (ATOM_I2C_RECORD *) |
544 | record; |
551 | record; |
545 | i2c_config = |
552 | i2c_config = |
546 | (ATOM_I2C_ID_CONFIG_ACCESS *) |
553 | (ATOM_I2C_ID_CONFIG_ACCESS *) |
547 | &i2c_record->sucI2cId; |
554 | &i2c_record->sucI2cId; |
548 | ddc_bus = radeon_lookup_i2c_gpio(rdev, |
555 | ddc_bus = radeon_lookup_i2c_gpio(rdev, |
549 | i2c_config-> |
556 | i2c_config-> |
550 | ucAccess); |
557 | ucAccess); |
551 | break; |
558 | break; |
552 | case ATOM_HPD_INT_RECORD_TYPE: |
559 | case ATOM_HPD_INT_RECORD_TYPE: |
553 | hpd_record = |
560 | hpd_record = |
554 | (ATOM_HPD_INT_RECORD *) |
561 | (ATOM_HPD_INT_RECORD *) |
555 | record; |
562 | record; |
556 | gpio = radeon_lookup_gpio(rdev, |
563 | gpio = radeon_lookup_gpio(rdev, |
557 | hpd_record->ucHPDIntGPIOID); |
564 | hpd_record->ucHPDIntGPIOID); |
558 | hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); |
565 | hpd = radeon_atom_get_hpd_info_from_gpio(rdev, &gpio); |
559 | hpd.plugged_state = hpd_record->ucPlugged_PinState; |
566 | hpd.plugged_state = hpd_record->ucPlugged_PinState; |
560 | break; |
567 | break; |
561 | } |
568 | } |
562 | record = |
569 | record = |
563 | (ATOM_COMMON_RECORD_HEADER |
570 | (ATOM_COMMON_RECORD_HEADER |
564 | *) ((char *)record |
571 | *) ((char *)record |
565 | + |
572 | + |
566 | record-> |
573 | record-> |
567 | ucRecordSize); |
574 | ucRecordSize); |
568 | } |
575 | } |
569 | break; |
576 | break; |
570 | } |
577 | } |
571 | } |
578 | } |
572 | } else { |
579 | } else { |
573 | hpd.hpd = RADEON_HPD_NONE; |
580 | hpd.hpd = RADEON_HPD_NONE; |
574 | ddc_bus.valid = false; |
581 | ddc_bus.valid = false; |
575 | } |
582 | } |
- | 583 | ||
- | 584 | /* needed for aux chan transactions */ |
|
- | 585 | ddc_bus.hpd_id = hpd.hpd ? (hpd.hpd - 1) : 0; |
|
576 | 586 | ||
577 | conn_id = le16_to_cpu(path->usConnObjectId); |
587 | conn_id = le16_to_cpu(path->usConnObjectId); |
578 | 588 | ||
579 | if (!radeon_atom_apply_quirks |
589 | if (!radeon_atom_apply_quirks |
580 | (dev, le16_to_cpu(path->usDeviceTag), &connector_type, |
590 | (dev, le16_to_cpu(path->usDeviceTag), &connector_type, |
581 | &ddc_bus, &conn_id, &hpd)) |
591 | &ddc_bus, &conn_id, &hpd)) |
582 | continue; |
592 | continue; |
583 | 593 | ||
584 | radeon_add_atom_connector(dev, |
594 | radeon_add_atom_connector(dev, |
585 | conn_id, |
595 | conn_id, |
586 | le16_to_cpu(path-> |
596 | le16_to_cpu(path-> |
587 | usDeviceTag), |
597 | usDeviceTag), |
588 | connector_type, &ddc_bus, |
598 | connector_type, &ddc_bus, |
589 | linkb, igp_lane_info, |
599 | linkb, igp_lane_info, |
590 | connector_object_id, |
600 | connector_object_id, |
591 | &hpd); |
601 | &hpd); |
592 | 602 | ||
593 | } |
603 | } |
594 | } |
604 | } |
595 | 605 | ||
596 | radeon_link_encoder_connector(dev); |
606 | radeon_link_encoder_connector(dev); |
597 | 607 | ||
598 | return true; |
608 | return true; |
599 | } |
609 | } |
600 | 610 | ||
601 | static uint16_t atombios_get_connector_object_id(struct drm_device *dev, |
611 | static uint16_t atombios_get_connector_object_id(struct drm_device *dev, |
602 | int connector_type, |
612 | int connector_type, |
603 | uint16_t devices) |
613 | uint16_t devices) |
604 | { |
614 | { |
605 | struct radeon_device *rdev = dev->dev_private; |
615 | struct radeon_device *rdev = dev->dev_private; |
606 | 616 | ||
607 | if (rdev->flags & RADEON_IS_IGP) { |
617 | if (rdev->flags & RADEON_IS_IGP) { |
608 | return supported_devices_connector_object_id_convert |
618 | return supported_devices_connector_object_id_convert |
609 | [connector_type]; |
619 | [connector_type]; |
610 | } else if (((connector_type == DRM_MODE_CONNECTOR_DVII) || |
620 | } else if (((connector_type == DRM_MODE_CONNECTOR_DVII) || |
611 | (connector_type == DRM_MODE_CONNECTOR_DVID)) && |
621 | (connector_type == DRM_MODE_CONNECTOR_DVID)) && |
612 | (devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
622 | (devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
613 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
623 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
614 | struct atom_context *ctx = mode_info->atom_context; |
624 | struct atom_context *ctx = mode_info->atom_context; |
615 | int index = GetIndexIntoMasterTable(DATA, XTMDS_Info); |
625 | int index = GetIndexIntoMasterTable(DATA, XTMDS_Info); |
616 | uint16_t size, data_offset; |
626 | uint16_t size, data_offset; |
617 | uint8_t frev, crev; |
627 | uint8_t frev, crev; |
618 | ATOM_XTMDS_INFO *xtmds; |
628 | ATOM_XTMDS_INFO *xtmds; |
619 | 629 | ||
620 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
630 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
621 | xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset); |
631 | xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset); |
622 | 632 | ||
623 | if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) { |
633 | if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) { |
624 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
634 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
625 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; |
635 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; |
626 | else |
636 | else |
627 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; |
637 | return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; |
628 | } else { |
638 | } else { |
629 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
639 | if (connector_type == DRM_MODE_CONNECTOR_DVII) |
630 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
640 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; |
631 | else |
641 | else |
632 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; |
642 | return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; |
633 | } |
643 | } |
634 | } else { |
644 | } else { |
635 | return supported_devices_connector_object_id_convert |
645 | return supported_devices_connector_object_id_convert |
636 | [connector_type]; |
646 | [connector_type]; |
637 | } |
647 | } |
638 | } |
648 | } |
639 | 649 | ||
640 | struct bios_connector { |
650 | struct bios_connector { |
641 | bool valid; |
651 | bool valid; |
642 | uint16_t line_mux; |
652 | uint16_t line_mux; |
643 | uint16_t devices; |
653 | uint16_t devices; |
644 | int connector_type; |
654 | int connector_type; |
645 | struct radeon_i2c_bus_rec ddc_bus; |
655 | struct radeon_i2c_bus_rec ddc_bus; |
646 | struct radeon_hpd hpd; |
656 | struct radeon_hpd hpd; |
647 | }; |
657 | }; |
648 | 658 | ||
649 | bool radeon_get_atom_connector_info_from_supported_devices_table(struct |
659 | bool radeon_get_atom_connector_info_from_supported_devices_table(struct |
650 | drm_device |
660 | drm_device |
651 | *dev) |
661 | *dev) |
652 | { |
662 | { |
653 | struct radeon_device *rdev = dev->dev_private; |
663 | struct radeon_device *rdev = dev->dev_private; |
654 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
664 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
655 | struct atom_context *ctx = mode_info->atom_context; |
665 | struct atom_context *ctx = mode_info->atom_context; |
656 | int index = GetIndexIntoMasterTable(DATA, SupportedDevicesInfo); |
666 | int index = GetIndexIntoMasterTable(DATA, SupportedDevicesInfo); |
657 | uint16_t size, data_offset; |
667 | uint16_t size, data_offset; |
658 | uint8_t frev, crev; |
668 | uint8_t frev, crev; |
659 | uint16_t device_support; |
669 | uint16_t device_support; |
660 | uint8_t dac; |
670 | uint8_t dac; |
661 | union atom_supported_devices *supported_devices; |
671 | union atom_supported_devices *supported_devices; |
662 | int i, j, max_device; |
672 | int i, j, max_device; |
663 | struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE]; |
673 | struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE]; |
664 | 674 | ||
665 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
675 | atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); |
666 | 676 | ||
667 | supported_devices = |
677 | supported_devices = |
668 | (union atom_supported_devices *)(ctx->bios + data_offset); |
678 | (union atom_supported_devices *)(ctx->bios + data_offset); |
669 | 679 | ||
670 | device_support = le16_to_cpu(supported_devices->info.usDeviceSupport); |
680 | device_support = le16_to_cpu(supported_devices->info.usDeviceSupport); |
671 | 681 | ||
672 | if (frev > 1) |
682 | if (frev > 1) |
673 | max_device = ATOM_MAX_SUPPORTED_DEVICE; |
683 | max_device = ATOM_MAX_SUPPORTED_DEVICE; |
674 | else |
684 | else |
675 | max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO; |
685 | max_device = ATOM_MAX_SUPPORTED_DEVICE_INFO; |
676 | 686 | ||
677 | for (i = 0; i < max_device; i++) { |
687 | for (i = 0; i < max_device; i++) { |
678 | ATOM_CONNECTOR_INFO_I2C ci = |
688 | ATOM_CONNECTOR_INFO_I2C ci = |
679 | supported_devices->info.asConnInfo[i]; |
689 | supported_devices->info.asConnInfo[i]; |
680 | 690 | ||
681 | bios_connectors[i].valid = false; |
691 | bios_connectors[i].valid = false; |
682 | 692 | ||
683 | if (!(device_support & (1 << i))) { |
693 | if (!(device_support & (1 << i))) { |
684 | continue; |
694 | continue; |
685 | } |
695 | } |
686 | 696 | ||
687 | if (i == ATOM_DEVICE_CV_INDEX) { |
697 | if (i == ATOM_DEVICE_CV_INDEX) { |
688 | DRM_DEBUG("Skipping Component Video\n"); |
698 | DRM_DEBUG("Skipping Component Video\n"); |
689 | continue; |
699 | continue; |
690 | } |
700 | } |
691 | 701 | ||
692 | bios_connectors[i].connector_type = |
702 | bios_connectors[i].connector_type = |
693 | supported_devices_connector_convert[ci.sucConnectorInfo. |
703 | supported_devices_connector_convert[ci.sucConnectorInfo. |
694 | sbfAccess. |
704 | sbfAccess. |
695 | bfConnectorType]; |
705 | bfConnectorType]; |
696 | 706 | ||
697 | if (bios_connectors[i].connector_type == |
707 | if (bios_connectors[i].connector_type == |
698 | DRM_MODE_CONNECTOR_Unknown) |
708 | DRM_MODE_CONNECTOR_Unknown) |
699 | continue; |
709 | continue; |
700 | 710 | ||
701 | dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC; |
711 | dac = ci.sucConnectorInfo.sbfAccess.bfAssociatedDAC; |
702 | 712 | ||
703 | bios_connectors[i].line_mux = |
713 | bios_connectors[i].line_mux = |
704 | ci.sucI2cId.ucAccess; |
714 | ci.sucI2cId.ucAccess; |
705 | 715 | ||
706 | /* give tv unique connector ids */ |
716 | /* give tv unique connector ids */ |
707 | if (i == ATOM_DEVICE_TV1_INDEX) { |
717 | if (i == ATOM_DEVICE_TV1_INDEX) { |
708 | bios_connectors[i].ddc_bus.valid = false; |
718 | bios_connectors[i].ddc_bus.valid = false; |
709 | bios_connectors[i].line_mux = 50; |
719 | bios_connectors[i].line_mux = 50; |
710 | } else if (i == ATOM_DEVICE_TV2_INDEX) { |
720 | } else if (i == ATOM_DEVICE_TV2_INDEX) { |
711 | bios_connectors[i].ddc_bus.valid = false; |
721 | bios_connectors[i].ddc_bus.valid = false; |
712 | bios_connectors[i].line_mux = 51; |
722 | bios_connectors[i].line_mux = 51; |
713 | } else if (i == ATOM_DEVICE_CV_INDEX) { |
723 | } else if (i == ATOM_DEVICE_CV_INDEX) { |
714 | bios_connectors[i].ddc_bus.valid = false; |
724 | bios_connectors[i].ddc_bus.valid = false; |
715 | bios_connectors[i].line_mux = 52; |
725 | bios_connectors[i].line_mux = 52; |
716 | } else |
726 | } else |
717 | bios_connectors[i].ddc_bus = |
727 | bios_connectors[i].ddc_bus = |
718 | radeon_lookup_i2c_gpio(rdev, |
728 | radeon_lookup_i2c_gpio(rdev, |
719 | bios_connectors[i].line_mux); |
729 | bios_connectors[i].line_mux); |
720 | 730 | ||
721 | if ((crev > 1) && (frev > 1)) { |
731 | if ((crev > 1) && (frev > 1)) { |
722 | u8 isb = supported_devices->info_2d1.asIntSrcInfo[i].ucIntSrcBitmap; |
732 | u8 isb = supported_devices->info_2d1.asIntSrcInfo[i].ucIntSrcBitmap; |
723 | switch (isb) { |
733 | switch (isb) { |
724 | case 0x4: |
734 | case 0x4: |
725 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
735 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
726 | break; |
736 | break; |
727 | case 0xa: |
737 | case 0xa: |
728 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
738 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
729 | break; |
739 | break; |
730 | default: |
740 | default: |
731 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
741 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
732 | break; |
742 | break; |
733 | } |
743 | } |
734 | } else { |
744 | } else { |
735 | if (i == ATOM_DEVICE_DFP1_INDEX) |
745 | if (i == ATOM_DEVICE_DFP1_INDEX) |
736 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
746 | bios_connectors[i].hpd.hpd = RADEON_HPD_1; |
737 | else if (i == ATOM_DEVICE_DFP2_INDEX) |
747 | else if (i == ATOM_DEVICE_DFP2_INDEX) |
738 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
748 | bios_connectors[i].hpd.hpd = RADEON_HPD_2; |
739 | else |
749 | else |
740 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
750 | bios_connectors[i].hpd.hpd = RADEON_HPD_NONE; |
741 | } |
751 | } |
742 | 752 | ||
743 | /* Always set the connector type to VGA for CRT1/CRT2. if they are |
753 | /* Always set the connector type to VGA for CRT1/CRT2. if they are |
744 | * shared with a DVI port, we'll pick up the DVI connector when we |
754 | * shared with a DVI port, we'll pick up the DVI connector when we |
745 | * merge the outputs. Some bioses incorrectly list VGA ports as DVI. |
755 | * merge the outputs. Some bioses incorrectly list VGA ports as DVI. |
746 | */ |
756 | */ |
747 | if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX) |
757 | if (i == ATOM_DEVICE_CRT1_INDEX || i == ATOM_DEVICE_CRT2_INDEX) |
748 | bios_connectors[i].connector_type = |
758 | bios_connectors[i].connector_type = |
749 | DRM_MODE_CONNECTOR_VGA; |
759 | DRM_MODE_CONNECTOR_VGA; |
750 | 760 | ||
751 | if (!radeon_atom_apply_quirks |
761 | if (!radeon_atom_apply_quirks |
752 | (dev, (1 << i), &bios_connectors[i].connector_type, |
762 | (dev, (1 << i), &bios_connectors[i].connector_type, |
753 | &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux, |
763 | &bios_connectors[i].ddc_bus, &bios_connectors[i].line_mux, |
754 | &bios_connectors[i].hpd)) |
764 | &bios_connectors[i].hpd)) |
755 | continue; |
765 | continue; |
756 | 766 | ||
757 | bios_connectors[i].valid = true; |
767 | bios_connectors[i].valid = true; |
758 | bios_connectors[i].devices = (1 << i); |
768 | bios_connectors[i].devices = (1 << i); |
759 | 769 | ||
760 | if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) |
770 | if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) |
761 | radeon_add_atom_encoder(dev, |
771 | radeon_add_atom_encoder(dev, |
762 | radeon_get_encoder_id(dev, |
772 | radeon_get_encoder_id(dev, |
763 | (1 << i), |
773 | (1 << i), |
764 | dac), |
774 | dac), |
765 | (1 << i)); |
775 | (1 << i)); |
766 | else |
776 | else |
767 | radeon_add_legacy_encoder(dev, |
777 | radeon_add_legacy_encoder(dev, |
768 | radeon_get_encoder_id(dev, |
778 | radeon_get_encoder_id(dev, |
769 | (1 << i), |
779 | (1 << i), |
770 | dac), |
780 | dac), |
771 | (1 << i)); |
781 | (1 << i)); |
772 | } |
782 | } |
773 | 783 | ||
774 | /* combine shared connectors */ |
784 | /* combine shared connectors */ |
775 | for (i = 0; i < max_device; i++) { |
785 | for (i = 0; i < max_device; i++) { |
776 | if (bios_connectors[i].valid) { |
786 | if (bios_connectors[i].valid) { |
777 | for (j = 0; j < max_device; j++) { |
787 | for (j = 0; j < max_device; j++) { |
778 | if (bios_connectors[j].valid && (i != j)) { |
788 | if (bios_connectors[j].valid && (i != j)) { |
779 | if (bios_connectors[i].line_mux == |
789 | if (bios_connectors[i].line_mux == |
780 | bios_connectors[j].line_mux) { |
790 | bios_connectors[j].line_mux) { |
781 | /* make sure not to combine LVDS */ |
791 | /* make sure not to combine LVDS */ |
782 | if (bios_connectors[i].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
792 | if (bios_connectors[i].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
783 | bios_connectors[i].line_mux = 53; |
793 | bios_connectors[i].line_mux = 53; |
784 | bios_connectors[i].ddc_bus.valid = false; |
794 | bios_connectors[i].ddc_bus.valid = false; |
785 | continue; |
795 | continue; |
786 | } |
796 | } |
787 | if (bios_connectors[j].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
797 | if (bios_connectors[j].devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
788 | bios_connectors[j].line_mux = 53; |
798 | bios_connectors[j].line_mux = 53; |
789 | bios_connectors[j].ddc_bus.valid = false; |
799 | bios_connectors[j].ddc_bus.valid = false; |
790 | continue; |
800 | continue; |
791 | } |
801 | } |
792 | /* combine analog and digital for DVI-I */ |
802 | /* combine analog and digital for DVI-I */ |
793 | if (((bios_connectors[i].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
803 | if (((bios_connectors[i].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
794 | (bios_connectors[j].devices & (ATOM_DEVICE_CRT_SUPPORT))) || |
804 | (bios_connectors[j].devices & (ATOM_DEVICE_CRT_SUPPORT))) || |
795 | ((bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
805 | ((bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) && |
796 | (bios_connectors[i].devices & (ATOM_DEVICE_CRT_SUPPORT)))) { |
806 | (bios_connectors[i].devices & (ATOM_DEVICE_CRT_SUPPORT)))) { |
797 | bios_connectors[i].devices |= |
807 | bios_connectors[i].devices |= |
798 | bios_connectors[j].devices; |
808 | bios_connectors[j].devices; |
799 | bios_connectors[i].connector_type = |
809 | bios_connectors[i].connector_type = |
800 | DRM_MODE_CONNECTOR_DVII; |
810 | DRM_MODE_CONNECTOR_DVII; |
801 | if (bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) |
811 | if (bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) |
802 | bios_connectors[i].hpd = |
812 | bios_connectors[i].hpd = |
803 | bios_connectors[j].hpd; |
813 | bios_connectors[j].hpd; |
804 | bios_connectors[j].valid = false; |
814 | bios_connectors[j].valid = false; |
805 | } |
815 | } |
806 | } |
816 | } |
807 | } |
817 | } |
808 | } |
818 | } |
809 | } |
819 | } |
810 | } |
820 | } |
811 | 821 | ||
812 | /* add the connectors */ |
822 | /* add the connectors */ |
813 | for (i = 0; i < max_device; i++) { |
823 | for (i = 0; i < max_device; i++) { |
814 | if (bios_connectors[i].valid) { |
824 | if (bios_connectors[i].valid) { |
815 | uint16_t connector_object_id = |
825 | uint16_t connector_object_id = |
816 | atombios_get_connector_object_id(dev, |
826 | atombios_get_connector_object_id(dev, |
817 | bios_connectors[i].connector_type, |
827 | bios_connectors[i].connector_type, |
818 | bios_connectors[i].devices); |
828 | bios_connectors[i].devices); |
819 | radeon_add_atom_connector(dev, |
829 | radeon_add_atom_connector(dev, |
820 | bios_connectors[i].line_mux, |
830 | bios_connectors[i].line_mux, |
821 | bios_connectors[i].devices, |
831 | bios_connectors[i].devices, |
822 | bios_connectors[i]. |
832 | bios_connectors[i]. |
823 | connector_type, |
833 | connector_type, |
824 | &bios_connectors[i].ddc_bus, |
834 | &bios_connectors[i].ddc_bus, |
825 | false, 0, |
835 | false, 0, |
826 | connector_object_id, |
836 | connector_object_id, |
827 | &bios_connectors[i].hpd); |
837 | &bios_connectors[i].hpd); |
828 | } |
838 | } |
829 | } |
839 | } |
830 | 840 | ||
831 | radeon_link_encoder_connector(dev); |
841 | radeon_link_encoder_connector(dev); |
832 | 842 | ||
833 | return true; |
843 | return true; |
834 | } |
844 | } |
835 | 845 | ||
836 | union firmware_info { |
846 | union firmware_info { |
837 | ATOM_FIRMWARE_INFO info; |
847 | ATOM_FIRMWARE_INFO info; |
838 | ATOM_FIRMWARE_INFO_V1_2 info_12; |
848 | ATOM_FIRMWARE_INFO_V1_2 info_12; |
839 | ATOM_FIRMWARE_INFO_V1_3 info_13; |
849 | ATOM_FIRMWARE_INFO_V1_3 info_13; |
840 | ATOM_FIRMWARE_INFO_V1_4 info_14; |
850 | ATOM_FIRMWARE_INFO_V1_4 info_14; |
- | 851 | ATOM_FIRMWARE_INFO_V2_1 info_21; |
|
841 | }; |
852 | }; |
842 | 853 | ||
843 | bool radeon_atom_get_clock_info(struct drm_device *dev) |
854 | bool radeon_atom_get_clock_info(struct drm_device *dev) |
844 | { |
855 | { |
845 | struct radeon_device *rdev = dev->dev_private; |
856 | struct radeon_device *rdev = dev->dev_private; |
846 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
857 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
847 | int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); |
858 | int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); |
848 | union firmware_info *firmware_info; |
859 | union firmware_info *firmware_info; |
849 | uint8_t frev, crev; |
860 | uint8_t frev, crev; |
850 | struct radeon_pll *p1pll = &rdev->clock.p1pll; |
861 | struct radeon_pll *p1pll = &rdev->clock.p1pll; |
851 | struct radeon_pll *p2pll = &rdev->clock.p2pll; |
862 | struct radeon_pll *p2pll = &rdev->clock.p2pll; |
- | 863 | struct radeon_pll *dcpll = &rdev->clock.dcpll; |
|
852 | struct radeon_pll *spll = &rdev->clock.spll; |
864 | struct radeon_pll *spll = &rdev->clock.spll; |
853 | struct radeon_pll *mpll = &rdev->clock.mpll; |
865 | struct radeon_pll *mpll = &rdev->clock.mpll; |
854 | uint16_t data_offset; |
866 | uint16_t data_offset; |
855 | 867 | ||
856 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
868 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
857 | &crev, &data_offset); |
869 | &crev, &data_offset); |
858 | 870 | ||
859 | firmware_info = |
871 | firmware_info = |
860 | (union firmware_info *)(mode_info->atom_context->bios + |
872 | (union firmware_info *)(mode_info->atom_context->bios + |
861 | data_offset); |
873 | data_offset); |
862 | 874 | ||
863 | if (firmware_info) { |
875 | if (firmware_info) { |
864 | /* pixel clocks */ |
876 | /* pixel clocks */ |
865 | p1pll->reference_freq = |
877 | p1pll->reference_freq = |
866 | le16_to_cpu(firmware_info->info.usReferenceClock); |
878 | le16_to_cpu(firmware_info->info.usReferenceClock); |
867 | p1pll->reference_div = 0; |
879 | p1pll->reference_div = 0; |
868 | 880 | ||
869 | if (crev < 2) |
881 | if (crev < 2) |
870 | p1pll->pll_out_min = |
882 | p1pll->pll_out_min = |
871 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); |
883 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Output); |
872 | else |
884 | else |
873 | p1pll->pll_out_min = |
885 | p1pll->pll_out_min = |
874 | le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); |
886 | le32_to_cpu(firmware_info->info_12.ulMinPixelClockPLL_Output); |
875 | p1pll->pll_out_max = |
887 | p1pll->pll_out_max = |
876 | le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); |
888 | le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); |
877 | 889 | ||
878 | if (p1pll->pll_out_min == 0) { |
890 | if (p1pll->pll_out_min == 0) { |
879 | if (ASIC_IS_AVIVO(rdev)) |
891 | if (ASIC_IS_AVIVO(rdev)) |
880 | p1pll->pll_out_min = 64800; |
892 | p1pll->pll_out_min = 64800; |
881 | else |
893 | else |
882 | p1pll->pll_out_min = 20000; |
894 | p1pll->pll_out_min = 20000; |
883 | } else if (p1pll->pll_out_min > 64800) { |
895 | } else if (p1pll->pll_out_min > 64800) { |
884 | /* Limiting the pll output range is a good thing generally as |
896 | /* Limiting the pll output range is a good thing generally as |
885 | * it limits the number of possible pll combinations for a given |
897 | * it limits the number of possible pll combinations for a given |
886 | * frequency presumably to the ones that work best on each card. |
898 | * frequency presumably to the ones that work best on each card. |
887 | * However, certain duallink DVI monitors seem to like |
899 | * However, certain duallink DVI monitors seem to like |
888 | * pll combinations that would be limited by this at least on |
900 | * pll combinations that would be limited by this at least on |
889 | * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per |
901 | * pre-DCE 3.0 r6xx hardware. This might need to be adjusted per |
890 | * family. |
902 | * family. |
891 | */ |
903 | */ |
892 | if (!radeon_new_pll) |
904 | if (!radeon_new_pll) |
893 | p1pll->pll_out_min = 64800; |
905 | p1pll->pll_out_min = 64800; |
894 | } |
906 | } |
895 | 907 | ||
896 | p1pll->pll_in_min = |
908 | p1pll->pll_in_min = |
897 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); |
909 | le16_to_cpu(firmware_info->info.usMinPixelClockPLL_Input); |
898 | p1pll->pll_in_max = |
910 | p1pll->pll_in_max = |
899 | le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); |
911 | le16_to_cpu(firmware_info->info.usMaxPixelClockPLL_Input); |
900 | 912 | ||
901 | *p2pll = *p1pll; |
913 | *p2pll = *p1pll; |
902 | 914 | ||
903 | /* system clock */ |
915 | /* system clock */ |
904 | spll->reference_freq = |
916 | spll->reference_freq = |
905 | le16_to_cpu(firmware_info->info.usReferenceClock); |
917 | le16_to_cpu(firmware_info->info.usReferenceClock); |
906 | spll->reference_div = 0; |
918 | spll->reference_div = 0; |
907 | 919 | ||
908 | spll->pll_out_min = |
920 | spll->pll_out_min = |
909 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); |
921 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Output); |
910 | spll->pll_out_max = |
922 | spll->pll_out_max = |
911 | le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); |
923 | le32_to_cpu(firmware_info->info.ulMaxEngineClockPLL_Output); |
912 | 924 | ||
913 | /* ??? */ |
925 | /* ??? */ |
914 | if (spll->pll_out_min == 0) { |
926 | if (spll->pll_out_min == 0) { |
915 | if (ASIC_IS_AVIVO(rdev)) |
927 | if (ASIC_IS_AVIVO(rdev)) |
916 | spll->pll_out_min = 64800; |
928 | spll->pll_out_min = 64800; |
917 | else |
929 | else |
918 | spll->pll_out_min = 20000; |
930 | spll->pll_out_min = 20000; |
919 | } |
931 | } |
920 | 932 | ||
921 | spll->pll_in_min = |
933 | spll->pll_in_min = |
922 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); |
934 | le16_to_cpu(firmware_info->info.usMinEngineClockPLL_Input); |
923 | spll->pll_in_max = |
935 | spll->pll_in_max = |
924 | le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); |
936 | le16_to_cpu(firmware_info->info.usMaxEngineClockPLL_Input); |
925 | 937 | ||
926 | /* memory clock */ |
938 | /* memory clock */ |
927 | mpll->reference_freq = |
939 | mpll->reference_freq = |
928 | le16_to_cpu(firmware_info->info.usReferenceClock); |
940 | le16_to_cpu(firmware_info->info.usReferenceClock); |
929 | mpll->reference_div = 0; |
941 | mpll->reference_div = 0; |
930 | 942 | ||
931 | mpll->pll_out_min = |
943 | mpll->pll_out_min = |
932 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); |
944 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Output); |
933 | mpll->pll_out_max = |
945 | mpll->pll_out_max = |
934 | le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); |
946 | le32_to_cpu(firmware_info->info.ulMaxMemoryClockPLL_Output); |
935 | 947 | ||
936 | /* ??? */ |
948 | /* ??? */ |
937 | if (mpll->pll_out_min == 0) { |
949 | if (mpll->pll_out_min == 0) { |
938 | if (ASIC_IS_AVIVO(rdev)) |
950 | if (ASIC_IS_AVIVO(rdev)) |
939 | mpll->pll_out_min = 64800; |
951 | mpll->pll_out_min = 64800; |
940 | else |
952 | else |
941 | mpll->pll_out_min = 20000; |
953 | mpll->pll_out_min = 20000; |
942 | } |
954 | } |
943 | 955 | ||
944 | mpll->pll_in_min = |
956 | mpll->pll_in_min = |
945 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); |
957 | le16_to_cpu(firmware_info->info.usMinMemoryClockPLL_Input); |
946 | mpll->pll_in_max = |
958 | mpll->pll_in_max = |
947 | le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); |
959 | le16_to_cpu(firmware_info->info.usMaxMemoryClockPLL_Input); |
948 | 960 | ||
949 | rdev->clock.default_sclk = |
961 | rdev->clock.default_sclk = |
950 | le32_to_cpu(firmware_info->info.ulDefaultEngineClock); |
962 | le32_to_cpu(firmware_info->info.ulDefaultEngineClock); |
951 | rdev->clock.default_mclk = |
963 | rdev->clock.default_mclk = |
952 | le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); |
964 | le32_to_cpu(firmware_info->info.ulDefaultMemoryClock); |
- | 965 | ||
- | 966 | if (ASIC_IS_DCE4(rdev)) { |
|
- | 967 | rdev->clock.default_dispclk = |
|
- | 968 | le32_to_cpu(firmware_info->info_21.ulDefaultDispEngineClkFreq); |
|
- | 969 | if (rdev->clock.default_dispclk == 0) |
|
- | 970 | rdev->clock.default_dispclk = 60000; /* 600 Mhz */ |
|
- | 971 | rdev->clock.dp_extclk = |
|
- | 972 | le16_to_cpu(firmware_info->info_21.usUniphyDPModeExtClkFreq); |
|
- | 973 | } |
|
- | 974 | *dcpll = *p1pll; |
|
953 | 975 | ||
954 | return true; |
976 | return true; |
- | 977 | } |
|
955 | } |
978 | |
956 | return false; |
979 | return false; |
957 | } |
980 | } |
958 | 981 | ||
959 | union igp_info { |
982 | union igp_info { |
960 | struct _ATOM_INTEGRATED_SYSTEM_INFO info; |
983 | struct _ATOM_INTEGRATED_SYSTEM_INFO info; |
961 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2; |
984 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2; |
962 | }; |
985 | }; |
963 | 986 | ||
964 | bool radeon_atombios_sideport_present(struct radeon_device *rdev) |
987 | bool radeon_atombios_sideport_present(struct radeon_device *rdev) |
965 | { |
988 | { |
966 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
989 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
967 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); |
990 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); |
968 | union igp_info *igp_info; |
991 | union igp_info *igp_info; |
969 | u8 frev, crev; |
992 | u8 frev, crev; |
970 | u16 data_offset; |
993 | u16 data_offset; |
971 | 994 | ||
972 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
995 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
973 | &crev, &data_offset); |
996 | &crev, &data_offset); |
974 | 997 | ||
975 | igp_info = (union igp_info *)(mode_info->atom_context->bios + |
998 | igp_info = (union igp_info *)(mode_info->atom_context->bios + |
976 | data_offset); |
999 | data_offset); |
977 | 1000 | ||
978 | if (igp_info) { |
1001 | if (igp_info) { |
979 | switch (crev) { |
1002 | switch (crev) { |
980 | case 1: |
1003 | case 1: |
981 | if (igp_info->info.ucMemoryType & 0xf0) |
1004 | if (igp_info->info.ucMemoryType & 0xf0) |
982 | return true; |
1005 | return true; |
983 | break; |
1006 | break; |
984 | case 2: |
1007 | case 2: |
985 | if (igp_info->info_2.ucMemoryType & 0x0f) |
1008 | if (igp_info->info_2.ucMemoryType & 0x0f) |
986 | return true; |
1009 | return true; |
987 | break; |
1010 | break; |
988 | default: |
1011 | default: |
989 | DRM_ERROR("Unsupported IGP table: %d %d\n", frev, crev); |
1012 | DRM_ERROR("Unsupported IGP table: %d %d\n", frev, crev); |
990 | break; |
1013 | break; |
991 | } |
1014 | } |
992 | } |
1015 | } |
993 | return false; |
1016 | return false; |
994 | } |
1017 | } |
995 | 1018 | ||
996 | bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder, |
1019 | bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder, |
997 | struct radeon_encoder_int_tmds *tmds) |
1020 | struct radeon_encoder_int_tmds *tmds) |
998 | { |
1021 | { |
999 | struct drm_device *dev = encoder->base.dev; |
1022 | struct drm_device *dev = encoder->base.dev; |
1000 | struct radeon_device *rdev = dev->dev_private; |
1023 | struct radeon_device *rdev = dev->dev_private; |
1001 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1024 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1002 | int index = GetIndexIntoMasterTable(DATA, TMDS_Info); |
1025 | int index = GetIndexIntoMasterTable(DATA, TMDS_Info); |
1003 | uint16_t data_offset; |
1026 | uint16_t data_offset; |
1004 | struct _ATOM_TMDS_INFO *tmds_info; |
1027 | struct _ATOM_TMDS_INFO *tmds_info; |
1005 | uint8_t frev, crev; |
1028 | uint8_t frev, crev; |
1006 | uint16_t maxfreq; |
1029 | uint16_t maxfreq; |
1007 | int i; |
1030 | int i; |
1008 | 1031 | ||
1009 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1032 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1010 | &crev, &data_offset); |
1033 | &crev, &data_offset); |
1011 | 1034 | ||
1012 | tmds_info = |
1035 | tmds_info = |
1013 | (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios + |
1036 | (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios + |
1014 | data_offset); |
1037 | data_offset); |
1015 | 1038 | ||
1016 | if (tmds_info) { |
1039 | if (tmds_info) { |
1017 | maxfreq = le16_to_cpu(tmds_info->usMaxFrequency); |
1040 | maxfreq = le16_to_cpu(tmds_info->usMaxFrequency); |
1018 | for (i = 0; i < 4; i++) { |
1041 | for (i = 0; i < 4; i++) { |
1019 | tmds->tmds_pll[i].freq = |
1042 | tmds->tmds_pll[i].freq = |
1020 | le16_to_cpu(tmds_info->asMiscInfo[i].usFrequency); |
1043 | le16_to_cpu(tmds_info->asMiscInfo[i].usFrequency); |
1021 | tmds->tmds_pll[i].value = |
1044 | tmds->tmds_pll[i].value = |
1022 | tmds_info->asMiscInfo[i].ucPLL_ChargePump & 0x3f; |
1045 | tmds_info->asMiscInfo[i].ucPLL_ChargePump & 0x3f; |
1023 | tmds->tmds_pll[i].value |= |
1046 | tmds->tmds_pll[i].value |= |
1024 | (tmds_info->asMiscInfo[i]. |
1047 | (tmds_info->asMiscInfo[i]. |
1025 | ucPLL_VCO_Gain & 0x3f) << 6; |
1048 | ucPLL_VCO_Gain & 0x3f) << 6; |
1026 | tmds->tmds_pll[i].value |= |
1049 | tmds->tmds_pll[i].value |= |
1027 | (tmds_info->asMiscInfo[i]. |
1050 | (tmds_info->asMiscInfo[i]. |
1028 | ucPLL_DutyCycle & 0xf) << 12; |
1051 | ucPLL_DutyCycle & 0xf) << 12; |
1029 | tmds->tmds_pll[i].value |= |
1052 | tmds->tmds_pll[i].value |= |
1030 | (tmds_info->asMiscInfo[i]. |
1053 | (tmds_info->asMiscInfo[i]. |
1031 | ucPLL_VoltageSwing & 0xf) << 16; |
1054 | ucPLL_VoltageSwing & 0xf) << 16; |
1032 | 1055 | ||
1033 | DRM_DEBUG("TMDS PLL From ATOMBIOS %u %x\n", |
1056 | DRM_DEBUG("TMDS PLL From ATOMBIOS %u %x\n", |
1034 | tmds->tmds_pll[i].freq, |
1057 | tmds->tmds_pll[i].freq, |
1035 | tmds->tmds_pll[i].value); |
1058 | tmds->tmds_pll[i].value); |
1036 | 1059 | ||
1037 | if (maxfreq == tmds->tmds_pll[i].freq) { |
1060 | if (maxfreq == tmds->tmds_pll[i].freq) { |
1038 | tmds->tmds_pll[i].freq = 0xffffffff; |
1061 | tmds->tmds_pll[i].freq = 0xffffffff; |
1039 | break; |
1062 | break; |
1040 | } |
1063 | } |
1041 | } |
1064 | } |
1042 | return true; |
1065 | return true; |
1043 | } |
1066 | } |
1044 | return false; |
1067 | return false; |
1045 | } |
1068 | } |
1046 | 1069 | ||
1047 | static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct |
1070 | static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct |
1048 | radeon_encoder |
1071 | radeon_encoder |
1049 | *encoder, |
1072 | *encoder, |
1050 | int id) |
1073 | int id) |
1051 | { |
1074 | { |
1052 | struct drm_device *dev = encoder->base.dev; |
1075 | struct drm_device *dev = encoder->base.dev; |
1053 | struct radeon_device *rdev = dev->dev_private; |
1076 | struct radeon_device *rdev = dev->dev_private; |
1054 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1077 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1055 | int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info); |
1078 | int index = GetIndexIntoMasterTable(DATA, PPLL_SS_Info); |
1056 | uint16_t data_offset; |
1079 | uint16_t data_offset; |
1057 | struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info; |
1080 | struct _ATOM_SPREAD_SPECTRUM_INFO *ss_info; |
1058 | uint8_t frev, crev; |
1081 | uint8_t frev, crev; |
1059 | struct radeon_atom_ss *ss = NULL; |
1082 | struct radeon_atom_ss *ss = NULL; |
1060 | int i; |
1083 | int i; |
1061 | 1084 | ||
1062 | if (id > ATOM_MAX_SS_ENTRY) |
1085 | if (id > ATOM_MAX_SS_ENTRY) |
1063 | return NULL; |
1086 | return NULL; |
1064 | 1087 | ||
1065 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1088 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1066 | &crev, &data_offset); |
1089 | &crev, &data_offset); |
1067 | 1090 | ||
1068 | ss_info = |
1091 | ss_info = |
1069 | (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset); |
1092 | (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset); |
1070 | 1093 | ||
1071 | if (ss_info) { |
1094 | if (ss_info) { |
1072 | ss = |
1095 | ss = |
1073 | kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL); |
1096 | kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL); |
1074 | 1097 | ||
1075 | if (!ss) |
1098 | if (!ss) |
1076 | return NULL; |
1099 | return NULL; |
1077 | 1100 | ||
1078 | for (i = 0; i < ATOM_MAX_SS_ENTRY; i++) { |
1101 | for (i = 0; i < ATOM_MAX_SS_ENTRY; i++) { |
1079 | if (ss_info->asSS_Info[i].ucSS_Id == id) { |
1102 | if (ss_info->asSS_Info[i].ucSS_Id == id) { |
1080 | ss->percentage = |
1103 | ss->percentage = |
1081 | le16_to_cpu(ss_info->asSS_Info[i].usSpreadSpectrumPercentage); |
1104 | le16_to_cpu(ss_info->asSS_Info[i].usSpreadSpectrumPercentage); |
1082 | ss->type = ss_info->asSS_Info[i].ucSpreadSpectrumType; |
1105 | ss->type = ss_info->asSS_Info[i].ucSpreadSpectrumType; |
1083 | ss->step = ss_info->asSS_Info[i].ucSS_Step; |
1106 | ss->step = ss_info->asSS_Info[i].ucSS_Step; |
1084 | ss->delay = ss_info->asSS_Info[i].ucSS_Delay; |
1107 | ss->delay = ss_info->asSS_Info[i].ucSS_Delay; |
1085 | ss->range = ss_info->asSS_Info[i].ucSS_Range; |
1108 | ss->range = ss_info->asSS_Info[i].ucSS_Range; |
1086 | ss->refdiv = ss_info->asSS_Info[i].ucRecommendedRef_Div; |
1109 | ss->refdiv = ss_info->asSS_Info[i].ucRecommendedRef_Div; |
1087 | break; |
1110 | break; |
1088 | } |
1111 | } |
1089 | } |
1112 | } |
1090 | } |
1113 | } |
1091 | return ss; |
1114 | return ss; |
1092 | } |
1115 | } |
- | 1116 | ||
- | 1117 | static void radeon_atom_apply_lvds_quirks(struct drm_device *dev, |
|
- | 1118 | struct radeon_encoder_atom_dig *lvds) |
|
- | 1119 | { |
|
- | 1120 | ||
- | 1121 | /* Toshiba A300-1BU laptop panel doesn't like new pll divider algo */ |
|
- | 1122 | if ((dev->pdev->device == 0x95c4) && |
|
- | 1123 | (dev->pdev->subsystem_vendor == 0x1179) && |
|
- | 1124 | (dev->pdev->subsystem_device == 0xff50)) { |
|
- | 1125 | if ((lvds->native_mode.hdisplay == 1280) && |
|
- | 1126 | (lvds->native_mode.vdisplay == 800)) |
|
- | 1127 | lvds->pll_algo = PLL_ALGO_LEGACY; |
|
- | 1128 | } |
|
- | 1129 | ||
- | 1130 | /* Dell Studio 15 laptop panel doesn't like new pll divider algo */ |
|
- | 1131 | if ((dev->pdev->device == 0x95c4) && |
|
- | 1132 | (dev->pdev->subsystem_vendor == 0x1028) && |
|
- | 1133 | (dev->pdev->subsystem_device == 0x029f)) { |
|
- | 1134 | if ((lvds->native_mode.hdisplay == 1280) && |
|
- | 1135 | (lvds->native_mode.vdisplay == 800)) |
|
- | 1136 | lvds->pll_algo = PLL_ALGO_LEGACY; |
|
- | 1137 | } |
|
- | 1138 | ||
- | 1139 | } |
|
1093 | 1140 | ||
1094 | union lvds_info { |
1141 | union lvds_info { |
1095 | struct _ATOM_LVDS_INFO info; |
1142 | struct _ATOM_LVDS_INFO info; |
1096 | struct _ATOM_LVDS_INFO_V12 info_12; |
1143 | struct _ATOM_LVDS_INFO_V12 info_12; |
1097 | }; |
1144 | }; |
1098 | 1145 | ||
1099 | struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct |
1146 | struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct |
1100 | radeon_encoder |
1147 | radeon_encoder |
1101 | *encoder) |
1148 | *encoder) |
1102 | { |
1149 | { |
1103 | struct drm_device *dev = encoder->base.dev; |
1150 | struct drm_device *dev = encoder->base.dev; |
1104 | struct radeon_device *rdev = dev->dev_private; |
1151 | struct radeon_device *rdev = dev->dev_private; |
1105 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1152 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1106 | int index = GetIndexIntoMasterTable(DATA, LVDS_Info); |
1153 | int index = GetIndexIntoMasterTable(DATA, LVDS_Info); |
1107 | uint16_t data_offset, misc; |
1154 | uint16_t data_offset, misc; |
1108 | union lvds_info *lvds_info; |
1155 | union lvds_info *lvds_info; |
1109 | uint8_t frev, crev; |
1156 | uint8_t frev, crev; |
1110 | struct radeon_encoder_atom_dig *lvds = NULL; |
1157 | struct radeon_encoder_atom_dig *lvds = NULL; |
1111 | 1158 | ||
1112 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1159 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, |
1113 | &crev, &data_offset); |
1160 | &crev, &data_offset); |
1114 | 1161 | ||
1115 | lvds_info = |
1162 | lvds_info = |
1116 | (union lvds_info *)(mode_info->atom_context->bios + data_offset); |
1163 | (union lvds_info *)(mode_info->atom_context->bios + data_offset); |
1117 | 1164 | ||
1118 | if (lvds_info) { |
1165 | if (lvds_info) { |
1119 | lvds = |
1166 | lvds = |
1120 | kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL); |
1167 | kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL); |
1121 | 1168 | ||
1122 | if (!lvds) |
1169 | if (!lvds) |
1123 | return NULL; |
1170 | return NULL; |
1124 | 1171 | ||
1125 | lvds->native_mode.clock = |
1172 | lvds->native_mode.clock = |
1126 | le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10; |
1173 | le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10; |
1127 | lvds->native_mode.hdisplay = |
1174 | lvds->native_mode.hdisplay = |
1128 | le16_to_cpu(lvds_info->info.sLCDTiming.usHActive); |
1175 | le16_to_cpu(lvds_info->info.sLCDTiming.usHActive); |
1129 | lvds->native_mode.vdisplay = |
1176 | lvds->native_mode.vdisplay = |
1130 | le16_to_cpu(lvds_info->info.sLCDTiming.usVActive); |
1177 | le16_to_cpu(lvds_info->info.sLCDTiming.usVActive); |
1131 | lvds->native_mode.htotal = lvds->native_mode.hdisplay + |
1178 | lvds->native_mode.htotal = lvds->native_mode.hdisplay + |
1132 | le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time); |
1179 | le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time); |
1133 | lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + |
1180 | lvds->native_mode.hsync_start = lvds->native_mode.hdisplay + |
1134 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset); |
1181 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset); |
1135 | lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + |
1182 | lvds->native_mode.hsync_end = lvds->native_mode.hsync_start + |
1136 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth); |
1183 | le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth); |
1137 | lvds->native_mode.vtotal = lvds->native_mode.vdisplay + |
1184 | lvds->native_mode.vtotal = lvds->native_mode.vdisplay + |
1138 | le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time); |
1185 | le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time); |
1139 | lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + |
1186 | lvds->native_mode.vsync_start = lvds->native_mode.vdisplay + |
1140 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); |
1187 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); |
1141 | lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + |
1188 | lvds->native_mode.vsync_end = lvds->native_mode.vsync_start + |
1142 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); |
1189 | le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); |
1143 | lvds->panel_pwr_delay = |
1190 | lvds->panel_pwr_delay = |
1144 | le16_to_cpu(lvds_info->info.usOffDelayInMs); |
1191 | le16_to_cpu(lvds_info->info.usOffDelayInMs); |
1145 | lvds->lvds_misc = lvds_info->info.ucLVDS_Misc; |
1192 | lvds->lvds_misc = lvds_info->info.ucLVDS_Misc; |
1146 | 1193 | ||
1147 | misc = le16_to_cpu(lvds_info->info.sLCDTiming.susModeMiscInfo.usAccess); |
1194 | misc = le16_to_cpu(lvds_info->info.sLCDTiming.susModeMiscInfo.usAccess); |
1148 | if (misc & ATOM_VSYNC_POLARITY) |
1195 | if (misc & ATOM_VSYNC_POLARITY) |
1149 | lvds->native_mode.flags |= DRM_MODE_FLAG_NVSYNC; |
1196 | lvds->native_mode.flags |= DRM_MODE_FLAG_NVSYNC; |
1150 | if (misc & ATOM_HSYNC_POLARITY) |
1197 | if (misc & ATOM_HSYNC_POLARITY) |
1151 | lvds->native_mode.flags |= DRM_MODE_FLAG_NHSYNC; |
1198 | lvds->native_mode.flags |= DRM_MODE_FLAG_NHSYNC; |
1152 | if (misc & ATOM_COMPOSITESYNC) |
1199 | if (misc & ATOM_COMPOSITESYNC) |
1153 | lvds->native_mode.flags |= DRM_MODE_FLAG_CSYNC; |
1200 | lvds->native_mode.flags |= DRM_MODE_FLAG_CSYNC; |
1154 | if (misc & ATOM_INTERLACE) |
1201 | if (misc & ATOM_INTERLACE) |
1155 | lvds->native_mode.flags |= DRM_MODE_FLAG_INTERLACE; |
1202 | lvds->native_mode.flags |= DRM_MODE_FLAG_INTERLACE; |
1156 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1203 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1157 | lvds->native_mode.flags |= DRM_MODE_FLAG_DBLSCAN; |
1204 | lvds->native_mode.flags |= DRM_MODE_FLAG_DBLSCAN; |
1158 | 1205 | ||
1159 | /* set crtc values */ |
1206 | /* set crtc values */ |
1160 | drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); |
1207 | drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V); |
1161 | 1208 | ||
1162 | lvds->ss = radeon_atombios_get_ss_info(encoder, lvds_info->info.ucSS_Id); |
1209 | lvds->ss = radeon_atombios_get_ss_info(encoder, lvds_info->info.ucSS_Id); |
- | 1210 | ||
- | 1211 | if (ASIC_IS_AVIVO(rdev)) { |
|
- | 1212 | if (radeon_new_pll == 0) |
|
- | 1213 | lvds->pll_algo = PLL_ALGO_LEGACY; |
|
- | 1214 | else |
|
- | 1215 | lvds->pll_algo = PLL_ALGO_NEW; |
|
- | 1216 | } else { |
|
- | 1217 | if (radeon_new_pll == 1) |
|
- | 1218 | lvds->pll_algo = PLL_ALGO_NEW; |
|
- | 1219 | else |
|
- | 1220 | lvds->pll_algo = PLL_ALGO_LEGACY; |
|
- | 1221 | } |
|
- | 1222 | ||
- | 1223 | /* LVDS quirks */ |
|
- | 1224 | radeon_atom_apply_lvds_quirks(dev, lvds); |
|
1163 | 1225 | ||
1164 | encoder->native_mode = lvds->native_mode; |
1226 | encoder->native_mode = lvds->native_mode; |
1165 | } |
1227 | } |
1166 | return lvds; |
1228 | return lvds; |
1167 | } |
1229 | } |
1168 | 1230 | ||
1169 | struct radeon_encoder_primary_dac * |
1231 | struct radeon_encoder_primary_dac * |
1170 | radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder) |
1232 | radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder) |
1171 | { |
1233 | { |
1172 | struct drm_device *dev = encoder->base.dev; |
1234 | struct drm_device *dev = encoder->base.dev; |
1173 | struct radeon_device *rdev = dev->dev_private; |
1235 | struct radeon_device *rdev = dev->dev_private; |
1174 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1236 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1175 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
1237 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
1176 | uint16_t data_offset; |
1238 | uint16_t data_offset; |
1177 | struct _COMPASSIONATE_DATA *dac_info; |
1239 | struct _COMPASSIONATE_DATA *dac_info; |
1178 | uint8_t frev, crev; |
1240 | uint8_t frev, crev; |
1179 | uint8_t bg, dac; |
1241 | uint8_t bg, dac; |
1180 | struct radeon_encoder_primary_dac *p_dac = NULL; |
1242 | struct radeon_encoder_primary_dac *p_dac = NULL; |
1181 | 1243 | ||
1182 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1244 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1183 | 1245 | ||
1184 | dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); |
1246 | dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); |
1185 | 1247 | ||
1186 | if (dac_info) { |
1248 | if (dac_info) { |
1187 | p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL); |
1249 | p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL); |
1188 | 1250 | ||
1189 | if (!p_dac) |
1251 | if (!p_dac) |
1190 | return NULL; |
1252 | return NULL; |
1191 | 1253 | ||
1192 | bg = dac_info->ucDAC1_BG_Adjustment; |
1254 | bg = dac_info->ucDAC1_BG_Adjustment; |
1193 | dac = dac_info->ucDAC1_DAC_Adjustment; |
1255 | dac = dac_info->ucDAC1_DAC_Adjustment; |
1194 | p_dac->ps2_pdac_adj = (bg << 8) | (dac); |
1256 | p_dac->ps2_pdac_adj = (bg << 8) | (dac); |
1195 | 1257 | ||
1196 | } |
1258 | } |
1197 | return p_dac; |
1259 | return p_dac; |
1198 | } |
1260 | } |
1199 | 1261 | ||
1200 | bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, |
1262 | bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index, |
1201 | struct drm_display_mode *mode) |
1263 | struct drm_display_mode *mode) |
1202 | { |
1264 | { |
1203 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1265 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1204 | ATOM_ANALOG_TV_INFO *tv_info; |
1266 | ATOM_ANALOG_TV_INFO *tv_info; |
1205 | ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2; |
1267 | ATOM_ANALOG_TV_INFO_V1_2 *tv_info_v1_2; |
1206 | ATOM_DTD_FORMAT *dtd_timings; |
1268 | ATOM_DTD_FORMAT *dtd_timings; |
1207 | int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
1269 | int data_index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
1208 | u8 frev, crev; |
1270 | u8 frev, crev; |
1209 | u16 data_offset, misc; |
1271 | u16 data_offset, misc; |
1210 | 1272 | ||
1211 | atom_parse_data_header(mode_info->atom_context, data_index, NULL, &frev, &crev, &data_offset); |
1273 | atom_parse_data_header(mode_info->atom_context, data_index, NULL, &frev, &crev, &data_offset); |
1212 | 1274 | ||
1213 | switch (crev) { |
1275 | switch (crev) { |
1214 | case 1: |
1276 | case 1: |
1215 | tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); |
1277 | tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); |
1216 | if (index > MAX_SUPPORTED_TV_TIMING) |
1278 | if (index > MAX_SUPPORTED_TV_TIMING) |
1217 | return false; |
1279 | return false; |
1218 | 1280 | ||
1219 | mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); |
1281 | mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); |
1220 | mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp); |
1282 | mode->crtc_hdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Disp); |
1221 | mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart); |
1283 | mode->crtc_hsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart); |
1222 | mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) + |
1284 | mode->crtc_hsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncStart) + |
1223 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth); |
1285 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_SyncWidth); |
1224 | 1286 | ||
1225 | mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total); |
1287 | mode->crtc_vtotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Total); |
1226 | mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp); |
1288 | mode->crtc_vdisplay = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_Disp); |
1227 | mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart); |
1289 | mode->crtc_vsync_start = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart); |
1228 | mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) + |
1290 | mode->crtc_vsync_end = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncStart) + |
1229 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth); |
1291 | le16_to_cpu(tv_info->aModeTimings[index].usCRTC_V_SyncWidth); |
1230 | 1292 | ||
1231 | mode->flags = 0; |
1293 | mode->flags = 0; |
1232 | misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess); |
1294 | misc = le16_to_cpu(tv_info->aModeTimings[index].susModeMiscInfo.usAccess); |
1233 | if (misc & ATOM_VSYNC_POLARITY) |
1295 | if (misc & ATOM_VSYNC_POLARITY) |
1234 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
1296 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
1235 | if (misc & ATOM_HSYNC_POLARITY) |
1297 | if (misc & ATOM_HSYNC_POLARITY) |
1236 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
1298 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
1237 | if (misc & ATOM_COMPOSITESYNC) |
1299 | if (misc & ATOM_COMPOSITESYNC) |
1238 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
1300 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
1239 | if (misc & ATOM_INTERLACE) |
1301 | if (misc & ATOM_INTERLACE) |
1240 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
1302 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
1241 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1303 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1242 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
1304 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
1243 | 1305 | ||
1244 | mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10; |
1306 | mode->clock = le16_to_cpu(tv_info->aModeTimings[index].usPixelClock) * 10; |
1245 | 1307 | ||
1246 | if (index == 1) { |
1308 | if (index == 1) { |
1247 | /* PAL timings appear to have wrong values for totals */ |
1309 | /* PAL timings appear to have wrong values for totals */ |
1248 | mode->crtc_htotal -= 1; |
1310 | mode->crtc_htotal -= 1; |
1249 | mode->crtc_vtotal -= 1; |
1311 | mode->crtc_vtotal -= 1; |
1250 | } |
1312 | } |
1251 | break; |
1313 | break; |
1252 | case 2: |
1314 | case 2: |
1253 | tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); |
1315 | tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); |
1254 | if (index > MAX_SUPPORTED_TV_TIMING_V1_2) |
1316 | if (index > MAX_SUPPORTED_TV_TIMING_V1_2) |
1255 | return false; |
1317 | return false; |
1256 | 1318 | ||
1257 | dtd_timings = &tv_info_v1_2->aModeTimings[index]; |
1319 | dtd_timings = &tv_info_v1_2->aModeTimings[index]; |
1258 | mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) + |
1320 | mode->crtc_htotal = le16_to_cpu(dtd_timings->usHActive) + |
1259 | le16_to_cpu(dtd_timings->usHBlanking_Time); |
1321 | le16_to_cpu(dtd_timings->usHBlanking_Time); |
1260 | mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive); |
1322 | mode->crtc_hdisplay = le16_to_cpu(dtd_timings->usHActive); |
1261 | mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) + |
1323 | mode->crtc_hsync_start = le16_to_cpu(dtd_timings->usHActive) + |
1262 | le16_to_cpu(dtd_timings->usHSyncOffset); |
1324 | le16_to_cpu(dtd_timings->usHSyncOffset); |
1263 | mode->crtc_hsync_end = mode->crtc_hsync_start + |
1325 | mode->crtc_hsync_end = mode->crtc_hsync_start + |
1264 | le16_to_cpu(dtd_timings->usHSyncWidth); |
1326 | le16_to_cpu(dtd_timings->usHSyncWidth); |
1265 | 1327 | ||
1266 | mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) + |
1328 | mode->crtc_vtotal = le16_to_cpu(dtd_timings->usVActive) + |
1267 | le16_to_cpu(dtd_timings->usVBlanking_Time); |
1329 | le16_to_cpu(dtd_timings->usVBlanking_Time); |
1268 | mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive); |
1330 | mode->crtc_vdisplay = le16_to_cpu(dtd_timings->usVActive); |
1269 | mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) + |
1331 | mode->crtc_vsync_start = le16_to_cpu(dtd_timings->usVActive) + |
1270 | le16_to_cpu(dtd_timings->usVSyncOffset); |
1332 | le16_to_cpu(dtd_timings->usVSyncOffset); |
1271 | mode->crtc_vsync_end = mode->crtc_vsync_start + |
1333 | mode->crtc_vsync_end = mode->crtc_vsync_start + |
1272 | le16_to_cpu(dtd_timings->usVSyncWidth); |
1334 | le16_to_cpu(dtd_timings->usVSyncWidth); |
1273 | 1335 | ||
1274 | mode->flags = 0; |
1336 | mode->flags = 0; |
1275 | misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess); |
1337 | misc = le16_to_cpu(dtd_timings->susModeMiscInfo.usAccess); |
1276 | if (misc & ATOM_VSYNC_POLARITY) |
1338 | if (misc & ATOM_VSYNC_POLARITY) |
1277 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
1339 | mode->flags |= DRM_MODE_FLAG_NVSYNC; |
1278 | if (misc & ATOM_HSYNC_POLARITY) |
1340 | if (misc & ATOM_HSYNC_POLARITY) |
1279 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
1341 | mode->flags |= DRM_MODE_FLAG_NHSYNC; |
1280 | if (misc & ATOM_COMPOSITESYNC) |
1342 | if (misc & ATOM_COMPOSITESYNC) |
1281 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
1343 | mode->flags |= DRM_MODE_FLAG_CSYNC; |
1282 | if (misc & ATOM_INTERLACE) |
1344 | if (misc & ATOM_INTERLACE) |
1283 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
1345 | mode->flags |= DRM_MODE_FLAG_INTERLACE; |
1284 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1346 | if (misc & ATOM_DOUBLE_CLOCK_MODE) |
1285 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
1347 | mode->flags |= DRM_MODE_FLAG_DBLSCAN; |
1286 | 1348 | ||
1287 | mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10; |
1349 | mode->clock = le16_to_cpu(dtd_timings->usPixClk) * 10; |
1288 | break; |
1350 | break; |
1289 | } |
1351 | } |
1290 | return true; |
1352 | return true; |
1291 | } |
1353 | } |
1292 | 1354 | ||
1293 | enum radeon_tv_std |
1355 | enum radeon_tv_std |
1294 | radeon_atombios_get_tv_info(struct radeon_device *rdev) |
1356 | radeon_atombios_get_tv_info(struct radeon_device *rdev) |
1295 | { |
1357 | { |
1296 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1358 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1297 | int index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
1359 | int index = GetIndexIntoMasterTable(DATA, AnalogTV_Info); |
1298 | uint16_t data_offset; |
1360 | uint16_t data_offset; |
1299 | uint8_t frev, crev; |
1361 | uint8_t frev, crev; |
1300 | struct _ATOM_ANALOG_TV_INFO *tv_info; |
1362 | struct _ATOM_ANALOG_TV_INFO *tv_info; |
1301 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
1363 | enum radeon_tv_std tv_std = TV_STD_NTSC; |
1302 | 1364 | ||
1303 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1365 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1304 | 1366 | ||
1305 | tv_info = (struct _ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); |
1367 | tv_info = (struct _ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); |
1306 | 1368 | ||
1307 | switch (tv_info->ucTV_BootUpDefaultStandard) { |
1369 | switch (tv_info->ucTV_BootUpDefaultStandard) { |
1308 | case ATOM_TV_NTSC: |
1370 | case ATOM_TV_NTSC: |
1309 | tv_std = TV_STD_NTSC; |
1371 | tv_std = TV_STD_NTSC; |
1310 | DRM_INFO("Default TV standard: NTSC\n"); |
1372 | DRM_INFO("Default TV standard: NTSC\n"); |
1311 | break; |
1373 | break; |
1312 | case ATOM_TV_NTSCJ: |
1374 | case ATOM_TV_NTSCJ: |
1313 | tv_std = TV_STD_NTSC_J; |
1375 | tv_std = TV_STD_NTSC_J; |
1314 | DRM_INFO("Default TV standard: NTSC-J\n"); |
1376 | DRM_INFO("Default TV standard: NTSC-J\n"); |
1315 | break; |
1377 | break; |
1316 | case ATOM_TV_PAL: |
1378 | case ATOM_TV_PAL: |
1317 | tv_std = TV_STD_PAL; |
1379 | tv_std = TV_STD_PAL; |
1318 | DRM_INFO("Default TV standard: PAL\n"); |
1380 | DRM_INFO("Default TV standard: PAL\n"); |
1319 | break; |
1381 | break; |
1320 | case ATOM_TV_PALM: |
1382 | case ATOM_TV_PALM: |
1321 | tv_std = TV_STD_PAL_M; |
1383 | tv_std = TV_STD_PAL_M; |
1322 | DRM_INFO("Default TV standard: PAL-M\n"); |
1384 | DRM_INFO("Default TV standard: PAL-M\n"); |
1323 | break; |
1385 | break; |
1324 | case ATOM_TV_PALN: |
1386 | case ATOM_TV_PALN: |
1325 | tv_std = TV_STD_PAL_N; |
1387 | tv_std = TV_STD_PAL_N; |
1326 | DRM_INFO("Default TV standard: PAL-N\n"); |
1388 | DRM_INFO("Default TV standard: PAL-N\n"); |
1327 | break; |
1389 | break; |
1328 | case ATOM_TV_PALCN: |
1390 | case ATOM_TV_PALCN: |
1329 | tv_std = TV_STD_PAL_CN; |
1391 | tv_std = TV_STD_PAL_CN; |
1330 | DRM_INFO("Default TV standard: PAL-CN\n"); |
1392 | DRM_INFO("Default TV standard: PAL-CN\n"); |
1331 | break; |
1393 | break; |
1332 | case ATOM_TV_PAL60: |
1394 | case ATOM_TV_PAL60: |
1333 | tv_std = TV_STD_PAL_60; |
1395 | tv_std = TV_STD_PAL_60; |
1334 | DRM_INFO("Default TV standard: PAL-60\n"); |
1396 | DRM_INFO("Default TV standard: PAL-60\n"); |
1335 | break; |
1397 | break; |
1336 | case ATOM_TV_SECAM: |
1398 | case ATOM_TV_SECAM: |
1337 | tv_std = TV_STD_SECAM; |
1399 | tv_std = TV_STD_SECAM; |
1338 | DRM_INFO("Default TV standard: SECAM\n"); |
1400 | DRM_INFO("Default TV standard: SECAM\n"); |
1339 | break; |
1401 | break; |
1340 | default: |
1402 | default: |
1341 | tv_std = TV_STD_NTSC; |
1403 | tv_std = TV_STD_NTSC; |
1342 | DRM_INFO("Unknown TV standard; defaulting to NTSC\n"); |
1404 | DRM_INFO("Unknown TV standard; defaulting to NTSC\n"); |
1343 | break; |
1405 | break; |
1344 | } |
1406 | } |
1345 | return tv_std; |
1407 | return tv_std; |
1346 | } |
1408 | } |
1347 | 1409 | ||
1348 | struct radeon_encoder_tv_dac * |
1410 | struct radeon_encoder_tv_dac * |
1349 | radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder) |
1411 | radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder) |
1350 | { |
1412 | { |
1351 | struct drm_device *dev = encoder->base.dev; |
1413 | struct drm_device *dev = encoder->base.dev; |
1352 | struct radeon_device *rdev = dev->dev_private; |
1414 | struct radeon_device *rdev = dev->dev_private; |
1353 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1415 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
1354 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
1416 | int index = GetIndexIntoMasterTable(DATA, CompassionateData); |
1355 | uint16_t data_offset; |
1417 | uint16_t data_offset; |
1356 | struct _COMPASSIONATE_DATA *dac_info; |
1418 | struct _COMPASSIONATE_DATA *dac_info; |
1357 | uint8_t frev, crev; |
1419 | uint8_t frev, crev; |
1358 | uint8_t bg, dac; |
1420 | uint8_t bg, dac; |
1359 | struct radeon_encoder_tv_dac *tv_dac = NULL; |
1421 | struct radeon_encoder_tv_dac *tv_dac = NULL; |
1360 | 1422 | ||
1361 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1423 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
1362 | 1424 | ||
1363 | dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); |
1425 | dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); |
1364 | 1426 | ||
1365 | if (dac_info) { |
1427 | if (dac_info) { |
1366 | tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); |
1428 | tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); |
1367 | 1429 | ||
1368 | if (!tv_dac) |
1430 | if (!tv_dac) |
1369 | return NULL; |
1431 | return NULL; |
1370 | 1432 | ||
1371 | bg = dac_info->ucDAC2_CRT2_BG_Adjustment; |
1433 | bg = dac_info->ucDAC2_CRT2_BG_Adjustment; |
1372 | dac = dac_info->ucDAC2_CRT2_DAC_Adjustment; |
1434 | dac = dac_info->ucDAC2_CRT2_DAC_Adjustment; |
1373 | tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); |
1435 | tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20); |
1374 | 1436 | ||
1375 | bg = dac_info->ucDAC2_PAL_BG_Adjustment; |
1437 | bg = dac_info->ucDAC2_PAL_BG_Adjustment; |
1376 | dac = dac_info->ucDAC2_PAL_DAC_Adjustment; |
1438 | dac = dac_info->ucDAC2_PAL_DAC_Adjustment; |
1377 | tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); |
1439 | tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20); |
1378 | 1440 | ||
1379 | bg = dac_info->ucDAC2_NTSC_BG_Adjustment; |
1441 | bg = dac_info->ucDAC2_NTSC_BG_Adjustment; |
1380 | dac = dac_info->ucDAC2_NTSC_DAC_Adjustment; |
1442 | dac = dac_info->ucDAC2_NTSC_DAC_Adjustment; |
1381 | tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); |
1443 | tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); |
1382 | 1444 | ||
1383 | tv_dac->tv_std = radeon_atombios_get_tv_info(rdev); |
1445 | tv_dac->tv_std = radeon_atombios_get_tv_info(rdev); |
1384 | } |
1446 | } |
1385 | return tv_dac; |
1447 | return tv_dac; |
1386 | } |
1448 | } |
- | 1449 | ||
- | 1450 | union power_info { |
|
- | 1451 | struct _ATOM_POWERPLAY_INFO info; |
|
- | 1452 | struct _ATOM_POWERPLAY_INFO_V2 info_2; |
|
- | 1453 | struct _ATOM_POWERPLAY_INFO_V3 info_3; |
|
- | 1454 | struct _ATOM_PPLIB_POWERPLAYTABLE info_4; |
|
- | 1455 | }; |
|
1387 | 1456 | ||
1388 | void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable) |
1457 | void radeon_atombios_get_power_modes(struct radeon_device *rdev) |
1389 | { |
1458 | { |
1390 | DYNAMIC_CLOCK_GATING_PS_ALLOCATION args; |
1459 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
- | 1460 | int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); |
|
- | 1461 | u16 data_offset; |
|
- | 1462 | u8 frev, crev; |
|
- | 1463 | u32 misc, misc2 = 0, sclk, mclk; |
|
- | 1464 | union power_info *power_info; |
|
- | 1465 | struct _ATOM_PPLIB_NONCLOCK_INFO *non_clock_info; |
|
- | 1466 | struct _ATOM_PPLIB_STATE *power_state; |
|
- | 1467 | int num_modes = 0, i, j; |
|
- | 1468 | int state_index = 0, mode_index = 0; |
|
- | 1469 | ||
- | 1470 | atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); |
|
- | 1471 | ||
1391 | int index = GetIndexIntoMasterTable(COMMAND, DynamicClockGating); |
1472 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
- | 1473 | ||
- | 1474 | rdev->pm.default_power_state = NULL; |
|
- | 1475 | ||
- | 1476 | if (power_info) { |
|
- | 1477 | if (frev < 4) { |
|
- | 1478 | num_modes = power_info->info.ucNumOfPowerModeEntries; |
|
- | 1479 | if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK) |
|
- | 1480 | num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK; |
|
- | 1481 | for (i = 0; i < num_modes; i++) { |
|
- | 1482 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
|
- | 1483 | switch (frev) { |
|
- | 1484 | case 1: |
|
- | 1485 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
|
- | 1486 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
|
- | 1487 | le16_to_cpu(power_info->info.asPowerPlayInfo[i].usMemoryClock); |
|
- | 1488 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
|
- | 1489 | le16_to_cpu(power_info->info.asPowerPlayInfo[i].usEngineClock); |
|
- | 1490 | /* skip invalid modes */ |
|
- | 1491 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
|
- | 1492 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
|
- | 1493 | continue; |
|
- | 1494 | /* skip overclock modes for now */ |
|
- | 1495 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk > |
|
- | 1496 | rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || |
|
- | 1497 | (rdev->pm.power_state[state_index].clock_info[0].sclk > |
|
- | 1498 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) |
|
- | 1499 | continue; |
|
- | 1500 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = |
|
- | 1501 | power_info->info.asPowerPlayInfo[i].ucNumPciELanes; |
|
- | 1502 | misc = le32_to_cpu(power_info->info.asPowerPlayInfo[i].ulMiscInfo); |
|
- | 1503 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) { |
|
- | 1504 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1505 | VOLTAGE_GPIO; |
|
- | 1506 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
|
- | 1507 | radeon_lookup_gpio(rdev, |
|
- | 1508 | power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex); |
|
- | 1509 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
|
- | 1510 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1511 | true; |
|
- | 1512 | else |
|
- | 1513 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1514 | false; |
|
- | 1515 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
|
- | 1516 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1517 | VOLTAGE_VDDC; |
|
- | 1518 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
|
- | 1519 | power_info->info.asPowerPlayInfo[i].ucVoltageDropIndex; |
|
- | 1520 | } |
|
- | 1521 | /* order matters! */ |
|
- | 1522 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
|
- | 1523 | rdev->pm.power_state[state_index].type = |
|
- | 1524 | POWER_STATE_TYPE_POWERSAVE; |
|
- | 1525 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
|
- | 1526 | rdev->pm.power_state[state_index].type = |
|
- | 1527 | POWER_STATE_TYPE_BATTERY; |
|
- | 1528 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
|
- | 1529 | rdev->pm.power_state[state_index].type = |
|
- | 1530 | POWER_STATE_TYPE_BATTERY; |
|
- | 1531 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
|
- | 1532 | rdev->pm.power_state[state_index].type = |
|
- | 1533 | POWER_STATE_TYPE_BALANCED; |
|
- | 1534 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) |
|
- | 1535 | rdev->pm.power_state[state_index].type = |
|
- | 1536 | POWER_STATE_TYPE_PERFORMANCE; |
|
- | 1537 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
|
- | 1538 | rdev->pm.power_state[state_index].type = |
|
- | 1539 | POWER_STATE_TYPE_DEFAULT; |
|
- | 1540 | rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; |
|
- | 1541 | rdev->pm.power_state[state_index].default_clock_mode = |
|
- | 1542 | &rdev->pm.power_state[state_index].clock_info[0]; |
|
- | 1543 | } |
|
- | 1544 | state_index++; |
|
- | 1545 | break; |
|
- | 1546 | case 2: |
|
- | 1547 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
|
- | 1548 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
|
- | 1549 | le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMemoryClock); |
|
- | 1550 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
|
- | 1551 | le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulEngineClock); |
|
- | 1552 | /* skip invalid modes */ |
|
- | 1553 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
|
- | 1554 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
|
- | 1555 | continue; |
|
- | 1556 | /* skip overclock modes for now */ |
|
- | 1557 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk > |
|
- | 1558 | rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || |
|
- | 1559 | (rdev->pm.power_state[state_index].clock_info[0].sclk > |
|
- | 1560 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) |
|
- | 1561 | continue; |
|
- | 1562 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = |
|
- | 1563 | power_info->info_2.asPowerPlayInfo[i].ucNumPciELanes; |
|
- | 1564 | misc = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo); |
|
- | 1565 | misc2 = le32_to_cpu(power_info->info_2.asPowerPlayInfo[i].ulMiscInfo2); |
|
- | 1566 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) { |
|
- | 1567 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1568 | VOLTAGE_GPIO; |
|
- | 1569 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
|
- | 1570 | radeon_lookup_gpio(rdev, |
|
- | 1571 | power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex); |
|
- | 1572 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
|
- | 1573 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1574 | true; |
|
- | 1575 | else |
|
- | 1576 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1577 | false; |
|
- | 1578 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
|
- | 1579 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1580 | VOLTAGE_VDDC; |
|
- | 1581 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
|
- | 1582 | power_info->info_2.asPowerPlayInfo[i].ucVoltageDropIndex; |
|
- | 1583 | } |
|
- | 1584 | /* order matters! */ |
|
- | 1585 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
|
- | 1586 | rdev->pm.power_state[state_index].type = |
|
- | 1587 | POWER_STATE_TYPE_POWERSAVE; |
|
- | 1588 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
|
- | 1589 | rdev->pm.power_state[state_index].type = |
|
- | 1590 | POWER_STATE_TYPE_BATTERY; |
|
- | 1591 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
|
- | 1592 | rdev->pm.power_state[state_index].type = |
|
- | 1593 | POWER_STATE_TYPE_BATTERY; |
|
- | 1594 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
|
- | 1595 | rdev->pm.power_state[state_index].type = |
|
- | 1596 | POWER_STATE_TYPE_BALANCED; |
|
- | 1597 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) |
|
- | 1598 | rdev->pm.power_state[state_index].type = |
|
- | 1599 | POWER_STATE_TYPE_PERFORMANCE; |
|
- | 1600 | if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE) |
|
- | 1601 | rdev->pm.power_state[state_index].type = |
|
- | 1602 | POWER_STATE_TYPE_BALANCED; |
|
- | 1603 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
|
- | 1604 | rdev->pm.power_state[state_index].type = |
|
- | 1605 | POWER_STATE_TYPE_DEFAULT; |
|
- | 1606 | rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; |
|
- | 1607 | rdev->pm.power_state[state_index].default_clock_mode = |
|
- | 1608 | &rdev->pm.power_state[state_index].clock_info[0]; |
|
- | 1609 | } |
|
- | 1610 | state_index++; |
|
- | 1611 | break; |
|
- | 1612 | case 3: |
|
- | 1613 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
|
- | 1614 | rdev->pm.power_state[state_index].clock_info[0].mclk = |
|
- | 1615 | le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMemoryClock); |
|
- | 1616 | rdev->pm.power_state[state_index].clock_info[0].sclk = |
|
- | 1617 | le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulEngineClock); |
|
- | 1618 | /* skip invalid modes */ |
|
- | 1619 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) || |
|
- | 1620 | (rdev->pm.power_state[state_index].clock_info[0].sclk == 0)) |
|
- | 1621 | continue; |
|
- | 1622 | /* skip overclock modes for now */ |
|
- | 1623 | if ((rdev->pm.power_state[state_index].clock_info[0].mclk > |
|
- | 1624 | rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || |
|
- | 1625 | (rdev->pm.power_state[state_index].clock_info[0].sclk > |
|
- | 1626 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) |
|
- | 1627 | continue; |
|
- | 1628 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = |
|
- | 1629 | power_info->info_3.asPowerPlayInfo[i].ucNumPciELanes; |
|
- | 1630 | misc = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo); |
|
- | 1631 | misc2 = le32_to_cpu(power_info->info_3.asPowerPlayInfo[i].ulMiscInfo2); |
|
- | 1632 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT) { |
|
- | 1633 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1634 | VOLTAGE_GPIO; |
|
- | 1635 | rdev->pm.power_state[state_index].clock_info[0].voltage.gpio = |
|
- | 1636 | radeon_lookup_gpio(rdev, |
|
- | 1637 | power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex); |
|
- | 1638 | if (misc & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH) |
|
- | 1639 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1640 | true; |
|
- | 1641 | else |
|
- | 1642 | rdev->pm.power_state[state_index].clock_info[0].voltage.active_high = |
|
- | 1643 | false; |
|
- | 1644 | } else if (misc & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE) { |
|
- | 1645 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = |
|
- | 1646 | VOLTAGE_VDDC; |
|
- | 1647 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddc_id = |
|
- | 1648 | power_info->info_3.asPowerPlayInfo[i].ucVoltageDropIndex; |
|
- | 1649 | if (misc2 & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN) { |
|
- | 1650 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_enabled = |
|
- | 1651 | true; |
|
- | 1652 | rdev->pm.power_state[state_index].clock_info[0].voltage.vddci_id = |
|
- | 1653 | power_info->info_3.asPowerPlayInfo[i].ucVDDCI_VoltageDropIndex; |
|
- | 1654 | } |
|
- | 1655 | } |
|
- | 1656 | /* order matters! */ |
|
- | 1657 | if (misc & ATOM_PM_MISCINFO_POWER_SAVING_MODE) |
|
- | 1658 | rdev->pm.power_state[state_index].type = |
|
- | 1659 | POWER_STATE_TYPE_POWERSAVE; |
|
- | 1660 | if (misc & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE) |
|
- | 1661 | rdev->pm.power_state[state_index].type = |
|
- | 1662 | POWER_STATE_TYPE_BATTERY; |
|
- | 1663 | if (misc & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE) |
|
- | 1664 | rdev->pm.power_state[state_index].type = |
|
- | 1665 | POWER_STATE_TYPE_BATTERY; |
|
- | 1666 | if (misc & ATOM_PM_MISCINFO_LOAD_BALANCE_EN) |
|
- | 1667 | rdev->pm.power_state[state_index].type = |
|
- | 1668 | POWER_STATE_TYPE_BALANCED; |
|
- | 1669 | if (misc & ATOM_PM_MISCINFO_3D_ACCELERATION_EN) |
|
- | 1670 | rdev->pm.power_state[state_index].type = |
|
- | 1671 | POWER_STATE_TYPE_PERFORMANCE; |
|
- | 1672 | if (misc2 & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE) |
|
- | 1673 | rdev->pm.power_state[state_index].type = |
|
- | 1674 | POWER_STATE_TYPE_BALANCED; |
|
- | 1675 | if (misc & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE) { |
|
- | 1676 | rdev->pm.power_state[state_index].type = |
|
- | 1677 | POWER_STATE_TYPE_DEFAULT; |
|
- | 1678 | rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; |
|
- | 1679 | rdev->pm.power_state[state_index].default_clock_mode = |
|
- | 1680 | &rdev->pm.power_state[state_index].clock_info[0]; |
|
- | 1681 | } |
|
- | 1682 | state_index++; |
|
- | 1683 | break; |
|
- | 1684 | } |
|
- | 1685 | } |
|
- | 1686 | } else if (frev == 4) { |
|
- | 1687 | for (i = 0; i < power_info->info_4.ucNumStates; i++) { |
|
- | 1688 | mode_index = 0; |
|
- | 1689 | power_state = (struct _ATOM_PPLIB_STATE *) |
|
- | 1690 | (mode_info->atom_context->bios + |
|
- | 1691 | data_offset + |
|
- | 1692 | le16_to_cpu(power_info->info_4.usStateArrayOffset) + |
|
- | 1693 | i * power_info->info_4.ucStateEntrySize); |
|
- | 1694 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) |
|
- | 1695 | (mode_info->atom_context->bios + |
|
- | 1696 | data_offset + |
|
- | 1697 | le16_to_cpu(power_info->info_4.usNonClockInfoArrayOffset) + |
|
- | 1698 | (power_state->ucNonClockStateIndex * |
|
- | 1699 | power_info->info_4.ucNonClockSize)); |
|
- | 1700 | for (j = 0; j < (power_info->info_4.ucStateEntrySize - 1); j++) { |
|
- | 1701 | if (rdev->flags & RADEON_IS_IGP) { |
|
- | 1702 | struct _ATOM_PPLIB_RS780_CLOCK_INFO *clock_info = |
|
- | 1703 | (struct _ATOM_PPLIB_RS780_CLOCK_INFO *) |
|
- | 1704 | (mode_info->atom_context->bios + |
|
- | 1705 | data_offset + |
|
- | 1706 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + |
|
- | 1707 | (power_state->ucClockStateIndices[j] * |
|
- | 1708 | power_info->info_4.ucClockInfoSize)); |
|
- | 1709 | sclk = le16_to_cpu(clock_info->usLowEngineClockLow); |
|
- | 1710 | sclk |= clock_info->ucLowEngineClockHigh << 16; |
|
- | 1711 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; |
|
- | 1712 | /* skip invalid modes */ |
|
- | 1713 | if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0) |
|
- | 1714 | continue; |
|
- | 1715 | /* skip overclock modes for now */ |
|
- | 1716 | if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk > |
|
- | 1717 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN) |
|
- | 1718 | continue; |
|
- | 1719 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type = |
|
- | 1720 | VOLTAGE_SW; |
|
- | 1721 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = |
|
- | 1722 | clock_info->usVDDC; |
|
- | 1723 | mode_index++; |
|
- | 1724 | } else { |
|
- | 1725 | struct _ATOM_PPLIB_R600_CLOCK_INFO *clock_info = |
|
- | 1726 | (struct _ATOM_PPLIB_R600_CLOCK_INFO *) |
|
- | 1727 | (mode_info->atom_context->bios + |
|
- | 1728 | data_offset + |
|
- | 1729 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + |
|
- | 1730 | (power_state->ucClockStateIndices[j] * |
|
- | 1731 | power_info->info_4.ucClockInfoSize)); |
|
- | 1732 | sclk = le16_to_cpu(clock_info->usEngineClockLow); |
|
- | 1733 | sclk |= clock_info->ucEngineClockHigh << 16; |
|
- | 1734 | mclk = le16_to_cpu(clock_info->usMemoryClockLow); |
|
- | 1735 | mclk |= clock_info->ucMemoryClockHigh << 16; |
|
- | 1736 | rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk; |
|
- | 1737 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; |
|
- | 1738 | /* skip invalid modes */ |
|
- | 1739 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk == 0) || |
|
- | 1740 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)) |
|
- | 1741 | continue; |
|
- | 1742 | /* skip overclock modes for now */ |
|
- | 1743 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk > |
|
- | 1744 | rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || |
|
- | 1745 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk > |
|
- | 1746 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) |
|
- | 1747 | continue; |
|
- | 1748 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type = |
|
- | 1749 | VOLTAGE_SW; |
|
- | 1750 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = |
|
- | 1751 | clock_info->usVDDC; |
|
- | 1752 | mode_index++; |
|
- | 1753 | } |
|
- | 1754 | } |
|
- | 1755 | rdev->pm.power_state[state_index].num_clock_modes = mode_index; |
|
- | 1756 | if (mode_index) { |
|
- | 1757 | misc = le32_to_cpu(non_clock_info->ulCapsAndSettings); |
|
- | 1758 | misc2 = le16_to_cpu(non_clock_info->usClassification); |
|
- | 1759 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = |
|
- | 1760 | ((misc & ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >> |
|
- | 1761 | ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1; |
|
- | 1762 | switch (misc2 & ATOM_PPLIB_CLASSIFICATION_UI_MASK) { |
|
- | 1763 | case ATOM_PPLIB_CLASSIFICATION_UI_BATTERY: |
|
- | 1764 | rdev->pm.power_state[state_index].type = |
|
- | 1765 | POWER_STATE_TYPE_BATTERY; |
|
- | 1766 | break; |
|
- | 1767 | case ATOM_PPLIB_CLASSIFICATION_UI_BALANCED: |
|
- | 1768 | rdev->pm.power_state[state_index].type = |
|
- | 1769 | POWER_STATE_TYPE_BALANCED; |
|
- | 1770 | break; |
|
- | 1771 | case ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE: |
|
- | 1772 | rdev->pm.power_state[state_index].type = |
|
- | 1773 | POWER_STATE_TYPE_PERFORMANCE; |
|
- | 1774 | break; |
|
- | 1775 | } |
|
- | 1776 | if (misc2 & ATOM_PPLIB_CLASSIFICATION_BOOT) { |
|
- | 1777 | rdev->pm.power_state[state_index].type = |
|
- | 1778 | POWER_STATE_TYPE_DEFAULT; |
|
- | 1779 | rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; |
|
- | 1780 | rdev->pm.power_state[state_index].default_clock_mode = |
|
- | 1781 | &rdev->pm.power_state[state_index].clock_info[mode_index - 1]; |
|
- | 1782 | } |
|
- | 1783 | state_index++; |
|
- | 1784 | } |
|
- | 1785 | } |
|
- | 1786 | } |
|
- | 1787 | } else { |
|
- | 1788 | /* XXX figure out some good default low power mode for cards w/out power tables */ |
|
- | 1789 | } |
|
- | 1790 | ||
- | 1791 | if (rdev->pm.default_power_state == NULL) { |
|
- | 1792 | /* add the default mode */ |
|
- | 1793 | rdev->pm.power_state[state_index].type = |
|
- | 1794 | POWER_STATE_TYPE_DEFAULT; |
|
- | 1795 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
|
- | 1796 | rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk; |
|
- | 1797 | rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk; |
|
- | 1798 | rdev->pm.power_state[state_index].default_clock_mode = |
|
1392 | 1799 | &rdev->pm.power_state[state_index].clock_info[0]; |
|
- | 1800 | rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE; |
|
- | 1801 | if (rdev->asic->get_pcie_lanes) |
|
- | 1802 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev); |
|
- | 1803 | else |
|
- | 1804 | rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16; |
|
- | 1805 | rdev->pm.default_power_state = &rdev->pm.power_state[state_index]; |
|
- | 1806 | state_index++; |
|
- | 1807 | } |
|
- | 1808 | rdev->pm.num_power_states = state_index; |
|
- | 1809 | ||
1393 | args.ucEnable = enable; |
1810 | rdev->pm.current_power_state = rdev->pm.default_power_state; |
1394 | 1811 | rdev->pm.current_clock_mode = |
|
1395 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1812 | rdev->pm.default_power_state->default_clock_mode; |
1396 | } |
1813 | } |
1397 | 1814 | ||
1398 | void radeon_atom_static_pwrmgt_setup(struct radeon_device *rdev, int enable) |
1815 | void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable) |
1399 | { |
1816 | { |
1400 | ENABLE_ASIC_STATIC_PWR_MGT_PS_ALLOCATION args; |
1817 | DYNAMIC_CLOCK_GATING_PS_ALLOCATION args; |
1401 | int index = GetIndexIntoMasterTable(COMMAND, EnableASIC_StaticPwrMgt); |
1818 | int index = GetIndexIntoMasterTable(COMMAND, DynamicClockGating); |
1402 | 1819 | ||
1403 | args.ucEnable = enable; |
1820 | args.ucEnable = enable; |
1404 | 1821 | ||
1405 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1822 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1406 | } |
1823 | } |
1407 | 1824 | ||
1408 | uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev) |
1825 | uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev) |
1409 | { |
1826 | { |
1410 | GET_ENGINE_CLOCK_PS_ALLOCATION args; |
1827 | GET_ENGINE_CLOCK_PS_ALLOCATION args; |
1411 | int index = GetIndexIntoMasterTable(COMMAND, GetEngineClock); |
1828 | int index = GetIndexIntoMasterTable(COMMAND, GetEngineClock); |
1412 | 1829 | ||
1413 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1830 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1414 | return args.ulReturnEngineClock; |
1831 | return args.ulReturnEngineClock; |
1415 | } |
1832 | } |
1416 | 1833 | ||
1417 | uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev) |
1834 | uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev) |
1418 | { |
1835 | { |
1419 | GET_MEMORY_CLOCK_PS_ALLOCATION args; |
1836 | GET_MEMORY_CLOCK_PS_ALLOCATION args; |
1420 | int index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock); |
1837 | int index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock); |
1421 | 1838 | ||
1422 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1839 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1423 | return args.ulReturnMemoryClock; |
1840 | return args.ulReturnMemoryClock; |
1424 | } |
1841 | } |
1425 | 1842 | ||
1426 | void radeon_atom_set_engine_clock(struct radeon_device *rdev, |
1843 | void radeon_atom_set_engine_clock(struct radeon_device *rdev, |
1427 | uint32_t eng_clock) |
1844 | uint32_t eng_clock) |
1428 | { |
1845 | { |
1429 | SET_ENGINE_CLOCK_PS_ALLOCATION args; |
1846 | SET_ENGINE_CLOCK_PS_ALLOCATION args; |
1430 | int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock); |
1847 | int index = GetIndexIntoMasterTable(COMMAND, SetEngineClock); |
1431 | 1848 | ||
1432 | args.ulTargetEngineClock = eng_clock; /* 10 khz */ |
1849 | args.ulTargetEngineClock = eng_clock; /* 10 khz */ |
1433 | 1850 | ||
1434 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1851 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1435 | } |
1852 | } |
1436 | 1853 | ||
1437 | void radeon_atom_set_memory_clock(struct radeon_device *rdev, |
1854 | void radeon_atom_set_memory_clock(struct radeon_device *rdev, |
1438 | uint32_t mem_clock) |
1855 | uint32_t mem_clock) |
1439 | { |
1856 | { |
1440 | SET_MEMORY_CLOCK_PS_ALLOCATION args; |
1857 | SET_MEMORY_CLOCK_PS_ALLOCATION args; |
1441 | int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock); |
1858 | int index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock); |
1442 | 1859 | ||
1443 | if (rdev->flags & RADEON_IS_IGP) |
1860 | if (rdev->flags & RADEON_IS_IGP) |
1444 | return; |
1861 | return; |
1445 | 1862 | ||
1446 | args.ulTargetMemoryClock = mem_clock; /* 10 khz */ |
1863 | args.ulTargetMemoryClock = mem_clock; /* 10 khz */ |
1447 | 1864 | ||
1448 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1865 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
1449 | } |
1866 | } |
1450 | 1867 | ||
1451 | void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev) |
1868 | void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev) |
1452 | { |
1869 | { |
1453 | struct radeon_device *rdev = dev->dev_private; |
1870 | struct radeon_device *rdev = dev->dev_private; |
1454 | uint32_t bios_2_scratch, bios_6_scratch; |
1871 | uint32_t bios_2_scratch, bios_6_scratch; |
1455 | 1872 | ||
1456 | if (rdev->family >= CHIP_R600) { |
1873 | if (rdev->family >= CHIP_R600) { |
1457 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
1874 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
1458 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1875 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1459 | } else { |
1876 | } else { |
1460 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
1877 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
1461 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1878 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1462 | } |
1879 | } |
1463 | 1880 | ||
1464 | /* let the bios control the backlight */ |
1881 | /* let the bios control the backlight */ |
1465 | bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE; |
1882 | bios_2_scratch &= ~ATOM_S2_VRI_BRIGHT_ENABLE; |
1466 | 1883 | ||
1467 | /* tell the bios not to handle mode switching */ |
1884 | /* tell the bios not to handle mode switching */ |
1468 | bios_6_scratch |= (ATOM_S6_ACC_BLOCK_DISPLAY_SWITCH | ATOM_S6_ACC_MODE); |
1885 | bios_6_scratch |= (ATOM_S6_ACC_BLOCK_DISPLAY_SWITCH | ATOM_S6_ACC_MODE); |
1469 | 1886 | ||
1470 | if (rdev->family >= CHIP_R600) { |
1887 | if (rdev->family >= CHIP_R600) { |
1471 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
1888 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
1472 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
1889 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
1473 | } else { |
1890 | } else { |
1474 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
1891 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
1475 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
1892 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
1476 | } |
1893 | } |
1477 | 1894 | ||
1478 | } |
1895 | } |
1479 | 1896 | ||
1480 | void radeon_save_bios_scratch_regs(struct radeon_device *rdev) |
1897 | void radeon_save_bios_scratch_regs(struct radeon_device *rdev) |
1481 | { |
1898 | { |
1482 | uint32_t scratch_reg; |
1899 | uint32_t scratch_reg; |
1483 | int i; |
1900 | int i; |
1484 | 1901 | ||
1485 | if (rdev->family >= CHIP_R600) |
1902 | if (rdev->family >= CHIP_R600) |
1486 | scratch_reg = R600_BIOS_0_SCRATCH; |
1903 | scratch_reg = R600_BIOS_0_SCRATCH; |
1487 | else |
1904 | else |
1488 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
1905 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
1489 | 1906 | ||
1490 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
1907 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
1491 | rdev->bios_scratch[i] = RREG32(scratch_reg + (i * 4)); |
1908 | rdev->bios_scratch[i] = RREG32(scratch_reg + (i * 4)); |
1492 | } |
1909 | } |
1493 | 1910 | ||
1494 | void radeon_restore_bios_scratch_regs(struct radeon_device *rdev) |
1911 | void radeon_restore_bios_scratch_regs(struct radeon_device *rdev) |
1495 | { |
1912 | { |
1496 | uint32_t scratch_reg; |
1913 | uint32_t scratch_reg; |
1497 | int i; |
1914 | int i; |
1498 | 1915 | ||
1499 | if (rdev->family >= CHIP_R600) |
1916 | if (rdev->family >= CHIP_R600) |
1500 | scratch_reg = R600_BIOS_0_SCRATCH; |
1917 | scratch_reg = R600_BIOS_0_SCRATCH; |
1501 | else |
1918 | else |
1502 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
1919 | scratch_reg = RADEON_BIOS_0_SCRATCH; |
1503 | 1920 | ||
1504 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
1921 | for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) |
1505 | WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]); |
1922 | WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]); |
1506 | } |
1923 | } |
1507 | 1924 | ||
1508 | void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock) |
1925 | void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock) |
1509 | { |
1926 | { |
1510 | struct drm_device *dev = encoder->dev; |
1927 | struct drm_device *dev = encoder->dev; |
1511 | struct radeon_device *rdev = dev->dev_private; |
1928 | struct radeon_device *rdev = dev->dev_private; |
1512 | uint32_t bios_6_scratch; |
1929 | uint32_t bios_6_scratch; |
1513 | 1930 | ||
1514 | if (rdev->family >= CHIP_R600) |
1931 | if (rdev->family >= CHIP_R600) |
1515 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1932 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1516 | else |
1933 | else |
1517 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1934 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1518 | 1935 | ||
1519 | if (lock) |
1936 | if (lock) |
1520 | bios_6_scratch |= ATOM_S6_CRITICAL_STATE; |
1937 | bios_6_scratch |= ATOM_S6_CRITICAL_STATE; |
1521 | else |
1938 | else |
1522 | bios_6_scratch &= ~ATOM_S6_CRITICAL_STATE; |
1939 | bios_6_scratch &= ~ATOM_S6_CRITICAL_STATE; |
1523 | 1940 | ||
1524 | if (rdev->family >= CHIP_R600) |
1941 | if (rdev->family >= CHIP_R600) |
1525 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
1942 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
1526 | else |
1943 | else |
1527 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
1944 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
1528 | } |
1945 | } |
1529 | 1946 | ||
1530 | /* at some point we may want to break this out into individual functions */ |
1947 | /* at some point we may want to break this out into individual functions */ |
1531 | void |
1948 | void |
1532 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
1949 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
1533 | struct drm_encoder *encoder, |
1950 | struct drm_encoder *encoder, |
1534 | bool connected) |
1951 | bool connected) |
1535 | { |
1952 | { |
1536 | struct drm_device *dev = connector->dev; |
1953 | struct drm_device *dev = connector->dev; |
1537 | struct radeon_device *rdev = dev->dev_private; |
1954 | struct radeon_device *rdev = dev->dev_private; |
1538 | struct radeon_connector *radeon_connector = |
1955 | struct radeon_connector *radeon_connector = |
1539 | to_radeon_connector(connector); |
1956 | to_radeon_connector(connector); |
1540 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
1957 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
1541 | uint32_t bios_0_scratch, bios_3_scratch, bios_6_scratch; |
1958 | uint32_t bios_0_scratch, bios_3_scratch, bios_6_scratch; |
1542 | 1959 | ||
1543 | if (rdev->family >= CHIP_R600) { |
1960 | if (rdev->family >= CHIP_R600) { |
1544 | bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH); |
1961 | bios_0_scratch = RREG32(R600_BIOS_0_SCRATCH); |
1545 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
1962 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
1546 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1963 | bios_6_scratch = RREG32(R600_BIOS_6_SCRATCH); |
1547 | } else { |
1964 | } else { |
1548 | bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); |
1965 | bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH); |
1549 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
1966 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
1550 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1967 | bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH); |
1551 | } |
1968 | } |
1552 | 1969 | ||
1553 | if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && |
1970 | if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) && |
1554 | (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { |
1971 | (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) { |
1555 | if (connected) { |
1972 | if (connected) { |
1556 | DRM_DEBUG("TV1 connected\n"); |
1973 | DRM_DEBUG("TV1 connected\n"); |
1557 | bios_3_scratch |= ATOM_S3_TV1_ACTIVE; |
1974 | bios_3_scratch |= ATOM_S3_TV1_ACTIVE; |
1558 | bios_6_scratch |= ATOM_S6_ACC_REQ_TV1; |
1975 | bios_6_scratch |= ATOM_S6_ACC_REQ_TV1; |
1559 | } else { |
1976 | } else { |
1560 | DRM_DEBUG("TV1 disconnected\n"); |
1977 | DRM_DEBUG("TV1 disconnected\n"); |
1561 | bios_0_scratch &= ~ATOM_S0_TV1_MASK; |
1978 | bios_0_scratch &= ~ATOM_S0_TV1_MASK; |
1562 | bios_3_scratch &= ~ATOM_S3_TV1_ACTIVE; |
1979 | bios_3_scratch &= ~ATOM_S3_TV1_ACTIVE; |
1563 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_TV1; |
1980 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_TV1; |
1564 | } |
1981 | } |
1565 | } |
1982 | } |
1566 | if ((radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) && |
1983 | if ((radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) && |
1567 | (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT)) { |
1984 | (radeon_connector->devices & ATOM_DEVICE_CV_SUPPORT)) { |
1568 | if (connected) { |
1985 | if (connected) { |
1569 | DRM_DEBUG("CV connected\n"); |
1986 | DRM_DEBUG("CV connected\n"); |
1570 | bios_3_scratch |= ATOM_S3_CV_ACTIVE; |
1987 | bios_3_scratch |= ATOM_S3_CV_ACTIVE; |
1571 | bios_6_scratch |= ATOM_S6_ACC_REQ_CV; |
1988 | bios_6_scratch |= ATOM_S6_ACC_REQ_CV; |
1572 | } else { |
1989 | } else { |
1573 | DRM_DEBUG("CV disconnected\n"); |
1990 | DRM_DEBUG("CV disconnected\n"); |
1574 | bios_0_scratch &= ~ATOM_S0_CV_MASK; |
1991 | bios_0_scratch &= ~ATOM_S0_CV_MASK; |
1575 | bios_3_scratch &= ~ATOM_S3_CV_ACTIVE; |
1992 | bios_3_scratch &= ~ATOM_S3_CV_ACTIVE; |
1576 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CV; |
1993 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CV; |
1577 | } |
1994 | } |
1578 | } |
1995 | } |
1579 | if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && |
1996 | if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) && |
1580 | (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { |
1997 | (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) { |
1581 | if (connected) { |
1998 | if (connected) { |
1582 | DRM_DEBUG("LCD1 connected\n"); |
1999 | DRM_DEBUG("LCD1 connected\n"); |
1583 | bios_0_scratch |= ATOM_S0_LCD1; |
2000 | bios_0_scratch |= ATOM_S0_LCD1; |
1584 | bios_3_scratch |= ATOM_S3_LCD1_ACTIVE; |
2001 | bios_3_scratch |= ATOM_S3_LCD1_ACTIVE; |
1585 | bios_6_scratch |= ATOM_S6_ACC_REQ_LCD1; |
2002 | bios_6_scratch |= ATOM_S6_ACC_REQ_LCD1; |
1586 | } else { |
2003 | } else { |
1587 | DRM_DEBUG("LCD1 disconnected\n"); |
2004 | DRM_DEBUG("LCD1 disconnected\n"); |
1588 | bios_0_scratch &= ~ATOM_S0_LCD1; |
2005 | bios_0_scratch &= ~ATOM_S0_LCD1; |
1589 | bios_3_scratch &= ~ATOM_S3_LCD1_ACTIVE; |
2006 | bios_3_scratch &= ~ATOM_S3_LCD1_ACTIVE; |
1590 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_LCD1; |
2007 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_LCD1; |
1591 | } |
2008 | } |
1592 | } |
2009 | } |
1593 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && |
2010 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) && |
1594 | (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { |
2011 | (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) { |
1595 | if (connected) { |
2012 | if (connected) { |
1596 | DRM_DEBUG("CRT1 connected\n"); |
2013 | DRM_DEBUG("CRT1 connected\n"); |
1597 | bios_0_scratch |= ATOM_S0_CRT1_COLOR; |
2014 | bios_0_scratch |= ATOM_S0_CRT1_COLOR; |
1598 | bios_3_scratch |= ATOM_S3_CRT1_ACTIVE; |
2015 | bios_3_scratch |= ATOM_S3_CRT1_ACTIVE; |
1599 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT1; |
2016 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT1; |
1600 | } else { |
2017 | } else { |
1601 | DRM_DEBUG("CRT1 disconnected\n"); |
2018 | DRM_DEBUG("CRT1 disconnected\n"); |
1602 | bios_0_scratch &= ~ATOM_S0_CRT1_MASK; |
2019 | bios_0_scratch &= ~ATOM_S0_CRT1_MASK; |
1603 | bios_3_scratch &= ~ATOM_S3_CRT1_ACTIVE; |
2020 | bios_3_scratch &= ~ATOM_S3_CRT1_ACTIVE; |
1604 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT1; |
2021 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT1; |
1605 | } |
2022 | } |
1606 | } |
2023 | } |
1607 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && |
2024 | if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) && |
1608 | (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { |
2025 | (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) { |
1609 | if (connected) { |
2026 | if (connected) { |
1610 | DRM_DEBUG("CRT2 connected\n"); |
2027 | DRM_DEBUG("CRT2 connected\n"); |
1611 | bios_0_scratch |= ATOM_S0_CRT2_COLOR; |
2028 | bios_0_scratch |= ATOM_S0_CRT2_COLOR; |
1612 | bios_3_scratch |= ATOM_S3_CRT2_ACTIVE; |
2029 | bios_3_scratch |= ATOM_S3_CRT2_ACTIVE; |
1613 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT2; |
2030 | bios_6_scratch |= ATOM_S6_ACC_REQ_CRT2; |
1614 | } else { |
2031 | } else { |
1615 | DRM_DEBUG("CRT2 disconnected\n"); |
2032 | DRM_DEBUG("CRT2 disconnected\n"); |
1616 | bios_0_scratch &= ~ATOM_S0_CRT2_MASK; |
2033 | bios_0_scratch &= ~ATOM_S0_CRT2_MASK; |
1617 | bios_3_scratch &= ~ATOM_S3_CRT2_ACTIVE; |
2034 | bios_3_scratch &= ~ATOM_S3_CRT2_ACTIVE; |
1618 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT2; |
2035 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_CRT2; |
1619 | } |
2036 | } |
1620 | } |
2037 | } |
1621 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && |
2038 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) && |
1622 | (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { |
2039 | (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) { |
1623 | if (connected) { |
2040 | if (connected) { |
1624 | DRM_DEBUG("DFP1 connected\n"); |
2041 | DRM_DEBUG("DFP1 connected\n"); |
1625 | bios_0_scratch |= ATOM_S0_DFP1; |
2042 | bios_0_scratch |= ATOM_S0_DFP1; |
1626 | bios_3_scratch |= ATOM_S3_DFP1_ACTIVE; |
2043 | bios_3_scratch |= ATOM_S3_DFP1_ACTIVE; |
1627 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP1; |
2044 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP1; |
1628 | } else { |
2045 | } else { |
1629 | DRM_DEBUG("DFP1 disconnected\n"); |
2046 | DRM_DEBUG("DFP1 disconnected\n"); |
1630 | bios_0_scratch &= ~ATOM_S0_DFP1; |
2047 | bios_0_scratch &= ~ATOM_S0_DFP1; |
1631 | bios_3_scratch &= ~ATOM_S3_DFP1_ACTIVE; |
2048 | bios_3_scratch &= ~ATOM_S3_DFP1_ACTIVE; |
1632 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP1; |
2049 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP1; |
1633 | } |
2050 | } |
1634 | } |
2051 | } |
1635 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && |
2052 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) && |
1636 | (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
2053 | (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) { |
1637 | if (connected) { |
2054 | if (connected) { |
1638 | DRM_DEBUG("DFP2 connected\n"); |
2055 | DRM_DEBUG("DFP2 connected\n"); |
1639 | bios_0_scratch |= ATOM_S0_DFP2; |
2056 | bios_0_scratch |= ATOM_S0_DFP2; |
1640 | bios_3_scratch |= ATOM_S3_DFP2_ACTIVE; |
2057 | bios_3_scratch |= ATOM_S3_DFP2_ACTIVE; |
1641 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP2; |
2058 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP2; |
1642 | } else { |
2059 | } else { |
1643 | DRM_DEBUG("DFP2 disconnected\n"); |
2060 | DRM_DEBUG("DFP2 disconnected\n"); |
1644 | bios_0_scratch &= ~ATOM_S0_DFP2; |
2061 | bios_0_scratch &= ~ATOM_S0_DFP2; |
1645 | bios_3_scratch &= ~ATOM_S3_DFP2_ACTIVE; |
2062 | bios_3_scratch &= ~ATOM_S3_DFP2_ACTIVE; |
1646 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP2; |
2063 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP2; |
1647 | } |
2064 | } |
1648 | } |
2065 | } |
1649 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) && |
2066 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) && |
1650 | (radeon_connector->devices & ATOM_DEVICE_DFP3_SUPPORT)) { |
2067 | (radeon_connector->devices & ATOM_DEVICE_DFP3_SUPPORT)) { |
1651 | if (connected) { |
2068 | if (connected) { |
1652 | DRM_DEBUG("DFP3 connected\n"); |
2069 | DRM_DEBUG("DFP3 connected\n"); |
1653 | bios_0_scratch |= ATOM_S0_DFP3; |
2070 | bios_0_scratch |= ATOM_S0_DFP3; |
1654 | bios_3_scratch |= ATOM_S3_DFP3_ACTIVE; |
2071 | bios_3_scratch |= ATOM_S3_DFP3_ACTIVE; |
1655 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP3; |
2072 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP3; |
1656 | } else { |
2073 | } else { |
1657 | DRM_DEBUG("DFP3 disconnected\n"); |
2074 | DRM_DEBUG("DFP3 disconnected\n"); |
1658 | bios_0_scratch &= ~ATOM_S0_DFP3; |
2075 | bios_0_scratch &= ~ATOM_S0_DFP3; |
1659 | bios_3_scratch &= ~ATOM_S3_DFP3_ACTIVE; |
2076 | bios_3_scratch &= ~ATOM_S3_DFP3_ACTIVE; |
1660 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP3; |
2077 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP3; |
1661 | } |
2078 | } |
1662 | } |
2079 | } |
1663 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) && |
2080 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) && |
1664 | (radeon_connector->devices & ATOM_DEVICE_DFP4_SUPPORT)) { |
2081 | (radeon_connector->devices & ATOM_DEVICE_DFP4_SUPPORT)) { |
1665 | if (connected) { |
2082 | if (connected) { |
1666 | DRM_DEBUG("DFP4 connected\n"); |
2083 | DRM_DEBUG("DFP4 connected\n"); |
1667 | bios_0_scratch |= ATOM_S0_DFP4; |
2084 | bios_0_scratch |= ATOM_S0_DFP4; |
1668 | bios_3_scratch |= ATOM_S3_DFP4_ACTIVE; |
2085 | bios_3_scratch |= ATOM_S3_DFP4_ACTIVE; |
1669 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP4; |
2086 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP4; |
1670 | } else { |
2087 | } else { |
1671 | DRM_DEBUG("DFP4 disconnected\n"); |
2088 | DRM_DEBUG("DFP4 disconnected\n"); |
1672 | bios_0_scratch &= ~ATOM_S0_DFP4; |
2089 | bios_0_scratch &= ~ATOM_S0_DFP4; |
1673 | bios_3_scratch &= ~ATOM_S3_DFP4_ACTIVE; |
2090 | bios_3_scratch &= ~ATOM_S3_DFP4_ACTIVE; |
1674 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP4; |
2091 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP4; |
1675 | } |
2092 | } |
1676 | } |
2093 | } |
1677 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) && |
2094 | if ((radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) && |
1678 | (radeon_connector->devices & ATOM_DEVICE_DFP5_SUPPORT)) { |
2095 | (radeon_connector->devices & ATOM_DEVICE_DFP5_SUPPORT)) { |
1679 | if (connected) { |
2096 | if (connected) { |
1680 | DRM_DEBUG("DFP5 connected\n"); |
2097 | DRM_DEBUG("DFP5 connected\n"); |
1681 | bios_0_scratch |= ATOM_S0_DFP5; |
2098 | bios_0_scratch |= ATOM_S0_DFP5; |
1682 | bios_3_scratch |= ATOM_S3_DFP5_ACTIVE; |
2099 | bios_3_scratch |= ATOM_S3_DFP5_ACTIVE; |
1683 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP5; |
2100 | bios_6_scratch |= ATOM_S6_ACC_REQ_DFP5; |
1684 | } else { |
2101 | } else { |
1685 | DRM_DEBUG("DFP5 disconnected\n"); |
2102 | DRM_DEBUG("DFP5 disconnected\n"); |
1686 | bios_0_scratch &= ~ATOM_S0_DFP5; |
2103 | bios_0_scratch &= ~ATOM_S0_DFP5; |
1687 | bios_3_scratch &= ~ATOM_S3_DFP5_ACTIVE; |
2104 | bios_3_scratch &= ~ATOM_S3_DFP5_ACTIVE; |
1688 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP5; |
2105 | bios_6_scratch &= ~ATOM_S6_ACC_REQ_DFP5; |
1689 | } |
2106 | } |
1690 | } |
2107 | } |
1691 | 2108 | ||
1692 | if (rdev->family >= CHIP_R600) { |
2109 | if (rdev->family >= CHIP_R600) { |
1693 | WREG32(R600_BIOS_0_SCRATCH, bios_0_scratch); |
2110 | WREG32(R600_BIOS_0_SCRATCH, bios_0_scratch); |
1694 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
2111 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
1695 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
2112 | WREG32(R600_BIOS_6_SCRATCH, bios_6_scratch); |
1696 | } else { |
2113 | } else { |
1697 | WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); |
2114 | WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch); |
1698 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
2115 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
1699 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
2116 | WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch); |
1700 | } |
2117 | } |
1701 | } |
2118 | } |
1702 | 2119 | ||
1703 | void |
2120 | void |
1704 | radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) |
2121 | radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc) |
1705 | { |
2122 | { |
1706 | struct drm_device *dev = encoder->dev; |
2123 | struct drm_device *dev = encoder->dev; |
1707 | struct radeon_device *rdev = dev->dev_private; |
2124 | struct radeon_device *rdev = dev->dev_private; |
1708 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
2125 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
1709 | uint32_t bios_3_scratch; |
2126 | uint32_t bios_3_scratch; |
1710 | 2127 | ||
1711 | if (rdev->family >= CHIP_R600) |
2128 | if (rdev->family >= CHIP_R600) |
1712 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
2129 | bios_3_scratch = RREG32(R600_BIOS_3_SCRATCH); |
1713 | else |
2130 | else |
1714 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
2131 | bios_3_scratch = RREG32(RADEON_BIOS_3_SCRATCH); |
1715 | 2132 | ||
1716 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
2133 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
1717 | bios_3_scratch &= ~ATOM_S3_TV1_CRTC_ACTIVE; |
2134 | bios_3_scratch &= ~ATOM_S3_TV1_CRTC_ACTIVE; |
1718 | bios_3_scratch |= (crtc << 18); |
2135 | bios_3_scratch |= (crtc << 18); |
1719 | } |
2136 | } |
1720 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
2137 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
1721 | bios_3_scratch &= ~ATOM_S3_CV_CRTC_ACTIVE; |
2138 | bios_3_scratch &= ~ATOM_S3_CV_CRTC_ACTIVE; |
1722 | bios_3_scratch |= (crtc << 24); |
2139 | bios_3_scratch |= (crtc << 24); |
1723 | } |
2140 | } |
1724 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
2141 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
1725 | bios_3_scratch &= ~ATOM_S3_CRT1_CRTC_ACTIVE; |
2142 | bios_3_scratch &= ~ATOM_S3_CRT1_CRTC_ACTIVE; |
1726 | bios_3_scratch |= (crtc << 16); |
2143 | bios_3_scratch |= (crtc << 16); |
1727 | } |
2144 | } |
1728 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
2145 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
1729 | bios_3_scratch &= ~ATOM_S3_CRT2_CRTC_ACTIVE; |
2146 | bios_3_scratch &= ~ATOM_S3_CRT2_CRTC_ACTIVE; |
1730 | bios_3_scratch |= (crtc << 20); |
2147 | bios_3_scratch |= (crtc << 20); |
1731 | } |
2148 | } |
1732 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
2149 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
1733 | bios_3_scratch &= ~ATOM_S3_LCD1_CRTC_ACTIVE; |
2150 | bios_3_scratch &= ~ATOM_S3_LCD1_CRTC_ACTIVE; |
1734 | bios_3_scratch |= (crtc << 17); |
2151 | bios_3_scratch |= (crtc << 17); |
1735 | } |
2152 | } |
1736 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
2153 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
1737 | bios_3_scratch &= ~ATOM_S3_DFP1_CRTC_ACTIVE; |
2154 | bios_3_scratch &= ~ATOM_S3_DFP1_CRTC_ACTIVE; |
1738 | bios_3_scratch |= (crtc << 19); |
2155 | bios_3_scratch |= (crtc << 19); |
1739 | } |
2156 | } |
1740 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
2157 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
1741 | bios_3_scratch &= ~ATOM_S3_DFP2_CRTC_ACTIVE; |
2158 | bios_3_scratch &= ~ATOM_S3_DFP2_CRTC_ACTIVE; |
1742 | bios_3_scratch |= (crtc << 23); |
2159 | bios_3_scratch |= (crtc << 23); |
1743 | } |
2160 | } |
1744 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
2161 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
1745 | bios_3_scratch &= ~ATOM_S3_DFP3_CRTC_ACTIVE; |
2162 | bios_3_scratch &= ~ATOM_S3_DFP3_CRTC_ACTIVE; |
1746 | bios_3_scratch |= (crtc << 25); |
2163 | bios_3_scratch |= (crtc << 25); |
1747 | } |
2164 | } |
1748 | 2165 | ||
1749 | if (rdev->family >= CHIP_R600) |
2166 | if (rdev->family >= CHIP_R600) |
1750 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
2167 | WREG32(R600_BIOS_3_SCRATCH, bios_3_scratch); |
1751 | else |
2168 | else |
1752 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
2169 | WREG32(RADEON_BIOS_3_SCRATCH, bios_3_scratch); |
1753 | } |
2170 | } |
1754 | 2171 | ||
1755 | void |
2172 | void |
1756 | radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) |
2173 | radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on) |
1757 | { |
2174 | { |
1758 | struct drm_device *dev = encoder->dev; |
2175 | struct drm_device *dev = encoder->dev; |
1759 | struct radeon_device *rdev = dev->dev_private; |
2176 | struct radeon_device *rdev = dev->dev_private; |
1760 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
2177 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
1761 | uint32_t bios_2_scratch; |
2178 | uint32_t bios_2_scratch; |
1762 | 2179 | ||
1763 | if (rdev->family >= CHIP_R600) |
2180 | if (rdev->family >= CHIP_R600) |
1764 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
2181 | bios_2_scratch = RREG32(R600_BIOS_2_SCRATCH); |
1765 | else |
2182 | else |
1766 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
2183 | bios_2_scratch = RREG32(RADEON_BIOS_2_SCRATCH); |
1767 | 2184 | ||
1768 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
2185 | if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) { |
1769 | if (on) |
2186 | if (on) |
1770 | bios_2_scratch &= ~ATOM_S2_TV1_DPMS_STATE; |
2187 | bios_2_scratch &= ~ATOM_S2_TV1_DPMS_STATE; |
1771 | else |
2188 | else |
1772 | bios_2_scratch |= ATOM_S2_TV1_DPMS_STATE; |
2189 | bios_2_scratch |= ATOM_S2_TV1_DPMS_STATE; |
1773 | } |
2190 | } |
1774 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
2191 | if (radeon_encoder->devices & ATOM_DEVICE_CV_SUPPORT) { |
1775 | if (on) |
2192 | if (on) |
1776 | bios_2_scratch &= ~ATOM_S2_CV_DPMS_STATE; |
2193 | bios_2_scratch &= ~ATOM_S2_CV_DPMS_STATE; |
1777 | else |
2194 | else |
1778 | bios_2_scratch |= ATOM_S2_CV_DPMS_STATE; |
2195 | bios_2_scratch |= ATOM_S2_CV_DPMS_STATE; |
1779 | } |
2196 | } |
1780 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
2197 | if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) { |
1781 | if (on) |
2198 | if (on) |
1782 | bios_2_scratch &= ~ATOM_S2_CRT1_DPMS_STATE; |
2199 | bios_2_scratch &= ~ATOM_S2_CRT1_DPMS_STATE; |
1783 | else |
2200 | else |
1784 | bios_2_scratch |= ATOM_S2_CRT1_DPMS_STATE; |
2201 | bios_2_scratch |= ATOM_S2_CRT1_DPMS_STATE; |
1785 | } |
2202 | } |
1786 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
2203 | if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) { |
1787 | if (on) |
2204 | if (on) |
1788 | bios_2_scratch &= ~ATOM_S2_CRT2_DPMS_STATE; |
2205 | bios_2_scratch &= ~ATOM_S2_CRT2_DPMS_STATE; |
1789 | else |
2206 | else |
1790 | bios_2_scratch |= ATOM_S2_CRT2_DPMS_STATE; |
2207 | bios_2_scratch |= ATOM_S2_CRT2_DPMS_STATE; |
1791 | } |
2208 | } |
1792 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
2209 | if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { |
1793 | if (on) |
2210 | if (on) |
1794 | bios_2_scratch &= ~ATOM_S2_LCD1_DPMS_STATE; |
2211 | bios_2_scratch &= ~ATOM_S2_LCD1_DPMS_STATE; |
1795 | else |
2212 | else |
1796 | bios_2_scratch |= ATOM_S2_LCD1_DPMS_STATE; |
2213 | bios_2_scratch |= ATOM_S2_LCD1_DPMS_STATE; |
1797 | } |
2214 | } |
1798 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
2215 | if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) { |
1799 | if (on) |
2216 | if (on) |
1800 | bios_2_scratch &= ~ATOM_S2_DFP1_DPMS_STATE; |
2217 | bios_2_scratch &= ~ATOM_S2_DFP1_DPMS_STATE; |
1801 | else |
2218 | else |
1802 | bios_2_scratch |= ATOM_S2_DFP1_DPMS_STATE; |
2219 | bios_2_scratch |= ATOM_S2_DFP1_DPMS_STATE; |
1803 | } |
2220 | } |
1804 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
2221 | if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) { |
1805 | if (on) |
2222 | if (on) |
1806 | bios_2_scratch &= ~ATOM_S2_DFP2_DPMS_STATE; |
2223 | bios_2_scratch &= ~ATOM_S2_DFP2_DPMS_STATE; |
1807 | else |
2224 | else |
1808 | bios_2_scratch |= ATOM_S2_DFP2_DPMS_STATE; |
2225 | bios_2_scratch |= ATOM_S2_DFP2_DPMS_STATE; |
1809 | } |
2226 | } |
1810 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
2227 | if (radeon_encoder->devices & ATOM_DEVICE_DFP3_SUPPORT) { |
1811 | if (on) |
2228 | if (on) |
1812 | bios_2_scratch &= ~ATOM_S2_DFP3_DPMS_STATE; |
2229 | bios_2_scratch &= ~ATOM_S2_DFP3_DPMS_STATE; |
1813 | else |
2230 | else |
1814 | bios_2_scratch |= ATOM_S2_DFP3_DPMS_STATE; |
2231 | bios_2_scratch |= ATOM_S2_DFP3_DPMS_STATE; |
1815 | } |
2232 | } |
1816 | if (radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) { |
2233 | if (radeon_encoder->devices & ATOM_DEVICE_DFP4_SUPPORT) { |
1817 | if (on) |
2234 | if (on) |
1818 | bios_2_scratch &= ~ATOM_S2_DFP4_DPMS_STATE; |
2235 | bios_2_scratch &= ~ATOM_S2_DFP4_DPMS_STATE; |
1819 | else |
2236 | else |
1820 | bios_2_scratch |= ATOM_S2_DFP4_DPMS_STATE; |
2237 | bios_2_scratch |= ATOM_S2_DFP4_DPMS_STATE; |
1821 | } |
2238 | } |
1822 | if (radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) { |
2239 | if (radeon_encoder->devices & ATOM_DEVICE_DFP5_SUPPORT) { |
1823 | if (on) |
2240 | if (on) |
1824 | bios_2_scratch &= ~ATOM_S2_DFP5_DPMS_STATE; |
2241 | bios_2_scratch &= ~ATOM_S2_DFP5_DPMS_STATE; |
1825 | else |
2242 | else |
1826 | bios_2_scratch |= ATOM_S2_DFP5_DPMS_STATE; |
2243 | bios_2_scratch |= ATOM_S2_DFP5_DPMS_STATE; |
1827 | } |
2244 | } |
1828 | 2245 | ||
1829 | if (rdev->family >= CHIP_R600) |
2246 | if (rdev->family >= CHIP_R600) |
1830 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
2247 | WREG32(R600_BIOS_2_SCRATCH, bios_2_scratch); |
1831 | else |
2248 | else |
1832 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
2249 | WREG32(RADEON_BIOS_2_SCRATCH, bios_2_scratch); |
1833 | }><>><>><>><>><>><>><>><>>>><>><>><>><>><>><>><>>><>><>><>>>>>>><>><>><>><>><>><>><>>= |
2250 | }><>><>><>><>><>><>><>><>>>><>><>><>>>>>><>><>><>><>><>><>><>>><>><>><>>>>>>><>><>><>><>><>><>><>>= |
1834 | >>>>>><>><>><>><>><>><>><>>><>><>><>><>><>><>><>><>> |
2251 | >>>>>><>><>><>><>><>><>><>>><>><>><>><>><>><>><>><>> |