Commit 49845a23 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Use enum plane_id in VLV/CHV wm code

Let's try not to abuse plane->plane for sprites on VLV/CHV and instead
use plane->id. Since out watermark structures aren't entirely plane type
agnostic (for now) and start indexing sprites from 0  we'll add a small
helper to convert between the two bases.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1479830524-7882-7-git-send-email-ville.syrjala@linux.intel.com
parent 83c04a62
...@@ -370,12 +370,15 @@ static const int pessimal_latency_ns = 5000; ...@@ -370,12 +370,15 @@ static const int pessimal_latency_ns = 5000;
#define VLV_FIFO_START(dsparb, dsparb2, lo_shift, hi_shift) \ #define VLV_FIFO_START(dsparb, dsparb2, lo_shift, hi_shift) \
((((dsparb) >> (lo_shift)) & 0xff) | ((((dsparb2) >> (hi_shift)) & 0x1) << 8)) ((((dsparb) >> (lo_shift)) & 0xff) | ((((dsparb2) >> (hi_shift)) & 0x1) << 8))
static int vlv_get_fifo_size(struct drm_i915_private *dev_priv, static int vlv_get_fifo_size(struct intel_plane *plane)
enum pipe pipe, int plane)
{ {
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
int sprite0_start, sprite1_start, size; int sprite0_start, sprite1_start, size;
switch (pipe) { if (plane->id == PLANE_CURSOR)
return 63;
switch (plane->pipe) {
uint32_t dsparb, dsparb2, dsparb3; uint32_t dsparb, dsparb2, dsparb3;
case PIPE_A: case PIPE_A:
dsparb = I915_READ(DSPARB); dsparb = I915_READ(DSPARB);
...@@ -399,24 +402,21 @@ static int vlv_get_fifo_size(struct drm_i915_private *dev_priv, ...@@ -399,24 +402,21 @@ static int vlv_get_fifo_size(struct drm_i915_private *dev_priv,
return 0; return 0;
} }
switch (plane) { switch (plane->id) {
case 0: case PLANE_PRIMARY:
size = sprite0_start; size = sprite0_start;
break; break;
case 1: case PLANE_SPRITE0:
size = sprite1_start - sprite0_start; size = sprite1_start - sprite0_start;
break; break;
case 2: case PLANE_SPRITE1:
size = 512 - 1 - sprite1_start; size = 512 - 1 - sprite1_start;
break; break;
default: default:
return 0; return 0;
} }
DRM_DEBUG_KMS("Pipe %c %s %c FIFO size: %d\n", DRM_DEBUG_KMS("%s FIFO size: %d\n", plane->base.name, size);
pipe_name(pipe), plane == 0 ? "primary" : "sprite",
plane == 0 ? plane_name(pipe) : sprite_name(pipe, plane - 1),
size);
return size; return size;
} }
...@@ -1053,6 +1053,12 @@ static void vlv_compute_fifo(struct intel_crtc *crtc) ...@@ -1053,6 +1053,12 @@ static void vlv_compute_fifo(struct intel_crtc *crtc)
WARN_ON(fifo_left != 0); WARN_ON(fifo_left != 0);
} }
/* FIXME kill me */
static inline int vlv_sprite_id(enum plane_id plane_id)
{
return plane_id - PLANE_SPRITE0;
}
static void vlv_invert_wms(struct intel_crtc *crtc) static void vlv_invert_wms(struct intel_crtc *crtc)
{ {
struct vlv_wm_state *wm_state = &crtc->wm_state; struct vlv_wm_state *wm_state = &crtc->wm_state;
...@@ -1079,7 +1085,7 @@ static void vlv_invert_wms(struct intel_crtc *crtc) ...@@ -1079,7 +1085,7 @@ static void vlv_invert_wms(struct intel_crtc *crtc)
wm_state->wm[level].primary; wm_state->wm[level].primary;
break; break;
case DRM_PLANE_TYPE_OVERLAY: case DRM_PLANE_TYPE_OVERLAY:
sprite = plane->plane; sprite = vlv_sprite_id(plane->id);
wm_state->wm[level].sprite[sprite] = plane->wm.fifo_size - wm_state->wm[level].sprite[sprite] = plane->wm.fifo_size -
wm_state->wm[level].sprite[sprite]; wm_state->wm[level].sprite[sprite];
break; break;
...@@ -1144,7 +1150,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc) ...@@ -1144,7 +1150,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
wm_state->wm[level].primary = wm; wm_state->wm[level].primary = wm;
break; break;
case DRM_PLANE_TYPE_OVERLAY: case DRM_PLANE_TYPE_OVERLAY:
sprite = plane->plane; sprite = vlv_sprite_id(plane->id);
wm_state->wm[level].sprite[sprite] = wm; wm_state->wm[level].sprite[sprite] = wm;
break; break;
} }
...@@ -1170,7 +1176,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc) ...@@ -1170,7 +1176,7 @@ static void vlv_compute_wm(struct intel_crtc *crtc)
wm_state->wm[level].primary); wm_state->wm[level].primary);
break; break;
case DRM_PLANE_TYPE_OVERLAY: case DRM_PLANE_TYPE_OVERLAY:
sprite = plane->plane; sprite = vlv_sprite_id(plane->id);
for (level = 0; level < wm_state->num_levels; level++) for (level = 0; level < wm_state->num_levels; level++)
wm_state->sr[level].plane = wm_state->sr[level].plane =
min(wm_state->sr[level].plane, min(wm_state->sr[level].plane,
...@@ -1199,17 +1205,23 @@ static void vlv_pipe_set_fifo_size(struct intel_crtc *crtc) ...@@ -1199,17 +1205,23 @@ static void vlv_pipe_set_fifo_size(struct intel_crtc *crtc)
int sprite0_start = 0, sprite1_start = 0, fifo_size = 0; int sprite0_start = 0, sprite1_start = 0, fifo_size = 0;
for_each_intel_plane_on_crtc(dev, crtc, plane) { for_each_intel_plane_on_crtc(dev, crtc, plane) {
if (plane->base.type == DRM_PLANE_TYPE_CURSOR) { switch (plane->id) {
WARN_ON(plane->wm.fifo_size != 63); case PLANE_PRIMARY:
continue;
}
if (plane->base.type == DRM_PLANE_TYPE_PRIMARY)
sprite0_start = plane->wm.fifo_size; sprite0_start = plane->wm.fifo_size;
else if (plane->plane == 0) break;
case PLANE_SPRITE0:
sprite1_start = sprite0_start + plane->wm.fifo_size; sprite1_start = sprite0_start + plane->wm.fifo_size;
else break;
case PLANE_SPRITE1:
fifo_size = sprite1_start + plane->wm.fifo_size; fifo_size = sprite1_start + plane->wm.fifo_size;
break;
case PLANE_CURSOR:
WARN_ON(plane->wm.fifo_size != 63);
break;
default:
MISSING_CASE(plane->id);
break;
}
} }
WARN_ON(fifo_size != 512 - 1); WARN_ON(fifo_size != 512 - 1);
...@@ -4510,21 +4522,8 @@ void vlv_wm_get_hw_state(struct drm_device *dev) ...@@ -4510,21 +4522,8 @@ void vlv_wm_get_hw_state(struct drm_device *dev)
vlv_read_wm_values(dev_priv, wm); vlv_read_wm_values(dev_priv, wm);
for_each_intel_plane(dev, plane) { for_each_intel_plane(dev, plane)
switch (plane->base.type) { plane->wm.fifo_size = vlv_get_fifo_size(plane);
int sprite;
case DRM_PLANE_TYPE_CURSOR:
plane->wm.fifo_size = 63;
break;
case DRM_PLANE_TYPE_PRIMARY:
plane->wm.fifo_size = vlv_get_fifo_size(dev_priv, plane->pipe, 0);
break;
case DRM_PLANE_TYPE_OVERLAY:
sprite = plane->plane;
plane->wm.fifo_size = vlv_get_fifo_size(dev_priv, plane->pipe, sprite + 1);
break;
}
}
wm->cxsr = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN; wm->cxsr = I915_READ(FW_BLC_SELF_VLV) & FW_CSPWRDWNEN;
wm->level = VLV_WM_LEVEL_PM2; wm->level = VLV_WM_LEVEL_PM2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment