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 | |
861d2107 BS |
8 | #include <subdev/vm.h> |
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 | ||
56 | struct { | |
57 | enum { | |
58 | NV_MEM_TYPE_UNKNOWN = 0, | |
59 | NV_MEM_TYPE_STOLEN, | |
60 | NV_MEM_TYPE_SGRAM, | |
61 | NV_MEM_TYPE_SDRAM, | |
62 | NV_MEM_TYPE_DDR1, | |
63 | NV_MEM_TYPE_DDR2, | |
64 | NV_MEM_TYPE_DDR3, | |
65 | NV_MEM_TYPE_GDDR2, | |
66 | NV_MEM_TYPE_GDDR3, | |
67 | NV_MEM_TYPE_GDDR4, | |
68 | NV_MEM_TYPE_GDDR5 | |
69 | } type; | |
70 | u64 stolen; | |
71 | u64 size; | |
72 | int ranks; | |
73 | ||
74 | int (*get)(struct nouveau_fb *, u64 size, u32 align, | |
75 | u32 size_nc, u32 type, struct nouveau_mem **); | |
76 | void (*put)(struct nouveau_fb *, struct nouveau_mem **); | |
77 | } ram; | |
78 | ||
79 | struct nouveau_mm vram; | |
80 | struct nouveau_mm tags; | |
81 | ||
82 | struct { | |
83 | struct nouveau_fb_tile region[16]; | |
84 | int regions; | |
85 | void (*init)(struct nouveau_fb *, int i, u32 addr, u32 size, | |
86 | u32 pitch, u32 flags, struct nouveau_fb_tile *); | |
67e9e9f6 BS |
87 | void (*comp)(struct nouveau_fb *, int i, u32 size, u32 flags, |
88 | struct nouveau_fb_tile *); | |
861d2107 BS |
89 | void (*fini)(struct nouveau_fb *, int i, |
90 | struct nouveau_fb_tile *); | |
91 | void (*prog)(struct nouveau_fb *, int i, | |
92 | struct nouveau_fb_tile *); | |
93 | } tile; | |
94 | }; | |
95 | ||
96 | static inline struct nouveau_fb * | |
97 | nouveau_fb(void *obj) | |
98 | { | |
99 | return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB]; | |
100 | } | |
101 | ||
102 | #define nouveau_fb_create(p,e,c,d) \ | |
103 | nouveau_subdev_create((p), (e), (c), 0, "PFB", "fb", (d)) | |
104 | int nouveau_fb_created(struct nouveau_fb *); | |
105 | void nouveau_fb_destroy(struct nouveau_fb *); | |
106 | int nouveau_fb_init(struct nouveau_fb *); | |
107 | #define nouveau_fb_fini(p,s) \ | |
108 | nouveau_subdev_fini(&(p)->base, (s)) | |
109 | ||
110 | void _nouveau_fb_dtor(struct nouveau_object *); | |
111 | int _nouveau_fb_init(struct nouveau_object *); | |
112 | #define _nouveau_fb_fini _nouveau_subdev_fini | |
113 | ||
114 | extern struct nouveau_oclass nv04_fb_oclass; | |
115 | extern struct nouveau_oclass nv10_fb_oclass; | |
116 | extern struct nouveau_oclass nv20_fb_oclass; | |
a8749af1 | 117 | extern struct nouveau_oclass nv25_fb_oclass; |
861d2107 | 118 | extern struct nouveau_oclass nv30_fb_oclass; |
11bac407 | 119 | extern struct nouveau_oclass nv35_fb_oclass; |
861d2107 | 120 | extern struct nouveau_oclass nv40_fb_oclass; |
4ae20745 BS |
121 | extern struct nouveau_oclass nv41_fb_oclass; |
122 | extern struct nouveau_oclass nv44_fb_oclass; | |
123 | extern struct nouveau_oclass nv46_fb_oclass; | |
124 | extern struct nouveau_oclass nv47_fb_oclass; | |
125 | extern struct nouveau_oclass nv49_fb_oclass; | |
126 | extern struct nouveau_oclass nv4e_fb_oclass; | |
861d2107 BS |
127 | extern struct nouveau_oclass nv50_fb_oclass; |
128 | extern struct nouveau_oclass nvc0_fb_oclass; | |
129 | ||
130 | struct nouveau_bios; | |
131 | int nouveau_fb_bios_memtype(struct nouveau_bios *); | |
132 | ||
133 | bool nv04_fb_memtype_valid(struct nouveau_fb *, u32 memtype); | |
134 | ||
135 | void nv10_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); | |
136 | ||
a8749af1 BS |
137 | void nv20_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, |
138 | u32 pitch, u32 flags, struct nouveau_fb_tile *); | |
139 | void nv20_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); | |
140 | void nv20_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); | |
141 | ||
11bac407 | 142 | int nv30_fb_init(struct nouveau_object *); |
861d2107 BS |
143 | void nv30_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size, |
144 | u32 pitch, u32 flags, struct nouveau_fb_tile *); | |
145 | void nv30_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *); | |
146 | ||
4ae20745 BS |
147 | int nv41_fb_init(struct nouveau_object *); |
148 | int nv44_fb_init(struct nouveau_object *); | |
149 | void nv41_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *); | |
150 | ||
861d2107 BS |
151 | void nv50_fb_vram_del(struct nouveau_fb *, struct nouveau_mem **); |
152 | void nv50_fb_trap(struct nouveau_fb *, int display); | |
861d2107 BS |
153 | |
154 | #endif |