1 /* $NetBSD: nouveau_dispnv50_head917d.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $ */ 2 3 /* 4 * Copyright 2018 Red Hat Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 #include <sys/cdefs.h> 25 __KERNEL_RCSID(0, "$NetBSD: nouveau_dispnv50_head917d.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $"); 26 27 #include "head.h" 28 #include "core.h" 29 30 static void 31 head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh) 32 { 33 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan; 34 u32 *push; 35 if ((push = evo_wait(core, 2))) { 36 evo_mthd(push, 0x04a0 + (head->base.index * 0x0300), 1); 37 evo_data(push, asyh->dither.mode << 3 | 38 asyh->dither.bits << 1 | 39 asyh->dither.enable); 40 evo_kick(push, core); 41 } 42 } 43 44 static void 45 head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh) 46 { 47 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan; 48 u32 bounds = 0; 49 u32 *push; 50 51 if (asyh->base.cpp) { 52 switch (asyh->base.cpp) { 53 case 8: bounds |= 0x00000500; break; 54 case 4: bounds |= 0x00000300; break; 55 case 2: bounds |= 0x00000100; break; 56 case 1: bounds |= 0x00000000; break; 57 default: 58 WARN_ON(1); 59 break; 60 } 61 bounds |= 0x00020001; 62 } 63 64 if ((push = evo_wait(core, 2))) { 65 evo_mthd(push, 0x04d0 + head->base.index * 0x300, 1); 66 evo_data(push, bounds); 67 evo_kick(push, core); 68 } 69 } 70 71 int 72 head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw, 73 struct nv50_head_atom *asyh) 74 { 75 switch (asyw->state.fb->width) { 76 case 32: asyh->curs.layout = 0; break; 77 case 64: asyh->curs.layout = 1; break; 78 case 128: asyh->curs.layout = 2; break; 79 case 256: asyh->curs.layout = 3; break; 80 default: 81 return -EINVAL; 82 } 83 return 0; 84 } 85 86 const struct nv50_head_func 87 head917d = { 88 .view = head907d_view, 89 .mode = head907d_mode, 90 .olut = head907d_olut, 91 .olut_size = 1024, 92 .olut_set = head907d_olut_set, 93 .olut_clr = head907d_olut_clr, 94 .core_calc = head507d_core_calc, 95 .core_set = head907d_core_set, 96 .core_clr = head907d_core_clr, 97 .curs_layout = head917d_curs_layout, 98 .curs_format = head507d_curs_format, 99 .curs_set = head907d_curs_set, 100 .curs_clr = head907d_curs_clr, 101 .base = head917d_base, 102 .ovly = head907d_ovly, 103 .dither = head917d_dither, 104 .procamp = head907d_procamp, 105 .or = head907d_or, 106 }; 107