162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2018 Red Hat Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1262306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci#include "base.h" 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#include <nvif/push507c.h> 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#include <nvhw/class/cl827c.h> 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistatic int 2962306a36Sopenharmony_cibase827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 3262306a36Sopenharmony_ci int ret; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 13))) 3562306a36Sopenharmony_ci return ret; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci PUSH_MTHD(push, NV827C, SET_PRESENT_CONTROL, 3862306a36Sopenharmony_ci NVVAL(NV827C, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) | 3962306a36Sopenharmony_ci NVVAL(NV827C, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval)); 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci PUSH_MTHD(push, NV827C, SET_CONTEXT_DMAS_ISO(0), asyw->image.handle, 1); 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci if (asyw->image.format == NV827C_SURFACE_SET_PARAMS_FORMAT_RF16_GF16_BF16_AF16) { 4462306a36Sopenharmony_ci PUSH_MTHD(push, NV827C, SET_PROCESSING, 4562306a36Sopenharmony_ci NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, ENABLE), 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci SET_CONVERSION, 4862306a36Sopenharmony_ci NVVAL(NV827C, SET_CONVERSION, GAIN, 0) | 4962306a36Sopenharmony_ci NVVAL(NV827C, SET_CONVERSION, OFS, 0x64)); 5062306a36Sopenharmony_ci } else { 5162306a36Sopenharmony_ci PUSH_MTHD(push, NV827C, SET_PROCESSING, 5262306a36Sopenharmony_ci NVDEF(NV827C, SET_PROCESSING, USE_GAIN_OFS, DISABLE), 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci SET_CONVERSION, 5562306a36Sopenharmony_ci NVVAL(NV827C, SET_CONVERSION, GAIN, 0) | 5662306a36Sopenharmony_ci NVVAL(NV827C, SET_CONVERSION, OFS, 0)); 5762306a36Sopenharmony_ci } 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci PUSH_MTHD(push, NV827C, SURFACE_SET_OFFSET(0, 0), asyw->image.offset[0] >> 8, 6062306a36Sopenharmony_ci SURFACE_SET_OFFSET(0, 1), 0x00000000, 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci SURFACE_SET_SIZE(0), 6362306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_SIZE, WIDTH, asyw->image.w) | 6462306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_SIZE, HEIGHT, asyw->image.h), 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci SURFACE_SET_STORAGE(0), 6762306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) | 6862306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.pitch[0] >> 8) | 6962306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) | 7062306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout), 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci SURFACE_SET_PARAMS(0), 7362306a36Sopenharmony_ci NVVAL(NV827C, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) | 7462306a36Sopenharmony_ci NVDEF(NV827C, SURFACE_SET_PARAMS, SUPER_SAMPLE, X1_AA) | 7562306a36Sopenharmony_ci NVDEF(NV827C, SURFACE_SET_PARAMS, GAMMA, LINEAR) | 7662306a36Sopenharmony_ci NVDEF(NV827C, SURFACE_SET_PARAMS, LAYOUT, FRM)); 7762306a36Sopenharmony_ci return 0; 7862306a36Sopenharmony_ci} 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistatic const struct nv50_wndw_func 8162306a36Sopenharmony_cibase827c = { 8262306a36Sopenharmony_ci .acquire = base507c_acquire, 8362306a36Sopenharmony_ci .release = base507c_release, 8462306a36Sopenharmony_ci .sema_set = base507c_sema_set, 8562306a36Sopenharmony_ci .sema_clr = base507c_sema_clr, 8662306a36Sopenharmony_ci .ntfy_reset = base507c_ntfy_reset, 8762306a36Sopenharmony_ci .ntfy_set = base507c_ntfy_set, 8862306a36Sopenharmony_ci .ntfy_clr = base507c_ntfy_clr, 8962306a36Sopenharmony_ci .ntfy_wait_begun = base507c_ntfy_wait_begun, 9062306a36Sopenharmony_ci .olut_core = 1, 9162306a36Sopenharmony_ci .xlut_set = base507c_xlut_set, 9262306a36Sopenharmony_ci .xlut_clr = base507c_xlut_clr, 9362306a36Sopenharmony_ci .image_set = base827c_image_set, 9462306a36Sopenharmony_ci .image_clr = base507c_image_clr, 9562306a36Sopenharmony_ci .update = base507c_update, 9662306a36Sopenharmony_ci}; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ciint 9962306a36Sopenharmony_cibase827c_new(struct nouveau_drm *drm, int head, s32 oclass, 10062306a36Sopenharmony_ci struct nv50_wndw **pwndw) 10162306a36Sopenharmony_ci{ 10262306a36Sopenharmony_ci return base507c_new_(&base827c, base507c_format, drm, head, oclass, 10362306a36Sopenharmony_ci 0x00000002 << (head * 8), pwndw); 10462306a36Sopenharmony_ci} 105