2009-10-21 11:33:33 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm.h>
|
|
|
|
#include <drm_mm.h>
|
|
|
|
#include "radeon_drm.h"
|
|
|
|
#include "radeon.h"
|
|
|
|
#include "radeon_object.h"
|
2009-11-02 21:36:12 +01:00
|
|
|
#include "display.h"
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
display_t *rdisplay;
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
static cursor_t* __stdcall select_cursor(cursor_t *cursor);
|
|
|
|
static void __stdcall move_cursor(cursor_t *cursor, int x, int y);
|
2009-10-21 11:33:33 +02:00
|
|
|
|
|
|
|
int init_cursor(cursor_t *cursor)
|
|
|
|
{
|
|
|
|
struct radeon_device *rdev;
|
|
|
|
|
|
|
|
uint32_t *bits;
|
|
|
|
uint32_t *src;
|
|
|
|
|
|
|
|
int i,j;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
|
|
|
|
|
|
|
|
r = radeon_object_create(rdev, NULL, CURSOR_WIDTH*CURSOR_HEIGHT*4,
|
|
|
|
false,
|
|
|
|
RADEON_GEM_DOMAIN_VRAM,
|
|
|
|
false, &cursor->robj);
|
|
|
|
|
|
|
|
if (unlikely(r != 0))
|
|
|
|
return r;
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
radeon_object_pin(cursor->robj, TTM_PL_FLAG_VRAM, NULL);
|
2009-10-21 11:33:33 +02:00
|
|
|
|
|
|
|
r = radeon_object_kmap(cursor->robj, &bits);
|
|
|
|
if (r) {
|
|
|
|
DRM_ERROR("radeon: failed to map cursor (%d).\n", r);
|
|
|
|
return r;
|
|
|
|
};
|
|
|
|
|
|
|
|
src = cursor->data;
|
|
|
|
|
|
|
|
for(i = 0; i < 32; i++)
|
|
|
|
{
|
|
|
|
for(j = 0; j < 32; j++)
|
|
|
|
*bits++ = *src++;
|
2009-10-24 01:46:58 +02:00
|
|
|
for(j = 32; j < CURSOR_WIDTH; j++)
|
2009-10-21 11:33:33 +02:00
|
|
|
*bits++ = 0;
|
|
|
|
}
|
|
|
|
for(i = 0; i < CURSOR_WIDTH*(CURSOR_HEIGHT-32); i++)
|
|
|
|
*bits++ = 0;
|
|
|
|
|
|
|
|
radeon_object_kunmap(cursor->robj);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
static void radeon_show_cursor()
|
2009-10-24 01:46:58 +02:00
|
|
|
{
|
2009-11-02 21:36:12 +01:00
|
|
|
struct radeon_device *rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
|
2009-10-24 01:46:58 +02:00
|
|
|
|
|
|
|
if (ASIC_IS_AVIVO(rdev)) {
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(RADEON_MM_INDEX, AVIVO_D1CUR_CONTROL);
|
2009-10-24 01:46:58 +02:00
|
|
|
WREG32(RADEON_MM_DATA, AVIVO_D1CURSOR_EN |
|
|
|
|
(AVIVO_D1CURSOR_MODE_24BPP << AVIVO_D1CURSOR_MODE_SHIFT));
|
|
|
|
} else {
|
|
|
|
WREG32(RADEON_MM_INDEX, RADEON_CRTC_GEN_CNTL);
|
|
|
|
WREG32_P(RADEON_MM_DATA, (RADEON_CRTC_CUR_EN |
|
|
|
|
(RADEON_CRTC_CUR_MODE_24BPP << RADEON_CRTC_CUR_MODE_SHIFT)),
|
|
|
|
~(RADEON_CRTC_CUR_EN | RADEON_CRTC_CUR_MODE_MASK));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor_t* __stdcall select_cursor(cursor_t *cursor)
|
2009-10-21 11:33:33 +02:00
|
|
|
{
|
|
|
|
struct radeon_device *rdev;
|
|
|
|
cursor_t *old;
|
|
|
|
uint32_t gpu_addr;
|
|
|
|
|
|
|
|
rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
|
|
|
|
|
2009-10-24 01:46:58 +02:00
|
|
|
old = rdisplay->cursor;
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-10-24 01:46:58 +02:00
|
|
|
rdisplay->cursor = cursor;
|
2009-10-21 11:33:33 +02:00
|
|
|
gpu_addr = cursor->robj->gpu_addr;
|
|
|
|
|
|
|
|
if (ASIC_IS_AVIVO(rdev))
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(AVIVO_D1CUR_SURFACE_ADDRESS, gpu_addr);
|
2009-10-21 11:33:33 +02:00
|
|
|
else {
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(RADEON_CUR_OFFSET, gpu_addr - rdev->mc.vram_location);
|
2009-10-21 11:33:33 +02:00
|
|
|
}
|
2009-10-24 01:46:58 +02:00
|
|
|
|
2009-10-21 11:33:33 +02:00
|
|
|
return old;
|
|
|
|
};
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
static void radeon_lock_cursor(bool lock)
|
|
|
|
{
|
|
|
|
struct radeon_device *rdev;
|
|
|
|
|
|
|
|
rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
|
|
|
|
|
|
|
|
uint32_t cur_lock;
|
|
|
|
|
|
|
|
if (ASIC_IS_AVIVO(rdev)) {
|
|
|
|
cur_lock = RREG32(AVIVO_D1CUR_UPDATE);
|
|
|
|
if (lock)
|
|
|
|
cur_lock |= AVIVO_D1CURSOR_UPDATE_LOCK;
|
|
|
|
else
|
|
|
|
cur_lock &= ~AVIVO_D1CURSOR_UPDATE_LOCK;
|
|
|
|
WREG32(AVIVO_D1CUR_UPDATE, cur_lock);
|
|
|
|
} else {
|
|
|
|
cur_lock = RREG32(RADEON_CUR_OFFSET);
|
|
|
|
if (lock)
|
|
|
|
cur_lock |= RADEON_CUR_LOCK;
|
|
|
|
else
|
|
|
|
cur_lock &= ~RADEON_CUR_LOCK;
|
|
|
|
WREG32(RADEON_CUR_OFFSET, cur_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-10-24 01:46:58 +02:00
|
|
|
void __stdcall move_cursor(cursor_t *cursor, int x, int y)
|
2009-10-21 11:33:33 +02:00
|
|
|
{
|
2009-10-24 01:46:58 +02:00
|
|
|
struct radeon_device *rdev;
|
|
|
|
rdev = (struct radeon_device *)rdisplay->ddev->dev_private;
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-10-24 01:46:58 +02:00
|
|
|
int hot_x = cursor->hot_x;
|
|
|
|
int hot_y = cursor->hot_y;
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
radeon_lock_cursor(true);
|
2009-10-21 11:33:33 +02:00
|
|
|
if (ASIC_IS_AVIVO(rdev))
|
|
|
|
{
|
|
|
|
int w = 32;
|
|
|
|
int i = 0;
|
2009-11-02 21:36:12 +01:00
|
|
|
|
|
|
|
WREG32(AVIVO_D1CUR_POSITION, (x << 16) | y);
|
|
|
|
WREG32(AVIVO_D1CUR_HOT_SPOT, (hot_x << 16) | hot_y);
|
|
|
|
WREG32(AVIVO_D1CUR_SIZE, ((w - 1) << 16) | 31);
|
2009-10-21 11:33:33 +02:00
|
|
|
} else {
|
2009-11-02 21:36:12 +01:00
|
|
|
uint32_t gpu_addr;
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(RADEON_CUR_HORZ_VERT_OFF,
|
2009-10-21 11:33:33 +02:00
|
|
|
(RADEON_CUR_LOCK | (hot_x << 16) | (hot_y << 16)));
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(RADEON_CUR_HORZ_VERT_POSN,
|
2009-10-21 11:33:33 +02:00
|
|
|
(RADEON_CUR_LOCK | (x << 16) | y));
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
gpu_addr = cursor->robj->gpu_addr;
|
|
|
|
|
2009-10-21 11:33:33 +02:00
|
|
|
/* offset is from DISP(2)_BASE_ADDRESS */
|
2009-11-02 21:36:12 +01:00
|
|
|
WREG32(RADEON_CUR_OFFSET,
|
|
|
|
(gpu_addr - rdev->mc.vram_location + (hot_y * 256)));
|
2009-10-21 11:33:33 +02:00
|
|
|
}
|
2009-11-02 21:36:12 +01:00
|
|
|
radeon_lock_cursor(false);
|
2009-10-21 11:33:33 +02:00
|
|
|
}
|
|
|
|
|
2009-10-24 01:46:58 +02:00
|
|
|
void __stdcall restore_cursor(int x, int y)
|
|
|
|
{
|
|
|
|
};
|
2009-10-21 11:33:33 +02:00
|
|
|
|
2009-10-24 23:42:25 +02:00
|
|
|
|
2009-10-26 23:40:01 +01:00
|
|
|
bool init_display(struct radeon_device *rdev, mode_t *usermode)
|
2009-10-24 23:42:25 +02:00
|
|
|
{
|
2009-10-26 23:40:01 +01:00
|
|
|
struct drm_device *dev;
|
2009-11-02 21:36:12 +01:00
|
|
|
|
2009-10-24 23:42:25 +02:00
|
|
|
cursor_t *cursor;
|
2009-10-26 23:40:01 +01:00
|
|
|
bool retval = false;
|
2009-11-02 21:36:12 +01:00
|
|
|
u32_t ifl;
|
2009-10-24 23:42:25 +02:00
|
|
|
|
|
|
|
ENTER();
|
|
|
|
|
|
|
|
rdisplay = GetDisplay();
|
|
|
|
|
2009-10-26 23:40:01 +01:00
|
|
|
dev = rdisplay->ddev = rdev->ddev;
|
2009-10-24 23:42:25 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
ifl = safe_cli();
|
|
|
|
{
|
2009-10-24 23:42:25 +02:00
|
|
|
list_for_each_entry(cursor, &rdisplay->cursors, list)
|
|
|
|
{
|
|
|
|
init_cursor(cursor);
|
|
|
|
};
|
2009-10-26 23:40:01 +01:00
|
|
|
};
|
2009-11-02 21:36:12 +01:00
|
|
|
safe_sti(ifl);
|
2009-10-24 23:42:25 +02:00
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
ifl = safe_cli();
|
|
|
|
{
|
|
|
|
rdisplay->restore_cursor(0,0);
|
2009-10-24 23:42:25 +02:00
|
|
|
rdisplay->init_cursor = init_cursor;
|
|
|
|
rdisplay->select_cursor = select_cursor;
|
|
|
|
rdisplay->show_cursor = NULL;
|
|
|
|
rdisplay->move_cursor = move_cursor;
|
|
|
|
rdisplay->restore_cursor = restore_cursor;
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
select_cursor(rdisplay->cursor);
|
|
|
|
radeon_show_cursor();
|
2009-10-24 23:42:25 +02:00
|
|
|
};
|
2009-11-02 21:36:12 +01:00
|
|
|
safe_sti(ifl);
|
2009-10-26 23:40:01 +01:00
|
|
|
|
|
|
|
LEAVE();
|
|
|
|
|
2009-11-02 21:36:12 +01:00
|
|
|
return retval;
|
|
|
|
};
|
2009-10-26 23:40:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|