Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 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 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
| 28 | #ifndef __RADEON_H__ |
| 29 | #define __RADEON_H__ |
| 30 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 31 | /* TODO: Here are things that needs to be done : |
| 32 | * - surface allocator & initializer : (bit like scratch reg) should |
| 33 | * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings |
| 34 | * related to surface |
| 35 | * - WB : write back stuff (do it bit like scratch reg things) |
| 36 | * - Vblank : look at Jesse's rework and what we should do |
| 37 | * - r600/r700: gart & cp |
| 38 | * - cs : clean cs ioctl use bitmap & things like that. |
| 39 | * - power management stuff |
| 40 | * - Barrier in gart code |
| 41 | * - Unmappabled vram ? |
| 42 | * - TESTING, TESTING, TESTING |
| 43 | */ |
| 44 | |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 45 | /* Initialization path: |
| 46 | * We expect that acceleration initialization might fail for various |
| 47 | * reasons even thought we work hard to make it works on most |
| 48 | * configurations. In order to still have a working userspace in such |
| 49 | * situation the init path must succeed up to the memory controller |
| 50 | * initialization point. Failure before this point are considered as |
| 51 | * fatal error. Here is the init callchain : |
| 52 | * radeon_device_init perform common structure, mutex initialization |
| 53 | * asic_init setup the GPU memory layout and perform all |
| 54 | * one time initialization (failure in this |
| 55 | * function are considered fatal) |
| 56 | * asic_startup setup the GPU acceleration, in order to |
| 57 | * follow guideline the first thing this |
| 58 | * function should do is setting the GPU |
| 59 | * memory controller (only MC setup failure |
| 60 | * are considered as fatal) |
| 61 | */ |
| 62 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 63 | #include <asm/atomic.h> |
| 64 | #include <linux/wait.h> |
| 65 | #include <linux/list.h> |
| 66 | #include <linux/kref.h> |
| 67 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 68 | #include <ttm/ttm_bo_api.h> |
| 69 | #include <ttm/ttm_bo_driver.h> |
| 70 | #include <ttm/ttm_placement.h> |
| 71 | #include <ttm/ttm_module.h> |
| 72 | |
Dave Airlie | c214271 | 2009-09-22 08:50:10 +1000 | [diff] [blame] | 73 | #include "radeon_family.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 74 | #include "radeon_mode.h" |
| 75 | #include "radeon_reg.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Modules parameters. |
| 79 | */ |
| 80 | extern int radeon_no_wb; |
| 81 | extern int radeon_modeset; |
| 82 | extern int radeon_dynclks; |
| 83 | extern int radeon_r4xx_atom; |
| 84 | extern int radeon_agpmode; |
| 85 | extern int radeon_vram_limit; |
| 86 | extern int radeon_gart_size; |
| 87 | extern int radeon_benchmarking; |
Michel Dänzer | ecc0b32 | 2009-07-21 11:23:57 +0200 | [diff] [blame] | 88 | extern int radeon_testing; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 89 | extern int radeon_connector_table; |
Dave Airlie | 4ce001a | 2009-08-13 16:32:14 +1000 | [diff] [blame] | 90 | extern int radeon_tv; |
Alex Deucher | b27b637 | 2009-12-09 17:44:25 -0500 | [diff] [blame] | 91 | extern int radeon_new_pll; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 92 | extern int radeon_audio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 93 | |
| 94 | /* |
| 95 | * Copy from radeon_drv.h so we don't have to include both and have conflicting |
| 96 | * symbol; |
| 97 | */ |
| 98 | #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */ |
| 99 | #define RADEON_IB_POOL_SIZE 16 |
| 100 | #define RADEON_DEBUGFS_MAX_NUM_FILES 32 |
| 101 | #define RADEONFB_CONN_LIMIT 4 |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 102 | #define RADEON_BIOS_NUM_SCRATCH 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 103 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 104 | /* |
| 105 | * Errata workarounds. |
| 106 | */ |
| 107 | enum radeon_pll_errata { |
| 108 | CHIP_ERRATA_R300_CG = 0x00000001, |
| 109 | CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002, |
| 110 | CHIP_ERRATA_PLL_DELAY = 0x00000004 |
| 111 | }; |
| 112 | |
| 113 | |
| 114 | struct radeon_device; |
| 115 | |
| 116 | |
| 117 | /* |
| 118 | * BIOS. |
| 119 | */ |
| 120 | bool radeon_get_bios(struct radeon_device *rdev); |
| 121 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 122 | |
| 123 | /* |
| 124 | * Dummy page |
| 125 | */ |
| 126 | struct radeon_dummy_page { |
| 127 | struct page *page; |
| 128 | dma_addr_t addr; |
| 129 | }; |
| 130 | int radeon_dummy_page_init(struct radeon_device *rdev); |
| 131 | void radeon_dummy_page_fini(struct radeon_device *rdev); |
| 132 | |
| 133 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 134 | /* |
| 135 | * Clocks |
| 136 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 137 | struct radeon_clock { |
| 138 | struct radeon_pll p1pll; |
| 139 | struct radeon_pll p2pll; |
| 140 | struct radeon_pll spll; |
| 141 | struct radeon_pll mpll; |
| 142 | /* 10 Khz units */ |
| 143 | uint32_t default_mclk; |
| 144 | uint32_t default_sclk; |
| 145 | }; |
| 146 | |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 147 | /* |
| 148 | * Power management |
| 149 | */ |
| 150 | int radeon_pm_init(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 151 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 152 | /* |
| 153 | * Fences. |
| 154 | */ |
| 155 | struct radeon_fence_driver { |
| 156 | uint32_t scratch_reg; |
| 157 | atomic_t seq; |
| 158 | uint32_t last_seq; |
| 159 | unsigned long count_timeout; |
| 160 | wait_queue_head_t queue; |
| 161 | rwlock_t lock; |
| 162 | struct list_head created; |
| 163 | struct list_head emited; |
| 164 | struct list_head signaled; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 165 | bool initialized; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | struct radeon_fence { |
| 169 | struct radeon_device *rdev; |
| 170 | struct kref kref; |
| 171 | struct list_head list; |
| 172 | /* protected by radeon_fence.lock */ |
| 173 | uint32_t seq; |
| 174 | unsigned long timeout; |
| 175 | bool emited; |
| 176 | bool signaled; |
| 177 | }; |
| 178 | |
| 179 | int radeon_fence_driver_init(struct radeon_device *rdev); |
| 180 | void radeon_fence_driver_fini(struct radeon_device *rdev); |
| 181 | int radeon_fence_create(struct radeon_device *rdev, struct radeon_fence **fence); |
| 182 | int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence); |
| 183 | void radeon_fence_process(struct radeon_device *rdev); |
| 184 | bool radeon_fence_signaled(struct radeon_fence *fence); |
| 185 | int radeon_fence_wait(struct radeon_fence *fence, bool interruptible); |
| 186 | int radeon_fence_wait_next(struct radeon_device *rdev); |
| 187 | int radeon_fence_wait_last(struct radeon_device *rdev); |
| 188 | struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence); |
| 189 | void radeon_fence_unref(struct radeon_fence **fence); |
| 190 | |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 191 | /* |
| 192 | * Tiling registers |
| 193 | */ |
| 194 | struct radeon_surface_reg { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 195 | struct radeon_bo *bo; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | #define RADEON_GEM_MAX_SURFACES 8 |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 199 | |
| 200 | /* |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 201 | * TTM. |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 202 | */ |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 203 | struct radeon_mman { |
| 204 | struct ttm_bo_global_ref bo_global_ref; |
| 205 | struct ttm_global_reference mem_global_ref; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 206 | struct ttm_bo_device bdev; |
Jerome Glisse | 0a0c759 | 2009-12-11 20:36:19 +0100 | [diff] [blame] | 207 | bool mem_global_referenced; |
| 208 | bool initialized; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 209 | }; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 210 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 211 | struct radeon_bo { |
| 212 | /* Protected by gem.mutex */ |
| 213 | struct list_head list; |
| 214 | /* Protected by tbo.reserved */ |
Jerome Glisse | 312ea8d | 2009-12-07 15:52:58 +0100 | [diff] [blame] | 215 | u32 placements[3]; |
| 216 | struct ttm_placement placement; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 217 | struct ttm_buffer_object tbo; |
| 218 | struct ttm_bo_kmap_obj kmap; |
| 219 | unsigned pin_count; |
| 220 | void *kptr; |
| 221 | u32 tiling_flags; |
| 222 | u32 pitch; |
| 223 | int surface_reg; |
| 224 | /* Constant after initialization */ |
| 225 | struct radeon_device *rdev; |
| 226 | struct drm_gem_object *gobj; |
| 227 | }; |
| 228 | |
| 229 | struct radeon_bo_list { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 230 | struct list_head list; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 231 | struct radeon_bo *bo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 232 | uint64_t gpu_offset; |
| 233 | unsigned rdomain; |
| 234 | unsigned wdomain; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 235 | u32 tiling_flags; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 236 | }; |
| 237 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 238 | /* |
| 239 | * GEM objects. |
| 240 | */ |
| 241 | struct radeon_gem { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 242 | struct mutex mutex; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 243 | struct list_head objects; |
| 244 | }; |
| 245 | |
| 246 | int radeon_gem_init(struct radeon_device *rdev); |
| 247 | void radeon_gem_fini(struct radeon_device *rdev); |
| 248 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 249 | int alignment, int initial_domain, |
| 250 | bool discardable, bool kernel, |
| 251 | struct drm_gem_object **obj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 252 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, |
| 253 | uint64_t *gpu_addr); |
| 254 | void radeon_gem_object_unpin(struct drm_gem_object *obj); |
| 255 | |
| 256 | |
| 257 | /* |
| 258 | * GART structures, functions & helpers |
| 259 | */ |
| 260 | struct radeon_mc; |
| 261 | |
| 262 | struct radeon_gart_table_ram { |
| 263 | volatile uint32_t *ptr; |
| 264 | }; |
| 265 | |
| 266 | struct radeon_gart_table_vram { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 267 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 268 | volatile uint32_t *ptr; |
| 269 | }; |
| 270 | |
| 271 | union radeon_gart_table { |
| 272 | struct radeon_gart_table_ram ram; |
| 273 | struct radeon_gart_table_vram vram; |
| 274 | }; |
| 275 | |
Matt Turner | a77f171 | 2009-10-14 00:34:41 -0400 | [diff] [blame] | 276 | #define RADEON_GPU_PAGE_SIZE 4096 |
| 277 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 278 | struct radeon_gart { |
| 279 | dma_addr_t table_addr; |
| 280 | unsigned num_gpu_pages; |
| 281 | unsigned num_cpu_pages; |
| 282 | unsigned table_size; |
| 283 | union radeon_gart_table table; |
| 284 | struct page **pages; |
| 285 | dma_addr_t *pages_addr; |
| 286 | bool ready; |
| 287 | }; |
| 288 | |
| 289 | int radeon_gart_table_ram_alloc(struct radeon_device *rdev); |
| 290 | void radeon_gart_table_ram_free(struct radeon_device *rdev); |
| 291 | int radeon_gart_table_vram_alloc(struct radeon_device *rdev); |
| 292 | void radeon_gart_table_vram_free(struct radeon_device *rdev); |
| 293 | int radeon_gart_init(struct radeon_device *rdev); |
| 294 | void radeon_gart_fini(struct radeon_device *rdev); |
| 295 | void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, |
| 296 | int pages); |
| 297 | int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, |
| 298 | int pages, struct page **pagelist); |
| 299 | |
| 300 | |
| 301 | /* |
| 302 | * GPU MC structures, functions & helpers |
| 303 | */ |
| 304 | struct radeon_mc { |
| 305 | resource_size_t aper_size; |
| 306 | resource_size_t aper_base; |
| 307 | resource_size_t agp_base; |
Dave Airlie | 7a50f01 | 2009-07-21 20:39:30 +1000 | [diff] [blame] | 308 | /* for some chips with <= 32MB we need to lie |
| 309 | * about vram size near mc fb location */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 310 | u64 mc_vram_size; |
| 311 | u64 gtt_location; |
| 312 | u64 gtt_size; |
| 313 | u64 gtt_start; |
| 314 | u64 gtt_end; |
| 315 | u64 vram_location; |
| 316 | u64 vram_start; |
| 317 | u64 vram_end; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 318 | unsigned vram_width; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 319 | u64 real_vram_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 320 | int vram_mtrr; |
| 321 | bool vram_is_ddr; |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame^] | 322 | bool igp_sideport_enabled; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | int radeon_mc_setup(struct radeon_device *rdev); |
Alex Deucher | 06b6476 | 2010-01-05 11:27:29 -0500 | [diff] [blame^] | 326 | bool radeon_combios_sideport_present(struct radeon_device *rdev); |
| 327 | bool radeon_atombios_sideport_present(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 328 | |
| 329 | /* |
| 330 | * GPU scratch registers structures, functions & helpers |
| 331 | */ |
| 332 | struct radeon_scratch { |
| 333 | unsigned num_reg; |
| 334 | bool free[32]; |
| 335 | uint32_t reg[32]; |
| 336 | }; |
| 337 | |
| 338 | int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg); |
| 339 | void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg); |
| 340 | |
| 341 | |
| 342 | /* |
| 343 | * IRQS. |
| 344 | */ |
| 345 | struct radeon_irq { |
| 346 | bool installed; |
| 347 | bool sw_int; |
| 348 | /* FIXME: use a define max crtc rather than hardcode it */ |
| 349 | bool crtc_vblank_int[2]; |
Alex Deucher | b500f68 | 2009-12-03 13:08:53 -0500 | [diff] [blame] | 350 | /* FIXME: use defines for max hpd/dacs */ |
| 351 | bool hpd[6]; |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 352 | spinlock_t sw_lock; |
| 353 | int sw_refcount; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 354 | }; |
| 355 | |
| 356 | int radeon_irq_kms_init(struct radeon_device *rdev); |
| 357 | void radeon_irq_kms_fini(struct radeon_device *rdev); |
Dave Airlie | 1614f8b | 2009-12-01 16:04:56 +1000 | [diff] [blame] | 358 | void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev); |
| 359 | void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 360 | |
| 361 | /* |
| 362 | * CP & ring. |
| 363 | */ |
| 364 | struct radeon_ib { |
| 365 | struct list_head list; |
| 366 | unsigned long idx; |
| 367 | uint64_t gpu_addr; |
| 368 | struct radeon_fence *fence; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 369 | uint32_t *ptr; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 370 | uint32_t length_dw; |
| 371 | }; |
| 372 | |
Dave Airlie | ecb114a | 2009-09-15 11:12:56 +1000 | [diff] [blame] | 373 | /* |
| 374 | * locking - |
| 375 | * mutex protects scheduled_ibs, ready, alloc_bm |
| 376 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 377 | struct radeon_ib_pool { |
| 378 | struct mutex mutex; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 379 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 380 | struct list_head scheduled_ibs; |
| 381 | struct radeon_ib ibs[RADEON_IB_POOL_SIZE]; |
| 382 | bool ready; |
| 383 | DECLARE_BITMAP(alloc_bm, RADEON_IB_POOL_SIZE); |
| 384 | }; |
| 385 | |
| 386 | struct radeon_cp { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 387 | struct radeon_bo *ring_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 388 | volatile uint32_t *ring; |
| 389 | unsigned rptr; |
| 390 | unsigned wptr; |
| 391 | unsigned wptr_old; |
| 392 | unsigned ring_size; |
| 393 | unsigned ring_free_dw; |
| 394 | int count_dw; |
| 395 | uint64_t gpu_addr; |
| 396 | uint32_t align_mask; |
| 397 | uint32_t ptr_mask; |
| 398 | struct mutex mutex; |
| 399 | bool ready; |
| 400 | }; |
| 401 | |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 402 | /* |
| 403 | * R6xx+ IH ring |
| 404 | */ |
| 405 | struct r600_ih { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 406 | struct radeon_bo *ring_obj; |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 407 | volatile uint32_t *ring; |
| 408 | unsigned rptr; |
| 409 | unsigned wptr; |
| 410 | unsigned wptr_old; |
| 411 | unsigned ring_size; |
| 412 | uint64_t gpu_addr; |
| 413 | uint32_t align_mask; |
| 414 | uint32_t ptr_mask; |
| 415 | spinlock_t lock; |
| 416 | bool enabled; |
| 417 | }; |
| 418 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 419 | struct r600_blit { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 420 | struct radeon_bo *shader_obj; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 421 | u64 shader_gpu_addr; |
| 422 | u32 vs_offset, ps_offset; |
| 423 | u32 state_offset; |
| 424 | u32 state_len; |
| 425 | u32 vb_used, vb_total; |
| 426 | struct radeon_ib *vb_ib; |
| 427 | }; |
| 428 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 429 | int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); |
| 430 | void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); |
| 431 | int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); |
| 432 | int radeon_ib_pool_init(struct radeon_device *rdev); |
| 433 | void radeon_ib_pool_fini(struct radeon_device *rdev); |
| 434 | int radeon_ib_test(struct radeon_device *rdev); |
| 435 | /* Ring access between begin & end cannot sleep */ |
| 436 | void radeon_ring_free_size(struct radeon_device *rdev); |
| 437 | int radeon_ring_lock(struct radeon_device *rdev, unsigned ndw); |
| 438 | void radeon_ring_unlock_commit(struct radeon_device *rdev); |
| 439 | void radeon_ring_unlock_undo(struct radeon_device *rdev); |
| 440 | int radeon_ring_test(struct radeon_device *rdev); |
| 441 | int radeon_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 442 | void radeon_ring_fini(struct radeon_device *rdev); |
| 443 | |
| 444 | |
| 445 | /* |
| 446 | * CS. |
| 447 | */ |
| 448 | struct radeon_cs_reloc { |
| 449 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 450 | struct radeon_bo *robj; |
| 451 | struct radeon_bo_list lobj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 452 | uint32_t handle; |
| 453 | uint32_t flags; |
| 454 | }; |
| 455 | |
| 456 | struct radeon_cs_chunk { |
| 457 | uint32_t chunk_id; |
| 458 | uint32_t length_dw; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 459 | int kpage_idx[2]; |
| 460 | uint32_t *kpage[2]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 461 | uint32_t *kdata; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 462 | void __user *user_ptr; |
| 463 | int last_copied_page; |
| 464 | int last_page_index; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 465 | }; |
| 466 | |
| 467 | struct radeon_cs_parser { |
| 468 | struct radeon_device *rdev; |
| 469 | struct drm_file *filp; |
| 470 | /* chunks */ |
| 471 | unsigned nchunks; |
| 472 | struct radeon_cs_chunk *chunks; |
| 473 | uint64_t *chunks_array; |
| 474 | /* IB */ |
| 475 | unsigned idx; |
| 476 | /* relocations */ |
| 477 | unsigned nrelocs; |
| 478 | struct radeon_cs_reloc *relocs; |
| 479 | struct radeon_cs_reloc **relocs_ptr; |
| 480 | struct list_head validated; |
| 481 | /* indices of various chunks */ |
| 482 | int chunk_ib_idx; |
| 483 | int chunk_relocs_idx; |
| 484 | struct radeon_ib *ib; |
| 485 | void *track; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 486 | unsigned family; |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 487 | int parser_error; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 488 | }; |
| 489 | |
Dave Airlie | 513bcb4 | 2009-09-23 16:56:27 +1000 | [diff] [blame] | 490 | extern int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx); |
| 491 | extern int radeon_cs_finish_pages(struct radeon_cs_parser *p); |
| 492 | |
| 493 | |
| 494 | static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx) |
| 495 | { |
| 496 | struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx]; |
| 497 | u32 pg_idx, pg_offset; |
| 498 | u32 idx_value = 0; |
| 499 | int new_page; |
| 500 | |
| 501 | pg_idx = (idx * 4) / PAGE_SIZE; |
| 502 | pg_offset = (idx * 4) % PAGE_SIZE; |
| 503 | |
| 504 | if (ibc->kpage_idx[0] == pg_idx) |
| 505 | return ibc->kpage[0][pg_offset/4]; |
| 506 | if (ibc->kpage_idx[1] == pg_idx) |
| 507 | return ibc->kpage[1][pg_offset/4]; |
| 508 | |
| 509 | new_page = radeon_cs_update_pages(p, pg_idx); |
| 510 | if (new_page < 0) { |
| 511 | p->parser_error = new_page; |
| 512 | return 0; |
| 513 | } |
| 514 | |
| 515 | idx_value = ibc->kpage[new_page][pg_offset/4]; |
| 516 | return idx_value; |
| 517 | } |
| 518 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 519 | struct radeon_cs_packet { |
| 520 | unsigned idx; |
| 521 | unsigned type; |
| 522 | unsigned reg; |
| 523 | unsigned opcode; |
| 524 | int count; |
| 525 | unsigned one_reg_wr; |
| 526 | }; |
| 527 | |
| 528 | typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p, |
| 529 | struct radeon_cs_packet *pkt, |
| 530 | unsigned idx, unsigned reg); |
| 531 | typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p, |
| 532 | struct radeon_cs_packet *pkt); |
| 533 | |
| 534 | |
| 535 | /* |
| 536 | * AGP |
| 537 | */ |
| 538 | int radeon_agp_init(struct radeon_device *rdev); |
Dave Airlie | 0ebf171 | 2009-11-05 15:39:10 +1000 | [diff] [blame] | 539 | void radeon_agp_resume(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 540 | void radeon_agp_fini(struct radeon_device *rdev); |
| 541 | |
| 542 | |
| 543 | /* |
| 544 | * Writeback |
| 545 | */ |
| 546 | struct radeon_wb { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 547 | struct radeon_bo *wb_obj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 548 | volatile uint32_t *wb; |
| 549 | uint64_t gpu_addr; |
| 550 | }; |
| 551 | |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 552 | /** |
| 553 | * struct radeon_pm - power management datas |
| 554 | * @max_bandwidth: maximum bandwidth the gpu has (MByte/s) |
| 555 | * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880) |
| 556 | * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880) |
| 557 | * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880) |
| 558 | * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880) |
| 559 | * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP) |
| 560 | * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP) |
| 561 | * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP) |
| 562 | * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP) |
| 563 | * @sclk: GPU clock Mhz (core bandwith depends of this clock) |
| 564 | * @needed_bandwidth: current bandwidth needs |
| 565 | * |
| 566 | * It keeps track of various data needed to take powermanagement decision. |
| 567 | * Bandwith need is used to determine minimun clock of the GPU and memory. |
| 568 | * Equation between gpu/memory clock and available bandwidth is hw dependent |
| 569 | * (type of memory, bus size, efficiency, ...) |
| 570 | */ |
| 571 | struct radeon_pm { |
| 572 | fixed20_12 max_bandwidth; |
| 573 | fixed20_12 igp_sideport_mclk; |
| 574 | fixed20_12 igp_system_mclk; |
| 575 | fixed20_12 igp_ht_link_clk; |
| 576 | fixed20_12 igp_ht_link_width; |
| 577 | fixed20_12 k8_bandwidth; |
| 578 | fixed20_12 sideport_bandwidth; |
| 579 | fixed20_12 ht_bandwidth; |
| 580 | fixed20_12 core_bandwidth; |
| 581 | fixed20_12 sclk; |
| 582 | fixed20_12 needed_bandwidth; |
| 583 | }; |
| 584 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 585 | |
| 586 | /* |
| 587 | * Benchmarking |
| 588 | */ |
| 589 | void radeon_benchmark(struct radeon_device *rdev); |
| 590 | |
| 591 | |
| 592 | /* |
Michel Dänzer | ecc0b32 | 2009-07-21 11:23:57 +0200 | [diff] [blame] | 593 | * Testing |
| 594 | */ |
| 595 | void radeon_test_moves(struct radeon_device *rdev); |
| 596 | |
| 597 | |
| 598 | /* |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 599 | * Debugfs |
| 600 | */ |
| 601 | int radeon_debugfs_add_files(struct radeon_device *rdev, |
| 602 | struct drm_info_list *files, |
| 603 | unsigned nfiles); |
| 604 | int radeon_debugfs_fence_init(struct radeon_device *rdev); |
| 605 | int r100_debugfs_rbbm_init(struct radeon_device *rdev); |
| 606 | int r100_debugfs_cp_init(struct radeon_device *rdev); |
| 607 | |
| 608 | |
| 609 | /* |
| 610 | * ASIC specific functions. |
| 611 | */ |
| 612 | struct radeon_asic { |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 613 | int (*init)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 614 | void (*fini)(struct radeon_device *rdev); |
| 615 | int (*resume)(struct radeon_device *rdev); |
| 616 | int (*suspend)(struct radeon_device *rdev); |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 617 | void (*vga_set_state)(struct radeon_device *rdev, bool state); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 618 | int (*gpu_reset)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 619 | void (*gart_tlb_flush)(struct radeon_device *rdev); |
| 620 | int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr); |
| 621 | int (*cp_init)(struct radeon_device *rdev, unsigned ring_size); |
| 622 | void (*cp_fini)(struct radeon_device *rdev); |
| 623 | void (*cp_disable)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 624 | void (*cp_commit)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 625 | void (*ring_start)(struct radeon_device *rdev); |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 626 | int (*ring_test)(struct radeon_device *rdev); |
| 627 | void (*ring_ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 628 | int (*irq_set)(struct radeon_device *rdev); |
| 629 | int (*irq_process)(struct radeon_device *rdev); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 630 | u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 631 | void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence); |
| 632 | int (*cs_parse)(struct radeon_cs_parser *p); |
| 633 | int (*copy_blit)(struct radeon_device *rdev, |
| 634 | uint64_t src_offset, |
| 635 | uint64_t dst_offset, |
| 636 | unsigned num_pages, |
| 637 | struct radeon_fence *fence); |
| 638 | int (*copy_dma)(struct radeon_device *rdev, |
| 639 | uint64_t src_offset, |
| 640 | uint64_t dst_offset, |
| 641 | unsigned num_pages, |
| 642 | struct radeon_fence *fence); |
| 643 | int (*copy)(struct radeon_device *rdev, |
| 644 | uint64_t src_offset, |
| 645 | uint64_t dst_offset, |
| 646 | unsigned num_pages, |
| 647 | struct radeon_fence *fence); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 648 | uint32_t (*get_engine_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 649 | void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock); |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 650 | uint32_t (*get_memory_clock)(struct radeon_device *rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 651 | void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock); |
| 652 | void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes); |
| 653 | void (*set_clock_gating)(struct radeon_device *rdev, int enable); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 654 | int (*set_surface_reg)(struct radeon_device *rdev, int reg, |
| 655 | uint32_t tiling_flags, uint32_t pitch, |
| 656 | uint32_t offset, uint32_t obj_size); |
| 657 | int (*clear_surface_reg)(struct radeon_device *rdev, int reg); |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 658 | void (*bandwidth_update)(struct radeon_device *rdev); |
Dave Airlie | 23956df | 2009-11-23 12:01:09 +1000 | [diff] [blame] | 659 | void (*hdp_flush)(struct radeon_device *rdev); |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 660 | void (*hpd_init)(struct radeon_device *rdev); |
| 661 | void (*hpd_fini)(struct radeon_device *rdev); |
| 662 | bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
| 663 | void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 664 | }; |
| 665 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 666 | /* |
| 667 | * Asic structures |
| 668 | */ |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 669 | struct r100_asic { |
| 670 | const unsigned *reg_safe_bm; |
| 671 | unsigned reg_safe_bm_size; |
| 672 | }; |
| 673 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 674 | struct r300_asic { |
| 675 | const unsigned *reg_safe_bm; |
| 676 | unsigned reg_safe_bm_size; |
| 677 | }; |
| 678 | |
| 679 | struct r600_asic { |
| 680 | unsigned max_pipes; |
| 681 | unsigned max_tile_pipes; |
| 682 | unsigned max_simds; |
| 683 | unsigned max_backends; |
| 684 | unsigned max_gprs; |
| 685 | unsigned max_threads; |
| 686 | unsigned max_stack_entries; |
| 687 | unsigned max_hw_contexts; |
| 688 | unsigned max_gs_threads; |
| 689 | unsigned sx_max_export_size; |
| 690 | unsigned sx_max_export_pos_size; |
| 691 | unsigned sx_max_export_smx_size; |
| 692 | unsigned sq_num_cf_insts; |
| 693 | }; |
| 694 | |
| 695 | struct rv770_asic { |
| 696 | unsigned max_pipes; |
| 697 | unsigned max_tile_pipes; |
| 698 | unsigned max_simds; |
| 699 | unsigned max_backends; |
| 700 | unsigned max_gprs; |
| 701 | unsigned max_threads; |
| 702 | unsigned max_stack_entries; |
| 703 | unsigned max_hw_contexts; |
| 704 | unsigned max_gs_threads; |
| 705 | unsigned sx_max_export_size; |
| 706 | unsigned sx_max_export_pos_size; |
| 707 | unsigned sx_max_export_smx_size; |
| 708 | unsigned sq_num_cf_insts; |
| 709 | unsigned sx_num_of_sets; |
| 710 | unsigned sc_prim_fifo_size; |
| 711 | unsigned sc_hiz_tile_fifo_size; |
| 712 | unsigned sc_earlyz_tile_fifo_fize; |
| 713 | }; |
| 714 | |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 715 | union radeon_asic_config { |
| 716 | struct r300_asic r300; |
Dave Airlie | 551ebd8 | 2009-09-01 15:25:57 +1000 | [diff] [blame] | 717 | struct r100_asic r100; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 718 | struct r600_asic r600; |
| 719 | struct rv770_asic rv770; |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 720 | }; |
| 721 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 722 | |
| 723 | /* |
| 724 | * IOCTL. |
| 725 | */ |
| 726 | int radeon_gem_info_ioctl(struct drm_device *dev, void *data, |
| 727 | struct drm_file *filp); |
| 728 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, |
| 729 | struct drm_file *filp); |
| 730 | int radeon_gem_pin_ioctl(struct drm_device *dev, void *data, |
| 731 | struct drm_file *file_priv); |
| 732 | int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data, |
| 733 | struct drm_file *file_priv); |
| 734 | int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data, |
| 735 | struct drm_file *file_priv); |
| 736 | int radeon_gem_pread_ioctl(struct drm_device *dev, void *data, |
| 737 | struct drm_file *file_priv); |
| 738 | int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, |
| 739 | struct drm_file *filp); |
| 740 | int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, |
| 741 | struct drm_file *filp); |
| 742 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, |
| 743 | struct drm_file *filp); |
| 744 | int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, |
| 745 | struct drm_file *filp); |
| 746 | int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 747 | int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, |
| 748 | struct drm_file *filp); |
| 749 | int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, |
| 750 | struct drm_file *filp); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 751 | |
| 752 | |
| 753 | /* |
| 754 | * Core structure, functions and helpers. |
| 755 | */ |
| 756 | typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t); |
| 757 | typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t); |
| 758 | |
| 759 | struct radeon_device { |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 760 | struct device *dev; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 761 | struct drm_device *ddev; |
| 762 | struct pci_dev *pdev; |
| 763 | /* ASIC */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 764 | union radeon_asic_config config; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 765 | enum radeon_family family; |
| 766 | unsigned long flags; |
| 767 | int usec_timeout; |
| 768 | enum radeon_pll_errata pll_errata; |
| 769 | int num_gb_pipes; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 770 | int num_z_pipes; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 771 | int disp_priority; |
| 772 | /* BIOS */ |
| 773 | uint8_t *bios; |
| 774 | bool is_atom_bios; |
| 775 | uint16_t bios_header_start; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 776 | struct radeon_bo *stollen_vga_memory; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 777 | struct fb_info *fbdev_info; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 778 | struct radeon_bo *fbdev_rbo; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 779 | struct radeon_framebuffer *fbdev_rfb; |
| 780 | /* Register mmio */ |
Dave Airlie | 4c9bc75 | 2009-06-29 18:29:12 +1000 | [diff] [blame] | 781 | resource_size_t rmmio_base; |
| 782 | resource_size_t rmmio_size; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 783 | void *rmmio; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 784 | radeon_rreg_t mc_rreg; |
| 785 | radeon_wreg_t mc_wreg; |
| 786 | radeon_rreg_t pll_rreg; |
| 787 | radeon_wreg_t pll_wreg; |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 788 | uint32_t pcie_reg_mask; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 789 | radeon_rreg_t pciep_rreg; |
| 790 | radeon_wreg_t pciep_wreg; |
| 791 | struct radeon_clock clock; |
| 792 | struct radeon_mc mc; |
| 793 | struct radeon_gart gart; |
| 794 | struct radeon_mode_info mode_info; |
| 795 | struct radeon_scratch scratch; |
| 796 | struct radeon_mman mman; |
| 797 | struct radeon_fence_driver fence_drv; |
| 798 | struct radeon_cp cp; |
| 799 | struct radeon_ib_pool ib_pool; |
| 800 | struct radeon_irq irq; |
| 801 | struct radeon_asic *asic; |
| 802 | struct radeon_gem gem; |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 803 | struct radeon_pm pm; |
Yang Zhao | f657c2a | 2009-09-15 12:21:01 +1000 | [diff] [blame] | 804 | uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 805 | struct mutex cs_mutex; |
| 806 | struct radeon_wb wb; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 807 | struct radeon_dummy_page dummy_page; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 808 | bool gpu_lockup; |
| 809 | bool shutdown; |
| 810 | bool suspend; |
Dave Airlie | ad49f50 | 2009-07-10 22:36:26 +1000 | [diff] [blame] | 811 | bool need_dma32; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 812 | bool accel_working; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 813 | struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES]; |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 814 | const struct firmware *me_fw; /* all family ME firmware */ |
| 815 | const struct firmware *pfp_fw; /* r6/700 PFP firmware */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 816 | const struct firmware *rlc_fw; /* r6/700 RLC firmware */ |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 817 | struct r600_blit r600_blit; |
Alex Deucher | 3e5cb98 | 2009-10-16 12:21:24 -0400 | [diff] [blame] | 818 | int msi_enabled; /* msi enabled */ |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 819 | struct r600_ih ih; /* r6/700 interrupt ring */ |
Alex Deucher | d4877cf | 2009-12-04 16:56:37 -0500 | [diff] [blame] | 820 | struct workqueue_struct *wq; |
| 821 | struct work_struct hotplug_work; |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 822 | |
| 823 | /* audio stuff */ |
| 824 | struct timer_list audio_timer; |
| 825 | int audio_channels; |
| 826 | int audio_rate; |
| 827 | int audio_bits_per_sample; |
| 828 | uint8_t audio_status_bits; |
| 829 | uint8_t audio_category_code; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 830 | }; |
| 831 | |
| 832 | int radeon_device_init(struct radeon_device *rdev, |
| 833 | struct drm_device *ddev, |
| 834 | struct pci_dev *pdev, |
| 835 | uint32_t flags); |
| 836 | void radeon_device_fini(struct radeon_device *rdev); |
| 837 | int radeon_gpu_wait_for_idle(struct radeon_device *rdev); |
| 838 | |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 839 | /* r600 blit */ |
| 840 | int r600_blit_prepare_copy(struct radeon_device *rdev, int size_bytes); |
| 841 | void r600_blit_done_copy(struct radeon_device *rdev, struct radeon_fence *fence); |
| 842 | void r600_kms_blit_copy(struct radeon_device *rdev, |
| 843 | u64 src_gpu_addr, u64 dst_gpu_addr, |
| 844 | int size_bytes); |
| 845 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 846 | static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg) |
| 847 | { |
| 848 | if (reg < 0x10000) |
| 849 | return readl(((void __iomem *)rdev->rmmio) + reg); |
| 850 | else { |
| 851 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 852 | return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 857 | { |
| 858 | if (reg < 0x10000) |
| 859 | writel(v, ((void __iomem *)rdev->rmmio) + reg); |
| 860 | else { |
| 861 | writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX); |
| 862 | writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA); |
| 863 | } |
| 864 | } |
| 865 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 866 | /* |
| 867 | * Cast helper |
| 868 | */ |
| 869 | #define to_radeon_fence(p) ((struct radeon_fence *)(p)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 870 | |
| 871 | /* |
| 872 | * Registers read & write functions. |
| 873 | */ |
| 874 | #define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) |
| 875 | #define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 876 | #define RREG32(reg) r100_mm_rreg(rdev, (reg)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 877 | #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg))) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 878 | #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 879 | #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 880 | #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) |
| 881 | #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg)) |
| 882 | #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v)) |
| 883 | #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg)) |
| 884 | #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v)) |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 885 | #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg)) |
| 886 | #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 887 | #define WREG32_P(reg, val, mask) \ |
| 888 | do { \ |
| 889 | uint32_t tmp_ = RREG32(reg); \ |
| 890 | tmp_ &= (mask); \ |
| 891 | tmp_ |= ((val) & ~(mask)); \ |
| 892 | WREG32(reg, tmp_); \ |
| 893 | } while (0) |
| 894 | #define WREG32_PLL_P(reg, val, mask) \ |
| 895 | do { \ |
| 896 | uint32_t tmp_ = RREG32_PLL(reg); \ |
| 897 | tmp_ &= (mask); \ |
| 898 | tmp_ |= ((val) & ~(mask)); \ |
| 899 | WREG32_PLL(reg, tmp_); \ |
| 900 | } while (0) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 901 | #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg))) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 902 | |
Dave Airlie | de1b289 | 2009-08-12 18:43:14 +1000 | [diff] [blame] | 903 | /* |
| 904 | * Indirect registers accessor |
| 905 | */ |
| 906 | static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg) |
| 907 | { |
| 908 | uint32_t r; |
| 909 | |
| 910 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 911 | r = RREG32(RADEON_PCIE_DATA); |
| 912 | return r; |
| 913 | } |
| 914 | |
| 915 | static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v) |
| 916 | { |
| 917 | WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask)); |
| 918 | WREG32(RADEON_PCIE_DATA, (v)); |
| 919 | } |
| 920 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 921 | void r100_pll_errata_after_index(struct radeon_device *rdev); |
| 922 | |
| 923 | |
| 924 | /* |
| 925 | * ASICs helpers. |
| 926 | */ |
Dave Airlie | b995e43 | 2009-07-14 02:02:32 +1000 | [diff] [blame] | 927 | #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \ |
| 928 | (rdev->pdev->device == 0x5969)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 929 | #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \ |
| 930 | (rdev->family == CHIP_RV200) || \ |
| 931 | (rdev->family == CHIP_RS100) || \ |
| 932 | (rdev->family == CHIP_RS200) || \ |
| 933 | (rdev->family == CHIP_RV250) || \ |
| 934 | (rdev->family == CHIP_RV280) || \ |
| 935 | (rdev->family == CHIP_RS300)) |
| 936 | #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \ |
| 937 | (rdev->family == CHIP_RV350) || \ |
| 938 | (rdev->family == CHIP_R350) || \ |
| 939 | (rdev->family == CHIP_RV380) || \ |
| 940 | (rdev->family == CHIP_R420) || \ |
| 941 | (rdev->family == CHIP_R423) || \ |
| 942 | (rdev->family == CHIP_RV410) || \ |
| 943 | (rdev->family == CHIP_RS400) || \ |
| 944 | (rdev->family == CHIP_RS480)) |
| 945 | #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600)) |
| 946 | #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620)) |
| 947 | #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730)) |
| 948 | |
| 949 | |
| 950 | /* |
| 951 | * BIOS helpers. |
| 952 | */ |
| 953 | #define RBIOS8(i) (rdev->bios[i]) |
| 954 | #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8)) |
| 955 | #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16)) |
| 956 | |
| 957 | int radeon_combios_init(struct radeon_device *rdev); |
| 958 | void radeon_combios_fini(struct radeon_device *rdev); |
| 959 | int radeon_atombios_init(struct radeon_device *rdev); |
| 960 | void radeon_atombios_fini(struct radeon_device *rdev); |
| 961 | |
| 962 | |
| 963 | /* |
| 964 | * RING helpers. |
| 965 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 966 | static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v) |
| 967 | { |
| 968 | #if DRM_DEBUG_CODE |
| 969 | if (rdev->cp.count_dw <= 0) { |
| 970 | DRM_ERROR("radeon: writting more dword to ring than expected !\n"); |
| 971 | } |
| 972 | #endif |
| 973 | rdev->cp.ring[rdev->cp.wptr++] = v; |
| 974 | rdev->cp.wptr &= rdev->cp.ptr_mask; |
| 975 | rdev->cp.count_dw--; |
| 976 | rdev->cp.ring_free_dw--; |
| 977 | } |
| 978 | |
| 979 | |
| 980 | /* |
| 981 | * ASICs macro. |
| 982 | */ |
Jerome Glisse | 068a117 | 2009-06-17 13:28:30 +0200 | [diff] [blame] | 983 | #define radeon_init(rdev) (rdev)->asic->init((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 984 | #define radeon_fini(rdev) (rdev)->asic->fini((rdev)) |
| 985 | #define radeon_resume(rdev) (rdev)->asic->resume((rdev)) |
| 986 | #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 987 | #define radeon_cs_parse(p) rdev->asic->cs_parse((p)) |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 988 | #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 989 | #define radeon_gpu_reset(rdev) (rdev)->asic->gpu_reset((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 990 | #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev)) |
| 991 | #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), (i), (p)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 992 | #define radeon_cp_commit(rdev) (rdev)->asic->cp_commit((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 993 | #define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) |
Jerome Glisse | 3ce0a23 | 2009-09-08 10:10:24 +1000 | [diff] [blame] | 994 | #define radeon_ring_test(rdev) (rdev)->asic->ring_test((rdev)) |
| 995 | #define radeon_ring_ib_execute(rdev, ib) (rdev)->asic->ring_ib_execute((rdev), (ib)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 996 | #define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) |
| 997 | #define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 998 | #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 999 | #define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence)) |
| 1000 | #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f)) |
| 1001 | #define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f)) |
| 1002 | #define radeon_copy(rdev, s, d, np, f) (rdev)->asic->copy((rdev), (s), (d), (np), (f)) |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 1003 | #define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1004 | #define radeon_set_engine_clock(rdev, e) (rdev)->asic->set_engine_clock((rdev), (e)) |
Rafał Miłecki | 7433874 | 2009-11-03 00:53:02 +0100 | [diff] [blame] | 1005 | #define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev)) |
Rafał Miłecki | 93e7de7 | 2009-11-04 23:34:10 +0100 | [diff] [blame] | 1006 | #define radeon_set_memory_clock(rdev, e) (rdev)->asic->set_memory_clock((rdev), (e)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1007 | #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), (l)) |
| 1008 | #define radeon_set_clock_gating(rdev, e) (rdev)->asic->set_clock_gating((rdev), (e)) |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 1009 | #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s))) |
| 1010 | #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->clear_surface_reg((rdev), (r))) |
Jerome Glisse | c93bb85 | 2009-07-13 21:04:08 +0200 | [diff] [blame] | 1011 | #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev)) |
Dave Airlie | 23956df | 2009-11-23 12:01:09 +1000 | [diff] [blame] | 1012 | #define radeon_hdp_flush(rdev) (rdev)->asic->hdp_flush((rdev)) |
Alex Deucher | 429770b | 2009-12-04 15:26:55 -0500 | [diff] [blame] | 1013 | #define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev)) |
| 1014 | #define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev)) |
| 1015 | #define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd)) |
| 1016 | #define radeon_hpd_set_polarity(rdev, hpd) (rdev)->asic->hpd_set_polarity((rdev), (hpd)) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1017 | |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1018 | /* Common functions */ |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1019 | extern int radeon_gart_table_vram_pin(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1020 | extern int radeon_modeset_init(struct radeon_device *rdev); |
| 1021 | extern void radeon_modeset_fini(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1022 | extern bool radeon_card_posted(struct radeon_device *rdev); |
Dave Airlie | 72542d7 | 2009-12-01 14:06:31 +1000 | [diff] [blame] | 1023 | extern bool radeon_boot_test_post_card(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1024 | extern int radeon_clocks_init(struct radeon_device *rdev); |
| 1025 | extern void radeon_clocks_fini(struct radeon_device *rdev); |
| 1026 | extern void radeon_scratch_init(struct radeon_device *rdev); |
| 1027 | extern void radeon_surface_init(struct radeon_device *rdev); |
| 1028 | extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1029 | extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1030 | extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable); |
Jerome Glisse | 312ea8d | 2009-12-07 15:52:58 +0100 | [diff] [blame] | 1031 | extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain); |
Jerome Glisse | d03d858 | 2009-12-14 21:02:09 +0100 | [diff] [blame] | 1032 | extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo); |
Jerome Glisse | 6cf8a3f5 | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 1033 | |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1034 | /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */ |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1035 | struct r100_mc_save { |
| 1036 | u32 GENMO_WT; |
| 1037 | u32 CRTC_EXT_CNTL; |
| 1038 | u32 CRTC_GEN_CNTL; |
| 1039 | u32 CRTC2_GEN_CNTL; |
| 1040 | u32 CUR_OFFSET; |
| 1041 | u32 CUR2_OFFSET; |
| 1042 | }; |
| 1043 | extern void r100_cp_disable(struct radeon_device *rdev); |
| 1044 | extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size); |
| 1045 | extern void r100_cp_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1046 | extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1047 | extern int r100_pci_gart_init(struct radeon_device *rdev); |
| 1048 | extern void r100_pci_gart_fini(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1049 | extern int r100_pci_gart_enable(struct radeon_device *rdev); |
| 1050 | extern void r100_pci_gart_disable(struct radeon_device *rdev); |
| 1051 | extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1052 | extern int r100_debugfs_mc_info_init(struct radeon_device *rdev); |
| 1053 | extern int r100_gui_wait_for_idle(struct radeon_device *rdev); |
| 1054 | extern void r100_ib_fini(struct radeon_device *rdev); |
| 1055 | extern int r100_ib_init(struct radeon_device *rdev); |
| 1056 | extern void r100_irq_disable(struct radeon_device *rdev); |
| 1057 | extern int r100_irq_set(struct radeon_device *rdev); |
| 1058 | extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save); |
| 1059 | extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1060 | extern void r100_vram_init_sizes(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1061 | extern void r100_wb_disable(struct radeon_device *rdev); |
| 1062 | extern void r100_wb_fini(struct radeon_device *rdev); |
| 1063 | extern int r100_wb_init(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1064 | extern void r100_hdp_reset(struct radeon_device *rdev); |
| 1065 | extern int r100_rb2d_reset(struct radeon_device *rdev); |
| 1066 | extern int r100_cp_reset(struct radeon_device *rdev); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1067 | extern void r100_vga_render_disable(struct radeon_device *rdev); |
Jerome Glisse | 207bf9e | 2009-09-30 15:35:32 +0200 | [diff] [blame] | 1068 | extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p, |
| 1069 | struct radeon_cs_packet *pkt, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1070 | struct radeon_bo *robj); |
Jerome Glisse | 207bf9e | 2009-09-30 15:35:32 +0200 | [diff] [blame] | 1071 | extern int r100_cs_parse_packet0(struct radeon_cs_parser *p, |
| 1072 | struct radeon_cs_packet *pkt, |
| 1073 | const unsigned *auth, unsigned n, |
| 1074 | radeon_packet0_check_t check); |
| 1075 | extern int r100_cs_packet_parse(struct radeon_cs_parser *p, |
| 1076 | struct radeon_cs_packet *pkt, |
| 1077 | unsigned idx); |
Dave Airlie | 17e15b0 | 2009-11-05 15:36:53 +1000 | [diff] [blame] | 1078 | extern void r100_enable_bm(struct radeon_device *rdev); |
Alex Deucher | 92cde00 | 2009-12-04 10:55:12 -0500 | [diff] [blame] | 1079 | extern void r100_set_common_regs(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1080 | |
Jerome Glisse | d455090 | 2009-10-01 10:12:06 +0200 | [diff] [blame] | 1081 | /* rv200,rv250,rv280 */ |
| 1082 | extern void r200_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1083 | |
| 1084 | /* r300,r350,rv350,rv370,rv380 */ |
| 1085 | extern void r300_set_reg_safe(struct radeon_device *rdev); |
| 1086 | extern void r300_mc_program(struct radeon_device *rdev); |
| 1087 | extern void r300_vram_info(struct radeon_device *rdev); |
Jerome Glisse | ca6ffc6 | 2009-10-01 10:20:52 +0200 | [diff] [blame] | 1088 | extern void r300_clock_startup(struct radeon_device *rdev); |
| 1089 | extern int r300_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1090 | extern int rv370_pcie_gart_init(struct radeon_device *rdev); |
| 1091 | extern void rv370_pcie_gart_fini(struct radeon_device *rdev); |
| 1092 | extern int rv370_pcie_gart_enable(struct radeon_device *rdev); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1093 | extern void rv370_pcie_gart_disable(struct radeon_device *rdev); |
Jerome Glisse | a18d7ea | 2009-09-09 22:23:27 +0200 | [diff] [blame] | 1094 | |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1095 | /* r420,r423,rv410 */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1096 | extern int r420_mc_init(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1097 | extern u32 r420_mc_rreg(struct radeon_device *rdev, u32 reg); |
| 1098 | extern void r420_mc_wreg(struct radeon_device *rdev, u32 reg, u32 v); |
Jerome Glisse | 9f022dd | 2009-09-11 15:35:22 +0200 | [diff] [blame] | 1099 | extern int r420_debugfs_pipes_info_init(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1100 | extern void r420_pipes_init(struct radeon_device *rdev); |
Jerome Glisse | 905b682 | 2009-09-09 22:24:20 +0200 | [diff] [blame] | 1101 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1102 | /* rv515 */ |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1103 | struct rv515_mc_save { |
| 1104 | u32 d1vga_control; |
| 1105 | u32 d2vga_control; |
| 1106 | u32 vga_render_control; |
| 1107 | u32 vga_hdp_control; |
| 1108 | u32 d1crtc_control; |
| 1109 | u32 d2crtc_control; |
| 1110 | }; |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1111 | extern void rv515_bandwidth_avivo_update(struct radeon_device *rdev); |
Jerome Glisse | d39c3b8 | 2009-09-28 18:34:43 +0200 | [diff] [blame] | 1112 | extern void rv515_vga_render_disable(struct radeon_device *rdev); |
| 1113 | extern void rv515_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | f0ed1f6 | 2009-09-28 20:39:19 +0200 | [diff] [blame] | 1114 | extern void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1115 | extern void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save); |
| 1116 | extern void rv515_clock_startup(struct radeon_device *rdev); |
| 1117 | extern void rv515_debugfs(struct radeon_device *rdev); |
| 1118 | extern int rv515_suspend(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1119 | |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1120 | /* rs400 */ |
| 1121 | extern int rs400_gart_init(struct radeon_device *rdev); |
| 1122 | extern int rs400_gart_enable(struct radeon_device *rdev); |
| 1123 | extern void rs400_gart_adjust_size(struct radeon_device *rdev); |
| 1124 | extern void rs400_gart_disable(struct radeon_device *rdev); |
| 1125 | extern void rs400_gart_fini(struct radeon_device *rdev); |
| 1126 | |
| 1127 | /* rs600 */ |
| 1128 | extern void rs600_set_safe_registers(struct radeon_device *rdev); |
Jerome Glisse | ac447df | 2009-09-30 22:18:43 +0200 | [diff] [blame] | 1129 | extern int rs600_irq_set(struct radeon_device *rdev); |
| 1130 | extern void rs600_irq_disable(struct radeon_device *rdev); |
Jerome Glisse | 3bc6853 | 2009-10-01 09:39:24 +0200 | [diff] [blame] | 1131 | |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1132 | /* rs690, rs740 */ |
| 1133 | extern void rs690_line_buffer_adjust(struct radeon_device *rdev, |
| 1134 | struct drm_display_mode *mode1, |
| 1135 | struct drm_display_mode *mode2); |
| 1136 | |
| 1137 | /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */ |
| 1138 | extern bool r600_card_posted(struct radeon_device *rdev); |
| 1139 | extern void r600_cp_stop(struct radeon_device *rdev); |
| 1140 | extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1141 | extern int r600_cp_resume(struct radeon_device *rdev); |
| 1142 | extern int r600_count_pipe_bits(uint32_t val); |
| 1143 | extern int r600_gart_clear_page(struct radeon_device *rdev, int i); |
| 1144 | extern int r600_mc_wait_for_idle(struct radeon_device *rdev); |
Jerome Glisse | 4aac047 | 2009-09-14 18:29:49 +0200 | [diff] [blame] | 1145 | extern int r600_pcie_gart_init(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1146 | extern void r600_pcie_gart_tlb_flush(struct radeon_device *rdev); |
| 1147 | extern int r600_ib_test(struct radeon_device *rdev); |
| 1148 | extern int r600_ring_test(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1149 | extern void r600_wb_fini(struct radeon_device *rdev); |
Jerome Glisse | 81cc35b | 2009-10-01 18:02:12 +0200 | [diff] [blame] | 1150 | extern int r600_wb_enable(struct radeon_device *rdev); |
| 1151 | extern void r600_wb_disable(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1152 | extern void r600_scratch_init(struct radeon_device *rdev); |
| 1153 | extern int r600_blit_init(struct radeon_device *rdev); |
| 1154 | extern void r600_blit_fini(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1155 | extern int r600_init_microcode(struct radeon_device *rdev); |
Dave Airlie | fe62e1a | 2009-09-21 14:06:30 +1000 | [diff] [blame] | 1156 | extern int r600_gpu_reset(struct radeon_device *rdev); |
Alex Deucher | d8f60cf | 2009-12-01 13:43:46 -0500 | [diff] [blame] | 1157 | /* r600 irq */ |
| 1158 | extern int r600_irq_init(struct radeon_device *rdev); |
| 1159 | extern void r600_irq_fini(struct radeon_device *rdev); |
| 1160 | extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); |
| 1161 | extern int r600_irq_set(struct radeon_device *rdev); |
Jerome Glisse | 21f9a43 | 2009-09-11 15:55:33 +0200 | [diff] [blame] | 1162 | |
Christian Koenig | dafc3bd | 2009-10-11 23:49:13 +0200 | [diff] [blame] | 1163 | extern int r600_audio_init(struct radeon_device *rdev); |
| 1164 | extern int r600_audio_tmds_index(struct drm_encoder *encoder); |
| 1165 | extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock); |
| 1166 | extern void r600_audio_fini(struct radeon_device *rdev); |
| 1167 | extern void r600_hdmi_init(struct drm_encoder *encoder); |
| 1168 | extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable); |
| 1169 | extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode); |
| 1170 | extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder); |
| 1171 | extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder, |
| 1172 | int channels, |
| 1173 | int rate, |
| 1174 | int bps, |
| 1175 | uint8_t status_bits, |
| 1176 | uint8_t category_code); |
| 1177 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 1178 | #include "radeon_object.h" |
| 1179 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1180 | #endif |