drm: userspace rip out TTM API
[platform/upstream/libdrm.git] / shared-core / nouveau_drv.h
index b7459b1..03fe2ba 100644 (file)
 
 #define DRIVER_MAJOR           0
 #define DRIVER_MINOR           0
-#define DRIVER_PATCHLEVEL      10
+#define DRIVER_PATCHLEVEL      11
 
 #define NOUVEAU_FAMILY   0x0000FFFF
 #define NOUVEAU_FLAGS    0xFFFF0000
 
 #include "nouveau_drm.h"
 #include "nouveau_reg.h"
+#include "nouveau_bios.h"
+
+#define MAX_NUM_DCB_ENTRIES 16
 
 struct mem_block {
        struct mem_block *next;
@@ -59,7 +62,7 @@ enum nouveau_flags {
 };
 
 #define NVOBJ_ENGINE_SW                0
-#define NVOBJ_ENGINE_GR        1
+#define NVOBJ_ENGINE_GR                1
 #define NVOBJ_ENGINE_INT       0xdeadbeef
 
 #define NVOBJ_FLAG_ALLOW_NO_REFS       (1 << 0)
@@ -106,11 +109,20 @@ struct nouveau_channel
        /* mapping of the regs controling the fifo */
        drm_local_map_t *regs;
 
+       /* Fencing */
+       uint32_t next_sequence;
+
        /* DMA push buffer */
        struct nouveau_gpuobj_ref *pushbuf;
        struct mem_block          *pushbuf_mem;
        uint32_t                   pushbuf_base;
 
+       /* FIFO user control regs */
+       uint32_t user, user_size;
+       uint32_t put;
+       uint32_t get;
+       uint32_t ref_cnt;
+
        /* Notifier memory */
        struct mem_block *notifier_block;
        struct mem_block *notifier_heap;
@@ -120,12 +132,14 @@ struct nouveau_channel
        struct nouveau_gpuobj_ref *ramfc;
 
        /* PGRAPH context */
+       /* XXX may be merge 2 pointers as private data ??? */
        struct nouveau_gpuobj_ref *ramin_grctx;
-       uint32_t pgraph_ctx [340]; /* XXX dynamic alloc ? */
+       void *pgraph_ctx;
 
        /* NV50 VM */
        struct nouveau_gpuobj     *vm_pd;
        struct nouveau_gpuobj_ref *vm_gart_pt;
+       struct nouveau_gpuobj_ref *vm_vram_pt;
 
        /* Objects */
        struct nouveau_gpuobj_ref *ramin; /* Private instmem */
@@ -189,9 +203,13 @@ struct nouveau_fb_engine {
 struct nouveau_fifo_engine {
        void *priv;
 
+       int  channels;
+
        int  (*init)(struct drm_device *);
        void (*takedown)(struct drm_device *);
 
+       int  (*channel_id)(struct drm_device *);
+
        int  (*create_context)(struct nouveau_channel *);
        void (*destroy_context)(struct nouveau_channel *);
        int  (*load_context)(struct nouveau_channel *);
@@ -217,6 +235,7 @@ struct nouveau_engine {
        struct nouveau_fifo_engine    fifo;
 };
 
+#define NOUVEAU_MAX_CHANNEL_NR 128
 struct drm_nouveau_private {
        enum {
                NOUVEAU_CARD_INIT_DOWN,
@@ -224,6 +243,8 @@ struct drm_nouveau_private {
                NOUVEAU_CARD_INIT_FAILED
        } init_state;
 
+       int ttm;
+
        /* the card type, takes NV_* as values */
        int card_type;
        /* exact chipset, derived from NV_PMC_BOOT_0 */
@@ -235,7 +256,7 @@ struct drm_nouveau_private {
        drm_local_map_t *ramin; /* NV40 onwards */
 
        int fifo_alloc_count;
-       struct nouveau_channel *fifos[NV_MAX_FIFO_NUMBER];
+       struct nouveau_channel *fifos[NOUVEAU_MAX_CHANNEL_NR];
 
        struct nouveau_engine Engine;
        struct nouveau_drm_channel channel;
@@ -273,6 +294,9 @@ struct drm_nouveau_private {
                unsigned long sg_handle;
        } gart_info;
 
+       /* G8x global VRAM page table */
+       struct nouveau_gpuobj *vm_vram_pt;
+
        /* the mtrr covering the FB */
        int fb_mtrr;
 
@@ -289,6 +313,28 @@ struct drm_nouveau_private {
        struct nouveau_config config;
 
        struct list_head gpuobj_list;
+
+       void *display_priv; /* internal modesetting */
+       void *kms_priv; /* related to public interface */
+
+       /* Hook these up to the "public interface" to accomodate a certain allocation style. */
+       /* This is to avoid polluting the internal interface. */
+       void *(*alloc_crtc) (struct drm_device *dev);
+       void *(*alloc_output) (struct drm_device *dev);
+       void *(*alloc_connector) (struct drm_device *dev);
+
+       void (*free_crtc) (void *crtc);
+       void (*free_output) (void *output);
+       void (*free_connector) (void *connector);
+
+       struct bios bios;
+
+       struct {
+               int entries;
+               struct dcb_entry entry[MAX_NUM_DCB_ENTRIES];
+               unsigned char i2c_read[MAX_NUM_DCB_ENTRIES];
+               unsigned char i2c_write[MAX_NUM_DCB_ENTRIES];
+       } dcb_table;
 };
 
 #define NOUVEAU_CHECK_INITIALISED_WITH_RETURN do {         \
@@ -329,20 +375,24 @@ extern int  nouveau_mem_init_heap(struct mem_block **, uint64_t start,
                                 uint64_t size);
 extern struct mem_block *nouveau_mem_alloc_block(struct mem_block *,
                                                 uint64_t size, int align2,
-                                                struct drm_file *);
+                                                struct drm_file *, int tail);
 extern void nouveau_mem_takedown(struct mem_block **heap);
 extern void nouveau_mem_free_block(struct mem_block *);
+extern struct mem_block* find_block_by_handle(struct mem_block *heap, drm_handle_t handle);
 extern uint64_t nouveau_mem_fb_amount(struct drm_device *);
 extern void nouveau_mem_release(struct drm_file *, struct mem_block *heap);
 extern int  nouveau_ioctl_mem_alloc(struct drm_device *, void *data,
                                    struct drm_file *);
 extern int  nouveau_ioctl_mem_free(struct drm_device *, void *data,
                                   struct drm_file *);
+extern int  nouveau_ioctl_mem_tile(struct drm_device *, void *data,
+                                  struct drm_file *);
 extern struct mem_block* nouveau_mem_alloc(struct drm_device *,
                                           int alignment, uint64_t size,
                                           int flags, struct drm_file *);
 extern void nouveau_mem_free(struct drm_device *dev, struct mem_block*);
 extern int  nouveau_mem_init(struct drm_device *);
+extern int  nouveau_mem_init_ttm(struct drm_device *);
 extern void nouveau_mem_close(struct drm_device *);
 
 /* nouveau_notifier.c */
@@ -357,7 +407,6 @@ extern int  nouveau_ioctl_notifier_free(struct drm_device *, void *data,
 
 /* nouveau_fifo.c */
 extern int  nouveau_fifo_init(struct drm_device *);
-extern int  nouveau_fifo_number(struct drm_device *);
 extern int  nouveau_fifo_ctx_size(struct drm_device *);
 extern void nouveau_fifo_cleanup(struct drm_device *, struct drm_file *);
 extern int  nouveau_fifo_owner(struct drm_device *, struct drm_file *,
@@ -415,12 +464,14 @@ extern int nouveau_ioctl_gpuobj_free(struct drm_device *, void *data,
 /* nouveau_irq.c */
 extern irqreturn_t nouveau_irq_handler(DRM_IRQ_ARGS);
 extern void        nouveau_irq_preinstall(struct drm_device *);
-extern void        nouveau_irq_postinstall(struct drm_device *);
+extern int         nouveau_irq_postinstall(struct drm_device *);
 extern void        nouveau_irq_uninstall(struct drm_device *);
 
 /* nouveau_sgdma.c */
 extern int nouveau_sgdma_init(struct drm_device *);
 extern void nouveau_sgdma_takedown(struct drm_device *);
+extern int nouveau_sgdma_get_page(struct drm_device *, uint32_t offset,
+                                 uint32_t *page);
 extern struct drm_ttm_backend *nouveau_sgdma_init_ttm(struct drm_device *);
 extern int nouveau_sgdma_nottm_hack_init(struct drm_device *);
 extern void nouveau_sgdma_nottm_hack_takedown(struct drm_device *);
@@ -443,12 +494,14 @@ extern int  nv40_fb_init(struct drm_device *);
 extern void nv40_fb_takedown(struct drm_device *);
 
 /* nv04_fifo.c */
+extern int  nv04_fifo_channel_id(struct drm_device *);
 extern int  nv04_fifo_create_context(struct nouveau_channel *);
 extern void nv04_fifo_destroy_context(struct nouveau_channel *);
 extern int  nv04_fifo_load_context(struct nouveau_channel *);
 extern int  nv04_fifo_save_context(struct nouveau_channel *);
 
 /* nv10_fifo.c */
+extern int  nv10_fifo_channel_id(struct drm_device *);
 extern int  nv10_fifo_create_context(struct nouveau_channel *);
 extern void nv10_fifo_destroy_context(struct nouveau_channel *);
 extern int  nv10_fifo_load_context(struct nouveau_channel *);
@@ -464,6 +517,7 @@ extern int  nv40_fifo_save_context(struct nouveau_channel *);
 /* nv50_fifo.c */
 extern int  nv50_fifo_init(struct drm_device *);
 extern void nv50_fifo_takedown(struct drm_device *);
+extern int  nv50_fifo_channel_id(struct drm_device *);
 extern int  nv50_fifo_create_context(struct nouveau_channel *);
 extern void nv50_fifo_destroy_context(struct nouveau_channel *);
 extern int  nv50_fifo_load_context(struct nouveau_channel *);
@@ -488,21 +542,13 @@ extern int  nv10_graph_load_context(struct nouveau_channel *);
 extern int  nv10_graph_save_context(struct nouveau_channel *);
 
 /* nv20_graph.c */
-extern void nouveau_nv20_context_switch(struct drm_device *);
-extern int  nv20_graph_init(struct drm_device *);
-extern void nv20_graph_takedown(struct drm_device *);
 extern int  nv20_graph_create_context(struct nouveau_channel *);
 extern void nv20_graph_destroy_context(struct nouveau_channel *);
 extern int  nv20_graph_load_context(struct nouveau_channel *);
 extern int  nv20_graph_save_context(struct nouveau_channel *);
-
-/* nv30_graph.c */
+extern int  nv20_graph_init(struct drm_device *);
+extern void nv20_graph_takedown(struct drm_device *);
 extern int  nv30_graph_init(struct drm_device *);
-extern void nv30_graph_takedown(struct drm_device *);
-extern int  nv30_graph_create_context(struct nouveau_channel *);
-extern void nv30_graph_destroy_context(struct nouveau_channel *);
-extern int  nv30_graph_load_context(struct nouveau_channel *);
-extern int  nv30_graph_save_context(struct nouveau_channel *);
 
 /* nv40_graph.c */
 extern int  nv40_graph_init(struct drm_device *);
@@ -558,6 +604,13 @@ extern void nv04_timer_takedown(struct drm_device *);
 extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,
                                 unsigned long arg);
 
+/* nouveau_buffer.c */
+extern struct drm_bo_driver nouveau_bo_driver;
+
+/* nouveau_fence.c */
+extern struct drm_fence_driver nouveau_fence_driver;
+extern void nouveau_fence_handler(struct drm_device *dev, int channel);
+
 #if defined(__powerpc__)
 #define NV_READ(reg)        in_be32((void __iomem *)(dev_priv->mmio)->handle + (reg) )
 #define NV_WRITE(reg,val)   out_be32((void __iomem *)(dev_priv->mmio)->handle + (reg) , (val) )
@@ -579,4 +632,3 @@ extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,
 #define INSTANCE_WR(o,i,v) NV_WI32((o)->im_pramin->start + ((i)<<2), (v))
 
 #endif /* __NOUVEAU_DRV_H__ */
-