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 "drm_edid.h" |
27 | #include "drm_edid.h" |
28 | #include "drm_crtc_helper.h" |
28 | #include "drm_crtc_helper.h" |
29 | #include "drm_fb_helper.h" |
29 | #include "drm_fb_helper.h" |
30 | #include "radeon_drm.h" |
30 | #include "radeon_drm.h" |
31 | #include "radeon.h" |
31 | #include "radeon.h" |
32 | #include "atom.h" |
32 | #include "atom.h" |
33 | 33 | ||
34 | extern void |
34 | extern void |
35 | radeon_combios_connected_scratch_regs(struct drm_connector *connector, |
35 | radeon_combios_connected_scratch_regs(struct drm_connector *connector, |
36 | struct drm_encoder *encoder, |
36 | struct drm_encoder *encoder, |
37 | bool connected); |
37 | bool connected); |
38 | extern void |
38 | extern void |
39 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
39 | radeon_atombios_connected_scratch_regs(struct drm_connector *connector, |
40 | struct drm_encoder *encoder, |
40 | struct drm_encoder *encoder, |
41 | bool connected); |
41 | bool connected); |
42 | 42 | ||
43 | void radeon_connector_hotplug(struct drm_connector *connector) |
43 | void radeon_connector_hotplug(struct drm_connector *connector) |
44 | { |
44 | { |
45 | struct drm_device *dev = connector->dev; |
45 | struct drm_device *dev = connector->dev; |
46 | struct radeon_device *rdev = dev->dev_private; |
46 | struct radeon_device *rdev = dev->dev_private; |
47 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
47 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
48 | 48 | ||
49 | if (radeon_connector->hpd.hpd != RADEON_HPD_NONE) |
49 | if (radeon_connector->hpd.hpd != RADEON_HPD_NONE) |
50 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
50 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
51 | 51 | ||
52 | if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || |
52 | if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || |
53 | (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) { |
53 | (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) { |
54 | if ((radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
54 | if ((radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
55 | (radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_eDP)) { |
55 | (radeon_dp_getsinktype(radeon_connector) == CONNECTOR_OBJECT_ID_eDP)) { |
56 | if (radeon_dp_needs_link_train(radeon_connector)) { |
56 | if (radeon_dp_needs_link_train(radeon_connector)) { |
57 | if (connector->encoder) |
57 | if (connector->encoder) |
58 | dp_link_train(connector->encoder, connector); |
58 | dp_link_train(connector->encoder, connector); |
59 | } |
59 | } |
60 | } |
60 | } |
61 | } |
61 | } |
62 | 62 | ||
63 | } |
63 | } |
64 | 64 | ||
65 | static void radeon_property_change_mode(struct drm_encoder *encoder) |
65 | static void radeon_property_change_mode(struct drm_encoder *encoder) |
66 | { |
66 | { |
67 | struct drm_crtc *crtc = encoder->crtc; |
67 | struct drm_crtc *crtc = encoder->crtc; |
68 | 68 | ||
69 | if (crtc && crtc->enabled) { |
69 | if (crtc && crtc->enabled) { |
70 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
70 | drm_crtc_helper_set_mode(crtc, &crtc->mode, |
71 | crtc->x, crtc->y, crtc->fb); |
71 | crtc->x, crtc->y, crtc->fb); |
72 | } |
72 | } |
73 | } |
73 | } |
74 | static void |
74 | static void |
75 | radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) |
75 | radeon_connector_update_scratch_regs(struct drm_connector *connector, enum drm_connector_status status) |
76 | { |
76 | { |
77 | struct drm_device *dev = connector->dev; |
77 | struct drm_device *dev = connector->dev; |
78 | struct radeon_device *rdev = dev->dev_private; |
78 | struct radeon_device *rdev = dev->dev_private; |
79 | struct drm_encoder *best_encoder = NULL; |
79 | struct drm_encoder *best_encoder = NULL; |
80 | struct drm_encoder *encoder = NULL; |
80 | struct drm_encoder *encoder = NULL; |
81 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
81 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
82 | struct drm_mode_object *obj; |
82 | struct drm_mode_object *obj; |
83 | bool connected; |
83 | bool connected; |
84 | int i; |
84 | int i; |
85 | 85 | ||
86 | best_encoder = connector_funcs->best_encoder(connector); |
86 | best_encoder = connector_funcs->best_encoder(connector); |
87 | 87 | ||
88 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
88 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
89 | if (connector->encoder_ids[i] == 0) |
89 | if (connector->encoder_ids[i] == 0) |
90 | break; |
90 | break; |
91 | 91 | ||
92 | obj = drm_mode_object_find(connector->dev, |
92 | obj = drm_mode_object_find(connector->dev, |
93 | connector->encoder_ids[i], |
93 | connector->encoder_ids[i], |
94 | DRM_MODE_OBJECT_ENCODER); |
94 | DRM_MODE_OBJECT_ENCODER); |
95 | if (!obj) |
95 | if (!obj) |
96 | continue; |
96 | continue; |
97 | 97 | ||
98 | encoder = obj_to_encoder(obj); |
98 | encoder = obj_to_encoder(obj); |
99 | 99 | ||
100 | if ((encoder == best_encoder) && (status == connector_status_connected)) |
100 | if ((encoder == best_encoder) && (status == connector_status_connected)) |
101 | connected = true; |
101 | connected = true; |
102 | else |
102 | else |
103 | connected = false; |
103 | connected = false; |
104 | 104 | ||
105 | if (rdev->is_atom_bios) |
105 | if (rdev->is_atom_bios) |
106 | radeon_atombios_connected_scratch_regs(connector, encoder, connected); |
106 | radeon_atombios_connected_scratch_regs(connector, encoder, connected); |
107 | else |
107 | else |
108 | radeon_combios_connected_scratch_regs(connector, encoder, connected); |
108 | radeon_combios_connected_scratch_regs(connector, encoder, connected); |
109 | 109 | ||
110 | } |
110 | } |
111 | } |
111 | } |
112 | 112 | ||
113 | struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) |
113 | struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, int encoder_type) |
114 | { |
114 | { |
115 | struct drm_mode_object *obj; |
115 | struct drm_mode_object *obj; |
116 | struct drm_encoder *encoder; |
116 | struct drm_encoder *encoder; |
117 | int i; |
117 | int i; |
118 | 118 | ||
119 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
119 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
120 | if (connector->encoder_ids[i] == 0) |
120 | if (connector->encoder_ids[i] == 0) |
121 | break; |
121 | break; |
122 | 122 | ||
123 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
123 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
124 | if (!obj) |
124 | if (!obj) |
125 | continue; |
125 | continue; |
126 | 126 | ||
127 | encoder = obj_to_encoder(obj); |
127 | encoder = obj_to_encoder(obj); |
128 | if (encoder->encoder_type == encoder_type) |
128 | if (encoder->encoder_type == encoder_type) |
129 | return encoder; |
129 | return encoder; |
130 | } |
130 | } |
131 | return NULL; |
131 | return NULL; |
132 | } |
132 | } |
133 | 133 | ||
134 | struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) |
134 | struct drm_encoder *radeon_best_single_encoder(struct drm_connector *connector) |
135 | { |
135 | { |
136 | int enc_id = connector->encoder_ids[0]; |
136 | int enc_id = connector->encoder_ids[0]; |
137 | struct drm_mode_object *obj; |
137 | struct drm_mode_object *obj; |
138 | struct drm_encoder *encoder; |
138 | struct drm_encoder *encoder; |
139 | 139 | ||
140 | /* pick the encoder ids */ |
140 | /* pick the encoder ids */ |
141 | if (enc_id) { |
141 | if (enc_id) { |
142 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
142 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
143 | if (!obj) |
143 | if (!obj) |
144 | return NULL; |
144 | return NULL; |
145 | encoder = obj_to_encoder(obj); |
145 | encoder = obj_to_encoder(obj); |
146 | return encoder; |
146 | return encoder; |
147 | } |
147 | } |
148 | return NULL; |
148 | return NULL; |
149 | } |
149 | } |
150 | 150 | ||
151 | /* |
151 | /* |
152 | * radeon_connector_analog_encoder_conflict_solve |
152 | * radeon_connector_analog_encoder_conflict_solve |
153 | * - search for other connectors sharing this encoder |
153 | * - search for other connectors sharing this encoder |
154 | * if priority is true, then set them disconnected if this is connected |
154 | * if priority is true, then set them disconnected if this is connected |
155 | * if priority is false, set us disconnected if they are connected |
155 | * if priority is false, set us disconnected if they are connected |
156 | */ |
156 | */ |
157 | static enum drm_connector_status |
157 | static enum drm_connector_status |
158 | radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, |
158 | radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector, |
159 | struct drm_encoder *encoder, |
159 | struct drm_encoder *encoder, |
160 | enum drm_connector_status current_status, |
160 | enum drm_connector_status current_status, |
161 | bool priority) |
161 | bool priority) |
162 | { |
162 | { |
163 | struct drm_device *dev = connector->dev; |
163 | struct drm_device *dev = connector->dev; |
164 | struct drm_connector *conflict; |
164 | struct drm_connector *conflict; |
165 | int i; |
165 | int i; |
166 | 166 | ||
167 | list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { |
167 | list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { |
168 | if (conflict == connector) |
168 | if (conflict == connector) |
169 | continue; |
169 | continue; |
170 | 170 | ||
171 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
171 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
172 | if (conflict->encoder_ids[i] == 0) |
172 | if (conflict->encoder_ids[i] == 0) |
173 | break; |
173 | break; |
174 | 174 | ||
175 | /* if the IDs match */ |
175 | /* if the IDs match */ |
176 | if (conflict->encoder_ids[i] == encoder->base.id) { |
176 | if (conflict->encoder_ids[i] == encoder->base.id) { |
177 | if (conflict->status != connector_status_connected) |
177 | if (conflict->status != connector_status_connected) |
178 | continue; |
178 | continue; |
179 | 179 | ||
180 | if (priority == true) { |
180 | if (priority == true) { |
181 | DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); |
181 | DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); |
182 | DRM_INFO("in favor of %s\n", drm_get_connector_name(connector)); |
182 | DRM_INFO("in favor of %s\n", drm_get_connector_name(connector)); |
183 | conflict->status = connector_status_disconnected; |
183 | conflict->status = connector_status_disconnected; |
184 | radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); |
184 | radeon_connector_update_scratch_regs(conflict, connector_status_disconnected); |
185 | } else { |
185 | } else { |
186 | DRM_INFO("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); |
186 | DRM_INFO("2: conflicting encoders switching off %s\n", drm_get_connector_name(connector)); |
187 | DRM_INFO("in favor of %s\n", drm_get_connector_name(conflict)); |
187 | DRM_INFO("in favor of %s\n", drm_get_connector_name(conflict)); |
188 | current_status = connector_status_disconnected; |
188 | current_status = connector_status_disconnected; |
189 | } |
189 | } |
190 | break; |
190 | break; |
191 | } |
191 | } |
192 | } |
192 | } |
193 | } |
193 | } |
194 | return current_status; |
194 | return current_status; |
195 | 195 | ||
196 | } |
196 | } |
197 | 197 | ||
198 | static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) |
198 | static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encoder) |
199 | { |
199 | { |
200 | struct drm_device *dev = encoder->dev; |
200 | struct drm_device *dev = encoder->dev; |
201 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
201 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
202 | struct drm_display_mode *mode = NULL; |
202 | struct drm_display_mode *mode = NULL; |
203 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
203 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
204 | 204 | ||
205 | if (native_mode->hdisplay != 0 && |
205 | if (native_mode->hdisplay != 0 && |
206 | native_mode->vdisplay != 0 && |
206 | native_mode->vdisplay != 0 && |
207 | native_mode->clock != 0) { |
207 | native_mode->clock != 0) { |
208 | mode = drm_mode_duplicate(dev, native_mode); |
208 | mode = drm_mode_duplicate(dev, native_mode); |
209 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
209 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
210 | drm_mode_set_name(mode); |
210 | drm_mode_set_name(mode); |
211 | 211 | ||
212 | DRM_DEBUG("Adding native panel mode %s\n", mode->name); |
212 | DRM_DEBUG("Adding native panel mode %s\n", mode->name); |
213 | } else if (native_mode->hdisplay != 0 && |
213 | } else if (native_mode->hdisplay != 0 && |
214 | native_mode->vdisplay != 0) { |
214 | native_mode->vdisplay != 0) { |
215 | /* mac laptops without an edid */ |
215 | /* mac laptops without an edid */ |
216 | /* Note that this is not necessarily the exact panel mode, |
216 | /* Note that this is not necessarily the exact panel mode, |
217 | * but an approximation based on the cvt formula. For these |
217 | * but an approximation based on the cvt formula. For these |
218 | * systems we should ideally read the mode info out of the |
218 | * systems we should ideally read the mode info out of the |
219 | * registers or add a mode table, but this works and is much |
219 | * registers or add a mode table, but this works and is much |
220 | * simpler. |
220 | * simpler. |
221 | */ |
221 | */ |
222 | mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); |
222 | mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false); |
223 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
223 | mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; |
224 | DRM_DEBUG("Adding cvt approximation of native panel mode %s\n", mode->name); |
224 | DRM_DEBUG("Adding cvt approximation of native panel mode %s\n", mode->name); |
225 | } |
225 | } |
226 | return mode; |
226 | return mode; |
227 | } |
227 | } |
228 | 228 | ||
229 | static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) |
229 | static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_connector *connector) |
230 | { |
230 | { |
231 | struct drm_device *dev = encoder->dev; |
231 | struct drm_device *dev = encoder->dev; |
232 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
232 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
233 | struct drm_display_mode *mode = NULL; |
233 | struct drm_display_mode *mode = NULL; |
234 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
234 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
235 | int i; |
235 | int i; |
236 | struct mode_size { |
236 | struct mode_size { |
237 | int w; |
237 | int w; |
238 | int h; |
238 | int h; |
239 | } common_modes[17] = { |
239 | } common_modes[17] = { |
240 | { 640, 480}, |
240 | { 640, 480}, |
241 | { 720, 480}, |
241 | { 720, 480}, |
242 | { 800, 600}, |
242 | { 800, 600}, |
243 | { 848, 480}, |
243 | { 848, 480}, |
244 | {1024, 768}, |
244 | {1024, 768}, |
245 | {1152, 768}, |
245 | {1152, 768}, |
246 | {1280, 720}, |
246 | {1280, 720}, |
247 | {1280, 800}, |
247 | {1280, 800}, |
248 | {1280, 854}, |
248 | {1280, 854}, |
249 | {1280, 960}, |
249 | {1280, 960}, |
250 | {1280, 1024}, |
250 | {1280, 1024}, |
251 | {1440, 900}, |
251 | {1440, 900}, |
252 | {1400, 1050}, |
252 | {1400, 1050}, |
253 | {1680, 1050}, |
253 | {1680, 1050}, |
254 | {1600, 1200}, |
254 | {1600, 1200}, |
255 | {1920, 1080}, |
255 | {1920, 1080}, |
256 | {1920, 1200} |
256 | {1920, 1200} |
257 | }; |
257 | }; |
258 | 258 | ||
259 | for (i = 0; i < 17; i++) { |
259 | for (i = 0; i < 17; i++) { |
260 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { |
260 | if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) { |
261 | if (common_modes[i].w > 1024 || |
261 | if (common_modes[i].w > 1024 || |
262 | common_modes[i].h > 768) |
262 | common_modes[i].h > 768) |
263 | continue; |
263 | continue; |
264 | } |
264 | } |
265 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
265 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
266 | if (common_modes[i].w > native_mode->hdisplay || |
266 | if (common_modes[i].w > native_mode->hdisplay || |
267 | common_modes[i].h > native_mode->vdisplay || |
267 | common_modes[i].h > native_mode->vdisplay || |
268 | (common_modes[i].w == native_mode->hdisplay && |
268 | (common_modes[i].w == native_mode->hdisplay && |
269 | common_modes[i].h == native_mode->vdisplay)) |
269 | common_modes[i].h == native_mode->vdisplay)) |
270 | continue; |
270 | continue; |
271 | } |
271 | } |
272 | if (common_modes[i].w < 320 || common_modes[i].h < 200) |
272 | if (common_modes[i].w < 320 || common_modes[i].h < 200) |
273 | continue; |
273 | continue; |
274 | 274 | ||
275 | mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); |
275 | mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); |
276 | drm_mode_probed_add(connector, mode); |
276 | drm_mode_probed_add(connector, mode); |
277 | } |
277 | } |
278 | } |
278 | } |
279 | 279 | ||
280 | int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, |
280 | int radeon_connector_set_property(struct drm_connector *connector, struct drm_property *property, |
281 | uint64_t val) |
281 | uint64_t val) |
282 | { |
282 | { |
283 | struct drm_device *dev = connector->dev; |
283 | struct drm_device *dev = connector->dev; |
284 | struct radeon_device *rdev = dev->dev_private; |
284 | struct radeon_device *rdev = dev->dev_private; |
285 | struct drm_encoder *encoder; |
285 | struct drm_encoder *encoder; |
286 | struct radeon_encoder *radeon_encoder; |
286 | struct radeon_encoder *radeon_encoder; |
287 | 287 | ||
288 | if (property == rdev->mode_info.coherent_mode_property) { |
288 | if (property == rdev->mode_info.coherent_mode_property) { |
289 | struct radeon_encoder_atom_dig *dig; |
289 | struct radeon_encoder_atom_dig *dig; |
290 | 290 | ||
291 | /* need to find digital encoder on connector */ |
291 | /* need to find digital encoder on connector */ |
292 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
292 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
293 | if (!encoder) |
293 | if (!encoder) |
294 | return 0; |
294 | return 0; |
295 | 295 | ||
296 | radeon_encoder = to_radeon_encoder(encoder); |
296 | radeon_encoder = to_radeon_encoder(encoder); |
297 | 297 | ||
298 | if (!radeon_encoder->enc_priv) |
298 | if (!radeon_encoder->enc_priv) |
299 | return 0; |
299 | return 0; |
300 | 300 | ||
301 | dig = radeon_encoder->enc_priv; |
301 | dig = radeon_encoder->enc_priv; |
302 | dig->coherent_mode = val ? true : false; |
302 | dig->coherent_mode = val ? true : false; |
303 | radeon_property_change_mode(&radeon_encoder->base); |
303 | radeon_property_change_mode(&radeon_encoder->base); |
304 | } |
304 | } |
305 | 305 | ||
306 | if (property == rdev->mode_info.tv_std_property) { |
306 | if (property == rdev->mode_info.tv_std_property) { |
307 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); |
307 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC); |
308 | if (!encoder) { |
308 | if (!encoder) { |
309 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); |
309 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_DAC); |
310 | } |
310 | } |
311 | 311 | ||
312 | if (!encoder) |
312 | if (!encoder) |
313 | return 0; |
313 | return 0; |
314 | 314 | ||
315 | radeon_encoder = to_radeon_encoder(encoder); |
315 | radeon_encoder = to_radeon_encoder(encoder); |
316 | if (!radeon_encoder->enc_priv) |
316 | if (!radeon_encoder->enc_priv) |
317 | return 0; |
317 | return 0; |
318 | if (rdev->is_atom_bios) { |
318 | if (rdev->is_atom_bios) { |
319 | struct radeon_encoder_atom_dac *dac_int; |
319 | struct radeon_encoder_atom_dac *dac_int; |
320 | dac_int = radeon_encoder->enc_priv; |
320 | dac_int = radeon_encoder->enc_priv; |
321 | dac_int->tv_std = val; |
321 | dac_int->tv_std = val; |
322 | } else { |
322 | } else { |
323 | struct radeon_encoder_tv_dac *dac_int; |
323 | struct radeon_encoder_tv_dac *dac_int; |
324 | dac_int = radeon_encoder->enc_priv; |
324 | dac_int = radeon_encoder->enc_priv; |
325 | dac_int->tv_std = val; |
325 | dac_int->tv_std = val; |
326 | } |
326 | } |
327 | radeon_property_change_mode(&radeon_encoder->base); |
327 | radeon_property_change_mode(&radeon_encoder->base); |
328 | } |
328 | } |
329 | 329 | ||
330 | if (property == rdev->mode_info.load_detect_property) { |
330 | if (property == rdev->mode_info.load_detect_property) { |
331 | struct radeon_connector *radeon_connector = |
331 | struct radeon_connector *radeon_connector = |
332 | to_radeon_connector(connector); |
332 | to_radeon_connector(connector); |
333 | 333 | ||
334 | if (val == 0) |
334 | if (val == 0) |
335 | radeon_connector->dac_load_detect = false; |
335 | radeon_connector->dac_load_detect = false; |
336 | else |
336 | else |
337 | radeon_connector->dac_load_detect = true; |
337 | radeon_connector->dac_load_detect = true; |
338 | } |
338 | } |
339 | 339 | ||
340 | if (property == rdev->mode_info.tmds_pll_property) { |
340 | if (property == rdev->mode_info.tmds_pll_property) { |
341 | struct radeon_encoder_int_tmds *tmds = NULL; |
341 | struct radeon_encoder_int_tmds *tmds = NULL; |
342 | bool ret = false; |
342 | bool ret = false; |
343 | /* need to find digital encoder on connector */ |
343 | /* need to find digital encoder on connector */ |
344 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
344 | encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); |
345 | if (!encoder) |
345 | if (!encoder) |
346 | return 0; |
346 | return 0; |
347 | 347 | ||
348 | radeon_encoder = to_radeon_encoder(encoder); |
348 | radeon_encoder = to_radeon_encoder(encoder); |
349 | 349 | ||
350 | tmds = radeon_encoder->enc_priv; |
350 | tmds = radeon_encoder->enc_priv; |
351 | if (!tmds) |
351 | if (!tmds) |
352 | return 0; |
352 | return 0; |
353 | 353 | ||
354 | if (val == 0) { |
354 | if (val == 0) { |
355 | if (rdev->is_atom_bios) |
355 | if (rdev->is_atom_bios) |
356 | ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); |
356 | ret = radeon_atombios_get_tmds_info(radeon_encoder, tmds); |
357 | else |
357 | else |
358 | ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); |
358 | ret = radeon_legacy_get_tmds_info_from_combios(radeon_encoder, tmds); |
359 | } |
359 | } |
360 | if (val == 1 || ret == false) { |
360 | if (val == 1 || ret == false) { |
361 | radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); |
361 | radeon_legacy_get_tmds_info_from_table(radeon_encoder, tmds); |
362 | } |
362 | } |
363 | radeon_property_change_mode(&radeon_encoder->base); |
363 | radeon_property_change_mode(&radeon_encoder->base); |
364 | } |
364 | } |
365 | 365 | ||
366 | return 0; |
366 | return 0; |
367 | } |
367 | } |
368 | 368 | ||
369 | static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, |
369 | static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder, |
370 | struct drm_connector *connector) |
370 | struct drm_connector *connector) |
371 | { |
371 | { |
372 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
372 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
373 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
373 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
374 | 374 | ||
375 | /* Try to get native mode details from EDID if necessary */ |
375 | /* Try to get native mode details from EDID if necessary */ |
376 | if (!native_mode->clock) { |
376 | if (!native_mode->clock) { |
377 | struct drm_display_mode *t, *mode; |
377 | struct drm_display_mode *t, *mode; |
378 | 378 | ||
379 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { |
379 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { |
380 | if (mode->hdisplay == native_mode->hdisplay && |
380 | if (mode->hdisplay == native_mode->hdisplay && |
381 | mode->vdisplay == native_mode->vdisplay) { |
381 | mode->vdisplay == native_mode->vdisplay) { |
382 | *native_mode = *mode; |
382 | *native_mode = *mode; |
383 | drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); |
383 | drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V); |
384 | DRM_INFO("Determined LVDS native mode details from EDID\n"); |
384 | DRM_INFO("Determined LVDS native mode details from EDID\n"); |
385 | break; |
385 | break; |
386 | } |
386 | } |
387 | } |
387 | } |
388 | } |
388 | } |
389 | if (!native_mode->clock) { |
389 | if (!native_mode->clock) { |
390 | DRM_INFO("No LVDS native mode details, disabling RMX\n"); |
390 | DRM_INFO("No LVDS native mode details, disabling RMX\n"); |
391 | radeon_encoder->rmx_type = RMX_OFF; |
391 | radeon_encoder->rmx_type = RMX_OFF; |
392 | } |
392 | } |
393 | } |
393 | } |
394 | 394 | ||
395 | static int radeon_lvds_get_modes(struct drm_connector *connector) |
395 | static int radeon_lvds_get_modes(struct drm_connector *connector) |
396 | { |
396 | { |
397 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
397 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
398 | struct drm_encoder *encoder; |
398 | struct drm_encoder *encoder; |
399 | int ret = 0; |
399 | int ret = 0; |
400 | struct drm_display_mode *mode; |
400 | struct drm_display_mode *mode; |
401 | 401 | ||
402 | if (radeon_connector->ddc_bus) { |
402 | if (radeon_connector->ddc_bus) { |
403 | ret = radeon_ddc_get_modes(radeon_connector); |
403 | ret = radeon_ddc_get_modes(radeon_connector); |
404 | if (ret > 0) { |
404 | if (ret > 0) { |
405 | encoder = radeon_best_single_encoder(connector); |
405 | encoder = radeon_best_single_encoder(connector); |
406 | if (encoder) { |
406 | if (encoder) { |
407 | radeon_fixup_lvds_native_mode(encoder, connector); |
407 | radeon_fixup_lvds_native_mode(encoder, connector); |
408 | /* add scaled modes */ |
408 | /* add scaled modes */ |
409 | radeon_add_common_modes(encoder, connector); |
409 | radeon_add_common_modes(encoder, connector); |
410 | } |
410 | } |
411 | return ret; |
411 | return ret; |
412 | } |
412 | } |
413 | } |
413 | } |
414 | 414 | ||
415 | encoder = radeon_best_single_encoder(connector); |
415 | encoder = radeon_best_single_encoder(connector); |
416 | if (!encoder) |
416 | if (!encoder) |
417 | return 0; |
417 | return 0; |
418 | 418 | ||
419 | /* we have no EDID modes */ |
419 | /* we have no EDID modes */ |
420 | mode = radeon_fp_native_mode(encoder); |
420 | mode = radeon_fp_native_mode(encoder); |
421 | if (mode) { |
421 | if (mode) { |
422 | ret = 1; |
422 | ret = 1; |
423 | drm_mode_probed_add(connector, mode); |
423 | drm_mode_probed_add(connector, mode); |
424 | /* add scaled modes */ |
424 | /* add scaled modes */ |
425 | radeon_add_common_modes(encoder, connector); |
425 | radeon_add_common_modes(encoder, connector); |
426 | } |
426 | } |
427 | 427 | ||
428 | return ret; |
428 | return ret; |
429 | } |
429 | } |
430 | 430 | ||
431 | static int radeon_lvds_mode_valid(struct drm_connector *connector, |
431 | static int radeon_lvds_mode_valid(struct drm_connector *connector, |
432 | struct drm_display_mode *mode) |
432 | struct drm_display_mode *mode) |
433 | { |
433 | { |
434 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
434 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
435 | 435 | ||
436 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) |
436 | if ((mode->hdisplay < 320) || (mode->vdisplay < 240)) |
437 | return MODE_PANEL; |
437 | return MODE_PANEL; |
438 | 438 | ||
439 | if (encoder) { |
439 | if (encoder) { |
440 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
440 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
441 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
441 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
442 | 442 | ||
443 | /* AVIVO hardware supports downscaling modes larger than the panel |
443 | /* AVIVO hardware supports downscaling modes larger than the panel |
444 | * to the panel size, but I'm not sure this is desirable. |
444 | * to the panel size, but I'm not sure this is desirable. |
445 | */ |
445 | */ |
446 | if ((mode->hdisplay > native_mode->hdisplay) || |
446 | if ((mode->hdisplay > native_mode->hdisplay) || |
447 | (mode->vdisplay > native_mode->vdisplay)) |
447 | (mode->vdisplay > native_mode->vdisplay)) |
448 | return MODE_PANEL; |
448 | return MODE_PANEL; |
449 | 449 | ||
450 | /* if scaling is disabled, block non-native modes */ |
450 | /* if scaling is disabled, block non-native modes */ |
451 | if (radeon_encoder->rmx_type == RMX_OFF) { |
451 | if (radeon_encoder->rmx_type == RMX_OFF) { |
452 | if ((mode->hdisplay != native_mode->hdisplay) || |
452 | if ((mode->hdisplay != native_mode->hdisplay) || |
453 | (mode->vdisplay != native_mode->vdisplay)) |
453 | (mode->vdisplay != native_mode->vdisplay)) |
454 | return MODE_PANEL; |
454 | return MODE_PANEL; |
455 | } |
455 | } |
456 | } |
456 | } |
457 | 457 | ||
458 | return MODE_OK; |
458 | return MODE_OK; |
459 | } |
459 | } |
460 | 460 | ||
461 | static enum drm_connector_status radeon_lvds_detect(struct drm_connector *connector) |
461 | static enum drm_connector_status radeon_lvds_detect(struct drm_connector *connector) |
462 | { |
462 | { |
463 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
463 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
464 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
464 | struct drm_encoder *encoder = radeon_best_single_encoder(connector); |
465 | enum drm_connector_status ret = connector_status_disconnected; |
465 | enum drm_connector_status ret = connector_status_disconnected; |
466 | 466 | ||
467 | if (encoder) { |
467 | if (encoder) { |
468 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
468 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
469 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
469 | struct drm_display_mode *native_mode = &radeon_encoder->native_mode; |
470 | 470 | ||
471 | /* check if panel is valid */ |
471 | /* check if panel is valid */ |
472 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) |
472 | if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) |
473 | ret = connector_status_connected; |
473 | ret = connector_status_connected; |
474 | 474 | ||
475 | } |
475 | } |
476 | 476 | ||
477 | /* check for edid as well */ |
477 | /* check for edid as well */ |
478 | if (radeon_connector->edid) |
478 | if (radeon_connector->edid) |
479 | ret = connector_status_connected; |
479 | ret = connector_status_connected; |
480 | else { |
480 | else { |
481 | if (radeon_connector->ddc_bus) { |
481 | if (radeon_connector->ddc_bus) { |
482 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
- | |
483 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
482 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, |
484 | &radeon_connector->ddc_bus->adapter); |
483 | &radeon_connector->ddc_bus->adapter); |
485 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
486 | if (radeon_connector->edid) |
484 | if (radeon_connector->edid) |
487 | ret = connector_status_connected; |
485 | ret = connector_status_connected; |
488 | } |
486 | } |
489 | } |
487 | } |
490 | /* check acpi lid status ??? */ |
488 | /* check acpi lid status ??? */ |
491 | 489 | ||
492 | radeon_connector_update_scratch_regs(connector, ret); |
490 | radeon_connector_update_scratch_regs(connector, ret); |
493 | return ret; |
491 | return ret; |
494 | } |
492 | } |
495 | 493 | ||
496 | static void radeon_connector_destroy(struct drm_connector *connector) |
494 | static void radeon_connector_destroy(struct drm_connector *connector) |
497 | { |
495 | { |
498 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
496 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
499 | 497 | ||
500 | if (radeon_connector->ddc_bus) |
498 | if (radeon_connector->ddc_bus) |
501 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
499 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
502 | if (radeon_connector->edid) |
500 | if (radeon_connector->edid) |
503 | kfree(radeon_connector->edid); |
501 | kfree(radeon_connector->edid); |
504 | kfree(radeon_connector->con_priv); |
502 | kfree(radeon_connector->con_priv); |
505 | drm_sysfs_connector_remove(connector); |
503 | drm_sysfs_connector_remove(connector); |
506 | drm_connector_cleanup(connector); |
504 | drm_connector_cleanup(connector); |
507 | kfree(connector); |
505 | kfree(connector); |
508 | } |
506 | } |
509 | 507 | ||
510 | static int radeon_lvds_set_property(struct drm_connector *connector, |
508 | static int radeon_lvds_set_property(struct drm_connector *connector, |
511 | struct drm_property *property, |
509 | struct drm_property *property, |
512 | uint64_t value) |
510 | uint64_t value) |
513 | { |
511 | { |
514 | struct drm_device *dev = connector->dev; |
512 | struct drm_device *dev = connector->dev; |
515 | struct radeon_encoder *radeon_encoder; |
513 | struct radeon_encoder *radeon_encoder; |
516 | enum radeon_rmx_type rmx_type; |
514 | enum radeon_rmx_type rmx_type; |
517 | 515 | ||
518 | DRM_DEBUG("\n"); |
516 | DRM_DEBUG("\n"); |
519 | if (property != dev->mode_config.scaling_mode_property) |
517 | if (property != dev->mode_config.scaling_mode_property) |
520 | return 0; |
518 | return 0; |
521 | 519 | ||
522 | if (connector->encoder) |
520 | if (connector->encoder) |
523 | radeon_encoder = to_radeon_encoder(connector->encoder); |
521 | radeon_encoder = to_radeon_encoder(connector->encoder); |
524 | else { |
522 | else { |
525 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
523 | struct drm_connector_helper_funcs *connector_funcs = connector->helper_private; |
526 | radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); |
524 | radeon_encoder = to_radeon_encoder(connector_funcs->best_encoder(connector)); |
527 | } |
525 | } |
528 | 526 | ||
529 | switch (value) { |
527 | switch (value) { |
530 | case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; |
528 | case DRM_MODE_SCALE_NONE: rmx_type = RMX_OFF; break; |
531 | case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; |
529 | case DRM_MODE_SCALE_CENTER: rmx_type = RMX_CENTER; break; |
532 | case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; |
530 | case DRM_MODE_SCALE_ASPECT: rmx_type = RMX_ASPECT; break; |
533 | default: |
531 | default: |
534 | case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; |
532 | case DRM_MODE_SCALE_FULLSCREEN: rmx_type = RMX_FULL; break; |
535 | } |
533 | } |
536 | if (radeon_encoder->rmx_type == rmx_type) |
534 | if (radeon_encoder->rmx_type == rmx_type) |
537 | return 0; |
535 | return 0; |
538 | 536 | ||
539 | radeon_encoder->rmx_type = rmx_type; |
537 | radeon_encoder->rmx_type = rmx_type; |
540 | 538 | ||
541 | radeon_property_change_mode(&radeon_encoder->base); |
539 | radeon_property_change_mode(&radeon_encoder->base); |
542 | return 0; |
540 | return 0; |
543 | } |
541 | } |
544 | 542 | ||
545 | 543 | ||
546 | struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { |
544 | struct drm_connector_helper_funcs radeon_lvds_connector_helper_funcs = { |
547 | .get_modes = radeon_lvds_get_modes, |
545 | .get_modes = radeon_lvds_get_modes, |
548 | .mode_valid = radeon_lvds_mode_valid, |
546 | .mode_valid = radeon_lvds_mode_valid, |
549 | .best_encoder = radeon_best_single_encoder, |
547 | .best_encoder = radeon_best_single_encoder, |
550 | }; |
548 | }; |
551 | 549 | ||
552 | struct drm_connector_funcs radeon_lvds_connector_funcs = { |
550 | struct drm_connector_funcs radeon_lvds_connector_funcs = { |
553 | .dpms = drm_helper_connector_dpms, |
551 | .dpms = drm_helper_connector_dpms, |
554 | .detect = radeon_lvds_detect, |
552 | .detect = radeon_lvds_detect, |
555 | .fill_modes = drm_helper_probe_single_connector_modes, |
553 | .fill_modes = drm_helper_probe_single_connector_modes, |
556 | .destroy = radeon_connector_destroy, |
554 | .destroy = radeon_connector_destroy, |
557 | .set_property = radeon_lvds_set_property, |
555 | .set_property = radeon_lvds_set_property, |
558 | }; |
556 | }; |
559 | 557 | ||
560 | static int radeon_vga_get_modes(struct drm_connector *connector) |
558 | static int radeon_vga_get_modes(struct drm_connector *connector) |
561 | { |
559 | { |
562 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
560 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
563 | int ret; |
561 | int ret; |
564 | 562 | ||
565 | ret = radeon_ddc_get_modes(radeon_connector); |
563 | ret = radeon_ddc_get_modes(radeon_connector); |
566 | 564 | ||
567 | return ret; |
565 | return ret; |
568 | } |
566 | } |
569 | 567 | ||
570 | static int radeon_vga_mode_valid(struct drm_connector *connector, |
568 | static int radeon_vga_mode_valid(struct drm_connector *connector, |
571 | struct drm_display_mode *mode) |
569 | struct drm_display_mode *mode) |
572 | { |
570 | { |
573 | /* XXX check mode bandwidth */ |
571 | /* XXX check mode bandwidth */ |
574 | /* XXX verify against max DAC output frequency */ |
572 | /* XXX verify against max DAC output frequency */ |
575 | return MODE_OK; |
573 | return MODE_OK; |
576 | } |
574 | } |
577 | 575 | ||
578 | static enum drm_connector_status radeon_vga_detect(struct drm_connector *connector) |
576 | static enum drm_connector_status radeon_vga_detect(struct drm_connector *connector) |
579 | { |
577 | { |
580 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
578 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
581 | struct drm_encoder *encoder; |
579 | struct drm_encoder *encoder; |
582 | struct drm_encoder_helper_funcs *encoder_funcs; |
580 | struct drm_encoder_helper_funcs *encoder_funcs; |
583 | bool dret = false; |
581 | bool dret = false; |
584 | enum drm_connector_status ret = connector_status_disconnected; |
582 | enum drm_connector_status ret = connector_status_disconnected; |
585 | 583 | ||
586 | encoder = radeon_best_single_encoder(connector); |
584 | encoder = radeon_best_single_encoder(connector); |
587 | if (!encoder) |
585 | if (!encoder) |
588 | ret = connector_status_disconnected; |
586 | ret = connector_status_disconnected; |
589 | 587 | ||
590 | if (radeon_connector->ddc_bus) { |
- | |
591 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
588 | if (radeon_connector->ddc_bus) |
592 | dret = radeon_ddc_probe(radeon_connector); |
- | |
593 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
594 | } |
589 | dret = radeon_ddc_probe(radeon_connector); |
595 | if (dret) { |
590 | if (dret) { |
596 | if (radeon_connector->edid) { |
591 | if (radeon_connector->edid) { |
597 | kfree(radeon_connector->edid); |
592 | kfree(radeon_connector->edid); |
598 | radeon_connector->edid = NULL; |
593 | radeon_connector->edid = NULL; |
599 | } |
594 | } |
600 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
- | |
601 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
595 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
602 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
603 | 596 | ||
604 | if (!radeon_connector->edid) { |
597 | if (!radeon_connector->edid) { |
605 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
598 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
606 | drm_get_connector_name(connector)); |
599 | drm_get_connector_name(connector)); |
607 | ret = connector_status_connected; |
600 | ret = connector_status_connected; |
608 | } else { |
601 | } else { |
609 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
602 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
610 | 603 | ||
611 | /* some oems have boards with separate digital and analog connectors |
604 | /* some oems have boards with separate digital and analog connectors |
612 | * with a shared ddc line (often vga + hdmi) |
605 | * with a shared ddc line (often vga + hdmi) |
613 | */ |
606 | */ |
614 | if (radeon_connector->use_digital && radeon_connector->shared_ddc) { |
607 | if (radeon_connector->use_digital && radeon_connector->shared_ddc) { |
615 | kfree(radeon_connector->edid); |
608 | kfree(radeon_connector->edid); |
616 | radeon_connector->edid = NULL; |
609 | radeon_connector->edid = NULL; |
617 | ret = connector_status_disconnected; |
610 | ret = connector_status_disconnected; |
618 | } else |
611 | } else |
619 | ret = connector_status_connected; |
612 | ret = connector_status_connected; |
620 | } |
613 | } |
621 | } else { |
614 | } else { |
622 | if (radeon_connector->dac_load_detect && encoder) { |
615 | if (radeon_connector->dac_load_detect && encoder) { |
623 | encoder_funcs = encoder->helper_private; |
616 | encoder_funcs = encoder->helper_private; |
624 | ret = encoder_funcs->detect(encoder, connector); |
617 | ret = encoder_funcs->detect(encoder, connector); |
625 | } |
618 | } |
626 | } |
619 | } |
627 | 620 | ||
628 | if (ret == connector_status_connected) |
621 | if (ret == connector_status_connected) |
629 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
622 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
630 | radeon_connector_update_scratch_regs(connector, ret); |
623 | radeon_connector_update_scratch_regs(connector, ret); |
631 | return ret; |
624 | return ret; |
632 | } |
625 | } |
633 | 626 | ||
634 | struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { |
627 | struct drm_connector_helper_funcs radeon_vga_connector_helper_funcs = { |
635 | .get_modes = radeon_vga_get_modes, |
628 | .get_modes = radeon_vga_get_modes, |
636 | .mode_valid = radeon_vga_mode_valid, |
629 | .mode_valid = radeon_vga_mode_valid, |
637 | .best_encoder = radeon_best_single_encoder, |
630 | .best_encoder = radeon_best_single_encoder, |
638 | }; |
631 | }; |
639 | 632 | ||
640 | struct drm_connector_funcs radeon_vga_connector_funcs = { |
633 | struct drm_connector_funcs radeon_vga_connector_funcs = { |
641 | .dpms = drm_helper_connector_dpms, |
634 | .dpms = drm_helper_connector_dpms, |
642 | .detect = radeon_vga_detect, |
635 | .detect = radeon_vga_detect, |
643 | .fill_modes = drm_helper_probe_single_connector_modes, |
636 | .fill_modes = drm_helper_probe_single_connector_modes, |
644 | .destroy = radeon_connector_destroy, |
637 | .destroy = radeon_connector_destroy, |
645 | .set_property = radeon_connector_set_property, |
638 | .set_property = radeon_connector_set_property, |
646 | }; |
639 | }; |
647 | 640 | ||
648 | static int radeon_tv_get_modes(struct drm_connector *connector) |
641 | static int radeon_tv_get_modes(struct drm_connector *connector) |
649 | { |
642 | { |
650 | struct drm_device *dev = connector->dev; |
643 | struct drm_device *dev = connector->dev; |
651 | struct radeon_device *rdev = dev->dev_private; |
644 | struct radeon_device *rdev = dev->dev_private; |
652 | struct drm_display_mode *tv_mode; |
645 | struct drm_display_mode *tv_mode; |
653 | struct drm_encoder *encoder; |
646 | struct drm_encoder *encoder; |
654 | 647 | ||
655 | encoder = radeon_best_single_encoder(connector); |
648 | encoder = radeon_best_single_encoder(connector); |
656 | if (!encoder) |
649 | if (!encoder) |
657 | return 0; |
650 | return 0; |
658 | 651 | ||
659 | /* avivo chips can scale any mode */ |
652 | /* avivo chips can scale any mode */ |
660 | if (rdev->family >= CHIP_RS600) |
653 | if (rdev->family >= CHIP_RS600) |
661 | /* add scaled modes */ |
654 | /* add scaled modes */ |
662 | radeon_add_common_modes(encoder, connector); |
655 | radeon_add_common_modes(encoder, connector); |
663 | else { |
656 | else { |
664 | /* only 800x600 is supported right now on pre-avivo chips */ |
657 | /* only 800x600 is supported right now on pre-avivo chips */ |
665 | tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); |
658 | tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false); |
666 | tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
659 | tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; |
667 | drm_mode_probed_add(connector, tv_mode); |
660 | drm_mode_probed_add(connector, tv_mode); |
668 | } |
661 | } |
669 | return 1; |
662 | return 1; |
670 | } |
663 | } |
671 | 664 | ||
672 | static int radeon_tv_mode_valid(struct drm_connector *connector, |
665 | static int radeon_tv_mode_valid(struct drm_connector *connector, |
673 | struct drm_display_mode *mode) |
666 | struct drm_display_mode *mode) |
674 | { |
667 | { |
675 | if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) |
668 | if ((mode->hdisplay > 1024) || (mode->vdisplay > 768)) |
676 | return MODE_CLOCK_RANGE; |
669 | return MODE_CLOCK_RANGE; |
677 | return MODE_OK; |
670 | return MODE_OK; |
678 | } |
671 | } |
679 | 672 | ||
680 | static enum drm_connector_status radeon_tv_detect(struct drm_connector *connector) |
673 | static enum drm_connector_status radeon_tv_detect(struct drm_connector *connector) |
681 | { |
674 | { |
682 | struct drm_encoder *encoder; |
675 | struct drm_encoder *encoder; |
683 | struct drm_encoder_helper_funcs *encoder_funcs; |
676 | struct drm_encoder_helper_funcs *encoder_funcs; |
684 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
677 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
685 | enum drm_connector_status ret = connector_status_disconnected; |
678 | enum drm_connector_status ret = connector_status_disconnected; |
686 | 679 | ||
687 | if (!radeon_connector->dac_load_detect) |
680 | if (!radeon_connector->dac_load_detect) |
688 | return ret; |
681 | return ret; |
689 | 682 | ||
690 | encoder = radeon_best_single_encoder(connector); |
683 | encoder = radeon_best_single_encoder(connector); |
691 | if (!encoder) |
684 | if (!encoder) |
692 | ret = connector_status_disconnected; |
685 | ret = connector_status_disconnected; |
693 | else { |
686 | else { |
694 | encoder_funcs = encoder->helper_private; |
687 | encoder_funcs = encoder->helper_private; |
695 | ret = encoder_funcs->detect(encoder, connector); |
688 | ret = encoder_funcs->detect(encoder, connector); |
696 | } |
689 | } |
697 | if (ret == connector_status_connected) |
690 | if (ret == connector_status_connected) |
698 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); |
691 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, false); |
699 | radeon_connector_update_scratch_regs(connector, ret); |
692 | radeon_connector_update_scratch_regs(connector, ret); |
700 | return ret; |
693 | return ret; |
701 | } |
694 | } |
702 | 695 | ||
703 | struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { |
696 | struct drm_connector_helper_funcs radeon_tv_connector_helper_funcs = { |
704 | .get_modes = radeon_tv_get_modes, |
697 | .get_modes = radeon_tv_get_modes, |
705 | .mode_valid = radeon_tv_mode_valid, |
698 | .mode_valid = radeon_tv_mode_valid, |
706 | .best_encoder = radeon_best_single_encoder, |
699 | .best_encoder = radeon_best_single_encoder, |
707 | }; |
700 | }; |
708 | 701 | ||
709 | struct drm_connector_funcs radeon_tv_connector_funcs = { |
702 | struct drm_connector_funcs radeon_tv_connector_funcs = { |
710 | .dpms = drm_helper_connector_dpms, |
703 | .dpms = drm_helper_connector_dpms, |
711 | .detect = radeon_tv_detect, |
704 | .detect = radeon_tv_detect, |
712 | .fill_modes = drm_helper_probe_single_connector_modes, |
705 | .fill_modes = drm_helper_probe_single_connector_modes, |
713 | .destroy = radeon_connector_destroy, |
706 | .destroy = radeon_connector_destroy, |
714 | .set_property = radeon_connector_set_property, |
707 | .set_property = radeon_connector_set_property, |
715 | }; |
708 | }; |
716 | 709 | ||
717 | static int radeon_dvi_get_modes(struct drm_connector *connector) |
710 | static int radeon_dvi_get_modes(struct drm_connector *connector) |
718 | { |
711 | { |
719 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
712 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
720 | int ret; |
713 | int ret; |
721 | 714 | ||
722 | ret = radeon_ddc_get_modes(radeon_connector); |
715 | ret = radeon_ddc_get_modes(radeon_connector); |
723 | return ret; |
716 | return ret; |
724 | } |
717 | } |
725 | 718 | ||
726 | /* |
719 | /* |
727 | * DVI is complicated |
720 | * DVI is complicated |
728 | * Do a DDC probe, if DDC probe passes, get the full EDID so |
721 | * Do a DDC probe, if DDC probe passes, get the full EDID so |
729 | * we can do analog/digital monitor detection at this point. |
722 | * we can do analog/digital monitor detection at this point. |
730 | * If the monitor is an analog monitor or we got no DDC, |
723 | * If the monitor is an analog monitor or we got no DDC, |
731 | * we need to find the DAC encoder object for this connector. |
724 | * we need to find the DAC encoder object for this connector. |
732 | * If we got no DDC, we do load detection on the DAC encoder object. |
725 | * If we got no DDC, we do load detection on the DAC encoder object. |
733 | * If we got analog DDC or load detection passes on the DAC encoder |
726 | * If we got analog DDC or load detection passes on the DAC encoder |
734 | * we have to check if this analog encoder is shared with anyone else (TV) |
727 | * we have to check if this analog encoder is shared with anyone else (TV) |
735 | * if its shared we have to set the other connector to disconnected. |
728 | * if its shared we have to set the other connector to disconnected. |
736 | */ |
729 | */ |
737 | static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connector) |
730 | static enum drm_connector_status radeon_dvi_detect(struct drm_connector *connector) |
738 | { |
731 | { |
739 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
732 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
740 | struct drm_encoder *encoder = NULL; |
733 | struct drm_encoder *encoder = NULL; |
741 | struct drm_encoder_helper_funcs *encoder_funcs; |
734 | struct drm_encoder_helper_funcs *encoder_funcs; |
742 | struct drm_mode_object *obj; |
735 | struct drm_mode_object *obj; |
743 | int i; |
736 | int i; |
744 | enum drm_connector_status ret = connector_status_disconnected; |
737 | enum drm_connector_status ret = connector_status_disconnected; |
745 | bool dret = false; |
738 | bool dret = false; |
746 | 739 | ||
747 | if (radeon_connector->ddc_bus) { |
- | |
748 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
740 | if (radeon_connector->ddc_bus) |
749 | dret = radeon_ddc_probe(radeon_connector); |
- | |
750 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
751 | } |
741 | dret = radeon_ddc_probe(radeon_connector); |
752 | if (dret) { |
742 | if (dret) { |
753 | if (radeon_connector->edid) { |
743 | if (radeon_connector->edid) { |
754 | kfree(radeon_connector->edid); |
744 | kfree(radeon_connector->edid); |
755 | radeon_connector->edid = NULL; |
745 | radeon_connector->edid = NULL; |
756 | } |
746 | } |
757 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
- | |
758 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
747 | radeon_connector->edid = drm_get_edid(&radeon_connector->base, &radeon_connector->ddc_bus->adapter); |
759 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
760 | 748 | ||
761 | if (!radeon_connector->edid) { |
749 | if (!radeon_connector->edid) { |
762 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
750 | DRM_ERROR("%s: probed a monitor but no|invalid EDID\n", |
763 | drm_get_connector_name(connector)); |
751 | drm_get_connector_name(connector)); |
764 | } else { |
752 | } else { |
765 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
753 | radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); |
766 | 754 | ||
767 | /* some oems have boards with separate digital and analog connectors |
755 | /* some oems have boards with separate digital and analog connectors |
768 | * with a shared ddc line (often vga + hdmi) |
756 | * with a shared ddc line (often vga + hdmi) |
769 | */ |
757 | */ |
770 | if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { |
758 | if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { |
771 | kfree(radeon_connector->edid); |
759 | kfree(radeon_connector->edid); |
772 | radeon_connector->edid = NULL; |
760 | radeon_connector->edid = NULL; |
773 | ret = connector_status_disconnected; |
761 | ret = connector_status_disconnected; |
774 | } else |
762 | } else |
775 | ret = connector_status_connected; |
763 | ret = connector_status_connected; |
776 | 764 | ||
777 | /* multiple connectors on the same encoder with the same ddc line |
765 | /* multiple connectors on the same encoder with the same ddc line |
778 | * This tends to be HDMI and DVI on the same encoder with the |
766 | * This tends to be HDMI and DVI on the same encoder with the |
779 | * same ddc line. If the edid says HDMI, consider the HDMI port |
767 | * same ddc line. If the edid says HDMI, consider the HDMI port |
780 | * connected and the DVI port disconnected. If the edid doesn't |
768 | * connected and the DVI port disconnected. If the edid doesn't |
781 | * say HDMI, vice versa. |
769 | * say HDMI, vice versa. |
782 | */ |
770 | */ |
783 | if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { |
771 | if (radeon_connector->shared_ddc && (ret == connector_status_connected)) { |
784 | struct drm_device *dev = connector->dev; |
772 | struct drm_device *dev = connector->dev; |
785 | struct drm_connector *list_connector; |
773 | struct drm_connector *list_connector; |
786 | struct radeon_connector *list_radeon_connector; |
774 | struct radeon_connector *list_radeon_connector; |
787 | list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { |
775 | list_for_each_entry(list_connector, &dev->mode_config.connector_list, head) { |
788 | if (connector == list_connector) |
776 | if (connector == list_connector) |
789 | continue; |
777 | continue; |
790 | list_radeon_connector = to_radeon_connector(list_connector); |
778 | list_radeon_connector = to_radeon_connector(list_connector); |
791 | if (radeon_connector->devices == list_radeon_connector->devices) { |
779 | if (radeon_connector->devices == list_radeon_connector->devices) { |
792 | if (drm_detect_hdmi_monitor(radeon_connector->edid)) { |
780 | if (drm_detect_hdmi_monitor(radeon_connector->edid)) { |
793 | if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) { |
781 | if (connector->connector_type == DRM_MODE_CONNECTOR_DVID) { |
794 | kfree(radeon_connector->edid); |
782 | kfree(radeon_connector->edid); |
795 | radeon_connector->edid = NULL; |
783 | radeon_connector->edid = NULL; |
796 | ret = connector_status_disconnected; |
784 | ret = connector_status_disconnected; |
797 | } |
785 | } |
798 | } else { |
786 | } else { |
799 | if ((connector->connector_type == DRM_MODE_CONNECTOR_HDMIA) || |
787 | if ((connector->connector_type == DRM_MODE_CONNECTOR_HDMIA) || |
800 | (connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) { |
788 | (connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)) { |
801 | kfree(radeon_connector->edid); |
789 | kfree(radeon_connector->edid); |
802 | radeon_connector->edid = NULL; |
790 | radeon_connector->edid = NULL; |
803 | ret = connector_status_disconnected; |
791 | ret = connector_status_disconnected; |
804 | } |
792 | } |
805 | } |
793 | } |
806 | } |
794 | } |
807 | } |
795 | } |
808 | } |
796 | } |
809 | } |
797 | } |
810 | } |
798 | } |
811 | 799 | ||
812 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) |
800 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == true)) |
813 | goto out; |
801 | goto out; |
814 | 802 | ||
815 | /* find analog encoder */ |
803 | /* find analog encoder */ |
816 | if (radeon_connector->dac_load_detect) { |
804 | if (radeon_connector->dac_load_detect) { |
817 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
805 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
818 | if (connector->encoder_ids[i] == 0) |
806 | if (connector->encoder_ids[i] == 0) |
819 | break; |
807 | break; |
820 | 808 | ||
821 | obj = drm_mode_object_find(connector->dev, |
809 | obj = drm_mode_object_find(connector->dev, |
822 | connector->encoder_ids[i], |
810 | connector->encoder_ids[i], |
823 | DRM_MODE_OBJECT_ENCODER); |
811 | DRM_MODE_OBJECT_ENCODER); |
824 | if (!obj) |
812 | if (!obj) |
825 | continue; |
813 | continue; |
826 | 814 | ||
827 | encoder = obj_to_encoder(obj); |
815 | encoder = obj_to_encoder(obj); |
828 | 816 | ||
829 | encoder_funcs = encoder->helper_private; |
817 | encoder_funcs = encoder->helper_private; |
830 | if (encoder_funcs->detect) { |
818 | if (encoder_funcs->detect) { |
831 | if (ret != connector_status_connected) { |
819 | if (ret != connector_status_connected) { |
832 | ret = encoder_funcs->detect(encoder, connector); |
820 | ret = encoder_funcs->detect(encoder, connector); |
833 | if (ret == connector_status_connected) { |
821 | if (ret == connector_status_connected) { |
834 | radeon_connector->use_digital = false; |
822 | radeon_connector->use_digital = false; |
835 | } |
823 | } |
836 | } |
824 | } |
837 | break; |
825 | break; |
838 | } |
826 | } |
839 | } |
827 | } |
840 | } |
828 | } |
841 | 829 | ||
842 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && |
830 | if ((ret == connector_status_connected) && (radeon_connector->use_digital == false) && |
843 | encoder) { |
831 | encoder) { |
844 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
832 | ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret, true); |
845 | } |
833 | } |
846 | 834 | ||
847 | out: |
835 | out: |
848 | /* updated in get modes as well since we need to know if it's analog or digital */ |
836 | /* updated in get modes as well since we need to know if it's analog or digital */ |
849 | radeon_connector_update_scratch_regs(connector, ret); |
837 | radeon_connector_update_scratch_regs(connector, ret); |
850 | return ret; |
838 | return ret; |
851 | } |
839 | } |
852 | 840 | ||
853 | /* okay need to be smart in here about which encoder to pick */ |
841 | /* okay need to be smart in here about which encoder to pick */ |
854 | struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) |
842 | struct drm_encoder *radeon_dvi_encoder(struct drm_connector *connector) |
855 | { |
843 | { |
856 | int enc_id = connector->encoder_ids[0]; |
844 | int enc_id = connector->encoder_ids[0]; |
857 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
845 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
858 | struct drm_mode_object *obj; |
846 | struct drm_mode_object *obj; |
859 | struct drm_encoder *encoder; |
847 | struct drm_encoder *encoder; |
860 | int i; |
848 | int i; |
861 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
849 | for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { |
862 | if (connector->encoder_ids[i] == 0) |
850 | if (connector->encoder_ids[i] == 0) |
863 | break; |
851 | break; |
864 | 852 | ||
865 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
853 | obj = drm_mode_object_find(connector->dev, connector->encoder_ids[i], DRM_MODE_OBJECT_ENCODER); |
866 | if (!obj) |
854 | if (!obj) |
867 | continue; |
855 | continue; |
868 | 856 | ||
869 | encoder = obj_to_encoder(obj); |
857 | encoder = obj_to_encoder(obj); |
870 | 858 | ||
871 | if (radeon_connector->use_digital == true) { |
859 | if (radeon_connector->use_digital == true) { |
872 | if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) |
860 | if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) |
873 | return encoder; |
861 | return encoder; |
874 | } else { |
862 | } else { |
875 | if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || |
863 | if (encoder->encoder_type == DRM_MODE_ENCODER_DAC || |
876 | encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) |
864 | encoder->encoder_type == DRM_MODE_ENCODER_TVDAC) |
877 | return encoder; |
865 | return encoder; |
878 | } |
866 | } |
879 | } |
867 | } |
880 | 868 | ||
881 | /* see if we have a default encoder TODO */ |
869 | /* see if we have a default encoder TODO */ |
882 | 870 | ||
883 | /* then check use digitial */ |
871 | /* then check use digitial */ |
884 | /* pick the first one */ |
872 | /* pick the first one */ |
885 | if (enc_id) { |
873 | if (enc_id) { |
886 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
874 | obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER); |
887 | if (!obj) |
875 | if (!obj) |
888 | return NULL; |
876 | return NULL; |
889 | encoder = obj_to_encoder(obj); |
877 | encoder = obj_to_encoder(obj); |
890 | return encoder; |
878 | return encoder; |
891 | } |
879 | } |
892 | return NULL; |
880 | return NULL; |
893 | } |
881 | } |
894 | 882 | ||
895 | static void radeon_dvi_force(struct drm_connector *connector) |
883 | static void radeon_dvi_force(struct drm_connector *connector) |
896 | { |
884 | { |
897 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
885 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
898 | if (connector->force == DRM_FORCE_ON) |
886 | if (connector->force == DRM_FORCE_ON) |
899 | radeon_connector->use_digital = false; |
887 | radeon_connector->use_digital = false; |
900 | if (connector->force == DRM_FORCE_ON_DIGITAL) |
888 | if (connector->force == DRM_FORCE_ON_DIGITAL) |
901 | radeon_connector->use_digital = true; |
889 | radeon_connector->use_digital = true; |
902 | } |
890 | } |
903 | 891 | ||
904 | static int radeon_dvi_mode_valid(struct drm_connector *connector, |
892 | static int radeon_dvi_mode_valid(struct drm_connector *connector, |
905 | struct drm_display_mode *mode) |
893 | struct drm_display_mode *mode) |
906 | { |
894 | { |
907 | struct drm_device *dev = connector->dev; |
895 | struct drm_device *dev = connector->dev; |
908 | struct radeon_device *rdev = dev->dev_private; |
896 | struct radeon_device *rdev = dev->dev_private; |
909 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
897 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
910 | 898 | ||
911 | /* XXX check mode bandwidth */ |
899 | /* XXX check mode bandwidth */ |
912 | 900 | ||
913 | /* clocks over 135 MHz have heat issues with DVI on RV100 */ |
901 | /* clocks over 135 MHz have heat issues with DVI on RV100 */ |
914 | if (radeon_connector->use_digital && |
902 | if (radeon_connector->use_digital && |
915 | (rdev->family == CHIP_RV100) && |
903 | (rdev->family == CHIP_RV100) && |
916 | (mode->clock > 135000)) |
904 | (mode->clock > 135000)) |
917 | return MODE_CLOCK_HIGH; |
905 | return MODE_CLOCK_HIGH; |
918 | 906 | ||
919 | if (radeon_connector->use_digital && (mode->clock > 165000)) { |
907 | if (radeon_connector->use_digital && (mode->clock > 165000)) { |
920 | if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || |
908 | if ((radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I) || |
921 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || |
909 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || |
922 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) |
910 | (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) |
923 | return MODE_OK; |
911 | return MODE_OK; |
924 | else |
912 | else |
925 | return MODE_CLOCK_HIGH; |
913 | return MODE_CLOCK_HIGH; |
926 | } |
914 | } |
927 | return MODE_OK; |
915 | return MODE_OK; |
928 | } |
916 | } |
929 | 917 | ||
930 | struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { |
918 | struct drm_connector_helper_funcs radeon_dvi_connector_helper_funcs = { |
931 | .get_modes = radeon_dvi_get_modes, |
919 | .get_modes = radeon_dvi_get_modes, |
932 | .mode_valid = radeon_dvi_mode_valid, |
920 | .mode_valid = radeon_dvi_mode_valid, |
933 | .best_encoder = radeon_dvi_encoder, |
921 | .best_encoder = radeon_dvi_encoder, |
934 | }; |
922 | }; |
935 | 923 | ||
936 | struct drm_connector_funcs radeon_dvi_connector_funcs = { |
924 | struct drm_connector_funcs radeon_dvi_connector_funcs = { |
937 | .dpms = drm_helper_connector_dpms, |
925 | .dpms = drm_helper_connector_dpms, |
938 | .detect = radeon_dvi_detect, |
926 | .detect = radeon_dvi_detect, |
939 | .fill_modes = drm_helper_probe_single_connector_modes, |
927 | .fill_modes = drm_helper_probe_single_connector_modes, |
940 | .set_property = radeon_connector_set_property, |
928 | .set_property = radeon_connector_set_property, |
941 | .destroy = radeon_connector_destroy, |
929 | .destroy = radeon_connector_destroy, |
942 | .force = radeon_dvi_force, |
930 | .force = radeon_dvi_force, |
943 | }; |
931 | }; |
944 | 932 | ||
945 | static void radeon_dp_connector_destroy(struct drm_connector *connector) |
933 | static void radeon_dp_connector_destroy(struct drm_connector *connector) |
946 | { |
934 | { |
947 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
935 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
948 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
936 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
949 | 937 | ||
950 | if (radeon_connector->ddc_bus) |
938 | if (radeon_connector->ddc_bus) |
951 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
939 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
952 | if (radeon_connector->edid) |
940 | if (radeon_connector->edid) |
953 | kfree(radeon_connector->edid); |
941 | kfree(radeon_connector->edid); |
954 | if (radeon_dig_connector->dp_i2c_bus) |
942 | if (radeon_dig_connector->dp_i2c_bus) |
955 | radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus); |
943 | radeon_i2c_destroy_dp(radeon_dig_connector->dp_i2c_bus); |
956 | kfree(radeon_connector->con_priv); |
944 | kfree(radeon_connector->con_priv); |
957 | drm_sysfs_connector_remove(connector); |
945 | drm_sysfs_connector_remove(connector); |
958 | drm_connector_cleanup(connector); |
946 | drm_connector_cleanup(connector); |
959 | kfree(connector); |
947 | kfree(connector); |
960 | } |
948 | } |
961 | 949 | ||
962 | static int radeon_dp_get_modes(struct drm_connector *connector) |
950 | static int radeon_dp_get_modes(struct drm_connector *connector) |
963 | { |
951 | { |
964 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
952 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
965 | int ret; |
953 | int ret; |
966 | 954 | ||
967 | ret = radeon_ddc_get_modes(radeon_connector); |
955 | ret = radeon_ddc_get_modes(radeon_connector); |
968 | return ret; |
956 | return ret; |
969 | } |
957 | } |
970 | 958 | ||
971 | static enum drm_connector_status radeon_dp_detect(struct drm_connector *connector) |
959 | static enum drm_connector_status radeon_dp_detect(struct drm_connector *connector) |
972 | { |
960 | { |
973 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
961 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
974 | enum drm_connector_status ret = connector_status_disconnected; |
962 | enum drm_connector_status ret = connector_status_disconnected; |
975 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
963 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
976 | u8 sink_type; |
964 | u8 sink_type; |
977 | 965 | ||
978 | if (radeon_connector->edid) { |
966 | if (radeon_connector->edid) { |
979 | kfree(radeon_connector->edid); |
967 | kfree(radeon_connector->edid); |
980 | radeon_connector->edid = NULL; |
968 | radeon_connector->edid = NULL; |
981 | } |
969 | } |
982 | 970 | ||
983 | sink_type = radeon_dp_getsinktype(radeon_connector); |
971 | sink_type = radeon_dp_getsinktype(radeon_connector); |
984 | if ((sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
972 | if ((sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
985 | (sink_type == CONNECTOR_OBJECT_ID_eDP)) { |
973 | (sink_type == CONNECTOR_OBJECT_ID_eDP)) { |
986 | if (radeon_dp_getdpcd(radeon_connector)) { |
974 | if (radeon_dp_getdpcd(radeon_connector)) { |
987 | radeon_dig_connector->dp_sink_type = sink_type; |
975 | radeon_dig_connector->dp_sink_type = sink_type; |
988 | ret = connector_status_connected; |
976 | ret = connector_status_connected; |
989 | } |
977 | } |
990 | } else { |
978 | } else { |
991 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 1); |
- | |
992 | if (radeon_ddc_probe(radeon_connector)) { |
979 | if (radeon_ddc_probe(radeon_connector)) { |
993 | radeon_dig_connector->dp_sink_type = sink_type; |
980 | radeon_dig_connector->dp_sink_type = sink_type; |
994 | ret = connector_status_connected; |
981 | ret = connector_status_connected; |
995 | } |
982 | } |
996 | radeon_i2c_do_lock(radeon_connector->ddc_bus, 0); |
- | |
997 | } |
983 | } |
998 | 984 | ||
999 | return ret; |
985 | return ret; |
1000 | } |
986 | } |
1001 | 987 | ||
1002 | static int radeon_dp_mode_valid(struct drm_connector *connector, |
988 | static int radeon_dp_mode_valid(struct drm_connector *connector, |
1003 | struct drm_display_mode *mode) |
989 | struct drm_display_mode *mode) |
1004 | { |
990 | { |
1005 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
991 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
1006 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
992 | struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; |
1007 | 993 | ||
1008 | /* XXX check mode bandwidth */ |
994 | /* XXX check mode bandwidth */ |
1009 | 995 | ||
1010 | if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
996 | if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || |
1011 | (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
997 | (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) |
1012 | return radeon_dp_mode_valid_helper(radeon_connector, mode); |
998 | return radeon_dp_mode_valid_helper(radeon_connector, mode); |
1013 | else |
999 | else |
1014 | return MODE_OK; |
1000 | return MODE_OK; |
1015 | } |
1001 | } |
1016 | 1002 | ||
1017 | struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { |
1003 | struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { |
1018 | .get_modes = radeon_dp_get_modes, |
1004 | .get_modes = radeon_dp_get_modes, |
1019 | .mode_valid = radeon_dp_mode_valid, |
1005 | .mode_valid = radeon_dp_mode_valid, |
1020 | .best_encoder = radeon_dvi_encoder, |
1006 | .best_encoder = radeon_dvi_encoder, |
1021 | }; |
1007 | }; |
1022 | 1008 | ||
1023 | struct drm_connector_funcs radeon_dp_connector_funcs = { |
1009 | struct drm_connector_funcs radeon_dp_connector_funcs = { |
1024 | .dpms = drm_helper_connector_dpms, |
1010 | .dpms = drm_helper_connector_dpms, |
1025 | .detect = radeon_dp_detect, |
1011 | .detect = radeon_dp_detect, |
1026 | .fill_modes = drm_helper_probe_single_connector_modes, |
1012 | .fill_modes = drm_helper_probe_single_connector_modes, |
1027 | .set_property = radeon_connector_set_property, |
1013 | .set_property = radeon_connector_set_property, |
1028 | .destroy = radeon_dp_connector_destroy, |
1014 | .destroy = radeon_dp_connector_destroy, |
1029 | .force = radeon_dvi_force, |
1015 | .force = radeon_dvi_force, |
1030 | }; |
1016 | }; |
1031 | 1017 | ||
1032 | void |
1018 | void |
1033 | radeon_add_atom_connector(struct drm_device *dev, |
1019 | radeon_add_atom_connector(struct drm_device *dev, |
1034 | uint32_t connector_id, |
1020 | uint32_t connector_id, |
1035 | uint32_t supported_device, |
1021 | uint32_t supported_device, |
1036 | int connector_type, |
1022 | int connector_type, |
1037 | struct radeon_i2c_bus_rec *i2c_bus, |
1023 | struct radeon_i2c_bus_rec *i2c_bus, |
1038 | bool linkb, |
1024 | bool linkb, |
1039 | uint32_t igp_lane_info, |
1025 | uint32_t igp_lane_info, |
1040 | uint16_t connector_object_id, |
1026 | uint16_t connector_object_id, |
1041 | struct radeon_hpd *hpd) |
1027 | struct radeon_hpd *hpd) |
1042 | { |
1028 | { |
1043 | struct radeon_device *rdev = dev->dev_private; |
1029 | struct radeon_device *rdev = dev->dev_private; |
1044 | struct drm_connector *connector; |
1030 | struct drm_connector *connector; |
1045 | struct radeon_connector *radeon_connector; |
1031 | struct radeon_connector *radeon_connector; |
1046 | struct radeon_connector_atom_dig *radeon_dig_connector; |
1032 | struct radeon_connector_atom_dig *radeon_dig_connector; |
1047 | uint32_t subpixel_order = SubPixelNone; |
1033 | uint32_t subpixel_order = SubPixelNone; |
1048 | bool shared_ddc = false; |
1034 | bool shared_ddc = false; |
1049 | int ret; |
1035 | int ret; |
1050 | 1036 | ||
1051 | /* fixme - tv/cv/din */ |
1037 | /* fixme - tv/cv/din */ |
1052 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
1038 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
1053 | return; |
1039 | return; |
1054 | 1040 | ||
1055 | /* see if we already added it */ |
1041 | /* see if we already added it */ |
1056 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
1042 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
1057 | radeon_connector = to_radeon_connector(connector); |
1043 | radeon_connector = to_radeon_connector(connector); |
1058 | if (radeon_connector->connector_id == connector_id) { |
1044 | if (radeon_connector->connector_id == connector_id) { |
1059 | radeon_connector->devices |= supported_device; |
1045 | radeon_connector->devices |= supported_device; |
1060 | return; |
1046 | return; |
1061 | } |
1047 | } |
1062 | if (radeon_connector->ddc_bus && i2c_bus->valid) { |
1048 | if (radeon_connector->ddc_bus && i2c_bus->valid) { |
1063 | if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { |
1049 | if (radeon_connector->ddc_bus->rec.i2c_id == i2c_bus->i2c_id) { |
1064 | radeon_connector->shared_ddc = true; |
1050 | radeon_connector->shared_ddc = true; |
1065 | shared_ddc = true; |
1051 | shared_ddc = true; |
1066 | } |
1052 | } |
1067 | } |
1053 | } |
1068 | } |
1054 | } |
1069 | 1055 | ||
1070 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
1056 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
1071 | if (!radeon_connector) |
1057 | if (!radeon_connector) |
1072 | return; |
1058 | return; |
1073 | 1059 | ||
1074 | connector = &radeon_connector->base; |
1060 | connector = &radeon_connector->base; |
1075 | 1061 | ||
1076 | radeon_connector->connector_id = connector_id; |
1062 | radeon_connector->connector_id = connector_id; |
1077 | radeon_connector->devices = supported_device; |
1063 | radeon_connector->devices = supported_device; |
1078 | radeon_connector->shared_ddc = shared_ddc; |
1064 | radeon_connector->shared_ddc = shared_ddc; |
1079 | radeon_connector->connector_object_id = connector_object_id; |
1065 | radeon_connector->connector_object_id = connector_object_id; |
1080 | radeon_connector->hpd = *hpd; |
1066 | radeon_connector->hpd = *hpd; |
1081 | switch (connector_type) { |
1067 | switch (connector_type) { |
1082 | case DRM_MODE_CONNECTOR_VGA: |
1068 | case DRM_MODE_CONNECTOR_VGA: |
1083 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1069 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1084 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1070 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1085 | if (ret) |
1071 | if (ret) |
1086 | goto failed; |
1072 | goto failed; |
1087 | if (i2c_bus->valid) { |
1073 | if (i2c_bus->valid) { |
1088 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); |
1074 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); |
1089 | if (!radeon_connector->ddc_bus) |
1075 | if (!radeon_connector->ddc_bus) |
1090 | goto failed; |
1076 | goto failed; |
1091 | } |
1077 | } |
1092 | radeon_connector->dac_load_detect = true; |
1078 | radeon_connector->dac_load_detect = true; |
1093 | drm_connector_attach_property(&radeon_connector->base, |
1079 | drm_connector_attach_property(&radeon_connector->base, |
1094 | rdev->mode_info.load_detect_property, |
1080 | rdev->mode_info.load_detect_property, |
1095 | 1); |
1081 | 1); |
1096 | break; |
1082 | break; |
1097 | case DRM_MODE_CONNECTOR_DVIA: |
1083 | case DRM_MODE_CONNECTOR_DVIA: |
1098 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1084 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1099 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1085 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1100 | if (ret) |
1086 | if (ret) |
1101 | goto failed; |
1087 | goto failed; |
1102 | if (i2c_bus->valid) { |
1088 | if (i2c_bus->valid) { |
1103 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1089 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1104 | if (!radeon_connector->ddc_bus) |
1090 | if (!radeon_connector->ddc_bus) |
1105 | goto failed; |
1091 | goto failed; |
1106 | } |
1092 | } |
1107 | radeon_connector->dac_load_detect = true; |
1093 | radeon_connector->dac_load_detect = true; |
1108 | drm_connector_attach_property(&radeon_connector->base, |
1094 | drm_connector_attach_property(&radeon_connector->base, |
1109 | rdev->mode_info.load_detect_property, |
1095 | rdev->mode_info.load_detect_property, |
1110 | 1); |
1096 | 1); |
1111 | break; |
1097 | break; |
1112 | case DRM_MODE_CONNECTOR_DVII: |
1098 | case DRM_MODE_CONNECTOR_DVII: |
1113 | case DRM_MODE_CONNECTOR_DVID: |
1099 | case DRM_MODE_CONNECTOR_DVID: |
1114 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1100 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1115 | if (!radeon_dig_connector) |
1101 | if (!radeon_dig_connector) |
1116 | goto failed; |
1102 | goto failed; |
1117 | radeon_dig_connector->linkb = linkb; |
1103 | radeon_dig_connector->linkb = linkb; |
1118 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1104 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1119 | radeon_connector->con_priv = radeon_dig_connector; |
1105 | radeon_connector->con_priv = radeon_dig_connector; |
1120 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1106 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1121 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1107 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1122 | if (ret) |
1108 | if (ret) |
1123 | goto failed; |
1109 | goto failed; |
1124 | if (i2c_bus->valid) { |
1110 | if (i2c_bus->valid) { |
1125 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1111 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1126 | if (!radeon_connector->ddc_bus) |
1112 | if (!radeon_connector->ddc_bus) |
1127 | goto failed; |
1113 | goto failed; |
1128 | } |
1114 | } |
1129 | subpixel_order = SubPixelHorizontalRGB; |
1115 | subpixel_order = SubPixelHorizontalRGB; |
1130 | drm_connector_attach_property(&radeon_connector->base, |
1116 | drm_connector_attach_property(&radeon_connector->base, |
1131 | rdev->mode_info.coherent_mode_property, |
1117 | rdev->mode_info.coherent_mode_property, |
1132 | 1); |
1118 | 1); |
1133 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
1119 | if (connector_type == DRM_MODE_CONNECTOR_DVII) { |
1134 | radeon_connector->dac_load_detect = true; |
1120 | radeon_connector->dac_load_detect = true; |
1135 | drm_connector_attach_property(&radeon_connector->base, |
1121 | drm_connector_attach_property(&radeon_connector->base, |
1136 | rdev->mode_info.load_detect_property, |
1122 | rdev->mode_info.load_detect_property, |
1137 | 1); |
1123 | 1); |
1138 | } |
1124 | } |
1139 | break; |
1125 | break; |
1140 | case DRM_MODE_CONNECTOR_HDMIA: |
1126 | case DRM_MODE_CONNECTOR_HDMIA: |
1141 | case DRM_MODE_CONNECTOR_HDMIB: |
1127 | case DRM_MODE_CONNECTOR_HDMIB: |
1142 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1128 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1143 | if (!radeon_dig_connector) |
1129 | if (!radeon_dig_connector) |
1144 | goto failed; |
1130 | goto failed; |
1145 | radeon_dig_connector->linkb = linkb; |
1131 | radeon_dig_connector->linkb = linkb; |
1146 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1132 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1147 | radeon_connector->con_priv = radeon_dig_connector; |
1133 | radeon_connector->con_priv = radeon_dig_connector; |
1148 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1134 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1149 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1135 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1150 | if (ret) |
1136 | if (ret) |
1151 | goto failed; |
1137 | goto failed; |
1152 | if (i2c_bus->valid) { |
1138 | if (i2c_bus->valid) { |
1153 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "HDMI"); |
1139 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "HDMI"); |
1154 | if (!radeon_connector->ddc_bus) |
1140 | if (!radeon_connector->ddc_bus) |
1155 | goto failed; |
1141 | goto failed; |
1156 | } |
1142 | } |
1157 | drm_connector_attach_property(&radeon_connector->base, |
1143 | drm_connector_attach_property(&radeon_connector->base, |
1158 | rdev->mode_info.coherent_mode_property, |
1144 | rdev->mode_info.coherent_mode_property, |
1159 | 1); |
1145 | 1); |
1160 | subpixel_order = SubPixelHorizontalRGB; |
1146 | subpixel_order = SubPixelHorizontalRGB; |
1161 | break; |
1147 | break; |
1162 | case DRM_MODE_CONNECTOR_DisplayPort: |
1148 | case DRM_MODE_CONNECTOR_DisplayPort: |
1163 | case DRM_MODE_CONNECTOR_eDP: |
1149 | case DRM_MODE_CONNECTOR_eDP: |
1164 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1150 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1165 | if (!radeon_dig_connector) |
1151 | if (!radeon_dig_connector) |
1166 | goto failed; |
1152 | goto failed; |
1167 | radeon_dig_connector->linkb = linkb; |
1153 | radeon_dig_connector->linkb = linkb; |
1168 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1154 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1169 | radeon_connector->con_priv = radeon_dig_connector; |
1155 | radeon_connector->con_priv = radeon_dig_connector; |
1170 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
1156 | drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type); |
1171 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
1157 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs); |
1172 | if (ret) |
1158 | if (ret) |
1173 | goto failed; |
1159 | goto failed; |
1174 | if (i2c_bus->valid) { |
1160 | if (i2c_bus->valid) { |
1175 | /* add DP i2c bus */ |
1161 | /* add DP i2c bus */ |
1176 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
1162 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
1177 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); |
1163 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "eDP-auxch"); |
1178 | else |
1164 | else |
1179 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); |
1165 | radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); |
1180 | if (!radeon_dig_connector->dp_i2c_bus) |
1166 | if (!radeon_dig_connector->dp_i2c_bus) |
1181 | goto failed; |
1167 | goto failed; |
1182 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
1168 | if (connector_type == DRM_MODE_CONNECTOR_eDP) |
1183 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "eDP"); |
1169 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "eDP"); |
1184 | else |
1170 | else |
1185 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP"); |
1171 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DP"); |
1186 | if (!radeon_connector->ddc_bus) |
1172 | if (!radeon_connector->ddc_bus) |
1187 | goto failed; |
1173 | goto failed; |
1188 | } |
1174 | } |
1189 | subpixel_order = SubPixelHorizontalRGB; |
1175 | subpixel_order = SubPixelHorizontalRGB; |
1190 | drm_connector_attach_property(&radeon_connector->base, |
1176 | drm_connector_attach_property(&radeon_connector->base, |
1191 | rdev->mode_info.coherent_mode_property, |
1177 | rdev->mode_info.coherent_mode_property, |
1192 | 1); |
1178 | 1); |
1193 | break; |
1179 | break; |
1194 | case DRM_MODE_CONNECTOR_SVIDEO: |
1180 | case DRM_MODE_CONNECTOR_SVIDEO: |
1195 | case DRM_MODE_CONNECTOR_Composite: |
1181 | case DRM_MODE_CONNECTOR_Composite: |
1196 | case DRM_MODE_CONNECTOR_9PinDIN: |
1182 | case DRM_MODE_CONNECTOR_9PinDIN: |
1197 | if (radeon_tv == 1) { |
1183 | if (radeon_tv == 1) { |
1198 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
1184 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
1199 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
1185 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
1200 | if (ret) |
1186 | if (ret) |
1201 | goto failed; |
1187 | goto failed; |
1202 | radeon_connector->dac_load_detect = true; |
1188 | radeon_connector->dac_load_detect = true; |
1203 | drm_connector_attach_property(&radeon_connector->base, |
1189 | drm_connector_attach_property(&radeon_connector->base, |
1204 | rdev->mode_info.load_detect_property, |
1190 | rdev->mode_info.load_detect_property, |
1205 | 1); |
1191 | 1); |
1206 | drm_connector_attach_property(&radeon_connector->base, |
1192 | drm_connector_attach_property(&radeon_connector->base, |
1207 | rdev->mode_info.tv_std_property, |
1193 | rdev->mode_info.tv_std_property, |
1208 | radeon_atombios_get_tv_info(rdev)); |
1194 | radeon_atombios_get_tv_info(rdev)); |
1209 | } |
1195 | } |
1210 | break; |
1196 | break; |
1211 | case DRM_MODE_CONNECTOR_LVDS: |
1197 | case DRM_MODE_CONNECTOR_LVDS: |
1212 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1198 | radeon_dig_connector = kzalloc(sizeof(struct radeon_connector_atom_dig), GFP_KERNEL); |
1213 | if (!radeon_dig_connector) |
1199 | if (!radeon_dig_connector) |
1214 | goto failed; |
1200 | goto failed; |
1215 | radeon_dig_connector->linkb = linkb; |
1201 | radeon_dig_connector->linkb = linkb; |
1216 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1202 | radeon_dig_connector->igp_lane_info = igp_lane_info; |
1217 | radeon_connector->con_priv = radeon_dig_connector; |
1203 | radeon_connector->con_priv = radeon_dig_connector; |
1218 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
1204 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
1219 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
1205 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
1220 | if (ret) |
1206 | if (ret) |
1221 | goto failed; |
1207 | goto failed; |
1222 | if (i2c_bus->valid) { |
1208 | if (i2c_bus->valid) { |
1223 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); |
1209 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); |
1224 | if (!radeon_connector->ddc_bus) |
1210 | if (!radeon_connector->ddc_bus) |
1225 | goto failed; |
1211 | goto failed; |
1226 | } |
1212 | } |
1227 | drm_connector_attach_property(&radeon_connector->base, |
1213 | drm_connector_attach_property(&radeon_connector->base, |
1228 | dev->mode_config.scaling_mode_property, |
1214 | dev->mode_config.scaling_mode_property, |
1229 | DRM_MODE_SCALE_FULLSCREEN); |
1215 | DRM_MODE_SCALE_FULLSCREEN); |
1230 | subpixel_order = SubPixelHorizontalRGB; |
1216 | subpixel_order = SubPixelHorizontalRGB; |
1231 | break; |
1217 | break; |
1232 | } |
1218 | } |
1233 | 1219 | ||
1234 | connector->display_info.subpixel_order = subpixel_order; |
1220 | connector->display_info.subpixel_order = subpixel_order; |
1235 | drm_sysfs_connector_add(connector); |
1221 | drm_sysfs_connector_add(connector); |
1236 | return; |
1222 | return; |
1237 | 1223 | ||
1238 | failed: |
1224 | failed: |
1239 | if (radeon_connector->ddc_bus) |
1225 | if (radeon_connector->ddc_bus) |
1240 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
1226 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
1241 | drm_connector_cleanup(connector); |
1227 | drm_connector_cleanup(connector); |
1242 | kfree(connector); |
1228 | kfree(connector); |
1243 | } |
1229 | } |
1244 | 1230 | ||
1245 | void |
1231 | void |
1246 | radeon_add_legacy_connector(struct drm_device *dev, |
1232 | radeon_add_legacy_connector(struct drm_device *dev, |
1247 | uint32_t connector_id, |
1233 | uint32_t connector_id, |
1248 | uint32_t supported_device, |
1234 | uint32_t supported_device, |
1249 | int connector_type, |
1235 | int connector_type, |
1250 | struct radeon_i2c_bus_rec *i2c_bus, |
1236 | struct radeon_i2c_bus_rec *i2c_bus, |
1251 | uint16_t connector_object_id, |
1237 | uint16_t connector_object_id, |
1252 | struct radeon_hpd *hpd) |
1238 | struct radeon_hpd *hpd) |
1253 | { |
1239 | { |
1254 | struct radeon_device *rdev = dev->dev_private; |
1240 | struct radeon_device *rdev = dev->dev_private; |
1255 | struct drm_connector *connector; |
1241 | struct drm_connector *connector; |
1256 | struct radeon_connector *radeon_connector; |
1242 | struct radeon_connector *radeon_connector; |
1257 | uint32_t subpixel_order = SubPixelNone; |
1243 | uint32_t subpixel_order = SubPixelNone; |
1258 | int ret; |
1244 | int ret; |
1259 | 1245 | ||
1260 | /* fixme - tv/cv/din */ |
1246 | /* fixme - tv/cv/din */ |
1261 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
1247 | if (connector_type == DRM_MODE_CONNECTOR_Unknown) |
1262 | return; |
1248 | return; |
1263 | 1249 | ||
1264 | /* see if we already added it */ |
1250 | /* see if we already added it */ |
1265 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
1251 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
1266 | radeon_connector = to_radeon_connector(connector); |
1252 | radeon_connector = to_radeon_connector(connector); |
1267 | if (radeon_connector->connector_id == connector_id) { |
1253 | if (radeon_connector->connector_id == connector_id) { |
1268 | radeon_connector->devices |= supported_device; |
1254 | radeon_connector->devices |= supported_device; |
1269 | return; |
1255 | return; |
1270 | } |
1256 | } |
1271 | } |
1257 | } |
1272 | 1258 | ||
1273 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
1259 | radeon_connector = kzalloc(sizeof(struct radeon_connector), GFP_KERNEL); |
1274 | if (!radeon_connector) |
1260 | if (!radeon_connector) |
1275 | return; |
1261 | return; |
1276 | 1262 | ||
1277 | connector = &radeon_connector->base; |
1263 | connector = &radeon_connector->base; |
1278 | 1264 | ||
1279 | radeon_connector->connector_id = connector_id; |
1265 | radeon_connector->connector_id = connector_id; |
1280 | radeon_connector->devices = supported_device; |
1266 | radeon_connector->devices = supported_device; |
1281 | radeon_connector->connector_object_id = connector_object_id; |
1267 | radeon_connector->connector_object_id = connector_object_id; |
1282 | radeon_connector->hpd = *hpd; |
1268 | radeon_connector->hpd = *hpd; |
1283 | switch (connector_type) { |
1269 | switch (connector_type) { |
1284 | case DRM_MODE_CONNECTOR_VGA: |
1270 | case DRM_MODE_CONNECTOR_VGA: |
1285 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1271 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1286 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1272 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1287 | if (ret) |
1273 | if (ret) |
1288 | goto failed; |
1274 | goto failed; |
1289 | if (i2c_bus->valid) { |
1275 | if (i2c_bus->valid) { |
1290 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); |
1276 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "VGA"); |
1291 | if (!radeon_connector->ddc_bus) |
1277 | if (!radeon_connector->ddc_bus) |
1292 | goto failed; |
1278 | goto failed; |
1293 | } |
1279 | } |
1294 | radeon_connector->dac_load_detect = true; |
1280 | radeon_connector->dac_load_detect = true; |
1295 | drm_connector_attach_property(&radeon_connector->base, |
1281 | drm_connector_attach_property(&radeon_connector->base, |
1296 | rdev->mode_info.load_detect_property, |
1282 | rdev->mode_info.load_detect_property, |
1297 | 1); |
1283 | 1); |
1298 | break; |
1284 | break; |
1299 | case DRM_MODE_CONNECTOR_DVIA: |
1285 | case DRM_MODE_CONNECTOR_DVIA: |
1300 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1286 | drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type); |
1301 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1287 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs); |
1302 | if (ret) |
1288 | if (ret) |
1303 | goto failed; |
1289 | goto failed; |
1304 | if (i2c_bus->valid) { |
1290 | if (i2c_bus->valid) { |
1305 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1291 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1306 | if (!radeon_connector->ddc_bus) |
1292 | if (!radeon_connector->ddc_bus) |
1307 | goto failed; |
1293 | goto failed; |
1308 | } |
1294 | } |
1309 | radeon_connector->dac_load_detect = true; |
1295 | radeon_connector->dac_load_detect = true; |
1310 | drm_connector_attach_property(&radeon_connector->base, |
1296 | drm_connector_attach_property(&radeon_connector->base, |
1311 | rdev->mode_info.load_detect_property, |
1297 | rdev->mode_info.load_detect_property, |
1312 | 1); |
1298 | 1); |
1313 | break; |
1299 | break; |
1314 | case DRM_MODE_CONNECTOR_DVII: |
1300 | case DRM_MODE_CONNECTOR_DVII: |
1315 | case DRM_MODE_CONNECTOR_DVID: |
1301 | case DRM_MODE_CONNECTOR_DVID: |
1316 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1302 | drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type); |
1317 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1303 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs); |
1318 | if (ret) |
1304 | if (ret) |
1319 | goto failed; |
1305 | goto failed; |
1320 | if (i2c_bus->valid) { |
1306 | if (i2c_bus->valid) { |
1321 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1307 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); |
1322 | if (!radeon_connector->ddc_bus) |
1308 | if (!radeon_connector->ddc_bus) |
1323 | goto failed; |
1309 | goto failed; |
1324 | radeon_connector->dac_load_detect = true; |
1310 | radeon_connector->dac_load_detect = true; |
1325 | drm_connector_attach_property(&radeon_connector->base, |
1311 | drm_connector_attach_property(&radeon_connector->base, |
1326 | rdev->mode_info.load_detect_property, |
1312 | rdev->mode_info.load_detect_property, |
1327 | 1); |
1313 | 1); |
1328 | } |
1314 | } |
1329 | subpixel_order = SubPixelHorizontalRGB; |
1315 | subpixel_order = SubPixelHorizontalRGB; |
1330 | break; |
1316 | break; |
1331 | case DRM_MODE_CONNECTOR_SVIDEO: |
1317 | case DRM_MODE_CONNECTOR_SVIDEO: |
1332 | case DRM_MODE_CONNECTOR_Composite: |
1318 | case DRM_MODE_CONNECTOR_Composite: |
1333 | case DRM_MODE_CONNECTOR_9PinDIN: |
1319 | case DRM_MODE_CONNECTOR_9PinDIN: |
1334 | if (radeon_tv == 1) { |
1320 | if (radeon_tv == 1) { |
1335 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
1321 | drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type); |
1336 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
1322 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs); |
1337 | if (ret) |
1323 | if (ret) |
1338 | goto failed; |
1324 | goto failed; |
1339 | radeon_connector->dac_load_detect = true; |
1325 | radeon_connector->dac_load_detect = true; |
1340 | /* RS400,RC410,RS480 chipset seems to report a lot |
1326 | /* RS400,RC410,RS480 chipset seems to report a lot |
1341 | * of false positive on load detect, we haven't yet |
1327 | * of false positive on load detect, we haven't yet |
1342 | * found a way to make load detect reliable on those |
1328 | * found a way to make load detect reliable on those |
1343 | * chipset, thus just disable it for TV. |
1329 | * chipset, thus just disable it for TV. |
1344 | */ |
1330 | */ |
1345 | if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) |
1331 | if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) |
1346 | radeon_connector->dac_load_detect = false; |
1332 | radeon_connector->dac_load_detect = false; |
1347 | drm_connector_attach_property(&radeon_connector->base, |
1333 | drm_connector_attach_property(&radeon_connector->base, |
1348 | rdev->mode_info.load_detect_property, |
1334 | rdev->mode_info.load_detect_property, |
1349 | radeon_connector->dac_load_detect); |
1335 | radeon_connector->dac_load_detect); |
1350 | drm_connector_attach_property(&radeon_connector->base, |
1336 | drm_connector_attach_property(&radeon_connector->base, |
1351 | rdev->mode_info.tv_std_property, |
1337 | rdev->mode_info.tv_std_property, |
1352 | radeon_combios_get_tv_info(rdev)); |
1338 | radeon_combios_get_tv_info(rdev)); |
1353 | } |
1339 | } |
1354 | break; |
1340 | break; |
1355 | case DRM_MODE_CONNECTOR_LVDS: |
1341 | case DRM_MODE_CONNECTOR_LVDS: |
1356 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
1342 | drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type); |
1357 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
1343 | ret = drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs); |
1358 | if (ret) |
1344 | if (ret) |
1359 | goto failed; |
1345 | goto failed; |
1360 | if (i2c_bus->valid) { |
1346 | if (i2c_bus->valid) { |
1361 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); |
1347 | radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "LVDS"); |
1362 | if (!radeon_connector->ddc_bus) |
1348 | if (!radeon_connector->ddc_bus) |
1363 | goto failed; |
1349 | goto failed; |
1364 | } |
1350 | } |
1365 | drm_connector_attach_property(&radeon_connector->base, |
1351 | drm_connector_attach_property(&radeon_connector->base, |
1366 | dev->mode_config.scaling_mode_property, |
1352 | dev->mode_config.scaling_mode_property, |
1367 | DRM_MODE_SCALE_FULLSCREEN); |
1353 | DRM_MODE_SCALE_FULLSCREEN); |
1368 | subpixel_order = SubPixelHorizontalRGB; |
1354 | subpixel_order = SubPixelHorizontalRGB; |
1369 | break; |
1355 | break; |
1370 | } |
1356 | } |
1371 | 1357 | ||
1372 | connector->display_info.subpixel_order = subpixel_order; |
1358 | connector->display_info.subpixel_order = subpixel_order; |
1373 | drm_sysfs_connector_add(connector); |
1359 | drm_sysfs_connector_add(connector); |
1374 | return; |
1360 | return; |
1375 | 1361 | ||
1376 | failed: |
1362 | failed: |
1377 | if (radeon_connector->ddc_bus) |
1363 | if (radeon_connector->ddc_bus) |
1378 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
1364 | radeon_i2c_destroy(radeon_connector->ddc_bus); |
1379 | drm_connector_cleanup(connector); |
1365 | drm_connector_cleanup(connector); |
1380 | kfree(connector); |
1366 | kfree(connector); |
1381 | }>>>>>>>>>> |
1367 | }>>>>>>>>>> |