forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/nouveau/nv04_fbcon.c
....@@ -21,10 +21,12 @@
2121 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2222 * DEALINGS IN THE SOFTWARE.
2323 */
24
-
24
+#define NVIF_DEBUG_PRINT_DISABLE
2525 #include "nouveau_drv.h"
2626 #include "nouveau_dma.h"
2727 #include "nouveau_fbcon.h"
28
+
29
+#include <nvif/push006c.h>
2830
2931 int
3032 nv04_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *region)
....@@ -32,17 +34,17 @@
3234 struct nouveau_fbdev *nfbdev = info->par;
3335 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
3436 struct nouveau_channel *chan = drm->channel;
37
+ struct nvif_push *push = chan->chan.push;
3538 int ret;
3639
37
- ret = RING_SPACE(chan, 4);
40
+ ret = PUSH_WAIT(push, 4);
3841 if (ret)
3942 return ret;
4043
41
- BEGIN_NV04(chan, NvSubImageBlit, 0x0300, 3);
42
- OUT_RING(chan, (region->sy << 16) | region->sx);
43
- OUT_RING(chan, (region->dy << 16) | region->dx);
44
- OUT_RING(chan, (region->height << 16) | region->width);
45
- FIRE_RING(chan);
44
+ PUSH_NVSQ(push, NV05F, 0x0300, (region->sy << 16) | region->sx,
45
+ 0x0304, (region->dy << 16) | region->dx,
46
+ 0x0308, (region->height << 16) | region->width);
47
+ PUSH_KICK(push);
4648 return 0;
4749 }
4850
....@@ -52,24 +54,22 @@
5254 struct nouveau_fbdev *nfbdev = info->par;
5355 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
5456 struct nouveau_channel *chan = drm->channel;
57
+ struct nvif_push *push = chan->chan.push;
5558 int ret;
5659
57
- ret = RING_SPACE(chan, 7);
60
+ ret = PUSH_WAIT(push, 7);
5861 if (ret)
5962 return ret;
6063
61
- BEGIN_NV04(chan, NvSubGdiRect, 0x02fc, 1);
62
- OUT_RING(chan, (rect->rop != ROP_COPY) ? 1 : 3);
63
- BEGIN_NV04(chan, NvSubGdiRect, 0x03fc, 1);
64
+ PUSH_NVSQ(push, NV04A, 0x02fc, (rect->rop != ROP_COPY) ? 1 : 3);
6465 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
6566 info->fix.visual == FB_VISUAL_DIRECTCOLOR)
66
- OUT_RING(chan, ((uint32_t *)info->pseudo_palette)[rect->color]);
67
+ PUSH_NVSQ(push, NV04A, 0x03fc, ((uint32_t *)info->pseudo_palette)[rect->color]);
6768 else
68
- OUT_RING(chan, rect->color);
69
- BEGIN_NV04(chan, NvSubGdiRect, 0x0400, 2);
70
- OUT_RING(chan, (rect->dx << 16) | rect->dy);
71
- OUT_RING(chan, (rect->width << 16) | rect->height);
72
- FIRE_RING(chan);
69
+ PUSH_NVSQ(push, NV04A, 0x03fc, rect->color);
70
+ PUSH_NVSQ(push, NV04A, 0x0400, (rect->dx << 16) | rect->dy,
71
+ 0x0404, (rect->width << 16) | rect->height);
72
+ PUSH_KICK(push);
7373 return 0;
7474 }
7575
....@@ -79,6 +79,7 @@
7979 struct nouveau_fbdev *nfbdev = info->par;
8080 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
8181 struct nouveau_channel *chan = drm->channel;
82
+ struct nvif_push *push = chan->chan.push;
8283 uint32_t fg;
8384 uint32_t bg;
8485 uint32_t dsize;
....@@ -88,7 +89,7 @@
8889 if (image->depth != 1)
8990 return -ENODEV;
9091
91
- ret = RING_SPACE(chan, 8);
92
+ ret = PUSH_WAIT(push, 8);
9293 if (ret)
9394 return ret;
9495
....@@ -101,31 +102,29 @@
101102 bg = image->bg_color;
102103 }
103104
104
- BEGIN_NV04(chan, NvSubGdiRect, 0x0be4, 7);
105
- OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
106
- OUT_RING(chan, ((image->dy + image->height) << 16) |
107
- ((image->dx + image->width) & 0xffff));
108
- OUT_RING(chan, bg);
109
- OUT_RING(chan, fg);
110
- OUT_RING(chan, (image->height << 16) | ALIGN(image->width, 8));
111
- OUT_RING(chan, (image->height << 16) | image->width);
112
- OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
105
+ PUSH_NVSQ(push, NV04A, 0x0be4, (image->dy << 16) | (image->dx & 0xffff),
106
+ 0x0be8, ((image->dy + image->height) << 16) |
107
+ ((image->dx + image->width) & 0xffff),
108
+ 0x0bec, bg,
109
+ 0x0bf0, fg,
110
+ 0x0bf4, (image->height << 16) | ALIGN(image->width, 8),
111
+ 0x0bf8, (image->height << 16) | image->width,
112
+ 0x0bfc, (image->dy << 16) | (image->dx & 0xffff));
113113
114114 dsize = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5;
115115 while (dsize) {
116116 int iter_len = dsize > 128 ? 128 : dsize;
117117
118
- ret = RING_SPACE(chan, iter_len + 1);
118
+ ret = PUSH_WAIT(push, iter_len + 1);
119119 if (ret)
120120 return ret;
121121
122
- BEGIN_NV04(chan, NvSubGdiRect, 0x0c00, iter_len);
123
- OUT_RINGp(chan, data, iter_len);
122
+ PUSH_NVSQ(push, NV04A, 0x0c00, data, iter_len);
124123 data += iter_len;
125124 dsize -= iter_len;
126125 }
127126
128
- FIRE_RING(chan);
127
+ PUSH_KICK(push);
129128 return 0;
130129 }
131130
....@@ -137,6 +136,7 @@
137136 struct nouveau_drm *drm = nouveau_drm(dev);
138137 struct nouveau_channel *chan = drm->channel;
139138 struct nvif_device *device = &drm->client.device;
139
+ struct nvif_push *push = chan->chan.push;
140140 int surface_fmt, pattern_fmt, rect_fmt;
141141 int ret;
142142
....@@ -168,110 +168,90 @@
168168 return -EINVAL;
169169 }
170170
171
- ret = nvif_object_init(&chan->user, 0x0062,
171
+ ret = nvif_object_ctor(&chan->user, "fbconCtxSurf2d", 0x0062,
172172 device->info.family >= NV_DEVICE_INFO_V0_CELSIUS ?
173173 0x0062 : 0x0042, NULL, 0, &nfbdev->surf2d);
174174 if (ret)
175175 return ret;
176176
177
- ret = nvif_object_init(&chan->user, 0x0019, 0x0019, NULL, 0,
178
- &nfbdev->clip);
177
+ ret = nvif_object_ctor(&chan->user, "fbconCtxClip", 0x0019, 0x0019,
178
+ NULL, 0, &nfbdev->clip);
179179 if (ret)
180180 return ret;
181181
182
- ret = nvif_object_init(&chan->user, 0x0043, 0x0043, NULL, 0,
183
- &nfbdev->rop);
182
+ ret = nvif_object_ctor(&chan->user, "fbconCtxRop", 0x0043, 0x0043,
183
+ NULL, 0, &nfbdev->rop);
184184 if (ret)
185185 return ret;
186186
187
- ret = nvif_object_init(&chan->user, 0x0044, 0x0044, NULL, 0,
188
- &nfbdev->patt);
187
+ ret = nvif_object_ctor(&chan->user, "fbconCtxPatt", 0x0044, 0x0044,
188
+ NULL, 0, &nfbdev->patt);
189189 if (ret)
190190 return ret;
191191
192
- ret = nvif_object_init(&chan->user, 0x004a, 0x004a, NULL, 0,
193
- &nfbdev->gdi);
192
+ ret = nvif_object_ctor(&chan->user, "fbconGdiRectText", 0x004a, 0x004a,
193
+ NULL, 0, &nfbdev->gdi);
194194 if (ret)
195195 return ret;
196196
197
- ret = nvif_object_init(&chan->user, 0x005f,
197
+ ret = nvif_object_ctor(&chan->user, "fbconImageBlit", 0x005f,
198198 device->info.chipset >= 0x11 ? 0x009f : 0x005f,
199199 NULL, 0, &nfbdev->blit);
200200 if (ret)
201201 return ret;
202202
203
- if (RING_SPACE(chan, 49 + (device->info.chipset >= 0x11 ? 4 : 0))) {
203
+ if (PUSH_WAIT(push, 49 + (device->info.chipset >= 0x11 ? 4 : 0))) {
204204 nouveau_fbcon_gpu_lockup(info);
205205 return 0;
206206 }
207207
208
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0000, 1);
209
- OUT_RING(chan, nfbdev->surf2d.handle);
210
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0184, 2);
211
- OUT_RING(chan, chan->vram.handle);
212
- OUT_RING(chan, chan->vram.handle);
213
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0300, 4);
214
- OUT_RING(chan, surface_fmt);
215
- OUT_RING(chan, info->fix.line_length | (info->fix.line_length << 16));
216
- OUT_RING(chan, info->fix.smem_start - dev->mode_config.fb_base);
217
- OUT_RING(chan, info->fix.smem_start - dev->mode_config.fb_base);
208
+ PUSH_NVSQ(push, NV042, 0x0000, nfbdev->surf2d.handle);
209
+ PUSH_NVSQ(push, NV042, 0x0184, chan->vram.handle,
210
+ 0x0188, chan->vram.handle);
211
+ PUSH_NVSQ(push, NV042, 0x0300, surface_fmt,
212
+ 0x0304, info->fix.line_length | (info->fix.line_length << 16),
213
+ 0x0308, info->fix.smem_start - dev->mode_config.fb_base,
214
+ 0x030c, info->fix.smem_start - dev->mode_config.fb_base);
218215
219
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0000, 1);
220
- OUT_RING(chan, nfbdev->rop.handle);
221
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0300, 1);
222
- OUT_RING(chan, 0x55);
216
+ PUSH_NVSQ(push, NV043, 0x0000, nfbdev->rop.handle);
217
+ PUSH_NVSQ(push, NV043, 0x0300, 0x55);
223218
224
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0000, 1);
225
- OUT_RING(chan, nfbdev->patt.handle);
226
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0300, 8);
227
- OUT_RING(chan, pattern_fmt);
219
+ PUSH_NVSQ(push, NV044, 0x0000, nfbdev->patt.handle);
220
+ PUSH_NVSQ(push, NV044, 0x0300, pattern_fmt,
228221 #ifdef __BIG_ENDIAN
229
- OUT_RING(chan, 2);
222
+ 0x0304, 2,
230223 #else
231
- OUT_RING(chan, 1);
224
+ 0x0304, 1,
232225 #endif
233
- OUT_RING(chan, 0);
234
- OUT_RING(chan, 1);
235
- OUT_RING(chan, ~0);
236
- OUT_RING(chan, ~0);
237
- OUT_RING(chan, ~0);
238
- OUT_RING(chan, ~0);
226
+ 0x0308, 0,
227
+ 0x030c, 1,
228
+ 0x0310, ~0,
229
+ 0x0314, ~0,
230
+ 0x0318, ~0,
231
+ 0x031c, ~0);
239232
240
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0000, 1);
241
- OUT_RING(chan, nfbdev->clip.handle);
242
- BEGIN_NV04(chan, NvSubCtxSurf2D, 0x0300, 2);
243
- OUT_RING(chan, 0);
244
- OUT_RING(chan, (info->var.yres_virtual << 16) | info->var.xres_virtual);
233
+ PUSH_NVSQ(push, NV019, 0x0000, nfbdev->clip.handle);
234
+ PUSH_NVSQ(push, NV019, 0x0300, 0,
235
+ 0x0304, (info->var.yres_virtual << 16) | info->var.xres_virtual);
245236
246
- BEGIN_NV04(chan, NvSubImageBlit, 0x0000, 1);
247
- OUT_RING(chan, nfbdev->blit.handle);
248
- BEGIN_NV04(chan, NvSubImageBlit, 0x019c, 1);
249
- OUT_RING(chan, nfbdev->surf2d.handle);
250
- BEGIN_NV04(chan, NvSubImageBlit, 0x02fc, 1);
251
- OUT_RING(chan, 3);
252
- if (device->info.chipset >= 0x11 /*XXX: oclass == 0x009f*/) {
253
- BEGIN_NV04(chan, NvSubImageBlit, 0x0120, 3);
254
- OUT_RING(chan, 0);
255
- OUT_RING(chan, 1);
256
- OUT_RING(chan, 2);
237
+ PUSH_NVSQ(push, NV05F, 0x0000, nfbdev->blit.handle);
238
+ PUSH_NVSQ(push, NV05F, 0x019c, nfbdev->surf2d.handle);
239
+ PUSH_NVSQ(push, NV05F, 0x02fc, 3);
240
+ if (nfbdev->blit.oclass == 0x009f) {
241
+ PUSH_NVSQ(push, NV09F, 0x0120, 0,
242
+ 0x0124, 1,
243
+ 0x0128, 2);
257244 }
258245
259
- BEGIN_NV04(chan, NvSubGdiRect, 0x0000, 1);
260
- OUT_RING(chan, nfbdev->gdi.handle);
261
- BEGIN_NV04(chan, NvSubGdiRect, 0x0198, 1);
262
- OUT_RING(chan, nfbdev->surf2d.handle);
263
- BEGIN_NV04(chan, NvSubGdiRect, 0x0188, 2);
264
- OUT_RING(chan, nfbdev->patt.handle);
265
- OUT_RING(chan, nfbdev->rop.handle);
266
- BEGIN_NV04(chan, NvSubGdiRect, 0x0304, 1);
267
- OUT_RING(chan, 1);
268
- BEGIN_NV04(chan, NvSubGdiRect, 0x0300, 1);
269
- OUT_RING(chan, rect_fmt);
270
- BEGIN_NV04(chan, NvSubGdiRect, 0x02fc, 1);
271
- OUT_RING(chan, 3);
246
+ PUSH_NVSQ(push, NV04A, 0x0000, nfbdev->gdi.handle);
247
+ PUSH_NVSQ(push, NV04A, 0x0198, nfbdev->surf2d.handle);
248
+ PUSH_NVSQ(push, NV04A, 0x0188, nfbdev->patt.handle,
249
+ 0x018c, nfbdev->rop.handle);
250
+ PUSH_NVSQ(push, NV04A, 0x0304, 1);
251
+ PUSH_NVSQ(push, NV04A, 0x0300, rect_fmt);
252
+ PUSH_NVSQ(push, NV04A, 0x02fc, 3);
272253
273
- FIRE_RING(chan);
274
-
254
+ PUSH_KICK(push);
275255 return 0;
276256 }
277257