2010-12-16 11:32:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors: Ben Skeggs
|
|
|
|
*/
|
|
|
|
|
2012-07-20 06:17:34 +08:00
|
|
|
#include "nouveau_drm.h"
|
2009-12-11 17:24:15 +08:00
|
|
|
#include "nouveau_dma.h"
|
|
|
|
#include "nouveau_fbcon.h"
|
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
int
|
2009-12-11 17:24:15 +08:00
|
|
|
nv50_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
|
|
|
|
{
|
2010-03-30 13:34:14 +08:00
|
|
|
struct nouveau_fbdev *nfbdev = info->par;
|
2012-07-31 14:16:21 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
|
2012-07-20 06:17:34 +08:00
|
|
|
struct nouveau_channel *chan = drm->channel;
|
2010-10-05 14:41:29 +08:00
|
|
|
int ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
ret = RING_SPACE(chan, rect->rop == ROP_COPY ? 7 : 11);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
if (rect->rop != ROP_COPY) {
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x02ac, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 1);
|
|
|
|
}
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0588, 1);
|
2010-01-04 07:10:55 +08:00
|
|
|
if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
|
|
|
|
info->fix.visual == FB_VISUAL_DIRECTCOLOR)
|
|
|
|
OUT_RING(chan, ((uint32_t *)info->pseudo_palette)[rect->color]);
|
|
|
|
else
|
|
|
|
OUT_RING(chan, rect->color);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0600, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, rect->dx);
|
|
|
|
OUT_RING(chan, rect->dy);
|
|
|
|
OUT_RING(chan, rect->dx + rect->width);
|
|
|
|
OUT_RING(chan, rect->dy + rect->height);
|
|
|
|
if (rect->rop != ROP_COPY) {
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x02ac, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 3);
|
|
|
|
}
|
|
|
|
FIRE_RING(chan);
|
2010-10-05 14:41:29 +08:00
|
|
|
return 0;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
int
|
2009-12-11 17:24:15 +08:00
|
|
|
nv50_fbcon_copyarea(struct fb_info *info, const struct fb_copyarea *region)
|
|
|
|
{
|
2010-03-30 13:34:14 +08:00
|
|
|
struct nouveau_fbdev *nfbdev = info->par;
|
2012-07-31 14:16:21 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
|
2012-07-20 06:17:34 +08:00
|
|
|
struct nouveau_channel *chan = drm->channel;
|
2010-10-05 14:41:29 +08:00
|
|
|
int ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
ret = RING_SPACE(chan, 12);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0110, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x08b0, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, region->dx);
|
|
|
|
OUT_RING(chan, region->dy);
|
|
|
|
OUT_RING(chan, region->width);
|
|
|
|
OUT_RING(chan, region->height);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x08d0, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, region->sx);
|
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, region->sy);
|
|
|
|
FIRE_RING(chan);
|
2010-10-05 14:41:29 +08:00
|
|
|
return 0;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
int
|
2009-12-11 17:24:15 +08:00
|
|
|
nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
|
|
|
|
{
|
2010-03-30 13:34:14 +08:00
|
|
|
struct nouveau_fbdev *nfbdev = info->par;
|
2012-07-31 14:16:21 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
|
2012-07-20 06:17:34 +08:00
|
|
|
struct nouveau_channel *chan = drm->channel;
|
2009-12-11 17:24:15 +08:00
|
|
|
uint32_t width, dwords, *data = (uint32_t *)image->data;
|
|
|
|
uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
|
|
|
|
uint32_t *palette = info->pseudo_palette;
|
2010-10-05 14:41:29 +08:00
|
|
|
int ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
if (image->depth != 1)
|
|
|
|
return -ENODEV;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
ret = RING_SPACE(chan, 11);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
2010-02-25 12:27:10 +08:00
|
|
|
width = ALIGN(image->width, 32);
|
2009-12-11 17:24:15 +08:00
|
|
|
dwords = (width * image->height) >> 5;
|
|
|
|
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0814, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
|
|
|
|
info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
|
|
|
|
OUT_RING(chan, palette[image->bg_color] | mask);
|
|
|
|
OUT_RING(chan, palette[image->fg_color] | mask);
|
|
|
|
} else {
|
|
|
|
OUT_RING(chan, image->bg_color);
|
|
|
|
OUT_RING(chan, image->fg_color);
|
|
|
|
}
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0838, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, image->width);
|
|
|
|
OUT_RING(chan, image->height);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0850, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, image->dx);
|
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, image->dy);
|
|
|
|
|
|
|
|
while (dwords) {
|
|
|
|
int push = dwords > 2047 ? 2047 : dwords;
|
|
|
|
|
2010-10-05 14:41:29 +08:00
|
|
|
ret = RING_SPACE(chan, push + 1);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
dwords -= push;
|
|
|
|
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NI04(chan, NvSub2D, 0x0860, push);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RINGp(chan, data, push);
|
|
|
|
data += push;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIRE_RING(chan);
|
2010-10-05 14:41:29 +08:00
|
|
|
return 0;
|
2009-12-11 17:24:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nv50_fbcon_accel_init(struct fb_info *info)
|
|
|
|
{
|
2010-03-30 13:34:14 +08:00
|
|
|
struct nouveau_fbdev *nfbdev = info->par;
|
2011-06-07 11:12:44 +08:00
|
|
|
struct nouveau_framebuffer *fb = &nfbdev->nouveau_fb;
|
2012-07-20 06:17:34 +08:00
|
|
|
struct drm_device *dev = nfbdev->dev;
|
2012-07-31 14:16:21 +08:00
|
|
|
struct nouveau_drm *drm = nouveau_drm(dev);
|
2012-07-20 06:17:34 +08:00
|
|
|
struct nouveau_channel *chan = drm->channel;
|
2009-12-11 17:24:15 +08:00
|
|
|
int ret, format;
|
2010-03-16 11:20:58 +08:00
|
|
|
|
2009-12-11 17:24:15 +08:00
|
|
|
switch (info->var.bits_per_pixel) {
|
|
|
|
case 8:
|
|
|
|
format = 0xf3;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
format = 0xf8;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
format = 0xe8;
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
switch (info->var.transp.length) {
|
|
|
|
case 0: /* depth 24 */
|
|
|
|
case 8: /* depth 32, just use 24.. */
|
|
|
|
format = 0xe6;
|
|
|
|
break;
|
|
|
|
case 2: /* depth 30 */
|
|
|
|
format = 0xd1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2014-08-10 02:10:23 +08:00
|
|
|
ret = nvif_object_init(chan->object, NULL, 0x502d, 0x502d, NULL, 0,
|
2014-08-10 02:10:22 +08:00
|
|
|
&nfbdev->twod);
|
2009-12-11 17:24:15 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = RING_SPACE(chan, 59);
|
|
|
|
if (ret) {
|
2010-01-05 02:25:09 +08:00
|
|
|
nouveau_fbcon_gpu_lockup(info);
|
2009-12-11 17:24:15 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0000, 1);
|
2014-08-10 02:10:23 +08:00
|
|
|
OUT_RING(chan, nfbdev->twod.handle);
|
2012-05-04 12:01:52 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0184, 3);
|
2014-08-10 02:10:23 +08:00
|
|
|
OUT_RING(chan, chan->vram.handle);
|
|
|
|
OUT_RING(chan, chan->vram.handle);
|
|
|
|
OUT_RING(chan, chan->vram.handle);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0290, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0888, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x02ac, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 3);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x02a0, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0x55);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x08c0, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, 1);
|
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0580, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 4);
|
|
|
|
OUT_RING(chan, format);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x02e8, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 2);
|
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0804, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, format);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0800, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0808, 3);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, 0);
|
2010-02-28 02:13:35 +08:00
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x081c, 1);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0840, 4);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, 1);
|
|
|
|
OUT_RING(chan, 0);
|
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0200, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, format);
|
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0214, 5);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, info->fix.line_length);
|
|
|
|
OUT_RING(chan, info->var.xres_virtual);
|
|
|
|
OUT_RING(chan, info->var.yres_virtual);
|
2011-06-07 11:12:44 +08:00
|
|
|
OUT_RING(chan, upper_32_bits(fb->vma.offset));
|
|
|
|
OUT_RING(chan, lower_32_bits(fb->vma.offset));
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0230, 2);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, format);
|
|
|
|
OUT_RING(chan, 1);
|
2012-04-01 19:09:13 +08:00
|
|
|
BEGIN_NV04(chan, NvSub2D, 0x0244, 5);
|
2009-12-11 17:24:15 +08:00
|
|
|
OUT_RING(chan, info->fix.line_length);
|
|
|
|
OUT_RING(chan, info->var.xres_virtual);
|
|
|
|
OUT_RING(chan, info->var.yres_virtual);
|
2011-06-07 11:12:44 +08:00
|
|
|
OUT_RING(chan, upper_32_bits(fb->vma.offset));
|
|
|
|
OUT_RING(chan, lower_32_bits(fb->vma.offset));
|
2009-12-11 17:24:15 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|