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 "head.h" 2362306a36Sopenharmony_ci#include "core.h" 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#include <nvif/push507c.h> 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include <nvhw/class/cl827d.h> 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistatic int 3062306a36Sopenharmony_cihead827d_curs_clr(struct nv50_head *head) 3162306a36Sopenharmony_ci{ 3262306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 3362306a36Sopenharmony_ci const int i = head->base.index; 3462306a36Sopenharmony_ci int ret; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 4))) 3762306a36Sopenharmony_ci return ret; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i), 4062306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) | 4162306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8) | 4262306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, W64_H64)); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), 0x00000000); 4562306a36Sopenharmony_ci return 0; 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic int 4962306a36Sopenharmony_cihead827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh) 5062306a36Sopenharmony_ci{ 5162306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 5262306a36Sopenharmony_ci const int i = head->base.index; 5362306a36Sopenharmony_ci int ret; 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 5))) 5662306a36Sopenharmony_ci return ret; 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTROL_CURSOR(i), 5962306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) | 6062306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) | 6162306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) | 6262306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) | 6362306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) | 6462306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND) | 6562306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_CONTROL_CURSOR, SUB_OWNER, NONE), 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle); 7062306a36Sopenharmony_ci return 0; 7162306a36Sopenharmony_ci} 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_cistatic int 7462306a36Sopenharmony_cihead827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh) 7562306a36Sopenharmony_ci{ 7662306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 7762306a36Sopenharmony_ci const int i = head->base.index; 7862306a36Sopenharmony_ci int ret; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 9))) 8162306a36Sopenharmony_ci return ret; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_OFFSET(i, 0), 8462306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_OFFSET, ORIGIN, asyh->core.offset >> 8)); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_SIZE(i), 8762306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_SIZE, WIDTH, asyh->core.w) | 8862306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_SIZE, HEIGHT, asyh->core.h), 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci HEAD_SET_STORAGE(i), 9162306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_STORAGE, BLOCK_HEIGHT, asyh->core.blockh) | 9262306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.pitch >> 8) | 9362306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_STORAGE, PITCH, asyh->core.blocks) | 9462306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_STORAGE, MEMORY_LAYOUT, asyh->core.layout), 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci HEAD_SET_PARAMS(i), 9762306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_PARAMS, FORMAT, asyh->core.format) | 9862306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_PARAMS, SUPER_SAMPLE, X1_AA) | 9962306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_PARAMS, GAMMA, LINEAR), 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci HEAD_SET_CONTEXT_DMAS_ISO(i, 0), 10262306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_CONTEXT_DMAS_ISO, HANDLE, asyh->core.handle)); 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_VIEWPORT_POINT_IN(i, 0), 10562306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, X, asyh->core.x) | 10662306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_VIEWPORT_POINT_IN, Y, asyh->core.y)); 10762306a36Sopenharmony_ci return 0; 10862306a36Sopenharmony_ci} 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_cistatic int 11162306a36Sopenharmony_cihead827d_olut_clr(struct nv50_head *head) 11262306a36Sopenharmony_ci{ 11362306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 11462306a36Sopenharmony_ci const int i = head->base.index; 11562306a36Sopenharmony_ci int ret; 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 4))) 11862306a36Sopenharmony_ci return ret; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i), 12162306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, DISABLE)); 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), 0x00000000); 12462306a36Sopenharmony_ci return 0; 12562306a36Sopenharmony_ci} 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_cistatic int 12862306a36Sopenharmony_cihead827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh) 12962306a36Sopenharmony_ci{ 13062306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 13162306a36Sopenharmony_ci const int i = head->base.index; 13262306a36Sopenharmony_ci int ret; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 5))) 13562306a36Sopenharmony_ci return ret; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_BASE_LUT_LO(i), 13862306a36Sopenharmony_ci NVDEF(NV827D, HEAD_SET_BASE_LUT_LO, ENABLE, ENABLE) | 13962306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, MODE, asyh->olut.mode) | 14062306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_BASE_LUT_LO, ORIGIN, 0), 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci HEAD_SET_BASE_LUT_HI(i), 14362306a36Sopenharmony_ci NVVAL(NV827D, HEAD_SET_BASE_LUT_HI, ORIGIN, asyh->olut.offset >> 8)); 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci PUSH_MTHD(push, NV827D, HEAD_SET_CONTEXT_DMA_LUT(i), asyh->olut.handle); 14662306a36Sopenharmony_ci return 0; 14762306a36Sopenharmony_ci} 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ciconst struct nv50_head_func 15062306a36Sopenharmony_cihead827d = { 15162306a36Sopenharmony_ci .view = head507d_view, 15262306a36Sopenharmony_ci .mode = head507d_mode, 15362306a36Sopenharmony_ci .olut = head507d_olut, 15462306a36Sopenharmony_ci .olut_size = 256, 15562306a36Sopenharmony_ci .olut_set = head827d_olut_set, 15662306a36Sopenharmony_ci .olut_clr = head827d_olut_clr, 15762306a36Sopenharmony_ci .core_calc = head507d_core_calc, 15862306a36Sopenharmony_ci .core_set = head827d_core_set, 15962306a36Sopenharmony_ci .core_clr = head507d_core_clr, 16062306a36Sopenharmony_ci .curs_layout = head507d_curs_layout, 16162306a36Sopenharmony_ci .curs_format = head507d_curs_format, 16262306a36Sopenharmony_ci .curs_set = head827d_curs_set, 16362306a36Sopenharmony_ci .curs_clr = head827d_curs_clr, 16462306a36Sopenharmony_ci .base = head507d_base, 16562306a36Sopenharmony_ci .ovly = head507d_ovly, 16662306a36Sopenharmony_ci .dither = head507d_dither, 16762306a36Sopenharmony_ci .procamp = head507d_procamp, 16862306a36Sopenharmony_ci}; 169