drm/nouveau/kms/nv50-: convert core head_curs_set() to new push macros
[linux-2.6-microblaze.git] / drivers / gpu / drm / nouveau / dispnv50 / head827d.c
1 /*
2  * Copyright 2018 Red Hat Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #include "head.h"
23 #include "core.h"
24
25 #include <nvif/push507c.h>
26
27 static void
28 head827d_curs_clr(struct nv50_head *head)
29 {
30         struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
31         u32 *push;
32         if ((push = evo_wait(core, 4))) {
33                 evo_mthd(push, 0x0880 + head->base.index * 0x400, 1);
34                 evo_data(push, 0x05000000);
35                 evo_mthd(push, 0x089c + head->base.index * 0x400, 1);
36                 evo_data(push, 0x00000000);
37                 evo_kick(push, core);
38         }
39 }
40
41 static int
42 head827d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
43 {
44         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
45         const int i = head->base.index;
46         int ret;
47
48         if ((ret = PUSH_WAIT(push, 5)))
49                 return ret;
50
51         PUSH_NVSQ(push, NV827D, 0x0880 + (i * 0x400), 0x80000000 |
52                                                       asyh->curs.layout << 26 |
53                                                       asyh->curs.format << 24,
54                                 0x0884 + (i * 0x400), asyh->curs.offset >> 8);
55         PUSH_NVSQ(push, NV827D, 0x089c + (i * 0x400), asyh->curs.handle);
56         return 0;
57 }
58
59 static int
60 head827d_core_set(struct nv50_head *head, struct nv50_head_atom *asyh)
61 {
62         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
63         const int i = head->base.index;
64         int ret;
65
66         if ((ret = PUSH_WAIT(push, 9)))
67                 return ret;
68
69         PUSH_NVSQ(push, NV827D, 0x0860 + (i * 0x400), asyh->core.offset >> 8);
70         PUSH_NVSQ(push, NV827D, 0x0868 + (i * 0x400), asyh->core.h << 16 | asyh->core.w,
71                                 0x086c + (i * 0x400), asyh->core.layout << 20 |
72                                                      (asyh->core.pitch >> 8) << 8 |
73                                                       asyh->core.blocks << 8 |
74                                                       asyh->core.blockh,
75                                 0x0870 + (i * 0x400), asyh->core.format << 8,
76                                 0x0874 + (i * 0x400), asyh->core.handle);
77         PUSH_NVSQ(push, NV827D, 0x08c0 + (i * 0x400), asyh->core.y << 16 | asyh->core.x);
78         return 0;
79 }
80
81 static int
82 head827d_olut_clr(struct nv50_head *head)
83 {
84         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
85         const int i = head->base.index;
86         int ret;
87
88         if ((ret = PUSH_WAIT(push, 4)))
89                 return ret;
90
91         PUSH_NVSQ(push, NV827D, 0x0840 + (i * 0x400), 0x00000000);
92         PUSH_NVSQ(push, NV827D, 0x085c + (i * 0x400), 0x00000000);
93         return 0;
94 }
95
96 static int
97 head827d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
98 {
99         struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
100         const int i = head->base.index;
101         int ret;
102
103         if ((ret = PUSH_WAIT(push, 5)))
104                 return ret;
105
106         PUSH_NVSQ(push, NV827D, 0x0840 + (i * 0x400), 0x80000000 | asyh->olut.mode << 30,
107                                 0x0844 + (i * 0x400), asyh->olut.offset >> 8);
108         PUSH_NVSQ(push, NV827D, 0x085c + (i * 0x400), asyh->olut.handle);
109         return 0;
110 }
111
112 const struct nv50_head_func
113 head827d = {
114         .view = head507d_view,
115         .mode = head507d_mode,
116         .olut = head507d_olut,
117         .olut_size = 256,
118         .olut_set = head827d_olut_set,
119         .olut_clr = head827d_olut_clr,
120         .core_calc = head507d_core_calc,
121         .core_set = head827d_core_set,
122         .core_clr = head507d_core_clr,
123         .curs_layout = head507d_curs_layout,
124         .curs_format = head507d_curs_format,
125         .curs_set = head827d_curs_set,
126         .curs_clr = head827d_curs_clr,
127         .base = head507d_base,
128         .ovly = head507d_ovly,
129         .dither = head507d_dither,
130         .procamp = head507d_procamp,
131 };