aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-05-12 17:17:14 -0400
committerKeith Packard <keithp@keithp.com>2011-06-04 13:40:59 -0400
commit9f405100f2b39be7759eea3f4cf910869727429c (patch)
treefe683a1dc25690781653109d3ac29c5a855815de /drivers/gpu
parentbf3301abba31ee71ed8dc87f18fcaebd27dc3b3e (diff)
drm/i915: Replace ironlake_compute_wm0 with g4x_compute_wm0
The computation of the first-level watermarks for g4x and gen5+ are based on the same algorithm, so we can refactor those code paths to use a single function. Note that g4x_compute_wm0 takes a 'plane' argument while ironlake_compute_wm0 took a 'pipe' argument. Both should have used a 'plane' argument, so this patch fixes that as well (not that it caused a problem; ironlake always uses pipe == plane). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c88
1 files changed, 20 insertions, 68 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bb1b59b3d12..81a9059b6a9 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3983,54 +3983,6 @@ static void i830_update_wm(struct drm_device *dev)
3983#define ILK_LP0_PLANE_LATENCY 700 3983#define ILK_LP0_PLANE_LATENCY 700
3984#define ILK_LP0_CURSOR_LATENCY 1300 3984#define ILK_LP0_CURSOR_LATENCY 1300
3985 3985
3986static bool ironlake_compute_wm0(struct drm_device *dev,
3987 int pipe,
3988 const struct intel_watermark_params *display,
3989 int display_latency_ns,
3990 const struct intel_watermark_params *cursor,
3991 int cursor_latency_ns,
3992 int *plane_wm,
3993 int *cursor_wm)
3994{
3995 struct drm_crtc *crtc;
3996 int htotal, hdisplay, clock, pixel_size;
3997 int line_time_us, line_count;
3998 int entries, tlb_miss;
3999
4000 crtc = intel_get_crtc_for_pipe(dev, pipe);
4001 if (crtc->fb == NULL || !crtc->enabled)
4002 return false;
4003
4004 htotal = crtc->mode.htotal;
4005 hdisplay = crtc->mode.hdisplay;
4006 clock = crtc->mode.clock;
4007 pixel_size = crtc->fb->bits_per_pixel / 8;
4008
4009 /* Use the small buffer method to calculate plane watermark */
4010 entries = ((clock * pixel_size / 1000) * display_latency_ns) / 1000;
4011 tlb_miss = display->fifo_size*display->cacheline_size - hdisplay * 8;
4012 if (tlb_miss > 0)
4013 entries += tlb_miss;
4014 entries = DIV_ROUND_UP(entries, display->cacheline_size);
4015 *plane_wm = entries + display->guard_size;
4016 if (*plane_wm > (int)display->max_wm)
4017 *plane_wm = display->max_wm;
4018
4019 /* Use the large buffer method to calculate cursor watermark */
4020 line_time_us = ((htotal * 1000) / clock);
4021 line_count = (cursor_latency_ns / line_time_us + 1000) / 1000;
4022 entries = line_count * 64 * pixel_size;
4023 tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8;
4024 if (tlb_miss > 0)
4025 entries += tlb_miss;
4026 entries = DIV_ROUND_UP(entries, cursor->cacheline_size);
4027 *cursor_wm = entries + cursor->guard_size;
4028 if (*cursor_wm > (int)cursor->max_wm)
4029 *cursor_wm = (int)cursor->max_wm;
4030
4031 return true;
4032}
4033
4034/* 3986/*
4035 * Check the wm result. 3987 * Check the wm result.
4036 * 3988 *
@@ -4139,12 +4091,12 @@ static void ironlake_update_wm(struct drm_device *dev)
4139 unsigned int enabled; 4091 unsigned int enabled;
4140 4092
4141 enabled = 0; 4093 enabled = 0;
4142 if (ironlake_compute_wm0(dev, 0, 4094 if (g4x_compute_wm0(dev, 0,
4143 &ironlake_display_wm_info, 4095 &ironlake_display_wm_info,
4144 ILK_LP0_PLANE_LATENCY, 4096 ILK_LP0_PLANE_LATENCY,
4145 &ironlake_cursor_wm_info, 4097 &ironlake_cursor_wm_info,
4146 ILK_LP0_CURSOR_LATENCY, 4098 ILK_LP0_CURSOR_LATENCY,
4147 &plane_wm, &cursor_wm)) { 4099 &plane_wm, &cursor_wm)) {
4148 I915_WRITE(WM0_PIPEA_ILK, 4100 I915_WRITE(WM0_PIPEA_ILK,
4149 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm); 4101 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
4150 DRM_DEBUG_KMS("FIFO watermarks For pipe A -" 4102 DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
@@ -4153,12 +4105,12 @@ static void ironlake_update_wm(struct drm_device *dev)
4153 enabled |= 1; 4105 enabled |= 1;
4154 } 4106 }
4155 4107
4156 if (ironlake_compute_wm0(dev, 1, 4108 if (g4x_compute_wm0(dev, 1,
4157 &ironlake_display_wm_info, 4109 &ironlake_display_wm_info,
4158 ILK_LP0_PLANE_LATENCY, 4110 ILK_LP0_PLANE_LATENCY,
4159 &ironlake_cursor_wm_info, 4111 &ironlake_cursor_wm_info,
4160 ILK_LP0_CURSOR_LATENCY, 4112 ILK_LP0_CURSOR_LATENCY,
4161 &plane_wm, &cursor_wm)) { 4113 &plane_wm, &cursor_wm)) {
4162 I915_WRITE(WM0_PIPEB_ILK, 4114 I915_WRITE(WM0_PIPEB_ILK,
4163 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm); 4115 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
4164 DRM_DEBUG_KMS("FIFO watermarks For pipe B -" 4116 DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
@@ -4223,10 +4175,10 @@ static void sandybridge_update_wm(struct drm_device *dev)
4223 unsigned int enabled; 4175 unsigned int enabled;
4224 4176
4225 enabled = 0; 4177 enabled = 0;
4226 if (ironlake_compute_wm0(dev, 0, 4178 if (g4x_compute_wm0(dev, 0,
4227 &sandybridge_display_wm_info, latency, 4179 &sandybridge_display_wm_info, latency,
4228 &sandybridge_cursor_wm_info, latency, 4180 &sandybridge_cursor_wm_info, latency,
4229 &plane_wm, &cursor_wm)) { 4181 &plane_wm, &cursor_wm)) {
4230 I915_WRITE(WM0_PIPEA_ILK, 4182 I915_WRITE(WM0_PIPEA_ILK,
4231 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm); 4183 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
4232 DRM_DEBUG_KMS("FIFO watermarks For pipe A -" 4184 DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
@@ -4235,10 +4187,10 @@ static void sandybridge_update_wm(struct drm_device *dev)
4235 enabled |= 1; 4187 enabled |= 1;
4236 } 4188 }
4237 4189
4238 if (ironlake_compute_wm0(dev, 1, 4190 if (g4x_compute_wm0(dev, 1,
4239 &sandybridge_display_wm_info, latency, 4191 &sandybridge_display_wm_info, latency,
4240 &sandybridge_cursor_wm_info, latency, 4192 &sandybridge_cursor_wm_info, latency,
4241 &plane_wm, &cursor_wm)) { 4193 &plane_wm, &cursor_wm)) {
4242 I915_WRITE(WM0_PIPEB_ILK, 4194 I915_WRITE(WM0_PIPEB_ILK,
4243 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm); 4195 (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
4244 DRM_DEBUG_KMS("FIFO watermarks For pipe B -" 4196 DRM_DEBUG_KMS("FIFO watermarks For pipe B -"