1ccd27db8SBen Skeggs /* 2ccd27db8SBen Skeggs * Copyright 2018 Red Hat Inc. 3ccd27db8SBen Skeggs * 4ccd27db8SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5ccd27db8SBen Skeggs * copy of this software and associated documentation files (the "Software"), 6ccd27db8SBen Skeggs * to deal in the Software without restriction, including without limitation 7ccd27db8SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8ccd27db8SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9ccd27db8SBen Skeggs * Software is furnished to do so, subject to the following conditions: 10ccd27db8SBen Skeggs * 11ccd27db8SBen Skeggs * The above copyright notice and this permission notice shall be included in 12ccd27db8SBen Skeggs * all copies or substantial portions of the Software. 13ccd27db8SBen Skeggs * 14ccd27db8SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15ccd27db8SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16ccd27db8SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17ccd27db8SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18ccd27db8SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ccd27db8SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20ccd27db8SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 21ccd27db8SBen Skeggs */ 22ccd27db8SBen Skeggs #include "base.h" 23ccd27db8SBen Skeggs 246d6e11e2SBen Skeggs #include <nvif/push507c.h> 256d6e11e2SBen Skeggs 26*f844eb48SBen Skeggs #include <nvhw/class/cl827c.h> 27*f844eb48SBen Skeggs 286d6e11e2SBen Skeggs static int 29ccd27db8SBen Skeggs base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 30ccd27db8SBen Skeggs { 316d6e11e2SBen Skeggs struct nvif_push *push = wndw->wndw.push; 326d6e11e2SBen Skeggs int ret; 336d6e11e2SBen Skeggs 346d6e11e2SBen Skeggs if ((ret = PUSH_WAIT(push, 13))) 356d6e11e2SBen Skeggs return ret; 366d6e11e2SBen Skeggs 37*f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PRESENT_CONTROL, 38*f844eb48SBen Skeggs NVVAL(NV827C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) | 39*f844eb48SBen Skeggs NVVAL(NV827C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval)); 40*f844eb48SBen Skeggs 41*f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_CONTEXT_DMAS_ISO(0), asyw->image.handle, 1); 42*f844eb48SBen Skeggs 43*f844eb48SBen Skeggs if (asyw->image.format == NV827C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) { 44*f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PROCESSING, 45*f844eb48SBen Skeggs NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, ENABLE), 46*f844eb48SBen Skeggs 47*f844eb48SBen Skeggs SET_CONVERSION, 48*f844eb48SBen Skeggs NVVAL(NV827C, SET_CONVERSION, GAIN, 0) | 49*f844eb48SBen Skeggs NVVAL(NV827C, SET_CONVERSION, OFS, 0x64)); 5038a72243SIlia Mirkin } else { 51*f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SET_PROCESSING, 52*f844eb48SBen Skeggs NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, DISABLE)); 5338a72243SIlia Mirkin } 54*f844eb48SBen Skeggs 55*f844eb48SBen Skeggs PUSH_MTHD(push, NV827C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8, 56*f844eb48SBen Skeggs SURFACE_SET_OFFSET(0, 1), 0x00000000, 57*f844eb48SBen Skeggs 58*f844eb48SBen Skeggs SURFACE_SET_SIZE(0), 59*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) | 60*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h), 61*f844eb48SBen Skeggs 62*f844eb48SBen Skeggs SURFACE_SET_STORAGE(0), 63*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) | 64*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) | 65*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) | 66*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout), 67*f844eb48SBen Skeggs 68*f844eb48SBen Skeggs SURFACE_SET_PARAMS(0), 69*f844eb48SBen Skeggs NVVAL(NV827C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) | 70*f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) | 71*f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, GAMMA, LINEAR) | 72*f844eb48SBen Skeggs NVDEF(NV827C, SURFACE_SET_PARAMS, LAYOUT, FRM)); 736d6e11e2SBen Skeggs return 0; 74ccd27db8SBen Skeggs } 75ccd27db8SBen Skeggs 76ccd27db8SBen Skeggs static const struct nv50_wndw_func 77ccd27db8SBen Skeggs base827c = { 78ccd27db8SBen Skeggs .acquire = base507c_acquire, 79ccd27db8SBen Skeggs .release = base507c_release, 80ccd27db8SBen Skeggs .sema_set = base507c_sema_set, 81ccd27db8SBen Skeggs .sema_clr = base507c_sema_clr, 82ccd27db8SBen Skeggs .ntfy_reset = base507c_ntfy_reset, 83ccd27db8SBen Skeggs .ntfy_set = base507c_ntfy_set, 84ccd27db8SBen Skeggs .ntfy_clr = base507c_ntfy_clr, 85ccd27db8SBen Skeggs .ntfy_wait_begun = base507c_ntfy_wait_begun, 86119608a7SBen Skeggs .olut_core = 1, 87119608a7SBen Skeggs .xlut_set = base507c_xlut_set, 88119608a7SBen Skeggs .xlut_clr = base507c_xlut_clr, 89ccd27db8SBen Skeggs .image_set = base827c_image_set, 90ccd27db8SBen Skeggs .image_clr = base507c_image_clr, 91ccd27db8SBen Skeggs .update = base507c_update, 92ccd27db8SBen Skeggs }; 93ccd27db8SBen Skeggs 94ccd27db8SBen Skeggs int 95ccd27db8SBen Skeggs base827c_new(struct nouveau_drm *drm, int head, s32 oclass, 96ccd27db8SBen Skeggs struct nv50_wndw **pwndw) 97ccd27db8SBen Skeggs { 9853e0a3e7SBen Skeggs return base507c_new_(&base827c, base507c_format, drm, head, oclass, 9953e0a3e7SBen Skeggs 0x00000002 << (head * 8), pwndw); 100ccd27db8SBen Skeggs } 101