1 1.1 riastrad /* $NetBSD: amdgpu_mode.h,v 1.3 2021/12/18 23:44:58 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and 5 1.1 riastrad * VA Linux Systems Inc., Fremont, California. 6 1.1 riastrad * Copyright 2008 Red Hat Inc. 7 1.1 riastrad * 8 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 9 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 10 1.1 riastrad * to deal in the Software without restriction, including without limitation 11 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 13 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 14 1.1 riastrad * 15 1.1 riastrad * The above copyright notice and this permission notice shall be included in 16 1.1 riastrad * all copies or substantial portions of the Software. 17 1.1 riastrad * 18 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 25 1.1 riastrad * 26 1.1 riastrad * Original Authors: 27 1.1 riastrad * Kevin E. Martin, Rickard E. Faith, Alan Hourihane 28 1.1 riastrad * 29 1.1 riastrad * Kernel port Author: Dave Airlie 30 1.1 riastrad */ 31 1.1 riastrad 32 1.1 riastrad #ifndef AMDGPU_MODE_H 33 1.1 riastrad #define AMDGPU_MODE_H 34 1.1 riastrad 35 1.1 riastrad #include <drm/drm_crtc.h> 36 1.1 riastrad #include <drm/drm_edid.h> 37 1.3 riastrad #include <drm/drm_encoder.h> 38 1.1 riastrad #include <drm/drm_dp_helper.h> 39 1.1 riastrad #include <drm/drm_fixed.h> 40 1.1 riastrad #include <drm/drm_crtc_helper.h> 41 1.3 riastrad #include <drm/drm_fb_helper.h> 42 1.1 riastrad #include <drm/drm_plane_helper.h> 43 1.3 riastrad #include <drm/drm_probe_helper.h> 44 1.1 riastrad #include <linux/i2c.h> 45 1.1 riastrad #include <linux/i2c-algo-bit.h> 46 1.3 riastrad #include <linux/hrtimer.h> 47 1.3 riastrad #include "amdgpu_irq.h" 48 1.3 riastrad 49 1.3 riastrad #include <drm/drm_dp_mst_helper.h> 50 1.3 riastrad #include "modules/inc/mod_freesync.h" 51 1.1 riastrad 52 1.1 riastrad struct amdgpu_bo; 53 1.1 riastrad struct amdgpu_device; 54 1.1 riastrad struct amdgpu_encoder; 55 1.1 riastrad struct amdgpu_router; 56 1.1 riastrad struct amdgpu_hpd; 57 1.1 riastrad 58 1.1 riastrad #define to_amdgpu_crtc(x) container_of(x, struct amdgpu_crtc, base) 59 1.1 riastrad #define to_amdgpu_connector(x) container_of(x, struct amdgpu_connector, base) 60 1.1 riastrad #define to_amdgpu_encoder(x) container_of(x, struct amdgpu_encoder, base) 61 1.1 riastrad #define to_amdgpu_framebuffer(x) container_of(x, struct amdgpu_framebuffer, base) 62 1.1 riastrad 63 1.3 riastrad #define to_dm_plane_state(x) container_of(x, struct dm_plane_state, base) 64 1.3 riastrad 65 1.1 riastrad #define AMDGPU_MAX_HPD_PINS 6 66 1.1 riastrad #define AMDGPU_MAX_CRTCS 6 67 1.3 riastrad #define AMDGPU_MAX_PLANES 6 68 1.1 riastrad #define AMDGPU_MAX_AFMT_BLOCKS 9 69 1.1 riastrad 70 1.1 riastrad enum amdgpu_rmx_type { 71 1.1 riastrad RMX_OFF, 72 1.1 riastrad RMX_FULL, 73 1.1 riastrad RMX_CENTER, 74 1.1 riastrad RMX_ASPECT 75 1.1 riastrad }; 76 1.1 riastrad 77 1.1 riastrad enum amdgpu_underscan_type { 78 1.1 riastrad UNDERSCAN_OFF, 79 1.1 riastrad UNDERSCAN_ON, 80 1.1 riastrad UNDERSCAN_AUTO, 81 1.1 riastrad }; 82 1.1 riastrad 83 1.1 riastrad #define AMDGPU_HPD_CONNECT_INT_DELAY_IN_MS 50 84 1.1 riastrad #define AMDGPU_HPD_DISCONNECT_INT_DELAY_IN_MS 10 85 1.1 riastrad 86 1.1 riastrad enum amdgpu_hpd_id { 87 1.1 riastrad AMDGPU_HPD_1 = 0, 88 1.1 riastrad AMDGPU_HPD_2, 89 1.1 riastrad AMDGPU_HPD_3, 90 1.1 riastrad AMDGPU_HPD_4, 91 1.1 riastrad AMDGPU_HPD_5, 92 1.1 riastrad AMDGPU_HPD_6, 93 1.1 riastrad AMDGPU_HPD_NONE = 0xff, 94 1.1 riastrad }; 95 1.1 riastrad 96 1.1 riastrad enum amdgpu_crtc_irq { 97 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK1 = 0, 98 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK2, 99 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK3, 100 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK4, 101 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK5, 102 1.1 riastrad AMDGPU_CRTC_IRQ_VBLANK6, 103 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE1, 104 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE2, 105 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE3, 106 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE4, 107 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE5, 108 1.1 riastrad AMDGPU_CRTC_IRQ_VLINE6, 109 1.1 riastrad AMDGPU_CRTC_IRQ_NONE = 0xff 110 1.1 riastrad }; 111 1.1 riastrad 112 1.1 riastrad enum amdgpu_pageflip_irq { 113 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D1 = 0, 114 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D2, 115 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D3, 116 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D4, 117 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D5, 118 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_D6, 119 1.1 riastrad AMDGPU_PAGEFLIP_IRQ_NONE = 0xff 120 1.1 riastrad }; 121 1.1 riastrad 122 1.1 riastrad enum amdgpu_flip_status { 123 1.1 riastrad AMDGPU_FLIP_NONE, 124 1.1 riastrad AMDGPU_FLIP_PENDING, 125 1.1 riastrad AMDGPU_FLIP_SUBMITTED 126 1.1 riastrad }; 127 1.1 riastrad 128 1.1 riastrad #define AMDGPU_MAX_I2C_BUS 16 129 1.1 riastrad 130 1.1 riastrad /* amdgpu gpio-based i2c 131 1.1 riastrad * 1. "mask" reg and bits 132 1.1 riastrad * grabs the gpio pins for software use 133 1.1 riastrad * 0=not held 1=held 134 1.1 riastrad * 2. "a" reg and bits 135 1.1 riastrad * output pin value 136 1.1 riastrad * 0=low 1=high 137 1.1 riastrad * 3. "en" reg and bits 138 1.1 riastrad * sets the pin direction 139 1.1 riastrad * 0=input 1=output 140 1.1 riastrad * 4. "y" reg and bits 141 1.1 riastrad * input pin value 142 1.1 riastrad * 0=low 1=high 143 1.1 riastrad */ 144 1.1 riastrad struct amdgpu_i2c_bus_rec { 145 1.1 riastrad bool valid; 146 1.1 riastrad /* id used by atom */ 147 1.1 riastrad uint8_t i2c_id; 148 1.1 riastrad /* id used by atom */ 149 1.1 riastrad enum amdgpu_hpd_id hpd; 150 1.1 riastrad /* can be used with hw i2c engine */ 151 1.1 riastrad bool hw_capable; 152 1.1 riastrad /* uses multi-media i2c engine */ 153 1.1 riastrad bool mm_i2c; 154 1.1 riastrad /* regs and bits */ 155 1.1 riastrad uint32_t mask_clk_reg; 156 1.1 riastrad uint32_t mask_data_reg; 157 1.1 riastrad uint32_t a_clk_reg; 158 1.1 riastrad uint32_t a_data_reg; 159 1.1 riastrad uint32_t en_clk_reg; 160 1.1 riastrad uint32_t en_data_reg; 161 1.1 riastrad uint32_t y_clk_reg; 162 1.1 riastrad uint32_t y_data_reg; 163 1.1 riastrad uint32_t mask_clk_mask; 164 1.1 riastrad uint32_t mask_data_mask; 165 1.1 riastrad uint32_t a_clk_mask; 166 1.1 riastrad uint32_t a_data_mask; 167 1.1 riastrad uint32_t en_clk_mask; 168 1.1 riastrad uint32_t en_data_mask; 169 1.1 riastrad uint32_t y_clk_mask; 170 1.1 riastrad uint32_t y_data_mask; 171 1.1 riastrad }; 172 1.1 riastrad 173 1.1 riastrad #define AMDGPU_MAX_BIOS_CONNECTOR 16 174 1.1 riastrad 175 1.1 riastrad /* pll flags */ 176 1.1 riastrad #define AMDGPU_PLL_USE_BIOS_DIVS (1 << 0) 177 1.1 riastrad #define AMDGPU_PLL_NO_ODD_POST_DIV (1 << 1) 178 1.1 riastrad #define AMDGPU_PLL_USE_REF_DIV (1 << 2) 179 1.1 riastrad #define AMDGPU_PLL_LEGACY (1 << 3) 180 1.1 riastrad #define AMDGPU_PLL_PREFER_LOW_REF_DIV (1 << 4) 181 1.1 riastrad #define AMDGPU_PLL_PREFER_HIGH_REF_DIV (1 << 5) 182 1.1 riastrad #define AMDGPU_PLL_PREFER_LOW_FB_DIV (1 << 6) 183 1.1 riastrad #define AMDGPU_PLL_PREFER_HIGH_FB_DIV (1 << 7) 184 1.1 riastrad #define AMDGPU_PLL_PREFER_LOW_POST_DIV (1 << 8) 185 1.1 riastrad #define AMDGPU_PLL_PREFER_HIGH_POST_DIV (1 << 9) 186 1.1 riastrad #define AMDGPU_PLL_USE_FRAC_FB_DIV (1 << 10) 187 1.1 riastrad #define AMDGPU_PLL_PREFER_CLOSEST_LOWER (1 << 11) 188 1.1 riastrad #define AMDGPU_PLL_USE_POST_DIV (1 << 12) 189 1.1 riastrad #define AMDGPU_PLL_IS_LCD (1 << 13) 190 1.1 riastrad #define AMDGPU_PLL_PREFER_MINM_OVER_MAXP (1 << 14) 191 1.1 riastrad 192 1.1 riastrad struct amdgpu_pll { 193 1.1 riastrad /* reference frequency */ 194 1.1 riastrad uint32_t reference_freq; 195 1.1 riastrad 196 1.1 riastrad /* fixed dividers */ 197 1.1 riastrad uint32_t reference_div; 198 1.1 riastrad uint32_t post_div; 199 1.1 riastrad 200 1.1 riastrad /* pll in/out limits */ 201 1.1 riastrad uint32_t pll_in_min; 202 1.1 riastrad uint32_t pll_in_max; 203 1.1 riastrad uint32_t pll_out_min; 204 1.1 riastrad uint32_t pll_out_max; 205 1.1 riastrad uint32_t lcd_pll_out_min; 206 1.1 riastrad uint32_t lcd_pll_out_max; 207 1.1 riastrad uint32_t best_vco; 208 1.1 riastrad 209 1.1 riastrad /* divider limits */ 210 1.1 riastrad uint32_t min_ref_div; 211 1.1 riastrad uint32_t max_ref_div; 212 1.1 riastrad uint32_t min_post_div; 213 1.1 riastrad uint32_t max_post_div; 214 1.1 riastrad uint32_t min_feedback_div; 215 1.1 riastrad uint32_t max_feedback_div; 216 1.1 riastrad uint32_t min_frac_feedback_div; 217 1.1 riastrad uint32_t max_frac_feedback_div; 218 1.1 riastrad 219 1.1 riastrad /* flags for the current clock */ 220 1.1 riastrad uint32_t flags; 221 1.1 riastrad 222 1.1 riastrad /* pll id */ 223 1.1 riastrad uint32_t id; 224 1.1 riastrad }; 225 1.1 riastrad 226 1.1 riastrad struct amdgpu_i2c_chan { 227 1.1 riastrad struct i2c_adapter adapter; 228 1.1 riastrad struct drm_device *dev; 229 1.1 riastrad struct i2c_algo_bit_data bit; 230 1.1 riastrad struct amdgpu_i2c_bus_rec rec; 231 1.1 riastrad struct drm_dp_aux aux; 232 1.1 riastrad bool has_aux; 233 1.1 riastrad struct mutex mutex; 234 1.1 riastrad }; 235 1.1 riastrad 236 1.1 riastrad struct amdgpu_fbdev; 237 1.1 riastrad 238 1.1 riastrad struct amdgpu_afmt { 239 1.1 riastrad bool enabled; 240 1.1 riastrad int offset; 241 1.1 riastrad bool last_buffer_filled_status; 242 1.1 riastrad int id; 243 1.1 riastrad struct amdgpu_audio_pin *pin; 244 1.1 riastrad }; 245 1.1 riastrad 246 1.1 riastrad /* 247 1.1 riastrad * Audio 248 1.1 riastrad */ 249 1.1 riastrad struct amdgpu_audio_pin { 250 1.1 riastrad int channels; 251 1.1 riastrad int rate; 252 1.1 riastrad int bits_per_sample; 253 1.1 riastrad u8 status_bits; 254 1.1 riastrad u8 category_code; 255 1.1 riastrad u32 offset; 256 1.1 riastrad bool connected; 257 1.1 riastrad u32 id; 258 1.1 riastrad }; 259 1.1 riastrad 260 1.1 riastrad struct amdgpu_audio { 261 1.1 riastrad bool enabled; 262 1.1 riastrad struct amdgpu_audio_pin pin[AMDGPU_MAX_AFMT_BLOCKS]; 263 1.1 riastrad int num_pins; 264 1.1 riastrad }; 265 1.1 riastrad 266 1.1 riastrad struct amdgpu_display_funcs { 267 1.1 riastrad /* display watermarks */ 268 1.1 riastrad void (*bandwidth_update)(struct amdgpu_device *adev); 269 1.1 riastrad /* get frame count */ 270 1.1 riastrad u32 (*vblank_get_counter)(struct amdgpu_device *adev, int crtc); 271 1.1 riastrad /* set backlight level */ 272 1.1 riastrad void (*backlight_set_level)(struct amdgpu_encoder *amdgpu_encoder, 273 1.1 riastrad u8 level); 274 1.1 riastrad /* get backlight level */ 275 1.1 riastrad u8 (*backlight_get_level)(struct amdgpu_encoder *amdgpu_encoder); 276 1.1 riastrad /* hotplug detect */ 277 1.1 riastrad bool (*hpd_sense)(struct amdgpu_device *adev, enum amdgpu_hpd_id hpd); 278 1.1 riastrad void (*hpd_set_polarity)(struct amdgpu_device *adev, 279 1.1 riastrad enum amdgpu_hpd_id hpd); 280 1.1 riastrad u32 (*hpd_get_gpio_reg)(struct amdgpu_device *adev); 281 1.1 riastrad /* pageflipping */ 282 1.1 riastrad void (*page_flip)(struct amdgpu_device *adev, 283 1.3 riastrad int crtc_id, u64 crtc_base, bool async); 284 1.1 riastrad int (*page_flip_get_scanoutpos)(struct amdgpu_device *adev, int crtc, 285 1.1 riastrad u32 *vbl, u32 *position); 286 1.1 riastrad /* display topology setup */ 287 1.1 riastrad void (*add_encoder)(struct amdgpu_device *adev, 288 1.1 riastrad uint32_t encoder_enum, 289 1.1 riastrad uint32_t supported_device, 290 1.1 riastrad u16 caps); 291 1.1 riastrad void (*add_connector)(struct amdgpu_device *adev, 292 1.1 riastrad uint32_t connector_id, 293 1.1 riastrad uint32_t supported_device, 294 1.1 riastrad int connector_type, 295 1.1 riastrad struct amdgpu_i2c_bus_rec *i2c_bus, 296 1.1 riastrad uint16_t connector_object_id, 297 1.1 riastrad struct amdgpu_hpd *hpd, 298 1.1 riastrad struct amdgpu_router *router); 299 1.3 riastrad 300 1.3 riastrad 301 1.3 riastrad }; 302 1.3 riastrad 303 1.3 riastrad struct amdgpu_framebuffer { 304 1.3 riastrad struct drm_framebuffer base; 305 1.3 riastrad 306 1.3 riastrad /* caching for later use */ 307 1.3 riastrad uint64_t address; 308 1.3 riastrad }; 309 1.3 riastrad 310 1.3 riastrad struct amdgpu_fbdev { 311 1.3 riastrad struct drm_fb_helper helper; 312 1.3 riastrad struct amdgpu_framebuffer rfb; 313 1.3 riastrad struct list_head fbdev_list; 314 1.3 riastrad struct amdgpu_device *adev; 315 1.1 riastrad }; 316 1.1 riastrad 317 1.1 riastrad struct amdgpu_mode_info { 318 1.1 riastrad struct atom_context *atom_context; 319 1.1 riastrad struct card_info *atom_card_info; 320 1.1 riastrad bool mode_config_initialized; 321 1.1 riastrad struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS]; 322 1.3 riastrad struct drm_plane *planes[AMDGPU_MAX_PLANES]; 323 1.1 riastrad struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS]; 324 1.1 riastrad /* DVI-I properties */ 325 1.1 riastrad struct drm_property *coherent_mode_property; 326 1.1 riastrad /* DAC enable load detect */ 327 1.1 riastrad struct drm_property *load_detect_property; 328 1.1 riastrad /* underscan */ 329 1.1 riastrad struct drm_property *underscan_property; 330 1.1 riastrad struct drm_property *underscan_hborder_property; 331 1.1 riastrad struct drm_property *underscan_vborder_property; 332 1.1 riastrad /* audio */ 333 1.1 riastrad struct drm_property *audio_property; 334 1.1 riastrad /* FMT dithering */ 335 1.1 riastrad struct drm_property *dither_property; 336 1.3 riastrad /* Adaptive Backlight Modulation (power feature) */ 337 1.3 riastrad struct drm_property *abm_level_property; 338 1.1 riastrad /* hardcoded DFP edid from BIOS */ 339 1.1 riastrad struct edid *bios_hardcoded_edid; 340 1.1 riastrad int bios_hardcoded_edid_size; 341 1.1 riastrad 342 1.1 riastrad /* pointer to fbdev info structure */ 343 1.1 riastrad struct amdgpu_fbdev *rfbdev; 344 1.1 riastrad /* firmware flags */ 345 1.1 riastrad u16 firmware_flags; 346 1.1 riastrad /* pointer to backlight encoder */ 347 1.1 riastrad struct amdgpu_encoder *bl_encoder; 348 1.3 riastrad u8 bl_level; /* saved backlight level */ 349 1.1 riastrad struct amdgpu_audio audio; /* audio stuff */ 350 1.1 riastrad int num_crtc; /* number of crtcs */ 351 1.1 riastrad int num_hpd; /* number of hpd pins */ 352 1.1 riastrad int num_dig; /* number of dig blocks */ 353 1.1 riastrad int disp_priority; 354 1.1 riastrad const struct amdgpu_display_funcs *funcs; 355 1.3 riastrad const enum drm_plane_type *plane_type; 356 1.1 riastrad }; 357 1.1 riastrad 358 1.1 riastrad #define AMDGPU_MAX_BL_LEVEL 0xFF 359 1.1 riastrad 360 1.1 riastrad #if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE) 361 1.1 riastrad 362 1.1 riastrad struct amdgpu_backlight_privdata { 363 1.1 riastrad struct amdgpu_encoder *encoder; 364 1.1 riastrad uint8_t negative; 365 1.1 riastrad }; 366 1.1 riastrad 367 1.1 riastrad #endif 368 1.1 riastrad 369 1.1 riastrad struct amdgpu_atom_ss { 370 1.1 riastrad uint16_t percentage; 371 1.1 riastrad uint16_t percentage_divider; 372 1.1 riastrad uint8_t type; 373 1.1 riastrad uint16_t step; 374 1.1 riastrad uint8_t delay; 375 1.1 riastrad uint8_t range; 376 1.1 riastrad uint8_t refdiv; 377 1.1 riastrad /* asic_ss */ 378 1.1 riastrad uint16_t rate; 379 1.1 riastrad uint16_t amount; 380 1.1 riastrad }; 381 1.1 riastrad 382 1.1 riastrad struct amdgpu_crtc { 383 1.1 riastrad struct drm_crtc base; 384 1.1 riastrad int crtc_id; 385 1.1 riastrad bool enabled; 386 1.1 riastrad bool can_tile; 387 1.1 riastrad uint32_t crtc_offset; 388 1.1 riastrad struct drm_gem_object *cursor_bo; 389 1.1 riastrad uint64_t cursor_addr; 390 1.1 riastrad int cursor_x; 391 1.1 riastrad int cursor_y; 392 1.1 riastrad int cursor_hot_x; 393 1.1 riastrad int cursor_hot_y; 394 1.1 riastrad int cursor_width; 395 1.1 riastrad int cursor_height; 396 1.1 riastrad int max_cursor_width; 397 1.1 riastrad int max_cursor_height; 398 1.1 riastrad enum amdgpu_rmx_type rmx_type; 399 1.1 riastrad u8 h_border; 400 1.1 riastrad u8 v_border; 401 1.1 riastrad fixed20_12 vsc; 402 1.1 riastrad fixed20_12 hsc; 403 1.1 riastrad struct drm_display_mode native_mode; 404 1.1 riastrad u32 pll_id; 405 1.1 riastrad /* page flipping */ 406 1.1 riastrad struct amdgpu_flip_work *pflip_works; 407 1.1 riastrad enum amdgpu_flip_status pflip_status; 408 1.1 riastrad int deferred_flip_completion; 409 1.3 riastrad u32 last_flip_vblank; 410 1.1 riastrad /* pll sharing */ 411 1.1 riastrad struct amdgpu_atom_ss ss; 412 1.1 riastrad bool ss_enabled; 413 1.1 riastrad u32 adjusted_clock; 414 1.1 riastrad int bpc; 415 1.1 riastrad u32 pll_reference_div; 416 1.1 riastrad u32 pll_post_div; 417 1.1 riastrad u32 pll_flags; 418 1.1 riastrad struct drm_encoder *encoder; 419 1.1 riastrad struct drm_connector *connector; 420 1.1 riastrad /* for dpm */ 421 1.1 riastrad u32 line_time; 422 1.1 riastrad u32 wm_low; 423 1.1 riastrad u32 wm_high; 424 1.1 riastrad u32 lb_vblank_lead_lines; 425 1.1 riastrad struct drm_display_mode hw_mode; 426 1.3 riastrad /* for virtual dce */ 427 1.3 riastrad struct hrtimer vblank_timer; 428 1.3 riastrad enum amdgpu_interrupt_state vsync_timer_enabled; 429 1.3 riastrad 430 1.3 riastrad int otg_inst; 431 1.3 riastrad struct drm_pending_vblank_event *event; 432 1.1 riastrad }; 433 1.1 riastrad 434 1.1 riastrad struct amdgpu_encoder_atom_dig { 435 1.1 riastrad bool linkb; 436 1.1 riastrad /* atom dig */ 437 1.1 riastrad bool coherent_mode; 438 1.1 riastrad int dig_encoder; /* -1 disabled, 0 DIGA, 1 DIGB, etc. */ 439 1.1 riastrad /* atom lvds/edp */ 440 1.1 riastrad uint32_t lcd_misc; 441 1.1 riastrad uint16_t panel_pwr_delay; 442 1.1 riastrad uint32_t lcd_ss_id; 443 1.1 riastrad /* panel mode */ 444 1.1 riastrad struct drm_display_mode native_mode; 445 1.1 riastrad struct backlight_device *bl_dev; 446 1.1 riastrad int dpms_mode; 447 1.1 riastrad uint8_t backlight_level; 448 1.1 riastrad int panel_mode; 449 1.1 riastrad struct amdgpu_afmt *afmt; 450 1.1 riastrad }; 451 1.1 riastrad 452 1.1 riastrad struct amdgpu_encoder { 453 1.1 riastrad struct drm_encoder base; 454 1.1 riastrad uint32_t encoder_enum; 455 1.1 riastrad uint32_t encoder_id; 456 1.1 riastrad uint32_t devices; 457 1.1 riastrad uint32_t active_device; 458 1.1 riastrad uint32_t flags; 459 1.1 riastrad uint32_t pixel_clock; 460 1.1 riastrad enum amdgpu_rmx_type rmx_type; 461 1.1 riastrad enum amdgpu_underscan_type underscan_type; 462 1.1 riastrad uint32_t underscan_hborder; 463 1.1 riastrad uint32_t underscan_vborder; 464 1.1 riastrad struct drm_display_mode native_mode; 465 1.1 riastrad void *enc_priv; 466 1.1 riastrad int audio_polling_active; 467 1.1 riastrad bool is_ext_encoder; 468 1.1 riastrad u16 caps; 469 1.1 riastrad }; 470 1.1 riastrad 471 1.1 riastrad struct amdgpu_connector_atom_dig { 472 1.1 riastrad /* displayport */ 473 1.1 riastrad u8 dpcd[DP_RECEIVER_CAP_SIZE]; 474 1.1 riastrad u8 dp_sink_type; 475 1.1 riastrad int dp_clock; 476 1.1 riastrad int dp_lane_count; 477 1.1 riastrad bool edp_on; 478 1.1 riastrad }; 479 1.1 riastrad 480 1.1 riastrad struct amdgpu_gpio_rec { 481 1.1 riastrad bool valid; 482 1.1 riastrad u8 id; 483 1.1 riastrad u32 reg; 484 1.1 riastrad u32 mask; 485 1.1 riastrad u32 shift; 486 1.1 riastrad }; 487 1.1 riastrad 488 1.1 riastrad struct amdgpu_hpd { 489 1.1 riastrad enum amdgpu_hpd_id hpd; 490 1.1 riastrad u8 plugged_state; 491 1.1 riastrad struct amdgpu_gpio_rec gpio; 492 1.1 riastrad }; 493 1.1 riastrad 494 1.1 riastrad struct amdgpu_router { 495 1.1 riastrad u32 router_id; 496 1.1 riastrad struct amdgpu_i2c_bus_rec i2c_info; 497 1.1 riastrad u8 i2c_addr; 498 1.1 riastrad /* i2c mux */ 499 1.1 riastrad bool ddc_valid; 500 1.1 riastrad u8 ddc_mux_type; 501 1.1 riastrad u8 ddc_mux_control_pin; 502 1.1 riastrad u8 ddc_mux_state; 503 1.1 riastrad /* clock/data mux */ 504 1.1 riastrad bool cd_valid; 505 1.1 riastrad u8 cd_mux_type; 506 1.1 riastrad u8 cd_mux_control_pin; 507 1.1 riastrad u8 cd_mux_state; 508 1.1 riastrad }; 509 1.1 riastrad 510 1.1 riastrad enum amdgpu_connector_audio { 511 1.1 riastrad AMDGPU_AUDIO_DISABLE = 0, 512 1.1 riastrad AMDGPU_AUDIO_ENABLE = 1, 513 1.1 riastrad AMDGPU_AUDIO_AUTO = 2 514 1.1 riastrad }; 515 1.1 riastrad 516 1.1 riastrad enum amdgpu_connector_dither { 517 1.1 riastrad AMDGPU_FMT_DITHER_DISABLE = 0, 518 1.1 riastrad AMDGPU_FMT_DITHER_ENABLE = 1, 519 1.1 riastrad }; 520 1.1 riastrad 521 1.3 riastrad struct amdgpu_dm_dp_aux { 522 1.3 riastrad struct drm_dp_aux aux; 523 1.3 riastrad struct ddc_service *ddc_service; 524 1.3 riastrad }; 525 1.3 riastrad 526 1.3 riastrad struct amdgpu_i2c_adapter { 527 1.3 riastrad struct i2c_adapter base; 528 1.3 riastrad 529 1.3 riastrad struct ddc_service *ddc_service; 530 1.3 riastrad }; 531 1.3 riastrad 532 1.3 riastrad #define TO_DM_AUX(x) container_of((x), struct amdgpu_dm_dp_aux, aux) 533 1.3 riastrad 534 1.1 riastrad struct amdgpu_connector { 535 1.1 riastrad struct drm_connector base; 536 1.1 riastrad uint32_t connector_id; 537 1.1 riastrad uint32_t devices; 538 1.1 riastrad struct amdgpu_i2c_chan *ddc_bus; 539 1.1 riastrad /* some systems have an hdmi and vga port with a shared ddc line */ 540 1.1 riastrad bool shared_ddc; 541 1.1 riastrad bool use_digital; 542 1.1 riastrad /* we need to mind the EDID between detect 543 1.1 riastrad and get modes due to analog/digital/tvencoder */ 544 1.1 riastrad struct edid *edid; 545 1.1 riastrad void *con_priv; 546 1.1 riastrad bool dac_load_detect; 547 1.1 riastrad bool detected_by_load; /* if the connection status was determined by load */ 548 1.1 riastrad uint16_t connector_object_id; 549 1.1 riastrad struct amdgpu_hpd hpd; 550 1.1 riastrad struct amdgpu_router router; 551 1.1 riastrad struct amdgpu_i2c_chan *router_bus; 552 1.1 riastrad enum amdgpu_connector_audio audio; 553 1.1 riastrad enum amdgpu_connector_dither dither; 554 1.1 riastrad unsigned pixelclock_for_modeset; 555 1.1 riastrad }; 556 1.1 riastrad 557 1.3 riastrad /* TODO: start to use this struct and remove same field from base one */ 558 1.3 riastrad struct amdgpu_mst_connector { 559 1.3 riastrad struct amdgpu_connector base; 560 1.3 riastrad 561 1.3 riastrad struct drm_dp_mst_topology_mgr mst_mgr; 562 1.3 riastrad struct amdgpu_dm_dp_aux dm_dp_aux; 563 1.3 riastrad struct drm_dp_mst_port *port; 564 1.3 riastrad struct amdgpu_connector *mst_port; 565 1.3 riastrad bool is_mst_connector; 566 1.3 riastrad struct amdgpu_encoder *mst_encoder; 567 1.1 riastrad }; 568 1.1 riastrad 569 1.1 riastrad #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \ 570 1.1 riastrad ((em) == ATOM_ENCODER_MODE_DP_MST)) 571 1.1 riastrad 572 1.3 riastrad /* Driver internal use only flags of amdgpu_display_get_crtc_scanoutpos() */ 573 1.3 riastrad #define DRM_SCANOUTPOS_VALID (1 << 0) 574 1.3 riastrad #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) 575 1.3 riastrad #define DRM_SCANOUTPOS_ACCURATE (1 << 2) 576 1.3 riastrad #define USE_REAL_VBLANKSTART (1 << 30) 577 1.1 riastrad #define GET_DISTANCE_TO_VBLANKSTART (1 << 31) 578 1.1 riastrad 579 1.1 riastrad void amdgpu_link_encoder_connector(struct drm_device *dev); 580 1.1 riastrad 581 1.1 riastrad struct drm_connector * 582 1.1 riastrad amdgpu_get_connector_for_encoder(struct drm_encoder *encoder); 583 1.1 riastrad struct drm_connector * 584 1.1 riastrad amdgpu_get_connector_for_encoder_init(struct drm_encoder *encoder); 585 1.1 riastrad bool amdgpu_dig_monitor_is_duallink(struct drm_encoder *encoder, 586 1.1 riastrad u32 pixel_clock); 587 1.1 riastrad 588 1.1 riastrad u16 amdgpu_encoder_get_dp_bridge_encoder_id(struct drm_encoder *encoder); 589 1.1 riastrad struct drm_encoder *amdgpu_get_external_encoder(struct drm_encoder *encoder); 590 1.1 riastrad 591 1.3 riastrad bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector, 592 1.3 riastrad bool use_aux); 593 1.1 riastrad 594 1.1 riastrad void amdgpu_encoder_set_active_device(struct drm_encoder *encoder); 595 1.1 riastrad 596 1.3 riastrad int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev, 597 1.3 riastrad unsigned int pipe, unsigned int flags, int *vpos, 598 1.3 riastrad int *hpos, ktime_t *stime, ktime_t *etime, 599 1.3 riastrad const struct drm_display_mode *mode); 600 1.3 riastrad 601 1.3 riastrad int amdgpu_display_framebuffer_init(struct drm_device *dev, 602 1.3 riastrad struct amdgpu_framebuffer *rfb, 603 1.3 riastrad const struct drm_mode_fb_cmd2 *mode_cmd, 604 1.3 riastrad struct drm_gem_object *obj); 605 1.1 riastrad 606 1.1 riastrad int amdgpufb_remove(struct drm_device *dev, struct drm_framebuffer *fb); 607 1.1 riastrad 608 1.1 riastrad void amdgpu_enc_destroy(struct drm_encoder *encoder); 609 1.1 riastrad void amdgpu_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj); 610 1.3 riastrad bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc, 611 1.3 riastrad const struct drm_display_mode *mode, 612 1.3 riastrad struct drm_display_mode *adjusted_mode); 613 1.1 riastrad void amdgpu_panel_mode_fixup(struct drm_encoder *encoder, 614 1.1 riastrad struct drm_display_mode *adjusted_mode); 615 1.3 riastrad int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc); 616 1.1 riastrad 617 1.1 riastrad /* fbdev layer */ 618 1.1 riastrad int amdgpu_fbdev_init(struct amdgpu_device *adev); 619 1.1 riastrad void amdgpu_fbdev_fini(struct amdgpu_device *adev); 620 1.1 riastrad void amdgpu_fbdev_set_suspend(struct amdgpu_device *adev, int state); 621 1.1 riastrad int amdgpu_fbdev_total_size(struct amdgpu_device *adev); 622 1.1 riastrad bool amdgpu_fbdev_robj_is_fb(struct amdgpu_device *adev, struct amdgpu_bo *robj); 623 1.1 riastrad 624 1.1 riastrad int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tiled); 625 1.1 riastrad 626 1.1 riastrad /* amdgpu_display.c */ 627 1.3 riastrad void amdgpu_display_print_display_setup(struct drm_device *dev); 628 1.3 riastrad int amdgpu_display_modeset_create_props(struct amdgpu_device *adev); 629 1.3 riastrad int amdgpu_display_crtc_set_config(struct drm_mode_set *set, 630 1.3 riastrad struct drm_modeset_acquire_ctx *ctx); 631 1.3 riastrad int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, 632 1.3 riastrad struct drm_framebuffer *fb, 633 1.3 riastrad struct drm_pending_vblank_event *event, 634 1.3 riastrad uint32_t page_flip_flags, uint32_t target, 635 1.3 riastrad struct drm_modeset_acquire_ctx *ctx); 636 1.1 riastrad extern const struct drm_mode_config_funcs amdgpu_mode_funcs; 637 1.1 riastrad 638 1.1 riastrad #endif 639