dt-bindings: mtd: ingenic: Use standard ecc-engine property
[linux/fpc-iii.git] / drivers / gpu / drm / nouveau / dispnv50 / headc57d.c
blob32a7f9e85fb0e529b3451d5930786024c659f8a6
1 /*
2 * Copyright 2018 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
22 #include "head.h"
23 #include "atom.h"
24 #include "core.h"
26 static void
27 headc57d_or(struct nv50_head *head, struct nv50_head_atom *asyh)
29 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
30 u32 *push;
31 if ((push = evo_wait(core, 2))) {
32 /*XXX: This is a dirty hack until OR depth handling is
33 * improved later for deep colour etc.
35 switch (asyh->or.depth) {
36 case 6: asyh->or.depth = 5; break;
37 case 5: asyh->or.depth = 4; break;
38 case 2: asyh->or.depth = 1; break;
39 case 0: asyh->or.depth = 4; break;
40 default:
41 WARN_ON(1);
42 break;
45 evo_mthd(push, 0x2004 + (head->base.index * 0x400), 1);
46 evo_data(push, 0xfc000001 |
47 asyh->or.depth << 4 |
48 asyh->or.nvsync << 3 |
49 asyh->or.nhsync << 2);
50 evo_kick(push, core);
54 static void
55 headc57d_procamp(struct nv50_head *head, struct nv50_head_atom *asyh)
57 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
58 u32 *push;
59 if ((push = evo_wait(core, 2))) {
60 evo_mthd(push, 0x2000 + (head->base.index * 0x400), 1);
61 #if 0
62 evo_data(push, 0x80000000 |
63 asyh->procamp.sat.sin << 16 |
64 asyh->procamp.sat.cos << 4);
65 #else
66 evo_data(push, 0);
67 #endif
68 evo_kick(push, core);
72 void
73 headc57d_olut_clr(struct nv50_head *head)
75 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
76 u32 *push;
77 if ((push = evo_wait(core, 2))) {
78 evo_mthd(push, 0x2288 + (head->base.index * 0x400), 1);
79 evo_data(push, 0x00000000);
80 evo_kick(push, core);
84 void
85 headc57d_olut_set(struct nv50_head *head, struct nv50_head_atom *asyh)
87 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
88 u32 *push;
89 if ((push = evo_wait(core, 4))) {
90 evo_mthd(push, 0x2280 + (head->base.index * 0x400), 4);
91 evo_data(push, asyh->olut.size << 8 |
92 asyh->olut.mode << 2 |
93 asyh->olut.output_mode);
94 evo_data(push, 0xffffffff); /* FP_NORM_SCALE. */
95 evo_data(push, asyh->olut.handle);
96 evo_data(push, asyh->olut.offset >> 8);
97 evo_kick(push, core);
101 static void
102 headc57d_olut_load_8(struct drm_color_lut *in, int size, void __iomem *mem)
104 memset_io(mem, 0x00, 0x20); /* VSS header. */
105 mem += 0x20;
107 while (size--) {
108 u16 r = drm_color_lut_extract(in-> red + 0, 16);
109 u16 g = drm_color_lut_extract(in->green + 0, 16);
110 u16 b = drm_color_lut_extract(in-> blue + 0, 16);
111 u16 ri = 0, gi = 0, bi = 0, i;
113 if (in++, size) {
114 ri = (drm_color_lut_extract(in-> red, 16) - r) / 4;
115 gi = (drm_color_lut_extract(in->green, 16) - g) / 4;
116 bi = (drm_color_lut_extract(in-> blue, 16) - b) / 4;
119 for (i = 0; i < 4; i++, mem += 8) {
120 writew(r + ri * i, mem + 0);
121 writew(g + gi * i, mem + 2);
122 writew(b + bi * i, mem + 4);
126 /* INTERPOLATE modes require a "next" entry to interpolate with,
127 * so we replicate the last entry to deal with this for now.
129 writew(readw(mem - 8), mem + 0);
130 writew(readw(mem - 6), mem + 2);
131 writew(readw(mem - 4), mem + 4);
134 static void
135 headc57d_olut_load(struct drm_color_lut *in, int size, void __iomem *mem)
137 memset_io(mem, 0x00, 0x20); /* VSS header. */
138 mem += 0x20;
140 for (; size--; in++, mem += 0x08) {
141 writew(drm_color_lut_extract(in-> red, 16), mem + 0);
142 writew(drm_color_lut_extract(in->green, 16), mem + 2);
143 writew(drm_color_lut_extract(in-> blue, 16), mem + 4);
146 /* INTERPOLATE modes require a "next" entry to interpolate with,
147 * so we replicate the last entry to deal with this for now.
149 writew(readw(mem - 8), mem + 0);
150 writew(readw(mem - 6), mem + 2);
151 writew(readw(mem - 4), mem + 4);
154 void
155 headc57d_olut(struct nv50_head *head, struct nv50_head_atom *asyh)
157 asyh->olut.mode = 2; /* DIRECT10 */
158 asyh->olut.size = 4 /* VSS header. */ + 1024 + 1 /* Entries. */;
159 asyh->olut.output_mode = 1; /* INTERPOLATE_ENABLE. */
160 if (asyh->state.gamma_lut &&
161 asyh->state.gamma_lut->length / sizeof(struct drm_color_lut) == 256)
162 asyh->olut.load = headc57d_olut_load_8;
163 else
164 asyh->olut.load = headc57d_olut_load;
167 static void
168 headc57d_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
170 struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
171 struct nv50_head_mode *m = &asyh->mode;
172 u32 *push;
173 if ((push = evo_wait(core, 12))) {
174 evo_mthd(push, 0x2064 + (head->base.index * 0x400), 5);
175 evo_data(push, (m->v.active << 16) | m->h.active );
176 evo_data(push, (m->v.synce << 16) | m->h.synce );
177 evo_data(push, (m->v.blanke << 16) | m->h.blanke );
178 evo_data(push, (m->v.blanks << 16) | m->h.blanks );
179 evo_data(push, (m->v.blank2e << 16) | m->v.blank2s);
180 evo_mthd(push, 0x200c + (head->base.index * 0x400), 1);
181 evo_data(push, m->clock * 1000);
182 evo_mthd(push, 0x2028 + (head->base.index * 0x400), 1);
183 evo_data(push, m->clock * 1000);
184 /*XXX: HEAD_USAGE_BOUNDS, doesn't belong here. */
185 evo_mthd(push, 0x2030 + (head->base.index * 0x400), 1);
186 evo_data(push, 0x00001014);
187 evo_kick(push, core);
191 const struct nv50_head_func
192 headc57d = {
193 .view = headc37d_view,
194 .mode = headc57d_mode,
195 .olut = headc57d_olut,
196 .olut_identity = true,
197 .olut_set = headc57d_olut_set,
198 .olut_clr = headc57d_olut_clr,
199 .curs_layout = head917d_curs_layout,
200 .curs_format = headc37d_curs_format,
201 .curs_set = headc37d_curs_set,
202 .curs_clr = headc37d_curs_clr,
203 .dither = headc37d_dither,
204 .procamp = headc57d_procamp,
205 .or = headc57d_or,