• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __NOUVEAU_FB_H__
2 #define __NOUVEAU_FB_H__
3 
4 #include <core/subdev.h>
5 #include <core/device.h>
6 #include <core/mm.h>
7 
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 
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 
73 		int ranks;
74 		int parts;
75 
76 		int  (*init)(struct nouveau_fb *);
77 		int  (*get)(struct nouveau_fb *, u64 size, u32 align,
78 			    u32 size_nc, u32 type, struct nouveau_mem **);
79 		void (*put)(struct nouveau_fb *, struct nouveau_mem **);
80 	} ram;
81 
82 	struct nouveau_mm vram;
83 	struct nouveau_mm tags;
84 
85 	struct {
86 		struct nouveau_fb_tile region[16];
87 		int regions;
88 		void (*init)(struct nouveau_fb *, int i, u32 addr, u32 size,
89 			     u32 pitch, u32 flags, struct nouveau_fb_tile *);
90 		void (*comp)(struct nouveau_fb *, int i, u32 size, u32 flags,
91 			     struct nouveau_fb_tile *);
92 		void (*fini)(struct nouveau_fb *, int i,
93 			     struct nouveau_fb_tile *);
94 		void (*prog)(struct nouveau_fb *, int i,
95 			     struct nouveau_fb_tile *);
96 	} tile;
97 };
98 
99 static inline struct nouveau_fb *
nouveau_fb(void * obj)100 nouveau_fb(void *obj)
101 {
102 	return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_FB];
103 }
104 
105 #define nouveau_fb_create(p,e,c,d)                                             \
106 	nouveau_subdev_create((p), (e), (c), 0, "PFB", "fb", (d))
107 int  nouveau_fb_preinit(struct nouveau_fb *);
108 void nouveau_fb_destroy(struct nouveau_fb *);
109 int  nouveau_fb_init(struct nouveau_fb *);
110 #define nouveau_fb_fini(p,s)                                                   \
111 	nouveau_subdev_fini(&(p)->base, (s))
112 
113 void _nouveau_fb_dtor(struct nouveau_object *);
114 int  _nouveau_fb_init(struct nouveau_object *);
115 #define _nouveau_fb_fini _nouveau_subdev_fini
116 
117 extern struct nouveau_oclass nv04_fb_oclass;
118 extern struct nouveau_oclass nv10_fb_oclass;
119 extern struct nouveau_oclass nv1a_fb_oclass;
120 extern struct nouveau_oclass nv20_fb_oclass;
121 extern struct nouveau_oclass nv25_fb_oclass;
122 extern struct nouveau_oclass nv30_fb_oclass;
123 extern struct nouveau_oclass nv35_fb_oclass;
124 extern struct nouveau_oclass nv36_fb_oclass;
125 extern struct nouveau_oclass nv40_fb_oclass;
126 extern struct nouveau_oclass nv41_fb_oclass;
127 extern struct nouveau_oclass nv44_fb_oclass;
128 extern struct nouveau_oclass nv46_fb_oclass;
129 extern struct nouveau_oclass nv47_fb_oclass;
130 extern struct nouveau_oclass nv49_fb_oclass;
131 extern struct nouveau_oclass nv4e_fb_oclass;
132 extern struct nouveau_oclass nv50_fb_oclass;
133 extern struct nouveau_oclass nvc0_fb_oclass;
134 
135 struct nouveau_bios;
136 int  nouveau_fb_bios_memtype(struct nouveau_bios *);
137 
138 bool nv04_fb_memtype_valid(struct nouveau_fb *, u32 memtype);
139 
140 void nv10_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size,
141 		       u32 pitch, u32 flags, struct nouveau_fb_tile *);
142 void nv10_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *);
143 void nv10_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *);
144 
145 int  nv20_fb_vram_init(struct nouveau_fb *);
146 void nv20_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size,
147 		       u32 pitch, u32 flags, struct nouveau_fb_tile *);
148 void nv20_fb_tile_fini(struct nouveau_fb *, int i, struct nouveau_fb_tile *);
149 void nv20_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *);
150 
151 int  nv30_fb_init(struct nouveau_object *);
152 void nv30_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size,
153 		       u32 pitch, u32 flags, struct nouveau_fb_tile *);
154 
155 void nv40_fb_tile_comp(struct nouveau_fb *, int i, u32 size, u32 flags,
156 		       struct nouveau_fb_tile *);
157 
158 int  nv41_fb_vram_init(struct nouveau_fb *);
159 int  nv41_fb_init(struct nouveau_object *);
160 void nv41_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *);
161 
162 int  nv44_fb_vram_init(struct nouveau_fb *);
163 int  nv44_fb_init(struct nouveau_object *);
164 void nv44_fb_tile_prog(struct nouveau_fb *, int, struct nouveau_fb_tile *);
165 
166 void nv46_fb_tile_init(struct nouveau_fb *, int i, u32 addr, u32 size,
167 		       u32 pitch, u32 flags, struct nouveau_fb_tile *);
168 
169 void nv50_fb_vram_del(struct nouveau_fb *, struct nouveau_mem **);
170 
171 #endif
172