Home | History | Annotate | Line # | Download | only in dispnv50
      1 /*	$NetBSD: nouveau_dispnv50_head827d.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_head827d.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 head827d_curs_clr(struct nv50_head *head)
     32 {
     33 	struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
     34 	u32 *push;
     35 	if ((push = evo_wait(core, 4))) {
     36 		evo_mthd(push, 0x0880 + head->base.index * 0x400, 1);
     37 		evo_data(push, 0x05000000);
     38 		evo_mthd(push, 0x089c + head->base.index * 0x400, 1);
     39 		evo_data(push, 0x00000000);
     40 		evo_kick(push, core);
     41 	}
     42 }
     43 
     44 static void
     45 head827d_curs_set(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 *push;
     49 	if ((push = evo_wait(core, 5))) {
     50 		evo_mthd(push, 0x0880 + head->base.index * 0x400, 2);
     51 		evo_data(push, 0x80000000 | asyh->curs.layout << 26 |
     52 					    asyh->curs.format << 24);
     53 		evo_data(push, asyh->curs.offset >> 8);
     54 		evo_mthd(push, 0x089c + head->base.index * 0x400, 1);
     55 		evo_data(push, asyh->curs.handle);
     56 		evo_kick(push, core);
     57 	}
     58 }
     59 
     60 static void
     61 head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
     62 {
     63 	struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
     64 	u32 *push;
     65 	if ((push = evo_wait(core, 9))) {
     66 		evo_mthd(push, 0x0860 + head->base.index * 0x400, 1);
     67 		evo_data(push, asyh->core.offset >> 8);
     68 		evo_mthd(push, 0x0868 + head->base.index * 0x400, 4);
     69 		evo_data(push, asyh->core.h << 16 | asyh->core.w);
     70 		evo_data(push, asyh->core.layout << 20 |
     71 			       (asyh->core.pitch >> 8) << 8 |
     72 			       asyh->core.blocks << 8 |
     73 			       asyh->core.blockh);
     74 		evo_data(push, asyh->core.format << 8);
     75 		evo_data(push, asyh->core.handle);
     76 		evo_mthd(push, 0x08c0 + head->base.index * 0x400, 1);
     77 		evo_data(push, asyh->core.y << 16 | asyh->core.x);
     78 		evo_kick(push, core);
     79 	}
     80 }
     81 
     82 static void
     83 head827d_olut_clr(struct nv50_head *head)
     84 {
     85 	struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
     86 	u32 *push;
     87 	if ((push = evo_wait(core, 4))) {
     88 		evo_mthd(push, 0x0840 + (head->base.index * 0x400), 1);
     89 		evo_data(push, 0x00000000);
     90 		evo_mthd(push, 0x085c + (head->base.index * 0x400), 1);
     91 		evo_data(push, 0x00000000);
     92 		evo_kick(push, core);
     93 	}
     94 }
     95 
     96 static void
     97 head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
     98 {
     99 	struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
    100 	u32 *push;
    101 	if ((push = evo_wait(core, 5))) {
    102 		evo_mthd(push, 0x0840 + (head->base.index * 0x400), 2);
    103 		evo_data(push, 0x80000000 | asyh->olut.mode << 30);
    104 		evo_data(push, asyh->olut.offset >> 8);
    105 		evo_mthd(push, 0x085c + (head->base.index * 0x400), 1);
    106 		evo_data(push, asyh->olut.handle);
    107 		evo_kick(push, core);
    108 	}
    109 }
    110 
    111 const struct nv50_head_func
    112 head827d = {
    113 	.view = head507d_view,
    114 	.mode = head507d_mode,
    115 	.olut = head507d_olut,
    116 	.olut_size = 256,
    117 	.olut_set = head827d_olut_set,
    118 	.olut_clr = head827d_olut_clr,
    119 	.core_calc = head507d_core_calc,
    120 	.core_set = head827d_core_set,
    121 	.core_clr = head507d_core_clr,
    122 	.curs_layout = head507d_curs_layout,
    123 	.curs_format = head507d_curs_format,
    124 	.curs_set = head827d_curs_set,
    125 	.curs_clr = head827d_curs_clr,
    126 	.base = head507d_base,
    127 	.ovly = head507d_ovly,
    128 	.dither = head507d_dither,
    129 	.procamp = head507d_procamp,
    130 };
    131