Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2005 Stephane Marchesin. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * 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 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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 | |
| 25 | #ifndef __NOUVEAU_DRV_H__ |
| 26 | #define __NOUVEAU_DRV_H__ |
| 27 | |
| 28 | #define DRIVER_AUTHOR "Stephane Marchesin" |
| 29 | #define DRIVER_EMAIL "dri-devel@lists.sourceforge.net" |
| 30 | |
| 31 | #define DRIVER_NAME "nouveau" |
| 32 | #define DRIVER_DESC "nVidia Riva/TNT/GeForce" |
| 33 | #define DRIVER_DATE "20090420" |
| 34 | |
| 35 | #define DRIVER_MAJOR 0 |
| 36 | #define DRIVER_MINOR 0 |
Ben Skeggs | a1606a9 | 2010-02-12 10:27:35 +1000 | [diff] [blame] | 37 | #define DRIVER_PATCHLEVEL 16 |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 38 | |
| 39 | #define NOUVEAU_FAMILY 0x0000FFFF |
| 40 | #define NOUVEAU_FLAGS 0xFFFF0000 |
| 41 | |
| 42 | #include "ttm/ttm_bo_api.h" |
| 43 | #include "ttm/ttm_bo_driver.h" |
| 44 | #include "ttm/ttm_placement.h" |
| 45 | #include "ttm/ttm_memory.h" |
| 46 | #include "ttm/ttm_module.h" |
| 47 | |
| 48 | struct nouveau_fpriv { |
| 49 | struct ttm_object_file *tfile; |
| 50 | }; |
| 51 | |
| 52 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
| 53 | |
| 54 | #include "nouveau_drm.h" |
| 55 | #include "nouveau_reg.h" |
| 56 | #include "nouveau_bios.h" |
Ben Skeggs | 054b93e | 2009-12-15 22:02:47 +1000 | [diff] [blame] | 57 | struct nouveau_grctx; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 58 | |
| 59 | #define MAX_NUM_DCB_ENTRIES 16 |
| 60 | |
| 61 | #define NOUVEAU_MAX_CHANNEL_NR 128 |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 62 | #define NOUVEAU_MAX_TILE_NR 15 |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 63 | |
| 64 | #define NV50_VM_MAX_VRAM (2*1024*1024*1024ULL) |
| 65 | #define NV50_VM_BLOCK (512*1024*1024ULL) |
| 66 | #define NV50_VM_VRAM_NR (NV50_VM_MAX_VRAM / NV50_VM_BLOCK) |
| 67 | |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 68 | struct nouveau_tile_reg { |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 69 | bool used; |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 70 | uint32_t addr; |
| 71 | uint32_t limit; |
| 72 | uint32_t pitch; |
Francisco Jerez | 87a326a | 2010-10-24 16:36:12 +0200 | [diff] [blame] | 73 | uint32_t zcomp; |
| 74 | struct drm_mm_node *tag_mem; |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 75 | struct nouveau_fence *fence; |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 78 | struct nouveau_bo { |
| 79 | struct ttm_buffer_object bo; |
| 80 | struct ttm_placement placement; |
| 81 | u32 placements[3]; |
Francisco Jerez | 78ad0f7 | 2010-03-18 13:07:47 +0100 | [diff] [blame] | 82 | u32 busy_placements[3]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 83 | struct ttm_bo_kmap_obj kmap; |
| 84 | struct list_head head; |
| 85 | |
| 86 | /* protected by ttm_bo_reserve() */ |
| 87 | struct drm_file *reserved_by; |
| 88 | struct list_head entry; |
| 89 | int pbbo_index; |
Ben Skeggs | a1606a9 | 2010-02-12 10:27:35 +1000 | [diff] [blame] | 90 | bool validate_mapped; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 91 | |
| 92 | struct nouveau_channel *channel; |
| 93 | |
| 94 | bool mappable; |
| 95 | bool no_vm; |
| 96 | |
| 97 | uint32_t tile_mode; |
| 98 | uint32_t tile_flags; |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 99 | struct nouveau_tile_reg *tile; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 100 | |
| 101 | struct drm_gem_object *gem; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 102 | int pin_refcnt; |
| 103 | }; |
| 104 | |
Francisco Jerez | f13b326 | 2010-10-10 06:01:08 +0200 | [diff] [blame] | 105 | #define nouveau_bo_tile_layout(nvbo) \ |
| 106 | ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) |
| 107 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 108 | static inline struct nouveau_bo * |
| 109 | nouveau_bo(struct ttm_buffer_object *bo) |
| 110 | { |
| 111 | return container_of(bo, struct nouveau_bo, bo); |
| 112 | } |
| 113 | |
| 114 | static inline struct nouveau_bo * |
| 115 | nouveau_gem_object(struct drm_gem_object *gem) |
| 116 | { |
| 117 | return gem ? gem->driver_private : NULL; |
| 118 | } |
| 119 | |
| 120 | /* TODO: submit equivalent to TTM generic API upstream? */ |
| 121 | static inline void __iomem * |
| 122 | nvbo_kmap_obj_iovirtual(struct nouveau_bo *nvbo) |
| 123 | { |
| 124 | bool is_iomem; |
| 125 | void __iomem *ioptr = (void __force __iomem *)ttm_kmap_obj_virtual( |
| 126 | &nvbo->kmap, &is_iomem); |
| 127 | WARN_ON_ONCE(ioptr && !is_iomem); |
| 128 | return ioptr; |
| 129 | } |
| 130 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 131 | enum nouveau_flags { |
| 132 | NV_NFORCE = 0x10000000, |
| 133 | NV_NFORCE2 = 0x20000000 |
| 134 | }; |
| 135 | |
| 136 | #define NVOBJ_ENGINE_SW 0 |
| 137 | #define NVOBJ_ENGINE_GR 1 |
Ben Skeggs | bd2e597 | 2010-10-19 20:06:01 +1000 | [diff] [blame] | 138 | #define NVOBJ_ENGINE_PPP 2 |
| 139 | #define NVOBJ_ENGINE_COPY 3 |
| 140 | #define NVOBJ_ENGINE_VP 4 |
| 141 | #define NVOBJ_ENGINE_CRYPT 5 |
| 142 | #define NVOBJ_ENGINE_BSP 6 |
Ben Skeggs | 5053694 | 2010-10-19 19:47:06 +1000 | [diff] [blame] | 143 | #define NVOBJ_ENGINE_DISPLAY 0xcafe0001 |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 144 | #define NVOBJ_ENGINE_INT 0xdeadbeef |
| 145 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 146 | #define NVOBJ_FLAG_ZERO_ALLOC (1 << 1) |
| 147 | #define NVOBJ_FLAG_ZERO_FREE (1 << 2) |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 148 | struct nouveau_gpuobj { |
Ben Skeggs | b3beb16 | 2010-09-01 15:24:29 +1000 | [diff] [blame] | 149 | struct drm_device *dev; |
Ben Skeggs | eb9bcbd | 2010-09-01 15:24:37 +1000 | [diff] [blame] | 150 | struct kref refcount; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 151 | struct list_head list; |
| 152 | |
Ben Skeggs | b833ac2 | 2010-06-01 15:32:24 +1000 | [diff] [blame] | 153 | struct drm_mm_node *im_pramin; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 154 | struct nouveau_bo *im_backing; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 155 | uint32_t *im_backing_suspend; |
| 156 | int im_bound; |
| 157 | |
| 158 | uint32_t flags; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 159 | |
Ben Skeggs | 43efc9c | 2010-09-01 15:24:32 +1000 | [diff] [blame] | 160 | u32 size; |
Ben Skeggs | de3a6c0 | 2010-09-01 15:24:30 +1000 | [diff] [blame] | 161 | u32 pinst; |
| 162 | u32 cinst; |
| 163 | u64 vinst; |
| 164 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 165 | uint32_t engine; |
| 166 | uint32_t class; |
| 167 | |
| 168 | void (*dtor)(struct drm_device *, struct nouveau_gpuobj *); |
| 169 | void *priv; |
| 170 | }; |
| 171 | |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 172 | struct nouveau_page_flip_state { |
| 173 | struct list_head head; |
| 174 | struct drm_pending_vblank_event *event; |
| 175 | int crtc, bpp, pitch, x, y; |
| 176 | uint64_t offset; |
| 177 | }; |
| 178 | |
Francisco Jerez | e419cf0 | 2010-10-25 23:38:59 +0200 | [diff] [blame] | 179 | enum nouveau_channel_mutex_class { |
| 180 | NOUVEAU_UCHANNEL_MUTEX, |
| 181 | NOUVEAU_KCHANNEL_MUTEX |
| 182 | }; |
| 183 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 184 | struct nouveau_channel { |
| 185 | struct drm_device *dev; |
| 186 | int id; |
| 187 | |
Francisco Jerez | f091a3d | 2010-10-18 03:55:48 +0200 | [diff] [blame] | 188 | /* references to the channel data structure */ |
| 189 | struct kref ref; |
| 190 | /* users of the hardware channel resources, the hardware |
| 191 | * context will be kicked off when it reaches zero. */ |
| 192 | atomic_t users; |
Ben Skeggs | 6a6b73f | 2010-10-05 16:53:48 +1000 | [diff] [blame] | 193 | struct mutex mutex; |
| 194 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 195 | /* owner of this fifo */ |
| 196 | struct drm_file *file_priv; |
| 197 | /* mapping of the fifo itself */ |
| 198 | struct drm_local_map *map; |
| 199 | |
| 200 | /* mapping of the regs controling the fifo */ |
| 201 | void __iomem *user; |
| 202 | uint32_t user_get; |
| 203 | uint32_t user_put; |
| 204 | |
| 205 | /* Fencing */ |
| 206 | struct { |
| 207 | /* lock protects the pending list only */ |
| 208 | spinlock_t lock; |
| 209 | struct list_head pending; |
| 210 | uint32_t sequence; |
| 211 | uint32_t sequence_ack; |
Ben Skeggs | 047d1d3 | 2010-05-31 12:00:43 +1000 | [diff] [blame] | 212 | atomic_t last_sequence_irq; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 213 | } fence; |
| 214 | |
| 215 | /* DMA push buffer */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 216 | struct nouveau_gpuobj *pushbuf; |
| 217 | struct nouveau_bo *pushbuf_bo; |
| 218 | uint32_t pushbuf_base; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 219 | |
| 220 | /* Notifier memory */ |
| 221 | struct nouveau_bo *notifier_bo; |
Ben Skeggs | b833ac2 | 2010-06-01 15:32:24 +1000 | [diff] [blame] | 222 | struct drm_mm notifier_heap; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 223 | |
| 224 | /* PFIFO context */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 225 | struct nouveau_gpuobj *ramfc; |
| 226 | struct nouveau_gpuobj *cache; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 227 | |
| 228 | /* PGRAPH context */ |
| 229 | /* XXX may be merge 2 pointers as private data ??? */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 230 | struct nouveau_gpuobj *ramin_grctx; |
Ben Skeggs | bd2e597 | 2010-10-19 20:06:01 +1000 | [diff] [blame] | 231 | struct nouveau_gpuobj *crypt_ctx; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 232 | void *pgraph_ctx; |
| 233 | |
| 234 | /* NV50 VM */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 235 | struct nouveau_gpuobj *vm_pd; |
| 236 | struct nouveau_gpuobj *vm_gart_pt; |
| 237 | struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 238 | |
| 239 | /* Objects */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 240 | struct nouveau_gpuobj *ramin; /* Private instmem */ |
| 241 | struct drm_mm ramin_heap; /* Private PRAMIN heap */ |
| 242 | struct nouveau_ramht *ramht; /* Hash table */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 243 | |
| 244 | /* GPU object info for stuff used in-kernel (mm_enabled) */ |
| 245 | uint32_t m2mf_ntfy; |
| 246 | uint32_t vram_handle; |
| 247 | uint32_t gart_handle; |
| 248 | bool accel_done; |
| 249 | |
| 250 | /* Push buffer state (only for drm's channel on !mm_enabled) */ |
| 251 | struct { |
| 252 | int max; |
| 253 | int free; |
| 254 | int cur; |
| 255 | int put; |
| 256 | /* access via pushbuf_bo */ |
Ben Skeggs | 9a391ad | 2010-02-11 16:37:26 +1000 | [diff] [blame] | 257 | |
| 258 | int ib_base; |
| 259 | int ib_max; |
| 260 | int ib_free; |
| 261 | int ib_put; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 262 | } dma; |
| 263 | |
| 264 | uint32_t sw_subchannel[8]; |
| 265 | |
| 266 | struct { |
| 267 | struct nouveau_gpuobj *vblsem; |
Francisco Jerez | 1f6d2de | 2010-10-24 14:15:58 +0200 | [diff] [blame] | 268 | uint32_t vblsem_head; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 269 | uint32_t vblsem_offset; |
| 270 | uint32_t vblsem_rval; |
| 271 | struct list_head vbl_wait; |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 272 | struct list_head flip; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 273 | } nvsw; |
| 274 | |
| 275 | struct { |
| 276 | bool active; |
| 277 | char name[32]; |
| 278 | struct drm_info_list info; |
| 279 | } debugfs; |
| 280 | }; |
| 281 | |
| 282 | struct nouveau_instmem_engine { |
| 283 | void *priv; |
| 284 | |
| 285 | int (*init)(struct drm_device *dev); |
| 286 | void (*takedown)(struct drm_device *dev); |
| 287 | int (*suspend)(struct drm_device *dev); |
| 288 | void (*resume)(struct drm_device *dev); |
| 289 | |
| 290 | int (*populate)(struct drm_device *, struct nouveau_gpuobj *, |
Ben Skeggs | 9100468 | 2010-10-15 09:15:26 +1000 | [diff] [blame] | 291 | u32 *size, u32 align); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 292 | void (*clear)(struct drm_device *, struct nouveau_gpuobj *); |
| 293 | int (*bind)(struct drm_device *, struct nouveau_gpuobj *); |
| 294 | int (*unbind)(struct drm_device *, struct nouveau_gpuobj *); |
Ben Skeggs | f56cb86 | 2010-07-08 11:29:10 +1000 | [diff] [blame] | 295 | void (*flush)(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | struct nouveau_mc_engine { |
| 299 | int (*init)(struct drm_device *dev); |
| 300 | void (*takedown)(struct drm_device *dev); |
| 301 | }; |
| 302 | |
| 303 | struct nouveau_timer_engine { |
| 304 | int (*init)(struct drm_device *dev); |
| 305 | void (*takedown)(struct drm_device *dev); |
| 306 | uint64_t (*read)(struct drm_device *dev); |
| 307 | }; |
| 308 | |
| 309 | struct nouveau_fb_engine { |
Francisco Jerez | cb00f7c | 2009-12-16 12:12:27 +0100 | [diff] [blame] | 310 | int num_tiles; |
Francisco Jerez | 87a326a | 2010-10-24 16:36:12 +0200 | [diff] [blame] | 311 | struct drm_mm tag_heap; |
Francisco Jerez | cb00f7c | 2009-12-16 12:12:27 +0100 | [diff] [blame] | 312 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 313 | int (*init)(struct drm_device *dev); |
| 314 | void (*takedown)(struct drm_device *dev); |
Francisco Jerez | cb00f7c | 2009-12-16 12:12:27 +0100 | [diff] [blame] | 315 | |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 316 | void (*init_tile_region)(struct drm_device *dev, int i, |
| 317 | uint32_t addr, uint32_t size, |
| 318 | uint32_t pitch, uint32_t flags); |
| 319 | void (*set_tile_region)(struct drm_device *dev, int i); |
| 320 | void (*free_tile_region)(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | struct nouveau_fifo_engine { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 324 | int channels; |
| 325 | |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 326 | struct nouveau_gpuobj *playlist[2]; |
Ben Skeggs | ac94a34 | 2010-07-08 15:28:48 +1000 | [diff] [blame] | 327 | int cur_playlist; |
| 328 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 329 | int (*init)(struct drm_device *); |
| 330 | void (*takedown)(struct drm_device *); |
| 331 | |
| 332 | void (*disable)(struct drm_device *); |
| 333 | void (*enable)(struct drm_device *); |
| 334 | bool (*reassign)(struct drm_device *, bool enable); |
Francisco Jerez | 588d7d1 | 2009-12-13 20:07:42 +0100 | [diff] [blame] | 335 | bool (*cache_pull)(struct drm_device *dev, bool enable); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 336 | |
| 337 | int (*channel_id)(struct drm_device *); |
| 338 | |
| 339 | int (*create_context)(struct nouveau_channel *); |
| 340 | void (*destroy_context)(struct nouveau_channel *); |
| 341 | int (*load_context)(struct nouveau_channel *); |
| 342 | int (*unload_context)(struct drm_device *); |
Ben Skeggs | 56ac747 | 2010-10-22 10:26:24 +1000 | [diff] [blame] | 343 | void (*tlb_flush)(struct drm_device *dev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 344 | }; |
| 345 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 346 | struct nouveau_pgraph_engine { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 347 | bool accel_blocked; |
Ben Skeggs | b8c157d | 2010-10-20 10:39:35 +1000 | [diff] [blame] | 348 | bool registered; |
Ben Skeggs | 054b93e | 2009-12-15 22:02:47 +1000 | [diff] [blame] | 349 | int grctx_size; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 350 | |
Ben Skeggs | c50a568 | 2010-07-08 15:40:18 +1000 | [diff] [blame] | 351 | /* NV2x/NV3x context table (0x400780) */ |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 352 | struct nouveau_gpuobj *ctx_table; |
Ben Skeggs | c50a568 | 2010-07-08 15:40:18 +1000 | [diff] [blame] | 353 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 354 | int (*init)(struct drm_device *); |
| 355 | void (*takedown)(struct drm_device *); |
| 356 | |
| 357 | void (*fifo_access)(struct drm_device *, bool); |
| 358 | |
| 359 | struct nouveau_channel *(*channel)(struct drm_device *); |
| 360 | int (*create_context)(struct nouveau_channel *); |
| 361 | void (*destroy_context)(struct nouveau_channel *); |
| 362 | int (*load_context)(struct nouveau_channel *); |
| 363 | int (*unload_context)(struct drm_device *); |
Ben Skeggs | 56ac747 | 2010-10-22 10:26:24 +1000 | [diff] [blame] | 364 | void (*tlb_flush)(struct drm_device *dev); |
Francisco Jerez | cb00f7c | 2009-12-16 12:12:27 +0100 | [diff] [blame] | 365 | |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 366 | void (*set_tile_region)(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 367 | }; |
| 368 | |
Francisco Jerez | c88c2e0 | 2010-07-24 17:37:33 +0200 | [diff] [blame] | 369 | struct nouveau_display_engine { |
| 370 | int (*early_init)(struct drm_device *); |
| 371 | void (*late_takedown)(struct drm_device *); |
| 372 | int (*create)(struct drm_device *); |
| 373 | int (*init)(struct drm_device *); |
| 374 | void (*destroy)(struct drm_device *); |
| 375 | }; |
| 376 | |
Ben Skeggs | ee2e013 | 2010-07-26 09:28:25 +1000 | [diff] [blame] | 377 | struct nouveau_gpio_engine { |
| 378 | int (*init)(struct drm_device *); |
| 379 | void (*takedown)(struct drm_device *); |
| 380 | |
| 381 | int (*get)(struct drm_device *, enum dcb_gpio_tag); |
| 382 | int (*set)(struct drm_device *, enum dcb_gpio_tag, int state); |
| 383 | |
| 384 | void (*irq_enable)(struct drm_device *, enum dcb_gpio_tag, bool on); |
| 385 | }; |
| 386 | |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 387 | struct nouveau_pm_voltage_level { |
| 388 | u8 voltage; |
| 389 | u8 vid; |
| 390 | }; |
| 391 | |
| 392 | struct nouveau_pm_voltage { |
| 393 | bool supported; |
| 394 | u8 vid_mask; |
| 395 | |
| 396 | struct nouveau_pm_voltage_level *level; |
| 397 | int nr_level; |
| 398 | }; |
| 399 | |
| 400 | #define NOUVEAU_PM_MAX_LEVEL 8 |
| 401 | struct nouveau_pm_level { |
| 402 | struct device_attribute dev_attr; |
| 403 | char name[32]; |
| 404 | int id; |
| 405 | |
| 406 | u32 core; |
| 407 | u32 memory; |
| 408 | u32 shader; |
| 409 | u32 unk05; |
| 410 | |
| 411 | u8 voltage; |
| 412 | u8 fanspeed; |
Ben Skeggs | aee582d | 2010-09-27 10:13:23 +1000 | [diff] [blame] | 413 | |
| 414 | u16 memscript; |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 415 | }; |
| 416 | |
Martin Peres | 34e9d85 | 2010-09-22 20:54:22 +0200 | [diff] [blame] | 417 | struct nouveau_pm_temp_sensor_constants { |
| 418 | u16 offset_constant; |
| 419 | s16 offset_mult; |
| 420 | u16 offset_div; |
| 421 | u16 slope_mult; |
| 422 | u16 slope_div; |
| 423 | }; |
| 424 | |
| 425 | struct nouveau_pm_threshold_temp { |
| 426 | s16 critical; |
| 427 | s16 down_clock; |
| 428 | s16 fan_boost; |
| 429 | }; |
| 430 | |
Roy Spliet | 7760fcb | 2010-09-17 23:17:24 +0200 | [diff] [blame] | 431 | struct nouveau_pm_memtiming { |
| 432 | u32 reg_100220; |
| 433 | u32 reg_100224; |
| 434 | u32 reg_100228; |
| 435 | u32 reg_10022c; |
| 436 | u32 reg_100230; |
| 437 | u32 reg_100234; |
| 438 | u32 reg_100238; |
| 439 | u32 reg_10023c; |
| 440 | }; |
| 441 | |
| 442 | struct nouveau_pm_memtimings { |
| 443 | bool supported; |
| 444 | struct nouveau_pm_memtiming *timing; |
| 445 | int nr_timing; |
| 446 | }; |
| 447 | |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 448 | struct nouveau_pm_engine { |
| 449 | struct nouveau_pm_voltage voltage; |
| 450 | struct nouveau_pm_level perflvl[NOUVEAU_PM_MAX_LEVEL]; |
| 451 | int nr_perflvl; |
Roy Spliet | 7760fcb | 2010-09-17 23:17:24 +0200 | [diff] [blame] | 452 | struct nouveau_pm_memtimings memtimings; |
Martin Peres | 34e9d85 | 2010-09-22 20:54:22 +0200 | [diff] [blame] | 453 | struct nouveau_pm_temp_sensor_constants sensor_constants; |
| 454 | struct nouveau_pm_threshold_temp threshold_temp; |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 455 | |
| 456 | struct nouveau_pm_level boot; |
| 457 | struct nouveau_pm_level *cur; |
| 458 | |
Francisco Jerez | 8155cac | 2010-09-23 20:58:38 +0200 | [diff] [blame] | 459 | struct device *hwmon; |
Ben Skeggs | 6032649 | 2010-10-12 12:31:32 +1000 | [diff] [blame] | 460 | struct notifier_block acpi_nb; |
Francisco Jerez | 8155cac | 2010-09-23 20:58:38 +0200 | [diff] [blame] | 461 | |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 462 | int (*clock_get)(struct drm_device *, u32 id); |
Ben Skeggs | 5c6dc65 | 2010-09-27 09:47:56 +1000 | [diff] [blame] | 463 | void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *, |
| 464 | u32 id, int khz); |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 465 | void (*clock_set)(struct drm_device *, void *); |
| 466 | int (*voltage_get)(struct drm_device *); |
| 467 | int (*voltage_set)(struct drm_device *, int voltage); |
| 468 | int (*fanspeed_get)(struct drm_device *); |
| 469 | int (*fanspeed_set)(struct drm_device *, int fanspeed); |
Francisco Jerez | 8155cac | 2010-09-23 20:58:38 +0200 | [diff] [blame] | 470 | int (*temp_get)(struct drm_device *); |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 471 | }; |
| 472 | |
Ben Skeggs | bd2e597 | 2010-10-19 20:06:01 +1000 | [diff] [blame] | 473 | struct nouveau_crypt_engine { |
| 474 | bool registered; |
| 475 | |
| 476 | int (*init)(struct drm_device *); |
| 477 | void (*takedown)(struct drm_device *); |
| 478 | int (*create_context)(struct nouveau_channel *); |
| 479 | void (*destroy_context)(struct nouveau_channel *); |
| 480 | void (*tlb_flush)(struct drm_device *dev); |
| 481 | }; |
| 482 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 483 | struct nouveau_engine { |
| 484 | struct nouveau_instmem_engine instmem; |
| 485 | struct nouveau_mc_engine mc; |
| 486 | struct nouveau_timer_engine timer; |
| 487 | struct nouveau_fb_engine fb; |
| 488 | struct nouveau_pgraph_engine graph; |
| 489 | struct nouveau_fifo_engine fifo; |
Francisco Jerez | c88c2e0 | 2010-07-24 17:37:33 +0200 | [diff] [blame] | 490 | struct nouveau_display_engine display; |
Ben Skeggs | ee2e013 | 2010-07-26 09:28:25 +1000 | [diff] [blame] | 491 | struct nouveau_gpio_engine gpio; |
Ben Skeggs | 330c598 | 2010-09-16 15:39:49 +1000 | [diff] [blame] | 492 | struct nouveau_pm_engine pm; |
Ben Skeggs | bd2e597 | 2010-10-19 20:06:01 +1000 | [diff] [blame] | 493 | struct nouveau_crypt_engine crypt; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 494 | }; |
| 495 | |
| 496 | struct nouveau_pll_vals { |
| 497 | union { |
| 498 | struct { |
| 499 | #ifdef __BIG_ENDIAN |
| 500 | uint8_t N1, M1, N2, M2; |
| 501 | #else |
| 502 | uint8_t M1, N1, M2, N2; |
| 503 | #endif |
| 504 | }; |
| 505 | struct { |
| 506 | uint16_t NM1, NM2; |
| 507 | } __attribute__((packed)); |
| 508 | }; |
| 509 | int log2P; |
| 510 | |
| 511 | int refclk; |
| 512 | }; |
| 513 | |
| 514 | enum nv04_fp_display_regs { |
| 515 | FP_DISPLAY_END, |
| 516 | FP_TOTAL, |
| 517 | FP_CRTC, |
| 518 | FP_SYNC_START, |
| 519 | FP_SYNC_END, |
| 520 | FP_VALID_START, |
| 521 | FP_VALID_END |
| 522 | }; |
| 523 | |
| 524 | struct nv04_crtc_reg { |
Francisco Jerez | cbab95d | 2010-10-11 03:43:58 +0200 | [diff] [blame] | 525 | unsigned char MiscOutReg; |
Francisco Jerez | 4a9f822 | 2010-07-20 16:48:08 +0200 | [diff] [blame] | 526 | uint8_t CRTC[0xa0]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 527 | uint8_t CR58[0x10]; |
| 528 | uint8_t Sequencer[5]; |
| 529 | uint8_t Graphics[9]; |
| 530 | uint8_t Attribute[21]; |
Francisco Jerez | cbab95d | 2010-10-11 03:43:58 +0200 | [diff] [blame] | 531 | unsigned char DAC[768]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 532 | |
| 533 | /* PCRTC regs */ |
| 534 | uint32_t fb_start; |
| 535 | uint32_t crtc_cfg; |
| 536 | uint32_t cursor_cfg; |
| 537 | uint32_t gpio_ext; |
| 538 | uint32_t crtc_830; |
| 539 | uint32_t crtc_834; |
| 540 | uint32_t crtc_850; |
| 541 | uint32_t crtc_eng_ctrl; |
| 542 | |
| 543 | /* PRAMDAC regs */ |
| 544 | uint32_t nv10_cursync; |
| 545 | struct nouveau_pll_vals pllvals; |
| 546 | uint32_t ramdac_gen_ctrl; |
| 547 | uint32_t ramdac_630; |
| 548 | uint32_t ramdac_634; |
| 549 | uint32_t tv_setup; |
| 550 | uint32_t tv_vtotal; |
| 551 | uint32_t tv_vskew; |
| 552 | uint32_t tv_vsync_delay; |
| 553 | uint32_t tv_htotal; |
| 554 | uint32_t tv_hskew; |
| 555 | uint32_t tv_hsync_delay; |
| 556 | uint32_t tv_hsync_delay2; |
| 557 | uint32_t fp_horiz_regs[7]; |
| 558 | uint32_t fp_vert_regs[7]; |
| 559 | uint32_t dither; |
| 560 | uint32_t fp_control; |
| 561 | uint32_t dither_regs[6]; |
| 562 | uint32_t fp_debug_0; |
| 563 | uint32_t fp_debug_1; |
| 564 | uint32_t fp_debug_2; |
| 565 | uint32_t fp_margin_color; |
| 566 | uint32_t ramdac_8c0; |
| 567 | uint32_t ramdac_a20; |
| 568 | uint32_t ramdac_a24; |
| 569 | uint32_t ramdac_a34; |
| 570 | uint32_t ctv_regs[38]; |
| 571 | }; |
| 572 | |
| 573 | struct nv04_output_reg { |
| 574 | uint32_t output; |
| 575 | int head; |
| 576 | }; |
| 577 | |
| 578 | struct nv04_mode_state { |
Francisco Jerez | cbab95d | 2010-10-11 03:43:58 +0200 | [diff] [blame] | 579 | struct nv04_crtc_reg crtc_reg[2]; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 580 | uint32_t pllsel; |
| 581 | uint32_t sel_clk; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 582 | }; |
| 583 | |
| 584 | enum nouveau_card_type { |
| 585 | NV_04 = 0x00, |
| 586 | NV_10 = 0x10, |
| 587 | NV_20 = 0x20, |
| 588 | NV_30 = 0x30, |
| 589 | NV_40 = 0x40, |
| 590 | NV_50 = 0x50, |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 591 | NV_C0 = 0xc0, |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 592 | }; |
| 593 | |
| 594 | struct drm_nouveau_private { |
| 595 | struct drm_device *dev; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 596 | |
| 597 | /* the card type, takes NV_* as values */ |
| 598 | enum nouveau_card_type card_type; |
| 599 | /* exact chipset, derived from NV_PMC_BOOT_0 */ |
| 600 | int chipset; |
| 601 | int flags; |
| 602 | |
| 603 | void __iomem *mmio; |
Ben Skeggs | 5125bfd | 2010-09-01 15:24:33 +1000 | [diff] [blame] | 604 | |
Ben Skeggs | e05d7ea | 2010-09-01 15:24:38 +1000 | [diff] [blame] | 605 | spinlock_t ramin_lock; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 606 | void __iomem *ramin; |
Ben Skeggs | 5125bfd | 2010-09-01 15:24:33 +1000 | [diff] [blame] | 607 | u32 ramin_size; |
| 608 | u32 ramin_base; |
| 609 | bool ramin_available; |
Ben Skeggs | e05d7ea | 2010-09-01 15:24:38 +1000 | [diff] [blame] | 610 | struct drm_mm ramin_heap; |
| 611 | struct list_head gpuobj_list; |
Ben Skeggs | b8c157d | 2010-10-20 10:39:35 +1000 | [diff] [blame] | 612 | struct list_head classes; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 613 | |
Ben Skeggs | ac8fb97 | 2010-01-15 09:24:20 +1000 | [diff] [blame] | 614 | struct nouveau_bo *vga_ram; |
| 615 | |
Ben Skeggs | 35fa2f2 | 2010-10-21 14:07:03 +1000 | [diff] [blame] | 616 | /* interrupt handling */ |
Ben Skeggs | 8f8a544 | 2010-11-03 09:57:28 +1000 | [diff] [blame] | 617 | void (*irq_handler[32])(struct drm_device *); |
Ben Skeggs | 35fa2f2 | 2010-10-21 14:07:03 +1000 | [diff] [blame] | 618 | bool msi_enabled; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 619 | struct workqueue_struct *wq; |
| 620 | struct work_struct irq_work; |
Ben Skeggs | a5acac6 | 2010-03-30 15:14:41 +1000 | [diff] [blame] | 621 | struct work_struct hpd_work; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 622 | |
Andy Lutomirski | ab83833 | 2010-11-16 18:40:52 -0500 | [diff] [blame] | 623 | struct { |
| 624 | spinlock_t lock; |
| 625 | uint32_t hpd0_bits; |
| 626 | uint32_t hpd1_bits; |
| 627 | } hpd_state; |
| 628 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 629 | struct list_head vbl_waiting; |
| 630 | |
| 631 | struct { |
Dave Airlie | ba4420c | 2010-03-09 10:56:52 +1000 | [diff] [blame] | 632 | struct drm_global_reference mem_global_ref; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 633 | struct ttm_bo_global_ref bo_global_ref; |
| 634 | struct ttm_bo_device bdev; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 635 | atomic_t validate_sequence; |
| 636 | } ttm; |
| 637 | |
Francisco Jerez | 0c6c1c2 | 2010-09-22 00:58:54 +0200 | [diff] [blame] | 638 | struct { |
| 639 | spinlock_t lock; |
| 640 | struct drm_mm heap; |
| 641 | struct nouveau_bo *bo; |
| 642 | } fence; |
| 643 | |
Ben Skeggs | cff5c13 | 2010-10-06 16:16:59 +1000 | [diff] [blame] | 644 | struct { |
| 645 | spinlock_t lock; |
| 646 | struct nouveau_channel *ptr[NOUVEAU_MAX_CHANNEL_NR]; |
| 647 | } channels; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 648 | |
| 649 | struct nouveau_engine engine; |
| 650 | struct nouveau_channel *channel; |
| 651 | |
Maarten Maathuis | ff9e527 | 2010-02-01 20:58:27 +0100 | [diff] [blame] | 652 | /* For PFIFO and PGRAPH. */ |
| 653 | spinlock_t context_switch_lock; |
| 654 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 655 | /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */ |
Ben Skeggs | e05c5a3 | 2010-09-01 15:24:35 +1000 | [diff] [blame] | 656 | struct nouveau_ramht *ramht; |
| 657 | struct nouveau_gpuobj *ramfc; |
| 658 | struct nouveau_gpuobj *ramro; |
| 659 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 660 | uint32_t ramin_rsvd_vram; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 661 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 662 | struct { |
| 663 | enum { |
| 664 | NOUVEAU_GART_NONE = 0, |
| 665 | NOUVEAU_GART_AGP, |
| 666 | NOUVEAU_GART_SGDMA |
| 667 | } type; |
| 668 | uint64_t aper_base; |
| 669 | uint64_t aper_size; |
| 670 | uint64_t aper_free; |
| 671 | |
| 672 | struct nouveau_gpuobj *sg_ctxdma; |
| 673 | struct page *sg_dummy_page; |
| 674 | dma_addr_t sg_dummy_bus; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 675 | } gart_info; |
| 676 | |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 677 | /* nv10-nv40 tiling regions */ |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 678 | struct { |
| 679 | struct nouveau_tile_reg reg[NOUVEAU_MAX_TILE_NR]; |
| 680 | spinlock_t lock; |
| 681 | } tile; |
Francisco Jerez | a0af9ad | 2009-12-11 16:51:09 +0100 | [diff] [blame] | 682 | |
Ben Skeggs | a76fb4e | 2010-03-18 09:45:20 +1000 | [diff] [blame] | 683 | /* VRAM/fb configuration */ |
| 684 | uint64_t vram_size; |
| 685 | uint64_t vram_sys_base; |
Ben Skeggs | 6c3d7ef | 2010-08-12 12:37:28 +1000 | [diff] [blame] | 686 | u32 vram_rblock_size; |
Ben Skeggs | a76fb4e | 2010-03-18 09:45:20 +1000 | [diff] [blame] | 687 | |
| 688 | uint64_t fb_phys; |
| 689 | uint64_t fb_available_size; |
| 690 | uint64_t fb_mappable_pages; |
| 691 | uint64_t fb_aper_free; |
| 692 | int fb_mtrr; |
| 693 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 694 | /* G8x/G9x virtual address space */ |
| 695 | uint64_t vm_gart_base; |
| 696 | uint64_t vm_gart_size; |
| 697 | uint64_t vm_vram_base; |
| 698 | uint64_t vm_vram_size; |
| 699 | uint64_t vm_end; |
| 700 | struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR]; |
| 701 | int vm_vram_pt_nr; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 702 | |
Ben Skeggs | 04a39c5 | 2010-02-24 10:03:05 +1000 | [diff] [blame] | 703 | struct nvbios vbios; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 704 | |
| 705 | struct nv04_mode_state mode_reg; |
| 706 | struct nv04_mode_state saved_reg; |
| 707 | uint32_t saved_vga_font[4][16384]; |
| 708 | uint32_t crtc_owner; |
| 709 | uint32_t dac_users[4]; |
| 710 | |
| 711 | struct nouveau_suspend_resume { |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 712 | uint32_t *ramin_copy; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 713 | } susres; |
| 714 | |
| 715 | struct backlight_device *backlight; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 716 | |
| 717 | struct nouveau_channel *evo; |
Ben Skeggs | 1e96268 | 2010-10-19 14:18:06 +1000 | [diff] [blame] | 718 | u32 evo_alloc; |
Ben Skeggs | 87c0e0e | 2010-07-06 08:54:34 +1000 | [diff] [blame] | 719 | struct { |
| 720 | struct dcb_entry *dcb; |
| 721 | u16 script; |
| 722 | u32 pclk; |
| 723 | } evo_irq; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 724 | |
| 725 | struct { |
| 726 | struct dentry *channel_root; |
| 727 | } debugfs; |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 728 | |
Dave Airlie | 8be48d9 | 2010-03-30 05:34:14 +0000 | [diff] [blame] | 729 | struct nouveau_fbdev *nfbdev; |
Marcin Slusarz | 06415c5 | 2010-05-16 17:29:56 +0200 | [diff] [blame] | 730 | struct apertures_struct *apertures; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 731 | }; |
| 732 | |
| 733 | static inline struct drm_nouveau_private * |
Francisco Jerez | 2730723 | 2010-09-21 18:57:11 +0200 | [diff] [blame] | 734 | nouveau_private(struct drm_device *dev) |
| 735 | { |
| 736 | return dev->dev_private; |
| 737 | } |
| 738 | |
| 739 | static inline struct drm_nouveau_private * |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 740 | nouveau_bdev(struct ttm_bo_device *bd) |
| 741 | { |
| 742 | return container_of(bd, struct drm_nouveau_private, ttm.bdev); |
| 743 | } |
| 744 | |
| 745 | static inline int |
| 746 | nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) |
| 747 | { |
| 748 | struct nouveau_bo *prev; |
| 749 | |
| 750 | if (!pnvbo) |
| 751 | return -EINVAL; |
| 752 | prev = *pnvbo; |
| 753 | |
| 754 | *pnvbo = ref ? nouveau_bo(ttm_bo_reference(&ref->bo)) : NULL; |
| 755 | if (prev) { |
| 756 | struct ttm_buffer_object *bo = &prev->bo; |
| 757 | |
| 758 | ttm_bo_unref(&bo); |
| 759 | } |
| 760 | |
| 761 | return 0; |
| 762 | } |
| 763 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 764 | /* nouveau_drv.c */ |
Francisco Jerez | de5899b | 2010-09-08 02:28:23 +0200 | [diff] [blame] | 765 | extern int nouveau_agpmode; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 766 | extern int nouveau_duallink; |
| 767 | extern int nouveau_uscript_lvds; |
| 768 | extern int nouveau_uscript_tmds; |
| 769 | extern int nouveau_vram_pushbuf; |
| 770 | extern int nouveau_vram_notify; |
| 771 | extern int nouveau_fbpercrtc; |
Ben Skeggs | f405350 | 2010-03-15 09:43:51 +1000 | [diff] [blame] | 772 | extern int nouveau_tv_disable; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 773 | extern char *nouveau_tv_norm; |
| 774 | extern int nouveau_reg_debug; |
| 775 | extern char *nouveau_vbios; |
Ben Skeggs | a147089 | 2010-01-18 11:42:37 +1000 | [diff] [blame] | 776 | extern int nouveau_ignorelid; |
Marcin Kościelnicki | a32ed69 | 2010-01-26 14:00:42 +0000 | [diff] [blame] | 777 | extern int nouveau_nofbaccel; |
| 778 | extern int nouveau_noaccel; |
Marcin Kościelnicki | 0cba1b7 | 2010-09-29 11:15:01 +0000 | [diff] [blame] | 779 | extern int nouveau_force_post; |
Ben Skeggs | da647d5 | 2010-03-04 12:00:39 +1000 | [diff] [blame] | 780 | extern int nouveau_override_conntype; |
Ben Skeggs | 6f87698 | 2010-09-16 16:47:14 +1000 | [diff] [blame] | 781 | extern char *nouveau_perflvl; |
| 782 | extern int nouveau_perflvl_wr; |
Ben Skeggs | 35fa2f2 | 2010-10-21 14:07:03 +1000 | [diff] [blame] | 783 | extern int nouveau_msi; |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 784 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 785 | extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state); |
| 786 | extern int nouveau_pci_resume(struct pci_dev *pdev); |
| 787 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 788 | /* nouveau_state.c */ |
| 789 | extern void nouveau_preclose(struct drm_device *dev, struct drm_file *); |
| 790 | extern int nouveau_load(struct drm_device *, unsigned long flags); |
| 791 | extern int nouveau_firstopen(struct drm_device *); |
| 792 | extern void nouveau_lastclose(struct drm_device *); |
| 793 | extern int nouveau_unload(struct drm_device *); |
| 794 | extern int nouveau_ioctl_getparam(struct drm_device *, void *data, |
| 795 | struct drm_file *); |
| 796 | extern int nouveau_ioctl_setparam(struct drm_device *, void *data, |
| 797 | struct drm_file *); |
| 798 | extern bool nouveau_wait_until(struct drm_device *, uint64_t timeout, |
| 799 | uint32_t reg, uint32_t mask, uint32_t val); |
| 800 | extern bool nouveau_wait_for_idle(struct drm_device *); |
| 801 | extern int nouveau_card_init(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 802 | |
| 803 | /* nouveau_mem.c */ |
Ben Skeggs | fbd2895 | 2010-09-01 15:24:34 +1000 | [diff] [blame] | 804 | extern int nouveau_mem_vram_init(struct drm_device *); |
| 805 | extern void nouveau_mem_vram_fini(struct drm_device *); |
| 806 | extern int nouveau_mem_gart_init(struct drm_device *); |
| 807 | extern void nouveau_mem_gart_fini(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 808 | extern int nouveau_mem_init_agp(struct drm_device *); |
Francisco Jerez | e04d8e8 | 2010-07-23 20:29:13 +0200 | [diff] [blame] | 809 | extern int nouveau_mem_reset_agp(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 810 | extern void nouveau_mem_close(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 811 | extern struct nouveau_tile_reg *nv10_mem_set_tiling( |
| 812 | struct drm_device *dev, uint32_t addr, uint32_t size, |
| 813 | uint32_t pitch, uint32_t flags); |
| 814 | extern void nv10_mem_put_tile_region(struct drm_device *dev, |
| 815 | struct nouveau_tile_reg *tile, |
| 816 | struct nouveau_fence *fence); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 817 | extern int nv50_mem_vm_bind_linear(struct drm_device *, uint64_t virt, |
| 818 | uint32_t size, uint32_t flags, |
| 819 | uint64_t phys); |
| 820 | extern void nv50_mem_vm_unbind(struct drm_device *, uint64_t virt, |
| 821 | uint32_t size); |
| 822 | |
| 823 | /* nouveau_notifier.c */ |
| 824 | extern int nouveau_notifier_init_channel(struct nouveau_channel *); |
| 825 | extern void nouveau_notifier_takedown_channel(struct nouveau_channel *); |
| 826 | extern int nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle, |
| 827 | int cout, uint32_t *offset); |
| 828 | extern int nouveau_notifier_offset(struct nouveau_gpuobj *, uint32_t *); |
| 829 | extern int nouveau_ioctl_notifier_alloc(struct drm_device *, void *data, |
| 830 | struct drm_file *); |
| 831 | extern int nouveau_ioctl_notifier_free(struct drm_device *, void *data, |
| 832 | struct drm_file *); |
| 833 | |
| 834 | /* nouveau_channel.c */ |
| 835 | extern struct drm_ioctl_desc nouveau_ioctls[]; |
| 836 | extern int nouveau_max_ioctl; |
| 837 | extern void nouveau_channel_cleanup(struct drm_device *, struct drm_file *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 838 | extern int nouveau_channel_alloc(struct drm_device *dev, |
| 839 | struct nouveau_channel **chan, |
| 840 | struct drm_file *file_priv, |
| 841 | uint32_t fb_ctxdma, uint32_t tt_ctxdma); |
Ben Skeggs | cff5c13 | 2010-10-06 16:16:59 +1000 | [diff] [blame] | 842 | extern struct nouveau_channel * |
Francisco Jerez | feeb0ae | 2010-10-18 02:58:04 +0200 | [diff] [blame] | 843 | nouveau_channel_get_unlocked(struct nouveau_channel *); |
| 844 | extern struct nouveau_channel * |
Ben Skeggs | cff5c13 | 2010-10-06 16:16:59 +1000 | [diff] [blame] | 845 | nouveau_channel_get(struct drm_device *, struct drm_file *, int id); |
Francisco Jerez | feeb0ae | 2010-10-18 02:58:04 +0200 | [diff] [blame] | 846 | extern void nouveau_channel_put_unlocked(struct nouveau_channel **); |
Ben Skeggs | cff5c13 | 2010-10-06 16:16:59 +1000 | [diff] [blame] | 847 | extern void nouveau_channel_put(struct nouveau_channel **); |
Francisco Jerez | f091a3d | 2010-10-18 03:55:48 +0200 | [diff] [blame] | 848 | extern void nouveau_channel_ref(struct nouveau_channel *chan, |
| 849 | struct nouveau_channel **pchan); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 850 | |
| 851 | /* nouveau_object.c */ |
Ben Skeggs | b8c157d | 2010-10-20 10:39:35 +1000 | [diff] [blame] | 852 | #define NVOBJ_CLASS(d,c,e) do { \ |
| 853 | int ret = nouveau_gpuobj_class_new((d), (c), NVOBJ_ENGINE_##e); \ |
| 854 | if (ret) \ |
| 855 | return ret; \ |
| 856 | } while(0) |
| 857 | |
| 858 | #define NVOBJ_MTHD(d,c,m,e) do { \ |
| 859 | int ret = nouveau_gpuobj_mthd_new((d), (c), (m), (e)); \ |
| 860 | if (ret) \ |
| 861 | return ret; \ |
| 862 | } while(0) |
| 863 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 864 | extern int nouveau_gpuobj_early_init(struct drm_device *); |
| 865 | extern int nouveau_gpuobj_init(struct drm_device *); |
| 866 | extern void nouveau_gpuobj_takedown(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 867 | extern int nouveau_gpuobj_suspend(struct drm_device *dev); |
| 868 | extern void nouveau_gpuobj_suspend_cleanup(struct drm_device *dev); |
| 869 | extern void nouveau_gpuobj_resume(struct drm_device *dev); |
Ben Skeggs | b8c157d | 2010-10-20 10:39:35 +1000 | [diff] [blame] | 870 | extern int nouveau_gpuobj_class_new(struct drm_device *, u32 class, u32 eng); |
| 871 | extern int nouveau_gpuobj_mthd_new(struct drm_device *, u32 class, u32 mthd, |
| 872 | int (*exec)(struct nouveau_channel *, |
| 873 | u32 class, u32 mthd, u32 data)); |
| 874 | extern int nouveau_gpuobj_mthd_call(struct nouveau_channel *, u32, u32, u32); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 875 | extern int nouveau_gpuobj_channel_init(struct nouveau_channel *, |
| 876 | uint32_t vram_h, uint32_t tt_h); |
| 877 | extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *); |
| 878 | extern int nouveau_gpuobj_new(struct drm_device *, struct nouveau_channel *, |
| 879 | uint32_t size, int align, uint32_t flags, |
| 880 | struct nouveau_gpuobj **); |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 881 | extern void nouveau_gpuobj_ref(struct nouveau_gpuobj *, |
| 882 | struct nouveau_gpuobj **); |
Ben Skeggs | 43efc9c | 2010-09-01 15:24:32 +1000 | [diff] [blame] | 883 | extern int nouveau_gpuobj_new_fake(struct drm_device *, u32 pinst, u64 vinst, |
| 884 | u32 size, u32 flags, |
Ben Skeggs | a8eaebc | 2010-09-01 15:24:31 +1000 | [diff] [blame] | 885 | struct nouveau_gpuobj **); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 886 | extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class, |
| 887 | uint64_t offset, uint64_t size, int access, |
| 888 | int target, struct nouveau_gpuobj **); |
| 889 | extern int nouveau_gpuobj_gart_dma_new(struct nouveau_channel *, |
| 890 | uint64_t offset, uint64_t size, |
| 891 | int access, struct nouveau_gpuobj **, |
| 892 | uint32_t *o_ret); |
| 893 | extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, int class, |
| 894 | struct nouveau_gpuobj **); |
| 895 | extern int nouveau_ioctl_grobj_alloc(struct drm_device *, void *data, |
| 896 | struct drm_file *); |
| 897 | extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data, |
| 898 | struct drm_file *); |
| 899 | |
| 900 | /* nouveau_irq.c */ |
Ben Skeggs | 35fa2f2 | 2010-10-21 14:07:03 +1000 | [diff] [blame] | 901 | extern int nouveau_irq_init(struct drm_device *); |
| 902 | extern void nouveau_irq_fini(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 903 | extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS); |
Ben Skeggs | 8f8a544 | 2010-11-03 09:57:28 +1000 | [diff] [blame] | 904 | extern void nouveau_irq_register(struct drm_device *, int status_bit, |
| 905 | void (*)(struct drm_device *)); |
| 906 | extern void nouveau_irq_unregister(struct drm_device *, int status_bit); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 907 | extern void nouveau_irq_preinstall(struct drm_device *); |
| 908 | extern int nouveau_irq_postinstall(struct drm_device *); |
| 909 | extern void nouveau_irq_uninstall(struct drm_device *); |
| 910 | |
| 911 | /* nouveau_sgdma.c */ |
| 912 | extern int nouveau_sgdma_init(struct drm_device *); |
| 913 | extern void nouveau_sgdma_takedown(struct drm_device *); |
| 914 | extern int nouveau_sgdma_get_page(struct drm_device *, uint32_t offset, |
| 915 | uint32_t *page); |
| 916 | extern struct ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *); |
| 917 | |
| 918 | /* nouveau_debugfs.c */ |
| 919 | #if defined(CONFIG_DRM_NOUVEAU_DEBUG) |
| 920 | extern int nouveau_debugfs_init(struct drm_minor *); |
| 921 | extern void nouveau_debugfs_takedown(struct drm_minor *); |
| 922 | extern int nouveau_debugfs_channel_init(struct nouveau_channel *); |
| 923 | extern void nouveau_debugfs_channel_fini(struct nouveau_channel *); |
| 924 | #else |
| 925 | static inline int |
| 926 | nouveau_debugfs_init(struct drm_minor *minor) |
| 927 | { |
| 928 | return 0; |
| 929 | } |
| 930 | |
| 931 | static inline void nouveau_debugfs_takedown(struct drm_minor *minor) |
| 932 | { |
| 933 | } |
| 934 | |
| 935 | static inline int |
| 936 | nouveau_debugfs_channel_init(struct nouveau_channel *chan) |
| 937 | { |
| 938 | return 0; |
| 939 | } |
| 940 | |
| 941 | static inline void |
| 942 | nouveau_debugfs_channel_fini(struct nouveau_channel *chan) |
| 943 | { |
| 944 | } |
| 945 | #endif |
| 946 | |
| 947 | /* nouveau_dma.c */ |
Ben Skeggs | 75c99da | 2010-01-08 10:57:39 +1000 | [diff] [blame] | 948 | extern void nouveau_dma_pre_init(struct nouveau_channel *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 949 | extern int nouveau_dma_init(struct nouveau_channel *); |
Ben Skeggs | 9a391ad | 2010-02-11 16:37:26 +1000 | [diff] [blame] | 950 | extern int nouveau_dma_wait(struct nouveau_channel *, int slots, int size); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 951 | |
| 952 | /* nouveau_acpi.c */ |
Dave Airlie | afeb3e1 | 2010-04-07 13:55:09 +1000 | [diff] [blame] | 953 | #define ROM_BIOS_PAGE 4096 |
Dave Airlie | 2f41a7f | 2010-03-03 09:20:25 +1000 | [diff] [blame] | 954 | #if defined(CONFIG_ACPI) |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 955 | void nouveau_register_dsm_handler(void); |
| 956 | void nouveau_unregister_dsm_handler(void); |
Dave Airlie | afeb3e1 | 2010-04-07 13:55:09 +1000 | [diff] [blame] | 957 | int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len); |
| 958 | bool nouveau_acpi_rom_supported(struct pci_dev *pdev); |
Ben Skeggs | a6ed76d | 2010-07-12 15:33:07 +1000 | [diff] [blame] | 959 | int nouveau_acpi_edid(struct drm_device *, struct drm_connector *); |
Dave Airlie | 8edb381 | 2010-03-01 21:50:01 +1100 | [diff] [blame] | 960 | #else |
| 961 | static inline void nouveau_register_dsm_handler(void) {} |
| 962 | static inline void nouveau_unregister_dsm_handler(void) {} |
Dave Airlie | afeb3e1 | 2010-04-07 13:55:09 +1000 | [diff] [blame] | 963 | static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; } |
| 964 | static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; } |
Ben Skeggs | 5620ba4 | 2010-07-23 10:00:12 +1000 | [diff] [blame] | 965 | static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; } |
Dave Airlie | 8edb381 | 2010-03-01 21:50:01 +1100 | [diff] [blame] | 966 | #endif |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 967 | |
| 968 | /* nouveau_backlight.c */ |
| 969 | #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT |
| 970 | extern int nouveau_backlight_init(struct drm_device *); |
| 971 | extern void nouveau_backlight_exit(struct drm_device *); |
| 972 | #else |
| 973 | static inline int nouveau_backlight_init(struct drm_device *dev) |
| 974 | { |
| 975 | return 0; |
| 976 | } |
| 977 | |
| 978 | static inline void nouveau_backlight_exit(struct drm_device *dev) { } |
| 979 | #endif |
| 980 | |
| 981 | /* nouveau_bios.c */ |
| 982 | extern int nouveau_bios_init(struct drm_device *); |
| 983 | extern void nouveau_bios_takedown(struct drm_device *dev); |
| 984 | extern int nouveau_run_vbios_init(struct drm_device *); |
| 985 | extern void nouveau_bios_run_init_table(struct drm_device *, uint16_t table, |
| 986 | struct dcb_entry *); |
| 987 | extern struct dcb_gpio_entry *nouveau_bios_gpio_entry(struct drm_device *, |
| 988 | enum dcb_gpio_tag); |
| 989 | extern struct dcb_connector_table_entry * |
| 990 | nouveau_bios_connector_entry(struct drm_device *, int index); |
Ben Skeggs | 855a95e | 2010-09-16 15:25:25 +1000 | [diff] [blame] | 991 | extern u32 get_pll_register(struct drm_device *, enum pll_types); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 992 | extern int get_pll_limits(struct drm_device *, uint32_t limit_match, |
| 993 | struct pll_lims *); |
| 994 | extern int nouveau_bios_run_display_table(struct drm_device *, |
| 995 | struct dcb_entry *, |
| 996 | uint32_t script, int pxclk); |
| 997 | extern void *nouveau_bios_dp_table(struct drm_device *, struct dcb_entry *, |
| 998 | int *length); |
| 999 | extern bool nouveau_bios_fp_mode(struct drm_device *, struct drm_display_mode *); |
| 1000 | extern uint8_t *nouveau_bios_embedded_edid(struct drm_device *); |
| 1001 | extern int nouveau_bios_parse_lvds_table(struct drm_device *, int pxclk, |
| 1002 | bool *dl, bool *if_is_24bit); |
| 1003 | extern int run_tmds_table(struct drm_device *, struct dcb_entry *, |
| 1004 | int head, int pxclk); |
| 1005 | extern int call_lvds_script(struct drm_device *, struct dcb_entry *, int head, |
| 1006 | enum LVDS_script, int pxclk); |
| 1007 | |
| 1008 | /* nouveau_ttm.c */ |
| 1009 | int nouveau_ttm_global_init(struct drm_nouveau_private *); |
| 1010 | void nouveau_ttm_global_release(struct drm_nouveau_private *); |
| 1011 | int nouveau_ttm_mmap(struct file *, struct vm_area_struct *); |
| 1012 | |
| 1013 | /* nouveau_dp.c */ |
| 1014 | int nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr, |
| 1015 | uint8_t *data, int data_nr); |
| 1016 | bool nouveau_dp_detect(struct drm_encoder *); |
| 1017 | bool nouveau_dp_link_train(struct drm_encoder *); |
| 1018 | |
| 1019 | /* nv04_fb.c */ |
| 1020 | extern int nv04_fb_init(struct drm_device *); |
| 1021 | extern void nv04_fb_takedown(struct drm_device *); |
| 1022 | |
| 1023 | /* nv10_fb.c */ |
| 1024 | extern int nv10_fb_init(struct drm_device *); |
| 1025 | extern void nv10_fb_takedown(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1026 | extern void nv10_fb_init_tile_region(struct drm_device *dev, int i, |
| 1027 | uint32_t addr, uint32_t size, |
| 1028 | uint32_t pitch, uint32_t flags); |
| 1029 | extern void nv10_fb_set_tile_region(struct drm_device *dev, int i); |
| 1030 | extern void nv10_fb_free_tile_region(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1031 | |
Francisco Jerez | 8bded18 | 2010-07-21 21:08:11 +0200 | [diff] [blame] | 1032 | /* nv30_fb.c */ |
| 1033 | extern int nv30_fb_init(struct drm_device *); |
| 1034 | extern void nv30_fb_takedown(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1035 | extern void nv30_fb_init_tile_region(struct drm_device *dev, int i, |
| 1036 | uint32_t addr, uint32_t size, |
| 1037 | uint32_t pitch, uint32_t flags); |
| 1038 | extern void nv30_fb_free_tile_region(struct drm_device *dev, int i); |
Francisco Jerez | 8bded18 | 2010-07-21 21:08:11 +0200 | [diff] [blame] | 1039 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1040 | /* nv40_fb.c */ |
| 1041 | extern int nv40_fb_init(struct drm_device *); |
| 1042 | extern void nv40_fb_takedown(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1043 | extern void nv40_fb_set_tile_region(struct drm_device *dev, int i); |
| 1044 | |
Marcin Kościelnicki | 304424e | 2010-03-01 00:18:39 +0000 | [diff] [blame] | 1045 | /* nv50_fb.c */ |
| 1046 | extern int nv50_fb_init(struct drm_device *); |
| 1047 | extern void nv50_fb_takedown(struct drm_device *); |
Ben Skeggs | d96773e | 2010-09-03 15:46:58 +1000 | [diff] [blame] | 1048 | extern void nv50_fb_vm_trap(struct drm_device *, int display, const char *); |
Marcin Kościelnicki | 304424e | 2010-03-01 00:18:39 +0000 | [diff] [blame] | 1049 | |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1050 | /* nvc0_fb.c */ |
| 1051 | extern int nvc0_fb_init(struct drm_device *); |
| 1052 | extern void nvc0_fb_takedown(struct drm_device *); |
| 1053 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1054 | /* nv04_fifo.c */ |
| 1055 | extern int nv04_fifo_init(struct drm_device *); |
Ben Skeggs | 5178d40 | 2010-11-03 10:56:05 +1000 | [diff] [blame^] | 1056 | extern void nv04_fifo_fini(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1057 | extern void nv04_fifo_disable(struct drm_device *); |
| 1058 | extern void nv04_fifo_enable(struct drm_device *); |
| 1059 | extern bool nv04_fifo_reassign(struct drm_device *, bool); |
Francisco Jerez | 588d7d1 | 2009-12-13 20:07:42 +0100 | [diff] [blame] | 1060 | extern bool nv04_fifo_cache_pull(struct drm_device *, bool); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1061 | extern int nv04_fifo_channel_id(struct drm_device *); |
| 1062 | extern int nv04_fifo_create_context(struct nouveau_channel *); |
| 1063 | extern void nv04_fifo_destroy_context(struct nouveau_channel *); |
| 1064 | extern int nv04_fifo_load_context(struct nouveau_channel *); |
| 1065 | extern int nv04_fifo_unload_context(struct drm_device *); |
Ben Skeggs | 5178d40 | 2010-11-03 10:56:05 +1000 | [diff] [blame^] | 1066 | extern void nv04_fifo_isr(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1067 | |
| 1068 | /* nv10_fifo.c */ |
| 1069 | extern int nv10_fifo_init(struct drm_device *); |
| 1070 | extern int nv10_fifo_channel_id(struct drm_device *); |
| 1071 | extern int nv10_fifo_create_context(struct nouveau_channel *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1072 | extern int nv10_fifo_load_context(struct nouveau_channel *); |
| 1073 | extern int nv10_fifo_unload_context(struct drm_device *); |
| 1074 | |
| 1075 | /* nv40_fifo.c */ |
| 1076 | extern int nv40_fifo_init(struct drm_device *); |
| 1077 | extern int nv40_fifo_create_context(struct nouveau_channel *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1078 | extern int nv40_fifo_load_context(struct nouveau_channel *); |
| 1079 | extern int nv40_fifo_unload_context(struct drm_device *); |
| 1080 | |
| 1081 | /* nv50_fifo.c */ |
| 1082 | extern int nv50_fifo_init(struct drm_device *); |
| 1083 | extern void nv50_fifo_takedown(struct drm_device *); |
| 1084 | extern int nv50_fifo_channel_id(struct drm_device *); |
| 1085 | extern int nv50_fifo_create_context(struct nouveau_channel *); |
| 1086 | extern void nv50_fifo_destroy_context(struct nouveau_channel *); |
| 1087 | extern int nv50_fifo_load_context(struct nouveau_channel *); |
| 1088 | extern int nv50_fifo_unload_context(struct drm_device *); |
Ben Skeggs | 56ac747 | 2010-10-22 10:26:24 +1000 | [diff] [blame] | 1089 | extern void nv50_fifo_tlb_flush(struct drm_device *dev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1090 | |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1091 | /* nvc0_fifo.c */ |
| 1092 | extern int nvc0_fifo_init(struct drm_device *); |
| 1093 | extern void nvc0_fifo_takedown(struct drm_device *); |
| 1094 | extern void nvc0_fifo_disable(struct drm_device *); |
| 1095 | extern void nvc0_fifo_enable(struct drm_device *); |
| 1096 | extern bool nvc0_fifo_reassign(struct drm_device *, bool); |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1097 | extern bool nvc0_fifo_cache_pull(struct drm_device *, bool); |
| 1098 | extern int nvc0_fifo_channel_id(struct drm_device *); |
| 1099 | extern int nvc0_fifo_create_context(struct nouveau_channel *); |
| 1100 | extern void nvc0_fifo_destroy_context(struct nouveau_channel *); |
| 1101 | extern int nvc0_fifo_load_context(struct nouveau_channel *); |
| 1102 | extern int nvc0_fifo_unload_context(struct drm_device *); |
| 1103 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1104 | /* nv04_graph.c */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1105 | extern int nv04_graph_init(struct drm_device *); |
| 1106 | extern void nv04_graph_takedown(struct drm_device *); |
| 1107 | extern void nv04_graph_fifo_access(struct drm_device *, bool); |
| 1108 | extern struct nouveau_channel *nv04_graph_channel(struct drm_device *); |
| 1109 | extern int nv04_graph_create_context(struct nouveau_channel *); |
| 1110 | extern void nv04_graph_destroy_context(struct nouveau_channel *); |
| 1111 | extern int nv04_graph_load_context(struct nouveau_channel *); |
| 1112 | extern int nv04_graph_unload_context(struct drm_device *); |
| 1113 | extern void nv04_graph_context_switch(struct drm_device *); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 1114 | extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan, |
| 1115 | u32 class, u32 mthd, u32 data); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1116 | |
| 1117 | /* nv10_graph.c */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1118 | extern int nv10_graph_init(struct drm_device *); |
| 1119 | extern void nv10_graph_takedown(struct drm_device *); |
| 1120 | extern struct nouveau_channel *nv10_graph_channel(struct drm_device *); |
| 1121 | extern int nv10_graph_create_context(struct nouveau_channel *); |
| 1122 | extern void nv10_graph_destroy_context(struct nouveau_channel *); |
| 1123 | extern int nv10_graph_load_context(struct nouveau_channel *); |
| 1124 | extern int nv10_graph_unload_context(struct drm_device *); |
| 1125 | extern void nv10_graph_context_switch(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1126 | extern void nv10_graph_set_tile_region(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1127 | |
| 1128 | /* nv20_graph.c */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1129 | extern int nv20_graph_create_context(struct nouveau_channel *); |
| 1130 | extern void nv20_graph_destroy_context(struct nouveau_channel *); |
| 1131 | extern int nv20_graph_load_context(struct nouveau_channel *); |
| 1132 | extern int nv20_graph_unload_context(struct drm_device *); |
| 1133 | extern int nv20_graph_init(struct drm_device *); |
| 1134 | extern void nv20_graph_takedown(struct drm_device *); |
| 1135 | extern int nv30_graph_init(struct drm_device *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1136 | extern void nv20_graph_set_tile_region(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1137 | |
| 1138 | /* nv40_graph.c */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1139 | extern int nv40_graph_init(struct drm_device *); |
| 1140 | extern void nv40_graph_takedown(struct drm_device *); |
| 1141 | extern struct nouveau_channel *nv40_graph_channel(struct drm_device *); |
| 1142 | extern int nv40_graph_create_context(struct nouveau_channel *); |
| 1143 | extern void nv40_graph_destroy_context(struct nouveau_channel *); |
| 1144 | extern int nv40_graph_load_context(struct nouveau_channel *); |
| 1145 | extern int nv40_graph_unload_context(struct drm_device *); |
Ben Skeggs | 054b93e | 2009-12-15 22:02:47 +1000 | [diff] [blame] | 1146 | extern void nv40_grctx_init(struct nouveau_grctx *); |
Francisco Jerez | a5cf68b | 2010-10-24 16:14:41 +0200 | [diff] [blame] | 1147 | extern void nv40_graph_set_tile_region(struct drm_device *dev, int i); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1148 | |
| 1149 | /* nv50_graph.c */ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1150 | extern int nv50_graph_init(struct drm_device *); |
| 1151 | extern void nv50_graph_takedown(struct drm_device *); |
| 1152 | extern void nv50_graph_fifo_access(struct drm_device *, bool); |
| 1153 | extern struct nouveau_channel *nv50_graph_channel(struct drm_device *); |
| 1154 | extern int nv50_graph_create_context(struct nouveau_channel *); |
| 1155 | extern void nv50_graph_destroy_context(struct nouveau_channel *); |
| 1156 | extern int nv50_graph_load_context(struct nouveau_channel *); |
| 1157 | extern int nv50_graph_unload_context(struct drm_device *); |
| 1158 | extern void nv50_graph_context_switch(struct drm_device *); |
Marcin Kościelnicki | d5f3c90 | 2010-02-25 00:54:02 +0000 | [diff] [blame] | 1159 | extern int nv50_grctx_init(struct nouveau_grctx *); |
Ben Skeggs | 56ac747 | 2010-10-22 10:26:24 +1000 | [diff] [blame] | 1160 | extern void nv50_graph_tlb_flush(struct drm_device *dev); |
| 1161 | extern void nv86_graph_tlb_flush(struct drm_device *dev); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1162 | |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1163 | /* nvc0_graph.c */ |
| 1164 | extern int nvc0_graph_init(struct drm_device *); |
| 1165 | extern void nvc0_graph_takedown(struct drm_device *); |
| 1166 | extern void nvc0_graph_fifo_access(struct drm_device *, bool); |
| 1167 | extern struct nouveau_channel *nvc0_graph_channel(struct drm_device *); |
| 1168 | extern int nvc0_graph_create_context(struct nouveau_channel *); |
| 1169 | extern void nvc0_graph_destroy_context(struct nouveau_channel *); |
| 1170 | extern int nvc0_graph_load_context(struct nouveau_channel *); |
| 1171 | extern int nvc0_graph_unload_context(struct drm_device *); |
| 1172 | |
Ben Skeggs | bd2e597 | 2010-10-19 20:06:01 +1000 | [diff] [blame] | 1173 | /* nv84_crypt.c */ |
| 1174 | extern int nv84_crypt_init(struct drm_device *dev); |
| 1175 | extern void nv84_crypt_fini(struct drm_device *dev); |
| 1176 | extern int nv84_crypt_create_context(struct nouveau_channel *); |
| 1177 | extern void nv84_crypt_destroy_context(struct nouveau_channel *); |
| 1178 | extern void nv84_crypt_tlb_flush(struct drm_device *dev); |
| 1179 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1180 | /* nv04_instmem.c */ |
| 1181 | extern int nv04_instmem_init(struct drm_device *); |
| 1182 | extern void nv04_instmem_takedown(struct drm_device *); |
| 1183 | extern int nv04_instmem_suspend(struct drm_device *); |
| 1184 | extern void nv04_instmem_resume(struct drm_device *); |
| 1185 | extern int nv04_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, |
Ben Skeggs | 9100468 | 2010-10-15 09:15:26 +1000 | [diff] [blame] | 1186 | u32 *size, u32 align); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1187 | extern void nv04_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); |
| 1188 | extern int nv04_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); |
| 1189 | extern int nv04_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *); |
Ben Skeggs | f56cb86 | 2010-07-08 11:29:10 +1000 | [diff] [blame] | 1190 | extern void nv04_instmem_flush(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1191 | |
| 1192 | /* nv50_instmem.c */ |
| 1193 | extern int nv50_instmem_init(struct drm_device *); |
| 1194 | extern void nv50_instmem_takedown(struct drm_device *); |
| 1195 | extern int nv50_instmem_suspend(struct drm_device *); |
| 1196 | extern void nv50_instmem_resume(struct drm_device *); |
| 1197 | extern int nv50_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, |
Ben Skeggs | 9100468 | 2010-10-15 09:15:26 +1000 | [diff] [blame] | 1198 | u32 *size, u32 align); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1199 | extern void nv50_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); |
| 1200 | extern int nv50_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); |
| 1201 | extern int nv50_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *); |
Ben Skeggs | f56cb86 | 2010-07-08 11:29:10 +1000 | [diff] [blame] | 1202 | extern void nv50_instmem_flush(struct drm_device *); |
Ben Skeggs | 734ee83 | 2010-07-15 11:02:54 +1000 | [diff] [blame] | 1203 | extern void nv84_instmem_flush(struct drm_device *); |
Ben Skeggs | 6318721 | 2010-07-08 11:39:18 +1000 | [diff] [blame] | 1204 | extern void nv50_vm_flush(struct drm_device *, int engine); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1205 | |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1206 | /* nvc0_instmem.c */ |
| 1207 | extern int nvc0_instmem_init(struct drm_device *); |
| 1208 | extern void nvc0_instmem_takedown(struct drm_device *); |
| 1209 | extern int nvc0_instmem_suspend(struct drm_device *); |
| 1210 | extern void nvc0_instmem_resume(struct drm_device *); |
| 1211 | extern int nvc0_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, |
Ben Skeggs | 9100468 | 2010-10-15 09:15:26 +1000 | [diff] [blame] | 1212 | u32 *size, u32 align); |
Ben Skeggs | 4b223ee | 2010-08-03 10:00:56 +1000 | [diff] [blame] | 1213 | extern void nvc0_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); |
| 1214 | extern int nvc0_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); |
| 1215 | extern int nvc0_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *); |
| 1216 | extern void nvc0_instmem_flush(struct drm_device *); |
| 1217 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1218 | /* nv04_mc.c */ |
| 1219 | extern int nv04_mc_init(struct drm_device *); |
| 1220 | extern void nv04_mc_takedown(struct drm_device *); |
| 1221 | |
| 1222 | /* nv40_mc.c */ |
| 1223 | extern int nv40_mc_init(struct drm_device *); |
| 1224 | extern void nv40_mc_takedown(struct drm_device *); |
| 1225 | |
| 1226 | /* nv50_mc.c */ |
| 1227 | extern int nv50_mc_init(struct drm_device *); |
| 1228 | extern void nv50_mc_takedown(struct drm_device *); |
| 1229 | |
| 1230 | /* nv04_timer.c */ |
| 1231 | extern int nv04_timer_init(struct drm_device *); |
| 1232 | extern uint64_t nv04_timer_read(struct drm_device *); |
| 1233 | extern void nv04_timer_takedown(struct drm_device *); |
| 1234 | |
| 1235 | extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd, |
| 1236 | unsigned long arg); |
| 1237 | |
| 1238 | /* nv04_dac.c */ |
Ben Skeggs | 8f1a608 | 2010-06-28 14:35:50 +1000 | [diff] [blame] | 1239 | extern int nv04_dac_create(struct drm_connector *, struct dcb_entry *); |
Francisco Jerez | 11d6eb2 | 2009-12-17 18:52:44 +0100 | [diff] [blame] | 1240 | extern uint32_t nv17_dac_sample_load(struct drm_encoder *encoder); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1241 | extern int nv04_dac_output_offset(struct drm_encoder *encoder); |
| 1242 | extern void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable); |
Francisco Jerez | 8ccfe9e | 2010-07-04 16:14:42 +0200 | [diff] [blame] | 1243 | extern bool nv04_dac_in_use(struct drm_encoder *encoder); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1244 | |
| 1245 | /* nv04_dfp.c */ |
Ben Skeggs | 8f1a608 | 2010-06-28 14:35:50 +1000 | [diff] [blame] | 1246 | extern int nv04_dfp_create(struct drm_connector *, struct dcb_entry *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1247 | extern int nv04_dfp_get_bound_head(struct drm_device *dev, struct dcb_entry *dcbent); |
| 1248 | extern void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_entry *dcbent, |
| 1249 | int head, bool dl); |
| 1250 | extern void nv04_dfp_disable(struct drm_device *dev, int head); |
| 1251 | extern void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode); |
| 1252 | |
| 1253 | /* nv04_tv.c */ |
| 1254 | extern int nv04_tv_identify(struct drm_device *dev, int i2c_index); |
Ben Skeggs | 8f1a608 | 2010-06-28 14:35:50 +1000 | [diff] [blame] | 1255 | extern int nv04_tv_create(struct drm_connector *, struct dcb_entry *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1256 | |
| 1257 | /* nv17_tv.c */ |
Ben Skeggs | 8f1a608 | 2010-06-28 14:35:50 +1000 | [diff] [blame] | 1258 | extern int nv17_tv_create(struct drm_connector *, struct dcb_entry *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1259 | |
| 1260 | /* nv04_display.c */ |
Francisco Jerez | c88c2e0 | 2010-07-24 17:37:33 +0200 | [diff] [blame] | 1261 | extern int nv04_display_early_init(struct drm_device *); |
| 1262 | extern void nv04_display_late_takedown(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1263 | extern int nv04_display_create(struct drm_device *); |
Francisco Jerez | c88c2e0 | 2010-07-24 17:37:33 +0200 | [diff] [blame] | 1264 | extern int nv04_display_init(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1265 | extern void nv04_display_destroy(struct drm_device *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1266 | |
| 1267 | /* nv04_crtc.c */ |
| 1268 | extern int nv04_crtc_create(struct drm_device *, int index); |
| 1269 | |
| 1270 | /* nouveau_bo.c */ |
| 1271 | extern struct ttm_bo_driver nouveau_bo_driver; |
| 1272 | extern int nouveau_bo_new(struct drm_device *, struct nouveau_channel *, |
| 1273 | int size, int align, uint32_t flags, |
| 1274 | uint32_t tile_mode, uint32_t tile_flags, |
| 1275 | bool no_vm, bool mappable, struct nouveau_bo **); |
| 1276 | extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags); |
| 1277 | extern int nouveau_bo_unpin(struct nouveau_bo *); |
| 1278 | extern int nouveau_bo_map(struct nouveau_bo *); |
| 1279 | extern void nouveau_bo_unmap(struct nouveau_bo *); |
Francisco Jerez | 78ad0f7 | 2010-03-18 13:07:47 +0100 | [diff] [blame] | 1280 | extern void nouveau_bo_placement_set(struct nouveau_bo *, uint32_t type, |
| 1281 | uint32_t busy); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1282 | extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index); |
| 1283 | extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); |
| 1284 | extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); |
| 1285 | extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 1286 | extern void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1287 | |
| 1288 | /* nouveau_fence.c */ |
| 1289 | struct nouveau_fence; |
Francisco Jerez | 0c6c1c2 | 2010-09-22 00:58:54 +0200 | [diff] [blame] | 1290 | extern int nouveau_fence_init(struct drm_device *); |
| 1291 | extern void nouveau_fence_fini(struct drm_device *); |
Francisco Jerez | 2730723 | 2010-09-21 18:57:11 +0200 | [diff] [blame] | 1292 | extern int nouveau_fence_channel_init(struct nouveau_channel *); |
| 1293 | extern void nouveau_fence_channel_fini(struct nouveau_channel *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1294 | extern void nouveau_fence_update(struct nouveau_channel *); |
| 1295 | extern int nouveau_fence_new(struct nouveau_channel *, struct nouveau_fence **, |
| 1296 | bool emit); |
| 1297 | extern int nouveau_fence_emit(struct nouveau_fence *); |
Francisco Jerez | 8ac3891 | 2010-09-21 20:49:39 +0200 | [diff] [blame] | 1298 | extern void nouveau_fence_work(struct nouveau_fence *fence, |
| 1299 | void (*work)(void *priv, bool signalled), |
| 1300 | void *priv); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1301 | struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *); |
Marcin Slusarz | 382d62e | 2010-10-20 21:50:24 +0200 | [diff] [blame] | 1302 | |
| 1303 | extern bool __nouveau_fence_signalled(void *obj, void *arg); |
| 1304 | extern int __nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr); |
| 1305 | extern int __nouveau_fence_flush(void *obj, void *arg); |
| 1306 | extern void __nouveau_fence_unref(void **obj); |
| 1307 | extern void *__nouveau_fence_ref(void *obj); |
| 1308 | |
| 1309 | static inline bool nouveau_fence_signalled(struct nouveau_fence *obj) |
| 1310 | { |
| 1311 | return __nouveau_fence_signalled(obj, NULL); |
| 1312 | } |
| 1313 | static inline int |
| 1314 | nouveau_fence_wait(struct nouveau_fence *obj, bool lazy, bool intr) |
| 1315 | { |
| 1316 | return __nouveau_fence_wait(obj, NULL, lazy, intr); |
| 1317 | } |
Francisco Jerez | 2730723 | 2010-09-21 18:57:11 +0200 | [diff] [blame] | 1318 | extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *); |
Marcin Slusarz | 382d62e | 2010-10-20 21:50:24 +0200 | [diff] [blame] | 1319 | static inline int nouveau_fence_flush(struct nouveau_fence *obj) |
| 1320 | { |
| 1321 | return __nouveau_fence_flush(obj, NULL); |
| 1322 | } |
| 1323 | static inline void nouveau_fence_unref(struct nouveau_fence **obj) |
| 1324 | { |
| 1325 | __nouveau_fence_unref((void **)obj); |
| 1326 | } |
| 1327 | static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj) |
| 1328 | { |
| 1329 | return __nouveau_fence_ref(obj); |
| 1330 | } |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1331 | |
| 1332 | /* nouveau_gem.c */ |
| 1333 | extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *, |
| 1334 | int size, int align, uint32_t flags, |
| 1335 | uint32_t tile_mode, uint32_t tile_flags, |
| 1336 | bool no_vm, bool mappable, struct nouveau_bo **); |
| 1337 | extern int nouveau_gem_object_new(struct drm_gem_object *); |
| 1338 | extern void nouveau_gem_object_del(struct drm_gem_object *); |
| 1339 | extern int nouveau_gem_ioctl_new(struct drm_device *, void *, |
| 1340 | struct drm_file *); |
| 1341 | extern int nouveau_gem_ioctl_pushbuf(struct drm_device *, void *, |
| 1342 | struct drm_file *); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1343 | extern int nouveau_gem_ioctl_cpu_prep(struct drm_device *, void *, |
| 1344 | struct drm_file *); |
| 1345 | extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *, |
| 1346 | struct drm_file *); |
| 1347 | extern int nouveau_gem_ioctl_info(struct drm_device *, void *, |
| 1348 | struct drm_file *); |
| 1349 | |
Francisco Jerez | 042206c | 2010-10-21 18:19:29 +0200 | [diff] [blame] | 1350 | /* nouveau_display.c */ |
| 1351 | int nouveau_vblank_enable(struct drm_device *dev, int crtc); |
| 1352 | void nouveau_vblank_disable(struct drm_device *dev, int crtc); |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 1353 | int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 1354 | struct drm_pending_vblank_event *event); |
| 1355 | int nouveau_finish_page_flip(struct nouveau_channel *, |
| 1356 | struct nouveau_page_flip_state *); |
Francisco Jerez | 042206c | 2010-10-21 18:19:29 +0200 | [diff] [blame] | 1357 | |
Ben Skeggs | ee2e013 | 2010-07-26 09:28:25 +1000 | [diff] [blame] | 1358 | /* nv10_gpio.c */ |
| 1359 | int nv10_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag); |
| 1360 | int nv10_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1361 | |
Ben Skeggs | 4528416 | 2010-04-07 12:57:35 +1000 | [diff] [blame] | 1362 | /* nv50_gpio.c */ |
Ben Skeggs | ee2e013 | 2010-07-26 09:28:25 +1000 | [diff] [blame] | 1363 | int nv50_gpio_init(struct drm_device *dev); |
Ben Skeggs | 2cbd4c8 | 2010-11-03 10:18:04 +1000 | [diff] [blame] | 1364 | void nv50_gpio_fini(struct drm_device *dev); |
Ben Skeggs | 4528416 | 2010-04-07 12:57:35 +1000 | [diff] [blame] | 1365 | int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag); |
| 1366 | int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state); |
Ben Skeggs | d0875ed | 2010-07-23 11:31:08 +1000 | [diff] [blame] | 1367 | void nv50_gpio_irq_enable(struct drm_device *, enum dcb_gpio_tag, bool on); |
Ben Skeggs | 4528416 | 2010-04-07 12:57:35 +1000 | [diff] [blame] | 1368 | |
Ben Skeggs | e9ebb68 | 2010-04-28 14:07:06 +1000 | [diff] [blame] | 1369 | /* nv50_calc. */ |
| 1370 | int nv50_calc_pll(struct drm_device *, struct pll_lims *, int clk, |
| 1371 | int *N1, int *M1, int *N2, int *M2, int *P); |
| 1372 | int nv50_calc_pll2(struct drm_device *, struct pll_lims *, |
| 1373 | int clk, int *N, int *fN, int *M, int *P); |
| 1374 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1375 | #ifndef ioread32_native |
| 1376 | #ifdef __BIG_ENDIAN |
| 1377 | #define ioread16_native ioread16be |
| 1378 | #define iowrite16_native iowrite16be |
| 1379 | #define ioread32_native ioread32be |
| 1380 | #define iowrite32_native iowrite32be |
| 1381 | #else /* def __BIG_ENDIAN */ |
| 1382 | #define ioread16_native ioread16 |
| 1383 | #define iowrite16_native iowrite16 |
| 1384 | #define ioread32_native ioread32 |
| 1385 | #define iowrite32_native iowrite32 |
| 1386 | #endif /* def __BIG_ENDIAN else */ |
| 1387 | #endif /* !ioread32_native */ |
| 1388 | |
| 1389 | /* channel control reg access */ |
| 1390 | static inline u32 nvchan_rd32(struct nouveau_channel *chan, unsigned reg) |
| 1391 | { |
| 1392 | return ioread32_native(chan->user + reg); |
| 1393 | } |
| 1394 | |
| 1395 | static inline void nvchan_wr32(struct nouveau_channel *chan, |
| 1396 | unsigned reg, u32 val) |
| 1397 | { |
| 1398 | iowrite32_native(val, chan->user + reg); |
| 1399 | } |
| 1400 | |
| 1401 | /* register access */ |
| 1402 | static inline u32 nv_rd32(struct drm_device *dev, unsigned reg) |
| 1403 | { |
| 1404 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1405 | return ioread32_native(dev_priv->mmio + reg); |
| 1406 | } |
| 1407 | |
| 1408 | static inline void nv_wr32(struct drm_device *dev, unsigned reg, u32 val) |
| 1409 | { |
| 1410 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1411 | iowrite32_native(val, dev_priv->mmio + reg); |
| 1412 | } |
| 1413 | |
Ben Skeggs | 2a7fdb2b | 2010-08-30 16:14:51 +1000 | [diff] [blame] | 1414 | static inline u32 nv_mask(struct drm_device *dev, u32 reg, u32 mask, u32 val) |
Ben Skeggs | 49eed80 | 2010-07-23 11:17:57 +1000 | [diff] [blame] | 1415 | { |
| 1416 | u32 tmp = nv_rd32(dev, reg); |
Ben Skeggs | 2a7fdb2b | 2010-08-30 16:14:51 +1000 | [diff] [blame] | 1417 | nv_wr32(dev, reg, (tmp & ~mask) | val); |
| 1418 | return tmp; |
Ben Skeggs | 49eed80 | 2010-07-23 11:17:57 +1000 | [diff] [blame] | 1419 | } |
| 1420 | |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1421 | static inline u8 nv_rd08(struct drm_device *dev, unsigned reg) |
| 1422 | { |
| 1423 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1424 | return ioread8(dev_priv->mmio + reg); |
| 1425 | } |
| 1426 | |
| 1427 | static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val) |
| 1428 | { |
| 1429 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1430 | iowrite8(val, dev_priv->mmio + reg); |
| 1431 | } |
| 1432 | |
Francisco Jerez | 4b5c152 | 2010-09-07 17:34:44 +0200 | [diff] [blame] | 1433 | #define nv_wait(dev, reg, mask, val) \ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1434 | nouveau_wait_until(dev, 2000000000ULL, (reg), (mask), (val)) |
| 1435 | |
| 1436 | /* PRAMIN access */ |
| 1437 | static inline u32 nv_ri32(struct drm_device *dev, unsigned offset) |
| 1438 | { |
| 1439 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1440 | return ioread32_native(dev_priv->ramin + offset); |
| 1441 | } |
| 1442 | |
| 1443 | static inline void nv_wi32(struct drm_device *dev, unsigned offset, u32 val) |
| 1444 | { |
| 1445 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1446 | iowrite32_native(val, dev_priv->ramin + offset); |
| 1447 | } |
| 1448 | |
| 1449 | /* object access */ |
Ben Skeggs | b3beb16 | 2010-09-01 15:24:29 +1000 | [diff] [blame] | 1450 | extern u32 nv_ro32(struct nouveau_gpuobj *, u32 offset); |
| 1451 | extern void nv_wo32(struct nouveau_gpuobj *, u32 offset, u32 val); |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1452 | |
| 1453 | /* |
| 1454 | * Logging |
| 1455 | * Argument d is (struct drm_device *). |
| 1456 | */ |
| 1457 | #define NV_PRINTK(level, d, fmt, arg...) \ |
| 1458 | printk(level "[" DRM_NAME "] " DRIVER_NAME " %s: " fmt, \ |
| 1459 | pci_name(d->pdev), ##arg) |
| 1460 | #ifndef NV_DEBUG_NOTRACE |
| 1461 | #define NV_DEBUG(d, fmt, arg...) do { \ |
Maarten Maathuis | ef2bb50 | 2009-12-13 16:53:12 +0100 | [diff] [blame] | 1462 | if (drm_debug & DRM_UT_DRIVER) { \ |
| 1463 | NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \ |
| 1464 | __LINE__, ##arg); \ |
| 1465 | } \ |
| 1466 | } while (0) |
| 1467 | #define NV_DEBUG_KMS(d, fmt, arg...) do { \ |
| 1468 | if (drm_debug & DRM_UT_KMS) { \ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1469 | NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__, \ |
| 1470 | __LINE__, ##arg); \ |
| 1471 | } \ |
| 1472 | } while (0) |
| 1473 | #else |
| 1474 | #define NV_DEBUG(d, fmt, arg...) do { \ |
Maarten Maathuis | ef2bb50 | 2009-12-13 16:53:12 +0100 | [diff] [blame] | 1475 | if (drm_debug & DRM_UT_DRIVER) \ |
| 1476 | NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \ |
| 1477 | } while (0) |
| 1478 | #define NV_DEBUG_KMS(d, fmt, arg...) do { \ |
| 1479 | if (drm_debug & DRM_UT_KMS) \ |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1480 | NV_PRINTK(KERN_DEBUG, d, fmt, ##arg); \ |
| 1481 | } while (0) |
| 1482 | #endif |
| 1483 | #define NV_ERROR(d, fmt, arg...) NV_PRINTK(KERN_ERR, d, fmt, ##arg) |
| 1484 | #define NV_INFO(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg) |
| 1485 | #define NV_TRACEWARN(d, fmt, arg...) NV_PRINTK(KERN_NOTICE, d, fmt, ##arg) |
| 1486 | #define NV_TRACE(d, fmt, arg...) NV_PRINTK(KERN_INFO, d, fmt, ##arg) |
| 1487 | #define NV_WARN(d, fmt, arg...) NV_PRINTK(KERN_WARNING, d, fmt, ##arg) |
| 1488 | |
| 1489 | /* nouveau_reg_debug bitmask */ |
| 1490 | enum { |
| 1491 | NOUVEAU_REG_DEBUG_MC = 0x1, |
| 1492 | NOUVEAU_REG_DEBUG_VIDEO = 0x2, |
| 1493 | NOUVEAU_REG_DEBUG_FB = 0x4, |
| 1494 | NOUVEAU_REG_DEBUG_EXTDEV = 0x8, |
| 1495 | NOUVEAU_REG_DEBUG_CRTC = 0x10, |
| 1496 | NOUVEAU_REG_DEBUG_RAMDAC = 0x20, |
| 1497 | NOUVEAU_REG_DEBUG_VGACRTC = 0x40, |
| 1498 | NOUVEAU_REG_DEBUG_RMVIO = 0x80, |
| 1499 | NOUVEAU_REG_DEBUG_VGAATTR = 0x100, |
| 1500 | NOUVEAU_REG_DEBUG_EVO = 0x200, |
| 1501 | }; |
| 1502 | |
| 1503 | #define NV_REG_DEBUG(type, dev, fmt, arg...) do { \ |
| 1504 | if (nouveau_reg_debug & NOUVEAU_REG_DEBUG_##type) \ |
| 1505 | NV_PRINTK(KERN_DEBUG, dev, "%s: " fmt, __func__, ##arg); \ |
| 1506 | } while (0) |
| 1507 | |
| 1508 | static inline bool |
| 1509 | nv_two_heads(struct drm_device *dev) |
| 1510 | { |
| 1511 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1512 | const int impl = dev->pci_device & 0x0ff0; |
| 1513 | |
| 1514 | if (dev_priv->card_type >= NV_10 && impl != 0x0100 && |
| 1515 | impl != 0x0150 && impl != 0x01a0 && impl != 0x0200) |
| 1516 | return true; |
| 1517 | |
| 1518 | return false; |
| 1519 | } |
| 1520 | |
| 1521 | static inline bool |
| 1522 | nv_gf4_disp_arch(struct drm_device *dev) |
| 1523 | { |
| 1524 | return nv_two_heads(dev) && (dev->pci_device & 0x0ff0) != 0x0110; |
| 1525 | } |
| 1526 | |
| 1527 | static inline bool |
| 1528 | nv_two_reg_pll(struct drm_device *dev) |
| 1529 | { |
| 1530 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
| 1531 | const int impl = dev->pci_device & 0x0ff0; |
| 1532 | |
| 1533 | if (impl == 0x0310 || impl == 0x0340 || dev_priv->card_type >= NV_40) |
| 1534 | return true; |
| 1535 | return false; |
| 1536 | } |
| 1537 | |
Francisco Jerez | acae116 | 2010-08-15 14:31:31 +0200 | [diff] [blame] | 1538 | static inline bool |
| 1539 | nv_match_device(struct drm_device *dev, unsigned device, |
| 1540 | unsigned sub_vendor, unsigned sub_device) |
| 1541 | { |
| 1542 | return dev->pdev->device == device && |
| 1543 | dev->pdev->subsystem_vendor == sub_vendor && |
| 1544 | dev->pdev->subsystem_device == sub_device; |
| 1545 | } |
| 1546 | |
Francisco Jerez | f03a314 | 2009-12-26 02:42:45 +0100 | [diff] [blame] | 1547 | #define NV_SW 0x0000506e |
| 1548 | #define NV_SW_DMA_SEMAPHORE 0x00000060 |
| 1549 | #define NV_SW_SEMAPHORE_OFFSET 0x00000064 |
| 1550 | #define NV_SW_SEMAPHORE_ACQUIRE 0x00000068 |
| 1551 | #define NV_SW_SEMAPHORE_RELEASE 0x0000006c |
Francisco Jerez | 8af29cc | 2010-10-02 17:04:46 +0200 | [diff] [blame] | 1552 | #define NV_SW_YIELD 0x00000080 |
Francisco Jerez | f03a314 | 2009-12-26 02:42:45 +0100 | [diff] [blame] | 1553 | #define NV_SW_DMA_VBLSEM 0x0000018c |
| 1554 | #define NV_SW_VBLSEM_OFFSET 0x00000400 |
| 1555 | #define NV_SW_VBLSEM_RELEASE_VALUE 0x00000404 |
| 1556 | #define NV_SW_VBLSEM_RELEASE 0x00000408 |
Francisco Jerez | 332b242 | 2010-10-20 23:35:40 +0200 | [diff] [blame] | 1557 | #define NV_SW_PAGE_FLIP 0x00000500 |
Ben Skeggs | 6ee7386 | 2009-12-11 19:24:15 +1000 | [diff] [blame] | 1558 | |
| 1559 | #endif /* __NOUVEAU_DRV_H__ */ |