Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014 Intel Corporation |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 24 | /** |
| 25 | * DOC: Frame Buffer Compression (FBC) |
| 26 | * |
| 27 | * FBC tries to save memory bandwidth (and so power consumption) by |
| 28 | * compressing the amount of memory used by the display. It is total |
| 29 | * transparent to user space and completely handled in the kernel. |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 30 | * |
| 31 | * The benefits of FBC are mostly visible with solid backgrounds and |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 32 | * variation-less patterns. It comes from keeping the memory footprint small |
| 33 | * and having fewer memory pages opened and accessed for refreshing the display. |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 34 | * |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 35 | * i915 is responsible to reserve stolen memory for FBC and configure its |
| 36 | * offset on proper registers. The hardware takes care of all |
| 37 | * compress/decompress. However there are many known cases where we have to |
| 38 | * forcibly disable it to allow proper screen updates. |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 39 | */ |
| 40 | |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 41 | #include "intel_drv.h" |
| 42 | #include "i915_drv.h" |
| 43 | |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 44 | static inline bool fbc_supported(struct drm_i915_private *dev_priv) |
| 45 | { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 46 | return dev_priv->fbc.activate != NULL; |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 47 | } |
| 48 | |
Paulo Zanoni | 5710502 | 2015-11-04 17:10:46 -0200 | [diff] [blame] | 49 | static inline bool fbc_on_pipe_a_only(struct drm_i915_private *dev_priv) |
| 50 | { |
| 51 | return IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8; |
| 52 | } |
| 53 | |
Paulo Zanoni | e6cd6dc | 2015-10-16 17:55:40 -0300 | [diff] [blame] | 54 | static inline bool fbc_on_plane_a_only(struct drm_i915_private *dev_priv) |
| 55 | { |
| 56 | return INTEL_INFO(dev_priv)->gen < 4; |
| 57 | } |
| 58 | |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 59 | /* |
| 60 | * In some platforms where the CRTC's x:0/y:0 coordinates doesn't match the |
| 61 | * frontbuffer's x:0/y:0 coordinates we lie to the hardware about the plane's |
| 62 | * origin so the x and y offsets can actually fit the registers. As a |
| 63 | * consequence, the fence doesn't really start exactly at the display plane |
| 64 | * address we program because it starts at the real start of the buffer, so we |
| 65 | * have to take this into consideration here. |
| 66 | */ |
| 67 | static unsigned int get_crtc_fence_y_offset(struct intel_crtc *crtc) |
| 68 | { |
| 69 | return crtc->base.y - crtc->adjusted_y; |
| 70 | } |
| 71 | |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 72 | /* |
| 73 | * For SKL+, the plane source size used by the hardware is based on the value we |
| 74 | * write to the PLANE_SIZE register. For BDW-, the hardware looks at the value |
| 75 | * we wrote to PIPESRC. |
| 76 | */ |
| 77 | static void intel_fbc_get_plane_source_size(struct intel_crtc *crtc, |
| 78 | int *width, int *height) |
| 79 | { |
| 80 | struct intel_plane_state *plane_state = |
| 81 | to_intel_plane_state(crtc->base.primary->state); |
| 82 | int w, h; |
| 83 | |
| 84 | if (intel_rotation_90_or_270(plane_state->base.rotation)) { |
| 85 | w = drm_rect_height(&plane_state->src) >> 16; |
| 86 | h = drm_rect_width(&plane_state->src) >> 16; |
| 87 | } else { |
| 88 | w = drm_rect_width(&plane_state->src) >> 16; |
| 89 | h = drm_rect_height(&plane_state->src) >> 16; |
| 90 | } |
| 91 | |
| 92 | if (width) |
| 93 | *width = w; |
| 94 | if (height) |
| 95 | *height = h; |
| 96 | } |
| 97 | |
| 98 | static int intel_fbc_calculate_cfb_size(struct intel_crtc *crtc, |
| 99 | struct drm_framebuffer *fb) |
| 100 | { |
| 101 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 102 | int lines; |
| 103 | |
| 104 | intel_fbc_get_plane_source_size(crtc, NULL, &lines); |
| 105 | if (INTEL_INFO(dev_priv)->gen >= 7) |
| 106 | lines = min(lines, 2048); |
| 107 | |
| 108 | /* Hardware needs the full buffer stride, not just the active area. */ |
| 109 | return lines * fb->pitches[0]; |
| 110 | } |
| 111 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 112 | static void i8xx_fbc_deactivate(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 113 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 114 | u32 fbc_ctl; |
| 115 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 116 | dev_priv->fbc.active = false; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 117 | |
| 118 | /* Disable compression */ |
| 119 | fbc_ctl = I915_READ(FBC_CONTROL); |
| 120 | if ((fbc_ctl & FBC_CTL_EN) == 0) |
| 121 | return; |
| 122 | |
| 123 | fbc_ctl &= ~FBC_CTL_EN; |
| 124 | I915_WRITE(FBC_CONTROL, fbc_ctl); |
| 125 | |
| 126 | /* Wait for compressing bit to clear */ |
| 127 | if (wait_for((I915_READ(FBC_STATUS) & FBC_STAT_COMPRESSING) == 0, 10)) { |
| 128 | DRM_DEBUG_KMS("FBC idle timed out\n"); |
| 129 | return; |
| 130 | } |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 131 | } |
| 132 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 133 | static void i8xx_fbc_activate(struct intel_crtc *crtc) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 134 | { |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 135 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 136 | struct drm_framebuffer *fb = crtc->base.primary->fb; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 137 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 138 | int cfb_pitch; |
| 139 | int i; |
| 140 | u32 fbc_ctl; |
| 141 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 142 | dev_priv->fbc.active = true; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 143 | |
Jani Nikula | 60ee5cd | 2015-02-05 12:04:27 +0200 | [diff] [blame] | 144 | /* Note: fbc.threshold == 1 for i8xx */ |
Paulo Zanoni | 559d913 | 2015-10-26 18:44:25 -0200 | [diff] [blame] | 145 | cfb_pitch = intel_fbc_calculate_cfb_size(crtc, fb) / FBC_LL_SIZE; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 146 | if (fb->pitches[0] < cfb_pitch) |
| 147 | cfb_pitch = fb->pitches[0]; |
| 148 | |
| 149 | /* FBC_CTL wants 32B or 64B units */ |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 150 | if (IS_GEN2(dev_priv)) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 151 | cfb_pitch = (cfb_pitch / 32) - 1; |
| 152 | else |
| 153 | cfb_pitch = (cfb_pitch / 64) - 1; |
| 154 | |
| 155 | /* Clear old tags */ |
| 156 | for (i = 0; i < (FBC_LL_SIZE / 32) + 1; i++) |
Ville Syrjälä | 4d110c7 | 2015-09-18 20:03:18 +0300 | [diff] [blame] | 157 | I915_WRITE(FBC_TAG(i), 0); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 158 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 159 | if (IS_GEN4(dev_priv)) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 160 | u32 fbc_ctl2; |
| 161 | |
| 162 | /* Set it up... */ |
| 163 | fbc_ctl2 = FBC_CTL_FENCE_DBL | FBC_CTL_IDLE_IMM | FBC_CTL_CPU_FENCE; |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 164 | fbc_ctl2 |= FBC_CTL_PLANE(crtc->plane); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 165 | I915_WRITE(FBC_CONTROL2, fbc_ctl2); |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 166 | I915_WRITE(FBC_FENCE_OFF, get_crtc_fence_y_offset(crtc)); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* enable it... */ |
| 170 | fbc_ctl = I915_READ(FBC_CONTROL); |
| 171 | fbc_ctl &= 0x3fff << FBC_CTL_INTERVAL_SHIFT; |
| 172 | fbc_ctl |= FBC_CTL_EN | FBC_CTL_PERIODIC; |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 173 | if (IS_I945GM(dev_priv)) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 174 | fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */ |
| 175 | fbc_ctl |= (cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT; |
| 176 | fbc_ctl |= obj->fence_reg; |
| 177 | I915_WRITE(FBC_CONTROL, fbc_ctl); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 178 | } |
| 179 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 180 | static bool i8xx_fbc_is_active(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 181 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 182 | return I915_READ(FBC_CONTROL) & FBC_CTL_EN; |
| 183 | } |
| 184 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 185 | static void g4x_fbc_activate(struct intel_crtc *crtc) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 186 | { |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 187 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 188 | struct drm_framebuffer *fb = crtc->base.primary->fb; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 189 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 190 | u32 dpfc_ctl; |
| 191 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 192 | dev_priv->fbc.active = true; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 193 | |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 194 | dpfc_ctl = DPFC_CTL_PLANE(crtc->plane) | DPFC_SR_EN; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 195 | if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) |
| 196 | dpfc_ctl |= DPFC_CTL_LIMIT_2X; |
| 197 | else |
| 198 | dpfc_ctl |= DPFC_CTL_LIMIT_1X; |
| 199 | dpfc_ctl |= DPFC_CTL_FENCE_EN | obj->fence_reg; |
| 200 | |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 201 | I915_WRITE(DPFC_FENCE_YOFF, get_crtc_fence_y_offset(crtc)); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 202 | |
| 203 | /* enable it... */ |
| 204 | I915_WRITE(DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 205 | } |
| 206 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 207 | static void g4x_fbc_deactivate(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 208 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 209 | u32 dpfc_ctl; |
| 210 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 211 | dev_priv->fbc.active = false; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 212 | |
| 213 | /* Disable compression */ |
| 214 | dpfc_ctl = I915_READ(DPFC_CONTROL); |
| 215 | if (dpfc_ctl & DPFC_CTL_EN) { |
| 216 | dpfc_ctl &= ~DPFC_CTL_EN; |
| 217 | I915_WRITE(DPFC_CONTROL, dpfc_ctl); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 221 | static bool g4x_fbc_is_active(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 222 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 223 | return I915_READ(DPFC_CONTROL) & DPFC_CTL_EN; |
| 224 | } |
| 225 | |
Paulo Zanoni | d5ce416 | 2015-11-04 17:10:45 -0200 | [diff] [blame] | 226 | /* This function forces a CFB recompression through the nuke operation. */ |
| 227 | static void intel_fbc_recompress(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 228 | { |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 229 | I915_WRITE(MSG_FBC_REND_STATE, FBC_REND_NUKE); |
| 230 | POSTING_READ(MSG_FBC_REND_STATE); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 231 | } |
| 232 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 233 | static void ilk_fbc_activate(struct intel_crtc *crtc) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 234 | { |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 235 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 236 | struct drm_framebuffer *fb = crtc->base.primary->fb; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 237 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 238 | u32 dpfc_ctl; |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 239 | int threshold = dev_priv->fbc.threshold; |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 240 | unsigned int y_offset; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 241 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 242 | dev_priv->fbc.active = true; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 243 | |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 244 | dpfc_ctl = DPFC_CTL_PLANE(crtc->plane); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 245 | if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 246 | threshold++; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 247 | |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 248 | switch (threshold) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 249 | case 4: |
| 250 | case 3: |
| 251 | dpfc_ctl |= DPFC_CTL_LIMIT_4X; |
| 252 | break; |
| 253 | case 2: |
| 254 | dpfc_ctl |= DPFC_CTL_LIMIT_2X; |
| 255 | break; |
| 256 | case 1: |
| 257 | dpfc_ctl |= DPFC_CTL_LIMIT_1X; |
| 258 | break; |
| 259 | } |
| 260 | dpfc_ctl |= DPFC_CTL_FENCE_EN; |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 261 | if (IS_GEN5(dev_priv)) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 262 | dpfc_ctl |= obj->fence_reg; |
| 263 | |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 264 | y_offset = get_crtc_fence_y_offset(crtc); |
| 265 | I915_WRITE(ILK_DPFC_FENCE_YOFF, y_offset); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 266 | I915_WRITE(ILK_FBC_RT_BASE, i915_gem_obj_ggtt_offset(obj) | ILK_FBC_RT_VALID); |
| 267 | /* enable it... */ |
| 268 | I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); |
| 269 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 270 | if (IS_GEN6(dev_priv)) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 271 | I915_WRITE(SNB_DPFC_CTL_SA, |
| 272 | SNB_CPU_FENCE_ENABLE | obj->fence_reg); |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 273 | I915_WRITE(DPFC_CPU_FENCE_OFFSET, y_offset); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 274 | } |
| 275 | |
Paulo Zanoni | d5ce416 | 2015-11-04 17:10:45 -0200 | [diff] [blame] | 276 | intel_fbc_recompress(dev_priv); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 277 | } |
| 278 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 279 | static void ilk_fbc_deactivate(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 280 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 281 | u32 dpfc_ctl; |
| 282 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 283 | dev_priv->fbc.active = false; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 284 | |
| 285 | /* Disable compression */ |
| 286 | dpfc_ctl = I915_READ(ILK_DPFC_CONTROL); |
| 287 | if (dpfc_ctl & DPFC_CTL_EN) { |
| 288 | dpfc_ctl &= ~DPFC_CTL_EN; |
| 289 | I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 293 | static bool ilk_fbc_is_active(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 294 | { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 295 | return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN; |
| 296 | } |
| 297 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 298 | static void gen7_fbc_activate(struct intel_crtc *crtc) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 299 | { |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 300 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 301 | struct drm_framebuffer *fb = crtc->base.primary->fb; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 302 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 303 | u32 dpfc_ctl; |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 304 | int threshold = dev_priv->fbc.threshold; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 305 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 306 | dev_priv->fbc.active = true; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 307 | |
Paulo Zanoni | d8514d6 | 2015-06-12 14:36:21 -0300 | [diff] [blame] | 308 | dpfc_ctl = 0; |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 309 | if (IS_IVYBRIDGE(dev_priv)) |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 310 | dpfc_ctl |= IVB_DPFC_CTL_PLANE(crtc->plane); |
Paulo Zanoni | d8514d6 | 2015-06-12 14:36:21 -0300 | [diff] [blame] | 311 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 312 | if (drm_format_plane_cpp(fb->pixel_format, 0) == 2) |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 313 | threshold++; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 314 | |
Paulo Zanoni | ce65e47 | 2015-06-30 10:53:05 -0300 | [diff] [blame] | 315 | switch (threshold) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 316 | case 4: |
| 317 | case 3: |
| 318 | dpfc_ctl |= DPFC_CTL_LIMIT_4X; |
| 319 | break; |
| 320 | case 2: |
| 321 | dpfc_ctl |= DPFC_CTL_LIMIT_2X; |
| 322 | break; |
| 323 | case 1: |
| 324 | dpfc_ctl |= DPFC_CTL_LIMIT_1X; |
| 325 | break; |
| 326 | } |
| 327 | |
| 328 | dpfc_ctl |= IVB_DPFC_CTL_FENCE_EN; |
| 329 | |
| 330 | if (dev_priv->fbc.false_color) |
| 331 | dpfc_ctl |= FBC_CTL_FALSE_COLOR; |
| 332 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 333 | if (IS_IVYBRIDGE(dev_priv)) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 334 | /* WaFbcAsynchFlipDisableFbcQueue:ivb */ |
| 335 | I915_WRITE(ILK_DISPLAY_CHICKEN1, |
| 336 | I915_READ(ILK_DISPLAY_CHICKEN1) | |
| 337 | ILK_FBCQ_DIS); |
Paulo Zanoni | 40f4022 | 2015-09-14 15:20:01 -0300 | [diff] [blame] | 338 | } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 339 | /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */ |
Paulo Zanoni | 220285f | 2015-07-07 15:26:05 -0300 | [diff] [blame] | 340 | I915_WRITE(CHICKEN_PIPESL_1(crtc->pipe), |
| 341 | I915_READ(CHICKEN_PIPESL_1(crtc->pipe)) | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 342 | HSW_FBCQ_DIS); |
| 343 | } |
| 344 | |
Paulo Zanoni | 57012be9 | 2015-09-14 15:20:00 -0300 | [diff] [blame] | 345 | I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN); |
| 346 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 347 | I915_WRITE(SNB_DPFC_CTL_SA, |
| 348 | SNB_CPU_FENCE_ENABLE | obj->fence_reg); |
Paulo Zanoni | 2db3366 | 2015-09-14 15:20:03 -0300 | [diff] [blame] | 349 | I915_WRITE(DPFC_CPU_FENCE_OFFSET, get_crtc_fence_y_offset(crtc)); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 350 | |
Paulo Zanoni | d5ce416 | 2015-11-04 17:10:45 -0200 | [diff] [blame] | 351 | intel_fbc_recompress(dev_priv); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 352 | } |
| 353 | |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 354 | /** |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 355 | * intel_fbc_is_active - Is FBC active? |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 356 | * @dev_priv: i915 device instance |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 357 | * |
| 358 | * This function is used to verify the current state of FBC. |
| 359 | * FIXME: This should be tracked in the plane config eventually |
| 360 | * instead of queried at runtime for most callers. |
| 361 | */ |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 362 | bool intel_fbc_is_active(struct drm_i915_private *dev_priv) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 363 | { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 364 | return dev_priv->fbc.active; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 365 | } |
| 366 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 367 | static void intel_fbc_activate(const struct drm_framebuffer *fb) |
Paulo Zanoni | e8cb8d6 | 2015-09-14 15:19:55 -0300 | [diff] [blame] | 368 | { |
Paulo Zanoni | e9c5fd2 | 2015-10-13 18:04:45 -0300 | [diff] [blame] | 369 | struct drm_i915_private *dev_priv = fb->dev->dev_private; |
| 370 | struct intel_crtc *crtc = dev_priv->fbc.crtc; |
Paulo Zanoni | e8cb8d6 | 2015-09-14 15:19:55 -0300 | [diff] [blame] | 371 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 372 | dev_priv->fbc.activate(crtc); |
Paulo Zanoni | e8cb8d6 | 2015-09-14 15:19:55 -0300 | [diff] [blame] | 373 | |
Paulo Zanoni | e8cb8d6 | 2015-09-14 15:19:55 -0300 | [diff] [blame] | 374 | dev_priv->fbc.fb_id = fb->base.id; |
| 375 | dev_priv->fbc.y = crtc->base.y; |
| 376 | } |
| 377 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 378 | static void intel_fbc_work_fn(struct work_struct *__work) |
| 379 | { |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 380 | struct drm_i915_private *dev_priv = |
| 381 | container_of(__work, struct drm_i915_private, fbc.work.work); |
| 382 | struct intel_fbc_work *work = &dev_priv->fbc.work; |
| 383 | struct intel_crtc *crtc = dev_priv->fbc.crtc; |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 384 | struct drm_vblank_crtc *vblank = &dev_priv->dev->vblank[crtc->pipe]; |
| 385 | |
| 386 | if (drm_crtc_vblank_get(&crtc->base)) { |
| 387 | DRM_ERROR("vblank not available for FBC on pipe %c\n", |
| 388 | pipe_name(crtc->pipe)); |
| 389 | |
| 390 | mutex_lock(&dev_priv->fbc.lock); |
| 391 | work->scheduled = false; |
| 392 | mutex_unlock(&dev_priv->fbc.lock); |
| 393 | return; |
| 394 | } |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 395 | |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 396 | retry: |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 397 | /* Delay the actual enabling to let pageflipping cease and the |
| 398 | * display to settle before starting the compression. Note that |
| 399 | * this delay also serves a second purpose: it allows for a |
| 400 | * vblank to pass after disabling the FBC before we attempt |
| 401 | * to modify the control registers. |
| 402 | * |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 403 | * WaFbcWaitForVBlankBeforeEnable:ilk,snb |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 404 | * |
| 405 | * It is also worth mentioning that since work->scheduled_vblank can be |
| 406 | * updated multiple times by the other threads, hitting the timeout is |
| 407 | * not an error condition. We'll just end up hitting the "goto retry" |
| 408 | * case below. |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 409 | */ |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 410 | wait_event_timeout(vblank->queue, |
| 411 | drm_crtc_vblank_count(&crtc->base) != work->scheduled_vblank, |
| 412 | msecs_to_jiffies(50)); |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 413 | |
| 414 | mutex_lock(&dev_priv->fbc.lock); |
| 415 | |
| 416 | /* Were we cancelled? */ |
| 417 | if (!work->scheduled) |
| 418 | goto out; |
| 419 | |
| 420 | /* Were we delayed again while this function was sleeping? */ |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 421 | if (drm_crtc_vblank_count(&crtc->base) == work->scheduled_vblank) { |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 422 | mutex_unlock(&dev_priv->fbc.lock); |
| 423 | goto retry; |
| 424 | } |
| 425 | |
| 426 | if (crtc->base.primary->fb == work->fb) |
| 427 | intel_fbc_activate(work->fb); |
| 428 | |
| 429 | work->scheduled = false; |
| 430 | |
| 431 | out: |
| 432 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 433 | drm_crtc_vblank_put(&crtc->base); |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv) |
| 437 | { |
| 438 | WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); |
| 439 | dev_priv->fbc.work.scheduled = false; |
| 440 | } |
| 441 | |
| 442 | static void intel_fbc_schedule_activation(struct intel_crtc *crtc) |
| 443 | { |
| 444 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 445 | struct intel_fbc_work *work = &dev_priv->fbc.work; |
| 446 | |
| 447 | WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); |
| 448 | |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 449 | if (drm_crtc_vblank_get(&crtc->base)) { |
| 450 | DRM_ERROR("vblank not available for FBC on pipe %c\n", |
| 451 | pipe_name(crtc->pipe)); |
| 452 | return; |
| 453 | } |
| 454 | |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 455 | /* It is useless to call intel_fbc_cancel_work() in this function since |
| 456 | * we're not releasing fbc.lock, so it won't have an opportunity to grab |
| 457 | * it to discover that it was cancelled. So we just update the expected |
| 458 | * jiffy count. */ |
| 459 | work->fb = crtc->base.primary->fb; |
| 460 | work->scheduled = true; |
Paulo Zanoni | ca18d51 | 2016-01-21 18:03:05 -0200 | [diff] [blame^] | 461 | work->scheduled_vblank = drm_crtc_vblank_count(&crtc->base); |
| 462 | drm_crtc_vblank_put(&crtc->base); |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 463 | |
| 464 | schedule_work(&work->work); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 465 | } |
| 466 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 467 | static void __intel_fbc_deactivate(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 468 | { |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 469 | WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); |
| 470 | |
| 471 | intel_fbc_cancel_work(dev_priv); |
| 472 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 473 | if (dev_priv->fbc.active) |
| 474 | dev_priv->fbc.deactivate(dev_priv); |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 475 | } |
| 476 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 477 | /* |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 478 | * intel_fbc_deactivate - deactivate FBC if it's associated with crtc |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 479 | * @crtc: the CRTC |
| 480 | * |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 481 | * This function deactivates FBC if it's associated with the provided CRTC. |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 482 | */ |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 483 | void intel_fbc_deactivate(struct intel_crtc *crtc) |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 484 | { |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 485 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 486 | |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 487 | if (!fbc_supported(dev_priv)) |
Paulo Zanoni | 0bf73c3 | 2015-07-03 15:40:54 -0300 | [diff] [blame] | 488 | return; |
| 489 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 490 | mutex_lock(&dev_priv->fbc.lock); |
| 491 | if (dev_priv->fbc.crtc == crtc) |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 492 | __intel_fbc_deactivate(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 493 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 494 | } |
| 495 | |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 496 | static void set_no_fbc_reason(struct drm_i915_private *dev_priv, |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 497 | const char *reason) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 498 | { |
| 499 | if (dev_priv->fbc.no_fbc_reason == reason) |
Paulo Zanoni | 2e8144a | 2015-06-12 14:36:20 -0300 | [diff] [blame] | 500 | return; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 501 | |
| 502 | dev_priv->fbc.no_fbc_reason = reason; |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 503 | DRM_DEBUG_KMS("Disabling FBC: %s\n", reason); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 504 | } |
| 505 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 506 | static bool crtc_can_fbc(struct intel_crtc *crtc) |
Paulo Zanoni | 30c58d5 | 2015-11-04 17:10:48 -0200 | [diff] [blame] | 507 | { |
| 508 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 509 | |
| 510 | if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A) |
| 511 | return false; |
| 512 | |
Paulo Zanoni | e6cd6dc | 2015-10-16 17:55:40 -0300 | [diff] [blame] | 513 | if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A) |
| 514 | return false; |
| 515 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 516 | return true; |
| 517 | } |
| 518 | |
| 519 | static bool crtc_is_valid(struct intel_crtc *crtc) |
| 520 | { |
Paulo Zanoni | 30c58d5 | 2015-11-04 17:10:48 -0200 | [diff] [blame] | 521 | if (!intel_crtc_active(&crtc->base)) |
| 522 | return false; |
| 523 | |
| 524 | if (!to_intel_plane_state(crtc->base.primary->state)->visible) |
| 525 | return false; |
| 526 | |
| 527 | return true; |
| 528 | } |
| 529 | |
Paulo Zanoni | 232fd93 | 2015-07-07 15:26:07 -0300 | [diff] [blame] | 530 | static bool multiple_pipes_ok(struct drm_i915_private *dev_priv) |
| 531 | { |
| 532 | enum pipe pipe; |
| 533 | int n_pipes = 0; |
| 534 | struct drm_crtc *crtc; |
| 535 | |
| 536 | if (INTEL_INFO(dev_priv)->gen > 4) |
| 537 | return true; |
| 538 | |
| 539 | for_each_pipe(dev_priv, pipe) { |
| 540 | crtc = dev_priv->pipe_to_crtc_mapping[pipe]; |
| 541 | |
| 542 | if (intel_crtc_active(crtc) && |
| 543 | to_intel_plane_state(crtc->primary->state)->visible) |
| 544 | n_pipes++; |
| 545 | } |
| 546 | |
| 547 | return (n_pipes < 2); |
| 548 | } |
| 549 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 550 | static int find_compression_threshold(struct drm_i915_private *dev_priv, |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 551 | struct drm_mm_node *node, |
| 552 | int size, |
| 553 | int fb_cpp) |
| 554 | { |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 555 | int compression_threshold = 1; |
| 556 | int ret; |
Paulo Zanoni | a9da512 | 2015-09-14 15:19:57 -0300 | [diff] [blame] | 557 | u64 end; |
| 558 | |
| 559 | /* The FBC hardware for BDW/SKL doesn't have access to the stolen |
| 560 | * reserved range size, so it always assumes the maximum (8mb) is used. |
| 561 | * If we enable FBC using a CFB on that memory range we'll get FIFO |
| 562 | * underruns, even if that range is not reserved by the BIOS. */ |
Rodrigo Vivi | ef11bdb | 2015-10-28 04:16:45 -0700 | [diff] [blame] | 563 | if (IS_BROADWELL(dev_priv) || |
| 564 | IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) |
Paulo Zanoni | a9da512 | 2015-09-14 15:19:57 -0300 | [diff] [blame] | 565 | end = dev_priv->gtt.stolen_size - 8 * 1024 * 1024; |
| 566 | else |
| 567 | end = dev_priv->gtt.stolen_usable_size; |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 568 | |
| 569 | /* HACK: This code depends on what we will do in *_enable_fbc. If that |
| 570 | * code changes, this code needs to change as well. |
| 571 | * |
| 572 | * The enable_fbc code will attempt to use one of our 2 compression |
| 573 | * thresholds, therefore, in that case, we only have 1 resort. |
| 574 | */ |
| 575 | |
| 576 | /* Try to over-allocate to reduce reallocations and fragmentation. */ |
Paulo Zanoni | a9da512 | 2015-09-14 15:19:57 -0300 | [diff] [blame] | 577 | ret = i915_gem_stolen_insert_node_in_range(dev_priv, node, size <<= 1, |
| 578 | 4096, 0, end); |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 579 | if (ret == 0) |
| 580 | return compression_threshold; |
| 581 | |
| 582 | again: |
| 583 | /* HW's ability to limit the CFB is 1:4 */ |
| 584 | if (compression_threshold > 4 || |
| 585 | (fb_cpp == 2 && compression_threshold == 2)) |
| 586 | return 0; |
| 587 | |
Paulo Zanoni | a9da512 | 2015-09-14 15:19:57 -0300 | [diff] [blame] | 588 | ret = i915_gem_stolen_insert_node_in_range(dev_priv, node, size >>= 1, |
| 589 | 4096, 0, end); |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 590 | if (ret && INTEL_INFO(dev_priv)->gen <= 4) { |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 591 | return 0; |
| 592 | } else if (ret) { |
| 593 | compression_threshold <<= 1; |
| 594 | goto again; |
| 595 | } else { |
| 596 | return compression_threshold; |
| 597 | } |
| 598 | } |
| 599 | |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 600 | static int intel_fbc_alloc_cfb(struct intel_crtc *crtc) |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 601 | { |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 602 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 603 | struct drm_framebuffer *fb = crtc->base.primary->state->fb; |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 604 | struct drm_mm_node *uninitialized_var(compressed_llb); |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 605 | int size, fb_cpp, ret; |
| 606 | |
| 607 | WARN_ON(drm_mm_node_allocated(&dev_priv->fbc.compressed_fb)); |
| 608 | |
| 609 | size = intel_fbc_calculate_cfb_size(crtc, fb); |
| 610 | fb_cpp = drm_format_plane_cpp(fb->pixel_format, 0); |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 611 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 612 | ret = find_compression_threshold(dev_priv, &dev_priv->fbc.compressed_fb, |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 613 | size, fb_cpp); |
| 614 | if (!ret) |
| 615 | goto err_llb; |
| 616 | else if (ret > 1) { |
| 617 | DRM_INFO("Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.\n"); |
| 618 | |
| 619 | } |
| 620 | |
| 621 | dev_priv->fbc.threshold = ret; |
| 622 | |
| 623 | if (INTEL_INFO(dev_priv)->gen >= 5) |
| 624 | I915_WRITE(ILK_DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start); |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 625 | else if (IS_GM45(dev_priv)) { |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 626 | I915_WRITE(DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start); |
| 627 | } else { |
| 628 | compressed_llb = kzalloc(sizeof(*compressed_llb), GFP_KERNEL); |
| 629 | if (!compressed_llb) |
| 630 | goto err_fb; |
| 631 | |
| 632 | ret = i915_gem_stolen_insert_node(dev_priv, compressed_llb, |
| 633 | 4096, 4096); |
| 634 | if (ret) |
| 635 | goto err_fb; |
| 636 | |
| 637 | dev_priv->fbc.compressed_llb = compressed_llb; |
| 638 | |
| 639 | I915_WRITE(FBC_CFB_BASE, |
| 640 | dev_priv->mm.stolen_base + dev_priv->fbc.compressed_fb.start); |
| 641 | I915_WRITE(FBC_LL_BASE, |
| 642 | dev_priv->mm.stolen_base + compressed_llb->start); |
| 643 | } |
| 644 | |
Paulo Zanoni | b8bf5d7 | 2015-09-14 15:19:58 -0300 | [diff] [blame] | 645 | DRM_DEBUG_KMS("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n", |
| 646 | dev_priv->fbc.compressed_fb.size, |
| 647 | dev_priv->fbc.threshold); |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 648 | |
| 649 | return 0; |
| 650 | |
| 651 | err_fb: |
| 652 | kfree(compressed_llb); |
| 653 | i915_gem_stolen_remove_node(dev_priv, &dev_priv->fbc.compressed_fb); |
| 654 | err_llb: |
| 655 | pr_info_once("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size); |
| 656 | return -ENOSPC; |
| 657 | } |
| 658 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 659 | static void __intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv) |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 660 | { |
Paulo Zanoni | 559d913 | 2015-10-26 18:44:25 -0200 | [diff] [blame] | 661 | if (drm_mm_node_allocated(&dev_priv->fbc.compressed_fb)) |
| 662 | i915_gem_stolen_remove_node(dev_priv, |
| 663 | &dev_priv->fbc.compressed_fb); |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 664 | |
| 665 | if (dev_priv->fbc.compressed_llb) { |
| 666 | i915_gem_stolen_remove_node(dev_priv, |
| 667 | dev_priv->fbc.compressed_llb); |
| 668 | kfree(dev_priv->fbc.compressed_llb); |
| 669 | } |
Paulo Zanoni | fc78672 | 2015-07-02 19:25:08 -0300 | [diff] [blame] | 670 | } |
| 671 | |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 672 | void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv) |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 673 | { |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 674 | if (!fbc_supported(dev_priv)) |
Paulo Zanoni | 0bf73c3 | 2015-07-03 15:40:54 -0300 | [diff] [blame] | 675 | return; |
| 676 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 677 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 678 | __intel_fbc_cleanup_cfb(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 679 | mutex_unlock(&dev_priv->fbc.lock); |
| 680 | } |
| 681 | |
Paulo Zanoni | adf70c6 | 2015-09-14 15:19:56 -0300 | [diff] [blame] | 682 | static bool stride_is_valid(struct drm_i915_private *dev_priv, |
| 683 | unsigned int stride) |
| 684 | { |
| 685 | /* These should have been caught earlier. */ |
| 686 | WARN_ON(stride < 512); |
| 687 | WARN_ON((stride & (64 - 1)) != 0); |
| 688 | |
| 689 | /* Below are the additional FBC restrictions. */ |
| 690 | |
| 691 | if (IS_GEN2(dev_priv) || IS_GEN3(dev_priv)) |
| 692 | return stride == 4096 || stride == 8192; |
| 693 | |
| 694 | if (IS_GEN4(dev_priv) && !IS_G4X(dev_priv) && stride < 2048) |
| 695 | return false; |
| 696 | |
| 697 | if (stride > 16384) |
| 698 | return false; |
| 699 | |
| 700 | return true; |
| 701 | } |
| 702 | |
Paulo Zanoni | b9e831d | 2015-09-21 19:48:06 -0300 | [diff] [blame] | 703 | static bool pixel_format_is_valid(struct drm_framebuffer *fb) |
| 704 | { |
| 705 | struct drm_device *dev = fb->dev; |
| 706 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 707 | |
| 708 | switch (fb->pixel_format) { |
| 709 | case DRM_FORMAT_XRGB8888: |
| 710 | case DRM_FORMAT_XBGR8888: |
| 711 | return true; |
| 712 | case DRM_FORMAT_XRGB1555: |
| 713 | case DRM_FORMAT_RGB565: |
| 714 | /* 16bpp not supported on gen2 */ |
| 715 | if (IS_GEN2(dev)) |
| 716 | return false; |
| 717 | /* WaFbcOnly1to1Ratio:ctg */ |
| 718 | if (IS_G4X(dev_priv)) |
| 719 | return false; |
| 720 | return true; |
| 721 | default: |
| 722 | return false; |
| 723 | } |
| 724 | } |
| 725 | |
Paulo Zanoni | 856312a | 2015-10-01 19:57:12 -0300 | [diff] [blame] | 726 | /* |
| 727 | * For some reason, the hardware tracking starts looking at whatever we |
| 728 | * programmed as the display plane base address register. It does not look at |
| 729 | * the X and Y offset registers. That's why we look at the crtc->adjusted{x,y} |
| 730 | * variables instead of just looking at the pipe/plane size. |
| 731 | */ |
| 732 | static bool intel_fbc_hw_tracking_covers_screen(struct intel_crtc *crtc) |
Paulo Zanoni | 3c5f174 | 2015-09-23 12:52:24 -0300 | [diff] [blame] | 733 | { |
| 734 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
Paulo Zanoni | 856312a | 2015-10-01 19:57:12 -0300 | [diff] [blame] | 735 | unsigned int effective_w, effective_h, max_w, max_h; |
Paulo Zanoni | 3c5f174 | 2015-09-23 12:52:24 -0300 | [diff] [blame] | 736 | |
| 737 | if (INTEL_INFO(dev_priv)->gen >= 8 || IS_HASWELL(dev_priv)) { |
| 738 | max_w = 4096; |
| 739 | max_h = 4096; |
| 740 | } else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) { |
| 741 | max_w = 4096; |
| 742 | max_h = 2048; |
| 743 | } else { |
| 744 | max_w = 2048; |
| 745 | max_h = 1536; |
| 746 | } |
| 747 | |
Paulo Zanoni | 856312a | 2015-10-01 19:57:12 -0300 | [diff] [blame] | 748 | intel_fbc_get_plane_source_size(crtc, &effective_w, &effective_h); |
| 749 | effective_w += crtc->adjusted_x; |
| 750 | effective_h += crtc->adjusted_y; |
| 751 | |
| 752 | return effective_w <= max_w && effective_h <= max_h; |
Paulo Zanoni | 3c5f174 | 2015-09-23 12:52:24 -0300 | [diff] [blame] | 753 | } |
| 754 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 755 | /** |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 756 | * __intel_fbc_update - activate/deactivate FBC as needed, unlocked |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 757 | * @crtc: the CRTC that triggered the update |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 758 | * |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 759 | * This function completely reevaluates the status of FBC, then activates, |
| 760 | * deactivates or maintains it on the same state. |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 761 | */ |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 762 | static void __intel_fbc_update(struct intel_crtc *crtc) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 763 | { |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 764 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 765 | struct drm_framebuffer *fb; |
| 766 | struct drm_i915_gem_object *obj; |
| 767 | const struct drm_display_mode *adjusted_mode; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 768 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 769 | WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); |
| 770 | |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 771 | if (!multiple_pipes_ok(dev_priv)) { |
| 772 | set_no_fbc_reason(dev_priv, "more than one pipe active"); |
| 773 | goto out_disable; |
| 774 | } |
| 775 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 776 | if (!dev_priv->fbc.enabled || dev_priv->fbc.crtc != crtc) |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 777 | return; |
| 778 | |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 779 | if (!crtc_is_valid(crtc)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 780 | set_no_fbc_reason(dev_priv, "no output"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 781 | goto out_disable; |
Paulo Zanoni | 8df5dd5 | 2015-07-07 15:26:08 -0300 | [diff] [blame] | 782 | } |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 783 | |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 784 | fb = crtc->base.primary->fb; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 785 | obj = intel_fb_obj(fb); |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 786 | adjusted_mode = &crtc->config->base.adjusted_mode; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 787 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 788 | if ((adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) || |
| 789 | (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 790 | set_no_fbc_reason(dev_priv, "incompatible mode"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 791 | goto out_disable; |
| 792 | } |
| 793 | |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 794 | if (!intel_fbc_hw_tracking_covers_screen(crtc)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 795 | set_no_fbc_reason(dev_priv, "mode too large for compression"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 796 | goto out_disable; |
| 797 | } |
Paulo Zanoni | 3c5f174 | 2015-09-23 12:52:24 -0300 | [diff] [blame] | 798 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 799 | /* The use of a CPU fence is mandatory in order to detect writes |
| 800 | * by the CPU to the scanout and trigger updates to the FBC. |
| 801 | */ |
| 802 | if (obj->tiling_mode != I915_TILING_X || |
| 803 | obj->fence_reg == I915_FENCE_REG_NONE) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 804 | set_no_fbc_reason(dev_priv, "framebuffer not tiled or fenced"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 805 | goto out_disable; |
| 806 | } |
Paulo Zanoni | 7733b49 | 2015-07-07 15:26:04 -0300 | [diff] [blame] | 807 | if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_G4X(dev_priv) && |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 808 | crtc->base.primary->state->rotation != BIT(DRM_ROTATE_0)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 809 | set_no_fbc_reason(dev_priv, "rotation unsupported"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 810 | goto out_disable; |
| 811 | } |
| 812 | |
Paulo Zanoni | adf70c6 | 2015-09-14 15:19:56 -0300 | [diff] [blame] | 813 | if (!stride_is_valid(dev_priv, fb->pitches[0])) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 814 | set_no_fbc_reason(dev_priv, "framebuffer stride not supported"); |
Paulo Zanoni | adf70c6 | 2015-09-14 15:19:56 -0300 | [diff] [blame] | 815 | goto out_disable; |
| 816 | } |
| 817 | |
Paulo Zanoni | b9e831d | 2015-09-21 19:48:06 -0300 | [diff] [blame] | 818 | if (!pixel_format_is_valid(fb)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 819 | set_no_fbc_reason(dev_priv, "pixel format is invalid"); |
Paulo Zanoni | b9e831d | 2015-09-21 19:48:06 -0300 | [diff] [blame] | 820 | goto out_disable; |
| 821 | } |
| 822 | |
Paulo Zanoni | 7b24c9a | 2015-09-14 15:19:59 -0300 | [diff] [blame] | 823 | /* WaFbcExceedCdClockThreshold:hsw,bdw */ |
| 824 | if ((IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) && |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 825 | ilk_pipe_pixel_rate(crtc->config) >= |
Paulo Zanoni | 7b24c9a | 2015-09-14 15:19:59 -0300 | [diff] [blame] | 826 | dev_priv->cdclk_freq * 95 / 100) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 827 | set_no_fbc_reason(dev_priv, "pixel rate is too big"); |
Paulo Zanoni | 7b24c9a | 2015-09-14 15:19:59 -0300 | [diff] [blame] | 828 | goto out_disable; |
| 829 | } |
| 830 | |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 831 | /* It is possible for the required CFB size change without a |
| 832 | * crtc->disable + crtc->enable since it is possible to change the |
| 833 | * stride without triggering a full modeset. Since we try to |
| 834 | * over-allocate the CFB, there's a chance we may keep FBC enabled even |
| 835 | * if this happens, but if we exceed the current CFB size we'll have to |
| 836 | * disable FBC. Notice that it would be possible to disable FBC, wait |
| 837 | * for a frame, free the stolen node, then try to reenable FBC in case |
| 838 | * we didn't get any invalidate/deactivate calls, but this would require |
| 839 | * a lot of tracking just for a specific case. If we conclude it's an |
| 840 | * important case, we can implement it later. */ |
| 841 | if (intel_fbc_calculate_cfb_size(crtc, fb) > |
| 842 | dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) { |
| 843 | set_no_fbc_reason(dev_priv, "CFB requirements changed"); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 844 | goto out_disable; |
| 845 | } |
| 846 | |
| 847 | /* If the scanout has not changed, don't modify the FBC settings. |
| 848 | * Note that we make the fundamental assumption that the fb->obj |
| 849 | * cannot be unpinned (and have its GTT offset and fence revoked) |
| 850 | * without first being decoupled from the scanout and FBC disabled. |
| 851 | */ |
Paulo Zanoni | 45b32a2 | 2015-11-04 17:10:49 -0200 | [diff] [blame] | 852 | if (dev_priv->fbc.crtc == crtc && |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 853 | dev_priv->fbc.fb_id == fb->base.id && |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 854 | dev_priv->fbc.y == crtc->base.y && |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 855 | dev_priv->fbc.active) |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 856 | return; |
| 857 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 858 | if (intel_fbc_is_active(dev_priv)) { |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 859 | /* We update FBC along two paths, after changing fb/crtc |
| 860 | * configuration (modeswitching) and after page-flipping |
| 861 | * finishes. For the latter, we know that not only did |
| 862 | * we disable the FBC at the start of the page-flip |
| 863 | * sequence, but also more than one vblank has passed. |
| 864 | * |
| 865 | * For the former case of modeswitching, it is possible |
| 866 | * to switch between two FBC valid configurations |
| 867 | * instantaneously so we do need to disable the FBC |
| 868 | * before we can modify its control registers. We also |
| 869 | * have to wait for the next vblank for that to take |
| 870 | * effect. However, since we delay enabling FBC we can |
| 871 | * assume that a vblank has passed since disabling and |
| 872 | * that we can safely alter the registers in the deferred |
| 873 | * callback. |
| 874 | * |
| 875 | * In the scenario that we go from a valid to invalid |
| 876 | * and then back to valid FBC configuration we have |
| 877 | * no strict enforcement that a vblank occurred since |
| 878 | * disabling the FBC. However, along all current pipe |
| 879 | * disabling paths we do need to wait for a vblank at |
| 880 | * some point. And we wait before enabling FBC anyway. |
| 881 | */ |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 882 | DRM_DEBUG_KMS("deactivating FBC for update\n"); |
| 883 | __intel_fbc_deactivate(dev_priv); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 884 | } |
| 885 | |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 886 | intel_fbc_schedule_activation(crtc); |
Paulo Zanoni | 793af07 | 2015-11-04 17:10:57 -0200 | [diff] [blame] | 887 | dev_priv->fbc.no_fbc_reason = "FBC enabled (not necessarily active)"; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 888 | return; |
| 889 | |
| 890 | out_disable: |
| 891 | /* Multiple disables should be harmless */ |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 892 | if (intel_fbc_is_active(dev_priv)) { |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 893 | DRM_DEBUG_KMS("unsupported config, deactivating FBC\n"); |
| 894 | __intel_fbc_deactivate(dev_priv); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 895 | } |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | /* |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 899 | * intel_fbc_update - activate/deactivate FBC as needed |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 900 | * @crtc: the CRTC that triggered the update |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 901 | * |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 902 | * This function reevaluates the overall state and activates or deactivates FBC. |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 903 | */ |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 904 | void intel_fbc_update(struct intel_crtc *crtc) |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 905 | { |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 906 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 907 | |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 908 | if (!fbc_supported(dev_priv)) |
Paulo Zanoni | 0bf73c3 | 2015-07-03 15:40:54 -0300 | [diff] [blame] | 909 | return; |
| 910 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 911 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | 754d113 | 2015-10-13 19:13:25 -0300 | [diff] [blame] | 912 | __intel_fbc_update(crtc); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 913 | mutex_unlock(&dev_priv->fbc.lock); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 914 | } |
| 915 | |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 916 | void intel_fbc_invalidate(struct drm_i915_private *dev_priv, |
| 917 | unsigned int frontbuffer_bits, |
| 918 | enum fb_op_origin origin) |
| 919 | { |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 920 | unsigned int fbc_bits; |
| 921 | |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 922 | if (!fbc_supported(dev_priv)) |
Paulo Zanoni | 0bf73c3 | 2015-07-03 15:40:54 -0300 | [diff] [blame] | 923 | return; |
| 924 | |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 925 | if (origin == ORIGIN_GTT) |
| 926 | return; |
| 927 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 928 | mutex_lock(&dev_priv->fbc.lock); |
| 929 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 930 | if (dev_priv->fbc.enabled) |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 931 | fbc_bits = INTEL_FRONTBUFFER_PRIMARY(dev_priv->fbc.crtc->pipe); |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 932 | else |
| 933 | fbc_bits = dev_priv->fbc.possible_framebuffer_bits; |
| 934 | |
| 935 | dev_priv->fbc.busy_bits |= (fbc_bits & frontbuffer_bits); |
| 936 | |
| 937 | if (dev_priv->fbc.busy_bits) |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 938 | __intel_fbc_deactivate(dev_priv); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 939 | |
| 940 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | void intel_fbc_flush(struct drm_i915_private *dev_priv, |
Paulo Zanoni | 6f4551f | 2015-07-14 16:29:10 -0300 | [diff] [blame] | 944 | unsigned int frontbuffer_bits, enum fb_op_origin origin) |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 945 | { |
Paulo Zanoni | 9f21833 | 2015-09-23 12:52:27 -0300 | [diff] [blame] | 946 | if (!fbc_supported(dev_priv)) |
Paulo Zanoni | 0bf73c3 | 2015-07-03 15:40:54 -0300 | [diff] [blame] | 947 | return; |
| 948 | |
Paulo Zanoni | 6f4551f | 2015-07-14 16:29:10 -0300 | [diff] [blame] | 949 | if (origin == ORIGIN_GTT) |
| 950 | return; |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 951 | |
Paulo Zanoni | 6f4551f | 2015-07-14 16:29:10 -0300 | [diff] [blame] | 952 | mutex_lock(&dev_priv->fbc.lock); |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 953 | |
| 954 | dev_priv->fbc.busy_bits &= ~frontbuffer_bits; |
| 955 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 956 | if (!dev_priv->fbc.busy_bits && dev_priv->fbc.enabled) { |
Paulo Zanoni | ee7d6cf | 2015-11-11 14:46:22 -0200 | [diff] [blame] | 957 | if (origin != ORIGIN_FLIP && dev_priv->fbc.active) { |
| 958 | intel_fbc_recompress(dev_priv); |
| 959 | } else { |
| 960 | __intel_fbc_deactivate(dev_priv); |
| 961 | __intel_fbc_update(dev_priv->fbc.crtc); |
| 962 | } |
Paulo Zanoni | 6f4551f | 2015-07-14 16:29:10 -0300 | [diff] [blame] | 963 | } |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 964 | |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 965 | mutex_unlock(&dev_priv->fbc.lock); |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 966 | } |
| 967 | |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 968 | /** |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 969 | * intel_fbc_enable: tries to enable FBC on the CRTC |
| 970 | * @crtc: the CRTC |
| 971 | * |
| 972 | * This function checks if it's possible to enable FBC on the following CRTC, |
| 973 | * then enables it. Notice that it doesn't activate FBC. |
| 974 | */ |
| 975 | void intel_fbc_enable(struct intel_crtc *crtc) |
| 976 | { |
| 977 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 978 | |
| 979 | if (!fbc_supported(dev_priv)) |
| 980 | return; |
| 981 | |
| 982 | mutex_lock(&dev_priv->fbc.lock); |
| 983 | |
| 984 | if (dev_priv->fbc.enabled) { |
| 985 | WARN_ON(dev_priv->fbc.crtc == crtc); |
| 986 | goto out; |
| 987 | } |
| 988 | |
| 989 | WARN_ON(dev_priv->fbc.active); |
| 990 | WARN_ON(dev_priv->fbc.crtc != NULL); |
| 991 | |
| 992 | if (intel_vgpu_active(dev_priv->dev)) { |
| 993 | set_no_fbc_reason(dev_priv, "VGPU is active"); |
| 994 | goto out; |
| 995 | } |
| 996 | |
| 997 | if (i915.enable_fbc < 0) { |
| 998 | set_no_fbc_reason(dev_priv, "disabled per chip default"); |
| 999 | goto out; |
| 1000 | } |
| 1001 | |
| 1002 | if (!i915.enable_fbc) { |
| 1003 | set_no_fbc_reason(dev_priv, "disabled per module param"); |
| 1004 | goto out; |
| 1005 | } |
| 1006 | |
| 1007 | if (!crtc_can_fbc(crtc)) { |
| 1008 | set_no_fbc_reason(dev_priv, "no enabled pipes can have FBC"); |
| 1009 | goto out; |
| 1010 | } |
| 1011 | |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 1012 | if (intel_fbc_alloc_cfb(crtc)) { |
| 1013 | set_no_fbc_reason(dev_priv, "not enough stolen memory"); |
| 1014 | goto out; |
| 1015 | } |
| 1016 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 1017 | DRM_DEBUG_KMS("Enabling FBC on pipe %c\n", pipe_name(crtc->pipe)); |
| 1018 | dev_priv->fbc.no_fbc_reason = "FBC enabled but not active yet\n"; |
| 1019 | |
| 1020 | dev_priv->fbc.enabled = true; |
| 1021 | dev_priv->fbc.crtc = crtc; |
| 1022 | out: |
| 1023 | mutex_unlock(&dev_priv->fbc.lock); |
| 1024 | } |
| 1025 | |
| 1026 | /** |
| 1027 | * __intel_fbc_disable - disable FBC |
| 1028 | * @dev_priv: i915 device instance |
| 1029 | * |
| 1030 | * This is the low level function that actually disables FBC. Callers should |
| 1031 | * grab the FBC lock. |
| 1032 | */ |
| 1033 | static void __intel_fbc_disable(struct drm_i915_private *dev_priv) |
| 1034 | { |
| 1035 | struct intel_crtc *crtc = dev_priv->fbc.crtc; |
| 1036 | |
| 1037 | WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock)); |
| 1038 | WARN_ON(!dev_priv->fbc.enabled); |
| 1039 | WARN_ON(dev_priv->fbc.active); |
| 1040 | assert_pipe_disabled(dev_priv, crtc->pipe); |
| 1041 | |
| 1042 | DRM_DEBUG_KMS("Disabling FBC on pipe %c\n", pipe_name(crtc->pipe)); |
| 1043 | |
Paulo Zanoni | c5ecd46 | 2015-10-15 14:19:21 -0300 | [diff] [blame] | 1044 | __intel_fbc_cleanup_cfb(dev_priv); |
| 1045 | |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 1046 | dev_priv->fbc.enabled = false; |
| 1047 | dev_priv->fbc.crtc = NULL; |
| 1048 | } |
| 1049 | |
| 1050 | /** |
| 1051 | * intel_fbc_disable_crtc - disable FBC if it's associated with crtc |
| 1052 | * @crtc: the CRTC |
| 1053 | * |
| 1054 | * This function disables FBC if it's associated with the provided CRTC. |
| 1055 | */ |
| 1056 | void intel_fbc_disable_crtc(struct intel_crtc *crtc) |
| 1057 | { |
| 1058 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 1059 | |
| 1060 | if (!fbc_supported(dev_priv)) |
| 1061 | return; |
| 1062 | |
| 1063 | mutex_lock(&dev_priv->fbc.lock); |
| 1064 | if (dev_priv->fbc.crtc == crtc) { |
| 1065 | WARN_ON(!dev_priv->fbc.enabled); |
| 1066 | WARN_ON(dev_priv->fbc.active); |
| 1067 | __intel_fbc_disable(dev_priv); |
| 1068 | } |
| 1069 | mutex_unlock(&dev_priv->fbc.lock); |
| 1070 | } |
| 1071 | |
| 1072 | /** |
| 1073 | * intel_fbc_disable - globally disable FBC |
| 1074 | * @dev_priv: i915 device instance |
| 1075 | * |
| 1076 | * This function disables FBC regardless of which CRTC is associated with it. |
| 1077 | */ |
| 1078 | void intel_fbc_disable(struct drm_i915_private *dev_priv) |
| 1079 | { |
| 1080 | if (!fbc_supported(dev_priv)) |
| 1081 | return; |
| 1082 | |
| 1083 | mutex_lock(&dev_priv->fbc.lock); |
| 1084 | if (dev_priv->fbc.enabled) |
| 1085 | __intel_fbc_disable(dev_priv); |
| 1086 | mutex_unlock(&dev_priv->fbc.lock); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
Rodrigo Vivi | 94b8395 | 2014-12-08 06:46:31 -0800 | [diff] [blame] | 1090 | * intel_fbc_init - Initialize FBC |
| 1091 | * @dev_priv: the i915 device |
| 1092 | * |
| 1093 | * This function might be called during PM init process. |
| 1094 | */ |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1095 | void intel_fbc_init(struct drm_i915_private *dev_priv) |
| 1096 | { |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 1097 | enum pipe pipe; |
| 1098 | |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 1099 | INIT_WORK(&dev_priv->fbc.work.work, intel_fbc_work_fn); |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1100 | mutex_init(&dev_priv->fbc.lock); |
Paulo Zanoni | d029bca | 2015-10-15 10:44:46 -0300 | [diff] [blame] | 1101 | dev_priv->fbc.enabled = false; |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1102 | dev_priv->fbc.active = false; |
Paulo Zanoni | 128d735 | 2015-10-26 16:27:49 -0200 | [diff] [blame] | 1103 | dev_priv->fbc.work.scheduled = false; |
Paulo Zanoni | 25ad93f | 2015-07-02 19:25:10 -0300 | [diff] [blame] | 1104 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1105 | if (!HAS_FBC(dev_priv)) { |
Paulo Zanoni | bf6189c | 2015-10-27 14:50:03 -0200 | [diff] [blame] | 1106 | dev_priv->fbc.no_fbc_reason = "unsupported by this chipset"; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1107 | return; |
| 1108 | } |
| 1109 | |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 1110 | for_each_pipe(dev_priv, pipe) { |
| 1111 | dev_priv->fbc.possible_framebuffer_bits |= |
| 1112 | INTEL_FRONTBUFFER_PRIMARY(pipe); |
| 1113 | |
Paulo Zanoni | 5710502 | 2015-11-04 17:10:46 -0200 | [diff] [blame] | 1114 | if (fbc_on_pipe_a_only(dev_priv)) |
Paulo Zanoni | dbef0f1 | 2015-02-13 17:23:46 -0200 | [diff] [blame] | 1115 | break; |
| 1116 | } |
| 1117 | |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1118 | if (INTEL_INFO(dev_priv)->gen >= 7) { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1119 | dev_priv->fbc.is_active = ilk_fbc_is_active; |
| 1120 | dev_priv->fbc.activate = gen7_fbc_activate; |
| 1121 | dev_priv->fbc.deactivate = ilk_fbc_deactivate; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1122 | } else if (INTEL_INFO(dev_priv)->gen >= 5) { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1123 | dev_priv->fbc.is_active = ilk_fbc_is_active; |
| 1124 | dev_priv->fbc.activate = ilk_fbc_activate; |
| 1125 | dev_priv->fbc.deactivate = ilk_fbc_deactivate; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1126 | } else if (IS_GM45(dev_priv)) { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1127 | dev_priv->fbc.is_active = g4x_fbc_is_active; |
| 1128 | dev_priv->fbc.activate = g4x_fbc_activate; |
| 1129 | dev_priv->fbc.deactivate = g4x_fbc_deactivate; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1130 | } else { |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1131 | dev_priv->fbc.is_active = i8xx_fbc_is_active; |
| 1132 | dev_priv->fbc.activate = i8xx_fbc_activate; |
| 1133 | dev_priv->fbc.deactivate = i8xx_fbc_deactivate; |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1134 | |
| 1135 | /* This value was pulled out of someone's hat */ |
| 1136 | I915_WRITE(FBC_CONTROL, 500 << FBC_CTL_INTERVAL_SHIFT); |
| 1137 | } |
| 1138 | |
Paulo Zanoni | b07ea0f | 2015-11-04 17:10:52 -0200 | [diff] [blame] | 1139 | /* We still don't have any sort of hardware state readout for FBC, so |
Paulo Zanoni | 0e631ad | 2015-10-14 17:45:36 -0300 | [diff] [blame] | 1140 | * deactivate it in case the BIOS activated it to make sure software |
| 1141 | * matches the hardware state. */ |
| 1142 | if (dev_priv->fbc.is_active(dev_priv)) |
| 1143 | dev_priv->fbc.deactivate(dev_priv); |
Rodrigo Vivi | 7ff0ebc | 2014-12-08 14:09:10 -0200 | [diff] [blame] | 1144 | } |