d2384c9fd2ab2618e6e739dea930432298d370e1
[linux-2.6-block.git] / drivers / gpu / drm / nouveau / nvkm / engine / fifo / gk104.h
1 #ifndef __GK104_FIFO_H__
2 #define __GK104_FIFO_H__
3 #define gk104_fifo(p) container_of((p), struct gk104_fifo, base)
4 #include "priv.h"
5
6 #include <subdev/mmu.h>
7
8 struct gk104_fifo_chan;
9 struct gk104_fifo_engn {
10         struct nvkm_memory *runlist[2];
11         int cur_runlist;
12         wait_queue_head_t wait;
13         struct list_head chan;
14 };
15
16 struct gk104_fifo {
17         struct nvkm_fifo base;
18
19         struct work_struct fault;
20         u64 mask;
21
22         int pbdma_nr;
23
24         struct gk104_fifo_engn engine[7];
25         struct {
26                 struct nvkm_memory *mem;
27                 struct nvkm_vma bar;
28         } user;
29 };
30
31 int gk104_fifo_new_(const struct nvkm_fifo_func *, struct nvkm_device *,
32                     int index, int nr, struct nvkm_fifo **);
33 void *gk104_fifo_dtor(struct nvkm_fifo *);
34 int gk104_fifo_oneinit(struct nvkm_fifo *);
35 void gk104_fifo_init(struct nvkm_fifo *);
36 void gk104_fifo_fini(struct nvkm_fifo *);
37 void gk104_fifo_intr(struct nvkm_fifo *);
38 void gk104_fifo_uevent_init(struct nvkm_fifo *);
39 void gk104_fifo_uevent_fini(struct nvkm_fifo *);
40 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
41 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
42 void gk104_fifo_runlist_commit(struct gk104_fifo *, u32 engine);
43
44 static inline u64
45 gk104_fifo_engine_subdev(int engine)
46 {
47         switch (engine) {
48         case 0: return (1ULL << NVKM_ENGINE_GR) |
49                        (1ULL << NVKM_ENGINE_SW) |
50                        (1ULL << NVKM_ENGINE_CE2);
51         case 1: return (1ULL << NVKM_ENGINE_MSPDEC);
52         case 2: return (1ULL << NVKM_ENGINE_MSPPP);
53         case 3: return (1ULL << NVKM_ENGINE_MSVLD);
54         case 4: return (1ULL << NVKM_ENGINE_CE0);
55         case 5: return (1ULL << NVKM_ENGINE_CE1);
56         case 6: return (1ULL << NVKM_ENGINE_MSENC);
57         default:
58                 WARN_ON(1);
59                 return 0;
60         }
61 }
62
63 static inline int
64 gk104_fifo_subdev_engine(int subdev)
65 {
66         switch (subdev) {
67         case NVKM_ENGINE_GR:
68         case NVKM_ENGINE_SW:
69         case NVKM_ENGINE_CE2   : return 0;
70         case NVKM_ENGINE_MSPDEC: return 1;
71         case NVKM_ENGINE_MSPPP : return 2;
72         case NVKM_ENGINE_MSVLD : return 3;
73         case NVKM_ENGINE_CE0   : return 4;
74         case NVKM_ENGINE_CE1   : return 5;
75         case NVKM_ENGINE_MSENC : return 6;
76         default:
77                 WARN_ON(1);
78                 return 0;
79         }
80 }
81 #endif