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

Commit 663f3122 authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm/i915: Drop the broken cursor base==0 special casing



The cursor code tries to treat base==0 to mean disabled. That fails
when the cursor bo gets bound at ggtt offset 0, and the user is left
looking at an invisible cursor.

We lose the disabled->disabled optimization, but that seems like
something better handled at a slightly higher level.

Cc: drm-intel-fixes@lists.freedesktop.org
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1450091808-32607-3-git-send-email-ville.syrjala@linux.intel.com


Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent 1264859d
Loading
Loading
Loading
Loading
+12 −17
Original line number Original line Diff line number Diff line
@@ -10013,14 +10013,14 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
	return true;
	return true;
}
}


static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
static void i845_update_cursor(struct drm_crtc *crtc, u32 base, bool on)
{
{
	struct drm_device *dev = crtc->dev;
	struct drm_device *dev = crtc->dev;
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	uint32_t cntl = 0, size = 0;
	uint32_t cntl = 0, size = 0;


	if (base) {
	if (on) {
		unsigned int width = intel_crtc->base.cursor->state->crtc_w;
		unsigned int width = intel_crtc->base.cursor->state->crtc_w;
		unsigned int height = intel_crtc->base.cursor->state->crtc_h;
		unsigned int height = intel_crtc->base.cursor->state->crtc_h;
		unsigned int stride = roundup_pow_of_two(width) * 4;
		unsigned int stride = roundup_pow_of_two(width) * 4;
@@ -10075,16 +10075,15 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base)
	}
	}
}
}


static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base, bool on)
{
{
	struct drm_device *dev = crtc->dev;
	struct drm_device *dev = crtc->dev;
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
	int pipe = intel_crtc->pipe;
	int pipe = intel_crtc->pipe;
	uint32_t cntl;
	uint32_t cntl = 0;


	cntl = 0;
	if (on) {
	if (base) {
		cntl = MCURSOR_GAMMA_ENABLE;
		cntl = MCURSOR_GAMMA_ENABLE;
		switch (intel_crtc->base.cursor->state->crtc_w) {
		switch (intel_crtc->base.cursor->state->crtc_w) {
			case 64:
			case 64:
@@ -10135,18 +10134,17 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
	int y = cursor_state->crtc_y;
	int y = cursor_state->crtc_y;
	u32 base = 0, pos = 0;
	u32 base = 0, pos = 0;


	if (on)
	base = intel_crtc->cursor_addr;
	base = intel_crtc->cursor_addr;


	if (x >= intel_crtc->config->pipe_src_w)
	if (x >= intel_crtc->config->pipe_src_w)
		base = 0;
		on = false;


	if (y >= intel_crtc->config->pipe_src_h)
	if (y >= intel_crtc->config->pipe_src_h)
		base = 0;
		on = false;


	if (x < 0) {
	if (x < 0) {
		if (x + cursor_state->crtc_w <= 0)
		if (x + cursor_state->crtc_w <= 0)
			base = 0;
			on = false;


		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
		x = -x;
		x = -x;
@@ -10155,16 +10153,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,


	if (y < 0) {
	if (y < 0) {
		if (y + cursor_state->crtc_h <= 0)
		if (y + cursor_state->crtc_h <= 0)
			base = 0;
			on = false;


		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
		y = -y;
		y = -y;
	}
	}
	pos |= y << CURSOR_Y_SHIFT;
	pos |= y << CURSOR_Y_SHIFT;


	if (base == 0 && intel_crtc->cursor_base == 0)
		return;

	I915_WRITE(CURPOS(pipe), pos);
	I915_WRITE(CURPOS(pipe), pos);


	/* ILK+ do this automagically */
	/* ILK+ do this automagically */
@@ -10175,9 +10170,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
	}
	}


	if (IS_845G(dev) || IS_I865G(dev))
	if (IS_845G(dev) || IS_I865G(dev))
		i845_update_cursor(crtc, base);
		i845_update_cursor(crtc, base, on);
	else
	else
		i9xx_update_cursor(crtc, base);
		i9xx_update_cursor(crtc, base, on);
}
}


static bool cursor_size_ok(struct drm_device *dev,
static bool cursor_size_ok(struct drm_device *dev,