Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 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> |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 36 | #include <drm_dp_helper.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 37 | #include <linux/i2c.h> |
| 38 | #include <linux/i2c-id.h> |
| 39 | #include <linux/i2c-algo-bit.h> |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 40 | #include "radeon_fixed.h" |
| 41 | |
| 42 | struct radeon_device; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 43 | |
| 44 | #define to_radeon_crtc(x) container_of(x, struct radeon_crtc, base) |
| 45 | #define to_radeon_connector(x) container_of(x, struct radeon_connector, base) |
| 46 | #define to_radeon_encoder(x) container_of(x, struct radeon_encoder, base) |
| 47 | #define to_radeon_framebuffer(x) container_of(x, struct radeon_framebuffer, base) |
| 48 | |
| 49 | enum radeon_connector_type { |
| 50 | CONNECTOR_NONE, |
| 51 | CONNECTOR_VGA, |
| 52 | CONNECTOR_DVI_I, |
| 53 | CONNECTOR_DVI_D, |
| 54 | CONNECTOR_DVI_A, |
| 55 | CONNECTOR_STV, |
| 56 | CONNECTOR_CTV, |
| 57 | CONNECTOR_LVDS, |
| 58 | CONNECTOR_DIGITAL, |
| 59 | CONNECTOR_SCART, |
| 60 | CONNECTOR_HDMI_TYPE_A, |
| 61 | CONNECTOR_HDMI_TYPE_B, |
| 62 | CONNECTOR_0XC, |
| 63 | CONNECTOR_0XD, |
| 64 | CONNECTOR_DIN, |
| 65 | CONNECTOR_DISPLAY_PORT, |
| 66 | CONNECTOR_UNSUPPORTED |
| 67 | }; |
| 68 | |
| 69 | enum radeon_dvi_type { |
| 70 | DVI_AUTO, |
| 71 | DVI_DIGITAL, |
| 72 | DVI_ANALOG |
| 73 | }; |
| 74 | |
| 75 | enum radeon_rmx_type { |
| 76 | RMX_OFF, |
| 77 | RMX_FULL, |
| 78 | RMX_CENTER, |
| 79 | RMX_ASPECT |
| 80 | }; |
| 81 | |
| 82 | enum radeon_tv_std { |
| 83 | TV_STD_NTSC, |
| 84 | TV_STD_PAL, |
| 85 | TV_STD_PAL_M, |
| 86 | TV_STD_PAL_60, |
| 87 | TV_STD_NTSC_J, |
| 88 | TV_STD_SCART_PAL, |
| 89 | TV_STD_SECAM, |
| 90 | TV_STD_PAL_CN, |
| 91 | }; |
| 92 | |
Alex Deucher | 9b9fe72 | 2009-11-10 15:59:44 -0500 | [diff] [blame] | 93 | /* radeon gpio-based i2c |
| 94 | * 1. "mask" reg and bits |
| 95 | * grabs the gpio pins for software use |
| 96 | * 0=not held 1=held |
| 97 | * 2. "a" reg and bits |
| 98 | * output pin value |
| 99 | * 0=low 1=high |
| 100 | * 3. "en" reg and bits |
| 101 | * sets the pin direction |
| 102 | * 0=input 1=output |
| 103 | * 4. "y" reg and bits |
| 104 | * input pin value |
| 105 | * 0=low 1=high |
| 106 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 107 | struct radeon_i2c_bus_rec { |
| 108 | bool valid; |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 109 | /* id used by atom */ |
| 110 | uint8_t i2c_id; |
| 111 | /* can be used with hw i2c engine */ |
| 112 | bool hw_capable; |
| 113 | /* uses multi-media i2c engine */ |
| 114 | bool mm_i2c; |
| 115 | /* regs and bits */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 116 | uint32_t mask_clk_reg; |
| 117 | uint32_t mask_data_reg; |
| 118 | uint32_t a_clk_reg; |
| 119 | uint32_t a_data_reg; |
Alex Deucher | 9b9fe72 | 2009-11-10 15:59:44 -0500 | [diff] [blame] | 120 | uint32_t en_clk_reg; |
| 121 | uint32_t en_data_reg; |
| 122 | uint32_t y_clk_reg; |
| 123 | uint32_t y_data_reg; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 124 | uint32_t mask_clk_mask; |
| 125 | uint32_t mask_data_mask; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 126 | uint32_t a_clk_mask; |
| 127 | uint32_t a_data_mask; |
Alex Deucher | 9b9fe72 | 2009-11-10 15:59:44 -0500 | [diff] [blame] | 128 | uint32_t en_clk_mask; |
| 129 | uint32_t en_data_mask; |
| 130 | uint32_t y_clk_mask; |
| 131 | uint32_t y_data_mask; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | struct radeon_tmds_pll { |
| 135 | uint32_t freq; |
| 136 | uint32_t value; |
| 137 | }; |
| 138 | |
| 139 | #define RADEON_MAX_BIOS_CONNECTOR 16 |
| 140 | |
| 141 | #define RADEON_PLL_USE_BIOS_DIVS (1 << 0) |
| 142 | #define RADEON_PLL_NO_ODD_POST_DIV (1 << 1) |
| 143 | #define RADEON_PLL_USE_REF_DIV (1 << 2) |
| 144 | #define RADEON_PLL_LEGACY (1 << 3) |
| 145 | #define RADEON_PLL_PREFER_LOW_REF_DIV (1 << 4) |
| 146 | #define RADEON_PLL_PREFER_HIGH_REF_DIV (1 << 5) |
| 147 | #define RADEON_PLL_PREFER_LOW_FB_DIV (1 << 6) |
| 148 | #define RADEON_PLL_PREFER_HIGH_FB_DIV (1 << 7) |
| 149 | #define RADEON_PLL_PREFER_LOW_POST_DIV (1 << 8) |
| 150 | #define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9) |
| 151 | #define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10) |
Alex Deucher | d0e275a | 2009-07-13 11:08:18 -0400 | [diff] [blame] | 152 | #define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 153 | |
| 154 | struct radeon_pll { |
| 155 | uint16_t reference_freq; |
| 156 | uint16_t reference_div; |
| 157 | uint32_t pll_in_min; |
| 158 | uint32_t pll_in_max; |
| 159 | uint32_t pll_out_min; |
| 160 | uint32_t pll_out_max; |
| 161 | uint16_t xclk; |
| 162 | |
| 163 | uint32_t min_ref_div; |
| 164 | uint32_t max_ref_div; |
| 165 | uint32_t min_post_div; |
| 166 | uint32_t max_post_div; |
| 167 | uint32_t min_feedback_div; |
| 168 | uint32_t max_feedback_div; |
| 169 | uint32_t min_frac_feedback_div; |
| 170 | uint32_t max_frac_feedback_div; |
| 171 | uint32_t best_vco; |
| 172 | }; |
| 173 | |
| 174 | struct radeon_i2c_chan { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 175 | struct i2c_adapter adapter; |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 176 | struct drm_device *dev; |
| 177 | union { |
| 178 | struct i2c_algo_dp_aux_data dp; |
| 179 | struct i2c_algo_bit_data bit; |
| 180 | } algo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 181 | struct radeon_i2c_bus_rec rec; |
| 182 | }; |
| 183 | |
| 184 | /* mostly for macs, but really any system without connector tables */ |
| 185 | enum radeon_connector_table { |
| 186 | CT_NONE, |
| 187 | CT_GENERIC, |
| 188 | CT_IBOOK, |
| 189 | CT_POWERBOOK_EXTERNAL, |
| 190 | CT_POWERBOOK_INTERNAL, |
| 191 | CT_POWERBOOK_VGA, |
| 192 | CT_MINI_EXTERNAL, |
| 193 | CT_MINI_INTERNAL, |
| 194 | CT_IMAC_G5_ISIGHT, |
| 195 | CT_EMAC, |
| 196 | }; |
| 197 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 198 | enum radeon_dvo_chip { |
| 199 | DVO_SIL164, |
| 200 | DVO_SIL1178, |
| 201 | }; |
| 202 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 203 | struct radeon_mode_info { |
| 204 | struct atom_context *atom_context; |
Mathias Fröhlich | 61c4b24 | 2009-10-27 15:08:01 -0400 | [diff] [blame] | 205 | struct card_info *atom_card_info; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 206 | enum radeon_connector_table connector_table; |
| 207 | bool mode_config_initialized; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 208 | struct radeon_crtc *crtcs[2]; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 209 | /* DVI-I properties */ |
| 210 | struct drm_property *coherent_mode_property; |
| 211 | /* DAC enable load detect */ |
| 212 | struct drm_property *load_detect_property; |
| 213 | /* TV standard load detect */ |
| 214 | struct drm_property *tv_std_property; |
| 215 | /* legacy TMDS PLL detect */ |
| 216 | struct drm_property *tmds_pll_property; |
| 217 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 218 | }; |
| 219 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 220 | #define MAX_H_CODE_TIMING_LEN 32 |
| 221 | #define MAX_V_CODE_TIMING_LEN 32 |
| 222 | |
| 223 | /* need to store these as reading |
| 224 | back code tables is excessive */ |
| 225 | struct radeon_tv_regs { |
| 226 | uint32_t tv_uv_adr; |
| 227 | uint32_t timing_cntl; |
| 228 | uint32_t hrestart; |
| 229 | uint32_t vrestart; |
| 230 | uint32_t frestart; |
| 231 | uint16_t h_code_timing[MAX_H_CODE_TIMING_LEN]; |
| 232 | uint16_t v_code_timing[MAX_V_CODE_TIMING_LEN]; |
| 233 | }; |
| 234 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 235 | struct radeon_crtc { |
| 236 | struct drm_crtc base; |
| 237 | int crtc_id; |
| 238 | u16 lut_r[256], lut_g[256], lut_b[256]; |
| 239 | bool enabled; |
| 240 | bool can_tile; |
| 241 | uint32_t crtc_offset; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 242 | struct drm_gem_object *cursor_bo; |
| 243 | uint64_t cursor_addr; |
| 244 | int cursor_width; |
| 245 | int cursor_height; |
Dave Airlie | 4162338 | 2009-07-09 15:04:19 +1000 | [diff] [blame] | 246 | uint32_t legacy_display_base_addr; |
Alex Deucher | c836e86 | 2009-07-13 13:51:03 -0400 | [diff] [blame] | 247 | uint32_t legacy_cursor_offset; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 248 | enum radeon_rmx_type rmx_type; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 249 | fixed20_12 vsc; |
| 250 | fixed20_12 hsc; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 251 | struct drm_display_mode native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | struct radeon_encoder_primary_dac { |
| 255 | /* legacy primary dac */ |
| 256 | uint32_t ps2_pdac_adj; |
| 257 | }; |
| 258 | |
| 259 | struct radeon_encoder_lvds { |
| 260 | /* legacy lvds */ |
| 261 | uint16_t panel_vcc_delay; |
| 262 | uint8_t panel_pwr_delay; |
| 263 | uint8_t panel_digon_delay; |
| 264 | uint8_t panel_blon_delay; |
| 265 | uint16_t panel_ref_divider; |
| 266 | uint8_t panel_post_divider; |
| 267 | uint16_t panel_fb_divider; |
| 268 | bool use_bios_dividers; |
| 269 | uint32_t lvds_gen_cntl; |
| 270 | /* panel mode */ |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 271 | struct drm_display_mode native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | struct radeon_encoder_tv_dac { |
| 275 | /* legacy tv dac */ |
| 276 | uint32_t ps2_tvdac_adj; |
| 277 | uint32_t ntsc_tvdac_adj; |
| 278 | uint32_t pal_tvdac_adj; |
| 279 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 280 | int h_pos; |
| 281 | int v_pos; |
| 282 | int h_size; |
| 283 | int supported_tv_stds; |
| 284 | bool tv_on; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 285 | enum radeon_tv_std tv_std; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 286 | struct radeon_tv_regs tv; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | struct radeon_encoder_int_tmds { |
| 290 | /* legacy int tmds */ |
| 291 | struct radeon_tmds_pll tmds_pll[4]; |
| 292 | }; |
| 293 | |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 294 | struct radeon_encoder_ext_tmds { |
| 295 | /* tmds over dvo */ |
| 296 | struct radeon_i2c_chan *i2c_bus; |
| 297 | uint8_t slave_addr; |
| 298 | enum radeon_dvo_chip dvo_chip; |
| 299 | }; |
| 300 | |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 301 | /* spread spectrum */ |
| 302 | struct radeon_atom_ss { |
| 303 | uint16_t percentage; |
| 304 | uint8_t type; |
| 305 | uint8_t step; |
| 306 | uint8_t delay; |
| 307 | uint8_t range; |
| 308 | uint8_t refdiv; |
| 309 | }; |
| 310 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 311 | struct radeon_encoder_atom_dig { |
| 312 | /* atom dig */ |
| 313 | bool coherent_mode; |
| 314 | int dig_block; |
| 315 | /* atom lvds */ |
| 316 | uint32_t lvds_misc; |
| 317 | uint16_t panel_pwr_delay; |
Alex Deucher | ebbe1cb | 2009-10-16 11:15:25 -0400 | [diff] [blame] | 318 | struct radeon_atom_ss *ss; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 319 | /* panel mode */ |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 320 | struct drm_display_mode native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 321 | }; |
| 322 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 323 | struct radeon_encoder_atom_dac { |
| 324 | enum radeon_tv_std tv_std; |
| 325 | }; |
| 326 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 327 | struct radeon_encoder { |
| 328 | struct drm_encoder base; |
| 329 | uint32_t encoder_id; |
| 330 | uint32_t devices; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 331 | uint32_t active_device; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 332 | uint32_t flags; |
| 333 | uint32_t pixel_clock; |
| 334 | enum radeon_rmx_type rmx_type; |
Alex Deucher | de2103e | 2009-10-09 15:14:30 -0400 | [diff] [blame] | 335 | struct drm_display_mode native_mode; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 336 | void *enc_priv; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame^] | 337 | int hdmi_offset; |
| 338 | int hdmi_audio_workaround; |
| 339 | int hdmi_buffer_status; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | struct radeon_connector_atom_dig { |
| 343 | uint32_t igp_lane_info; |
| 344 | bool linkb; |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 345 | /* displayport */ |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 346 | struct radeon_i2c_chan *dp_i2c_bus; |
Alex Deucher | 1a66c95 | 2009-11-20 19:40:13 -0500 | [diff] [blame] | 347 | u8 dpcd[8]; |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 348 | u8 dp_sink_type; |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 349 | int dp_clock; |
| 350 | int dp_lane_count; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 351 | }; |
| 352 | |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 353 | struct radeon_gpio_rec { |
| 354 | bool valid; |
| 355 | u8 id; |
| 356 | u32 reg; |
| 357 | u32 mask; |
| 358 | }; |
| 359 | |
| 360 | enum radeon_hpd_id { |
| 361 | RADEON_HPD_NONE = 0, |
| 362 | RADEON_HPD_1, |
| 363 | RADEON_HPD_2, |
| 364 | RADEON_HPD_3, |
| 365 | RADEON_HPD_4, |
| 366 | RADEON_HPD_5, |
| 367 | RADEON_HPD_6, |
| 368 | }; |
| 369 | |
| 370 | struct radeon_hpd { |
| 371 | enum radeon_hpd_id hpd; |
| 372 | u8 plugged_state; |
| 373 | struct radeon_gpio_rec gpio; |
| 374 | }; |
| 375 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 376 | struct radeon_connector { |
| 377 | struct drm_connector base; |
| 378 | uint32_t connector_id; |
| 379 | uint32_t devices; |
| 380 | struct radeon_i2c_chan *ddc_bus; |
Alex Deucher | 0294cf4f | 2009-10-15 16:16:35 -0400 | [diff] [blame] | 381 | /* some systems have a an hdmi and vga port with a shared ddc line */ |
| 382 | bool shared_ddc; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 383 | bool use_digital; |
| 384 | /* we need to mind the EDID between detect |
| 385 | and get modes due to analog/digital/tvencoder */ |
| 386 | struct edid *edid; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 387 | void *con_priv; |
Dave Airlie | 445282d | 2009-09-09 17:40:54 +1000 | [diff] [blame] | 388 | bool dac_load_detect; |
Alex Deucher | b75fad0 | 2009-11-05 13:16:01 -0500 | [diff] [blame] | 389 | uint16_t connector_object_id; |
Alex Deucher | eed45b3 | 2009-12-04 14:45:27 -0500 | [diff] [blame] | 390 | struct radeon_hpd hpd; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | struct radeon_framebuffer { |
| 394 | struct drm_framebuffer base; |
| 395 | struct drm_gem_object *obj; |
| 396 | }; |
| 397 | |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 398 | extern void radeon_connector_hotplug(struct drm_connector *connector); |
| 399 | extern bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector); |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 400 | extern int radeon_dp_mode_valid_helper(struct radeon_connector *radeon_connector, |
| 401 | struct drm_display_mode *mode); |
| 402 | extern void radeon_dp_set_link_config(struct drm_connector *connector, |
| 403 | struct drm_display_mode *mode); |
| 404 | extern void dp_link_train(struct drm_encoder *encoder, |
| 405 | struct drm_connector *connector); |
Alex Deucher | 4143e91 | 2009-11-23 18:02:35 -0500 | [diff] [blame] | 406 | extern u8 radeon_dp_getsinktype(struct radeon_connector *radeon_connector); |
Alex Deucher | 9fa05c9 | 2009-11-27 13:01:46 -0500 | [diff] [blame] | 407 | extern bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector); |
Alex Deucher | 5801ead | 2009-11-24 13:32:59 -0500 | [diff] [blame] | 408 | extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, |
| 409 | int action, uint8_t lane_num, |
| 410 | uint8_t lane_set); |
Dave Airlie | 746c1aa | 2009-12-08 07:07:28 +1000 | [diff] [blame] | 411 | extern int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, |
| 412 | uint8_t write_byte, uint8_t *read_byte); |
| 413 | |
| 414 | extern struct radeon_i2c_chan *radeon_i2c_create_dp(struct drm_device *dev, |
Alex Deucher | 6a93cb2 | 2009-11-23 17:39:28 -0500 | [diff] [blame] | 415 | struct radeon_i2c_bus_rec *rec, |
| 416 | const char *name); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 417 | extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, |
| 418 | struct radeon_i2c_bus_rec *rec, |
| 419 | const char *name); |
| 420 | extern void radeon_i2c_destroy(struct radeon_i2c_chan *i2c); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 421 | extern void radeon_i2c_sw_get_byte(struct radeon_i2c_chan *i2c_bus, |
| 422 | u8 slave_addr, |
| 423 | u8 addr, |
| 424 | u8 *val); |
| 425 | extern void radeon_i2c_sw_put_byte(struct radeon_i2c_chan *i2c, |
| 426 | u8 slave_addr, |
| 427 | u8 addr, |
| 428 | u8 val); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 429 | extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector); |
| 430 | extern int radeon_ddc_get_modes(struct radeon_connector *radeon_connector); |
| 431 | |
| 432 | extern struct drm_encoder *radeon_best_encoder(struct drm_connector *connector); |
| 433 | |
| 434 | extern void radeon_compute_pll(struct radeon_pll *pll, |
| 435 | uint64_t freq, |
| 436 | uint32_t *dot_clock_p, |
| 437 | uint32_t *fb_div_p, |
| 438 | uint32_t *frac_fb_div_p, |
| 439 | uint32_t *ref_div_p, |
| 440 | uint32_t *post_div_p, |
| 441 | int flags); |
| 442 | |
Alex Deucher | b27b637 | 2009-12-09 17:44:25 -0500 | [diff] [blame] | 443 | extern void radeon_compute_pll_avivo(struct radeon_pll *pll, |
| 444 | uint64_t freq, |
| 445 | uint32_t *dot_clock_p, |
| 446 | uint32_t *fb_div_p, |
| 447 | uint32_t *frac_fb_div_p, |
| 448 | uint32_t *ref_div_p, |
| 449 | uint32_t *post_div_p, |
| 450 | int flags); |
| 451 | |
Dave Airlie | 1f3b6a4 | 2009-10-13 14:10:37 +1000 | [diff] [blame] | 452 | extern void radeon_setup_encoder_clones(struct drm_device *dev); |
| 453 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 454 | struct drm_encoder *radeon_encoder_legacy_lvds_add(struct drm_device *dev, int bios_index); |
| 455 | struct drm_encoder *radeon_encoder_legacy_primary_dac_add(struct drm_device *dev, int bios_index, int with_tv); |
| 456 | struct drm_encoder *radeon_encoder_legacy_tv_dac_add(struct drm_device *dev, int bios_index, int with_tv); |
| 457 | struct drm_encoder *radeon_encoder_legacy_tmds_int_add(struct drm_device *dev, int bios_index); |
| 458 | struct drm_encoder *radeon_encoder_legacy_tmds_ext_add(struct drm_device *dev, int bios_index); |
| 459 | extern void atombios_external_tmds_setup(struct drm_encoder *encoder, int action); |
Alex Deucher | 32f48ff | 2009-11-30 01:54:16 -0500 | [diff] [blame] | 460 | extern void atombios_digital_setup(struct drm_encoder *encoder, int action); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 461 | extern int atombios_get_encoder_mode(struct drm_encoder *encoder); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 462 | extern void radeon_encoder_set_active_device(struct drm_encoder *encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 463 | |
| 464 | extern void radeon_crtc_load_lut(struct drm_crtc *crtc); |
| 465 | extern int atombios_crtc_set_base(struct drm_crtc *crtc, int x, int y, |
| 466 | struct drm_framebuffer *old_fb); |
| 467 | extern int atombios_crtc_mode_set(struct drm_crtc *crtc, |
| 468 | struct drm_display_mode *mode, |
| 469 | struct drm_display_mode *adjusted_mode, |
| 470 | int x, int y, |
| 471 | struct drm_framebuffer *old_fb); |
| 472 | extern void atombios_crtc_dpms(struct drm_crtc *crtc, int mode); |
| 473 | |
| 474 | extern int radeon_crtc_set_base(struct drm_crtc *crtc, int x, int y, |
| 475 | struct drm_framebuffer *old_fb); |
| 476 | extern void radeon_legacy_atom_set_surface(struct drm_crtc *crtc); |
| 477 | |
| 478 | extern int radeon_crtc_cursor_set(struct drm_crtc *crtc, |
| 479 | struct drm_file *file_priv, |
| 480 | uint32_t handle, |
| 481 | uint32_t width, |
| 482 | uint32_t height); |
| 483 | extern int radeon_crtc_cursor_move(struct drm_crtc *crtc, |
| 484 | int x, int y); |
| 485 | |
| 486 | extern bool radeon_atom_get_clock_info(struct drm_device *dev); |
| 487 | extern bool radeon_combios_get_clock_info(struct drm_device *dev); |
| 488 | extern struct radeon_encoder_atom_dig * |
| 489 | radeon_atombios_get_lvds_info(struct radeon_encoder *encoder); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 490 | extern bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder, |
| 491 | struct radeon_encoder_int_tmds *tmds); |
| 492 | extern bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder, |
| 493 | struct radeon_encoder_int_tmds *tmds); |
| 494 | extern bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder, |
| 495 | struct radeon_encoder_int_tmds *tmds); |
| 496 | extern bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder, |
| 497 | struct radeon_encoder_ext_tmds *tmds); |
| 498 | extern bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder, |
| 499 | struct radeon_encoder_ext_tmds *tmds); |
Alex Deucher | 6fe7ac3 | 2009-06-12 17:26:08 +0000 | [diff] [blame] | 500 | extern struct radeon_encoder_primary_dac * |
| 501 | radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder); |
| 502 | extern struct radeon_encoder_tv_dac * |
| 503 | radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 504 | extern struct radeon_encoder_lvds * |
| 505 | radeon_combios_get_lvds_info(struct radeon_encoder *encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 506 | extern void radeon_combios_get_ext_tmds_info(struct radeon_encoder *encoder); |
| 507 | extern struct radeon_encoder_tv_dac * |
| 508 | radeon_combios_get_tv_dac_info(struct radeon_encoder *encoder); |
| 509 | extern struct radeon_encoder_primary_dac * |
| 510 | radeon_combios_get_primary_dac_info(struct radeon_encoder *encoder); |
Alex Deucher | fcec570 | 2009-11-10 21:25:07 -0500 | [diff] [blame] | 511 | extern bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder); |
| 512 | extern void radeon_external_tmds_setup(struct drm_encoder *encoder); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 513 | extern void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock); |
| 514 | extern void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev); |
| 515 | extern void radeon_atom_output_lock(struct drm_encoder *encoder, bool lock); |
| 516 | extern void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev); |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 517 | extern void radeon_save_bios_scratch_regs(struct radeon_device *rdev); |
| 518 | extern void radeon_restore_bios_scratch_regs(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 519 | extern void |
| 520 | radeon_atombios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc); |
| 521 | extern void |
| 522 | radeon_atombios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on); |
| 523 | extern void |
| 524 | radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc); |
| 525 | extern void |
| 526 | radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on); |
| 527 | extern void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, |
| 528 | u16 blue, int regno); |
Dave Airlie | b8c00ac | 2009-10-06 13:54:01 +1000 | [diff] [blame] | 529 | extern void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, |
| 530 | u16 *blue, int regno); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 531 | struct drm_framebuffer *radeon_framebuffer_create(struct drm_device *dev, |
| 532 | struct drm_mode_fb_cmd *mode_cmd, |
| 533 | struct drm_gem_object *obj); |
| 534 | |
| 535 | int radeonfb_probe(struct drm_device *dev); |
| 536 | |
| 537 | int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); |
| 538 | bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev); |
| 539 | bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev); |
| 540 | void radeon_atombios_init_crtc(struct drm_device *dev, |
| 541 | struct radeon_crtc *radeon_crtc); |
| 542 | void radeon_legacy_init_crtc(struct drm_device *dev, |
| 543 | struct radeon_crtc *radeon_crtc); |
Alex Deucher | ab1e9ea | 2009-11-05 18:27:30 -0500 | [diff] [blame] | 544 | extern void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 545 | |
| 546 | void radeon_get_clock_info(struct drm_device *dev); |
| 547 | |
| 548 | extern bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev); |
| 549 | extern bool radeon_get_atom_connector_info_from_supported_devices_table(struct drm_device *dev); |
| 550 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 551 | void radeon_enc_destroy(struct drm_encoder *encoder); |
| 552 | void radeon_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj); |
| 553 | void radeon_combios_asic_init(struct drm_device *dev); |
| 554 | extern int radeon_static_clocks_init(struct drm_device *dev); |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 555 | bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, |
| 556 | struct drm_display_mode *mode, |
| 557 | struct drm_display_mode *adjusted_mode); |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 558 | void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 559 | |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 560 | /* legacy tv */ |
| 561 | void radeon_legacy_tv_adjust_crtc_reg(struct drm_encoder *encoder, |
| 562 | uint32_t *h_total_disp, uint32_t *h_sync_strt_wid, |
| 563 | uint32_t *v_total_disp, uint32_t *v_sync_strt_wid); |
| 564 | void radeon_legacy_tv_adjust_pll1(struct drm_encoder *encoder, |
| 565 | uint32_t *htotal_cntl, uint32_t *ppll_ref_div, |
| 566 | uint32_t *ppll_div_3, uint32_t *pixclks_cntl); |
| 567 | void radeon_legacy_tv_adjust_pll2(struct drm_encoder *encoder, |
| 568 | uint32_t *htotal2_cntl, uint32_t *p2pll_ref_div, |
| 569 | uint32_t *p2pll_div_0, uint32_t *pixclks_cntl); |
| 570 | void radeon_legacy_tv_mode_set(struct drm_encoder *encoder, |
| 571 | struct drm_display_mode *mode, |
| 572 | struct drm_display_mode *adjusted_mode); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 573 | #endif |