2 * Copyright 2010 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.
24 #define NVIF_DEBUG_PRINT_DISABLE
25 #include "nouveau_drv.h"
26 #include "nouveau_dma.h"
27 #include "nouveau_fbcon.h"
28 #include "nouveau_vmm.h"
30 #include <nvif/push206e.h>
33 nv50_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
35 struct nouveau_fbdev *nfbdev = info->par;
36 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
37 struct nouveau_channel *chan = drm->channel;
38 struct nvif_push *push = chan->chan.push;
42 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
43 info->fix.visual == FB_VISUAL_DIRECTCOLOR)
44 colour = ((uint32_t *)info->pseudo_palette)[rect->color];
48 ret = PUSH_WAIT(push, rect->rop == ROP_COPY ? 7 : 11);
52 if (rect->rop != ROP_COPY) {
53 PUSH_NVSQ(push, NV502D, 0x02ac, 1);
56 PUSH_NVSQ(push, NV502D, 0x0588, colour);
57 PUSH_NVSQ(push, NV502D, 0x0600, rect->dx,
59 0x0608, rect->dx + rect->width,
60 0x060c, rect->dy + rect->height);
62 if (rect->rop != ROP_COPY) {
63 PUSH_NVSQ(push, NV502D, 0x02ac, 3);
71 nv50_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *region)
73 struct nouveau_fbdev *nfbdev = info->par;
74 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
75 struct nouveau_channel *chan = drm->channel;
76 struct nvif_push *push = chan->chan.push;
79 ret = PUSH_WAIT(push, 12);
83 PUSH_NVSQ(push, NV502D, 0x0110, 0);
84 PUSH_NVSQ(push, NV502D, 0x08b0, region->dx,
86 0x08b8, region->width,
87 0x08bc, region->height);
88 PUSH_NVSQ(push, NV502D, 0x08d0, 0,
97 nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
99 struct nouveau_fbdev *nfbdev = info->par;
100 struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
101 struct nouveau_channel *chan = drm->channel;
102 struct nvif_push *push = chan->chan.push;
103 uint32_t dwords, *data = (uint32_t *)image->data;
104 uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
105 uint32_t *palette = info->pseudo_palette, bg, fg;
108 if (image->depth != 1)
111 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
112 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
113 bg = palette[image->bg_color] | mask;
114 fg = palette[image->fg_color] | mask;
116 bg = image->bg_color;
117 fg = image->fg_color;
120 ret = PUSH_WAIT(push, 11);
124 PUSH_NVSQ(push, NV502D, 0x0814, bg,
126 PUSH_NVSQ(push, NV502D, 0x0838, image->width,
127 0x083c, image->height);
128 PUSH_NVSQ(push, NV502D, 0x0850, 0,
133 dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5;
135 int count = dwords > 2047 ? 2047 : dwords;
137 ret = PUSH_WAIT(push, count + 1);
143 PUSH_NVNI(push, NV502D, 0x0860, data, count);
152 nv50_fbcon_accel_init(struct fb_info *info)
154 struct nouveau_fbdev *nfbdev = info->par;
155 struct drm_device *dev = nfbdev->helper.dev;
156 struct nouveau_drm *drm = nouveau_drm(dev);
157 struct nouveau_channel *chan = drm->channel;
158 struct nvif_push *push = chan->chan.push;
161 switch (info->var.bits_per_pixel) {
172 switch (info->var.transp.length) {
173 case 0: /* depth 24 */
174 case 8: /* depth 32, just use 24.. */
177 case 2: /* depth 30 */
188 ret = nvif_object_ctor(&chan->user, "fbconTwoD", 0x502d, 0x502d,
189 NULL, 0, &nfbdev->twod);
193 ret = PUSH_WAIT(push, 56);
195 nouveau_fbcon_gpu_lockup(info);
199 PUSH_NVSQ(push, NV502D, 0x0000, nfbdev->twod.handle);
200 PUSH_NVSQ(push, NV502D, 0x0184, chan->vram.handle,
201 0x0188, chan->vram.handle,
202 0x018c, chan->vram.handle);
204 PUSH_NVSQ(push, NV502D, 0x0200, format,
206 PUSH_NVSQ(push, NV502D, 0x0214, info->fix.line_length,
207 0x0218, info->var.xres_virtual,
208 0x021c, info->var.yres_virtual,
209 0x0220, upper_32_bits(nfbdev->vma->addr),
210 0x0224, lower_32_bits(nfbdev->vma->addr));
212 PUSH_NVSQ(push, NV502D, 0x0230, format,
214 PUSH_NVSQ(push, NV502D, 0x0244, info->fix.line_length,
215 0x0248, info->var.xres_virtual,
216 0x024c, info->var.yres_virtual,
217 0x0250, upper_32_bits(nfbdev->vma->addr),
218 0x0254, lower_32_bits(nfbdev->vma->addr));
220 PUSH_NVSQ(push, NV502D, 0x0290, 0);
221 PUSH_NVSQ(push, NV502D, 0x02a0, 0x55);
222 PUSH_NVSQ(push, NV502D, 0x02ac, 3);
223 PUSH_NVSQ(push, NV502D, 0x02e8, 2,
226 PUSH_NVSQ(push, NV502D, 0X0580, 4,
229 PUSH_NVSQ(push, NV502D, 0x0800, 1,
234 PUSH_NVSQ(push, NV502D, 0x081c, 1);
235 PUSH_NVSQ(push, NV502D, 0x0840, 0,
240 PUSH_NVSQ(push, NV502D, 0x0888, 1);
241 PUSH_NVSQ(push, NV502D, 0x08c0, 0,