drm: remove lots of spurious whitespace.
[platform/upstream/libdrm.git] / shared-core / nouveau_drv.h
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             "20060213"
34
35 #define DRIVER_MAJOR            0
36 #define DRIVER_MINOR            0
37 #define DRIVER_PATCHLEVEL       10
38
39 #define NOUVEAU_FAMILY   0x0000FFFF
40 #define NOUVEAU_FLAGS    0xFFFF0000
41
42 #include "nouveau_drm.h"
43 #include "nouveau_reg.h"
44
45 struct mem_block {
46         struct mem_block *next;
47         struct mem_block *prev;
48         uint64_t start;
49         uint64_t size;
50         struct drm_file *file_priv; /* NULL: free, -1: heap, other: real files */
51         int flags;
52         drm_local_map_t *map;
53         drm_handle_t map_handle;
54 };
55
56 enum nouveau_flags {
57         NV_NFORCE   =0x10000000,
58         NV_NFORCE2  =0x20000000
59 };
60
61 #define NVOBJ_ENGINE_SW         0
62 #define NVOBJ_ENGINE_GR         1
63 #define NVOBJ_ENGINE_INT        0xdeadbeef
64
65 #define NVOBJ_FLAG_ALLOW_NO_REFS        (1 << 0)
66 #define NVOBJ_FLAG_ZERO_ALLOC           (1 << 1)
67 #define NVOBJ_FLAG_ZERO_FREE            (1 << 2)
68 #define NVOBJ_FLAG_FAKE                 (1 << 3)
69 struct nouveau_gpuobj {
70         struct list_head list;
71
72         int im_channel;
73         struct mem_block *im_pramin;
74         struct mem_block *im_backing;
75         int im_bound;
76
77         uint32_t flags;
78         int refcount;
79
80         uint32_t engine;
81         uint32_t class;
82
83         void (*dtor)(struct drm_device *, struct nouveau_gpuobj *);
84         void *priv;
85 };
86
87 struct nouveau_gpuobj_ref {
88         struct list_head list;
89
90         struct nouveau_gpuobj *gpuobj;
91         uint32_t instance;
92
93         int channel;
94         int handle;
95 };
96
97 struct nouveau_channel
98 {
99         struct drm_device *dev;
100         int id;
101
102         /* owner of this fifo */
103         struct drm_file *file_priv;
104         /* mapping of the fifo itself */
105         drm_local_map_t *map;
106         /* mapping of the regs controling the fifo */
107         drm_local_map_t *regs;
108
109         /* Fencing */
110         uint32_t next_sequence;
111
112         /* DMA push buffer */
113         struct nouveau_gpuobj_ref *pushbuf;
114         struct mem_block          *pushbuf_mem;
115         uint32_t                   pushbuf_base;
116
117         /* Notifier memory */
118         struct mem_block *notifier_block;
119         struct mem_block *notifier_heap;
120         drm_local_map_t  *notifier_map;
121
122         /* PFIFO context */
123         struct nouveau_gpuobj_ref *ramfc;
124
125         /* PGRAPH context */
126         /* XXX may be merge 2 pointers as private data ??? */
127         struct nouveau_gpuobj_ref *ramin_grctx;
128         void *pgraph_ctx;
129
130         /* NV50 VM */
131         struct nouveau_gpuobj     *vm_pd;
132         struct nouveau_gpuobj_ref *vm_gart_pt;
133
134         /* Objects */
135         struct nouveau_gpuobj_ref *ramin; /* Private instmem */
136         struct mem_block          *ramin_heap; /* Private PRAMIN heap */
137         struct nouveau_gpuobj_ref *ramht; /* Hash table */
138         struct list_head           ramht_refs; /* Objects referenced by RAMHT */
139 };
140
141 struct nouveau_drm_channel {
142         struct nouveau_channel *chan;
143
144         /* DMA state */
145         int max, put, cur, free;
146         int push_free;
147         volatile uint32_t *pushbuf;
148
149         /* Notifiers */
150         uint32_t notify0_offset;
151
152         /* Buffer moves */
153         uint32_t m2mf_dma_source;
154         uint32_t m2mf_dma_destin;
155 };
156
157 struct nouveau_config {
158         struct {
159                 int location;
160                 int size;
161         } cmdbuf;
162 };
163
164 struct nouveau_instmem_engine {
165         void    *priv;
166
167         int     (*init)(struct drm_device *dev);
168         void    (*takedown)(struct drm_device *dev);
169
170         int     (*populate)(struct drm_device *, struct nouveau_gpuobj *,
171                             uint32_t *size);
172         void    (*clear)(struct drm_device *, struct nouveau_gpuobj *);
173         int     (*bind)(struct drm_device *, struct nouveau_gpuobj *);
174         int     (*unbind)(struct drm_device *, struct nouveau_gpuobj *);
175 };
176
177 struct nouveau_mc_engine {
178         int  (*init)(struct drm_device *dev);
179         void (*takedown)(struct drm_device *dev);
180 };
181
182 struct nouveau_timer_engine {
183         int      (*init)(struct drm_device *dev);
184         void     (*takedown)(struct drm_device *dev);
185         uint64_t (*read)(struct drm_device *dev);
186 };
187
188 struct nouveau_fb_engine {
189         int  (*init)(struct drm_device *dev);
190         void (*takedown)(struct drm_device *dev);
191 };
192
193 struct nouveau_fifo_engine {
194         void *priv;
195
196         int  (*init)(struct drm_device *);
197         void (*takedown)(struct drm_device *);
198
199         int  (*create_context)(struct nouveau_channel *);
200         void (*destroy_context)(struct nouveau_channel *);
201         int  (*load_context)(struct nouveau_channel *);
202         int  (*save_context)(struct nouveau_channel *);
203 };
204
205 struct nouveau_pgraph_engine {
206         int  (*init)(struct drm_device *);
207         void (*takedown)(struct drm_device *);
208
209         int  (*create_context)(struct nouveau_channel *);
210         void (*destroy_context)(struct nouveau_channel *);
211         int  (*load_context)(struct nouveau_channel *);
212         int  (*save_context)(struct nouveau_channel *);
213 };
214
215 struct nouveau_engine {
216         struct nouveau_instmem_engine instmem;
217         struct nouveau_mc_engine      mc;
218         struct nouveau_timer_engine   timer;
219         struct nouveau_fb_engine      fb;
220         struct nouveau_pgraph_engine  graph;
221         struct nouveau_fifo_engine    fifo;
222 };
223
224 struct drm_nouveau_private {
225         enum {
226                 NOUVEAU_CARD_INIT_DOWN,
227                 NOUVEAU_CARD_INIT_DONE,
228                 NOUVEAU_CARD_INIT_FAILED
229         } init_state;
230
231         int ttm;
232
233         /* the card type, takes NV_* as values */
234         int card_type;
235         /* exact chipset, derived from NV_PMC_BOOT_0 */
236         int chipset;
237         int flags;
238
239         drm_local_map_t *mmio;
240         drm_local_map_t *fb;
241         drm_local_map_t *ramin; /* NV40 onwards */
242
243         int fifo_alloc_count;
244         struct nouveau_channel *fifos[NV_MAX_FIFO_NUMBER];
245
246         struct nouveau_engine Engine;
247         struct nouveau_drm_channel channel;
248
249         /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */
250         struct nouveau_gpuobj *ramht;
251         uint32_t ramin_rsvd_vram;
252         uint32_t ramht_offset;
253         uint32_t ramht_size;
254         uint32_t ramht_bits;
255         uint32_t ramfc_offset;
256         uint32_t ramfc_size;
257         uint32_t ramro_offset;
258         uint32_t ramro_size;
259
260         /* base physical adresses */
261         uint64_t fb_phys;
262         uint64_t fb_available_size;
263
264         struct {
265                 enum {
266                         NOUVEAU_GART_NONE = 0,
267                         NOUVEAU_GART_AGP,
268                         NOUVEAU_GART_SGDMA
269                 } type;
270                 uint64_t aper_base;
271                 uint64_t aper_size;
272
273                 struct nouveau_gpuobj *sg_ctxdma;
274                 struct page *sg_dummy_page;
275                 dma_addr_t sg_dummy_bus;
276
277                 /* nottm hack */
278                 struct drm_ttm_backend *sg_be;
279                 unsigned long sg_handle;
280         } gart_info;
281
282         /* the mtrr covering the FB */
283         int fb_mtrr;
284
285         struct mem_block *agp_heap;
286         struct mem_block *fb_heap;
287         struct mem_block *fb_nomap_heap;
288         struct mem_block *ramin_heap;
289         struct mem_block *pci_heap;
290
291         /* context table pointed to be NV_PGRAPH_CHANNEL_CTX_TABLE (0x400780) */
292         uint32_t ctx_table_size;
293         struct nouveau_gpuobj_ref *ctx_table;
294
295         struct nouveau_config config;
296
297         struct list_head gpuobj_list;
298 };
299
300 #define NOUVEAU_CHECK_INITIALISED_WITH_RETURN do {         \
301         struct drm_nouveau_private *nv = dev->dev_private; \
302         if (nv->init_state != NOUVEAU_CARD_INIT_DONE) {    \
303                 DRM_ERROR("called without init\n");        \
304                 return -EINVAL;                            \
305         }                                                  \
306 } while(0)
307
308 #define NOUVEAU_GET_USER_CHANNEL_WITH_RETURN(id,cl,ch) do {  \
309         struct drm_nouveau_private *nv = dev->dev_private;   \
310         if (!nouveau_fifo_owner(dev, (cl), (id))) {          \
311                 DRM_ERROR("pid %d doesn't own channel %d\n", \
312                           DRM_CURRENTPID, (id));             \
313                 return -EPERM;                               \
314         }                                                    \
315         (ch) = nv->fifos[(id)];                              \
316 } while(0)
317
318 /* nouveau_state.c */
319 extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);
320 extern int  nouveau_load(struct drm_device *, unsigned long flags);
321 extern int  nouveau_firstopen(struct drm_device *);
322 extern void nouveau_lastclose(struct drm_device *);
323 extern int  nouveau_unload(struct drm_device *);
324 extern int  nouveau_ioctl_getparam(struct drm_device *, void *data,
325                                    struct drm_file *);
326 extern int  nouveau_ioctl_setparam(struct drm_device *, void *data,
327                                    struct drm_file *);
328 extern void nouveau_wait_for_idle(struct drm_device *);
329 extern int  nouveau_card_init(struct drm_device *);
330 extern int  nouveau_ioctl_card_init(struct drm_device *, void *data,
331                                     struct drm_file *);
332
333 /* nouveau_mem.c */
334 extern int  nouveau_mem_init_heap(struct mem_block **, uint64_t start,
335                                  uint64_t size);
336 extern struct mem_block *nouveau_mem_alloc_block(struct mem_block *,
337                                                  uint64_t size, int align2,
338                                                  struct drm_file *);
339 extern void nouveau_mem_takedown(struct mem_block **heap);
340 extern void nouveau_mem_free_block(struct mem_block *);
341 extern uint64_t nouveau_mem_fb_amount(struct drm_device *);
342 extern void nouveau_mem_release(struct drm_file *, struct mem_block *heap);
343 extern int  nouveau_ioctl_mem_alloc(struct drm_device *, void *data,
344                                     struct drm_file *);
345 extern int  nouveau_ioctl_mem_free(struct drm_device *, void *data,
346                                    struct drm_file *);
347 extern struct mem_block* nouveau_mem_alloc(struct drm_device *,
348                                            int alignment, uint64_t size,
349                                            int flags, struct drm_file *);
350 extern void nouveau_mem_free(struct drm_device *dev, struct mem_block*);
351 extern int  nouveau_mem_init(struct drm_device *);
352 extern int  nouveau_mem_init_ttm(struct drm_device *);
353 extern void nouveau_mem_close(struct drm_device *);
354
355 /* nouveau_notifier.c */
356 extern int  nouveau_notifier_init_channel(struct nouveau_channel *);
357 extern void nouveau_notifier_takedown_channel(struct nouveau_channel *);
358 extern int  nouveau_notifier_alloc(struct nouveau_channel *, uint32_t handle,
359                                    int cout, uint32_t *offset);
360 extern int  nouveau_ioctl_notifier_alloc(struct drm_device *, void *data,
361                                          struct drm_file *);
362 extern int  nouveau_ioctl_notifier_free(struct drm_device *, void *data,
363                                         struct drm_file *);
364
365 /* nouveau_fifo.c */
366 extern int  nouveau_fifo_init(struct drm_device *);
367 extern int  nouveau_fifo_number(struct drm_device *);
368 extern int  nouveau_fifo_ctx_size(struct drm_device *);
369 extern void nouveau_fifo_cleanup(struct drm_device *, struct drm_file *);
370 extern int  nouveau_fifo_owner(struct drm_device *, struct drm_file *,
371                                int channel);
372 extern int  nouveau_fifo_alloc(struct drm_device *dev,
373                                struct nouveau_channel **chan,
374                                struct drm_file *file_priv,
375                                struct mem_block *pushbuf,
376                                uint32_t fb_ctxdma, uint32_t tt_ctxdma);
377 extern void nouveau_fifo_free(struct nouveau_channel *);
378
379 /* nouveau_object.c */
380 extern int  nouveau_gpuobj_early_init(struct drm_device *);
381 extern int  nouveau_gpuobj_init(struct drm_device *);
382 extern void nouveau_gpuobj_takedown(struct drm_device *);
383 extern void nouveau_gpuobj_late_takedown(struct drm_device *);
384 extern int nouveau_gpuobj_channel_init(struct nouveau_channel *,
385                                        uint32_t vram_h, uint32_t tt_h);
386 extern void nouveau_gpuobj_channel_takedown(struct nouveau_channel *);
387 extern int nouveau_gpuobj_new(struct drm_device *, struct nouveau_channel *,
388                               int size, int align, uint32_t flags,
389                               struct nouveau_gpuobj **);
390 extern int nouveau_gpuobj_del(struct drm_device *, struct nouveau_gpuobj **);
391 extern int nouveau_gpuobj_ref_add(struct drm_device *, struct nouveau_channel *,
392                                   uint32_t handle, struct nouveau_gpuobj *,
393                                   struct nouveau_gpuobj_ref **);
394 extern int nouveau_gpuobj_ref_del(struct drm_device *,
395                                   struct nouveau_gpuobj_ref **);
396 extern int nouveau_gpuobj_ref_find(struct nouveau_channel *, uint32_t handle,
397                                    struct nouveau_gpuobj_ref **ref_ret);
398 extern int nouveau_gpuobj_new_ref(struct drm_device *,
399                                   struct nouveau_channel *alloc_chan,
400                                   struct nouveau_channel *ref_chan,
401                                   uint32_t handle, int size, int align,
402                                   uint32_t flags, struct nouveau_gpuobj_ref **);
403 extern int nouveau_gpuobj_new_fake(struct drm_device *,
404                                    uint32_t p_offset, uint32_t b_offset,
405                                    uint32_t size, uint32_t flags,
406                                    struct nouveau_gpuobj **,
407                                    struct nouveau_gpuobj_ref**);
408 extern int nouveau_gpuobj_dma_new(struct nouveau_channel *, int class,
409                                   uint64_t offset, uint64_t size, int access,
410                                   int target, struct nouveau_gpuobj **);
411 extern int nouveau_gpuobj_gart_dma_new(struct nouveau_channel *,
412                                        uint64_t offset, uint64_t size,
413                                        int access, struct nouveau_gpuobj **,
414                                        uint32_t *o_ret);
415 extern int nouveau_gpuobj_gr_new(struct nouveau_channel *, int class,
416                                  struct nouveau_gpuobj **);
417 extern int nouveau_ioctl_grobj_alloc(struct drm_device *, void *data,
418                                      struct drm_file *);
419 extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data,
420                                      struct drm_file *);
421
422 /* nouveau_irq.c */
423 extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
424 extern void        nouveau_irq_preinstall(struct drm_device *);
425 extern void        nouveau_irq_postinstall(struct drm_device *);
426 extern void        nouveau_irq_uninstall(struct drm_device *);
427
428 /* nouveau_sgdma.c */
429 extern int nouveau_sgdma_init(struct drm_device *);
430 extern void nouveau_sgdma_takedown(struct drm_device *);
431 extern int nouveau_sgdma_get_page(struct drm_device *, uint32_t offset,
432                                   uint32_t *page);
433 extern struct drm_ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *);
434 extern int nouveau_sgdma_nottm_hack_init(struct drm_device *);
435 extern void nouveau_sgdma_nottm_hack_takedown(struct drm_device *);
436
437 /* nouveau_dma.c */
438 extern int  nouveau_dma_channel_init(struct drm_device *);
439 extern void nouveau_dma_channel_takedown(struct drm_device *);
440 extern int  nouveau_dma_wait(struct drm_device *, int size);
441
442 /* nv04_fb.c */
443 extern int  nv04_fb_init(struct drm_device *);
444 extern void nv04_fb_takedown(struct drm_device *);
445
446 /* nv10_fb.c */
447 extern int  nv10_fb_init(struct drm_device *);
448 extern void nv10_fb_takedown(struct drm_device *);
449
450 /* nv40_fb.c */
451 extern int  nv40_fb_init(struct drm_device *);
452 extern void nv40_fb_takedown(struct drm_device *);
453
454 /* nv04_fifo.c */
455 extern int  nv04_fifo_create_context(struct nouveau_channel *);
456 extern void nv04_fifo_destroy_context(struct nouveau_channel *);
457 extern int  nv04_fifo_load_context(struct nouveau_channel *);
458 extern int  nv04_fifo_save_context(struct nouveau_channel *);
459
460 /* nv10_fifo.c */
461 extern int  nv10_fifo_create_context(struct nouveau_channel *);
462 extern void nv10_fifo_destroy_context(struct nouveau_channel *);
463 extern int  nv10_fifo_load_context(struct nouveau_channel *);
464 extern int  nv10_fifo_save_context(struct nouveau_channel *);
465
466 /* nv40_fifo.c */
467 extern int  nv40_fifo_init(struct drm_device *);
468 extern int  nv40_fifo_create_context(struct nouveau_channel *);
469 extern void nv40_fifo_destroy_context(struct nouveau_channel *);
470 extern int  nv40_fifo_load_context(struct nouveau_channel *);
471 extern int  nv40_fifo_save_context(struct nouveau_channel *);
472
473 /* nv50_fifo.c */
474 extern int  nv50_fifo_init(struct drm_device *);
475 extern void nv50_fifo_takedown(struct drm_device *);
476 extern int  nv50_fifo_create_context(struct nouveau_channel *);
477 extern void nv50_fifo_destroy_context(struct nouveau_channel *);
478 extern int  nv50_fifo_load_context(struct nouveau_channel *);
479 extern int  nv50_fifo_save_context(struct nouveau_channel *);
480
481 /* nv04_graph.c */
482 extern void nouveau_nv04_context_switch(struct drm_device *);
483 extern int  nv04_graph_init(struct drm_device *);
484 extern void nv04_graph_takedown(struct drm_device *);
485 extern int  nv04_graph_create_context(struct nouveau_channel *);
486 extern void nv04_graph_destroy_context(struct nouveau_channel *);
487 extern int  nv04_graph_load_context(struct nouveau_channel *);
488 extern int  nv04_graph_save_context(struct nouveau_channel *);
489
490 /* nv10_graph.c */
491 extern void nouveau_nv10_context_switch(struct drm_device *);
492 extern int  nv10_graph_init(struct drm_device *);
493 extern void nv10_graph_takedown(struct drm_device *);
494 extern int  nv10_graph_create_context(struct nouveau_channel *);
495 extern void nv10_graph_destroy_context(struct nouveau_channel *);
496 extern int  nv10_graph_load_context(struct nouveau_channel *);
497 extern int  nv10_graph_save_context(struct nouveau_channel *);
498
499 /* nv20_graph.c */
500 extern int  nv20_graph_create_context(struct nouveau_channel *);
501 extern void nv20_graph_destroy_context(struct nouveau_channel *);
502 extern int  nv20_graph_load_context(struct nouveau_channel *);
503 extern int  nv20_graph_save_context(struct nouveau_channel *);
504 extern int  nv20_graph_init(struct drm_device *);
505 extern void nv20_graph_takedown(struct drm_device *);
506 extern int  nv30_graph_init(struct drm_device *);
507
508 /* nv40_graph.c */
509 extern int  nv40_graph_init(struct drm_device *);
510 extern void nv40_graph_takedown(struct drm_device *);
511 extern int  nv40_graph_create_context(struct nouveau_channel *);
512 extern void nv40_graph_destroy_context(struct nouveau_channel *);
513 extern int  nv40_graph_load_context(struct nouveau_channel *);
514 extern int  nv40_graph_save_context(struct nouveau_channel *);
515
516 /* nv50_graph.c */
517 extern int  nv50_graph_init(struct drm_device *);
518 extern void nv50_graph_takedown(struct drm_device *);
519 extern int  nv50_graph_create_context(struct nouveau_channel *);
520 extern void nv50_graph_destroy_context(struct nouveau_channel *);
521 extern int  nv50_graph_load_context(struct nouveau_channel *);
522 extern int  nv50_graph_save_context(struct nouveau_channel *);
523
524 /* nv04_instmem.c */
525 extern int  nv04_instmem_init(struct drm_device *);
526 extern void nv04_instmem_takedown(struct drm_device *);
527 extern int  nv04_instmem_populate(struct drm_device *, struct nouveau_gpuobj *,
528                                   uint32_t *size);
529 extern void nv04_instmem_clear(struct drm_device *, struct nouveau_gpuobj *);
530 extern int  nv04_instmem_bind(struct drm_device *, struct nouveau_gpuobj *);
531 extern int  nv04_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *);
532
533 /* nv50_instmem.c */
534 extern int  nv50_instmem_init(struct drm_device *);
535 extern void nv50_instmem_takedown(struct drm_device *);
536 extern int  nv50_instmem_populate(struct drm_device *, struct nouveau_gpuobj *,
537                                   uint32_t *size);
538 extern void nv50_instmem_clear(struct drm_device *, struct nouveau_gpuobj *);
539 extern int  nv50_instmem_bind(struct drm_device *, struct nouveau_gpuobj *);
540 extern int  nv50_instmem_unbind(struct drm_device *, struct nouveau_gpuobj *);
541
542 /* nv04_mc.c */
543 extern int  nv04_mc_init(struct drm_device *);
544 extern void nv04_mc_takedown(struct drm_device *);
545
546 /* nv40_mc.c */
547 extern int  nv40_mc_init(struct drm_device *);
548 extern void nv40_mc_takedown(struct drm_device *);
549
550 /* nv50_mc.c */
551 extern int  nv50_mc_init(struct drm_device *);
552 extern void nv50_mc_takedown(struct drm_device *);
553
554 /* nv04_timer.c */
555 extern int  nv04_timer_init(struct drm_device *);
556 extern uint64_t nv04_timer_read(struct drm_device *);
557 extern void nv04_timer_takedown(struct drm_device *);
558
559 extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,
560                                  unsigned long arg);
561
562 /* nouveau_buffer.c */
563 extern struct drm_bo_driver nouveau_bo_driver;
564
565 /* nouveau_fence.c */
566 extern struct drm_fence_driver nouveau_fence_driver;
567 extern void nouveau_fence_handler(struct drm_device *dev, int channel);
568
569 #if defined(__powerpc__)
570 #define NV_READ(reg)        in_be32((void __iomem *)(dev_priv->mmio)->handle + (reg) )
571 #define NV_WRITE(reg,val)   out_be32((void __iomem *)(dev_priv->mmio)->handle + (reg) , (val) )
572 #else
573 #define NV_READ(reg)        DRM_READ32(  dev_priv->mmio, (reg) )
574 #define NV_WRITE(reg,val)   DRM_WRITE32( dev_priv->mmio, (reg), (val) )
575 #endif
576
577 /* PRAMIN access */
578 #if defined(__powerpc__)
579 #define NV_RI32(o) in_be32((void __iomem *)(dev_priv->ramin)->handle+(o))
580 #define NV_WI32(o,v) out_be32((void __iomem*)(dev_priv->ramin)->handle+(o), (v))
581 #else
582 #define NV_RI32(o) DRM_READ32(dev_priv->ramin, (o))
583 #define NV_WI32(o,v) DRM_WRITE32(dev_priv->ramin, (o), (v))
584 #endif
585
586 #define INSTANCE_RD(o,i) NV_RI32((o)->im_pramin->start + ((i)<<2))
587 #define INSTANCE_WR(o,i,v) NV_WI32((o)->im_pramin->start + ((i)<<2), (v))
588
589 #endif /* __NOUVEAU_DRV_H__ */