diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2020-06-22 11:22:28 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2020-07-24 18:50:56 +1000 |
commit | 1d04a64a0a7a0ae5162ce42f27cfad37f6bc60ee (patch) | |
tree | 50530faa9b89e1b4f3fb55c78dda1a7bca09f33d | |
parent | d9a91300ae21bb886b05014cfb1a3ad0dfff04b8 (diff) | |
download | linux-1d04a64a0a7a0ae5162ce42f27cfad37f6bc60ee.tar.bz2 |
drm/nouveau/fbcon: convert imageblit() to new push macros
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_dma.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_dma.h | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_fbcon.c | 27 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_fbcon.c | 50 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nvc0_fbcon.c | 50 |
5 files changed, 63 insertions, 92 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c index 3c430a550a51..ddb75d80bc53 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dma.c +++ b/drivers/gpu/drm/nouveau/nouveau_dma.c @@ -30,19 +30,6 @@ #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 * * Returns: diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.h b/drivers/gpu/drm/nouveau/nouveau_dma.h index d00cf7bd220c..edc5a3b722e6 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dma.h +++ b/drivers/gpu/drm/nouveau/nouveau_dma.h @@ -101,9 +101,6 @@ OUT_RING(struct nouveau_channel *chan, int 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 BEGIN_NV04(struct nouveau_channel *chan, int subc, int mthd, int size) { @@ -111,24 +108,12 @@ BEGIN_NV04(struct nouveau_channel *chan, int subc, int mthd, int size) } 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 BEGIN_NVC0(struct nouveau_channel *chan, int subc, int mthd, int size) { 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 BEGIN_IMC0(struct nouveau_channel *chan, int subc, int mthd, u16 data) { OUT_RING(chan, 0x80000000 | (data << 16) | (subc << 13) | (mthd >> 2)); diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c index a254e5f7fad1..91be0d1827c3 100644 --- a/drivers/gpu/drm/nouveau/nv04_fbcon.c +++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c @@ -81,6 +81,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) struct nouveau_fbdev *nfbdev = info->par; struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_channel *chan = drm->channel; + struct nvif_push *push = chan->chan.push; uint32_t fg; uint32_t bg; uint32_t dsize; @@ -90,7 +91,7 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) if (image->depth != 1) return -ENODEV; - ret = RING_SPACE(chan, 8); + ret = PUSH_WAIT(push, 8); if (ret) return ret; @@ -103,31 +104,29 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) bg = image->bg_color; } - BEGIN_NV04(chan, NvSubGdiRect, 0x0be4, 7); - OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); - OUT_RING(chan, ((image->dy + image->height) << 16) | - ((image->dx + image->width) & 0xffff)); - OUT_RING(chan, bg); - OUT_RING(chan, fg); - OUT_RING(chan, (image->height << 16) | ALIGN(image->width, 8)); - OUT_RING(chan, (image->height << 16) | image->width); - OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); + PUSH_NVSQ(push, NV04A, 0x0be4, (image->dy << 16) | (image->dx & 0xffff), + 0x0be8, ((image->dy + image->height) << 16) | + ((image->dx + image->width) & 0xffff), + 0x0bec, bg, + 0x0bf0, fg, + 0x0bf4, (image->height << 16) | ALIGN(image->width, 8), + 0x0bf8, (image->height << 16) | image->width, + 0x0bfc, (image->dy << 16) | (image->dx & 0xffff)); dsize = ALIGN(ALIGN(image->width, 8) * image->height, 32) >> 5; while (dsize) { int iter_len = dsize > 128 ? 128 : dsize; - ret = RING_SPACE(chan, iter_len + 1); + ret = PUSH_WAIT(push, iter_len + 1); if (ret) return ret; - BEGIN_NV04(chan, NvSubGdiRect, 0x0c00, iter_len); - OUT_RINGp(chan, data, iter_len); + PUSH_NVSQ(push, NV04A, 0x0c00, data, iter_len); data += iter_len; dsize -= iter_len; } - FIRE_RING(chan); + PUSH_KICK(push); return 0; } diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c index 36348f72ecb3..dd20485e38d9 100644 --- a/drivers/gpu/drm/nouveau/nv50_fbcon.c +++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c @@ -98,52 +98,52 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) struct nouveau_fbdev *nfbdev = info->par; struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_channel *chan = drm->channel; + struct nvif_push *push = chan->chan.push; uint32_t dwords, *data = (uint32_t *)image->data; 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; if (image->depth != 1) return -ENODEV; - ret = RING_SPACE(chan, 11); - if (ret) - return ret; - - BEGIN_NV04(chan, NvSub2D, 0x0814, 2); 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); + bg = palette[image->bg_color] | mask; + fg = palette[image->fg_color] | mask; } else { - OUT_RING(chan, image->bg_color); - OUT_RING(chan, image->fg_color); + bg = image->bg_color; + fg = image->fg_color; } - BEGIN_NV04(chan, NvSub2D, 0x0838, 2); - OUT_RING(chan, image->width); - OUT_RING(chan, image->height); - BEGIN_NV04(chan, NvSub2D, 0x0850, 4); - OUT_RING(chan, 0); - OUT_RING(chan, image->dx); - OUT_RING(chan, 0); - OUT_RING(chan, image->dy); + + ret = PUSH_WAIT(push, 11); + if (ret) + return ret; + + PUSH_NVSQ(push, NV502D, 0x0814, bg, + 0x0818, fg); + 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; 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) return ret; - dwords -= push; + dwords -= count; - BEGIN_NI04(chan, NvSub2D, 0x0860, push); - OUT_RINGp(chan, data, push); - data += push; + PUSH_NVNI(push, NV502D, 0x0860, data, count); + data += count; } - FIRE_RING(chan); + PUSH_KICK(push); return 0; } diff --git a/drivers/gpu/drm/nouveau/nvc0_fbcon.c b/drivers/gpu/drm/nouveau/nvc0_fbcon.c index 2d213c365a43..ae88f6683f62 100644 --- a/drivers/gpu/drm/nouveau/nvc0_fbcon.c +++ b/drivers/gpu/drm/nouveau/nvc0_fbcon.c @@ -98,52 +98,52 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image) struct nouveau_fbdev *nfbdev = info->par; struct nouveau_drm *drm = nouveau_drm(nfbdev->helper.dev); struct nouveau_channel *chan = drm->channel; + struct nvif_push *push = chan->chan.push; uint32_t dwords, *data = (uint32_t *)image->data; 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; if (image->depth != 1) return -ENODEV; - ret = RING_SPACE(chan, 11); - if (ret) - return ret; - - BEGIN_NVC0(chan, NvSub2D, 0x0814, 2); 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); + bg = palette[image->bg_color] | mask; + fg = palette[image->fg_color] | mask; } else { - OUT_RING (chan, image->bg_color); - OUT_RING (chan, image->fg_color); + bg = image->bg_color; + fg = image->fg_color; } - BEGIN_NVC0(chan, NvSub2D, 0x0838, 2); - OUT_RING (chan, image->width); - OUT_RING (chan, image->height); - BEGIN_NVC0(chan, NvSub2D, 0x0850, 4); - OUT_RING (chan, 0); - OUT_RING (chan, image->dx); - OUT_RING (chan, 0); - OUT_RING (chan, image->dy); + + ret = PUSH_WAIT(push, 11); + if (ret) + return ret; + + PUSH_NVSQ(push, NV902D, 0x0814, bg, + 0x0818, fg); + 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; 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) return ret; - dwords -= push; + dwords -= count; - BEGIN_NIC0(chan, NvSub2D, 0x0860, push); - OUT_RINGp(chan, data, push); - data += push; + PUSH_NVNI(push, NV902D, 0x0860, data, count); + data += count; } - FIRE_RING(chan); + PUSH_KICK(push); return 0; } |