Commit | Line | Data |
---|---|---|
861d2107 BS |
1 | #ifndef __NOUVEAU_FB_H__ |
2 | #define __NOUVEAU_FB_H__ | |
3 | ||
861d2107 BS |
4 | #include <core/subdev.h> |
5 | #include <core/device.h> | |
861d2107 | 6 | #include <core/mm.h> |
3863c9bc | 7 | |
5ce3bf3c | 8 | #include <subdev/mmu.h> |
861d2107 BS |
9 | |
10 | /* memory type/access flags, do not match hardware values */ | |
11 | #define NV_MEM_ACCESS_RO 1 | |
12 | #define NV_MEM_ACCESS_WO 2 | |
13 | #define NV_MEM_ACCESS_RW (NV_MEM_ACCESS_RO | NV_MEM_ACCESS_WO) | |
14 | #define NV_MEM_ACCESS_SYS 4 | |
15 | #define NV_MEM_ACCESS_VM 8 | |
16 | #define NV_MEM_ACCESS_NOSNOOP 16 | |
17 | ||
18 | #define NV_MEM_TARGET_VRAM 0 | |
19 | #define NV_MEM_TARGET_PCI 1 | |
20 | #define NV_MEM_TARGET_PCI_NOSNOOP 2 | |
21 | #define NV_MEM_TARGET_VM 3 | |
22 | #define NV_MEM_TARGET_GART 4 | |
23 | ||
24 | #define NV_MEM_TYPE_VM 0x7f | |
25 | #define NV_MEM_COMP_VM 0x03 | |
26 | ||
27 | struct nouveau_mem { | |
28 | struct drm_device *dev; | |
29 | ||
30 | struct nouveau_vma bar_vma; | |
31 | struct nouveau_vma vma[2]; | |
32 | u8 page_shift; | |
33 | ||
34 | struct nouveau_mm_node *tag; | |
35 | struct list_head regions; | |
36 | dma_addr_t *pages; | |
37 | u32 memtype; | |
38 | u64 offset; | |
39 | u64 size; | |
40 | struct sg_table *sg; | |
41 | }; | |
42 | ||
43 | struct nouveau_fb_tile { | |
44 | struct nouveau_mm_node *tag; | |
45 | u32 addr; | |
46 | u32 limit; | |
47 | u32 pitch; | |
48 | u32 zcomp; | |
49 | }; | |
50 | ||
861d2107 BS |
51 | struct nouveau_fb { |
52 | struct nouveau_subdev base; | |
53 | ||
54 | bool (*memtype_valid)(struct nouveau_fb *, u32 memtype); | |
55 | ||
dceef5d8 | 56 | struct nouveau_ram *ram; |
861d2107 BS |
57 | |
58 | struct nouveau_mm vram; | |
59 | struct nouveau_mm tags; | |
60 | ||
61 | struct { | |
62 | struct nouveau_fb_tile region[16]; | |
63 | int regions; | |
64 | void (*init)(struct nouveau_fb *, int i, u32 addr, u32 size, | |
65 | u32 pitch, u32 flags, struct nouveau_fb_tile *); | |
67e9e9f6 BS |
66 | void (*comp)(struct nouveau_fb *, int i, u32 size, u32 flags, |
67 | struct nouveau_fb_tile *); | |
861d2107 BS |
68 | void (*fini)(struct nouveau_fb *, int i, |
69 | struct nouveau_fb_tile *); | |
70 | void (*prog)(struct nouveau_fb *, int i, | |
71 | struct nouveau_fb_tile *); | |
72 | } tile; | |
73 | }; | |
74 | ||
75 | static inline struct nouveau_fb * | |
76 | nouveau_fb(void *obj) | |
77 | { | |
61b365a5 BS |
78 | /* fbram uses this before device subdev pointer is valid */ |
79 | if (nv_iclass(obj, NV_SUBDEV_CLASS) && | |
80 | nv_subidx(obj) == NVDEV_SUBDEV_FB) | |
81 | return obj; | |
82 | ||
2f4a58e8 | 83 | return (void *)nouveau_subdev(obj, NVDEV_SUBDEV_FB); |
861d2107 BS |
84 | } |
85 | ||
1e9fc30e BS |
86 | extern struct nouveau_oclass *nv04_fb_oclass; |
87 | extern struct nouveau_oclass *nv10_fb_oclass; | |
88 | extern struct nouveau_oclass *nv1a_fb_oclass; | |
89 | extern struct nouveau_oclass *nv20_fb_oclass; | |
90 | extern struct nouveau_oclass *nv25_fb_oclass; | |
91 | extern struct nouveau_oclass *nv30_fb_oclass; | |
92 | extern struct nouveau_oclass *nv35_fb_oclass; | |
93 | extern struct nouveau_oclass *nv36_fb_oclass; | |
94 | extern struct nouveau_oclass *nv40_fb_oclass; | |
95 | extern struct nouveau_oclass *nv41_fb_oclass; | |
96 | extern struct nouveau_oclass *nv44_fb_oclass; | |
97 | extern struct nouveau_oclass *nv46_fb_oclass; | |
98 | extern struct nouveau_oclass *nv47_fb_oclass; | |
99 | extern struct nouveau_oclass *nv49_fb_oclass; | |
100 | extern struct nouveau_oclass *nv4e_fb_oclass; | |
101 | extern struct nouveau_oclass *nv50_fb_oclass; | |
9ca3037e BS |
102 | extern struct nouveau_oclass *nv84_fb_oclass; |
103 | extern struct nouveau_oclass *nva3_fb_oclass; | |
104 | extern struct nouveau_oclass *nvaa_fb_oclass; | |
105 | extern struct nouveau_oclass *nvaf_fb_oclass; | |
1e9fc30e | 106 | extern struct nouveau_oclass *nvc0_fb_oclass; |
aae95ca7 | 107 | extern struct nouveau_oclass *nve0_fb_oclass; |
fef94f62 | 108 | extern struct nouveau_oclass *gk20a_fb_oclass; |
267dcb66 | 109 | extern struct nouveau_oclass *gm107_fb_oclass; |
861d2107 | 110 | |
b655f2bb BS |
111 | #include <subdev/bios/ramcfg.h> |
112 | ||
113 | struct nouveau_ram_data { | |
d26e7489 | 114 | struct list_head head; |
b655f2bb | 115 | struct nvbios_ramcfg bios; |
46bf1c38 | 116 | u32 freq; |
b655f2bb BS |
117 | }; |
118 | ||
dceef5d8 BS |
119 | struct nouveau_ram { |
120 | struct nouveau_object base; | |
121 | enum { | |
122 | NV_MEM_TYPE_UNKNOWN = 0, | |
123 | NV_MEM_TYPE_STOLEN, | |
124 | NV_MEM_TYPE_SGRAM, | |
125 | NV_MEM_TYPE_SDRAM, | |
126 | NV_MEM_TYPE_DDR1, | |
127 | NV_MEM_TYPE_DDR2, | |
128 | NV_MEM_TYPE_DDR3, | |
129 | NV_MEM_TYPE_GDDR2, | |
130 | NV_MEM_TYPE_GDDR3, | |
131 | NV_MEM_TYPE_GDDR4, | |
132 | NV_MEM_TYPE_GDDR5 | |
133 | } type; | |
134 | u64 stolen; | |
135 | u64 size; | |
136 | u32 tags; | |
5f8e2567 | 137 | |
dceef5d8 BS |
138 | int ranks; |
139 | int parts; | |
de1c4e28 | 140 | int part_mask; |
150ccf16 | 141 | |
dceef5d8 BS |
142 | int (*get)(struct nouveau_fb *, u64 size, u32 align, |
143 | u32 size_nc, u32 type, struct nouveau_mem **); | |
144 | void (*put)(struct nouveau_fb *, struct nouveau_mem **); | |
aae95ca7 | 145 | |
7c856522 BS |
146 | int (*calc)(struct nouveau_fb *, u32 freq); |
147 | int (*prog)(struct nouveau_fb *); | |
148 | void (*tidy)(struct nouveau_fb *); | |
aae95ca7 BS |
149 | u32 freq; |
150 | u32 mr[16]; | |
d394fb12 | 151 | u32 mr1_nuts; |
b655f2bb BS |
152 | |
153 | struct nouveau_ram_data *next; | |
46bf1c38 BS |
154 | struct nouveau_ram_data former; |
155 | struct nouveau_ram_data xition; | |
b655f2bb | 156 | struct nouveau_ram_data target; |
dceef5d8 | 157 | }; |
861d2107 BS |
158 | |
159 | #endif |