Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3538e80a authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Gerd Hoffmann
Browse files
parent c2ff6632
Loading
Loading
Loading
Loading
+16 −72
Original line number Original line Diff line number Diff line
@@ -462,82 +462,25 @@ static void qxl_monitors_config_set(struct qxl_device *qdev,


}
}


static int qxl_crtc_mode_set(struct drm_crtc *crtc,
static void qxl_crtc_prepare(struct drm_crtc *crtc)
			       struct drm_display_mode *mode,
			       struct drm_display_mode *adjusted_mode,
			       int x, int y,
			       struct drm_framebuffer *old_fb)
{
{
	struct drm_device *dev = crtc->dev;
	DRM_DEBUG("current: %dx%d+%d+%d (%d).\n",
	struct qxl_device *qdev = dev->dev_private;
		  crtc->mode.hdisplay, crtc->mode.vdisplay,
	struct qxl_framebuffer *qfb;
		  crtc->x, crtc->y, crtc->enabled);
	struct qxl_bo *bo, *old_bo = NULL;
	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
	bool recreate_primary = false;
	int ret;
	int surf_id;
	if (!crtc->primary->fb) {
		DRM_DEBUG_KMS("No FB bound\n");
		return 0;
	}

	if (old_fb) {
		qfb = to_qxl_framebuffer(old_fb);
		old_bo = gem_to_qxl_bo(qfb->obj);
	}
	qfb = to_qxl_framebuffer(crtc->primary->fb);
	bo = gem_to_qxl_bo(qfb->obj);
	DRM_DEBUG("+%d+%d (%d,%d) => (%d,%d)\n",
		  x, y,
		  mode->hdisplay, mode->vdisplay,
		  adjusted_mode->hdisplay,
		  adjusted_mode->vdisplay);

	if (bo->is_primary == false)
		recreate_primary = true;

	if (bo->surf.stride * bo->surf.height > qdev->vram_size) {
		DRM_ERROR("Mode doesn't fit in vram size (vgamem)");
		return -EINVAL;
        }

	ret = qxl_bo_pin(bo, bo->type, NULL);
	if (ret != 0)
		return -EINVAL;

	if (recreate_primary) {
		qxl_io_destroy_primary(qdev);
		qxl_io_log(qdev,
			   "recreate primary: %dx%d,%d,%d\n",
			   bo->surf.width, bo->surf.height,
			   bo->surf.stride, bo->surf.format);
		qxl_io_create_primary(qdev, 0, bo);
		bo->is_primary = true;
}
}


	if (bo->is_primary) {
void qxl_mode_set_nofb(struct drm_crtc *crtc)
		DRM_DEBUG_KMS("setting surface_id to 0 for primary surface %d on crtc %d\n", bo->surface_id, qcrtc->index);
{
		surf_id = 0;
	struct qxl_device *qdev = crtc->dev->dev_private;
	} else {
	struct qxl_crtc *qcrtc = to_qxl_crtc(crtc);
		surf_id = bo->surface_id;
	struct drm_display_mode *mode = &crtc->mode;
	}


	if (old_bo && old_bo != bo) {
	DRM_DEBUG("Mode set (%d,%d)\n",
		old_bo->is_primary = false;
		  mode->hdisplay, mode->vdisplay);
		qxl_bo_unpin(old_bo);
	}


	qxl_monitors_config_set(qdev, qcrtc->index, x, y,
	qxl_monitors_config_set(qdev, qcrtc->index, 0, 0,
				mode->hdisplay,
				mode->hdisplay,	mode->vdisplay, 0);
				mode->vdisplay, surf_id);
	return 0;
}


static void qxl_crtc_prepare(struct drm_crtc *crtc)
{
	DRM_DEBUG("current: %dx%d+%d+%d (%d).\n",
		  crtc->mode.hdisplay, crtc->mode.vdisplay,
		  crtc->x, crtc->y, crtc->enabled);
}
}


static void qxl_crtc_commit(struct drm_crtc *crtc)
static void qxl_crtc_commit(struct drm_crtc *crtc)
@@ -567,7 +510,8 @@ static const struct drm_crtc_helper_funcs qxl_crtc_helper_funcs = {
	.dpms = qxl_crtc_dpms,
	.dpms = qxl_crtc_dpms,
	.disable = qxl_crtc_disable,
	.disable = qxl_crtc_disable,
	.mode_fixup = qxl_crtc_mode_fixup,
	.mode_fixup = qxl_crtc_mode_fixup,
	.mode_set = qxl_crtc_mode_set,
	.mode_set = drm_helper_crtc_mode_set,
	.mode_set_nofb = qxl_mode_set_nofb,
	.prepare = qxl_crtc_prepare,
	.prepare = qxl_crtc_prepare,
	.commit = qxl_crtc_commit,
	.commit = qxl_crtc_commit,
	.atomic_flush = qxl_crtc_atomic_flush,
	.atomic_flush = qxl_crtc_atomic_flush,