Commit 1d04a64a authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fbcon: convert imageblit() to new push macros

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent d9a91300
...@@ -30,19 +30,6 @@ ...@@ -30,19 +30,6 @@
#include <nvif/user.h> #include <nvif/user.h>
void
OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned nr_dwords)
{
bool is_iomem;
u32 *mem = ttm_kmap_obj_virtual(&chan->push.buffer->kmap, &is_iomem);
mem = &mem[chan->dma.cur];
if (is_iomem)
memcpy_toio((void __force __iomem *)mem, data, nr_dwords * 4);
else
memcpy(mem, data, nr_dwords * 4);
chan->dma.cur += nr_dwords;
}
/* Fetch and adjust GPU GET pointer /* Fetch and adjust GPU GET pointer
* *
* Returns: * Returns:
......
...@@ -101,33 +101,18 @@ OUT_RING(struct nouveau_channel *chan, int data) ...@@ -101,33 +101,18 @@ OUT_RING(struct nouveau_channel *chan, int data)
nouveau_bo_wr32(chan->push.buffer, chan->dma.cur++, data); nouveau_bo_wr32(chan->push.buffer, chan->dma.cur++, data);
} }
extern void
OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned nr_dwords);
static inline void static inline void
BEGIN_NV04(struct nouveau_channel *chan, int subc, int mthd, int size) BEGIN_NV04(struct nouveau_channel *chan, int subc, int mthd, int size)
{ {
OUT_RING(chan, 0x00000000 | (subc << 13) | (size << 18) | mthd); OUT_RING(chan, 0x00000000 | (subc << 13) | (size << 18) | mthd);
} }
static inline void
BEGIN_NI04(struct nouveau_channel *chan, int subc, int mthd, int size)
{
OUT_RING(chan, 0x40000000 | (subc << 13) | (size << 18) | mthd);
}
static inline void static inline void
BEGIN_NVC0(struct nouveau_channel *chan, int subc, int mthd, int size) BEGIN_NVC0(struct nouveau_channel *chan, int subc, int mthd, int size)
{ {
OUT_RING(chan, 0x20000000 | (size << 16) | (subc << 13) | (mthd >> 2)); OUT_RING(chan, 0x20000000 | (size << 16) | (subc << 13) | (mthd >> 2));
} }
static inline void
BEGIN_NIC0(struct nouveau_channel *chan, int subc, int mthd, int size)
{
OUT_RING(chan, 0x60000000 | (size << 16) | (subc << 13) | (mthd >> 2));
}
static inline void static inline void
BEGIN_IMC0(struct nouveau_channel *chan, int subc, int mthd, u16 data) BEGIN_IMC0(struct nouveau_channel *chan, int subc, int mthd, u16 data)
{ {
......
...@@ -81,6 +81,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -81,6 +81,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
struct nouveau_fbdev *nfbdev = info->par; struct nouveau_fbdev *nfbdev = info->par;
struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
struct nvif_push *push = chan->chan.push;
uint32_t fg; uint32_t fg;
uint32_t bg; uint32_t bg;
uint32_t dsize; uint32_t dsize;
...@@ -90,7 +91,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -90,7 +91,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
if (image->depth != 1) if (image->depth != 1)
return -ENODEV; return -ENODEV;
ret = RING_SPACE(chan, 8); ret = PUSH_WAIT(push, 8);
if (ret) if (ret)
return ret; return ret;
...@@ -103,31 +104,29 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -103,31 +104,29 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
bg = image->bg_color; bg = image->bg_color;
} }
BEGIN_NV04(chan, NvSubGdiRect, 0x0be4, 7); PUSH_NVSQ(push, NV04A, 0x0be4, (image->dy << 16) | (image->dx & 0xffff),
OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); 0x0be8, ((image->dy + image->height) << 16) |
OUT_RING(chan, ((image->dy + image->height) << 16) | ((image->dx + image->width) & 0xffff),
((image->dx + image->width) & 0xffff)); 0x0bec, bg,
OUT_RING(chan, bg); 0x0bf0, fg,
OUT_RING(chan, fg); 0x0bf4, (image->height << 16) | ALIGN(image->width, 8),
OUT_RING(chan, (image->height << 16) | ALIGN(image->width, 8)); 0x0bf8, (image->height << 16) | image->width,
OUT_RING(chan, (image->height << 16) | image->width); 0x0bfc, (image->dy << 16) | (image->dx & 0xffff));
OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
dsize = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; dsize = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5;
while (dsize) { while (dsize) {
int iter_len = dsize > 128 ? 128 : dsize; int iter_len = dsize > 128 ? 128 : dsize;
ret = RING_SPACE(chan, iter_len + 1); ret = PUSH_WAIT(push, iter_len + 1);
if (ret) if (ret)
return ret; return ret;
BEGIN_NV04(chan, NvSubGdiRect, 0x0c00, iter_len); PUSH_NVSQ(push, NV04A, 0x0c00, data, iter_len);
OUT_RINGp(chan, data, iter_len);
data += iter_len; data += iter_len;
dsize -= iter_len; dsize -= iter_len;
} }
FIRE_RING(chan); PUSH_KICK(push);
return 0; return 0;
} }
......
...@@ -98,52 +98,52 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -98,52 +98,52 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
struct nouveau_fbdev *nfbdev = info->par; struct nouveau_fbdev *nfbdev = info->par;
struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
struct nvif_push *push = chan->chan.push;
uint32_t dwords, *data = (uint32_t *)image->data; uint32_t dwords, *data = (uint32_t *)image->data;
uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel)); uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
uint32_t *palette = info->pseudo_palette; uint32_t *palette = info->pseudo_palette, bg, fg;
int ret; int ret;
if (image->depth != 1) if (image->depth != 1)
return -ENODEV; return -ENODEV;
ret = RING_SPACE(chan, 11);
if (ret)
return ret;
BEGIN_NV04(chan, NvSub2D, 0x0814, 2);
if (info->fix.visual == FB_VISUAL_TRUECOLOR || if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
info->fix.visual == FB_VISUAL_DIRECTCOLOR) { info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
OUT_RING(chan, palette[image->bg_color] | mask); bg = palette[image->bg_color] | mask;
OUT_RING(chan, palette[image->fg_color] | mask); fg = palette[image->fg_color] | mask;
} else { } else {
OUT_RING(chan, image->bg_color); bg = image->bg_color;
OUT_RING(chan, image->fg_color); fg = image->fg_color;
} }
BEGIN_NV04(chan, NvSub2D, 0x0838, 2);
OUT_RING(chan, image->width); ret = PUSH_WAIT(push, 11);
OUT_RING(chan, image->height); if (ret)
BEGIN_NV04(chan, NvSub2D, 0x0850, 4); return ret;
OUT_RING(chan, 0);
OUT_RING(chan, image->dx); PUSH_NVSQ(push, NV502D, 0x0814, bg,
OUT_RING(chan, 0); 0x0818, fg);
OUT_RING(chan, image->dy); PUSH_NVSQ(push, NV502D, 0x0838, image->width,
0x083c, image->height);
PUSH_NVSQ(push, NV502D, 0x0850, 0,
0x0854, image->dx,
0x0858, 0,
0x085c, image->dy);
dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5;
while (dwords) { while (dwords) {
int push = dwords > 2047 ? 2047 : dwords; int count = dwords > 2047 ? 2047 : dwords;
ret = RING_SPACE(chan, push + 1); ret = PUSH_WAIT(push, count + 1);
if (ret) if (ret)
return ret; return ret;
dwords -= push; dwords -= count;
BEGIN_NI04(chan, NvSub2D, 0x0860, push); PUSH_NVNI(push, NV502D, 0x0860, data, count);
OUT_RINGp(chan, data, push); data += count;
data += push;
} }
FIRE_RING(chan); PUSH_KICK(push);
return 0; return 0;
} }
......
...@@ -98,52 +98,52 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) ...@@ -98,52 +98,52 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
struct nouveau_fbdev *nfbdev = info->par; struct nouveau_fbdev *nfbdev = info->par;
struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev);
struct nouveau_channel *chan = drm->channel; struct nouveau_channel *chan = drm->channel;
struct nvif_push *push = chan->chan.push;
uint32_t dwords, *data = (uint32_t *)image->data; uint32_t dwords, *data = (uint32_t *)image->data;
uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel)); uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
uint32_t *palette = info->pseudo_palette; uint32_t *palette = info->pseudo_palette, bg, fg;
int ret; int ret;
if (image->depth != 1) if (image->depth != 1)
return -ENODEV; return -ENODEV;
ret = RING_SPACE(chan, 11);
if (ret)
return ret;
BEGIN_NVC0(chan, NvSub2D, 0x0814, 2);
if (info->fix.visual == FB_VISUAL_TRUECOLOR || if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
info->fix.visual == FB_VISUAL_DIRECTCOLOR) { info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
OUT_RING (chan, palette[image->bg_color] | mask); bg = palette[image->bg_color] | mask;
OUT_RING (chan, palette[image->fg_color] | mask); fg = palette[image->fg_color] | mask;
} else { } else {
OUT_RING (chan, image->bg_color); bg = image->bg_color;
OUT_RING (chan, image->fg_color); fg = image->fg_color;
} }
BEGIN_NVC0(chan, NvSub2D, 0x0838, 2);
OUT_RING (chan, image->width); ret = PUSH_WAIT(push, 11);
OUT_RING (chan, image->height); if (ret)
BEGIN_NVC0(chan, NvSub2D, 0x0850, 4); return ret;
OUT_RING (chan, 0);
OUT_RING (chan, image->dx); PUSH_NVSQ(push, NV902D, 0x0814, bg,
OUT_RING (chan, 0); 0x0818, fg);
OUT_RING (chan, image->dy); PUSH_NVSQ(push, NV902D, 0x0838, image->width,
0x083c, image->height);
PUSH_NVSQ(push, NV902D, 0x0850, 0,
0x0854, image->dx,
0x0858, 0,
0x085c, image->dy);
dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; dwords = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5;
while (dwords) { while (dwords) {
int push = dwords > 2047 ? 2047 : dwords; int count = dwords > 2047 ? 2047 : dwords;
ret = RING_SPACE(chan, push + 1); ret = PUSH_WAIT(push, count + 1);
if (ret) if (ret)
return ret; return ret;
dwords -= push; dwords -= count;
BEGIN_NIC0(chan, NvSub2D, 0x0860, push); PUSH_NVNI(push, NV902D, 0x0860, data, count);
OUT_RINGp(chan, data, push); data += count;
data += push;
} }
FIRE_RING(chan); PUSH_KICK(push);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment