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/cl507d.h> 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciint 3062306a36Sopenharmony_cihead507d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh) 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, 2))) 3762306a36Sopenharmony_ci return ret; 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_PROCAMP(i), 4062306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PROCAMP, COLOR_SPACE, RGB) | 4162306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PROCAMP, CHROMA_LPF, AUTO) | 4262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_PROCAMP, SAT_COS, asyh->procamp.sat.cos) | 4362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_PROCAMP, SAT_SINE, asyh->procamp.sat.sin) | 4462306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PROCAMP, TRANSITION, HARD)); 4562306a36Sopenharmony_ci return 0; 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciint 4962306a36Sopenharmony_cihead507d_dither(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, 2))) 5662306a36Sopenharmony_ci return ret; 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_DITHER_CONTROL(i), 5962306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) | 6062306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) | 6162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) | 6262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DITHER_CONTROL, PHASE, 0)); 6362306a36Sopenharmony_ci return 0; 6462306a36Sopenharmony_ci} 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciint 6762306a36Sopenharmony_cihead507d_ovly(struct nv50_head *head, struct nv50_head_atom *asyh) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 7062306a36Sopenharmony_ci const int i = head->base.index; 7162306a36Sopenharmony_ci u32 bounds = 0; 7262306a36Sopenharmony_ci int ret; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci if (asyh->ovly.cpp) { 7562306a36Sopenharmony_ci switch (asyh->ovly.cpp) { 7662306a36Sopenharmony_ci case 4: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_32); break; 7762306a36Sopenharmony_ci case 2: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_16); break; 7862306a36Sopenharmony_ci default: 7962306a36Sopenharmony_ci WARN_ON(1); 8062306a36Sopenharmony_ci break; 8162306a36Sopenharmony_ci } 8262306a36Sopenharmony_ci bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, USABLE, TRUE); 8362306a36Sopenharmony_ci } else { 8462306a36Sopenharmony_ci bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_16); 8562306a36Sopenharmony_ci } 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 8862306a36Sopenharmony_ci return ret; 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS(i), bounds); 9162306a36Sopenharmony_ci return 0; 9262306a36Sopenharmony_ci} 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ciint 9562306a36Sopenharmony_cihead507d_base(struct nv50_head *head, struct nv50_head_atom *asyh) 9662306a36Sopenharmony_ci{ 9762306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 9862306a36Sopenharmony_ci const int i = head->base.index; 9962306a36Sopenharmony_ci u32 bounds = 0; 10062306a36Sopenharmony_ci int ret; 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci if (asyh->base.cpp) { 10362306a36Sopenharmony_ci switch (asyh->base.cpp) { 10462306a36Sopenharmony_ci case 8: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_64); break; 10562306a36Sopenharmony_ci case 4: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_32); break; 10662306a36Sopenharmony_ci case 2: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_16); break; 10762306a36Sopenharmony_ci case 1: bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_8); break; 10862306a36Sopenharmony_ci default: 10962306a36Sopenharmony_ci WARN_ON(1); 11062306a36Sopenharmony_ci break; 11162306a36Sopenharmony_ci } 11262306a36Sopenharmony_ci bounds |= NVDEF(NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, USABLE, TRUE); 11362306a36Sopenharmony_ci } 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 11662306a36Sopenharmony_ci return ret; 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS(i), bounds); 11962306a36Sopenharmony_ci return 0; 12062306a36Sopenharmony_ci} 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_cistatic int 12362306a36Sopenharmony_cihead507d_curs_clr(struct nv50_head *head) 12462306a36Sopenharmony_ci{ 12562306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 12662306a36Sopenharmony_ci const int i = head->base.index; 12762306a36Sopenharmony_ci int ret; 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 13062306a36Sopenharmony_ci return ret; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_CONTROL_CURSOR(i), 13362306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, ENABLE, DISABLE) | 13462306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, FORMAT, A8R8G8B8) | 13562306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, SIZE, W64_H64)); 13662306a36Sopenharmony_ci return 0; 13762306a36Sopenharmony_ci} 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cistatic int 14062306a36Sopenharmony_cihead507d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh) 14162306a36Sopenharmony_ci{ 14262306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 14362306a36Sopenharmony_ci const int i = head->base.index; 14462306a36Sopenharmony_ci int ret; 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 3))) 14762306a36Sopenharmony_ci return ret; 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_CONTROL_CURSOR(i), 15062306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) | 15162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) | 15262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) | 15362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) | 15462306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) | 15562306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND) | 15662306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_CURSOR, SUB_OWNER, NONE), 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8); 15962306a36Sopenharmony_ci return 0; 16062306a36Sopenharmony_ci} 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciint 16362306a36Sopenharmony_cihead507d_curs_format(struct nv50_head *head, struct nv50_wndw_atom *asyw, 16462306a36Sopenharmony_ci struct nv50_head_atom *asyh) 16562306a36Sopenharmony_ci{ 16662306a36Sopenharmony_ci switch (asyw->image.format) { 16762306a36Sopenharmony_ci case 0xcf: asyh->curs.format = NV507D_HEAD_SET_CONTROL_CURSOR_FORMAT_A8R8G8B8; break; 16862306a36Sopenharmony_ci default: 16962306a36Sopenharmony_ci WARN_ON(1); 17062306a36Sopenharmony_ci return -EINVAL; 17162306a36Sopenharmony_ci } 17262306a36Sopenharmony_ci return 0; 17362306a36Sopenharmony_ci} 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ciint 17662306a36Sopenharmony_cihead507d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw, 17762306a36Sopenharmony_ci struct nv50_head_atom *asyh) 17862306a36Sopenharmony_ci{ 17962306a36Sopenharmony_ci switch (asyw->image.w) { 18062306a36Sopenharmony_ci case 32: asyh->curs.layout = NV507D_HEAD_SET_CONTROL_CURSOR_SIZE_W32_H32; break; 18162306a36Sopenharmony_ci case 64: asyh->curs.layout = NV507D_HEAD_SET_CONTROL_CURSOR_SIZE_W64_H64; break; 18262306a36Sopenharmony_ci default: 18362306a36Sopenharmony_ci return -EINVAL; 18462306a36Sopenharmony_ci } 18562306a36Sopenharmony_ci return 0; 18662306a36Sopenharmony_ci} 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ciint 18962306a36Sopenharmony_cihead507d_core_clr(struct nv50_head *head) 19062306a36Sopenharmony_ci{ 19162306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 19262306a36Sopenharmony_ci const int i = head->base.index; 19362306a36Sopenharmony_ci int ret; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 19662306a36Sopenharmony_ci return ret; 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_CONTEXT_DMA_ISO(i), 0x00000000); 19962306a36Sopenharmony_ci return 0; 20062306a36Sopenharmony_ci} 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_cistatic int 20362306a36Sopenharmony_cihead507d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh) 20462306a36Sopenharmony_ci{ 20562306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 20662306a36Sopenharmony_ci const int i = head->base.index; 20762306a36Sopenharmony_ci int ret; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 9))) 21062306a36Sopenharmony_ci return ret; 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_OFFSET(i, 0), 21362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_OFFSET, ORIGIN, asyh->core.offset >> 8)); 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_SIZE(i), 21662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_SIZE, WIDTH, asyh->core.w) | 21762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_SIZE, HEIGHT, asyh->core.h), 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci HEAD_SET_STORAGE(i), 22062306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_STORAGE, BLOCK_HEIGHT, asyh->core.blockh) | 22162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_STORAGE, PITCH, asyh->core.pitch >> 8) | 22262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_STORAGE, PITCH, asyh->core.blocks) | 22362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_STORAGE, MEMORY_LAYOUT, asyh->core.layout), 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci HEAD_SET_PARAMS(i), 22662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_PARAMS, FORMAT, asyh->core.format) | 22762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_PARAMS, KIND, asyh->core.kind) | 22862306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PARAMS, PART_STRIDE, PARTSTRIDE_256), 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci HEAD_SET_CONTEXT_DMA_ISO(i), 23162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTEXT_DMA_ISO, HANDLE, asyh->core.handle)); 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_VIEWPORT_POINT_IN(i, 0), 23462306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_POINT_IN, X, asyh->core.x) | 23562306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_POINT_IN, Y, asyh->core.y)); 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci /* EVO will complain with INVALID_STATE if we have an 23862306a36Sopenharmony_ci * active cursor and (re)specify HeadSetContextDmaIso 23962306a36Sopenharmony_ci * without also updating HeadSetOffsetCursor. 24062306a36Sopenharmony_ci */ 24162306a36Sopenharmony_ci asyh->set.curs = asyh->curs.visible; 24262306a36Sopenharmony_ci asyh->set.olut = asyh->olut.handle != 0; 24362306a36Sopenharmony_ci return 0; 24462306a36Sopenharmony_ci} 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_civoid 24762306a36Sopenharmony_cihead507d_core_calc(struct nv50_head *head, struct nv50_head_atom *asyh) 24862306a36Sopenharmony_ci{ 24962306a36Sopenharmony_ci struct nv50_disp *disp = nv50_disp(head->base.base.dev); 25062306a36Sopenharmony_ci if ((asyh->core.visible = (asyh->base.cpp != 0))) { 25162306a36Sopenharmony_ci asyh->core.x = asyh->base.x; 25262306a36Sopenharmony_ci asyh->core.y = asyh->base.y; 25362306a36Sopenharmony_ci asyh->core.w = asyh->base.w; 25462306a36Sopenharmony_ci asyh->core.h = asyh->base.h; 25562306a36Sopenharmony_ci } else 25662306a36Sopenharmony_ci if ((asyh->core.visible = (asyh->ovly.cpp != 0)) || 25762306a36Sopenharmony_ci (asyh->core.visible = asyh->curs.visible)) { 25862306a36Sopenharmony_ci /*XXX: We need to either find some way of having the 25962306a36Sopenharmony_ci * primary base layer appear black, while still 26062306a36Sopenharmony_ci * being able to display the other layers, or we 26162306a36Sopenharmony_ci * need to allocate a dummy black surface here. 26262306a36Sopenharmony_ci */ 26362306a36Sopenharmony_ci asyh->core.x = 0; 26462306a36Sopenharmony_ci asyh->core.y = 0; 26562306a36Sopenharmony_ci asyh->core.w = asyh->state.mode.hdisplay; 26662306a36Sopenharmony_ci asyh->core.h = asyh->state.mode.vdisplay; 26762306a36Sopenharmony_ci } 26862306a36Sopenharmony_ci asyh->core.handle = disp->core->chan.vram.handle; 26962306a36Sopenharmony_ci asyh->core.offset = 0; 27062306a36Sopenharmony_ci asyh->core.format = NV507D_HEAD_SET_PARAMS_FORMAT_A8R8G8B8; 27162306a36Sopenharmony_ci asyh->core.kind = NV507D_HEAD_SET_PARAMS_KIND_KIND_PITCH; 27262306a36Sopenharmony_ci asyh->core.layout = NV507D_HEAD_SET_STORAGE_MEMORY_LAYOUT_PITCH; 27362306a36Sopenharmony_ci asyh->core.blockh = NV507D_HEAD_SET_STORAGE_BLOCK_HEIGHT_ONE_GOB; 27462306a36Sopenharmony_ci asyh->core.blocks = 0; 27562306a36Sopenharmony_ci asyh->core.pitch = ALIGN(asyh->core.w, 64) * 4; 27662306a36Sopenharmony_ci} 27762306a36Sopenharmony_ci 27862306a36Sopenharmony_cistatic int 27962306a36Sopenharmony_cihead507d_olut_clr(struct nv50_head *head) 28062306a36Sopenharmony_ci{ 28162306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 28262306a36Sopenharmony_ci const int i = head->base.index; 28362306a36Sopenharmony_ci int ret; 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 28662306a36Sopenharmony_ci return ret; 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_BASE_LUT_LO(i), 28962306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_BASE_LUT_LO, ENABLE, DISABLE)); 29062306a36Sopenharmony_ci return 0; 29162306a36Sopenharmony_ci} 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_cistatic int 29462306a36Sopenharmony_cihead507d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh) 29562306a36Sopenharmony_ci{ 29662306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 29762306a36Sopenharmony_ci const int i = head->base.index; 29862306a36Sopenharmony_ci int ret; 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 3))) 30162306a36Sopenharmony_ci return ret; 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_BASE_LUT_LO(i), 30462306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_BASE_LUT_LO, ENABLE, ENABLE) | 30562306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_BASE_LUT_LO, MODE, asyh->olut.mode) | 30662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_BASE_LUT_LO, ORIGIN, 0), 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci HEAD_SET_BASE_LUT_HI(i), 30962306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_BASE_LUT_HI, ORIGIN, asyh->olut.offset >> 8)); 31062306a36Sopenharmony_ci return 0; 31162306a36Sopenharmony_ci} 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_cistatic void 31462306a36Sopenharmony_cihead507d_olut_load(struct drm_color_lut *in, int size, void __iomem *mem) 31562306a36Sopenharmony_ci{ 31662306a36Sopenharmony_ci for (; size--; in++, mem += 8) { 31762306a36Sopenharmony_ci writew(drm_color_lut_extract(in-> red, 11) << 3, mem + 0); 31862306a36Sopenharmony_ci writew(drm_color_lut_extract(in->green, 11) << 3, mem + 2); 31962306a36Sopenharmony_ci writew(drm_color_lut_extract(in-> blue, 11) << 3, mem + 4); 32062306a36Sopenharmony_ci } 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci /* INTERPOLATE modes require a "next" entry to interpolate with, 32362306a36Sopenharmony_ci * so we replicate the last entry to deal with this for now. 32462306a36Sopenharmony_ci */ 32562306a36Sopenharmony_ci writew(readw(mem - 8), mem + 0); 32662306a36Sopenharmony_ci writew(readw(mem - 6), mem + 2); 32762306a36Sopenharmony_ci writew(readw(mem - 4), mem + 4); 32862306a36Sopenharmony_ci} 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_cibool 33162306a36Sopenharmony_cihead507d_olut(struct nv50_head *head, struct nv50_head_atom *asyh, int size) 33262306a36Sopenharmony_ci{ 33362306a36Sopenharmony_ci if (size != 256) 33462306a36Sopenharmony_ci return false; 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci if (asyh->base.cpp == 1) 33762306a36Sopenharmony_ci asyh->olut.mode = NV507D_HEAD_SET_BASE_LUT_LO_MODE_LORES; 33862306a36Sopenharmony_ci else 33962306a36Sopenharmony_ci asyh->olut.mode = NV507D_HEAD_SET_BASE_LUT_LO_MODE_HIRES; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci asyh->olut.load = head507d_olut_load; 34262306a36Sopenharmony_ci return true; 34362306a36Sopenharmony_ci} 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ciint 34662306a36Sopenharmony_cihead507d_mode(struct nv50_head *head, struct nv50_head_atom *asyh) 34762306a36Sopenharmony_ci{ 34862306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 34962306a36Sopenharmony_ci struct nv50_head_mode *m = &asyh->mode; 35062306a36Sopenharmony_ci const int i = head->base.index; 35162306a36Sopenharmony_ci int ret; 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 13))) 35462306a36Sopenharmony_ci return ret; 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_PIXEL_CLOCK(i), 35762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_PIXEL_CLOCK, FREQUENCY, m->clock) | 35862306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PIXEL_CLOCK, MODE, CLK_CUSTOM) | 35962306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PIXEL_CLOCK, ADJ1000DIV1001, FALSE) | 36062306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_PIXEL_CLOCK, NOT_DRIVER, FALSE), 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci HEAD_SET_CONTROL(i), 36362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL, STRUCTURE, m->interlace)); 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_OVERSCAN_COLOR(i), 36662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_OVERSCAN_COLOR, RED, 0) | 36762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_OVERSCAN_COLOR, GRN, 0) | 36862306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_OVERSCAN_COLOR, BLU, 0), 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci HEAD_SET_RASTER_SIZE(i), 37162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_SIZE, WIDTH, m->h.active) | 37262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_SIZE, HEIGHT, m->v.active), 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci HEAD_SET_RASTER_SYNC_END(i), 37562306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_SYNC_END, X, m->h.synce) | 37662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_SYNC_END, Y, m->v.synce), 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci HEAD_SET_RASTER_BLANK_END(i), 37962306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_BLANK_END, X, m->h.blanke) | 38062306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_BLANK_END, Y, m->v.blanke), 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci HEAD_SET_RASTER_BLANK_START(i), 38362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_BLANK_START, X, m->h.blanks) | 38462306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_BLANK_START, Y, m->v.blanks), 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci HEAD_SET_RASTER_VERT_BLANK2(i), 38762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_VERT_BLANK2, YSTART, m->v.blank2s) | 38862306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_VERT_BLANK2, YEND, m->v.blank2e), 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci HEAD_SET_RASTER_VERT_BLANK_DMI(i), 39162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_RASTER_VERT_BLANK_DMI, DURATION, m->v.blankus)); 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_DEFAULT_BASE_COLOR(i), 39462306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DEFAULT_BASE_COLOR, RED, 0) | 39562306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DEFAULT_BASE_COLOR, GREEN, 0) | 39662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_DEFAULT_BASE_COLOR, BLUE, 0)); 39762306a36Sopenharmony_ci return 0; 39862306a36Sopenharmony_ci} 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ciint 40162306a36Sopenharmony_cihead507d_view(struct nv50_head *head, struct nv50_head_atom *asyh) 40262306a36Sopenharmony_ci{ 40362306a36Sopenharmony_ci struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 40462306a36Sopenharmony_ci const int i = head->base.index; 40562306a36Sopenharmony_ci int ret; 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci if ((ret = PUSH_WAIT(push, 7))) 40862306a36Sopenharmony_ci return ret; 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_CONTROL_OUTPUT_SCALER(i), 41162306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_OUTPUT_SCALER, VERTICAL_TAPS, TAPS_1) | 41262306a36Sopenharmony_ci NVDEF(NV507D, HEAD_SET_CONTROL_OUTPUT_SCALER, HORIZONTAL_TAPS, TAPS_1) | 41362306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_OUTPUT_SCALER, HRESPONSE_BIAS, 0) | 41462306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_CONTROL_OUTPUT_SCALER, VRESPONSE_BIAS, 0)); 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_VIEWPORT_SIZE_IN(i), 41762306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_IN, WIDTH, asyh->view.iW) | 41862306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_IN, HEIGHT, asyh->view.iH)); 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci PUSH_MTHD(push, NV507D, HEAD_SET_VIEWPORT_SIZE_OUT(i), 42162306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_OUT, WIDTH, asyh->view.oW) | 42262306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_OUT, HEIGHT, asyh->view.oH), 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci HEAD_SET_VIEWPORT_SIZE_OUT_MIN(i), 42562306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_OUT_MIN, WIDTH, asyh->view.oW) | 42662306a36Sopenharmony_ci NVVAL(NV507D, HEAD_SET_VIEWPORT_SIZE_OUT_MIN, HEIGHT, asyh->view.oH)); 42762306a36Sopenharmony_ci return 0; 42862306a36Sopenharmony_ci} 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_ciconst struct nv50_head_func 43162306a36Sopenharmony_cihead507d = { 43262306a36Sopenharmony_ci .view = head507d_view, 43362306a36Sopenharmony_ci .mode = head507d_mode, 43462306a36Sopenharmony_ci .olut = head507d_olut, 43562306a36Sopenharmony_ci .olut_size = 256, 43662306a36Sopenharmony_ci .olut_set = head507d_olut_set, 43762306a36Sopenharmony_ci .olut_clr = head507d_olut_clr, 43862306a36Sopenharmony_ci .core_calc = head507d_core_calc, 43962306a36Sopenharmony_ci .core_set = head507d_core_set, 44062306a36Sopenharmony_ci .core_clr = head507d_core_clr, 44162306a36Sopenharmony_ci .curs_layout = head507d_curs_layout, 44262306a36Sopenharmony_ci .curs_format = head507d_curs_format, 44362306a36Sopenharmony_ci .curs_set = head507d_curs_set, 44462306a36Sopenharmony_ci .curs_clr = head507d_curs_clr, 44562306a36Sopenharmony_ci .base = head507d_base, 44662306a36Sopenharmony_ci .ovly = head507d_ovly, 44762306a36Sopenharmony_ci .dither = head507d_dither, 44862306a36Sopenharmony_ci .procamp = head507d_procamp, 44962306a36Sopenharmony_ci}; 450