Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2011 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 FROM, |
| 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | * SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Jesse Barnes <jbarnes@virtuousgeek.org> |
| 25 | * |
| 26 | * New plane/sprite handling. |
| 27 | * |
| 28 | * The older chips had a separate interface for programming plane related |
| 29 | * registers; newer ones are much simpler and we can use the new DRM plane |
| 30 | * support. |
| 31 | */ |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 32 | #include <drm/drmP.h> |
| 33 | #include <drm/drm_crtc.h> |
| 34 | #include <drm/drm_fourcc.h> |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 35 | #include <drm/drm_rect.h> |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 36 | #include "intel_drv.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 37 | #include <drm/i915_drm.h> |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 38 | #include "i915_drv.h" |
| 39 | |
| 40 | static void |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 41 | vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb, |
| 42 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 43 | unsigned int crtc_w, unsigned int crtc_h, |
| 44 | uint32_t x, uint32_t y, |
| 45 | uint32_t src_w, uint32_t src_h) |
| 46 | { |
| 47 | struct drm_device *dev = dplane->dev; |
| 48 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 49 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 50 | int pipe = intel_plane->pipe; |
| 51 | int plane = intel_plane->plane; |
| 52 | u32 sprctl; |
| 53 | unsigned long sprsurf_offset, linear_offset; |
| 54 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
| 55 | |
| 56 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 57 | |
| 58 | /* Mask out pixel format bits in case we change it */ |
| 59 | sprctl &= ~SP_PIXFORMAT_MASK; |
| 60 | sprctl &= ~SP_YUV_BYTE_ORDER_MASK; |
| 61 | sprctl &= ~SP_TILED; |
| 62 | |
| 63 | switch (fb->pixel_format) { |
| 64 | case DRM_FORMAT_YUYV: |
| 65 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV; |
| 66 | break; |
| 67 | case DRM_FORMAT_YVYU: |
| 68 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YVYU; |
| 69 | break; |
| 70 | case DRM_FORMAT_UYVY: |
| 71 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_UYVY; |
| 72 | break; |
| 73 | case DRM_FORMAT_VYUY: |
| 74 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_VYUY; |
| 75 | break; |
| 76 | case DRM_FORMAT_RGB565: |
| 77 | sprctl |= SP_FORMAT_BGR565; |
| 78 | break; |
| 79 | case DRM_FORMAT_XRGB8888: |
| 80 | sprctl |= SP_FORMAT_BGRX8888; |
| 81 | break; |
| 82 | case DRM_FORMAT_ARGB8888: |
| 83 | sprctl |= SP_FORMAT_BGRA8888; |
| 84 | break; |
| 85 | case DRM_FORMAT_XBGR2101010: |
| 86 | sprctl |= SP_FORMAT_RGBX1010102; |
| 87 | break; |
| 88 | case DRM_FORMAT_ABGR2101010: |
| 89 | sprctl |= SP_FORMAT_RGBA1010102; |
| 90 | break; |
| 91 | case DRM_FORMAT_XBGR8888: |
| 92 | sprctl |= SP_FORMAT_RGBX8888; |
| 93 | break; |
| 94 | case DRM_FORMAT_ABGR8888: |
| 95 | sprctl |= SP_FORMAT_RGBA8888; |
| 96 | break; |
| 97 | default: |
| 98 | /* |
| 99 | * If we get here one of the upper layers failed to filter |
| 100 | * out the unsupported plane formats |
| 101 | */ |
| 102 | BUG(); |
| 103 | break; |
| 104 | } |
| 105 | |
| 106 | if (obj->tiling_mode != I915_TILING_NONE) |
| 107 | sprctl |= SP_TILED; |
| 108 | |
| 109 | sprctl |= SP_ENABLE; |
| 110 | |
| 111 | /* Sizes are 0 based */ |
| 112 | src_w--; |
| 113 | src_h--; |
| 114 | crtc_w--; |
| 115 | crtc_h--; |
| 116 | |
| 117 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
| 118 | |
| 119 | I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); |
| 120 | I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); |
| 121 | |
| 122 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
| 123 | sprsurf_offset = intel_gen4_compute_page_offset(&x, &y, |
| 124 | obj->tiling_mode, |
| 125 | pixel_size, |
| 126 | fb->pitches[0]); |
| 127 | linear_offset -= sprsurf_offset; |
| 128 | |
| 129 | if (obj->tiling_mode != I915_TILING_NONE) |
| 130 | I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x); |
| 131 | else |
| 132 | I915_WRITE(SPLINOFF(pipe, plane), linear_offset); |
| 133 | |
| 134 | I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w); |
| 135 | I915_WRITE(SPCNTR(pipe, plane), sprctl); |
| 136 | I915_MODIFY_DISPBASE(SPSURF(pipe, plane), obj->gtt_offset + |
| 137 | sprsurf_offset); |
| 138 | POSTING_READ(SPSURF(pipe, plane)); |
| 139 | } |
| 140 | |
| 141 | static void |
| 142 | vlv_disable_plane(struct drm_plane *dplane) |
| 143 | { |
| 144 | struct drm_device *dev = dplane->dev; |
| 145 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 146 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 147 | int pipe = intel_plane->pipe; |
| 148 | int plane = intel_plane->plane; |
| 149 | |
| 150 | I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) & |
| 151 | ~SP_ENABLE); |
| 152 | /* Activate double buffered register update */ |
| 153 | I915_MODIFY_DISPBASE(SPSURF(pipe, plane), 0); |
| 154 | POSTING_READ(SPSURF(pipe, plane)); |
| 155 | } |
| 156 | |
| 157 | static int |
| 158 | vlv_update_colorkey(struct drm_plane *dplane, |
| 159 | struct drm_intel_sprite_colorkey *key) |
| 160 | { |
| 161 | struct drm_device *dev = dplane->dev; |
| 162 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 163 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 164 | int pipe = intel_plane->pipe; |
| 165 | int plane = intel_plane->plane; |
| 166 | u32 sprctl; |
| 167 | |
| 168 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 169 | return -EINVAL; |
| 170 | |
| 171 | I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value); |
| 172 | I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value); |
| 173 | I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask); |
| 174 | |
| 175 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 176 | sprctl &= ~SP_SOURCE_KEY; |
| 177 | if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 178 | sprctl |= SP_SOURCE_KEY; |
| 179 | I915_WRITE(SPCNTR(pipe, plane), sprctl); |
| 180 | |
| 181 | POSTING_READ(SPKEYMSK(pipe, plane)); |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
| 186 | static void |
| 187 | vlv_get_colorkey(struct drm_plane *dplane, |
| 188 | struct drm_intel_sprite_colorkey *key) |
| 189 | { |
| 190 | struct drm_device *dev = dplane->dev; |
| 191 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 192 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 193 | int pipe = intel_plane->pipe; |
| 194 | int plane = intel_plane->plane; |
| 195 | u32 sprctl; |
| 196 | |
| 197 | key->min_value = I915_READ(SPKEYMINVAL(pipe, plane)); |
| 198 | key->max_value = I915_READ(SPKEYMAXVAL(pipe, plane)); |
| 199 | key->channel_mask = I915_READ(SPKEYMSK(pipe, plane)); |
| 200 | |
| 201 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 202 | if (sprctl & SP_SOURCE_KEY) |
| 203 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 204 | else |
| 205 | key->flags = I915_SET_COLORKEY_NONE; |
| 206 | } |
| 207 | |
| 208 | static void |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 209 | ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
| 210 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 211 | unsigned int crtc_w, unsigned int crtc_h, |
| 212 | uint32_t x, uint32_t y, |
| 213 | uint32_t src_w, uint32_t src_h) |
| 214 | { |
| 215 | struct drm_device *dev = plane->dev; |
| 216 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 217 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 218 | int pipe = intel_plane->pipe; |
| 219 | u32 sprctl, sprscale = 0; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 220 | unsigned long sprsurf_offset, linear_offset; |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 221 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 222 | bool scaling_was_enabled = dev_priv->sprite_scaling_enabled; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 223 | |
| 224 | sprctl = I915_READ(SPRCTL(pipe)); |
| 225 | |
| 226 | /* Mask out pixel format bits in case we change it */ |
| 227 | sprctl &= ~SPRITE_PIXFORMAT_MASK; |
| 228 | sprctl &= ~SPRITE_RGB_ORDER_RGBX; |
| 229 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; |
Jesse Barnes | e86fe0d | 2012-06-26 13:10:11 -0700 | [diff] [blame] | 230 | sprctl &= ~SPRITE_TILED; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 231 | |
| 232 | switch (fb->pixel_format) { |
| 233 | case DRM_FORMAT_XBGR8888: |
Vijay Purushothaman | 5ee3691 | 2012-08-23 12:08:57 +0530 | [diff] [blame] | 234 | sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 235 | break; |
| 236 | case DRM_FORMAT_XRGB8888: |
Vijay Purushothaman | 5ee3691 | 2012-08-23 12:08:57 +0530 | [diff] [blame] | 237 | sprctl |= SPRITE_FORMAT_RGBX888; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 238 | break; |
| 239 | case DRM_FORMAT_YUYV: |
| 240 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 241 | break; |
| 242 | case DRM_FORMAT_YVYU: |
| 243 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 244 | break; |
| 245 | case DRM_FORMAT_UYVY: |
| 246 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 247 | break; |
| 248 | case DRM_FORMAT_VYUY: |
| 249 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 250 | break; |
| 251 | default: |
Ville Syrjälä | 28d491d | 2012-10-31 17:50:21 +0200 | [diff] [blame] | 252 | BUG(); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | if (obj->tiling_mode != I915_TILING_NONE) |
| 256 | sprctl |= SPRITE_TILED; |
| 257 | |
| 258 | /* must disable */ |
| 259 | sprctl |= SPRITE_TRICKLE_FEED_DISABLE; |
| 260 | sprctl |= SPRITE_ENABLE; |
| 261 | |
Ville Syrjälä | 86d3efc | 2013-01-18 19:11:38 +0200 | [diff] [blame] | 262 | if (IS_HASWELL(dev)) |
| 263 | sprctl |= SPRITE_PIPE_CSC_ENABLE; |
| 264 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 265 | /* Sizes are 0 based */ |
| 266 | src_w--; |
| 267 | src_h--; |
| 268 | crtc_w--; |
| 269 | crtc_h--; |
| 270 | |
| 271 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
| 272 | |
| 273 | /* |
| 274 | * IVB workaround: must disable low power watermarks for at least |
| 275 | * one frame before enabling scaling. LP watermarks can be re-enabled |
| 276 | * when scaling is disabled. |
| 277 | */ |
| 278 | if (crtc_w != src_w || crtc_h != src_h) { |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 279 | dev_priv->sprite_scaling_enabled |= 1 << pipe; |
| 280 | |
| 281 | if (!scaling_was_enabled) { |
Chris Wilson | 828ed3e | 2012-04-18 17:12:26 +0100 | [diff] [blame] | 282 | intel_update_watermarks(dev); |
| 283 | intel_wait_for_vblank(dev, pipe); |
| 284 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 285 | sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 286 | } else |
| 287 | dev_priv->sprite_scaling_enabled &= ~(1 << pipe); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 288 | |
| 289 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); |
| 290 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
Damien Lespiau | c54173a | 2012-10-26 18:20:11 +0100 | [diff] [blame] | 291 | |
Chris Wilson | ca320ac | 2012-12-19 12:14:22 +0000 | [diff] [blame] | 292 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 293 | sprsurf_offset = |
Chris Wilson | bc75286 | 2013-02-21 20:04:31 +0000 | [diff] [blame] | 294 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
| 295 | pixel_size, fb->pitches[0]); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 296 | linear_offset -= sprsurf_offset; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 297 | |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 298 | /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET |
| 299 | * register */ |
| 300 | if (IS_HASWELL(dev)) |
| 301 | I915_WRITE(SPROFFSET(pipe), (y << 16) | x); |
| 302 | else if (obj->tiling_mode != I915_TILING_NONE) |
| 303 | I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x); |
| 304 | else |
| 305 | I915_WRITE(SPRLINOFF(pipe), linear_offset); |
Damien Lespiau | c54173a | 2012-10-26 18:20:11 +0100 | [diff] [blame] | 306 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 307 | I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w); |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 308 | if (intel_plane->can_scale) |
| 309 | I915_WRITE(SPRSCALE(pipe), sprscale); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 310 | I915_WRITE(SPRCTL(pipe), sprctl); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 311 | I915_MODIFY_DISPBASE(SPRSURF(pipe), obj->gtt_offset + sprsurf_offset); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 312 | POSTING_READ(SPRSURF(pipe)); |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 313 | |
| 314 | /* potentially re-enable LP watermarks */ |
| 315 | if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled) |
| 316 | intel_update_watermarks(dev); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | static void |
| 320 | ivb_disable_plane(struct drm_plane *plane) |
| 321 | { |
| 322 | struct drm_device *dev = plane->dev; |
| 323 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 324 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 325 | int pipe = intel_plane->pipe; |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 326 | bool scaling_was_enabled = dev_priv->sprite_scaling_enabled; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 327 | |
| 328 | I915_WRITE(SPRCTL(pipe), I915_READ(SPRCTL(pipe)) & ~SPRITE_ENABLE); |
| 329 | /* Can't leave the scaler enabled... */ |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 330 | if (intel_plane->can_scale) |
| 331 | I915_WRITE(SPRSCALE(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 332 | /* Activate double buffered register update */ |
Armin Reese | 446f254 | 2012-03-30 16:20:16 -0700 | [diff] [blame] | 333 | I915_MODIFY_DISPBASE(SPRSURF(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 334 | POSTING_READ(SPRSURF(pipe)); |
Chris Wilson | 828ed3e | 2012-04-18 17:12:26 +0100 | [diff] [blame] | 335 | |
Ville Syrjälä | 2c6602d | 2013-02-08 23:13:35 +0200 | [diff] [blame] | 336 | dev_priv->sprite_scaling_enabled &= ~(1 << pipe); |
| 337 | |
| 338 | /* potentially re-enable LP watermarks */ |
| 339 | if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled) |
| 340 | intel_update_watermarks(dev); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 341 | } |
| 342 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 343 | static int |
| 344 | ivb_update_colorkey(struct drm_plane *plane, |
| 345 | struct drm_intel_sprite_colorkey *key) |
| 346 | { |
| 347 | struct drm_device *dev = plane->dev; |
| 348 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 349 | struct intel_plane *intel_plane; |
| 350 | u32 sprctl; |
| 351 | int ret = 0; |
| 352 | |
| 353 | intel_plane = to_intel_plane(plane); |
| 354 | |
| 355 | I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value); |
| 356 | I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value); |
| 357 | I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask); |
| 358 | |
| 359 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
| 360 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); |
| 361 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 362 | sprctl |= SPRITE_DEST_KEY; |
| 363 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 364 | sprctl |= SPRITE_SOURCE_KEY; |
| 365 | I915_WRITE(SPRCTL(intel_plane->pipe), sprctl); |
| 366 | |
| 367 | POSTING_READ(SPRKEYMSK(intel_plane->pipe)); |
| 368 | |
| 369 | return ret; |
| 370 | } |
| 371 | |
| 372 | static void |
| 373 | ivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
| 374 | { |
| 375 | struct drm_device *dev = plane->dev; |
| 376 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 377 | struct intel_plane *intel_plane; |
| 378 | u32 sprctl; |
| 379 | |
| 380 | intel_plane = to_intel_plane(plane); |
| 381 | |
| 382 | key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe)); |
| 383 | key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe)); |
| 384 | key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe)); |
| 385 | key->flags = 0; |
| 386 | |
| 387 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
| 388 | |
| 389 | if (sprctl & SPRITE_DEST_KEY) |
| 390 | key->flags = I915_SET_COLORKEY_DESTINATION; |
| 391 | else if (sprctl & SPRITE_SOURCE_KEY) |
| 392 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 393 | else |
| 394 | key->flags = I915_SET_COLORKEY_NONE; |
| 395 | } |
| 396 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 397 | static void |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 398 | ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 399 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 400 | unsigned int crtc_w, unsigned int crtc_h, |
| 401 | uint32_t x, uint32_t y, |
| 402 | uint32_t src_w, uint32_t src_h) |
| 403 | { |
| 404 | struct drm_device *dev = plane->dev; |
| 405 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 406 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 407 | int pipe = intel_plane->pipe; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 408 | unsigned long dvssurf_offset, linear_offset; |
Chris Wilson | 8aaa81a | 2012-04-14 22:14:26 +0100 | [diff] [blame] | 409 | u32 dvscntr, dvsscale; |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 410 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 411 | |
| 412 | dvscntr = I915_READ(DVSCNTR(pipe)); |
| 413 | |
| 414 | /* Mask out pixel format bits in case we change it */ |
| 415 | dvscntr &= ~DVS_PIXFORMAT_MASK; |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 416 | dvscntr &= ~DVS_RGB_ORDER_XBGR; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 417 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; |
Ander Conselvan de Oliveira | 7962652 | 2012-07-13 15:50:33 +0300 | [diff] [blame] | 418 | dvscntr &= ~DVS_TILED; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 419 | |
| 420 | switch (fb->pixel_format) { |
| 421 | case DRM_FORMAT_XBGR8888: |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 422 | dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 423 | break; |
| 424 | case DRM_FORMAT_XRGB8888: |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 425 | dvscntr |= DVS_FORMAT_RGBX888; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 426 | break; |
| 427 | case DRM_FORMAT_YUYV: |
| 428 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 429 | break; |
| 430 | case DRM_FORMAT_YVYU: |
| 431 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 432 | break; |
| 433 | case DRM_FORMAT_UYVY: |
| 434 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 435 | break; |
| 436 | case DRM_FORMAT_VYUY: |
| 437 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 438 | break; |
| 439 | default: |
Ville Syrjälä | 28d491d | 2012-10-31 17:50:21 +0200 | [diff] [blame] | 440 | BUG(); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | if (obj->tiling_mode != I915_TILING_NONE) |
| 444 | dvscntr |= DVS_TILED; |
| 445 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 446 | if (IS_GEN6(dev)) |
| 447 | dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */ |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 448 | dvscntr |= DVS_ENABLE; |
| 449 | |
| 450 | /* Sizes are 0 based */ |
| 451 | src_w--; |
| 452 | src_h--; |
| 453 | crtc_w--; |
| 454 | crtc_h--; |
| 455 | |
| 456 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
| 457 | |
Chris Wilson | 8aaa81a | 2012-04-14 22:14:26 +0100 | [diff] [blame] | 458 | dvsscale = 0; |
| 459 | if (IS_GEN5(dev) || crtc_w != src_w || crtc_h != src_h) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 460 | dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; |
| 461 | |
| 462 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); |
| 463 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 464 | |
Chris Wilson | ca320ac | 2012-12-19 12:14:22 +0000 | [diff] [blame] | 465 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 466 | dvssurf_offset = |
Chris Wilson | bc75286 | 2013-02-21 20:04:31 +0000 | [diff] [blame] | 467 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
| 468 | pixel_size, fb->pitches[0]); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 469 | linear_offset -= dvssurf_offset; |
| 470 | |
| 471 | if (obj->tiling_mode != I915_TILING_NONE) |
| 472 | I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x); |
| 473 | else |
| 474 | I915_WRITE(DVSLINOFF(pipe), linear_offset); |
| 475 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 476 | I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); |
| 477 | I915_WRITE(DVSSCALE(pipe), dvsscale); |
| 478 | I915_WRITE(DVSCNTR(pipe), dvscntr); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 479 | I915_MODIFY_DISPBASE(DVSSURF(pipe), obj->gtt_offset + dvssurf_offset); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 480 | POSTING_READ(DVSSURF(pipe)); |
| 481 | } |
| 482 | |
| 483 | static void |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 484 | ilk_disable_plane(struct drm_plane *plane) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 485 | { |
| 486 | struct drm_device *dev = plane->dev; |
| 487 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 488 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 489 | int pipe = intel_plane->pipe; |
| 490 | |
| 491 | I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE); |
| 492 | /* Disable the scaler */ |
| 493 | I915_WRITE(DVSSCALE(pipe), 0); |
| 494 | /* Flush double buffered register updates */ |
Armin Reese | 446f254 | 2012-03-30 16:20:16 -0700 | [diff] [blame] | 495 | I915_MODIFY_DISPBASE(DVSSURF(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 496 | POSTING_READ(DVSSURF(pipe)); |
| 497 | } |
| 498 | |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 499 | static void |
| 500 | intel_enable_primary(struct drm_crtc *crtc) |
| 501 | { |
| 502 | struct drm_device *dev = crtc->dev; |
| 503 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 504 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 505 | int reg = DSPCNTR(intel_crtc->plane); |
| 506 | |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 507 | if (!intel_crtc->primary_disabled) |
| 508 | return; |
| 509 | |
| 510 | intel_crtc->primary_disabled = false; |
| 511 | intel_update_fbc(dev); |
| 512 | |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 513 | I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE); |
| 514 | } |
| 515 | |
| 516 | static void |
| 517 | intel_disable_primary(struct drm_crtc *crtc) |
| 518 | { |
| 519 | struct drm_device *dev = crtc->dev; |
| 520 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 521 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 522 | int reg = DSPCNTR(intel_crtc->plane); |
| 523 | |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 524 | if (intel_crtc->primary_disabled) |
| 525 | return; |
| 526 | |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 527 | I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE); |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 528 | |
| 529 | intel_crtc->primary_disabled = true; |
| 530 | intel_update_fbc(dev); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 531 | } |
| 532 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 533 | static int |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 534 | ilk_update_colorkey(struct drm_plane *plane, |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 535 | struct drm_intel_sprite_colorkey *key) |
| 536 | { |
| 537 | struct drm_device *dev = plane->dev; |
| 538 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 539 | struct intel_plane *intel_plane; |
| 540 | u32 dvscntr; |
| 541 | int ret = 0; |
| 542 | |
| 543 | intel_plane = to_intel_plane(plane); |
| 544 | |
| 545 | I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value); |
| 546 | I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value); |
| 547 | I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask); |
| 548 | |
| 549 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
| 550 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); |
| 551 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 552 | dvscntr |= DVS_DEST_KEY; |
| 553 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 554 | dvscntr |= DVS_SOURCE_KEY; |
| 555 | I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr); |
| 556 | |
| 557 | POSTING_READ(DVSKEYMSK(intel_plane->pipe)); |
| 558 | |
| 559 | return ret; |
| 560 | } |
| 561 | |
| 562 | static void |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 563 | ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 564 | { |
| 565 | struct drm_device *dev = plane->dev; |
| 566 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 567 | struct intel_plane *intel_plane; |
| 568 | u32 dvscntr; |
| 569 | |
| 570 | intel_plane = to_intel_plane(plane); |
| 571 | |
| 572 | key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe)); |
| 573 | key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe)); |
| 574 | key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe)); |
| 575 | key->flags = 0; |
| 576 | |
| 577 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
| 578 | |
| 579 | if (dvscntr & DVS_DEST_KEY) |
| 580 | key->flags = I915_SET_COLORKEY_DESTINATION; |
| 581 | else if (dvscntr & DVS_SOURCE_KEY) |
| 582 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 583 | else |
| 584 | key->flags = I915_SET_COLORKEY_NONE; |
| 585 | } |
| 586 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 587 | static bool |
| 588 | format_is_yuv(uint32_t format) |
| 589 | { |
| 590 | switch (format) { |
| 591 | case DRM_FORMAT_YUYV: |
| 592 | case DRM_FORMAT_UYVY: |
| 593 | case DRM_FORMAT_VYUY: |
| 594 | case DRM_FORMAT_YVYU: |
| 595 | return true; |
| 596 | default: |
| 597 | return false; |
| 598 | } |
| 599 | } |
| 600 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 601 | static int |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 602 | intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
| 603 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
| 604 | unsigned int crtc_w, unsigned int crtc_h, |
| 605 | uint32_t src_x, uint32_t src_y, |
| 606 | uint32_t src_w, uint32_t src_h) |
| 607 | { |
| 608 | struct drm_device *dev = plane->dev; |
| 609 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 610 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 611 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 612 | struct intel_framebuffer *intel_fb; |
| 613 | struct drm_i915_gem_object *obj, *old_obj; |
| 614 | int pipe = intel_plane->pipe; |
Paulo Zanoni | 702e7a5 | 2012-10-23 18:29:59 -0200 | [diff] [blame] | 615 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
| 616 | pipe); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 617 | int ret = 0; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 618 | bool disable_primary = false; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 619 | bool visible; |
| 620 | int hscale, vscale; |
| 621 | int max_scale, min_scale; |
| 622 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
| 623 | struct drm_rect src = { |
| 624 | /* sample coordinates in 16.16 fixed point */ |
| 625 | .x1 = src_x, |
| 626 | .x2 = src_x + src_w, |
| 627 | .y1 = src_y, |
| 628 | .y2 = src_y + src_h, |
| 629 | }; |
| 630 | struct drm_rect dst = { |
| 631 | /* integer pixels */ |
| 632 | .x1 = crtc_x, |
| 633 | .x2 = crtc_x + crtc_w, |
| 634 | .y1 = crtc_y, |
| 635 | .y2 = crtc_y + crtc_h, |
| 636 | }; |
| 637 | const struct drm_rect clip = { |
| 638 | .x2 = crtc->mode.hdisplay, |
| 639 | .y2 = crtc->mode.vdisplay, |
| 640 | }; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 641 | |
| 642 | intel_fb = to_intel_framebuffer(fb); |
| 643 | obj = intel_fb->obj; |
| 644 | |
| 645 | old_obj = intel_plane->obj; |
| 646 | |
Jesse Barnes | 5e1bac2 | 2013-03-26 09:25:43 -0700 | [diff] [blame] | 647 | intel_plane->crtc_x = crtc_x; |
| 648 | intel_plane->crtc_y = crtc_y; |
| 649 | intel_plane->crtc_w = crtc_w; |
| 650 | intel_plane->crtc_h = crtc_h; |
| 651 | intel_plane->src_x = src_x; |
| 652 | intel_plane->src_y = src_y; |
| 653 | intel_plane->src_w = src_w; |
| 654 | intel_plane->src_h = src_h; |
| 655 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 656 | /* Pipe must be running... */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 657 | if (!(I915_READ(PIPECONF(cpu_transcoder)) & PIPECONF_ENABLE)) { |
| 658 | DRM_DEBUG_KMS("Pipe disabled\n"); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 659 | return -EINVAL; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 660 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 661 | |
| 662 | /* Don't modify another pipe's plane */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 663 | if (intel_plane->pipe != intel_crtc->pipe) { |
| 664 | DRM_DEBUG_KMS("Wrong plane <-> crtc mapping\n"); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 665 | return -EINVAL; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | /* FIXME check all gen limits */ |
| 669 | if (fb->width < 3 || fb->height < 3 || fb->pitches[0] > 16384) { |
| 670 | DRM_DEBUG_KMS("Unsuitable framebuffer for plane\n"); |
| 671 | return -EINVAL; |
| 672 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 673 | |
Damien Lespiau | 94c6419 | 2012-10-29 15:14:51 +0000 | [diff] [blame] | 674 | /* Sprite planes can be linear or x-tiled surfaces */ |
| 675 | switch (obj->tiling_mode) { |
| 676 | case I915_TILING_NONE: |
| 677 | case I915_TILING_X: |
| 678 | break; |
| 679 | default: |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 680 | DRM_DEBUG_KMS("Unsupported tiling mode\n"); |
Damien Lespiau | 94c6419 | 2012-10-29 15:14:51 +0000 | [diff] [blame] | 681 | return -EINVAL; |
| 682 | } |
| 683 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame^] | 684 | /* |
| 685 | * FIXME the following code does a bunch of fuzzy adjustments to the |
| 686 | * coordinates and sizes. We probably need some way to decide whether |
| 687 | * more strict checking should be done instead. |
| 688 | */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 689 | max_scale = intel_plane->max_downscale << 16; |
| 690 | min_scale = intel_plane->can_scale ? 1 : (1 << 16); |
| 691 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame^] | 692 | hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale); |
| 693 | BUG_ON(hscale < 0); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 694 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame^] | 695 | vscale = drm_rect_calc_vscale_relaxed(&src, &dst, min_scale, max_scale); |
| 696 | BUG_ON(vscale < 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 697 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 698 | visible = drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 699 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 700 | crtc_x = dst.x1; |
| 701 | crtc_y = dst.y1; |
| 702 | crtc_w = drm_rect_width(&dst); |
| 703 | crtc_h = drm_rect_height(&dst); |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 704 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 705 | if (visible) { |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame^] | 706 | /* check again in case clipping clamped the results */ |
| 707 | hscale = drm_rect_calc_hscale(&src, &dst, min_scale, max_scale); |
| 708 | if (hscale < 0) { |
| 709 | DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n"); |
| 710 | drm_rect_debug_print(&src, true); |
| 711 | drm_rect_debug_print(&dst, false); |
| 712 | |
| 713 | return hscale; |
| 714 | } |
| 715 | |
| 716 | vscale = drm_rect_calc_vscale(&src, &dst, min_scale, max_scale); |
| 717 | if (vscale < 0) { |
| 718 | DRM_DEBUG_KMS("Vertical scaling factor out of limits\n"); |
| 719 | drm_rect_debug_print(&src, true); |
| 720 | drm_rect_debug_print(&dst, false); |
| 721 | |
| 722 | return vscale; |
| 723 | } |
| 724 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 725 | /* Make the source viewport size an exact multiple of the scaling factors. */ |
| 726 | drm_rect_adjust_size(&src, |
| 727 | drm_rect_width(&dst) * hscale - drm_rect_width(&src), |
| 728 | drm_rect_height(&dst) * vscale - drm_rect_height(&src)); |
| 729 | |
| 730 | /* sanity check to make sure the src viewport wasn't enlarged */ |
| 731 | WARN_ON(src.x1 < (int) src_x || |
| 732 | src.y1 < (int) src_y || |
| 733 | src.x2 > (int) (src_x + src_w) || |
| 734 | src.y2 > (int) (src_y + src_h)); |
| 735 | |
| 736 | /* |
| 737 | * Hardware doesn't handle subpixel coordinates. |
| 738 | * Adjust to (macro)pixel boundary, but be careful not to |
| 739 | * increase the source viewport size, because that could |
| 740 | * push the downscaling factor out of bounds. |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 741 | */ |
| 742 | src_x = src.x1 >> 16; |
| 743 | src_w = drm_rect_width(&src) >> 16; |
| 744 | src_y = src.y1 >> 16; |
| 745 | src_h = drm_rect_height(&src) >> 16; |
| 746 | |
| 747 | if (format_is_yuv(fb->pixel_format)) { |
| 748 | src_x &= ~1; |
| 749 | src_w &= ~1; |
| 750 | |
| 751 | /* |
| 752 | * Must keep src and dst the |
| 753 | * same if we can't scale. |
| 754 | */ |
| 755 | if (!intel_plane->can_scale) |
| 756 | crtc_w &= ~1; |
| 757 | |
| 758 | if (crtc_w == 0) |
| 759 | visible = false; |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | /* Check size restrictions when scaling */ |
| 764 | if (visible && (src_w != crtc_w || src_h != crtc_h)) { |
| 765 | unsigned int width_bytes; |
| 766 | |
| 767 | WARN_ON(!intel_plane->can_scale); |
| 768 | |
| 769 | /* FIXME interlacing min height is 6 */ |
| 770 | |
| 771 | if (crtc_w < 3 || crtc_h < 3) |
| 772 | visible = false; |
| 773 | |
| 774 | if (src_w < 3 || src_h < 3) |
| 775 | visible = false; |
| 776 | |
| 777 | width_bytes = ((src_x * pixel_size) & 63) + src_w * pixel_size; |
| 778 | |
| 779 | if (src_w > 2048 || src_h > 2048 || |
| 780 | width_bytes > 4096 || fb->pitches[0] > 4096) { |
| 781 | DRM_DEBUG_KMS("Source dimensions exceed hardware limits\n"); |
| 782 | return -EINVAL; |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | dst.x1 = crtc_x; |
| 787 | dst.x2 = crtc_x + crtc_w; |
| 788 | dst.y1 = crtc_y; |
| 789 | dst.y2 = crtc_y + crtc_h; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 790 | |
| 791 | /* |
| 792 | * If the sprite is completely covering the primary plane, |
| 793 | * we can disable the primary and save power. |
| 794 | */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 795 | disable_primary = drm_rect_equals(&dst, &clip); |
| 796 | WARN_ON(disable_primary && !visible); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 797 | |
| 798 | mutex_lock(&dev->struct_mutex); |
| 799 | |
Chris Wilson | 693db18 | 2013-03-05 14:52:39 +0000 | [diff] [blame] | 800 | /* Note that this will apply the VT-d workaround for scanouts, |
| 801 | * which is more restrictive than required for sprites. (The |
| 802 | * primary plane requires 256KiB alignment with 64 PTE padding, |
| 803 | * the sprite planes only require 128KiB alignment and 32 PTE padding. |
| 804 | */ |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 805 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
Jesse Barnes | 00c2064b | 2012-01-13 15:48:39 -0800 | [diff] [blame] | 806 | if (ret) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 807 | goto out_unlock; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 808 | |
| 809 | intel_plane->obj = obj; |
| 810 | |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 811 | /* |
| 812 | * Be sure to re-enable the primary before the sprite is no longer |
| 813 | * covering it fully. |
| 814 | */ |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 815 | if (!disable_primary) |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 816 | intel_enable_primary(crtc); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 817 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 818 | if (visible) |
| 819 | intel_plane->update_plane(plane, fb, obj, |
| 820 | crtc_x, crtc_y, crtc_w, crtc_h, |
| 821 | src_x, src_y, src_w, src_h); |
| 822 | else |
| 823 | intel_plane->disable_plane(plane); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 824 | |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 825 | if (disable_primary) |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 826 | intel_disable_primary(crtc); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 827 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 828 | /* Unpin old obj after new one is active to avoid ugliness */ |
| 829 | if (old_obj) { |
| 830 | /* |
| 831 | * It's fairly common to simply update the position of |
| 832 | * an existing object. In that case, we don't need to |
| 833 | * wait for vblank to avoid ugliness, we only need to |
| 834 | * do the pin & ref bookkeeping. |
| 835 | */ |
| 836 | if (old_obj != obj) { |
| 837 | mutex_unlock(&dev->struct_mutex); |
| 838 | intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); |
| 839 | mutex_lock(&dev->struct_mutex); |
| 840 | } |
Chris Wilson | 1690e1e | 2011-12-14 13:57:08 +0100 | [diff] [blame] | 841 | intel_unpin_fb_obj(old_obj); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | out_unlock: |
| 845 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 846 | return ret; |
| 847 | } |
| 848 | |
| 849 | static int |
| 850 | intel_disable_plane(struct drm_plane *plane) |
| 851 | { |
| 852 | struct drm_device *dev = plane->dev; |
| 853 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 854 | int ret = 0; |
| 855 | |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 856 | if (plane->crtc) |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 857 | intel_enable_primary(plane->crtc); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 858 | intel_plane->disable_plane(plane); |
| 859 | |
| 860 | if (!intel_plane->obj) |
| 861 | goto out; |
| 862 | |
Ville Syrjälä | c626d31 | 2013-03-27 17:49:13 +0200 | [diff] [blame] | 863 | intel_wait_for_vblank(dev, intel_plane->pipe); |
| 864 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 865 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 1690e1e | 2011-12-14 13:57:08 +0100 | [diff] [blame] | 866 | intel_unpin_fb_obj(intel_plane->obj); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 867 | intel_plane->obj = NULL; |
| 868 | mutex_unlock(&dev->struct_mutex); |
| 869 | out: |
| 870 | |
| 871 | return ret; |
| 872 | } |
| 873 | |
| 874 | static void intel_destroy_plane(struct drm_plane *plane) |
| 875 | { |
| 876 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 877 | intel_disable_plane(plane); |
| 878 | drm_plane_cleanup(plane); |
| 879 | kfree(intel_plane); |
| 880 | } |
| 881 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 882 | int intel_sprite_set_colorkey(struct drm_device *dev, void *data, |
| 883 | struct drm_file *file_priv) |
| 884 | { |
| 885 | struct drm_intel_sprite_colorkey *set = data; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 886 | struct drm_mode_object *obj; |
| 887 | struct drm_plane *plane; |
| 888 | struct intel_plane *intel_plane; |
| 889 | int ret = 0; |
| 890 | |
Daniel Vetter | 1cff8f6 | 2012-04-24 09:55:08 +0200 | [diff] [blame] | 891 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 892 | return -ENODEV; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 893 | |
| 894 | /* Make sure we don't try to enable both src & dest simultaneously */ |
| 895 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
| 896 | return -EINVAL; |
| 897 | |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 898 | drm_modeset_lock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 899 | |
| 900 | obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE); |
| 901 | if (!obj) { |
| 902 | ret = -EINVAL; |
| 903 | goto out_unlock; |
| 904 | } |
| 905 | |
| 906 | plane = obj_to_plane(obj); |
| 907 | intel_plane = to_intel_plane(plane); |
| 908 | ret = intel_plane->update_colorkey(plane, set); |
| 909 | |
| 910 | out_unlock: |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 911 | drm_modeset_unlock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 912 | return ret; |
| 913 | } |
| 914 | |
| 915 | int intel_sprite_get_colorkey(struct drm_device *dev, void *data, |
| 916 | struct drm_file *file_priv) |
| 917 | { |
| 918 | struct drm_intel_sprite_colorkey *get = data; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 919 | struct drm_mode_object *obj; |
| 920 | struct drm_plane *plane; |
| 921 | struct intel_plane *intel_plane; |
| 922 | int ret = 0; |
| 923 | |
Daniel Vetter | 1cff8f6 | 2012-04-24 09:55:08 +0200 | [diff] [blame] | 924 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 925 | return -ENODEV; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 926 | |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 927 | drm_modeset_lock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 928 | |
| 929 | obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE); |
| 930 | if (!obj) { |
| 931 | ret = -EINVAL; |
| 932 | goto out_unlock; |
| 933 | } |
| 934 | |
| 935 | plane = obj_to_plane(obj); |
| 936 | intel_plane = to_intel_plane(plane); |
| 937 | intel_plane->get_colorkey(plane, get); |
| 938 | |
| 939 | out_unlock: |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 940 | drm_modeset_unlock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 941 | return ret; |
| 942 | } |
| 943 | |
Jesse Barnes | 5e1bac2 | 2013-03-26 09:25:43 -0700 | [diff] [blame] | 944 | void intel_plane_restore(struct drm_plane *plane) |
| 945 | { |
| 946 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 947 | |
| 948 | if (!plane->crtc || !plane->fb) |
| 949 | return; |
| 950 | |
| 951 | intel_update_plane(plane, plane->crtc, plane->fb, |
| 952 | intel_plane->crtc_x, intel_plane->crtc_y, |
| 953 | intel_plane->crtc_w, intel_plane->crtc_h, |
| 954 | intel_plane->src_x, intel_plane->src_y, |
| 955 | intel_plane->src_w, intel_plane->src_h); |
| 956 | } |
| 957 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 958 | static const struct drm_plane_funcs intel_plane_funcs = { |
| 959 | .update_plane = intel_update_plane, |
| 960 | .disable_plane = intel_disable_plane, |
| 961 | .destroy = intel_destroy_plane, |
| 962 | }; |
| 963 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 964 | static uint32_t ilk_plane_formats[] = { |
| 965 | DRM_FORMAT_XRGB8888, |
| 966 | DRM_FORMAT_YUYV, |
| 967 | DRM_FORMAT_YVYU, |
| 968 | DRM_FORMAT_UYVY, |
| 969 | DRM_FORMAT_VYUY, |
| 970 | }; |
| 971 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 972 | static uint32_t snb_plane_formats[] = { |
| 973 | DRM_FORMAT_XBGR8888, |
| 974 | DRM_FORMAT_XRGB8888, |
| 975 | DRM_FORMAT_YUYV, |
| 976 | DRM_FORMAT_YVYU, |
| 977 | DRM_FORMAT_UYVY, |
| 978 | DRM_FORMAT_VYUY, |
| 979 | }; |
| 980 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 981 | static uint32_t vlv_plane_formats[] = { |
| 982 | DRM_FORMAT_RGB565, |
| 983 | DRM_FORMAT_ABGR8888, |
| 984 | DRM_FORMAT_ARGB8888, |
| 985 | DRM_FORMAT_XBGR8888, |
| 986 | DRM_FORMAT_XRGB8888, |
| 987 | DRM_FORMAT_XBGR2101010, |
| 988 | DRM_FORMAT_ABGR2101010, |
| 989 | DRM_FORMAT_YUYV, |
| 990 | DRM_FORMAT_YVYU, |
| 991 | DRM_FORMAT_UYVY, |
| 992 | DRM_FORMAT_VYUY, |
| 993 | }; |
| 994 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 995 | int |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 996 | intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 997 | { |
| 998 | struct intel_plane *intel_plane; |
| 999 | unsigned long possible_crtcs; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1000 | const uint32_t *plane_formats; |
| 1001 | int num_plane_formats; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1002 | int ret; |
| 1003 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1004 | if (INTEL_INFO(dev)->gen < 5) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1005 | return -ENODEV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1006 | |
| 1007 | intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL); |
| 1008 | if (!intel_plane) |
| 1009 | return -ENOMEM; |
| 1010 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1011 | switch (INTEL_INFO(dev)->gen) { |
| 1012 | case 5: |
| 1013 | case 6: |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 1014 | intel_plane->can_scale = true; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1015 | intel_plane->max_downscale = 16; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1016 | intel_plane->update_plane = ilk_update_plane; |
| 1017 | intel_plane->disable_plane = ilk_disable_plane; |
| 1018 | intel_plane->update_colorkey = ilk_update_colorkey; |
| 1019 | intel_plane->get_colorkey = ilk_get_colorkey; |
| 1020 | |
| 1021 | if (IS_GEN6(dev)) { |
| 1022 | plane_formats = snb_plane_formats; |
| 1023 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
| 1024 | } else { |
| 1025 | plane_formats = ilk_plane_formats; |
| 1026 | num_plane_formats = ARRAY_SIZE(ilk_plane_formats); |
| 1027 | } |
| 1028 | break; |
| 1029 | |
| 1030 | case 7: |
Damien Lespiau | d49f709 | 2013-04-25 15:15:00 +0100 | [diff] [blame] | 1031 | if (IS_IVYBRIDGE(dev)) { |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 1032 | intel_plane->can_scale = true; |
Damien Lespiau | d49f709 | 2013-04-25 15:15:00 +0100 | [diff] [blame] | 1033 | intel_plane->max_downscale = 2; |
| 1034 | } else { |
| 1035 | intel_plane->can_scale = false; |
| 1036 | intel_plane->max_downscale = 1; |
| 1037 | } |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1038 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1039 | if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1040 | intel_plane->update_plane = vlv_update_plane; |
| 1041 | intel_plane->disable_plane = vlv_disable_plane; |
| 1042 | intel_plane->update_colorkey = vlv_update_colorkey; |
| 1043 | intel_plane->get_colorkey = vlv_get_colorkey; |
| 1044 | |
| 1045 | plane_formats = vlv_plane_formats; |
| 1046 | num_plane_formats = ARRAY_SIZE(vlv_plane_formats); |
| 1047 | } else { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1048 | intel_plane->update_plane = ivb_update_plane; |
| 1049 | intel_plane->disable_plane = ivb_disable_plane; |
| 1050 | intel_plane->update_colorkey = ivb_update_colorkey; |
| 1051 | intel_plane->get_colorkey = ivb_get_colorkey; |
| 1052 | |
| 1053 | plane_formats = snb_plane_formats; |
| 1054 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
| 1055 | } |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1056 | break; |
| 1057 | |
| 1058 | default: |
Jesper Juhl | a8b0bba | 2012-06-27 00:55:37 +0200 | [diff] [blame] | 1059 | kfree(intel_plane); |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1060 | return -ENODEV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | intel_plane->pipe = pipe; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1064 | intel_plane->plane = plane; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1065 | possible_crtcs = (1 << pipe); |
| 1066 | ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs, |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1067 | &intel_plane_funcs, |
| 1068 | plane_formats, num_plane_formats, |
| 1069 | false); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1070 | if (ret) |
| 1071 | kfree(intel_plane); |
| 1072 | |
| 1073 | return ret; |
| 1074 | } |