1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "ovly.h"
23#include "atom.h"
24
25#include <drm/drm_atomic_helper.h>
26#include <drm/drm_plane_helper.h>
27
28#include <nvif/cl507e.h>
29#include <nvif/event.h>
30
31void
32ovly507e_update(struct nv50_wndw *wndw, u32 *interlock)
33{
34 u32 *push;
35 if ((push = evo_wait(&wndw->wndw, 2))) {
36 evo_mthd(push, 0x0080, 1);
37 evo_data(push, interlock[NV50_DISP_INTERLOCK_CORE]);
38 evo_kick(push, &wndw->wndw);
39 }
40}
41
42void
43ovly507e_scale_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
44{
45 u32 *push;
46 if ((push = evo_wait(&wndw->wndw, 4))) {
47 evo_mthd(push, 0x00e0, 3);
48 evo_data(push, asyw->scale.sy << 16 | asyw->scale.sx);
49 evo_data(push, asyw->scale.sh << 16 | asyw->scale.sw);
50 evo_data(push, asyw->scale.dw);
51 evo_kick(push, &wndw->wndw);
52 }
53}
54
55void
56ovly507e_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
69ovly507e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
70{
71 u32 *push;
72 if ((push = evo_wait(&wndw->wndw, 12))) {
73 evo_mthd(push, 0x0084, 1);
74 evo_data(push, asyw->image.interval << 4);
75 evo_mthd(push, 0x00c0, 1);
76 evo_data(push, asyw->image.handle[0]);
77 evo_mthd(push, 0x0100, 1);
78 evo_data(push, 0x00000002);
79 evo_mthd(push, 0x0800, 1);
80 evo_data(push, asyw->image.offset[0] >> 8);
81 evo_mthd(push, 0x0808, 3);
82 evo_data(push, asyw->image.h << 16 | asyw->image.w);
83 evo_data(push, asyw->image.layout << 20 |
84 (asyw->image.pitch[0] >> 8) << 8 |
85 asyw->image.blocks[0] << 8 |
86 asyw->image.blockh);
87 evo_data(push, asyw->image.kind << 16 |
88 asyw->image.format << 8 |
89 asyw->image.colorspace);
90 evo_kick(push, &wndw->wndw);
91 }
92}
93
94void
95ovly507e_ntfy_clr(struct nv50_wndw *wndw)
96{
97 u32 *push;
98 if ((push = evo_wait(&wndw->wndw, 2))) {
99 evo_mthd(push, 0x00a4, 1);
100 evo_data(push, 0x00000000);
101 evo_kick(push, &wndw->wndw);
102 }
103}
104
105void
106ovly507e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
107{
108 u32 *push;
109 if ((push = evo_wait(&wndw->wndw, 3))) {
110 evo_mthd(push, 0x00a0, 2);
111 evo_data(push, asyw->ntfy.awaken << 30 | asyw->ntfy.offset);
112 evo_data(push, asyw->ntfy.handle);
113 evo_kick(push, &wndw->wndw);
114 }
115}
116
117void
118ovly507e_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
119 struct nv50_head_atom *asyh)
120{
121 asyh->ovly.cpp = 0;
122}
123
124int
125ovly507e_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
126 struct nv50_head_atom *asyh)
127{
128 const struct drm_framebuffer *fb = asyw->state.fb;
129 int ret;
130
131 ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
132 DRM_PLANE_HELPER_NO_SCALING,
133 DRM_PLANE_HELPER_NO_SCALING,
134 true, true);
135 if (ret)
136 return ret;
137
138 asyh->ovly.cpp = fb->format->cpp[0];
139 return 0;
140}
141
142#include "nouveau_bo.h"
143
144static const struct nv50_wndw_func
145ovly507e = {
146 .acquire = ovly507e_acquire,
147 .release = ovly507e_release,
148 .ntfy_set = ovly507e_ntfy_set,
149 .ntfy_clr = ovly507e_ntfy_clr,
150 .ntfy_reset = base507c_ntfy_reset,
151 .ntfy_wait_begun = base507c_ntfy_wait_begun,
152 .image_set = ovly507e_image_set,
153 .image_clr = ovly507e_image_clr,
154 .scale_set = ovly507e_scale_set,
155 .update = ovly507e_update,
156};
157
158static const u32
159ovly507e_format[] = {
160 DRM_FORMAT_YUYV,
161 DRM_FORMAT_UYVY,
162 DRM_FORMAT_XRGB8888,
163 DRM_FORMAT_ARGB8888,
164 DRM_FORMAT_XRGB1555,
165 DRM_FORMAT_ARGB1555,
166 0
167};
168
169int
170ovly507e_new_(const struct nv50_wndw_func *func, const u32 *format,
171 struct nouveau_drm *drm, int head, s32 oclass, u32 interlock_data,
172 struct nv50_wndw **pwndw)
173{
174 struct nv50_disp_overlay_channel_dma_v0 args = {
175 .head = head,
176 };
177 struct nv50_disp *disp = nv50_disp(drm->dev);
178 struct nv50_wndw *wndw;
179 int ret;
180
181 ret = nv50_wndw_new_(func, drm->dev, DRM_PLANE_TYPE_OVERLAY,
182 "ovly", head, format, BIT(head),
183 NV50_DISP_INTERLOCK_OVLY, interlock_data,
184 &wndw);
185 if (*pwndw = wndw, ret)
186 return ret;
187
188 ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
189 &oclass, 0, &args, sizeof(args),
190 disp->sync->bo.offset, &wndw->wndw);
191 if (ret) {
192 NV_ERROR(drm, "ovly%04x allocation failed: %d\n", oclass, ret);
193 return ret;
194 }
195
196 ret = nvif_notify_init(&wndw->wndw.base.user, wndw->notify.func, false,
197 NV50_DISP_OVERLAY_CHANNEL_DMA_V0_NTFY_UEVENT,
198 &(struct nvif_notify_uevent_req) {},
199 sizeof(struct nvif_notify_uevent_req),
200 sizeof(struct nvif_notify_uevent_rep),
201 &wndw->notify);
202 if (ret)
203 return ret;
204
205 wndw->ntfy = NV50_DISP_OVLY_NTFY(wndw->id);
206 wndw->sema = NV50_DISP_OVLY_SEM0(wndw->id);
207 wndw->data = 0x00000000;
208 return 0;
209}
210
211int
212ovly507e_new(struct nouveau_drm *drm, int head, s32 oclass,
213 struct nv50_wndw **pwndw)
214{
215 return ovly507e_new_(&ovly507e, ovly507e_format, drm, head, oclass,
216 0x00000004 << (head * 8), pwndw);
217}
218