diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_mode.h')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_mode.h | 394 |
1 files changed, 394 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h new file mode 100644 index 000000000000..4b37746eae55 --- /dev/null +++ b/drivers/gpu/drm/radeon/radeon_mode.h | |||
@@ -0,0 +1,394 @@ | |||
1 | /* | ||
2 | * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and | ||
3 | * VA Linux Systems Inc., Fremont, California. | ||
4 | * Copyright 2008 Red Hat Inc. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included in | ||
14 | * all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
22 | * OTHER DEALINGS IN THE SOFTWARE. | ||
23 | * | ||
24 | * Original Authors: | ||
25 | * Kevin E. Martin, Rickard E. Faith, Alan Hourihane | ||
26 | * | ||
27 | * Kernel port Author: Dave Airlie | ||
28 | */ | ||
29 | |||
30 | #ifndef RADEON_MODE_H | ||
31 | #define RADEON_MODE_H | ||
32 | |||
33 | #include <drm_crtc.h> | ||
34 | #include <drm_mode.h> | ||
35 | #include <drm_edid.h> | ||
36 | #include <linux/i2c.h> | ||
37 | #include <linux/i2c-id.h> | ||
38 | #include <linux/i2c-algo-bit.h> | ||
39 | |||
40 | #define to_radeon_crtc(x) container_of(x, struct radeon_crtc, base) | ||
41 | #define to_radeon_connector(x) container_of(x, struct radeon_connector, base) | ||
42 | #define to_radeon_encoder(x) container_of(x, struct radeon_encoder, base) | ||
43 | #define to_radeon_framebuffer(x) container_of(x, struct radeon_framebuffer, base) | ||
44 | |||
45 | enum radeon_connector_type { | ||
46 | CONNECTOR_NONE, | ||
47 | CONNECTOR_VGA, | ||
48 | CONNECTOR_DVI_I, | ||
49 | CONNECTOR_DVI_D, | ||
50 | CONNECTOR_DVI_A, | ||
51 | CONNECTOR_STV, | ||
52 | CONNECTOR_CTV, | ||
53 | CONNECTOR_LVDS, | ||
54 | CONNECTOR_DIGITAL, | ||
55 | CONNECTOR_SCART, | ||
56 | CONNECTOR_HDMI_TYPE_A, | ||
57 | CONNECTOR_HDMI_TYPE_B, | ||
58 | CONNECTOR_0XC, | ||
59 | CONNECTOR_0XD, | ||
60 | CONNECTOR_DIN, | ||
61 | CONNECTOR_DISPLAY_PORT, | ||
62 | CONNECTOR_UNSUPPORTED | ||
63 | }; | ||
64 | |||
65 | enum radeon_dvi_type { | ||
66 | DVI_AUTO, | ||
67 | DVI_DIGITAL, | ||
68 | DVI_ANALOG | ||
69 | }; | ||
70 | |||
71 | enum radeon_rmx_type { | ||
72 | RMX_OFF, | ||
73 | RMX_FULL, | ||
74 | RMX_CENTER, | ||
75 | RMX_ASPECT | ||
76 | }; | ||
77 | |||
78 | enum radeon_tv_std { | ||
79 | TV_STD_NTSC, | ||
80 | TV_STD_PAL, | ||
81 | TV_STD_PAL_M, | ||
82 | TV_STD_PAL_60, | ||
83 | TV_STD_NTSC_J, | ||
84 | TV_STD_SCART_PAL, | ||
85 | TV_STD_SECAM, | ||
86 | TV_STD_PAL_CN, | ||
87 | }; | ||
88 | |||
89 | struct radeon_i2c_bus_rec { | ||
90 | bool valid; | ||
91 | uint32_t mask_clk_reg; | ||
92 | uint32_t mask_data_reg; | ||
93 | uint32_t a_clk_reg; | ||
94 | uint32_t a_data_reg; | ||
95 | uint32_t put_clk_reg; | ||
96 | uint32_t put_data_reg; | ||
97 | uint32_t get_clk_reg; | ||
98 | uint32_t get_data_reg; | ||
99 | uint32_t mask_clk_mask; | ||
100 | uint32_t mask_data_mask; | ||
101 | uint32_t put_clk_mask; | ||
102 | uint32_t put_data_mask; | ||
103 | uint32_t get_clk_mask; | ||
104 | uint32_t get_data_mask; | ||
105 | uint32_t a_clk_mask; | ||
106 | uint32_t a_data_mask; | ||
107 | }; | ||
108 | |||
109 | struct radeon_tmds_pll { | ||
110 | uint32_t freq; | ||
111 | uint32_t value; | ||
112 | }; | ||
113 | |||
114 | #define RADEON_MAX_BIOS_CONNECTOR 16 | ||
115 | |||
116 | #define RADEON_PLL_USE_BIOS_DIVS (1 << 0) | ||
117 | #define RADEON_PLL_NO_ODD_POST_DIV (1 << 1) | ||
118 | #define RADEON_PLL_USE_REF_DIV (1 << 2) | ||
119 | #define RADEON_PLL_LEGACY (1 << 3) | ||
120 | #define RADEON_PLL_PREFER_LOW_REF_DIV (1 << 4) | ||
121 | #define RADEON_PLL_PREFER_HIGH_REF_DIV (1 << 5) | ||
122 | #define RADEON_PLL_PREFER_LOW_FB_DIV (1 << 6) | ||
123 | #define RADEON_PLL_PREFER_HIGH_FB_DIV (1 << 7) | ||
124 | #define RADEON_PLL_PREFER_LOW_POST_DIV (1 << 8) | ||
125 | #define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9) | ||
126 | #define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10) | ||
127 | |||
128 | struct radeon_pll { | ||
129 | uint16_t reference_freq; | ||
130 | uint16_t reference_div; | ||
131 | uint32_t pll_in_min; | ||
132 | uint32_t pll_in_max; | ||
133 | uint32_t pll_out_min; | ||
134 | uint32_t pll_out_max; | ||
135 | uint16_t xclk; | ||
136 | |||
137 | uint32_t min_ref_div; | ||
138 | uint32_t max_ref_div; | ||
139 | uint32_t min_post_div; | ||
140 | uint32_t max_post_div; | ||
141 | uint32_t min_feedback_div; | ||
142 | uint32_t max_feedback_div; | ||
143 | uint32_t min_frac_feedback_div; | ||
144 | uint32_t max_frac_feedback_div; | ||
145 | uint32_t best_vco; | ||
146 | }; | ||
147 | |||
148 | struct radeon_i2c_chan { | ||
149 | struct drm_device *dev; | ||
150 | struct i2c_adapter adapter; | ||
151 | struct i2c_algo_bit_data algo; | ||
152 | struct radeon_i2c_bus_rec rec; | ||
153 | }; | ||
154 | |||
155 | /* mostly for macs, but really any system without connector tables */ | ||
156 | enum radeon_connector_table { | ||
157 | CT_NONE, | ||
158 | CT_GENERIC, | ||
159 | CT_IBOOK, | ||
160 | CT_POWERBOOK_EXTERNAL, | ||
161 | CT_POWERBOOK_INTERNAL, | ||
162 | CT_POWERBOOK_VGA, | ||
163 | CT_MINI_EXTERNAL, | ||
164 | CT_MINI_INTERNAL, | ||
165 | CT_IMAC_G5_ISIGHT, | ||
166 | CT_EMAC, | ||
167 | }; | ||
168 | |||
169 | struct radeon_mode_info { | ||
170 | struct atom_context *atom_context; | ||
171 | enum radeon_connector_table connector_table; | ||
172 | bool mode_config_initialized; | ||
173 | }; | ||
174 | |||
175 | struct radeon_crtc { | ||
176 | struct drm_crtc base; | ||
177 | int crtc_id; | ||
178 | u16 lut_r[256], lut_g[256], lut_b[256]; | ||
179 | bool enabled; | ||
180 | bool can_tile; | ||
181 | uint32_t crtc_offset; | ||
182 | struct radeon_framebuffer *fbdev_fb; | ||
183 | struct drm_mode_set mode_set; | ||
184 | struct drm_gem_object *cursor_bo; | ||
185 | uint64_t cursor_addr; | ||
186 | int cursor_width; | ||
187 | int cursor_height; | ||
188 | }; | ||
189 | |||
190 | #define RADEON_USE_RMX 1 | ||
191 | |||
192 | struct radeon_native_mode { | ||
193 | /* preferred mode */ | ||
194 | uint32_t panel_xres, panel_yres; | ||
195 | uint32_t hoverplus, hsync_width; | ||
196 | uint32_t hblank; | ||
197 | uint32_t voverplus, vsync_width; | ||
198 | uint32_t vblank; | ||
199 | uint32_t dotclock; | ||
200 | uint32_t flags; | ||
201 | }; | ||
202 | |||
203 | struct radeon_encoder_primary_dac { | ||
204 | /* legacy primary dac */ | ||
205 | uint32_t ps2_pdac_adj; | ||
206 | }; | ||
207 | |||
208 | struct radeon_encoder_lvds { | ||
209 | /* legacy lvds */ | ||
210 | uint16_t panel_vcc_delay; | ||
211 | uint8_t panel_pwr_delay; | ||
212 | uint8_t panel_digon_delay; | ||
213 | uint8_t panel_blon_delay; | ||
214 | uint16_t panel_ref_divider; | ||
215 | uint8_t panel_post_divider; | ||
216 | uint16_t panel_fb_divider; | ||
217 | bool use_bios_dividers; | ||
218 | uint32_t lvds_gen_cntl; | ||
219 | /* panel mode */ | ||
220 | struct radeon_native_mode native_mode; | ||
221 | }; | ||
222 | |||
223 | struct radeon_encoder_tv_dac { | ||
224 | /* legacy tv dac */ | ||
225 | uint32_t ps2_tvdac_adj; | ||
226 | uint32_t ntsc_tvdac_adj; | ||
227 | uint32_t pal_tvdac_adj; | ||
228 | |||
229 | enum radeon_tv_std tv_std; | ||
230 | }; | ||
231 | |||
232 | struct radeon_encoder_int_tmds { | ||
233 | /* legacy int tmds */ | ||
234 | struct radeon_tmds_pll tmds_pll[4]; | ||
235 | }; | ||
236 | |||
237 | struct radeon_encoder_atom_dig { | ||
238 | /* atom dig */ | ||
239 | bool coherent_mode; | ||
240 | int dig_block; | ||
241 | /* atom lvds */ | ||
242 | uint32_t lvds_misc; | ||
243 | uint16_t panel_pwr_delay; | ||
244 | /* panel mode */ | ||
245 | struct radeon_native_mode native_mode; | ||
246 | }; | ||
247 | |||
248 | struct radeon_encoder { | ||
249 | struct drm_encoder base; | ||
250 | uint32_t encoder_id; | ||
251 | uint32_t devices; | ||
252 | uint32_t flags; | ||
253 | uint32_t pixel_clock; | ||
254 | enum radeon_rmx_type rmx_type; | ||
255 | struct radeon_native_mode native_mode; | ||
256 | void *enc_priv; | ||
257 | }; | ||
258 | |||
259 | struct radeon_connector_atom_dig { | ||
260 | uint32_t igp_lane_info; | ||
261 | bool linkb; | ||
262 | }; | ||
263 | |||
264 | struct radeon_connector { | ||
265 | struct drm_connector base; | ||
266 | uint32_t connector_id; | ||
267 | uint32_t devices; | ||
268 | struct radeon_i2c_chan *ddc_bus; | ||
269 | int use_digital; | ||
270 | void *con_priv; | ||
271 | }; | ||
272 | |||
273 | struct radeon_framebuffer { | ||
274 | struct drm_framebuffer base; | ||
275 | struct drm_gem_object *obj; | ||
276 | }; | ||
277 | |||
278 | extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, | ||
279 | struct radeon_i2c_bus_rec *rec, | ||
280 | const char *name); | ||
281 | extern void radeon_i2c_destroy(struct radeon_i2c_chan *i2c); | ||
282 | extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector); | ||
283 | extern int radeon_ddc_get_modes(struct radeon_connector *radeon_connector); | ||
284 | |||
285 | extern struct drm_encoder *radeon_best_encoder(struct drm_connector *connector); | ||
286 | |||
287 | extern void radeon_compute_pll(struct radeon_pll *pll, | ||
288 | uint64_t freq, | ||
289 | uint32_t *dot_clock_p, | ||
290 | uint32_t *fb_div_p, | ||
291 | uint32_t *frac_fb_div_p, | ||
292 | uint32_t *ref_div_p, | ||
293 | uint32_t *post_div_p, | ||
294 | int flags); | ||
295 | |||
296 | struct drm_encoder *radeon_encoder_legacy_lvds_add(struct drm_device *dev, int bios_index); | ||
297 | struct drm_encoder *radeon_encoder_legacy_primary_dac_add(struct drm_device *dev, int bios_index, int with_tv); | ||
298 | struct drm_encoder *radeon_encoder_legacy_tv_dac_add(struct drm_device *dev, int bios_index, int with_tv); | ||
299 | struct drm_encoder *radeon_encoder_legacy_tmds_int_add(struct drm_device *dev, int bios_index); | ||
300 | struct drm_encoder *radeon_encoder_legacy_tmds_ext_add(struct drm_device *dev, int bios_index); | ||
301 | extern void atombios_external_tmds_setup(struct drm_encoder *encoder, int action); | ||
302 | extern int atombios_get_encoder_mode(struct drm_encoder *encoder); | ||
303 | |||
304 | extern void radeon_crtc_load_lut(struct drm_crtc *crtc); | ||
305 | extern int atombios_crtc_set_base(struct drm_crtc *crtc, int x, int y, | ||
306 | struct drm_framebuffer *old_fb); | ||
307 | extern int atombios_crtc_mode_set(struct drm_crtc *crtc, | ||
308 | struct drm_display_mode *mode, | ||
309 | struct drm_display_mode *adjusted_mode, | ||
310 | int x, int y, | ||
311 | struct drm_framebuffer *old_fb); | ||
312 | extern void atombios_crtc_dpms(struct drm_crtc *crtc, int mode); | ||
313 | |||
314 | extern int radeon_crtc_set_base(struct drm_crtc *crtc, int x, int y, | ||
315 | struct drm_framebuffer *old_fb); | ||
316 | extern void radeon_legacy_atom_set_surface(struct drm_crtc *crtc); | ||
317 | |||
318 | extern int radeon_crtc_cursor_set(struct drm_crtc *crtc, | ||
319 | struct drm_file *file_priv, | ||
320 | uint32_t handle, | ||
321 | uint32_t width, | ||
322 | uint32_t height); | ||
323 | extern int radeon_crtc_cursor_move(struct drm_crtc *crtc, | ||
324 | int x, int y); | ||
325 | |||
326 | extern bool radeon_atom_get_clock_info(struct drm_device *dev); | ||
327 | extern bool radeon_combios_get_clock_info(struct drm_device *dev); | ||
328 | extern struct radeon_encoder_atom_dig * | ||
329 | radeon_atombios_get_lvds_info(struct radeon_encoder *encoder); | ||
330 | extern struct radeon_encoder_int_tmds * | ||
331 | radeon_atombios_get_tmds_info(struct radeon_encoder *encoder); | ||
332 | extern struct radeon_encoder_lvds * | ||
333 | radeon_combios_get_lvds_info(struct radeon_encoder *encoder); | ||
334 | extern struct radeon_encoder_int_tmds * | ||
335 | radeon_combios_get_tmds_info(struct radeon_encoder *encoder); | ||
336 | extern void radeon_combios_get_ext_tmds_info(struct radeon_encoder *encoder); | ||
337 | extern struct radeon_encoder_tv_dac * | ||
338 | radeon_combios_get_tv_dac_info(struct radeon_encoder *encoder); | ||
339 | extern struct radeon_encoder_primary_dac * | ||
340 | radeon_combios_get_primary_dac_info(struct radeon_encoder *encoder); | ||
341 | extern void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock); | ||
342 | extern void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev); | ||
343 | extern void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock); | ||
344 | extern void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev); | ||
345 | extern void | ||
346 | radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc); | ||
347 | extern void | ||
348 | radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on); | ||
349 | extern void | ||
350 | radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc); | ||
351 | extern void | ||
352 | radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on); | ||
353 | extern void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, | ||
354 | u16 blue, int regno); | ||
355 | struct drm_framebuffer *radeon_framebuffer_create(struct drm_device *dev, | ||
356 | struct drm_mode_fb_cmd *mode_cmd, | ||
357 | struct drm_gem_object *obj); | ||
358 | |||
359 | int radeonfb_probe(struct drm_device *dev); | ||
360 | |||
361 | int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); | ||
362 | bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev); | ||
363 | bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev); | ||
364 | void radeon_atombios_init_crtc(struct drm_device *dev, | ||
365 | struct radeon_crtc *radeon_crtc); | ||
366 | void radeon_legacy_init_crtc(struct drm_device *dev, | ||
367 | struct radeon_crtc *radeon_crtc); | ||
368 | void radeon_i2c_do_lock(struct radeon_connector *radeon_connector, int lock_state); | ||
369 | |||
370 | void radeon_get_clock_info(struct drm_device *dev); | ||
371 | |||
372 | extern bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev); | ||
373 | extern bool radeon_get_atom_connector_info_from_supported_devices_table(struct drm_device *dev); | ||
374 | |||
375 | void radeon_rmx_mode_fixup(struct drm_encoder *encoder, | ||
376 | struct drm_display_mode *mode, | ||
377 | struct drm_display_mode *adjusted_mode); | ||
378 | void radeon_enc_destroy(struct drm_encoder *encoder); | ||
379 | void radeon_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj); | ||
380 | void radeon_combios_asic_init(struct drm_device *dev); | ||
381 | extern int radeon_static_clocks_init(struct drm_device *dev); | ||
382 | void radeon_init_disp_bw_legacy(struct drm_device *dev, | ||
383 | struct drm_display_mode *mode1, | ||
384 | uint32_t pixel_bytes1, | ||
385 | struct drm_display_mode *mode2, | ||
386 | uint32_t pixel_bytes2); | ||
387 | void radeon_init_disp_bw_avivo(struct drm_device *dev, | ||
388 | struct drm_display_mode *mode1, | ||
389 | uint32_t pixel_bytes1, | ||
390 | struct drm_display_mode *mode2, | ||
391 | uint32_t pixel_bytes2); | ||
392 | void radeon_init_disp_bandwidth(struct drm_device *dev); | ||
393 | |||
394 | #endif | ||