109e1b78aSBen Skeggs /* 209e1b78aSBen Skeggs * Copyright 2018 Red Hat Inc. 309e1b78aSBen Skeggs * 409e1b78aSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 509e1b78aSBen Skeggs * copy of this software and associated documentation files (the "Software"), 609e1b78aSBen Skeggs * to deal in the Software without restriction, including without limitation 709e1b78aSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 809e1b78aSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 909e1b78aSBen Skeggs * Software is furnished to do so, subject to the following conditions: 1009e1b78aSBen Skeggs * 1109e1b78aSBen Skeggs * The above copyright notice and this permission notice shall be included in 1209e1b78aSBen Skeggs * all copies or substantial portions of the Software. 1309e1b78aSBen Skeggs * 1409e1b78aSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1509e1b78aSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1609e1b78aSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1709e1b78aSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1809e1b78aSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1909e1b78aSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2009e1b78aSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 2109e1b78aSBen Skeggs */ 2209e1b78aSBen Skeggs #include "head.h" 2309e1b78aSBen Skeggs #include "core.h" 2409e1b78aSBen Skeggs 2593f7f054SBen Skeggs #include <nvif/push507c.h> 2693f7f054SBen Skeggs 27*2f819f2bSBen Skeggs static int 2809e1b78aSBen Skeggs head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh) 2909e1b78aSBen Skeggs { 30*2f819f2bSBen Skeggs struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 31*2f819f2bSBen Skeggs const int i = head->base.index; 32*2f819f2bSBen Skeggs int ret; 33*2f819f2bSBen Skeggs 34*2f819f2bSBen Skeggs if ((ret = PUSH_WAIT(push, 2))) 35*2f819f2bSBen Skeggs return ret; 36*2f819f2bSBen Skeggs 37*2f819f2bSBen Skeggs PUSH_NVSQ(push, NV917D, 0x04a0 + (i * 0x300), asyh->dither.mode << 3 | 3809e1b78aSBen Skeggs asyh->dither.bits << 1 | 3909e1b78aSBen Skeggs asyh->dither.enable); 40*2f819f2bSBen Skeggs return 0; 4109e1b78aSBen Skeggs } 4209e1b78aSBen Skeggs 4393f7f054SBen Skeggs static int 44119608a7SBen Skeggs head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh) 45119608a7SBen Skeggs { 4693f7f054SBen Skeggs struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push; 4793f7f054SBen Skeggs const int i = head->base.index; 48119608a7SBen Skeggs u32 bounds = 0; 4993f7f054SBen Skeggs int ret; 50119608a7SBen Skeggs 51119608a7SBen Skeggs if (asyh->base.cpp) { 52119608a7SBen Skeggs switch (asyh->base.cpp) { 53119608a7SBen Skeggs case 8: bounds |= 0x00000500; break; 54119608a7SBen Skeggs case 4: bounds |= 0x00000300; break; 55119608a7SBen Skeggs case 2: bounds |= 0x00000100; break; 56119608a7SBen Skeggs case 1: bounds |= 0x00000000; break; 57119608a7SBen Skeggs default: 58119608a7SBen Skeggs WARN_ON(1); 59119608a7SBen Skeggs break; 60119608a7SBen Skeggs } 61119608a7SBen Skeggs bounds |= 0x00020001; 62119608a7SBen Skeggs } 63119608a7SBen Skeggs 6493f7f054SBen Skeggs if ((ret = PUSH_WAIT(push, 2))) 6593f7f054SBen Skeggs return ret; 6693f7f054SBen Skeggs 6793f7f054SBen Skeggs PUSH_NVSQ(push, NV917D, 0x04d0 + (i * 0x300), bounds); 6893f7f054SBen Skeggs return 0; 69119608a7SBen Skeggs } 70119608a7SBen Skeggs 71facaed62SBen Skeggs int 7201d380abSBen Skeggs head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw, 7301d380abSBen Skeggs struct nv50_head_atom *asyh) 7401d380abSBen Skeggs { 7501d380abSBen Skeggs switch (asyw->state.fb->width) { 7601d380abSBen Skeggs case 32: asyh->curs.layout = 0; break; 7701d380abSBen Skeggs case 64: asyh->curs.layout = 1; break; 7801d380abSBen Skeggs case 128: asyh->curs.layout = 2; break; 7901d380abSBen Skeggs case 256: asyh->curs.layout = 3; break; 8001d380abSBen Skeggs default: 8101d380abSBen Skeggs return -EINVAL; 8201d380abSBen Skeggs } 8301d380abSBen Skeggs return 0; 8401d380abSBen Skeggs } 8501d380abSBen Skeggs 8609e1b78aSBen Skeggs const struct nv50_head_func 8709e1b78aSBen Skeggs head917d = { 8809e1b78aSBen Skeggs .view = head907d_view, 8909e1b78aSBen Skeggs .mode = head907d_mode, 90119608a7SBen Skeggs .olut = head907d_olut, 9113199270SIlia Mirkin .olut_size = 1024, 92119608a7SBen Skeggs .olut_set = head907d_olut_set, 93119608a7SBen Skeggs .olut_clr = head907d_olut_clr, 9409e1b78aSBen Skeggs .core_calc = head507d_core_calc, 9509e1b78aSBen Skeggs .core_set = head907d_core_set, 9609e1b78aSBen Skeggs .core_clr = head907d_core_clr, 9701d380abSBen Skeggs .curs_layout = head917d_curs_layout, 9801d380abSBen Skeggs .curs_format = head507d_curs_format, 9909e1b78aSBen Skeggs .curs_set = head907d_curs_set, 10009e1b78aSBen Skeggs .curs_clr = head907d_curs_clr, 101119608a7SBen Skeggs .base = head917d_base, 10209e1b78aSBen Skeggs .ovly = head907d_ovly, 10309e1b78aSBen Skeggs .dither = head917d_dither, 10409e1b78aSBen Skeggs .procamp = head907d_procamp, 10509e1b78aSBen Skeggs .or = head907d_or, 10609e1b78aSBen Skeggs }; 107