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.
25 #include <drm/drm_atomic_helper.h>
26 #include <drm/drm_fourcc.h>
27 #include <drm/drm_plane_helper.h>
29 #include <nvif/cl507e.h>
30 #include <nvif/event.h>
33 ovly507e_update(struct nv50_wndw
*wndw
, u32
*interlock
)
36 if ((push
= evo_wait(&wndw
->wndw
, 2))) {
37 evo_mthd(push
, 0x0080, 1);
38 evo_data(push
, interlock
[NV50_DISP_INTERLOCK_CORE
]);
39 evo_kick(push
, &wndw
->wndw
);
44 ovly507e_scale_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
47 if ((push
= evo_wait(&wndw
->wndw
, 4))) {
48 evo_mthd(push
, 0x00e0, 3);
49 evo_data(push
, asyw
->scale
.sy
<< 16 | asyw
->scale
.sx
);
50 evo_data(push
, asyw
->scale
.sh
<< 16 | asyw
->scale
.sw
);
51 evo_data(push
, asyw
->scale
.dw
);
52 evo_kick(push
, &wndw
->wndw
);
57 ovly507e_image_clr(struct nv50_wndw
*wndw
)
60 if ((push
= evo_wait(&wndw
->wndw
, 4))) {
61 evo_mthd(push
, 0x0084, 1);
62 evo_data(push
, 0x00000000);
63 evo_mthd(push
, 0x00c0, 1);
64 evo_data(push
, 0x00000000);
65 evo_kick(push
, &wndw
->wndw
);
70 ovly507e_image_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
73 if ((push
= evo_wait(&wndw
->wndw
, 12))) {
74 evo_mthd(push
, 0x0084, 1);
75 evo_data(push
, asyw
->image
.interval
<< 4);
76 evo_mthd(push
, 0x00c0, 1);
77 evo_data(push
, asyw
->image
.handle
[0]);
78 evo_mthd(push
, 0x0100, 1);
79 evo_data(push
, 0x00000002);
80 evo_mthd(push
, 0x0800, 1);
81 evo_data(push
, asyw
->image
.offset
[0] >> 8);
82 evo_mthd(push
, 0x0808, 3);
83 evo_data(push
, asyw
->image
.h
<< 16 | asyw
->image
.w
);
84 evo_data(push
, asyw
->image
.layout
<< 20 |
85 (asyw
->image
.pitch
[0] >> 8) << 8 |
86 asyw
->image
.blocks
[0] << 8 |
88 evo_data(push
, asyw
->image
.kind
<< 16 |
89 asyw
->image
.format
<< 8 |
90 asyw
->image
.colorspace
);
91 evo_kick(push
, &wndw
->wndw
);
96 ovly507e_ntfy_clr(struct nv50_wndw
*wndw
)
99 if ((push
= evo_wait(&wndw
->wndw
, 2))) {
100 evo_mthd(push
, 0x00a4, 1);
101 evo_data(push
, 0x00000000);
102 evo_kick(push
, &wndw
->wndw
);
107 ovly507e_ntfy_set(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
)
110 if ((push
= evo_wait(&wndw
->wndw
, 3))) {
111 evo_mthd(push
, 0x00a0, 2);
112 evo_data(push
, asyw
->ntfy
.awaken
<< 30 | asyw
->ntfy
.offset
);
113 evo_data(push
, asyw
->ntfy
.handle
);
114 evo_kick(push
, &wndw
->wndw
);
119 ovly507e_release(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
,
120 struct nv50_head_atom
*asyh
)
126 ovly507e_acquire(struct nv50_wndw
*wndw
, struct nv50_wndw_atom
*asyw
,
127 struct nv50_head_atom
*asyh
)
129 const struct drm_framebuffer
*fb
= asyw
->state
.fb
;
132 ret
= drm_atomic_helper_check_plane_state(&asyw
->state
, &asyh
->state
,
133 DRM_PLANE_HELPER_NO_SCALING
,
134 DRM_PLANE_HELPER_NO_SCALING
,
139 asyh
->ovly
.cpp
= fb
->format
->cpp
[0];
143 #include "nouveau_bo.h"
145 static const struct nv50_wndw_func
147 .acquire
= ovly507e_acquire
,
148 .release
= ovly507e_release
,
149 .ntfy_set
= ovly507e_ntfy_set
,
150 .ntfy_clr
= ovly507e_ntfy_clr
,
151 .ntfy_reset
= base507c_ntfy_reset
,
152 .ntfy_wait_begun
= base507c_ntfy_wait_begun
,
153 .image_set
= ovly507e_image_set
,
154 .image_clr
= ovly507e_image_clr
,
155 .scale_set
= ovly507e_scale_set
,
156 .update
= ovly507e_update
,
160 ovly507e_format
[] = {
169 ovly507e_new_(const struct nv50_wndw_func
*func
, const u32
*format
,
170 struct nouveau_drm
*drm
, int head
, s32 oclass
, u32 interlock_data
,
171 struct nv50_wndw
**pwndw
)
173 struct nv50_disp_overlay_channel_dma_v0 args
= {
176 struct nv50_disp
*disp
= nv50_disp(drm
->dev
);
177 struct nv50_wndw
*wndw
;
180 ret
= nv50_wndw_new_(func
, drm
->dev
, DRM_PLANE_TYPE_OVERLAY
,
181 "ovly", head
, format
, BIT(head
),
182 NV50_DISP_INTERLOCK_OVLY
, interlock_data
,
184 if (*pwndw
= wndw
, ret
)
187 ret
= nv50_dmac_create(&drm
->client
.device
, &disp
->disp
->object
,
188 &oclass
, 0, &args
, sizeof(args
),
189 disp
->sync
->bo
.offset
, &wndw
->wndw
);
191 NV_ERROR(drm
, "ovly%04x allocation failed: %d\n", oclass
, ret
);
195 ret
= nvif_notify_init(&wndw
->wndw
.base
.user
, wndw
->notify
.func
, false,
196 NV50_DISP_OVERLAY_CHANNEL_DMA_V0_NTFY_UEVENT
,
197 &(struct nvif_notify_uevent_req
) {},
198 sizeof(struct nvif_notify_uevent_req
),
199 sizeof(struct nvif_notify_uevent_rep
),
204 wndw
->ntfy
= NV50_DISP_OVLY_NTFY(wndw
->id
);
205 wndw
->sema
= NV50_DISP_OVLY_SEM0(wndw
->id
);
206 wndw
->data
= 0x00000000;
211 ovly507e_new(struct nouveau_drm
*drm
, int head
, s32 oclass
,
212 struct nv50_wndw
**pwndw
)
214 return ovly507e_new_(&ovly507e
, ovly507e_format
, drm
, head
, oclass
,
215 0x00000004 << (head
* 8), pwndw
);