2019-05-31 15:09:37 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Matrox Graphics
|
|
|
|
*
|
|
|
|
* Author: Christopher Harvey <charvey@matrox.com>
|
|
|
|
*/
|
|
|
|
|
2019-12-03 17:04:00 +07:00
|
|
|
#include <linux/pci.h>
|
2019-06-23 17:35:42 +07:00
|
|
|
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
#include "mgag200_drv.h"
|
|
|
|
|
|
|
|
static bool warn_transparent = true;
|
|
|
|
static bool warn_palette = true;
|
|
|
|
|
2019-09-27 16:12:58 +07:00
|
|
|
static int mgag200_cursor_update(struct mga_device *mdev, void *dst, void *src,
|
|
|
|
unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = mdev->dev;
|
|
|
|
unsigned int i, row, col;
|
|
|
|
uint32_t colour_set[16];
|
|
|
|
uint32_t *next_space = &colour_set[0];
|
|
|
|
uint32_t *palette_iter;
|
|
|
|
uint32_t this_colour;
|
|
|
|
bool found = false;
|
|
|
|
int colour_count = 0;
|
|
|
|
u8 reg_index;
|
|
|
|
u8 this_row[48];
|
|
|
|
|
|
|
|
memset(&colour_set[0], 0, sizeof(uint32_t)*16);
|
|
|
|
/* width*height*4 = 16384 */
|
|
|
|
for (i = 0; i < 16384; i += 4) {
|
|
|
|
this_colour = ioread32(src + i);
|
|
|
|
/* No transparency */
|
|
|
|
if (this_colour>>24 != 0xff &&
|
|
|
|
this_colour>>24 != 0x0) {
|
|
|
|
if (warn_transparent) {
|
|
|
|
dev_info(&dev->pdev->dev, "Video card doesn't support cursors with partial transparency.\n");
|
|
|
|
dev_info(&dev->pdev->dev, "Not enabling hardware cursor.\n");
|
|
|
|
warn_transparent = false; /* Only tell the user once. */
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
/* Don't need to store transparent pixels as colours */
|
|
|
|
if (this_colour>>24 == 0x0)
|
|
|
|
continue;
|
|
|
|
found = false;
|
|
|
|
for (palette_iter = &colour_set[0]; palette_iter != next_space; palette_iter++) {
|
|
|
|
if (*palette_iter == this_colour) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
continue;
|
|
|
|
/* We only support 4bit paletted cursors */
|
|
|
|
if (colour_count >= 16) {
|
|
|
|
if (warn_palette) {
|
|
|
|
dev_info(&dev->pdev->dev, "Video card only supports cursors with up to 16 colours.\n");
|
|
|
|
dev_info(&dev->pdev->dev, "Not enabling hardware cursor.\n");
|
|
|
|
warn_palette = false; /* Only tell the user once. */
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
*next_space = this_colour;
|
|
|
|
next_space++;
|
|
|
|
colour_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Program colours from cursor icon into palette */
|
|
|
|
for (i = 0; i < colour_count; i++) {
|
|
|
|
if (i <= 2)
|
|
|
|
reg_index = 0x8 + i*0x4;
|
|
|
|
else
|
|
|
|
reg_index = 0x60 + i*0x3;
|
|
|
|
WREG_DAC(reg_index, colour_set[i] & 0xff);
|
|
|
|
WREG_DAC(reg_index+1, colour_set[i]>>8 & 0xff);
|
|
|
|
WREG_DAC(reg_index+2, colour_set[i]>>16 & 0xff);
|
|
|
|
BUG_ON((colour_set[i]>>24 & 0xff) != 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now write colour indices into hardware cursor buffer */
|
|
|
|
for (row = 0; row < 64; row++) {
|
|
|
|
memset(&this_row[0], 0, 48);
|
|
|
|
for (col = 0; col < 64; col++) {
|
|
|
|
this_colour = ioread32(src + 4*(col + 64*row));
|
|
|
|
/* write transparent pixels */
|
|
|
|
if (this_colour>>24 == 0x0) {
|
|
|
|
this_row[47 - col/8] |= 0x80>>(col%8);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write colour index here */
|
|
|
|
for (i = 0; i < colour_count; i++) {
|
|
|
|
if (colour_set[i] == this_colour) {
|
|
|
|
if (col % 2)
|
|
|
|
this_row[col/2] |= i<<4;
|
|
|
|
else
|
|
|
|
this_row[col/2] |= i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memcpy_toio(dst + row*48, &this_row[0], 48);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mgag200_cursor_set_base(struct mga_device *mdev, u64 address)
|
|
|
|
{
|
|
|
|
u8 addrl = (address >> 10) & 0xff;
|
|
|
|
u8 addrh = (address >> 18) & 0x3f;
|
|
|
|
|
|
|
|
/* Program gpu address of cursor buffer */
|
|
|
|
WREG_DAC(MGA1064_CURSOR_BASE_ADR_LOW, addrl);
|
|
|
|
WREG_DAC(MGA1064_CURSOR_BASE_ADR_HI, addrh);
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:59 +07:00
|
|
|
static int mgag200_show_cursor(struct mga_device *mdev, void *src,
|
|
|
|
unsigned int width, unsigned int height)
|
2019-09-27 16:12:58 +07:00
|
|
|
{
|
2019-09-27 16:12:59 +07:00
|
|
|
struct drm_device *dev = mdev->dev;
|
2019-09-27 16:13:01 +07:00
|
|
|
struct drm_gem_vram_object *gbo;
|
2019-09-27 16:12:59 +07:00
|
|
|
void *dst;
|
|
|
|
s64 off;
|
2019-09-27 16:12:58 +07:00
|
|
|
int ret;
|
|
|
|
|
2019-09-27 16:13:01 +07:00
|
|
|
gbo = mdev->cursor.gbo[mdev->cursor.next_index];
|
|
|
|
if (!gbo) {
|
2019-09-27 16:12:59 +07:00
|
|
|
WREG8(MGA_CURPOSXL, 0);
|
|
|
|
WREG8(MGA_CURPOSXH, 0);
|
|
|
|
return -ENOTSUPP; /* Didn't allocate space for cursors */
|
|
|
|
}
|
2019-09-27 16:13:01 +07:00
|
|
|
dst = drm_gem_vram_vmap(gbo);
|
2019-09-27 16:12:59 +07:00
|
|
|
if (IS_ERR(dst)) {
|
|
|
|
ret = PTR_ERR(dst);
|
|
|
|
dev_err(&dev->pdev->dev,
|
|
|
|
"failed to map cursor updates: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2019-09-27 16:13:01 +07:00
|
|
|
off = drm_gem_vram_offset(gbo);
|
2019-09-27 16:12:59 +07:00
|
|
|
if (off < 0) {
|
|
|
|
ret = (int)off;
|
|
|
|
dev_err(&dev->pdev->dev,
|
|
|
|
"failed to get cursor scanout address: %d\n", ret);
|
|
|
|
goto err_drm_gem_vram_vunmap;
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:58 +07:00
|
|
|
ret = mgag200_cursor_update(mdev, dst, src, width, height);
|
|
|
|
if (ret)
|
2019-09-27 16:12:59 +07:00
|
|
|
goto err_drm_gem_vram_vunmap;
|
|
|
|
mgag200_cursor_set_base(mdev, off);
|
2019-09-27 16:12:58 +07:00
|
|
|
|
|
|
|
/* Adjust cursor control register to turn on the cursor */
|
|
|
|
WREG_DAC(MGA1064_CURSOR_CTL, 4); /* 16-colour palletized cursor mode */
|
|
|
|
|
2019-09-27 16:13:01 +07:00
|
|
|
drm_gem_vram_vunmap(gbo, dst);
|
2019-09-27 16:12:59 +07:00
|
|
|
|
2019-09-27 16:13:01 +07:00
|
|
|
++mdev->cursor.next_index;
|
|
|
|
mdev->cursor.next_index %= ARRAY_SIZE(mdev->cursor.gbo);
|
2019-09-27 16:12:59 +07:00
|
|
|
|
2019-09-27 16:12:58 +07:00
|
|
|
return 0;
|
2019-09-27 16:12:59 +07:00
|
|
|
|
|
|
|
err_drm_gem_vram_vunmap:
|
2019-09-27 16:13:01 +07:00
|
|
|
drm_gem_vram_vunmap(gbo, dst);
|
2019-09-27 16:12:59 +07:00
|
|
|
return ret;
|
2019-09-27 16:12:58 +07:00
|
|
|
}
|
|
|
|
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
/*
|
2019-09-27 16:12:55 +07:00
|
|
|
* Hide the cursor off screen. We can't disable the cursor hardware because
|
|
|
|
* it takes too long to re-activate and causes momentary corruption.
|
|
|
|
*/
|
|
|
|
static void mgag200_hide_cursor(struct mga_device *mdev)
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
{
|
|
|
|
WREG8(MGA_CURPOSXL, 0);
|
|
|
|
WREG8(MGA_CURPOSXH, 0);
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:57 +07:00
|
|
|
static void mgag200_move_cursor(struct mga_device *mdev, int x, int y)
|
|
|
|
{
|
|
|
|
if (WARN_ON(x <= 0))
|
|
|
|
return;
|
|
|
|
if (WARN_ON(y <= 0))
|
|
|
|
return;
|
|
|
|
if (WARN_ON(x & ~0xffff))
|
|
|
|
return;
|
|
|
|
if (WARN_ON(y & ~0xffff))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WREG8(MGA_CURPOSXL, x & 0xff);
|
|
|
|
WREG8(MGA_CURPOSXH, (x>>8) & 0xff);
|
|
|
|
|
|
|
|
WREG8(MGA_CURPOSYL, y & 0xff);
|
|
|
|
WREG8(MGA_CURPOSYH, (y>>8) & 0xff);
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:56 +07:00
|
|
|
int mgag200_cursor_init(struct mga_device *mdev)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = mdev->dev;
|
2019-09-27 16:13:01 +07:00
|
|
|
size_t ncursors = ARRAY_SIZE(mdev->cursor.gbo);
|
2019-09-27 16:13:00 +07:00
|
|
|
size_t size;
|
2019-09-27 16:13:01 +07:00
|
|
|
int ret;
|
|
|
|
size_t i;
|
|
|
|
struct drm_gem_vram_object *gbo;
|
2019-09-27 16:13:00 +07:00
|
|
|
|
|
|
|
size = roundup(64 * 48, PAGE_SIZE);
|
2019-09-27 16:13:01 +07:00
|
|
|
if (size * ncursors > mdev->vram_fb_available)
|
2019-09-27 16:13:00 +07:00
|
|
|
return -ENOMEM;
|
2019-09-27 16:12:56 +07:00
|
|
|
|
2019-09-27 16:13:01 +07:00
|
|
|
for (i = 0; i < ncursors; ++i) {
|
2020-01-06 19:57:44 +07:00
|
|
|
gbo = drm_gem_vram_create(dev, size, 0);
|
2019-09-27 16:13:01 +07:00
|
|
|
if (IS_ERR(gbo)) {
|
|
|
|
ret = PTR_ERR(gbo);
|
|
|
|
goto err_drm_gem_vram_put;
|
|
|
|
}
|
|
|
|
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM |
|
|
|
|
DRM_GEM_VRAM_PL_FLAG_TOPDOWN);
|
|
|
|
if (ret) {
|
|
|
|
drm_gem_vram_put(gbo);
|
|
|
|
goto err_drm_gem_vram_put;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdev->cursor.gbo[i] = gbo;
|
2019-09-27 16:12:56 +07:00
|
|
|
}
|
|
|
|
|
2019-09-27 16:13:00 +07:00
|
|
|
/*
|
|
|
|
* At the high end of video memory, we reserve space for
|
|
|
|
* buffer objects. The cursor plane uses this memory to store
|
|
|
|
* a double-buffered image of the current cursor. Hence, it's
|
|
|
|
* not available for framebuffers.
|
|
|
|
*/
|
2019-09-27 16:13:01 +07:00
|
|
|
mdev->vram_fb_available -= ncursors * size;
|
2019-09-27 16:13:00 +07:00
|
|
|
|
2019-09-27 16:12:56 +07:00
|
|
|
return 0;
|
2019-09-27 16:13:01 +07:00
|
|
|
|
|
|
|
err_drm_gem_vram_put:
|
|
|
|
while (i) {
|
|
|
|
--i;
|
|
|
|
gbo = mdev->cursor.gbo[i];
|
|
|
|
drm_gem_vram_unpin(gbo);
|
|
|
|
drm_gem_vram_put(gbo);
|
|
|
|
mdev->cursor.gbo[i] = NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
2019-09-27 16:12:56 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void mgag200_cursor_fini(struct mga_device *mdev)
|
2019-09-27 16:13:01 +07:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
struct drm_gem_vram_object *gbo;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(mdev->cursor.gbo); ++i) {
|
|
|
|
gbo = mdev->cursor.gbo[i];
|
|
|
|
drm_gem_vram_unpin(gbo);
|
|
|
|
drm_gem_vram_put(gbo);
|
|
|
|
}
|
|
|
|
}
|
2019-09-27 16:12:56 +07:00
|
|
|
|
2019-09-27 16:12:55 +07:00
|
|
|
int mgag200_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
|
|
|
|
uint32_t handle, uint32_t width, uint32_t height)
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
{
|
2014-01-16 11:28:22 +07:00
|
|
|
struct drm_device *dev = crtc->dev;
|
2020-05-07 16:03:10 +07:00
|
|
|
struct mga_device *mdev = to_mga_device(dev);
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
struct drm_gem_object *obj;
|
2019-05-08 15:26:24 +07:00
|
|
|
struct drm_gem_vram_object *gbo = NULL;
|
2019-09-27 16:12:58 +07:00
|
|
|
int ret;
|
2019-09-27 16:12:59 +07:00
|
|
|
u8 *src;
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
|
2015-11-18 22:00:53 +07:00
|
|
|
if (!handle || !file_priv) {
|
2019-09-27 16:12:55 +07:00
|
|
|
mgag200_hide_cursor(mdev);
|
2015-11-18 22:00:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-13 14:30:39 +07:00
|
|
|
if (width != 64 || height != 64) {
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
WREG8(MGA_CURPOSXL, 0);
|
|
|
|
WREG8(MGA_CURPOSXH, 0);
|
2019-06-13 14:30:39 +07:00
|
|
|
return -EINVAL;
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
}
|
|
|
|
|
2019-06-13 14:30:39 +07:00
|
|
|
obj = drm_gem_object_lookup(file_priv, handle);
|
|
|
|
if (!obj)
|
|
|
|
return -ENOENT;
|
2019-05-08 15:26:24 +07:00
|
|
|
gbo = drm_gem_vram_of_gem(obj);
|
2019-09-11 19:03:52 +07:00
|
|
|
src = drm_gem_vram_vmap(gbo);
|
2019-05-08 15:26:26 +07:00
|
|
|
if (IS_ERR(src)) {
|
|
|
|
ret = PTR_ERR(src);
|
2019-06-13 14:30:39 +07:00
|
|
|
dev_err(&dev->pdev->dev,
|
2019-09-11 19:03:52 +07:00
|
|
|
"failed to map user buffer updates\n");
|
|
|
|
goto err_drm_gem_object_put_unlocked;
|
2019-06-13 14:30:39 +07:00
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:59 +07:00
|
|
|
ret = mgag200_show_cursor(mdev, src, width, height);
|
2019-09-27 16:12:58 +07:00
|
|
|
if (ret)
|
2019-09-27 16:12:59 +07:00
|
|
|
goto err_drm_gem_vram_vunmap;
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
|
2019-06-13 14:30:39 +07:00
|
|
|
/* Now update internal buffer pointers */
|
2019-09-11 19:03:52 +07:00
|
|
|
drm_gem_vram_vunmap(gbo, src);
|
2017-08-11 19:33:00 +07:00
|
|
|
drm_gem_object_put_unlocked(obj);
|
2015-07-10 04:32:39 +07:00
|
|
|
|
2019-06-13 14:30:39 +07:00
|
|
|
return 0;
|
2019-09-11 19:03:52 +07:00
|
|
|
err_drm_gem_vram_vunmap:
|
|
|
|
drm_gem_vram_vunmap(gbo, src);
|
2019-06-13 14:30:39 +07:00
|
|
|
err_drm_gem_object_put_unlocked:
|
|
|
|
drm_gem_object_put_unlocked(obj);
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-27 16:12:55 +07:00
|
|
|
int mgag200_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
{
|
2020-05-07 16:03:10 +07:00
|
|
|
struct mga_device *mdev = to_mga_device(crtc->dev);
|
2019-09-27 16:12:57 +07:00
|
|
|
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
/* Our origin is at (64,64) */
|
|
|
|
x += 64;
|
|
|
|
y += 64;
|
|
|
|
|
2019-09-27 16:12:57 +07:00
|
|
|
mgag200_move_cursor(mdev, x, y);
|
drm/mgag200: Hardware cursor support
G200 cards support, at best, 16 colour palleted images for the cursor
so we do a conversion in the cursor_set function, and reject cursors
with more than 16 colours, or cursors with partial transparency. Xorg
falls back gracefully to software cursors in this case.
We can't disable/enable the cursor hardware without causing momentary
corruption around the cursor. Instead, once the cursor is on we leave
it on, and simulate turning the cursor off by moving it
offscreen. This works well.
Since we can't disable -> update -> enable the cursors, we double
buffer cursor icons, then just move the base address that points to
the old cursor, to the new. This also works well, but uses an extra
page of memory.
The cursor buffers are lazily-allocated on first cursor_set. This is
to make sure they don't take priority over any framebuffers in case of
limited memory.
Here is a representation of how the bitmap for the cursor is mapped in G200 memory :
Each line of color cursor use 6 Slices of 8 bytes. Slices 0 to 3
are used for the 4bpp bitmap, slice 4 for XOR mask and slice 5 for
AND mask. Each line has the following format:
// Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
//
// S0: P00-01 P02-03 P04-05 P06-07 P08-09 P10-11 P12-13 P14-15
// S1: P16-17 P18-19 P20-21 P22-23 P24-25 P26-27 P28-29 P30-31
// S2: P32-33 P34-35 P36-37 P38-39 P40-41 P42-43 P44-45 P46-47
// S3: P48-49 P50-51 P52-53 P54-55 P56-57 P58-59 P60-61 P62-63
// S4: X63-56 X55-48 X47-40 X39-32 X31-24 X23-16 X15-08 X07-00
// S5: A63-56 A55-48 A47-40 A39-32 A31-24 A23-16 A15-08 A07-00
//
// S0 to S5 = Slices 0 to 5
// P00 to P63 = Bitmap - pixels 0 to 63
// X00 to X63 = always 0 - pixels 0 to 63
// A00 to A63 = transparent markers - pixels 0 to 63
// 1 means colour, 0 means transparent
Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Mathieu Larouche <mathieu.larouche@matrox.com>
Acked-by: Julia Lemire <jlemire@matrox.com>
Tested-by: Julia Lemire <jlemire@matrox.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2013-06-06 02:24:26 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|