1 /* 2 * Copyright 2010 Red Hat Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: Ben Skeggs 23 */ 24 25 #ifndef __NVC0_GRAPH_H__ 26 #define __NVC0_GRAPH_H__ 27 28 #include <core/client.h> 29 #include <core/handle.h> 30 #include <core/gpuobj.h> 31 #include <core/option.h> 32 33 #include <nvif/unpack.h> 34 #include <nvif/class.h> 35 36 #include <subdev/fb.h> 37 #include <subdev/vm.h> 38 #include <subdev/bar.h> 39 #include <subdev/timer.h> 40 #include <subdev/mc.h> 41 #include <subdev/ltc.h> 42 43 #include <engine/fifo.h> 44 #include <engine/graph.h> 45 46 #include "fuc/os.h" 47 48 #define GPC_MAX 32 49 #define TPC_MAX (GPC_MAX * 8) 50 51 #define ROP_BCAST(r) (0x408800 + (r)) 52 #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) 53 #define GPC_BCAST(r) (0x418000 + (r)) 54 #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) 55 #define PPC_UNIT(t, m, r) (0x503000 + (t) * 0x8000 + (m) * 0x200 + (r)) 56 #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) 57 58 struct nvc0_graph_data { 59 u32 size; 60 u32 align; 61 u32 access; 62 }; 63 64 struct nvc0_graph_mmio { 65 u32 addr; 66 u32 data; 67 u32 shift; 68 int buffer; 69 }; 70 71 struct nvc0_graph_fuc { 72 u32 *data; 73 u32 size; 74 }; 75 76 struct nvc0_graph_zbc_color { 77 u32 format; 78 u32 ds[4]; 79 u32 l2[4]; 80 }; 81 82 struct nvc0_graph_zbc_depth { 83 u32 format; 84 u32 ds; 85 u32 l2; 86 }; 87 88 struct nvc0_graph_priv { 89 struct nouveau_graph base; 90 91 struct nvc0_graph_fuc fuc409c; 92 struct nvc0_graph_fuc fuc409d; 93 struct nvc0_graph_fuc fuc41ac; 94 struct nvc0_graph_fuc fuc41ad; 95 bool firmware; 96 97 struct nvc0_graph_zbc_color zbc_color[NOUVEAU_LTC_MAX_ZBC_CNT]; 98 struct nvc0_graph_zbc_depth zbc_depth[NOUVEAU_LTC_MAX_ZBC_CNT]; 99 100 u8 rop_nr; 101 u8 gpc_nr; 102 u8 tpc_nr[GPC_MAX]; 103 u8 tpc_total; 104 u8 ppc_nr[GPC_MAX]; 105 u8 ppc_tpc_nr[GPC_MAX][4]; 106 107 struct nouveau_gpuobj *unk4188b4; 108 struct nouveau_gpuobj *unk4188b8; 109 110 struct nvc0_graph_data mmio_data[4]; 111 struct nvc0_graph_mmio mmio_list[4096/8]; 112 u32 size; 113 u32 *data; 114 115 u8 magic_not_rop_nr; 116 }; 117 118 struct nvc0_graph_chan { 119 struct nouveau_graph_chan base; 120 121 struct nouveau_gpuobj *mmio; 122 struct nouveau_vma mmio_vma; 123 int mmio_nr; 124 struct { 125 struct nouveau_gpuobj *mem; 126 struct nouveau_vma vma; 127 } data[4]; 128 }; 129 130 int nvc0_graph_context_ctor(struct nouveau_object *, struct nouveau_object *, 131 struct nouveau_oclass *, void *, u32, 132 struct nouveau_object **); 133 void nvc0_graph_context_dtor(struct nouveau_object *); 134 135 void nvc0_graph_ctxctl_debug(struct nvc0_graph_priv *); 136 137 u64 nvc0_graph_units(struct nouveau_graph *); 138 int nvc0_graph_ctor(struct nouveau_object *, struct nouveau_object *, 139 struct nouveau_oclass *, void *data, u32 size, 140 struct nouveau_object **); 141 void nvc0_graph_dtor(struct nouveau_object *); 142 int nvc0_graph_init(struct nouveau_object *); 143 void nvc0_graph_zbc_init(struct nvc0_graph_priv *); 144 145 int nve4_graph_fini(struct nouveau_object *, bool); 146 int nve4_graph_init(struct nouveau_object *); 147 148 int nvf0_graph_fini(struct nouveau_object *, bool); 149 150 extern struct nouveau_ofuncs nvc0_fermi_ofuncs; 151 152 extern struct nouveau_oclass nvc0_graph_sclass[]; 153 extern struct nouveau_omthds nvc0_graph_9097_omthds[]; 154 extern struct nouveau_omthds nvc0_graph_90c0_omthds[]; 155 extern struct nouveau_oclass nvc8_graph_sclass[]; 156 extern struct nouveau_oclass nvf0_graph_sclass[]; 157 158 struct nvc0_graph_init { 159 u32 addr; 160 u8 count; 161 u8 pitch; 162 u32 data; 163 }; 164 165 struct nvc0_graph_pack { 166 const struct nvc0_graph_init *init; 167 u32 type; 168 }; 169 170 #define pack_for_each_init(init, pack, head) \ 171 for (pack = head; pack && pack->init; pack++) \ 172 for (init = pack->init; init && init->count; init++) 173 174 struct nvc0_graph_ucode { 175 struct nvc0_graph_fuc code; 176 struct nvc0_graph_fuc data; 177 }; 178 179 extern struct nvc0_graph_ucode nvc0_graph_fecs_ucode; 180 extern struct nvc0_graph_ucode nvc0_graph_gpccs_ucode; 181 182 extern struct nvc0_graph_ucode nvf0_graph_fecs_ucode; 183 extern struct nvc0_graph_ucode nvf0_graph_gpccs_ucode; 184 185 struct nvc0_graph_oclass { 186 struct nouveau_oclass base; 187 struct nouveau_oclass **cclass; 188 struct nouveau_oclass *sclass; 189 const struct nvc0_graph_pack *mmio; 190 struct { 191 struct nvc0_graph_ucode *ucode; 192 } fecs; 193 struct { 194 struct nvc0_graph_ucode *ucode; 195 } gpccs; 196 int ppc_nr; 197 }; 198 199 void nvc0_graph_mmio(struct nvc0_graph_priv *, const struct nvc0_graph_pack *); 200 void nvc0_graph_icmd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *); 201 void nvc0_graph_mthd(struct nvc0_graph_priv *, const struct nvc0_graph_pack *); 202 int nvc0_graph_init_ctxctl(struct nvc0_graph_priv *); 203 204 /* register init value lists */ 205 206 extern const struct nvc0_graph_init nvc0_graph_init_main_0[]; 207 extern const struct nvc0_graph_init nvc0_graph_init_fe_0[]; 208 extern const struct nvc0_graph_init nvc0_graph_init_pri_0[]; 209 extern const struct nvc0_graph_init nvc0_graph_init_rstr2d_0[]; 210 extern const struct nvc0_graph_init nvc0_graph_init_pd_0[]; 211 extern const struct nvc0_graph_init nvc0_graph_init_ds_0[]; 212 extern const struct nvc0_graph_init nvc0_graph_init_scc_0[]; 213 extern const struct nvc0_graph_init nvc0_graph_init_prop_0[]; 214 extern const struct nvc0_graph_init nvc0_graph_init_gpc_unk_0[]; 215 extern const struct nvc0_graph_init nvc0_graph_init_setup_0[]; 216 extern const struct nvc0_graph_init nvc0_graph_init_crstr_0[]; 217 extern const struct nvc0_graph_init nvc0_graph_init_setup_1[]; 218 extern const struct nvc0_graph_init nvc0_graph_init_zcull_0[]; 219 extern const struct nvc0_graph_init nvc0_graph_init_gpm_0[]; 220 extern const struct nvc0_graph_init nvc0_graph_init_gpc_unk_1[]; 221 extern const struct nvc0_graph_init nvc0_graph_init_gcc_0[]; 222 extern const struct nvc0_graph_init nvc0_graph_init_tpccs_0[]; 223 extern const struct nvc0_graph_init nvc0_graph_init_tex_0[]; 224 extern const struct nvc0_graph_init nvc0_graph_init_pe_0[]; 225 extern const struct nvc0_graph_init nvc0_graph_init_l1c_0[]; 226 extern const struct nvc0_graph_init nvc0_graph_init_wwdx_0[]; 227 extern const struct nvc0_graph_init nvc0_graph_init_tpccs_1[]; 228 extern const struct nvc0_graph_init nvc0_graph_init_mpc_0[]; 229 extern const struct nvc0_graph_init nvc0_graph_init_be_0[]; 230 extern const struct nvc0_graph_init nvc0_graph_init_fe_1[]; 231 extern const struct nvc0_graph_init nvc0_graph_init_pe_1[]; 232 233 extern const struct nvc0_graph_init nvc4_graph_init_ds_0[]; 234 extern const struct nvc0_graph_init nvc4_graph_init_tex_0[]; 235 extern const struct nvc0_graph_init nvc4_graph_init_sm_0[]; 236 237 extern const struct nvc0_graph_init nvc1_graph_init_gpc_unk_0[]; 238 extern const struct nvc0_graph_init nvc1_graph_init_setup_1[]; 239 240 extern const struct nvc0_graph_init nvd9_graph_init_pd_0[]; 241 extern const struct nvc0_graph_init nvd9_graph_init_ds_0[]; 242 extern const struct nvc0_graph_init nvd9_graph_init_prop_0[]; 243 extern const struct nvc0_graph_init nvd9_graph_init_gpm_0[]; 244 extern const struct nvc0_graph_init nvd9_graph_init_gpc_unk_1[]; 245 extern const struct nvc0_graph_init nvd9_graph_init_tex_0[]; 246 extern const struct nvc0_graph_init nvd9_graph_init_sm_0[]; 247 extern const struct nvc0_graph_init nvd9_graph_init_fe_1[]; 248 249 extern const struct nvc0_graph_init nvd7_graph_init_pes_0[]; 250 extern const struct nvc0_graph_init nvd7_graph_init_wwdx_0[]; 251 extern const struct nvc0_graph_init nvd7_graph_init_cbm_0[]; 252 253 extern const struct nvc0_graph_init nve4_graph_init_main_0[]; 254 extern const struct nvc0_graph_init nve4_graph_init_tpccs_0[]; 255 extern const struct nvc0_graph_init nve4_graph_init_pe_0[]; 256 extern const struct nvc0_graph_init nve4_graph_init_be_0[]; 257 extern const struct nvc0_graph_pack nve4_graph_pack_mmio[]; 258 259 extern const struct nvc0_graph_init nvf0_graph_init_fe_0[]; 260 extern const struct nvc0_graph_init nvf0_graph_init_ds_0[]; 261 extern const struct nvc0_graph_init nvf0_graph_init_sked_0[]; 262 extern const struct nvc0_graph_init nvf0_graph_init_cwd_0[]; 263 extern const struct nvc0_graph_init nvf0_graph_init_gpc_unk_1[]; 264 extern const struct nvc0_graph_init nvf0_graph_init_tex_0[]; 265 extern const struct nvc0_graph_init nvf0_graph_init_sm_0[]; 266 267 extern const struct nvc0_graph_init nv108_graph_init_gpc_unk_0[]; 268 269 270 #endif 271