base507c.c (1590700d94ac53772491ed3103a4e8b8de01640a) base507c.c (ccd27db8c731817ef36e75de2b5fdc2e79550213)
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

--- 7 unchanged lines hidden (view full) ---

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 "base.h"
23
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

--- 7 unchanged lines hidden (view full) ---

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 "base.h"
23
24#include <nvif/class.h>
25#include <nvif/cl507c.h>
26#include <nvif/event.h>
27
28#include <drm/drm_atomic_helper.h>
29#include <drm/drm_plane_helper.h>
30#include "nouveau_bo.h"
31
24#include <nvif/cl507c.h>
25#include <nvif/event.h>
26
27#include <drm/drm_atomic_helper.h>
28#include <drm/drm_plane_helper.h>
29#include "nouveau_bo.h"
30
32static u32
31u32
33base507c_update(struct nv50_wndw *wndw, u32 interlock)
34{
35 u32 *push;
32base507c_update(struct nv50_wndw *wndw, u32 interlock)
33{
34 u32 *push;
36
37 if (!(push = evo_wait(&wndw->wndw, 2)))
38 return 0;
39 evo_mthd(push, 0x0080, 1);
40 evo_data(push, interlock);
41 evo_kick(push, &wndw->wndw);
42
43 if (wndw->wndw.base.user.oclass < GF110_DISP_BASE_CHANNEL_DMA)
35 if ((push = evo_wait(&wndw->wndw, 2))) {
36 evo_mthd(push, 0x0080, 1);
37 evo_data(push, interlock);
38 evo_kick(push, &wndw->wndw);
44 return interlock ? 2 << (wndw->id * 8) : 0;
39 return interlock ? 2 << (wndw->id * 8) : 0;
45 return interlock ? 2 << (wndw->id * 4) : 0;
40 }
41 return 0;
46}
47
42}
43
48static void
44void
49base507c_lut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
50{
51 u32 *push;
52 if ((push = evo_wait(&wndw->wndw, 2))) {
53 evo_mthd(push, 0x00e0, 1);
54 evo_data(push, asyw->lut.enable << 30);
55 evo_kick(push, &wndw->wndw);
56 }
57}
58
45base507c_lut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
46{
47 u32 *push;
48 if ((push = evo_wait(&wndw->wndw, 2))) {
49 evo_mthd(push, 0x00e0, 1);
50 evo_data(push, asyw->lut.enable << 30);
51 evo_kick(push, &wndw->wndw);
52 }
53}
54
59static void
55void
60base507c_image_clr(struct nv50_wndw *wndw)
61{
62 u32 *push;
63 if ((push = evo_wait(&wndw->wndw, 4))) {
64 evo_mthd(push, 0x0084, 1);
65 evo_data(push, 0x00000000);
66 evo_mthd(push, 0x00c0, 1);
67 evo_data(push, 0x00000000);
68 evo_kick(push, &wndw->wndw);
69 }
70}
71
72static void
73base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
74{
56base507c_image_clr(struct nv50_wndw *wndw)
57{
58 u32 *push;
59 if ((push = evo_wait(&wndw->wndw, 4))) {
60 evo_mthd(push, 0x0084, 1);
61 evo_data(push, 0x00000000);
62 evo_mthd(push, 0x00c0, 1);
63 evo_data(push, 0x00000000);
64 evo_kick(push, &wndw->wndw);
65 }
66}
67
68static void
69base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
70{
75 const s32 oclass = wndw->wndw.base.user.oclass;
76 u32 *push;
77 if ((push = evo_wait(&wndw->wndw, 10))) {
78 evo_mthd(push, 0x0084, 1);
79 evo_data(push, asyw->image.mode << 8 |
80 asyw->image.interval << 4);
81 evo_mthd(push, 0x00c0, 1);
82 evo_data(push, asyw->image.handle);
71 u32 *push;
72 if ((push = evo_wait(&wndw->wndw, 10))) {
73 evo_mthd(push, 0x0084, 1);
74 evo_data(push, asyw->image.mode << 8 |
75 asyw->image.interval << 4);
76 evo_mthd(push, 0x00c0, 1);
77 evo_data(push, asyw->image.handle);
83 if (oclass < G82_DISP_BASE_CHANNEL_DMA) {
84 evo_mthd(push, 0x0800, 5);
85 evo_data(push, asyw->image.offset >> 8);
86 evo_data(push, 0x00000000);
87 evo_data(push, (asyw->image.h << 16) | asyw->image.w);
88 evo_data(push, (asyw->image.layout << 20) |
89 asyw->image.pitch |
90 asyw->image.block);
91 evo_data(push, (asyw->image.kind << 16) |
92 (asyw->image.format << 8));
93 } else
94 if (oclass < GF110_DISP_BASE_CHANNEL_DMA) {
95 evo_mthd(push, 0x0800, 5);
96 evo_data(push, asyw->image.offset >> 8);
97 evo_data(push, 0x00000000);
98 evo_data(push, (asyw->image.h << 16) | asyw->image.w);
99 evo_data(push, (asyw->image.layout << 20) |
100 asyw->image.pitch |
101 asyw->image.block);
102 evo_data(push, asyw->image.format << 8);
103 } else {
104 evo_mthd(push, 0x0400, 5);
105 evo_data(push, asyw->image.offset >> 8);
106 evo_data(push, 0x00000000);
107 evo_data(push, (asyw->image.h << 16) | asyw->image.w);
108 evo_data(push, (asyw->image.layout << 24) |
109 asyw->image.pitch |
110 asyw->image.block);
111 evo_data(push, asyw->image.format << 8);
112 }
78 evo_mthd(push, 0x0800, 5);
79 evo_data(push, asyw->image.offset >> 8);
80 evo_data(push, 0x00000000);
81 evo_data(push, asyw->image.h << 16 | asyw->image.w);
82 evo_data(push, asyw->image.layout << 20 |
83 asyw->image.pitch |
84 asyw->image.block);
85 evo_data(push, asyw->image.kind << 16 |
86 asyw->image.format << 8);
113 evo_kick(push, &wndw->wndw);
114 }
115}
116
87 evo_kick(push, &wndw->wndw);
88 }
89}
90
117static int
118base507c_ntfy_wait_begun(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
91int
92base507c_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
93 struct nvif_device *device)
119{
94{
120 struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
121 struct nv50_disp *disp = nv50_disp(wndw->plane.dev);
122 if (nvif_msec(&drm->client.device, 2000ULL,
123 u32 data = nouveau_bo_rd32(disp->sync, asyw->ntfy.offset / 4);
95 s64 time = nvif_msec(device, 2000ULL,
96 u32 data = nouveau_bo_rd32(bo, offset / 4);
124 if ((data & 0xc0000000) == 0x40000000)
125 break;
126 usleep_range(1, 2);
97 if ((data & 0xc0000000) == 0x40000000)
98 break;
99 usleep_range(1, 2);
127 ) < 0)
128 return -ETIMEDOUT;
129 return 0;
100 );
101 return time < 0 ? time : 0;
130}
131
102}
103
132static void
104void
133base507c_ntfy_clr(struct nv50_wndw *wndw)
134{
135 u32 *push;
136 if ((push = evo_wait(&wndw->wndw, 2))) {
137 evo_mthd(push, 0x00a4, 1);
138 evo_data(push, 0x00000000);
139 evo_kick(push, &wndw->wndw);
140 }
141}
142
105base507c_ntfy_clr(struct nv50_wndw *wndw)
106{
107 u32 *push;
108 if ((push = evo_wait(&wndw->wndw, 2))) {
109 evo_mthd(push, 0x00a4, 1);
110 evo_data(push, 0x00000000);
111 evo_kick(push, &wndw->wndw);
112 }
113}
114
143static void
115void
144base507c_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
145{
146 u32 *push;
147 if ((push = evo_wait(&wndw->wndw, 3))) {
148 evo_mthd(push, 0x00a0, 2);
149 evo_data(push, asyw->ntfy.awaken << 30 | asyw->ntfy.offset);
150 evo_data(push, asyw->ntfy.handle);
151 evo_kick(push, &wndw->wndw);
152 }
153}
154
116base507c_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
117{
118 u32 *push;
119 if ((push = evo_wait(&wndw->wndw, 3))) {
120 evo_mthd(push, 0x00a0, 2);
121 evo_data(push, asyw->ntfy.awaken << 30 | asyw->ntfy.offset);
122 evo_data(push, asyw->ntfy.handle);
123 evo_kick(push, &wndw->wndw);
124 }
125}
126
155static void
127void
128base507c_ntfy_reset(struct nouveau_bo *bo, u32 offset)
129{
130 nouveau_bo_wr32(bo, offset / 4, 0x00000000);
131}
132
133void
156base507c_sema_clr(struct nv50_wndw *wndw)
157{
158 u32 *push;
159 if ((push = evo_wait(&wndw->wndw, 2))) {
160 evo_mthd(push, 0x0094, 1);
161 evo_data(push, 0x00000000);
162 evo_kick(push, &wndw->wndw);
163 }
164}
165
134base507c_sema_clr(struct nv50_wndw *wndw)
135{
136 u32 *push;
137 if ((push = evo_wait(&wndw->wndw, 2))) {
138 evo_mthd(push, 0x0094, 1);
139 evo_data(push, 0x00000000);
140 evo_kick(push, &wndw->wndw);
141 }
142}
143
166static void
144void
167base507c_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
168{
169 u32 *push;
170 if ((push = evo_wait(&wndw->wndw, 5))) {
171 evo_mthd(push, 0x0088, 4);
172 evo_data(push, asyw->sema.offset);
173 evo_data(push, asyw->sema.acquire);
174 evo_data(push, asyw->sema.release);
175 evo_data(push, asyw->sema.handle);
176 evo_kick(push, &wndw->wndw);
177 }
178}
179
145base507c_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
146{
147 u32 *push;
148 if ((push = evo_wait(&wndw->wndw, 5))) {
149 evo_mthd(push, 0x0088, 4);
150 evo_data(push, asyw->sema.offset);
151 evo_data(push, asyw->sema.acquire);
152 evo_data(push, asyw->sema.release);
153 evo_data(push, asyw->sema.handle);
154 evo_kick(push, &wndw->wndw);
155 }
156}
157
180static void
158void
181base507c_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
182 struct nv50_head_atom *asyh)
183{
184 asyh->base.cpp = 0;
185}
186
159base507c_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
160 struct nv50_head_atom *asyh)
161{
162 asyh->base.cpp = 0;
163}
164
187static int
165int
188base507c_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
189 struct nv50_head_atom *asyh)
190{
191 const struct drm_framebuffer *fb = asyw->state.fb;
192 int ret;
193
194 if (!fb->format->depth)
195 return -EINVAL;

--- 28 unchanged lines hidden (view full) ---

224 return -EINVAL;
225 }
226
227 asyw->lut.enable = 1;
228 asyw->set.image = true;
229 return 0;
230}
231
166base507c_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
167 struct nv50_head_atom *asyh)
168{
169 const struct drm_framebuffer *fb = asyw->state.fb;
170 int ret;
171
172 if (!fb->format->depth)
173 return -EINVAL;

--- 28 unchanged lines hidden (view full) ---

202 return -EINVAL;
203 }
204
205 asyw->lut.enable = 1;
206 asyw->set.image = true;
207 return 0;
208}
209
232static const u32
210const u32
233base507c_format[] = {
234 DRM_FORMAT_C8,
235 DRM_FORMAT_RGB565,
236 DRM_FORMAT_XRGB1555,
237 DRM_FORMAT_ARGB1555,
238 DRM_FORMAT_XRGB8888,
239 DRM_FORMAT_ARGB8888,
240 DRM_FORMAT_XBGR2101010,

--- 4 unchanged lines hidden (view full) ---

245};
246
247static const struct nv50_wndw_func
248base507c = {
249 .acquire = base507c_acquire,
250 .release = base507c_release,
251 .sema_set = base507c_sema_set,
252 .sema_clr = base507c_sema_clr,
211base507c_format[] = {
212 DRM_FORMAT_C8,
213 DRM_FORMAT_RGB565,
214 DRM_FORMAT_XRGB1555,
215 DRM_FORMAT_ARGB1555,
216 DRM_FORMAT_XRGB8888,
217 DRM_FORMAT_ARGB8888,
218 DRM_FORMAT_XBGR2101010,

--- 4 unchanged lines hidden (view full) ---

223};
224
225static const struct nv50_wndw_func
226base507c = {
227 .acquire = base507c_acquire,
228 .release = base507c_release,
229 .sema_set = base507c_sema_set,
230 .sema_clr = base507c_sema_clr,
231 .ntfy_reset = base507c_ntfy_reset,
253 .ntfy_set = base507c_ntfy_set,
254 .ntfy_clr = base507c_ntfy_clr,
255 .ntfy_wait_begun = base507c_ntfy_wait_begun,
256 .image_set = base507c_image_set,
257 .image_clr = base507c_image_clr,
258 .lut = base507c_lut,
259 .update = base507c_update,
260};
261
232 .ntfy_set = base507c_ntfy_set,
233 .ntfy_clr = base507c_ntfy_clr,
234 .ntfy_wait_begun = base507c_ntfy_wait_begun,
235 .image_set = base507c_image_set,
236 .image_clr = base507c_image_clr,
237 .lut = base507c_lut,
238 .update = base507c_update,
239};
240
262static int
241int
263base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
264 struct nouveau_drm *drm, int head, s32 oclass,
265 struct nv50_wndw **pwndw)
266{
267 struct nv50_disp_base_channel_dma_v0 args = {
268 .head = head,
269 };
270 struct nv50_disp *disp = nv50_disp(drm->dev);

--- 37 unchanged lines hidden ---
242base507c_new_(const struct nv50_wndw_func *func, const u32 *format,
243 struct nouveau_drm *drm, int head, s32 oclass,
244 struct nv50_wndw **pwndw)
245{
246 struct nv50_disp_base_channel_dma_v0 args = {
247 .head = head,
248 };
249 struct nv50_disp *disp = nv50_disp(drm->dev);

--- 37 unchanged lines hidden ---