1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2018 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef GFX8_CONTEXT_H 25bf215546Sopenharmony_ci#define GFX8_CONTEXT_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_cistatic inline void gfx8_render_context_init(const struct intel_context_parameters *params, 28bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 29bf215546Sopenharmony_ci{ 30bf215546Sopenharmony_ci *size = CONTEXT_RENDER_SIZE; 31bf215546Sopenharmony_ci if (!data) 32bf215546Sopenharmony_ci return; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 35bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 36bf215546Sopenharmony_ci 0x2244 /* CONTEXT_CONTROL */, 37bf215546Sopenharmony_ci 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 38bf215546Sopenharmony_ci 0x2034 /* RING_HEAD */, 0, 39bf215546Sopenharmony_ci 0x2030 /* RING_TAIL */, 0, 40bf215546Sopenharmony_ci 0x2038 /* RING_BUFFER_START */, params->ring_addr, 41bf215546Sopenharmony_ci 0x203C /* RING_BUFFER_CONTROL */, (params->ring_addr - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 42bf215546Sopenharmony_ci 0x2168 /* BB_HEAD_U */, 0, 43bf215546Sopenharmony_ci 0x2140 /* BB_HEAD_L */, 0, 44bf215546Sopenharmony_ci 0x2110 /* BB_STATE */, 0, 45bf215546Sopenharmony_ci 0x211C /* SECOND_BB_HEAD_U */, 0, 46bf215546Sopenharmony_ci 0x2114 /* SECOND_BB_HEAD_L */, 0, 47bf215546Sopenharmony_ci 0x2118 /* SECOND_BB_STATE */, 0, 48bf215546Sopenharmony_ci 0x21C0 /* BB_PER_CTX_PTR */, 0, 49bf215546Sopenharmony_ci 0x21C4 /* RCS_INDIRECT_CTX */, 0, 50bf215546Sopenharmony_ci 0x21C8 /* RCS_INDIRECT_CTX_OFFSET */, 0); 51bf215546Sopenharmony_ci /* MI_NOOP */ 52bf215546Sopenharmony_ci *data++ = 0; 53bf215546Sopenharmony_ci *data++ = 0; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci *data++ = 0; /* MI_NOOP */ 56bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 57bf215546Sopenharmony_ci 0x23A8 /* CTX_TIMESTAMP */, 0, 58bf215546Sopenharmony_ci 0x228C /* PDP3_UDW */, 0, 59bf215546Sopenharmony_ci 0x2288 /* PDP3_LDW */, 0, 60bf215546Sopenharmony_ci 0x2284 /* PDP2_UDW */, 0, 61bf215546Sopenharmony_ci 0x2280 /* PDP2_LDW */, 0, 62bf215546Sopenharmony_ci 0x227C /* PDP1_UDW */, 0, 63bf215546Sopenharmony_ci 0x2278 /* PDP1_LDW */, 0, 64bf215546Sopenharmony_ci 0x2274 /* PDP0_UDW */, params->pml4_addr >> 32, 65bf215546Sopenharmony_ci 0x2270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 66bf215546Sopenharmony_ci /* MI_NOOP */ 67bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 68bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 71bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, 0, 72bf215546Sopenharmony_ci 0x20C8 /* R_PWR_CLK_STATE */, 0x7FFFFFFF); 73bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END; 74bf215546Sopenharmony_ci} 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_cistatic inline void gfx8_blitter_context_init(const struct intel_context_parameters *params, 77bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 78bf215546Sopenharmony_ci{ 79bf215546Sopenharmony_ci *size = CONTEXT_OTHER_SIZE; 80bf215546Sopenharmony_ci if (!data) 81bf215546Sopenharmony_ci return; 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 84bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 85bf215546Sopenharmony_ci 0x22244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 86bf215546Sopenharmony_ci 0x22034 /* RING_HEAD */, 0, 87bf215546Sopenharmony_ci 0x22030 /* RING_TAIL */, 0, 88bf215546Sopenharmony_ci 0x22038 /* RING_BUFFER_START */, params->ring_addr, 89bf215546Sopenharmony_ci 0x2203C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 90bf215546Sopenharmony_ci 0x22168 /* BB_HEAD_U */, 0, 91bf215546Sopenharmony_ci 0x22140 /* BB_HEAD_L */, 0, 92bf215546Sopenharmony_ci 0x22110 /* BB_STATE */, 0, 93bf215546Sopenharmony_ci 0x2211C /* SECOND_BB_HEAD_U */, 0, 94bf215546Sopenharmony_ci 0x22114 /* SECOND_BB_HEAD_L */, 0, 95bf215546Sopenharmony_ci 0x22118 /* SECOND_BB_STATE */, 0); 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci for (int i = 0; i < 8; i++) 98bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci *data = 0 /* MI_NOOP */; 101bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 102bf215546Sopenharmony_ci 0x223A8 /* CTX_TIMESTAMP */, 0, 103bf215546Sopenharmony_ci 0x2228C /* PDP3_UDW */, 0, 104bf215546Sopenharmony_ci 0x22288 /* PDP3_LDW */, 0, 105bf215546Sopenharmony_ci 0x22284 /* PDP2_UDW */, 0, 106bf215546Sopenharmony_ci 0x22280 /* PDP2_LDW */, 0, 107bf215546Sopenharmony_ci 0x2227C /* PDP1_UDW */, 0, 108bf215546Sopenharmony_ci 0x22278 /* PDP1_LDW */, 0, 109bf215546Sopenharmony_ci 0x22274 /* PDP0_UDW */, params->pml4_addr >> 32, 110bf215546Sopenharmony_ci 0x22270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 113bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END; 116bf215546Sopenharmony_ci} 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_cistatic inline void gfx8_video_context_init(const struct intel_context_parameters *params, 119bf215546Sopenharmony_ci uint32_t *data, uint32_t *size) 120bf215546Sopenharmony_ci{ 121bf215546Sopenharmony_ci *size = CONTEXT_OTHER_SIZE; 122bf215546Sopenharmony_ci if (!data) 123bf215546Sopenharmony_ci return; 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 126bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 127bf215546Sopenharmony_ci 0x1C244 /* CONTEXT_CONTROL */, 0x90009 /* Inhibit Synchronous Context Switch | Engine Context Restore Inhibit */, 128bf215546Sopenharmony_ci 0x1C034 /* RING_HEAD */, 0, 129bf215546Sopenharmony_ci 0x1C030 /* RING_TAIL */, 0, 130bf215546Sopenharmony_ci 0x1C038 /* RING_BUFFER_START */, params->ring_addr, 131bf215546Sopenharmony_ci 0x1C03C /* RING_BUFFER_CONTROL */, (params->ring_size - 4096) | 1 /* Buffer Length | Ring Buffer Enable */, 132bf215546Sopenharmony_ci 0x1C168 /* BB_HEAD_U */, 0, 133bf215546Sopenharmony_ci 0x1C140 /* BB_HEAD_L */, 0, 134bf215546Sopenharmony_ci 0x1C110 /* BB_STATE */, 0, 135bf215546Sopenharmony_ci 0x1C11C /* SECOND_BB_HEAD_U */, 0, 136bf215546Sopenharmony_ci 0x1C114 /* SECOND_BB_HEAD_L */, 0, 137bf215546Sopenharmony_ci 0x1C118 /* SECOND_BB_STATE */, 0); 138bf215546Sopenharmony_ci for (int i = 0; i < 8; i++) 139bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 140bf215546Sopenharmony_ci 141bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 142bf215546Sopenharmony_ci MI_LOAD_REGISTER_IMM_vals(data, MI_LRI_FORCE_POSTED, 143bf215546Sopenharmony_ci 0x1C3A8 /* CTX_TIMESTAMP */, 0, 144bf215546Sopenharmony_ci 0x1C28C /* PDP3_UDW */, 0, 145bf215546Sopenharmony_ci 0x1C288 /* PDP3_LDW */, 0, 146bf215546Sopenharmony_ci 0x1C284 /* PDP2_UDW */, 0, 147bf215546Sopenharmony_ci 0x1C280 /* PDP2_LDW */, 0, 148bf215546Sopenharmony_ci 0x1C27C /* PDP1_UDW */, 0, 149bf215546Sopenharmony_ci 0x1C278 /* PDP1_LDW */, 0, 150bf215546Sopenharmony_ci 0x1C274 /* PDP0_UDW */, params->pml4_addr >> 32, 151bf215546Sopenharmony_ci 0x1C270 /* PDP0_LDW */, params->pml4_addr & 0xffffffff); 152bf215546Sopenharmony_ci for (int i = 0; i < 12; i++) 153bf215546Sopenharmony_ci *data++ = 0 /* MI_NOOP */; 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci *data++ = MI_BATCH_BUFFER_END; 156bf215546Sopenharmony_ci} 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci#endif /* GFX8_CONTEXT_H */ 159