static bool attach(struct view * view, struct wld_buffer * buffer) { struct cursor_plane * plane = CONTAINER_OF(view, typeof(*plane), view); if (buffer) { union wld_object object; if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object)) { ERROR("Could not get export buffer to DRM handle\n"); return false; } if (drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32, buffer->width, buffer->height) != 0) { ERROR("Could not set cursor: %s\n", strerror(errno)); return false; } } else { if (drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0) != 0) { ERROR("Could not unset cursor: %s\n", strerror(errno)); return false; } } view_set_size_from_buffer(view, buffer); return true; }
static int attach(struct view * view, struct wld_buffer * buffer) { struct cursor_plane * plane = wl_container_of(view, plane, view); if (buffer) { union wld_object object; if (!wld_export(buffer, WLD_DRM_OBJECT_HANDLE, &object)) { ERROR("Could not get export buffer to DRM handle\n"); /* XXX: Not the best error code, but we don't know better until wld * returns an actual error code. */ return -EINVAL; } if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, object.u32, buffer->width, buffer->height) < 0) { ERROR("Could not set cursor: %s\n", strerror(errno)); return -errno; } } else if (swc.active && drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0) < 0) { ERROR("Could not unset cursor: %s\n", strerror(errno)); return -errno; } view_set_size_from_buffer(view, buffer); return 0; }
static void crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; unsigned char *ptr; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); CursorPtr c = config->cursor; if (vmwgfx_cursor_bypass(ms->fd, c->bits->xhot, c->bits->yhot) != 0) { xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, "Failed to set VMWare cursor bypass.\n"); } if (!crtcp->cursor_bo) { size_t size = 64*64*4; crtcp->cursor_bo = vmwgfx_dmabuf_alloc(ms->fd, size); if (!crtcp->cursor_bo) return; crtcp->cursor_handle = crtcp->cursor_bo->handle; } ptr = vmwgfx_dmabuf_map(crtcp->cursor_bo); if (ptr) { memcpy(ptr, image, 64*64*4); vmwgfx_dmabuf_unmap(crtcp->cursor_bo); } if (crtc->cursor_shown) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); return; }
static void move_cursor(struct cursor *cursor, struct cursor_step *step) { int x = cursor->x; int y = cursor->y; if (!cursor->enabled) drmModeSetCursor(cursor->fd, cursor->crtc_id, cursor->bo_handle, cursor->w, cursor->h); /* calculate new cursor position: */ x += cursor->dx * step->arg; y += cursor->dy * step->arg; if (x < 0) { x = 0; cursor->dx = 1; } else if (x > (int)cursor->crtc_w) { x = cursor->crtc_w - 1; cursor->dx = -1; } if (y < 0) { y = 0; cursor->dy = 1; } else if (y > (int)cursor->crtc_h) { y = cursor->crtc_h - 1; cursor->dy = -1; } cursor->x = x; cursor->y = y; drmModeMoveCursor(cursor->fd, cursor->crtc_id, x, y); }
static void crtc_hide_cursor(xf86CrtcPtr crtc) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0); }
static void unset_mode(void) { int rc; kmstest_unset_all_crtcs(drm.fd, drm.res); rc = drmModeSetCursor(drm.fd, modeset.crtc_id, 0, 0, 0); igt_assert(rc == 0); }
void mgm::RealKMSOutput::clear_cursor() { if (current_crtc) { drmModeSetCursor(drm_fd, current_crtc->crtc_id, 0, 0, 0); has_cursor_ = false; } }
static void drmmode_show_cursor (xf86CrtcPtr crtc) { drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; drmmode_ptr drmmode = drmmode_crtc->drmmode; drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, drmmode_crtc->cursor->handle, 64, 64); }
static void crtc_show_cursor(xf86CrtcPtr crtc) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; if (crtcp->cursor_bo) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); }
static void set_cursor(struct cursor *cursor, struct cursor_step *step) { int enabled = (step->arg ^ count) & 0x1; uint32_t handle = 0; if (enabled) handle = cursor->bo_handle; cursor->enabled = enabled; drmModeSetCursor(cursor->fd, cursor->crtc_id, handle, cursor->w, cursor->h); }
bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc, const struct swc_rectangle * origin) { if (drmModeSetCursor(swc.drm->fd, crtc, 0, 0, 0) != 0) return false; plane->origin = origin; plane->crtc = crtc; plane->launch_listener.notify = &handle_launch_event; wl_signal_add(&swc.launch->event_signal, &plane->launch_listener); view_initialize(&plane->view, &view_impl); return true; }
static void crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) { unsigned char *ptr; modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; struct pipe_transfer *transfer; if (!crtcp->cursor_tex) { struct pipe_resource templat; struct winsys_handle whandle; memset(&templat, 0, sizeof(templat)); templat.bind |= PIPE_BIND_RENDER_TARGET; templat.bind |= PIPE_BIND_SCANOUT; templat.target = PIPE_TEXTURE_2D; templat.last_level = 0; templat.depth0 = 1; templat.array_size = 1; templat.format = PIPE_FORMAT_B8G8R8A8_UNORM; templat.width0 = 64; templat.height0 = 64; memset(&whandle, 0, sizeof(whandle)); whandle.type = DRM_API_HANDLE_TYPE_KMS; crtcp->cursor_tex = ms->screen->resource_create(ms->screen, &templat); ms->screen->resource_get_handle(ms->screen, crtcp->cursor_tex, &whandle); crtcp->cursor_handle = whandle.handle; } transfer = pipe_get_transfer(ms->ctx, crtcp->cursor_tex, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, 64, 64); ptr = ms->ctx->transfer_map(ms->ctx, transfer); util_copy_rect(ptr, crtcp->cursor_tex->format, transfer->stride, 0, 0, 64, 64, (void*)image, 64 * 4, 0, 0); ms->ctx->transfer_unmap(ms->ctx, transfer); ms->ctx->transfer_destroy(ms->ctx, transfer); if (crtc->cursor_shown) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); }
void mgm::RealKMSOutput::set_cursor(gbm_bo* buffer) { if (current_crtc) { if (auto result = drmModeSetCursor( drm_fd, current_crtc->crtc_id, gbm_bo_get_handle(buffer).u32, gbm_bo_get_width(buffer), gbm_bo_get_height(buffer))) { fatal_error("drmModeSetCursor failed (returned %d)", result); } has_cursor_ = true; } }
static void set_mode(void) { int rc; front_fb = &fbs[0]; back_fb = &fbs[1]; rc = drmModeSetCrtc(drm.fd, modeset.crtc_id, front_fb->fb_id, 0, 0, &modeset.connector_id, 1, modeset.mode); igt_assert(rc == 0); /* TODO: it seems we need a cursor in order to reach PC7 on BDW. Why? */ rc = drmModeMoveCursor(drm.fd, modeset.crtc_id, 0, 0); igt_assert(rc == 0); rc = drmModeSetCursor(drm.fd, modeset.crtc_id, cursor.gem_handle, cursor.width, cursor.height); igt_assert(rc == 0); }
static void crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) { modesettingPtr ms = modesettingPTR(crtc->scrn); struct crtc_private *crtcp = crtc->driver_private; unsigned char *ptr; if (!crtcp->cursor_bo) { unsigned attr[8]; attr[0] = KMS_BO_TYPE; #ifdef KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 attr[1] = KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8; #else attr[1] = KMS_BO_TYPE_CURSOR; #endif attr[2] = KMS_WIDTH; attr[3] = 64; attr[4] = KMS_HEIGHT; attr[5] = 64; attr[6] = 0; if (kms_bo_create(ms->kms, attr, &crtcp->cursor_bo)) return; if (kms_bo_get_prop(crtcp->cursor_bo, KMS_HANDLE, &crtcp->cursor_handle)) goto err_bo_destroy; } kms_bo_map(crtcp->cursor_bo, (void**)&ptr); memcpy(ptr, image, 64*64*4); kms_bo_unmap(crtcp->cursor_bo); if (crtc->cursor_shown) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, crtcp->cursor_handle, 64, 64); return; err_bo_destroy: kms_bo_destroy(&crtcp->cursor_bo); }
/* Prevents some glitch if Chromium OS keeps cursor enabled (#2878). */ static void drm_disable_cursor() { int i, fd; drmModeRes* resources; if (!orig_open) preload_init(); fd = orig_open("/dev/dri/card0", O_RDWR, 0); TRACE("%s %d\n", __func__, fd); if (fd < 0) return; resources = drmModeGetResources(fd); if (!resources) goto closefd; TRACE("%s res=%p\n", __func__, resources); for (i = 0; i < resources->count_crtcs; i++) { drmModeCrtc* crtc; crtc = drmModeGetCrtc(fd, resources->crtcs[i]); TRACE("%s crtc %d %p\n", __func__, i, crtc); if (crtc) { drmModeSetCursor(fd, crtc->crtc_id, 0, 0, 0); drmModeFreeCrtc(crtc); } } drmModeFreeResources(resources); closefd: orig_close(fd); }
QKmsCursor::~QKmsCursor() { drmModeSetCursor(m_screen->device()->fd(), m_screen->crtcId(), 0, 0, 0); }
QKmsCursor::~QKmsCursor() { drmModeSetCursor(m_screen->device()->fd(), m_screen->crtcId(), 0, 0, 0); gbm_bo_destroy(m_cursorBufferObject); }
static void plane_cursor(struct kms_atomic_crtc_state *crtc, struct kms_atomic_plane_state *plane_old) { struct drm_mode_modeinfo *mode = crtc->mode.data; struct kms_atomic_plane_state plane = *plane_old; drmModeAtomicReq *req = drmModeAtomicAlloc(); struct igt_fb fb; uint64_t width, height; igt_assert(req); /* Any kernel new enough for atomic, also has the cursor size caps. */ do_or_die(drmGetCap(plane.state->desc->fd, DRM_CAP_CURSOR_WIDTH, &width)); do_or_die(drmGetCap(plane.state->desc->fd, DRM_CAP_CURSOR_HEIGHT, &height)); plane.src_x = 0; plane.src_y = 0; plane.src_w = width << 16; plane.src_h = height << 16; plane.crtc_x = mode->hdisplay / 2; plane.crtc_y = mode->vdisplay / 2; plane.crtc_w = width; plane.crtc_h = height; plane.crtc_id = crtc->obj; plane.fb_id = igt_create_color_fb(plane.state->desc->fd, width, height, DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE, 0.0, 0.0, 0.0, &fb); igt_assert_neq_u32(plane.fb_id, 0); /* Flip the cursor plane using the atomic API, and double-check * state is what we think it should be. */ plane_commit_atomic(&plane, req, ATOMIC_RELAX_NONE); /* Restore the cursor plane and check the state matches the old. */ plane_commit_atomic(plane_old, req, ATOMIC_RELAX_NONE); /* Re-enable the plane through the legacy cursor API, and verify * through atomic. */ do_or_die(drmModeMoveCursor(plane.state->desc->fd, plane.crtc_id, plane.crtc_x, plane.crtc_y)); do_or_die(drmModeSetCursor(plane.state->desc->fd, plane.crtc_id, fb.gem_handle, width, height)); plane_check_current_state(&plane, PLANE_RELAX_FB); /* Wiggle. */ plane.crtc_x -= 16; plane.crtc_y -= 16; do_or_die(drmModeMoveCursor(plane.state->desc->fd, plane.crtc_id, plane.crtc_x, plane.crtc_y)); plane_check_current_state(&plane, PLANE_RELAX_FB); /* Restore the plane to its original settings through the legacy cursor * API, and verify through atomic. */ do_or_die(drmModeSetCursor2(plane.state->desc->fd, plane.crtc_id, 0, 0, 0, 0, 0)); plane_check_current_state(plane_old, ATOMIC_RELAX_NONE); /* Finally, restore to the original state. */ plane_commit_atomic(plane_old, req, ATOMIC_RELAX_NONE); drmModeAtomicFree(req); }
void cursor_plane_finalize(struct cursor_plane * plane) { drmModeSetCursor(swc.drm->fd, plane->crtc, 0, 0, 0); }