aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_drv.h
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-12 00:37:42 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-12 00:37:42 -0500
commit83eb95b852902f952ba594447a796ad8146b9462 (patch)
tree33c199aeeae58b69ad8d6d2a33c2d96ba2b98ddf /drivers/gpu/drm/nouveau/nouveau_drv.h
parentefb3e34b6176d30c4fe8635fa8e1beb6280cc2cd (diff)
parent9bbe7b984096ac45586da2adf26c14069ecb79b2 (diff)
Merge branch 'sh/sdio' into sh-latest
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_drv.h')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h425
1 files changed, 286 insertions, 139 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 1c7db64c03bf..46e32573b3a3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -54,22 +54,37 @@ struct nouveau_fpriv {
54#include "nouveau_drm.h" 54#include "nouveau_drm.h"
55#include "nouveau_reg.h" 55#include "nouveau_reg.h"
56#include "nouveau_bios.h" 56#include "nouveau_bios.h"
57#include "nouveau_util.h"
58
57struct nouveau_grctx; 59struct nouveau_grctx;
60struct nouveau_vram;
61#include "nouveau_vm.h"
58 62
59#define MAX_NUM_DCB_ENTRIES 16 63#define MAX_NUM_DCB_ENTRIES 16
60 64
61#define NOUVEAU_MAX_CHANNEL_NR 128 65#define NOUVEAU_MAX_CHANNEL_NR 128
62#define NOUVEAU_MAX_TILE_NR 15 66#define NOUVEAU_MAX_TILE_NR 15
63 67
64#define NV50_VM_MAX_VRAM (2*1024*1024*1024ULL) 68struct nouveau_vram {
65#define NV50_VM_BLOCK (512*1024*1024ULL) 69 struct drm_device *dev;
66#define NV50_VM_VRAM_NR (NV50_VM_MAX_VRAM / NV50_VM_BLOCK) 70
71 struct nouveau_vma bar_vma;
72 u8 page_shift;
73
74 struct list_head regions;
75 u32 memtype;
76 u64 offset;
77 u64 size;
78};
67 79
68struct nouveau_tile_reg { 80struct nouveau_tile_reg {
69 struct nouveau_fence *fence;
70 uint32_t addr;
71 uint32_t size;
72 bool used; 81 bool used;
82 uint32_t addr;
83 uint32_t limit;
84 uint32_t pitch;
85 uint32_t zcomp;
86 struct drm_mm_node *tag_mem;
87 struct nouveau_fence *fence;
73}; 88};
74 89
75struct nouveau_bo { 90struct nouveau_bo {
@@ -88,6 +103,7 @@ struct nouveau_bo {
88 103
89 struct nouveau_channel *channel; 104 struct nouveau_channel *channel;
90 105
106 struct nouveau_vma vma;
91 bool mappable; 107 bool mappable;
92 bool no_vm; 108 bool no_vm;
93 109
@@ -96,7 +112,6 @@ struct nouveau_bo {
96 struct nouveau_tile_reg *tile; 112 struct nouveau_tile_reg *tile;
97 113
98 struct drm_gem_object *gem; 114 struct drm_gem_object *gem;
99 struct drm_file *cpu_filp;
100 int pin_refcnt; 115 int pin_refcnt;
101}; 116};
102 117
@@ -133,20 +148,28 @@ enum nouveau_flags {
133 148
134#define NVOBJ_ENGINE_SW 0 149#define NVOBJ_ENGINE_SW 0
135#define NVOBJ_ENGINE_GR 1 150#define NVOBJ_ENGINE_GR 1
136#define NVOBJ_ENGINE_DISPLAY 2 151#define NVOBJ_ENGINE_PPP 2
152#define NVOBJ_ENGINE_COPY 3
153#define NVOBJ_ENGINE_VP 4
154#define NVOBJ_ENGINE_CRYPT 5
155#define NVOBJ_ENGINE_BSP 6
156#define NVOBJ_ENGINE_DISPLAY 0xcafe0001
137#define NVOBJ_ENGINE_INT 0xdeadbeef 157#define NVOBJ_ENGINE_INT 0xdeadbeef
138 158
159#define NVOBJ_FLAG_DONT_MAP (1 << 0)
139#define NVOBJ_FLAG_ZERO_ALLOC (1 << 1) 160#define NVOBJ_FLAG_ZERO_ALLOC (1 << 1)
140#define NVOBJ_FLAG_ZERO_FREE (1 << 2) 161#define NVOBJ_FLAG_ZERO_FREE (1 << 2)
162#define NVOBJ_FLAG_VM (1 << 3)
163
164#define NVOBJ_CINST_GLOBAL 0xdeadbeef
165
141struct nouveau_gpuobj { 166struct nouveau_gpuobj {
142 struct drm_device *dev; 167 struct drm_device *dev;
143 struct kref refcount; 168 struct kref refcount;
144 struct list_head list; 169 struct list_head list;
145 170
146 struct drm_mm_node *im_pramin; 171 void *node;
147 struct nouveau_bo *im_backing; 172 u32 *suspend;
148 uint32_t *im_backing_suspend;
149 int im_bound;
150 173
151 uint32_t flags; 174 uint32_t flags;
152 175
@@ -162,10 +185,29 @@ struct nouveau_gpuobj {
162 void *priv; 185 void *priv;
163}; 186};
164 187
188struct nouveau_page_flip_state {
189 struct list_head head;
190 struct drm_pending_vblank_event *event;
191 int crtc, bpp, pitch, x, y;
192 uint64_t offset;
193};
194
195enum nouveau_channel_mutex_class {
196 NOUVEAU_UCHANNEL_MUTEX,
197 NOUVEAU_KCHANNEL_MUTEX
198};
199
165struct nouveau_channel { 200struct nouveau_channel {
166 struct drm_device *dev; 201 struct drm_device *dev;
167 int id; 202 int id;
168 203
204 /* references to the channel data structure */
205 struct kref ref;
206 /* users of the hardware channel resources, the hardware
207 * context will be kicked off when it reaches zero. */
208 atomic_t users;
209 struct mutex mutex;
210
169 /* owner of this fifo */ 211 /* owner of this fifo */
170 struct drm_file *file_priv; 212 struct drm_file *file_priv;
171 /* mapping of the fifo itself */ 213 /* mapping of the fifo itself */
@@ -198,16 +240,17 @@ struct nouveau_channel {
198 /* PFIFO context */ 240 /* PFIFO context */
199 struct nouveau_gpuobj *ramfc; 241 struct nouveau_gpuobj *ramfc;
200 struct nouveau_gpuobj *cache; 242 struct nouveau_gpuobj *cache;
243 void *fifo_priv;
201 244
202 /* PGRAPH context */ 245 /* PGRAPH context */
203 /* XXX may be merge 2 pointers as private data ??? */ 246 /* XXX may be merge 2 pointers as private data ??? */
204 struct nouveau_gpuobj *ramin_grctx; 247 struct nouveau_gpuobj *ramin_grctx;
248 struct nouveau_gpuobj *crypt_ctx;
205 void *pgraph_ctx; 249 void *pgraph_ctx;
206 250
207 /* NV50 VM */ 251 /* NV50 VM */
252 struct nouveau_vm *vm;
208 struct nouveau_gpuobj *vm_pd; 253 struct nouveau_gpuobj *vm_pd;
209 struct nouveau_gpuobj *vm_gart_pt;
210 struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR];
211 254
212 /* Objects */ 255 /* Objects */
213 struct nouveau_gpuobj *ramin; /* Private instmem */ 256 struct nouveau_gpuobj *ramin; /* Private instmem */
@@ -238,9 +281,11 @@ struct nouveau_channel {
238 281
239 struct { 282 struct {
240 struct nouveau_gpuobj *vblsem; 283 struct nouveau_gpuobj *vblsem;
284 uint32_t vblsem_head;
241 uint32_t vblsem_offset; 285 uint32_t vblsem_offset;
242 uint32_t vblsem_rval; 286 uint32_t vblsem_rval;
243 struct list_head vbl_wait; 287 struct list_head vbl_wait;
288 struct list_head flip;
244 } nvsw; 289 } nvsw;
245 290
246 struct { 291 struct {
@@ -258,11 +303,11 @@ struct nouveau_instmem_engine {
258 int (*suspend)(struct drm_device *dev); 303 int (*suspend)(struct drm_device *dev);
259 void (*resume)(struct drm_device *dev); 304 void (*resume)(struct drm_device *dev);
260 305
261 int (*populate)(struct drm_device *, struct nouveau_gpuobj *, 306 int (*get)(struct nouveau_gpuobj *, u32 size, u32 align);
262 uint32_t *size); 307 void (*put)(struct nouveau_gpuobj *);
263 void (*clear)(struct drm_device *, struct nouveau_gpuobj *); 308 int (*map)(struct nouveau_gpuobj *);
264 int (*bind)(struct drm_device *, struct nouveau_gpuobj *); 309 void (*unmap)(struct nouveau_gpuobj *);
265 int (*unbind)(struct drm_device *, struct nouveau_gpuobj *); 310
266 void (*flush)(struct drm_device *); 311 void (*flush)(struct drm_device *);
267}; 312};
268 313
@@ -279,15 +324,21 @@ struct nouveau_timer_engine {
279 324
280struct nouveau_fb_engine { 325struct nouveau_fb_engine {
281 int num_tiles; 326 int num_tiles;
327 struct drm_mm tag_heap;
328 void *priv;
282 329
283 int (*init)(struct drm_device *dev); 330 int (*init)(struct drm_device *dev);
284 void (*takedown)(struct drm_device *dev); 331 void (*takedown)(struct drm_device *dev);
285 332
286 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr, 333 void (*init_tile_region)(struct drm_device *dev, int i,
287 uint32_t size, uint32_t pitch); 334 uint32_t addr, uint32_t size,
335 uint32_t pitch, uint32_t flags);
336 void (*set_tile_region)(struct drm_device *dev, int i);
337 void (*free_tile_region)(struct drm_device *dev, int i);
288}; 338};
289 339
290struct nouveau_fifo_engine { 340struct nouveau_fifo_engine {
341 void *priv;
291 int channels; 342 int channels;
292 343
293 struct nouveau_gpuobj *playlist[2]; 344 struct nouveau_gpuobj *playlist[2];
@@ -310,22 +361,11 @@ struct nouveau_fifo_engine {
310 void (*tlb_flush)(struct drm_device *dev); 361 void (*tlb_flush)(struct drm_device *dev);
311}; 362};
312 363
313struct nouveau_pgraph_object_method {
314 int id;
315 int (*exec)(struct nouveau_channel *chan, int grclass, int mthd,
316 uint32_t data);
317};
318
319struct nouveau_pgraph_object_class {
320 int id;
321 bool software;
322 struct nouveau_pgraph_object_method *methods;
323};
324
325struct nouveau_pgraph_engine { 364struct nouveau_pgraph_engine {
326 struct nouveau_pgraph_object_class *grclass;
327 bool accel_blocked; 365 bool accel_blocked;
366 bool registered;
328 int grctx_size; 367 int grctx_size;
368 void *priv;
329 369
330 /* NV2x/NV3x context table (0x400780) */ 370 /* NV2x/NV3x context table (0x400780) */
331 struct nouveau_gpuobj *ctx_table; 371 struct nouveau_gpuobj *ctx_table;
@@ -342,8 +382,7 @@ struct nouveau_pgraph_engine {
342 int (*unload_context)(struct drm_device *); 382 int (*unload_context)(struct drm_device *);
343 void (*tlb_flush)(struct drm_device *dev); 383 void (*tlb_flush)(struct drm_device *dev);
344 384
345 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr, 385 void (*set_tile_region)(struct drm_device *dev, int i);
346 uint32_t size, uint32_t pitch);
347}; 386};
348 387
349struct nouveau_display_engine { 388struct nouveau_display_engine {
@@ -355,13 +394,19 @@ struct nouveau_display_engine {
355}; 394};
356 395
357struct nouveau_gpio_engine { 396struct nouveau_gpio_engine {
397 void *priv;
398
358 int (*init)(struct drm_device *); 399 int (*init)(struct drm_device *);
359 void (*takedown)(struct drm_device *); 400 void (*takedown)(struct drm_device *);
360 401
361 int (*get)(struct drm_device *, enum dcb_gpio_tag); 402 int (*get)(struct drm_device *, enum dcb_gpio_tag);
362 int (*set)(struct drm_device *, enum dcb_gpio_tag, int state); 403 int (*set)(struct drm_device *, enum dcb_gpio_tag, int state);
363 404
364 void (*irq_enable)(struct drm_device *, enum dcb_gpio_tag, bool on); 405 int (*irq_register)(struct drm_device *, enum dcb_gpio_tag,
406 void (*)(void *, int), void *);
407 void (*irq_unregister)(struct drm_device *, enum dcb_gpio_tag,
408 void (*)(void *, int), void *);
409 bool (*irq_enable)(struct drm_device *, enum dcb_gpio_tag, bool on);
365}; 410};
366 411
367struct nouveau_pm_voltage_level { 412struct nouveau_pm_voltage_level {
@@ -437,6 +482,7 @@ struct nouveau_pm_engine {
437 struct nouveau_pm_level *cur; 482 struct nouveau_pm_level *cur;
438 483
439 struct device *hwmon; 484 struct device *hwmon;
485 struct notifier_block acpi_nb;
440 486
441 int (*clock_get)(struct drm_device *, u32 id); 487 int (*clock_get)(struct drm_device *, u32 id);
442 void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *, 488 void *(*clock_pre)(struct drm_device *, struct nouveau_pm_level *,
@@ -449,6 +495,25 @@ struct nouveau_pm_engine {
449 int (*temp_get)(struct drm_device *); 495 int (*temp_get)(struct drm_device *);
450}; 496};
451 497
498struct nouveau_crypt_engine {
499 bool registered;
500
501 int (*init)(struct drm_device *);
502 void (*takedown)(struct drm_device *);
503 int (*create_context)(struct nouveau_channel *);
504 void (*destroy_context)(struct nouveau_channel *);
505 void (*tlb_flush)(struct drm_device *dev);
506};
507
508struct nouveau_vram_engine {
509 int (*init)(struct drm_device *);
510 int (*get)(struct drm_device *, u64, u32 align, u32 size_nc,
511 u32 type, struct nouveau_vram **);
512 void (*put)(struct drm_device *, struct nouveau_vram **);
513
514 bool (*flags_valid)(struct drm_device *, u32 tile_flags);
515};
516
452struct nouveau_engine { 517struct nouveau_engine {
453 struct nouveau_instmem_engine instmem; 518 struct nouveau_instmem_engine instmem;
454 struct nouveau_mc_engine mc; 519 struct nouveau_mc_engine mc;
@@ -459,6 +524,8 @@ struct nouveau_engine {
459 struct nouveau_display_engine display; 524 struct nouveau_display_engine display;
460 struct nouveau_gpio_engine gpio; 525 struct nouveau_gpio_engine gpio;
461 struct nouveau_pm_engine pm; 526 struct nouveau_pm_engine pm;
527 struct nouveau_crypt_engine crypt;
528 struct nouveau_vram_engine vram;
462}; 529};
463 530
464struct nouveau_pll_vals { 531struct nouveau_pll_vals {
@@ -577,18 +644,15 @@ struct drm_nouveau_private {
577 bool ramin_available; 644 bool ramin_available;
578 struct drm_mm ramin_heap; 645 struct drm_mm ramin_heap;
579 struct list_head gpuobj_list; 646 struct list_head gpuobj_list;
647 struct list_head classes;
580 648
581 struct nouveau_bo *vga_ram; 649 struct nouveau_bo *vga_ram;
582 650
651 /* interrupt handling */
652 void (*irq_handler[32])(struct drm_device *);
653 bool msi_enabled;
583 struct workqueue_struct *wq; 654 struct workqueue_struct *wq;
584 struct work_struct irq_work; 655 struct work_struct irq_work;
585 struct work_struct hpd_work;
586
587 struct {
588 spinlock_t lock;
589 uint32_t hpd0_bits;
590 uint32_t hpd1_bits;
591 } hpd_state;
592 656
593 struct list_head vbl_waiting; 657 struct list_head vbl_waiting;
594 658
@@ -605,8 +669,10 @@ struct drm_nouveau_private {
605 struct nouveau_bo *bo; 669 struct nouveau_bo *bo;
606 } fence; 670 } fence;
607 671
608 int fifo_alloc_count; 672 struct {
609 struct nouveau_channel *fifos[NOUVEAU_MAX_CHANNEL_NR]; 673 spinlock_t lock;
674 struct nouveau_channel *ptr[NOUVEAU_MAX_CHANNEL_NR];
675 } channels;
610 676
611 struct nouveau_engine engine; 677 struct nouveau_engine engine;
612 struct nouveau_channel *channel; 678 struct nouveau_channel *channel;
@@ -632,12 +698,14 @@ struct drm_nouveau_private {
632 uint64_t aper_free; 698 uint64_t aper_free;
633 699
634 struct nouveau_gpuobj *sg_ctxdma; 700 struct nouveau_gpuobj *sg_ctxdma;
635 struct page *sg_dummy_page; 701 struct nouveau_vma vma;
636 dma_addr_t sg_dummy_bus;
637 } gart_info; 702 } gart_info;
638 703
639 /* nv10-nv40 tiling regions */ 704 /* nv10-nv40 tiling regions */
640 struct nouveau_tile_reg tile[NOUVEAU_MAX_TILE_NR]; 705 struct {
706 struct nouveau_tile_reg reg[NOUVEAU_MAX_TILE_NR];
707 spinlock_t lock;
708 } tile;
641 709
642 /* VRAM/fb configuration */ 710 /* VRAM/fb configuration */
643 uint64_t vram_size; 711 uint64_t vram_size;
@@ -650,14 +718,12 @@ struct drm_nouveau_private {
650 uint64_t fb_aper_free; 718 uint64_t fb_aper_free;
651 int fb_mtrr; 719 int fb_mtrr;
652 720
721 /* BAR control (NV50-) */
722 struct nouveau_vm *bar1_vm;
723 struct nouveau_vm *bar3_vm;
724
653 /* G8x/G9x virtual address space */ 725 /* G8x/G9x virtual address space */
654 uint64_t vm_gart_base; 726 struct nouveau_vm *chan_vm;
655 uint64_t vm_gart_size;
656 uint64_t vm_vram_base;
657 uint64_t vm_vram_size;
658 uint64_t vm_end;
659 struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR];
660 int vm_vram_pt_nr;
661 727
662 struct nvbios vbios; 728 struct nvbios vbios;
663 729
@@ -674,6 +740,7 @@ struct drm_nouveau_private {
674 struct backlight_device *backlight; 740 struct backlight_device *backlight;
675 741
676 struct nouveau_channel *evo; 742 struct nouveau_channel *evo;
743 u32 evo_alloc;
677 struct { 744 struct {
678 struct dcb_entry *dcb; 745 struct dcb_entry *dcb;
679 u16 script; 746 u16 script;
@@ -686,6 +753,8 @@ struct drm_nouveau_private {
686 753
687 struct nouveau_fbdev *nfbdev; 754 struct nouveau_fbdev *nfbdev;
688 struct apertures_struct *apertures; 755 struct apertures_struct *apertures;
756
757 bool powered_down;
689}; 758};
690 759
691static inline struct drm_nouveau_private * 760static inline struct drm_nouveau_private *
@@ -719,16 +788,6 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo)
719 return 0; 788 return 0;
720} 789}
721 790
722#define NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(id, cl, ch) do { \
723 struct drm_nouveau_private *nv = dev->dev_private; \
724 if (!nouveau_channel_owner(dev, (cl), (id))) { \
725 NV_ERROR(dev, "pid %d doesn't own channel %d\n", \
726 DRM_CURRENTPID, (id)); \
727 return -EPERM; \
728 } \
729 (ch) = nv->fifos[(id)]; \
730} while (0)
731
732/* nouveau_drv.c */ 791/* nouveau_drv.c */
733extern int nouveau_agpmode; 792extern int nouveau_agpmode;
734extern int nouveau_duallink; 793extern int nouveau_duallink;
@@ -748,6 +807,7 @@ extern int nouveau_force_post;
748extern int nouveau_override_conntype; 807extern int nouveau_override_conntype;
749extern char *nouveau_perflvl; 808extern char *nouveau_perflvl;
750extern int nouveau_perflvl_wr; 809extern int nouveau_perflvl_wr;
810extern int nouveau_msi;
751 811
752extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state); 812extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
753extern int nouveau_pci_resume(struct pci_dev *pdev); 813extern int nouveau_pci_resume(struct pci_dev *pdev);
@@ -762,8 +822,10 @@ extern int nouveau_ioctl_getparam(struct drm_device *, void *data,
762 struct drm_file *); 822 struct drm_file *);
763extern int nouveau_ioctl_setparam(struct drm_device *, void *data, 823extern int nouveau_ioctl_setparam(struct drm_device *, void *data,
764 struct drm_file *); 824 struct drm_file *);
765extern bool nouveau_wait_until(struct drm_device *, uint64_t timeout, 825extern bool nouveau_wait_eq(struct drm_device *, uint64_t timeout,
766 uint32_t reg, uint32_t mask, uint32_t val); 826 uint32_t reg, uint32_t mask, uint32_t val);
827extern bool nouveau_wait_ne(struct drm_device *, uint64_t timeout,
828 uint32_t reg, uint32_t mask, uint32_t val);
767extern bool nouveau_wait_for_idle(struct drm_device *); 829extern bool nouveau_wait_for_idle(struct drm_device *);
768extern int nouveau_card_init(struct drm_device *); 830extern int nouveau_card_init(struct drm_device *);
769 831
@@ -775,18 +837,18 @@ extern void nouveau_mem_gart_fini(struct drm_device *);
775extern int nouveau_mem_init_agp(struct drm_device *); 837extern int nouveau_mem_init_agp(struct drm_device *);
776extern int nouveau_mem_reset_agp(struct drm_device *); 838extern int nouveau_mem_reset_agp(struct drm_device *);
777extern void nouveau_mem_close(struct drm_device *); 839extern void nouveau_mem_close(struct drm_device *);
778extern struct nouveau_tile_reg *nv10_mem_set_tiling(struct drm_device *dev, 840extern int nouveau_mem_detect(struct drm_device *);
779 uint32_t addr, 841extern bool nouveau_mem_flags_valid(struct drm_device *, u32 tile_flags);
780 uint32_t size, 842extern struct nouveau_tile_reg *nv10_mem_set_tiling(
781 uint32_t pitch); 843 struct drm_device *dev, uint32_t addr, uint32_t size,
782extern void nv10_mem_expire_tiling(struct drm_device *dev, 844 uint32_t pitch, uint32_t flags);
783 struct nouveau_tile_reg *tile, 845extern void nv10_mem_put_tile_region(struct drm_device *dev,
784 struct nouveau_fence *fence); 846 struct nouveau_tile_reg *tile,
785extern int nv50_mem_vm_bind_linear(struct drm_device *, uint64_t virt, 847 struct nouveau_fence *fence);
786 uint32_t size, uint32_t flags, 848extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
787 uint64_t phys); 849
788extern void nv50_mem_vm_unbind(struct drm_device *, uint64_t virt, 850/* nvc0_vram.c */
789 uint32_t size); 851extern const struct ttm_mem_type_manager_func nvc0_vram_manager;
790 852
791/* nouveau_notifier.c */ 853/* nouveau_notifier.c */
792extern int nouveau_notifier_init_channel(struct nouveau_channel *); 854extern int nouveau_notifier_init_channel(struct nouveau_channel *);
@@ -803,21 +865,44 @@ extern int nouveau_ioctl_notifier_free(struct drm_device *, void *data,
803extern struct drm_ioctl_desc nouveau_ioctls[]; 865extern struct drm_ioctl_desc nouveau_ioctls[];
804extern int nouveau_max_ioctl; 866extern int nouveau_max_ioctl;
805extern void nouveau_channel_cleanup(struct drm_device *, struct drm_file *); 867extern void nouveau_channel_cleanup(struct drm_device *, struct drm_file *);
806extern int nouveau_channel_owner(struct drm_device *, struct drm_file *,
807 int channel);
808extern int nouveau_channel_alloc(struct drm_device *dev, 868extern int nouveau_channel_alloc(struct drm_device *dev,
809 struct nouveau_channel **chan, 869 struct nouveau_channel **chan,
810 struct drm_file *file_priv, 870 struct drm_file *file_priv,
811 uint32_t fb_ctxdma, uint32_t tt_ctxdma); 871 uint32_t fb_ctxdma, uint32_t tt_ctxdma);
812extern void nouveau_channel_free(struct nouveau_channel *); 872extern struct nouveau_channel *
873nouveau_channel_get_unlocked(struct nouveau_channel *);
874extern struct nouveau_channel *
875nouveau_channel_get(struct drm_device *, struct drm_file *, int id);
876extern void nouveau_channel_put_unlocked(struct nouveau_channel **);
877extern void nouveau_channel_put(struct nouveau_channel **);
878extern void nouveau_channel_ref(struct nouveau_channel *chan,
879 struct nouveau_channel **pchan);
880extern void nouveau_channel_idle(struct nouveau_channel *chan);
813 881
814/* nouveau_object.c */ 882/* nouveau_object.c */
883#define NVOBJ_CLASS(d,c,e) do { \
884 int ret = nouveau_gpuobj_class_new((d), (c), NVOBJ_ENGINE_##e); \
885 if (ret) \
886 return ret; \
887} while(0)
888
889#define NVOBJ_MTHD(d,c,m,e) do { \
890 int ret = nouveau_gpuobj_mthd_new((d), (c), (m), (e)); \
891 if (ret) \
892 return ret; \
893} while(0)
894
815extern int nouveau_gpuobj_early_init(struct drm_device *); 895extern int nouveau_gpuobj_early_init(struct drm_device *);
816extern int nouveau_gpuobj_init(struct drm_device *); 896extern int nouveau_gpuobj_init(struct drm_device *);
817extern void nouveau_gpuobj_takedown(struct drm_device *); 897extern void nouveau_gpuobj_takedown(struct drm_device *);
818extern int nouveau_gpuobj_suspend(struct drm_device *dev); 898extern int nouveau_gpuobj_suspend(struct drm_device *dev);
819extern void nouveau_gpuobj_suspend_cleanup(struct drm_device *dev);
820extern void nouveau_gpuobj_resume(struct drm_device *dev); 899extern void nouveau_gpuobj_resume(struct drm_device *dev);
900extern int nouveau_gpuobj_class_new(struct drm_device *, u32 class, u32 eng);
901extern int nouveau_gpuobj_mthd_new(struct drm_device *, u32 class, u32 mthd,
902 int (*exec)(struct nouveau_channel *,
903 u32 class, u32 mthd, u32 data));
904extern int nouveau_gpuobj_mthd_call(struct nouveau_channel *, u32, u32, u32);
905extern int nouveau_gpuobj_mthd_call2(struct drm_device *, int, u32, u32, u32);
821extern int nouveau_gpuobj_channel_init(struct nouveau_channel *, 906extern int nouveau_gpuobj_channel_init(struct nouveau_channel *,
822 uint32_t vram_h, uint32_t tt_h); 907 uint32_t vram_h, uint32_t tt_h);
823extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *); 908extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *);
@@ -832,21 +917,25 @@ extern int nouveau_gpuobj_new_fake(struct drm_device *, u32 pinst, u64 vinst,
832extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class, 917extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class,
833 uint64_t offset, uint64_t size, int access, 918 uint64_t offset, uint64_t size, int access,
834 int target, struct nouveau_gpuobj **); 919 int target, struct nouveau_gpuobj **);
835extern int nouveau_gpuobj_gart_dma_new(struct nouveau_channel *, 920extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, u32 handle, int class);
836 uint64_t offset, uint64_t size, 921extern int nv50_gpuobj_dma_new(struct nouveau_channel *, int class, u64 base,
837 int access, struct nouveau_gpuobj **, 922 u64 size, int target, int access, u32 type,
838 uint32_t *o_ret); 923 u32 comp, struct nouveau_gpuobj **pobj);
839extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, int class, 924extern void nv50_gpuobj_dma_init(struct nouveau_gpuobj *, u32 offset,
840 struct nouveau_gpuobj **); 925 int class, u64 base, u64 size, int target,
841extern int nouveau_gpuobj_sw_new(struct nouveau_channel *, int class, 926 int access, u32 type, u32 comp);
842 struct nouveau_gpuobj **);
843extern int nouveau_ioctl_grobj_alloc(struct drm_device *, void *data, 927extern int nouveau_ioctl_grobj_alloc(struct drm_device *, void *data,
844 struct drm_file *); 928 struct drm_file *);
845extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data, 929extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data,
846 struct drm_file *); 930 struct drm_file *);
847 931
848/* nouveau_irq.c */ 932/* nouveau_irq.c */
933extern int nouveau_irq_init(struct drm_device *);
934extern void nouveau_irq_fini(struct drm_device *);
849extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS); 935extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
936extern void nouveau_irq_register(struct drm_device *, int status_bit,
937 void (*)(struct drm_device *));
938extern void nouveau_irq_unregister(struct drm_device *, int status_bit);
850extern void nouveau_irq_preinstall(struct drm_device *); 939extern void nouveau_irq_preinstall(struct drm_device *);
851extern int nouveau_irq_postinstall(struct drm_device *); 940extern int nouveau_irq_postinstall(struct drm_device *);
852extern void nouveau_irq_uninstall(struct drm_device *); 941extern void nouveau_irq_uninstall(struct drm_device *);
@@ -854,8 +943,8 @@ extern void nouveau_irq_uninstall(struct drm_device *);
854/* nouveau_sgdma.c */ 943/* nouveau_sgdma.c */
855extern int nouveau_sgdma_init(struct drm_device *); 944extern int nouveau_sgdma_init(struct drm_device *);
856extern void nouveau_sgdma_takedown(struct drm_device *); 945extern void nouveau_sgdma_takedown(struct drm_device *);
857extern int nouveau_sgdma_get_page(struct drm_device *, uint32_t offset, 946extern uint32_t nouveau_sgdma_get_physical(struct drm_device *,
858 uint32_t *page); 947 uint32_t offset);
859extern struct ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *); 948extern struct ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *);
860 949
861/* nouveau_debugfs.c */ 950/* nouveau_debugfs.c */
@@ -966,18 +1055,25 @@ extern void nv04_fb_takedown(struct drm_device *);
966/* nv10_fb.c */ 1055/* nv10_fb.c */
967extern int nv10_fb_init(struct drm_device *); 1056extern int nv10_fb_init(struct drm_device *);
968extern void nv10_fb_takedown(struct drm_device *); 1057extern void nv10_fb_takedown(struct drm_device *);
969extern void nv10_fb_set_region_tiling(struct drm_device *, int, uint32_t, 1058extern void nv10_fb_init_tile_region(struct drm_device *dev, int i,
970 uint32_t, uint32_t); 1059 uint32_t addr, uint32_t size,
1060 uint32_t pitch, uint32_t flags);
1061extern void nv10_fb_set_tile_region(struct drm_device *dev, int i);
1062extern void nv10_fb_free_tile_region(struct drm_device *dev, int i);
971 1063
972/* nv30_fb.c */ 1064/* nv30_fb.c */
973extern int nv30_fb_init(struct drm_device *); 1065extern int nv30_fb_init(struct drm_device *);
974extern void nv30_fb_takedown(struct drm_device *); 1066extern void nv30_fb_takedown(struct drm_device *);
1067extern void nv30_fb_init_tile_region(struct drm_device *dev, int i,
1068 uint32_t addr, uint32_t size,
1069 uint32_t pitch, uint32_t flags);
1070extern void nv30_fb_free_tile_region(struct drm_device *dev, int i);
975 1071
976/* nv40_fb.c */ 1072/* nv40_fb.c */
977extern int nv40_fb_init(struct drm_device *); 1073extern int nv40_fb_init(struct drm_device *);
978extern void nv40_fb_takedown(struct drm_device *); 1074extern void nv40_fb_takedown(struct drm_device *);
979extern void nv40_fb_set_region_tiling(struct drm_device *, int, uint32_t, 1075extern void nv40_fb_set_tile_region(struct drm_device *dev, int i);
980 uint32_t, uint32_t); 1076
981/* nv50_fb.c */ 1077/* nv50_fb.c */
982extern int nv50_fb_init(struct drm_device *); 1078extern int nv50_fb_init(struct drm_device *);
983extern void nv50_fb_takedown(struct drm_device *); 1079extern void nv50_fb_takedown(struct drm_device *);
@@ -989,6 +1085,7 @@ extern void nvc0_fb_takedown(struct drm_device *);
989 1085
990/* nv04_fifo.c */ 1086/* nv04_fifo.c */
991extern int nv04_fifo_init(struct drm_device *); 1087extern int nv04_fifo_init(struct drm_device *);
1088extern void nv04_fifo_fini(struct drm_device *);
992extern void nv04_fifo_disable(struct drm_device *); 1089extern void nv04_fifo_disable(struct drm_device *);
993extern void nv04_fifo_enable(struct drm_device *); 1090extern void nv04_fifo_enable(struct drm_device *);
994extern bool nv04_fifo_reassign(struct drm_device *, bool); 1091extern bool nv04_fifo_reassign(struct drm_device *, bool);
@@ -998,19 +1095,18 @@ extern int nv04_fifo_create_context(struct nouveau_channel *);
998extern void nv04_fifo_destroy_context(struct nouveau_channel *); 1095extern void nv04_fifo_destroy_context(struct nouveau_channel *);
999extern int nv04_fifo_load_context(struct nouveau_channel *); 1096extern int nv04_fifo_load_context(struct nouveau_channel *);
1000extern int nv04_fifo_unload_context(struct drm_device *); 1097extern int nv04_fifo_unload_context(struct drm_device *);
1098extern void nv04_fifo_isr(struct drm_device *);
1001 1099
1002/* nv10_fifo.c */ 1100/* nv10_fifo.c */
1003extern int nv10_fifo_init(struct drm_device *); 1101extern int nv10_fifo_init(struct drm_device *);
1004extern int nv10_fifo_channel_id(struct drm_device *); 1102extern int nv10_fifo_channel_id(struct drm_device *);
1005extern int nv10_fifo_create_context(struct nouveau_channel *); 1103extern int nv10_fifo_create_context(struct nouveau_channel *);
1006extern void nv10_fifo_destroy_context(struct nouveau_channel *);
1007extern int nv10_fifo_load_context(struct nouveau_channel *); 1104extern int nv10_fifo_load_context(struct nouveau_channel *);
1008extern int nv10_fifo_unload_context(struct drm_device *); 1105extern int nv10_fifo_unload_context(struct drm_device *);
1009 1106
1010/* nv40_fifo.c */ 1107/* nv40_fifo.c */
1011extern int nv40_fifo_init(struct drm_device *); 1108extern int nv40_fifo_init(struct drm_device *);
1012extern int nv40_fifo_create_context(struct nouveau_channel *); 1109extern int nv40_fifo_create_context(struct nouveau_channel *);
1013extern void nv40_fifo_destroy_context(struct nouveau_channel *);
1014extern int nv40_fifo_load_context(struct nouveau_channel *); 1110extern int nv40_fifo_load_context(struct nouveau_channel *);
1015extern int nv40_fifo_unload_context(struct drm_device *); 1111extern int nv40_fifo_unload_context(struct drm_device *);
1016 1112
@@ -1038,7 +1134,6 @@ extern int nvc0_fifo_load_context(struct nouveau_channel *);
1038extern int nvc0_fifo_unload_context(struct drm_device *); 1134extern int nvc0_fifo_unload_context(struct drm_device *);
1039 1135
1040/* nv04_graph.c */ 1136/* nv04_graph.c */
1041extern struct nouveau_pgraph_object_class nv04_graph_grclass[];
1042extern int nv04_graph_init(struct drm_device *); 1137extern int nv04_graph_init(struct drm_device *);
1043extern void nv04_graph_takedown(struct drm_device *); 1138extern void nv04_graph_takedown(struct drm_device *);
1044extern void nv04_graph_fifo_access(struct drm_device *, bool); 1139extern void nv04_graph_fifo_access(struct drm_device *, bool);
@@ -1047,10 +1142,11 @@ extern int nv04_graph_create_context(struct nouveau_channel *);
1047extern void nv04_graph_destroy_context(struct nouveau_channel *); 1142extern void nv04_graph_destroy_context(struct nouveau_channel *);
1048extern int nv04_graph_load_context(struct nouveau_channel *); 1143extern int nv04_graph_load_context(struct nouveau_channel *);
1049extern int nv04_graph_unload_context(struct drm_device *); 1144extern int nv04_graph_unload_context(struct drm_device *);
1050extern void nv04_graph_context_switch(struct drm_device *); 1145extern int nv04_graph_mthd_page_flip(struct nouveau_channel *chan,
1146 u32 class, u32 mthd, u32 data);
1147extern struct nouveau_bitfield nv04_graph_nsource[];
1051 1148
1052/* nv10_graph.c */ 1149/* nv10_graph.c */
1053extern struct nouveau_pgraph_object_class nv10_graph_grclass[];
1054extern int nv10_graph_init(struct drm_device *); 1150extern int nv10_graph_init(struct drm_device *);
1055extern void nv10_graph_takedown(struct drm_device *); 1151extern void nv10_graph_takedown(struct drm_device *);
1056extern struct nouveau_channel *nv10_graph_channel(struct drm_device *); 1152extern struct nouveau_channel *nv10_graph_channel(struct drm_device *);
@@ -1058,13 +1154,11 @@ extern int nv10_graph_create_context(struct nouveau_channel *);
1058extern void nv10_graph_destroy_context(struct nouveau_channel *); 1154extern void nv10_graph_destroy_context(struct nouveau_channel *);
1059extern int nv10_graph_load_context(struct nouveau_channel *); 1155extern int nv10_graph_load_context(struct nouveau_channel *);
1060extern int nv10_graph_unload_context(struct drm_device *); 1156extern int nv10_graph_unload_context(struct drm_device *);
1061extern void nv10_graph_context_switch(struct drm_device *); 1157extern void nv10_graph_set_tile_region(struct drm_device *dev, int i);
1062extern void nv10_graph_set_region_tiling(struct drm_device *, int, uint32_t, 1158extern struct nouveau_bitfield nv10_graph_intr[];
1063 uint32_t, uint32_t); 1159extern struct nouveau_bitfield nv10_graph_nstatus[];
1064 1160
1065/* nv20_graph.c */ 1161/* nv20_graph.c */
1066extern struct nouveau_pgraph_object_class nv20_graph_grclass[];
1067extern struct nouveau_pgraph_object_class nv30_graph_grclass[];
1068extern int nv20_graph_create_context(struct nouveau_channel *); 1162extern int nv20_graph_create_context(struct nouveau_channel *);
1069extern void nv20_graph_destroy_context(struct nouveau_channel *); 1163extern void nv20_graph_destroy_context(struct nouveau_channel *);
1070extern int nv20_graph_load_context(struct nouveau_channel *); 1164extern int nv20_graph_load_context(struct nouveau_channel *);
@@ -1072,11 +1166,9 @@ extern int nv20_graph_unload_context(struct drm_device *);
1072extern int nv20_graph_init(struct drm_device *); 1166extern int nv20_graph_init(struct drm_device *);
1073extern void nv20_graph_takedown(struct drm_device *); 1167extern void nv20_graph_takedown(struct drm_device *);
1074extern int nv30_graph_init(struct drm_device *); 1168extern int nv30_graph_init(struct drm_device *);
1075extern void nv20_graph_set_region_tiling(struct drm_device *, int, uint32_t, 1169extern void nv20_graph_set_tile_region(struct drm_device *dev, int i);
1076 uint32_t, uint32_t);
1077 1170
1078/* nv40_graph.c */ 1171/* nv40_graph.c */
1079extern struct nouveau_pgraph_object_class nv40_graph_grclass[];
1080extern int nv40_graph_init(struct drm_device *); 1172extern int nv40_graph_init(struct drm_device *);
1081extern void nv40_graph_takedown(struct drm_device *); 1173extern void nv40_graph_takedown(struct drm_device *);
1082extern struct nouveau_channel *nv40_graph_channel(struct drm_device *); 1174extern struct nouveau_channel *nv40_graph_channel(struct drm_device *);
@@ -1085,11 +1177,9 @@ extern void nv40_graph_destroy_context(struct nouveau_channel *);
1085extern int nv40_graph_load_context(struct nouveau_channel *); 1177extern int nv40_graph_load_context(struct nouveau_channel *);
1086extern int nv40_graph_unload_context(struct drm_device *); 1178extern int nv40_graph_unload_context(struct drm_device *);
1087extern void nv40_grctx_init(struct nouveau_grctx *); 1179extern void nv40_grctx_init(struct nouveau_grctx *);
1088extern void nv40_graph_set_region_tiling(struct drm_device *, int, uint32_t, 1180extern void nv40_graph_set_tile_region(struct drm_device *dev, int i);
1089 uint32_t, uint32_t);
1090 1181
1091/* nv50_graph.c */ 1182/* nv50_graph.c */
1092extern struct nouveau_pgraph_object_class nv50_graph_grclass[];
1093extern int nv50_graph_init(struct drm_device *); 1183extern int nv50_graph_init(struct drm_device *);
1094extern void nv50_graph_takedown(struct drm_device *); 1184extern void nv50_graph_takedown(struct drm_device *);
1095extern void nv50_graph_fifo_access(struct drm_device *, bool); 1185extern void nv50_graph_fifo_access(struct drm_device *, bool);
@@ -1098,10 +1188,10 @@ extern int nv50_graph_create_context(struct nouveau_channel *);
1098extern void nv50_graph_destroy_context(struct nouveau_channel *); 1188extern void nv50_graph_destroy_context(struct nouveau_channel *);
1099extern int nv50_graph_load_context(struct nouveau_channel *); 1189extern int nv50_graph_load_context(struct nouveau_channel *);
1100extern int nv50_graph_unload_context(struct drm_device *); 1190extern int nv50_graph_unload_context(struct drm_device *);
1101extern void nv50_graph_context_switch(struct drm_device *);
1102extern int nv50_grctx_init(struct nouveau_grctx *); 1191extern int nv50_grctx_init(struct nouveau_grctx *);
1103extern void nv50_graph_tlb_flush(struct drm_device *dev); 1192extern void nv50_graph_tlb_flush(struct drm_device *dev);
1104extern void nv86_graph_tlb_flush(struct drm_device *dev); 1193extern void nv86_graph_tlb_flush(struct drm_device *dev);
1194extern struct nouveau_enum nv50_data_error_names[];
1105 1195
1106/* nvc0_graph.c */ 1196/* nvc0_graph.c */
1107extern int nvc0_graph_init(struct drm_device *); 1197extern int nvc0_graph_init(struct drm_device *);
@@ -1113,16 +1203,22 @@ extern void nvc0_graph_destroy_context(struct nouveau_channel *);
1113extern int nvc0_graph_load_context(struct nouveau_channel *); 1203extern int nvc0_graph_load_context(struct nouveau_channel *);
1114extern int nvc0_graph_unload_context(struct drm_device *); 1204extern int nvc0_graph_unload_context(struct drm_device *);
1115 1205
1206/* nv84_crypt.c */
1207extern int nv84_crypt_init(struct drm_device *dev);
1208extern void nv84_crypt_fini(struct drm_device *dev);
1209extern int nv84_crypt_create_context(struct nouveau_channel *);
1210extern void nv84_crypt_destroy_context(struct nouveau_channel *);
1211extern void nv84_crypt_tlb_flush(struct drm_device *dev);
1212
1116/* nv04_instmem.c */ 1213/* nv04_instmem.c */
1117extern int nv04_instmem_init(struct drm_device *); 1214extern int nv04_instmem_init(struct drm_device *);
1118extern void nv04_instmem_takedown(struct drm_device *); 1215extern void nv04_instmem_takedown(struct drm_device *);
1119extern int nv04_instmem_suspend(struct drm_device *); 1216extern int nv04_instmem_suspend(struct drm_device *);
1120extern void nv04_instmem_resume(struct drm_device *); 1217extern void nv04_instmem_resume(struct drm_device *);
1121extern int nv04_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, 1218extern int nv04_instmem_get(struct nouveau_gpuobj *, u32 size, u32 align);
1122 uint32_t *size); 1219extern void nv04_instmem_put(struct nouveau_gpuobj *);
1123extern void nv04_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); 1220extern int nv04_instmem_map(struct nouveau_gpuobj *);
1124extern int nv04_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); 1221extern void nv04_instmem_unmap(struct nouveau_gpuobj *);
1125extern int nv04_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *);
1126extern void nv04_instmem_flush(struct drm_device *); 1222extern void nv04_instmem_flush(struct drm_device *);
1127 1223
1128/* nv50_instmem.c */ 1224/* nv50_instmem.c */
@@ -1130,26 +1226,18 @@ extern int nv50_instmem_init(struct drm_device *);
1130extern void nv50_instmem_takedown(struct drm_device *); 1226extern void nv50_instmem_takedown(struct drm_device *);
1131extern int nv50_instmem_suspend(struct drm_device *); 1227extern int nv50_instmem_suspend(struct drm_device *);
1132extern void nv50_instmem_resume(struct drm_device *); 1228extern void nv50_instmem_resume(struct drm_device *);
1133extern int nv50_instmem_populate(struct drm_device *, struct nouveau_gpuobj *, 1229extern int nv50_instmem_get(struct nouveau_gpuobj *, u32 size, u32 align);
1134 uint32_t *size); 1230extern void nv50_instmem_put(struct nouveau_gpuobj *);
1135extern void nv50_instmem_clear(struct drm_device *, struct nouveau_gpuobj *); 1231extern int nv50_instmem_map(struct nouveau_gpuobj *);
1136extern int nv50_instmem_bind(struct drm_device *, struct nouveau_gpuobj *); 1232extern void nv50_instmem_unmap(struct nouveau_gpuobj *);
1137extern int nv50_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *);
1138extern void nv50_instmem_flush(struct drm_device *); 1233extern void nv50_instmem_flush(struct drm_device *);
1139extern void nv84_instmem_flush(struct drm_device *); 1234extern void nv84_instmem_flush(struct drm_device *);
1140extern void nv50_vm_flush(struct drm_device *, int engine);
1141 1235
1142/* nvc0_instmem.c */ 1236/* nvc0_instmem.c */
1143extern int nvc0_instmem_init(struct drm_device *); 1237extern int nvc0_instmem_init(struct drm_device *);
1144extern void nvc0_instmem_takedown(struct drm_device *); 1238extern void nvc0_instmem_takedown(struct drm_device *);
1145extern int nvc0_instmem_suspend(struct drm_device *); 1239extern int nvc0_instmem_suspend(struct drm_device *);
1146extern void nvc0_instmem_resume(struct drm_device *); 1240extern void nvc0_instmem_resume(struct drm_device *);
1147extern int nvc0_instmem_populate(struct drm_device *, struct nouveau_gpuobj *,
1148 uint32_t *size);
1149extern void nvc0_instmem_clear(struct drm_device *, struct nouveau_gpuobj *);
1150extern int nvc0_instmem_bind(struct drm_device *, struct nouveau_gpuobj *);
1151extern int nvc0_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *);
1152extern void nvc0_instmem_flush(struct drm_device *);
1153 1241
1154/* nv04_mc.c */ 1242/* nv04_mc.c */
1155extern int nv04_mc_init(struct drm_device *); 1243extern int nv04_mc_init(struct drm_device *);
@@ -1219,6 +1307,9 @@ extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index);
1219extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); 1307extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val);
1220extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); 1308extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index);
1221extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val); 1309extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val);
1310extern void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
1311extern int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
1312 bool no_wait_reserve, bool no_wait_gpu);
1222 1313
1223/* nouveau_fence.c */ 1314/* nouveau_fence.c */
1224struct nouveau_fence; 1315struct nouveau_fence;
@@ -1234,12 +1325,35 @@ extern void nouveau_fence_work(struct nouveau_fence *fence,
1234 void (*work)(void *priv, bool signalled), 1325 void (*work)(void *priv, bool signalled),
1235 void *priv); 1326 void *priv);
1236struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *); 1327struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *);
1237extern bool nouveau_fence_signalled(void *obj, void *arg); 1328
1238extern int nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr); 1329extern bool __nouveau_fence_signalled(void *obj, void *arg);
1330extern int __nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);
1331extern int __nouveau_fence_flush(void *obj, void *arg);
1332extern void __nouveau_fence_unref(void **obj);
1333extern void *__nouveau_fence_ref(void *obj);
1334
1335static inline bool nouveau_fence_signalled(struct nouveau_fence *obj)
1336{
1337 return __nouveau_fence_signalled(obj, NULL);
1338}
1339static inline int
1340nouveau_fence_wait(struct nouveau_fence *obj, bool lazy, bool intr)
1341{
1342 return __nouveau_fence_wait(obj, NULL, lazy, intr);
1343}
1239extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *); 1344extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);
1240extern int nouveau_fence_flush(void *obj, void *arg); 1345static inline int nouveau_fence_flush(struct nouveau_fence *obj)
1241extern void nouveau_fence_unref(void **obj); 1346{
1242extern void *nouveau_fence_ref(void *obj); 1347 return __nouveau_fence_flush(obj, NULL);
1348}
1349static inline void nouveau_fence_unref(struct nouveau_fence **obj)
1350{
1351 __nouveau_fence_unref((void **)obj);
1352}
1353static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj)
1354{
1355 return __nouveau_fence_ref(obj);
1356}
1243 1357
1244/* nouveau_gem.c */ 1358/* nouveau_gem.c */
1245extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *, 1359extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,
@@ -1259,15 +1373,28 @@ extern int nouveau_gem_ioctl_cpu_fini(struct drm_device *, void *,
1259extern int nouveau_gem_ioctl_info(struct drm_device *, void *, 1373extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
1260 struct drm_file *); 1374 struct drm_file *);
1261 1375
1376/* nouveau_display.c */
1377int nouveau_vblank_enable(struct drm_device *dev, int crtc);
1378void nouveau_vblank_disable(struct drm_device *dev, int crtc);
1379int nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
1380 struct drm_pending_vblank_event *event);
1381int nouveau_finish_page_flip(struct nouveau_channel *,
1382 struct nouveau_page_flip_state *);
1383
1262/* nv10_gpio.c */ 1384/* nv10_gpio.c */
1263int nv10_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag); 1385int nv10_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);
1264int nv10_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state); 1386int nv10_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);
1265 1387
1266/* nv50_gpio.c */ 1388/* nv50_gpio.c */
1267int nv50_gpio_init(struct drm_device *dev); 1389int nv50_gpio_init(struct drm_device *dev);
1390void nv50_gpio_fini(struct drm_device *dev);
1268int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag); 1391int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);
1269int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state); 1392int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);
1270void nv50_gpio_irq_enable(struct drm_device *, enum dcb_gpio_tag, bool on); 1393int nv50_gpio_irq_register(struct drm_device *, enum dcb_gpio_tag,
1394 void (*)(void *, int), void *);
1395void nv50_gpio_irq_unregister(struct drm_device *, enum dcb_gpio_tag,
1396 void (*)(void *, int), void *);
1397bool nv50_gpio_irq_enable(struct drm_device *, enum dcb_gpio_tag, bool on);
1271 1398
1272/* nv50_calc. */ 1399/* nv50_calc. */
1273int nv50_calc_pll(struct drm_device *, struct pll_lims *, int clk, 1400int nv50_calc_pll(struct drm_device *, struct pll_lims *, int clk,
@@ -1334,7 +1461,9 @@ static inline void nv_wr08(struct drm_device *dev, unsigned reg, u8 val)
1334} 1461}
1335 1462
1336#define nv_wait(dev, reg, mask, val) \ 1463#define nv_wait(dev, reg, mask, val) \
1337 nouveau_wait_until(dev, 2000000000ULL, (reg), (mask), (val)) 1464 nouveau_wait_eq(dev, 2000000000ULL, (reg), (mask), (val))
1465#define nv_wait_ne(dev, reg, mask, val) \
1466 nouveau_wait_ne(dev, 2000000000ULL, (reg), (mask), (val))
1338 1467
1339/* PRAMIN access */ 1468/* PRAMIN access */
1340static inline u32 nv_ri32(struct drm_device *dev, unsigned offset) 1469static inline u32 nv_ri32(struct drm_device *dev, unsigned offset)
@@ -1447,6 +1576,23 @@ nv_match_device(struct drm_device *dev, unsigned device,
1447 dev->pdev->subsystem_device == sub_device; 1576 dev->pdev->subsystem_device == sub_device;
1448} 1577}
1449 1578
1579/* memory type/access flags, do not match hardware values */
1580#define NV_MEM_ACCESS_RO 1
1581#define NV_MEM_ACCESS_WO 2
1582#define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO)
1583#define NV_MEM_ACCESS_SYS 4
1584#define NV_MEM_ACCESS_VM 8
1585
1586#define NV_MEM_TARGET_VRAM 0
1587#define NV_MEM_TARGET_PCI 1
1588#define NV_MEM_TARGET_PCI_NOSNOOP 2
1589#define NV_MEM_TARGET_VM 3
1590#define NV_MEM_TARGET_GART 4
1591
1592#define NV_MEM_TYPE_VM 0x7f
1593#define NV_MEM_COMP_VM 0x03
1594
1595/* NV_SW object class */
1450#define NV_SW 0x0000506e 1596#define NV_SW 0x0000506e
1451#define NV_SW_DMA_SEMAPHORE 0x00000060 1597#define NV_SW_DMA_SEMAPHORE 0x00000060
1452#define NV_SW_SEMAPHORE_OFFSET 0x00000064 1598#define NV_SW_SEMAPHORE_OFFSET 0x00000064
@@ -1457,5 +1603,6 @@ nv_match_device(struct drm_device *dev, unsigned device,
1457#define NV_SW_VBLSEM_OFFSET 0x00000400 1603#define NV_SW_VBLSEM_OFFSET 0x00000400
1458#define NV_SW_VBLSEM_RELEASE_VALUE 0x00000404 1604#define NV_SW_VBLSEM_RELEASE_VALUE 0x00000404
1459#define NV_SW_VBLSEM_RELEASE 0x00000408 1605#define NV_SW_VBLSEM_RELEASE 0x00000408
1606#define NV_SW_PAGE_FLIP 0x00000500
1460 1607
1461#endif /* __NOUVEAU_DRV_H__ */ 1608#endif /* __NOUVEAU_DRV_H__ */