drm: userspace rip out TTM API
[platform/upstream/libdrm.git] / shared-core / nouveau_drv.h
index d35d670..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;
@@ -127,6 +139,7 @@ struct nouveau_channel
        /* 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 */
@@ -146,9 +159,6 @@ struct nouveau_drm_channel {
        /* Notifiers */
        uint32_t notify0_offset;
 
-        /* Fences */
-        uint32_t next_sequence;
-
        /* Buffer moves */
        uint32_t m2mf_dma_source;
        uint32_t m2mf_dma_destin;
@@ -193,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 *);
@@ -221,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,
@@ -241,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;
@@ -279,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;
 
@@ -295,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 {         \
@@ -335,15 +375,18 @@ 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 *);
@@ -364,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 *,
@@ -422,7 +464,7 @@ 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 */
@@ -452,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 *);
@@ -473,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 *);
@@ -587,4 +632,3 @@ extern void nouveau_fence_handler(struct drm_device *dev, int channel);
 #define INSTANCE_WR(o,i,v) NV_WI32((o)->im_pramin->start + ((i)<<2), (v))
 
 #endif /* __NOUVEAU_DRV_H__ */
-