diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-02-20 07:51:40 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-02-20 07:51:40 +0000 |
commit | caaf52834015c084704cf638f453b1fc3316eaa9 (patch) | |
tree | 6e8feb7bdd42c2691e2fa0a2f8dc92842e823e66 /src | |
parent | c91af569ee90a832899c9038badd84921e9a87fc (diff) |
sna: Query cursor size from the kernel
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna.h | 3 | ||||
-rw-r--r-- | src/sna/sna_display.c | 36 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 20 |
3 files changed, 44 insertions, 15 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index 7dc5067a..1b0a4e58 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -279,6 +279,9 @@ struct sna { int shadow_flip; int front_active; + unsigned short cursor_width; + unsigned short cursor_height; + unsigned num_real_crtc; unsigned num_real_output; unsigned num_fake; diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index e7695467..0902f804 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -1680,7 +1680,7 @@ sna_crtc_hide_cursor(xf86CrtcPtr crtc) VG_CLEAR(arg); arg.flags = DRM_MODE_CURSOR_BO; arg.crtc_id = sna_crtc->id; - arg.width = arg.height = 64; + arg.width = arg.height = 0; arg.handle = 0; (void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg); @@ -1690,6 +1690,7 @@ static void sna_crtc_show_cursor(xf86CrtcPtr crtc) { struct sna_crtc *sna_crtc = to_sna_crtc(crtc); + struct sna *sna = to_sna(crtc->scrn); struct drm_mode_cursor arg; __DBG(("%s: CRTC:%d\n", __FUNCTION__, sna_crtc->id)); @@ -1697,10 +1698,11 @@ sna_crtc_show_cursor(xf86CrtcPtr crtc) VG_CLEAR(arg); arg.flags = DRM_MODE_CURSOR_BO; arg.crtc_id = sna_crtc->id; - arg.width = arg.height = 64; + arg.width = sna->mode.cursor_width; + arg.height = sna->mode.cursor_height; arg.handle = sna_crtc->cursor; - (void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg); + (void)drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg); } static void @@ -1731,6 +1733,7 @@ sna_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) static void sna_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image) { + struct sna *sna = to_sna(crtc->scrn); struct drm_i915_gem_pwrite pwrite; __DBG(("%s: CRTC:%d\n", __FUNCTION__, to_sna_crtc(crtc)->id)); @@ -1738,9 +1741,9 @@ sna_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image) VG_CLEAR(pwrite); pwrite.handle = to_sna_crtc(crtc)->cursor; pwrite.offset = 0; - pwrite.size = 64*64*4; + pwrite.size = sna->mode.cursor_width*sna->mode.cursor_height*4; pwrite.data_ptr = (uintptr_t)image; - (void)drmIoctl(to_sna(crtc->scrn)->kgem.fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite); + (void)drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite); } static void @@ -1902,7 +1905,8 @@ sna_crtc_init(ScrnInfoPtr scrn, struct sna_mode *mode, int num) return false; } - sna_crtc->cursor = gem_create(sna->kgem.fd, 64*64*4); + sna_crtc->cursor = gem_create(sna->kgem.fd, + sna->mode.cursor_width*sna->mode.cursor_height*4); if (!sna_crtc->cursor) { xf86CrtcDestroy(crtc); free(sna_crtc); @@ -3517,6 +3521,24 @@ sna_crtc_config_notify(ScreenPtr screen) sna_mode_update(to_sna_from_screen(screen)); } +static void +sna_cursor_pre_init(struct sna *sna) +{ + uint64_t value; + +#define DRM_CAP_CURSOR_WIDTH 8 +#define DRM_CAP_CURSOR_HEIGHT 9 + + sna->mode.cursor_width = SNA_CURSOR_X; + sna->mode.cursor_height = SNA_CURSOR_Y; + + if (drmGetCap(sna->kgem.fd, DRM_CAP_CURSOR_WIDTH, &value) == 0) + sna->mode.cursor_width = value; + + if (drmGetCap(sna->kgem.fd, DRM_CAP_CURSOR_HEIGHT, &value) == 0) + sna->mode.cursor_height = value; +} + #if HAS_PIXMAP_SHARING #define sna_setup_provider(scrn) xf86ProviderSetup(scrn, NULL, "Intel") #else @@ -3529,6 +3551,8 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna) int num_fake = 0; int i; + sna_cursor_pre_init(sna); + if (sna->flags & SNA_IS_HOSTED) { sna_setup_provider(scrn); return true; diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 4ecef3cd..01d34f80 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -1000,15 +1000,17 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL) return FALSE; if ((sna->flags & SNA_IS_HOSTED) == 0 && - xf86_cursors_init(screen, SNA_CURSOR_X, SNA_CURSOR_Y, - HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | - HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | - HARDWARE_CURSOR_INVERT_MASK | - HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | - HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | - HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 | - HARDWARE_CURSOR_UPDATE_UNHIDDEN | - HARDWARE_CURSOR_ARGB)) + xf86_cursors_init(screen, + sna->mode.cursor_width, + sna->mode.cursor_height, + HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | + HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | + HARDWARE_CURSOR_INVERT_MASK | + HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | + HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | + HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 | + HARDWARE_CURSOR_UPDATE_UNHIDDEN | + HARDWARE_CURSOR_ARGB)) xf86DrvMsg(scrn->scrnIndex, X_INFO, "HW Cursor enabled\n"); /* Must force it before EnterVT, so we are in control of VT and |