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 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 40 | static int usecs_to_scanlines(const struct drm_display_mode *mode, int usecs) |
| 41 | { |
| 42 | /* paranoia */ |
| 43 | if (!mode->crtc_htotal) |
| 44 | return 1; |
| 45 | |
| 46 | return DIV_ROUND_UP(usecs * mode->crtc_clock, 1000 * mode->crtc_htotal); |
| 47 | } |
| 48 | |
| 49 | static bool intel_pipe_update_start(struct intel_crtc *crtc, uint32_t *start_vbl_count) |
| 50 | { |
| 51 | struct drm_device *dev = crtc->base.dev; |
| 52 | const struct drm_display_mode *mode = &crtc->config.adjusted_mode; |
| 53 | enum pipe pipe = crtc->pipe; |
| 54 | long timeout = msecs_to_jiffies_timeout(1); |
| 55 | int scanline, min, max, vblank_start; |
| 56 | DEFINE_WAIT(wait); |
| 57 | |
| 58 | WARN_ON(!mutex_is_locked(&crtc->base.mutex)); |
| 59 | |
| 60 | vblank_start = mode->crtc_vblank_start; |
| 61 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 62 | vblank_start = DIV_ROUND_UP(vblank_start, 2); |
| 63 | |
| 64 | /* FIXME needs to be calibrated sensibly */ |
| 65 | min = vblank_start - usecs_to_scanlines(mode, 100); |
| 66 | max = vblank_start - 1; |
| 67 | |
| 68 | if (min <= 0 || max <= 0) |
| 69 | return false; |
| 70 | |
| 71 | if (WARN_ON(drm_vblank_get(dev, pipe))) |
| 72 | return false; |
| 73 | |
| 74 | local_irq_disable(); |
| 75 | |
| 76 | for (;;) { |
| 77 | /* |
| 78 | * prepare_to_wait() has a memory barrier, which guarantees |
| 79 | * other CPUs can see the task state update by the time we |
| 80 | * read the scanline. |
| 81 | */ |
| 82 | prepare_to_wait(&crtc->vbl_wait, &wait, TASK_UNINTERRUPTIBLE); |
| 83 | |
| 84 | scanline = intel_get_crtc_scanline(crtc); |
| 85 | if (scanline < min || scanline > max) |
| 86 | break; |
| 87 | |
| 88 | if (timeout <= 0) { |
| 89 | DRM_ERROR("Potential atomic update failure on pipe %c\n", |
| 90 | pipe_name(crtc->pipe)); |
| 91 | break; |
| 92 | } |
| 93 | |
| 94 | local_irq_enable(); |
| 95 | |
| 96 | timeout = schedule_timeout(timeout); |
| 97 | |
| 98 | local_irq_disable(); |
| 99 | } |
| 100 | |
| 101 | finish_wait(&crtc->vbl_wait, &wait); |
| 102 | |
| 103 | drm_vblank_put(dev, pipe); |
| 104 | |
| 105 | *start_vbl_count = dev->driver->get_vblank_counter(dev, pipe); |
| 106 | |
| 107 | return true; |
| 108 | } |
| 109 | |
| 110 | static void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count) |
| 111 | { |
| 112 | struct drm_device *dev = crtc->base.dev; |
| 113 | enum pipe pipe = crtc->pipe; |
| 114 | u32 end_vbl_count = dev->driver->get_vblank_counter(dev, pipe); |
| 115 | |
| 116 | local_irq_enable(); |
| 117 | |
| 118 | if (start_vbl_count != end_vbl_count) |
| 119 | DRM_ERROR("Atomic update failure on pipe %c (start=%u end=%u)\n", |
| 120 | pipe_name(pipe), start_vbl_count, end_vbl_count); |
| 121 | } |
| 122 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 123 | static void intel_update_primary_plane(struct intel_crtc *crtc) |
| 124 | { |
| 125 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
| 126 | int reg = DSPCNTR(crtc->plane); |
| 127 | |
| 128 | if (crtc->primary_enabled) |
| 129 | I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE); |
| 130 | else |
| 131 | I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE); |
| 132 | } |
| 133 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 134 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 135 | vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, |
| 136 | struct drm_framebuffer *fb, |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 137 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 138 | unsigned int crtc_w, unsigned int crtc_h, |
| 139 | uint32_t x, uint32_t y, |
| 140 | uint32_t src_w, uint32_t src_h) |
| 141 | { |
| 142 | struct drm_device *dev = dplane->dev; |
| 143 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 144 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 145 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 146 | int pipe = intel_plane->pipe; |
| 147 | int plane = intel_plane->plane; |
| 148 | u32 sprctl; |
| 149 | unsigned long sprsurf_offset, linear_offset; |
| 150 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 151 | u32 start_vbl_count; |
| 152 | bool atomic_update; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 153 | |
| 154 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 155 | |
| 156 | /* Mask out pixel format bits in case we change it */ |
| 157 | sprctl &= ~SP_PIXFORMAT_MASK; |
| 158 | sprctl &= ~SP_YUV_BYTE_ORDER_MASK; |
| 159 | sprctl &= ~SP_TILED; |
| 160 | |
| 161 | switch (fb->pixel_format) { |
| 162 | case DRM_FORMAT_YUYV: |
| 163 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV; |
| 164 | break; |
| 165 | case DRM_FORMAT_YVYU: |
| 166 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YVYU; |
| 167 | break; |
| 168 | case DRM_FORMAT_UYVY: |
| 169 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_UYVY; |
| 170 | break; |
| 171 | case DRM_FORMAT_VYUY: |
| 172 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_VYUY; |
| 173 | break; |
| 174 | case DRM_FORMAT_RGB565: |
| 175 | sprctl |= SP_FORMAT_BGR565; |
| 176 | break; |
| 177 | case DRM_FORMAT_XRGB8888: |
| 178 | sprctl |= SP_FORMAT_BGRX8888; |
| 179 | break; |
| 180 | case DRM_FORMAT_ARGB8888: |
| 181 | sprctl |= SP_FORMAT_BGRA8888; |
| 182 | break; |
| 183 | case DRM_FORMAT_XBGR2101010: |
| 184 | sprctl |= SP_FORMAT_RGBX1010102; |
| 185 | break; |
| 186 | case DRM_FORMAT_ABGR2101010: |
| 187 | sprctl |= SP_FORMAT_RGBA1010102; |
| 188 | break; |
| 189 | case DRM_FORMAT_XBGR8888: |
| 190 | sprctl |= SP_FORMAT_RGBX8888; |
| 191 | break; |
| 192 | case DRM_FORMAT_ABGR8888: |
| 193 | sprctl |= SP_FORMAT_RGBA8888; |
| 194 | break; |
| 195 | default: |
| 196 | /* |
| 197 | * If we get here one of the upper layers failed to filter |
| 198 | * out the unsupported plane formats |
| 199 | */ |
| 200 | BUG(); |
| 201 | break; |
| 202 | } |
| 203 | |
Ville Syrjälä | 4ea67bc | 2013-11-18 18:32:38 -0800 | [diff] [blame] | 204 | /* |
| 205 | * Enable gamma to match primary/cursor plane behaviour. |
| 206 | * FIXME should be user controllable via propertiesa. |
| 207 | */ |
| 208 | sprctl |= SP_GAMMA_ENABLE; |
| 209 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 210 | if (obj->tiling_mode != I915_TILING_NONE) |
| 211 | sprctl |= SP_TILED; |
| 212 | |
| 213 | sprctl |= SP_ENABLE; |
| 214 | |
Ville Syrjälä | adf3d35 | 2013-08-06 22:24:11 +0300 | [diff] [blame] | 215 | intel_update_sprite_watermarks(dplane, crtc, src_w, pixel_size, true, |
Ville Syrjälä | 67ca28f | 2013-07-05 11:57:14 +0300 | [diff] [blame] | 216 | src_w != crtc_w || src_h != crtc_h); |
| 217 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 218 | /* Sizes are 0 based */ |
| 219 | src_w--; |
| 220 | src_h--; |
| 221 | crtc_w--; |
| 222 | crtc_h--; |
| 223 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 224 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
| 225 | sprsurf_offset = intel_gen4_compute_page_offset(&x, &y, |
| 226 | obj->tiling_mode, |
| 227 | pixel_size, |
| 228 | fb->pitches[0]); |
| 229 | linear_offset -= sprsurf_offset; |
| 230 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 231 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
| 232 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 233 | intel_update_primary_plane(intel_crtc); |
| 234 | |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 235 | I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); |
| 236 | I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); |
| 237 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 238 | if (obj->tiling_mode != I915_TILING_NONE) |
| 239 | I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x); |
| 240 | else |
| 241 | I915_WRITE(SPLINOFF(pipe, plane), linear_offset); |
| 242 | |
| 243 | I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w); |
| 244 | I915_WRITE(SPCNTR(pipe, plane), sprctl); |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 245 | I915_WRITE(SPSURF(pipe, plane), i915_gem_obj_ggtt_offset(obj) + |
| 246 | sprsurf_offset); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 247 | |
| 248 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 249 | |
| 250 | if (atomic_update) |
| 251 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 255 | vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc) |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 256 | { |
| 257 | struct drm_device *dev = dplane->dev; |
| 258 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 259 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 260 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 261 | int pipe = intel_plane->pipe; |
| 262 | int plane = intel_plane->plane; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 263 | u32 start_vbl_count; |
| 264 | bool atomic_update; |
| 265 | |
| 266 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 267 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 268 | intel_update_primary_plane(intel_crtc); |
| 269 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 270 | I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) & |
| 271 | ~SP_ENABLE); |
| 272 | /* Activate double buffered register update */ |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 273 | I915_WRITE(SPSURF(pipe, plane), 0); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 274 | |
| 275 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Ville Syrjälä | a95fd8c | 2013-08-06 22:24:12 +0300 | [diff] [blame] | 276 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 277 | if (atomic_update) |
| 278 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
| 279 | |
Ville Syrjälä | a95fd8c | 2013-08-06 22:24:12 +0300 | [diff] [blame] | 280 | intel_update_sprite_watermarks(dplane, crtc, 0, 0, false, false); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | static int |
| 284 | vlv_update_colorkey(struct drm_plane *dplane, |
| 285 | struct drm_intel_sprite_colorkey *key) |
| 286 | { |
| 287 | struct drm_device *dev = dplane->dev; |
| 288 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 289 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 290 | int pipe = intel_plane->pipe; |
| 291 | int plane = intel_plane->plane; |
| 292 | u32 sprctl; |
| 293 | |
| 294 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 295 | return -EINVAL; |
| 296 | |
| 297 | I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value); |
| 298 | I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value); |
| 299 | I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask); |
| 300 | |
| 301 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 302 | sprctl &= ~SP_SOURCE_KEY; |
| 303 | if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 304 | sprctl |= SP_SOURCE_KEY; |
| 305 | I915_WRITE(SPCNTR(pipe, plane), sprctl); |
| 306 | |
| 307 | POSTING_READ(SPKEYMSK(pipe, plane)); |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | static void |
| 313 | vlv_get_colorkey(struct drm_plane *dplane, |
| 314 | struct drm_intel_sprite_colorkey *key) |
| 315 | { |
| 316 | struct drm_device *dev = dplane->dev; |
| 317 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 318 | struct intel_plane *intel_plane = to_intel_plane(dplane); |
| 319 | int pipe = intel_plane->pipe; |
| 320 | int plane = intel_plane->plane; |
| 321 | u32 sprctl; |
| 322 | |
| 323 | key->min_value = I915_READ(SPKEYMINVAL(pipe, plane)); |
| 324 | key->max_value = I915_READ(SPKEYMAXVAL(pipe, plane)); |
| 325 | key->channel_mask = I915_READ(SPKEYMSK(pipe, plane)); |
| 326 | |
| 327 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
| 328 | if (sprctl & SP_SOURCE_KEY) |
| 329 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 330 | else |
| 331 | key->flags = I915_SET_COLORKEY_NONE; |
| 332 | } |
| 333 | |
| 334 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 335 | ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
| 336 | struct drm_framebuffer *fb, |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 337 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 338 | unsigned int crtc_w, unsigned int crtc_h, |
| 339 | uint32_t x, uint32_t y, |
| 340 | uint32_t src_w, uint32_t src_h) |
| 341 | { |
| 342 | struct drm_device *dev = plane->dev; |
| 343 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 344 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 345 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 346 | int pipe = intel_plane->pipe; |
| 347 | u32 sprctl, sprscale = 0; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 348 | unsigned long sprsurf_offset, linear_offset; |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 349 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 350 | u32 start_vbl_count; |
| 351 | bool atomic_update; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 352 | |
| 353 | sprctl = I915_READ(SPRCTL(pipe)); |
| 354 | |
| 355 | /* Mask out pixel format bits in case we change it */ |
| 356 | sprctl &= ~SPRITE_PIXFORMAT_MASK; |
| 357 | sprctl &= ~SPRITE_RGB_ORDER_RGBX; |
| 358 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; |
Jesse Barnes | e86fe0d | 2012-06-26 13:10:11 -0700 | [diff] [blame] | 359 | sprctl &= ~SPRITE_TILED; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 360 | |
| 361 | switch (fb->pixel_format) { |
| 362 | case DRM_FORMAT_XBGR8888: |
Vijay Purushothaman | 5ee3691 | 2012-08-23 12:08:57 +0530 | [diff] [blame] | 363 | sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 364 | break; |
| 365 | case DRM_FORMAT_XRGB8888: |
Vijay Purushothaman | 5ee3691 | 2012-08-23 12:08:57 +0530 | [diff] [blame] | 366 | sprctl |= SPRITE_FORMAT_RGBX888; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 367 | break; |
| 368 | case DRM_FORMAT_YUYV: |
| 369 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 370 | break; |
| 371 | case DRM_FORMAT_YVYU: |
| 372 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 373 | break; |
| 374 | case DRM_FORMAT_UYVY: |
| 375 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 376 | break; |
| 377 | case DRM_FORMAT_VYUY: |
| 378 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 379 | break; |
| 380 | default: |
Ville Syrjälä | 28d491d | 2012-10-31 17:50:21 +0200 | [diff] [blame] | 381 | BUG(); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 382 | } |
| 383 | |
Ville Syrjälä | 4ea67bc | 2013-11-18 18:32:38 -0800 | [diff] [blame] | 384 | /* |
| 385 | * Enable gamma to match primary/cursor plane behaviour. |
| 386 | * FIXME should be user controllable via propertiesa. |
| 387 | */ |
| 388 | sprctl |= SPRITE_GAMMA_ENABLE; |
| 389 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 390 | if (obj->tiling_mode != I915_TILING_NONE) |
| 391 | sprctl |= SPRITE_TILED; |
| 392 | |
Ville Syrjälä | b42c600 | 2013-11-03 13:47:27 +0200 | [diff] [blame] | 393 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Paulo Zanoni | 1f5d76d | 2013-08-23 19:51:28 -0300 | [diff] [blame] | 394 | sprctl &= ~SPRITE_TRICKLE_FEED_DISABLE; |
| 395 | else |
| 396 | sprctl |= SPRITE_TRICKLE_FEED_DISABLE; |
| 397 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 398 | sprctl |= SPRITE_ENABLE; |
| 399 | |
Ville Syrjälä | 6bbfa1c | 2013-11-02 21:07:39 -0700 | [diff] [blame] | 400 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Ville Syrjälä | 86d3efc | 2013-01-18 19:11:38 +0200 | [diff] [blame] | 401 | sprctl |= SPRITE_PIPE_CSC_ENABLE; |
| 402 | |
Ville Syrjälä | adf3d35 | 2013-08-06 22:24:11 +0300 | [diff] [blame] | 403 | intel_update_sprite_watermarks(plane, crtc, src_w, pixel_size, true, |
Ville Syrjälä | 67ca28f | 2013-07-05 11:57:14 +0300 | [diff] [blame] | 404 | src_w != crtc_w || src_h != crtc_h); |
| 405 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 406 | /* Sizes are 0 based */ |
| 407 | src_w--; |
| 408 | src_h--; |
| 409 | crtc_w--; |
| 410 | crtc_h--; |
| 411 | |
Ville Syrjälä | 8553c18 | 2013-12-05 15:51:39 +0200 | [diff] [blame] | 412 | if (crtc_w != src_w || crtc_h != src_h) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 413 | sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 414 | |
Chris Wilson | ca320ac | 2012-12-19 12:14:22 +0000 | [diff] [blame] | 415 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 416 | sprsurf_offset = |
Chris Wilson | bc75286 | 2013-02-21 20:04:31 +0000 | [diff] [blame] | 417 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
| 418 | pixel_size, fb->pitches[0]); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 419 | linear_offset -= sprsurf_offset; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 420 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 421 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
| 422 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 423 | intel_update_primary_plane(intel_crtc); |
| 424 | |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 425 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); |
| 426 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
| 427 | |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 428 | /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET |
| 429 | * register */ |
Paulo Zanoni | b3dc685 | 2013-11-02 21:07:33 -0700 | [diff] [blame] | 430 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 431 | I915_WRITE(SPROFFSET(pipe), (y << 16) | x); |
| 432 | else if (obj->tiling_mode != I915_TILING_NONE) |
| 433 | I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x); |
| 434 | else |
| 435 | I915_WRITE(SPRLINOFF(pipe), linear_offset); |
Damien Lespiau | c54173a | 2012-10-26 18:20:11 +0100 | [diff] [blame] | 436 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 437 | I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w); |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 438 | if (intel_plane->can_scale) |
| 439 | I915_WRITE(SPRSCALE(pipe), sprscale); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 440 | I915_WRITE(SPRCTL(pipe), sprctl); |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 441 | I915_WRITE(SPRSURF(pipe), |
| 442 | i915_gem_obj_ggtt_offset(obj) + sprsurf_offset); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 443 | |
| 444 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 445 | |
| 446 | if (atomic_update) |
| 447 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 451 | ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 452 | { |
| 453 | struct drm_device *dev = plane->dev; |
| 454 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 455 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 456 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 457 | int pipe = intel_plane->pipe; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 458 | u32 start_vbl_count; |
| 459 | bool atomic_update; |
| 460 | |
| 461 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 462 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 463 | intel_update_primary_plane(intel_crtc); |
| 464 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 465 | I915_WRITE(SPRCTL(pipe), I915_READ(SPRCTL(pipe)) & ~SPRITE_ENABLE); |
| 466 | /* Can't leave the scaler enabled... */ |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 467 | if (intel_plane->can_scale) |
| 468 | I915_WRITE(SPRSCALE(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 469 | /* Activate double buffered register update */ |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 470 | I915_WRITE(SPRSURF(pipe), 0); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 471 | |
| 472 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Chris Wilson | 828ed3e | 2012-04-18 17:12:26 +0100 | [diff] [blame] | 473 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 474 | if (atomic_update) |
| 475 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
| 476 | |
Ville Syrjälä | 1bd09ec | 2013-12-05 15:51:41 +0200 | [diff] [blame] | 477 | /* |
| 478 | * Avoid underruns when disabling the sprite. |
| 479 | * FIXME remove once watermark updates are done properly. |
| 480 | */ |
| 481 | intel_wait_for_vblank(dev, pipe); |
| 482 | |
Ville Syrjälä | adf3d35 | 2013-08-06 22:24:11 +0300 | [diff] [blame] | 483 | intel_update_sprite_watermarks(plane, crtc, 0, 0, false, false); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 484 | } |
| 485 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 486 | static int |
| 487 | ivb_update_colorkey(struct drm_plane *plane, |
| 488 | struct drm_intel_sprite_colorkey *key) |
| 489 | { |
| 490 | struct drm_device *dev = plane->dev; |
| 491 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 492 | struct intel_plane *intel_plane; |
| 493 | u32 sprctl; |
| 494 | int ret = 0; |
| 495 | |
| 496 | intel_plane = to_intel_plane(plane); |
| 497 | |
| 498 | I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value); |
| 499 | I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value); |
| 500 | I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask); |
| 501 | |
| 502 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
| 503 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); |
| 504 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 505 | sprctl |= SPRITE_DEST_KEY; |
| 506 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 507 | sprctl |= SPRITE_SOURCE_KEY; |
| 508 | I915_WRITE(SPRCTL(intel_plane->pipe), sprctl); |
| 509 | |
| 510 | POSTING_READ(SPRKEYMSK(intel_plane->pipe)); |
| 511 | |
| 512 | return ret; |
| 513 | } |
| 514 | |
| 515 | static void |
| 516 | ivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
| 517 | { |
| 518 | struct drm_device *dev = plane->dev; |
| 519 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 520 | struct intel_plane *intel_plane; |
| 521 | u32 sprctl; |
| 522 | |
| 523 | intel_plane = to_intel_plane(plane); |
| 524 | |
| 525 | key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe)); |
| 526 | key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe)); |
| 527 | key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe)); |
| 528 | key->flags = 0; |
| 529 | |
| 530 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
| 531 | |
| 532 | if (sprctl & SPRITE_DEST_KEY) |
| 533 | key->flags = I915_SET_COLORKEY_DESTINATION; |
| 534 | else if (sprctl & SPRITE_SOURCE_KEY) |
| 535 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 536 | else |
| 537 | key->flags = I915_SET_COLORKEY_NONE; |
| 538 | } |
| 539 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 540 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 541 | ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
| 542 | struct drm_framebuffer *fb, |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 543 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
| 544 | unsigned int crtc_w, unsigned int crtc_h, |
| 545 | uint32_t x, uint32_t y, |
| 546 | uint32_t src_w, uint32_t src_h) |
| 547 | { |
| 548 | struct drm_device *dev = plane->dev; |
| 549 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 550 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 551 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 552 | int pipe = intel_plane->pipe; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 553 | unsigned long dvssurf_offset, linear_offset; |
Chris Wilson | 8aaa81a | 2012-04-14 22:14:26 +0100 | [diff] [blame] | 554 | u32 dvscntr, dvsscale; |
Ville Syrjälä | 2bd3c3c | 2012-10-31 17:50:20 +0200 | [diff] [blame] | 555 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 556 | u32 start_vbl_count; |
| 557 | bool atomic_update; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 558 | |
| 559 | dvscntr = I915_READ(DVSCNTR(pipe)); |
| 560 | |
| 561 | /* Mask out pixel format bits in case we change it */ |
| 562 | dvscntr &= ~DVS_PIXFORMAT_MASK; |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 563 | dvscntr &= ~DVS_RGB_ORDER_XBGR; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 564 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; |
Ander Conselvan de Oliveira | 7962652 | 2012-07-13 15:50:33 +0300 | [diff] [blame] | 565 | dvscntr &= ~DVS_TILED; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 566 | |
| 567 | switch (fb->pixel_format) { |
| 568 | case DRM_FORMAT_XBGR8888: |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 569 | dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 570 | break; |
| 571 | case DRM_FORMAT_XRGB8888: |
Jesse Barnes | ab2f9df | 2012-02-27 12:40:10 -0800 | [diff] [blame] | 572 | dvscntr |= DVS_FORMAT_RGBX888; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 573 | break; |
| 574 | case DRM_FORMAT_YUYV: |
| 575 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 576 | break; |
| 577 | case DRM_FORMAT_YVYU: |
| 578 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 579 | break; |
| 580 | case DRM_FORMAT_UYVY: |
| 581 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 582 | break; |
| 583 | case DRM_FORMAT_VYUY: |
| 584 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 585 | break; |
| 586 | default: |
Ville Syrjälä | 28d491d | 2012-10-31 17:50:21 +0200 | [diff] [blame] | 587 | BUG(); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 588 | } |
| 589 | |
Ville Syrjälä | 4ea67bc | 2013-11-18 18:32:38 -0800 | [diff] [blame] | 590 | /* |
| 591 | * Enable gamma to match primary/cursor plane behaviour. |
| 592 | * FIXME should be user controllable via propertiesa. |
| 593 | */ |
| 594 | dvscntr |= DVS_GAMMA_ENABLE; |
| 595 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 596 | if (obj->tiling_mode != I915_TILING_NONE) |
| 597 | dvscntr |= DVS_TILED; |
| 598 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 599 | if (IS_GEN6(dev)) |
| 600 | dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */ |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 601 | dvscntr |= DVS_ENABLE; |
| 602 | |
Ville Syrjälä | adf3d35 | 2013-08-06 22:24:11 +0300 | [diff] [blame] | 603 | intel_update_sprite_watermarks(plane, crtc, src_w, pixel_size, true, |
Ville Syrjälä | 67ca28f | 2013-07-05 11:57:14 +0300 | [diff] [blame] | 604 | src_w != crtc_w || src_h != crtc_h); |
| 605 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 606 | /* Sizes are 0 based */ |
| 607 | src_w--; |
| 608 | src_h--; |
| 609 | crtc_w--; |
| 610 | crtc_h--; |
| 611 | |
Chris Wilson | 8aaa81a | 2012-04-14 22:14:26 +0100 | [diff] [blame] | 612 | dvsscale = 0; |
Ville Syrjälä | 8368f01 | 2013-12-05 15:51:31 +0200 | [diff] [blame] | 613 | if (crtc_w != src_w || crtc_h != src_h) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 614 | dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; |
| 615 | |
Chris Wilson | ca320ac | 2012-12-19 12:14:22 +0000 | [diff] [blame] | 616 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 617 | dvssurf_offset = |
Chris Wilson | bc75286 | 2013-02-21 20:04:31 +0000 | [diff] [blame] | 618 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
| 619 | pixel_size, fb->pitches[0]); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 620 | linear_offset -= dvssurf_offset; |
| 621 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 622 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
| 623 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 624 | intel_update_primary_plane(intel_crtc); |
| 625 | |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 626 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); |
| 627 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
| 628 | |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 629 | if (obj->tiling_mode != I915_TILING_NONE) |
| 630 | I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x); |
| 631 | else |
| 632 | I915_WRITE(DVSLINOFF(pipe), linear_offset); |
| 633 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 634 | I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); |
| 635 | I915_WRITE(DVSSCALE(pipe), dvsscale); |
| 636 | I915_WRITE(DVSCNTR(pipe), dvscntr); |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 637 | I915_WRITE(DVSSURF(pipe), |
| 638 | i915_gem_obj_ggtt_offset(obj) + dvssurf_offset); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 639 | |
| 640 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 641 | |
| 642 | if (atomic_update) |
| 643 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | static void |
Ville Syrjälä | b39d53f | 2013-08-06 22:24:09 +0300 | [diff] [blame] | 647 | ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 648 | { |
| 649 | struct drm_device *dev = plane->dev; |
| 650 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 651 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 652 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 653 | int pipe = intel_plane->pipe; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 654 | u32 start_vbl_count; |
| 655 | bool atomic_update; |
| 656 | |
| 657 | atomic_update = intel_pipe_update_start(intel_crtc, &start_vbl_count); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 658 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 659 | intel_update_primary_plane(intel_crtc); |
| 660 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 661 | I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE); |
| 662 | /* Disable the scaler */ |
| 663 | I915_WRITE(DVSSCALE(pipe), 0); |
| 664 | /* Flush double buffered register updates */ |
Daniel Vetter | 85ba7b7 | 2014-01-24 10:31:44 +0100 | [diff] [blame] | 665 | I915_WRITE(DVSSURF(pipe), 0); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 666 | |
| 667 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
Ville Syrjälä | a95fd8c | 2013-08-06 22:24:12 +0300 | [diff] [blame] | 668 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 669 | if (atomic_update) |
| 670 | intel_pipe_update_end(intel_crtc, start_vbl_count); |
| 671 | |
Ville Syrjälä | 1bd09ec | 2013-12-05 15:51:41 +0200 | [diff] [blame] | 672 | /* |
| 673 | * Avoid underruns when disabling the sprite. |
| 674 | * FIXME remove once watermark updates are done properly. |
| 675 | */ |
| 676 | intel_wait_for_vblank(dev, pipe); |
| 677 | |
Ville Syrjälä | a95fd8c | 2013-08-06 22:24:12 +0300 | [diff] [blame] | 678 | intel_update_sprite_watermarks(plane, crtc, 0, 0, false, false); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 679 | } |
| 680 | |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 681 | static void |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 682 | intel_post_enable_primary(struct drm_crtc *crtc) |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 683 | { |
| 684 | struct drm_device *dev = crtc->dev; |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 685 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Ville Syrjälä | abae50e | 2013-10-01 18:02:16 +0300 | [diff] [blame] | 686 | |
Ville Syrjälä | 20bc8673 | 2013-10-01 18:02:17 +0300 | [diff] [blame] | 687 | /* |
| 688 | * FIXME IPS should be fine as long as one plane is |
| 689 | * enabled, but in practice it seems to have problems |
| 690 | * when going from primary only to sprite only and vice |
| 691 | * versa. |
| 692 | */ |
| 693 | if (intel_crtc->config.ips_enabled) { |
| 694 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
| 695 | hsw_enable_ips(intel_crtc); |
| 696 | } |
| 697 | |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 698 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 93314b5 | 2012-06-13 17:36:55 +0100 | [diff] [blame] | 699 | intel_update_fbc(dev); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 700 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static void |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 704 | intel_pre_disable_primary(struct drm_crtc *crtc) |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 705 | { |
| 706 | struct drm_device *dev = crtc->dev; |
| 707 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 708 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 709 | |
| 710 | mutex_lock(&dev->struct_mutex); |
Ville Syrjälä | abae50e | 2013-10-01 18:02:16 +0300 | [diff] [blame] | 711 | if (dev_priv->fbc.plane == intel_crtc->plane) |
| 712 | intel_disable_fbc(dev); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 713 | mutex_unlock(&dev->struct_mutex); |
Ville Syrjälä | abae50e | 2013-10-01 18:02:16 +0300 | [diff] [blame] | 714 | |
Ville Syrjälä | 20bc8673 | 2013-10-01 18:02:17 +0300 | [diff] [blame] | 715 | /* |
| 716 | * FIXME IPS should be fine as long as one plane is |
| 717 | * enabled, but in practice it seems to have problems |
| 718 | * when going from primary only to sprite only and vice |
| 719 | * versa. |
| 720 | */ |
| 721 | hsw_disable_ips(intel_crtc); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 722 | } |
| 723 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 724 | static int |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 725 | ilk_update_colorkey(struct drm_plane *plane, |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 726 | struct drm_intel_sprite_colorkey *key) |
| 727 | { |
| 728 | struct drm_device *dev = plane->dev; |
| 729 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 730 | struct intel_plane *intel_plane; |
| 731 | u32 dvscntr; |
| 732 | int ret = 0; |
| 733 | |
| 734 | intel_plane = to_intel_plane(plane); |
| 735 | |
| 736 | I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value); |
| 737 | I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value); |
| 738 | I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask); |
| 739 | |
| 740 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
| 741 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); |
| 742 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 743 | dvscntr |= DVS_DEST_KEY; |
| 744 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 745 | dvscntr |= DVS_SOURCE_KEY; |
| 746 | I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr); |
| 747 | |
| 748 | POSTING_READ(DVSKEYMSK(intel_plane->pipe)); |
| 749 | |
| 750 | return ret; |
| 751 | } |
| 752 | |
| 753 | static void |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 754 | 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] | 755 | { |
| 756 | struct drm_device *dev = plane->dev; |
| 757 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 758 | struct intel_plane *intel_plane; |
| 759 | u32 dvscntr; |
| 760 | |
| 761 | intel_plane = to_intel_plane(plane); |
| 762 | |
| 763 | key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe)); |
| 764 | key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe)); |
| 765 | key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe)); |
| 766 | key->flags = 0; |
| 767 | |
| 768 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
| 769 | |
| 770 | if (dvscntr & DVS_DEST_KEY) |
| 771 | key->flags = I915_SET_COLORKEY_DESTINATION; |
| 772 | else if (dvscntr & DVS_SOURCE_KEY) |
| 773 | key->flags = I915_SET_COLORKEY_SOURCE; |
| 774 | else |
| 775 | key->flags = I915_SET_COLORKEY_NONE; |
| 776 | } |
| 777 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 778 | static bool |
| 779 | format_is_yuv(uint32_t format) |
| 780 | { |
| 781 | switch (format) { |
| 782 | case DRM_FORMAT_YUYV: |
| 783 | case DRM_FORMAT_UYVY: |
| 784 | case DRM_FORMAT_VYUY: |
| 785 | case DRM_FORMAT_YVYU: |
| 786 | return true; |
| 787 | default: |
| 788 | return false; |
| 789 | } |
| 790 | } |
| 791 | |
Ville Syrjälä | efb31d1 | 2013-12-05 15:51:40 +0200 | [diff] [blame] | 792 | static bool colorkey_enabled(struct intel_plane *intel_plane) |
| 793 | { |
| 794 | struct drm_intel_sprite_colorkey key; |
| 795 | |
| 796 | intel_plane->get_colorkey(&intel_plane->base, &key); |
| 797 | |
| 798 | return key.flags != I915_SET_COLORKEY_NONE; |
| 799 | } |
| 800 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 801 | static int |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 802 | intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
| 803 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
| 804 | unsigned int crtc_w, unsigned int crtc_h, |
| 805 | uint32_t src_x, uint32_t src_y, |
| 806 | uint32_t src_w, uint32_t src_h) |
| 807 | { |
| 808 | struct drm_device *dev = plane->dev; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 809 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 810 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 2afd9ef | 2013-10-01 18:02:14 +0300 | [diff] [blame] | 811 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
| 812 | struct drm_i915_gem_object *obj = intel_fb->obj; |
| 813 | struct drm_i915_gem_object *old_obj = intel_plane->obj; |
| 814 | int ret; |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 815 | bool primary_enabled; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 816 | bool visible; |
| 817 | int hscale, vscale; |
| 818 | int max_scale, min_scale; |
| 819 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
| 820 | struct drm_rect src = { |
| 821 | /* sample coordinates in 16.16 fixed point */ |
| 822 | .x1 = src_x, |
| 823 | .x2 = src_x + src_w, |
| 824 | .y1 = src_y, |
| 825 | .y2 = src_y + src_h, |
| 826 | }; |
| 827 | struct drm_rect dst = { |
| 828 | /* integer pixels */ |
| 829 | .x1 = crtc_x, |
| 830 | .x2 = crtc_x + crtc_w, |
| 831 | .y1 = crtc_y, |
| 832 | .y2 = crtc_y + crtc_h, |
| 833 | }; |
| 834 | const struct drm_rect clip = { |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 835 | .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, |
| 836 | .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0, |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 837 | }; |
Ville Syrjälä | 098ebd6 | 2013-10-01 18:02:15 +0300 | [diff] [blame] | 838 | const struct { |
| 839 | int crtc_x, crtc_y; |
| 840 | unsigned int crtc_w, crtc_h; |
| 841 | uint32_t src_x, src_y, src_w, src_h; |
| 842 | } orig = { |
| 843 | .crtc_x = crtc_x, |
| 844 | .crtc_y = crtc_y, |
| 845 | .crtc_w = crtc_w, |
| 846 | .crtc_h = crtc_h, |
| 847 | .src_x = src_x, |
| 848 | .src_y = src_y, |
| 849 | .src_w = src_w, |
| 850 | .src_h = src_h, |
| 851 | }; |
Jesse Barnes | 5e1bac2 | 2013-03-26 09:25:43 -0700 | [diff] [blame] | 852 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 853 | /* Don't modify another pipe's plane */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 854 | if (intel_plane->pipe != intel_crtc->pipe) { |
| 855 | DRM_DEBUG_KMS("Wrong plane <-> crtc mapping\n"); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 856 | return -EINVAL; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | /* FIXME check all gen limits */ |
| 860 | if (fb->width < 3 || fb->height < 3 || fb->pitches[0] > 16384) { |
| 861 | DRM_DEBUG_KMS("Unsuitable framebuffer for plane\n"); |
| 862 | return -EINVAL; |
| 863 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 864 | |
Damien Lespiau | 94c6419 | 2012-10-29 15:14:51 +0000 | [diff] [blame] | 865 | /* Sprite planes can be linear or x-tiled surfaces */ |
| 866 | switch (obj->tiling_mode) { |
| 867 | case I915_TILING_NONE: |
| 868 | case I915_TILING_X: |
| 869 | break; |
| 870 | default: |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 871 | DRM_DEBUG_KMS("Unsupported tiling mode\n"); |
Damien Lespiau | 94c6419 | 2012-10-29 15:14:51 +0000 | [diff] [blame] | 872 | return -EINVAL; |
| 873 | } |
| 874 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 875 | /* |
| 876 | * FIXME the following code does a bunch of fuzzy adjustments to the |
| 877 | * coordinates and sizes. We probably need some way to decide whether |
| 878 | * more strict checking should be done instead. |
| 879 | */ |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 880 | max_scale = intel_plane->max_downscale << 16; |
| 881 | min_scale = intel_plane->can_scale ? 1 : (1 << 16); |
| 882 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 883 | hscale = drm_rect_calc_hscale_relaxed(&src, &dst, min_scale, max_scale); |
| 884 | BUG_ON(hscale < 0); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 885 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 886 | vscale = drm_rect_calc_vscale_relaxed(&src, &dst, min_scale, max_scale); |
| 887 | BUG_ON(vscale < 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 888 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 889 | visible = drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 890 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 891 | crtc_x = dst.x1; |
| 892 | crtc_y = dst.y1; |
| 893 | crtc_w = drm_rect_width(&dst); |
| 894 | crtc_h = drm_rect_height(&dst); |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 895 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 896 | if (visible) { |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 897 | /* check again in case clipping clamped the results */ |
| 898 | hscale = drm_rect_calc_hscale(&src, &dst, min_scale, max_scale); |
| 899 | if (hscale < 0) { |
| 900 | DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n"); |
| 901 | drm_rect_debug_print(&src, true); |
| 902 | drm_rect_debug_print(&dst, false); |
| 903 | |
| 904 | return hscale; |
| 905 | } |
| 906 | |
| 907 | vscale = drm_rect_calc_vscale(&src, &dst, min_scale, max_scale); |
| 908 | if (vscale < 0) { |
| 909 | DRM_DEBUG_KMS("Vertical scaling factor out of limits\n"); |
| 910 | drm_rect_debug_print(&src, true); |
| 911 | drm_rect_debug_print(&dst, false); |
| 912 | |
| 913 | return vscale; |
| 914 | } |
| 915 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 916 | /* Make the source viewport size an exact multiple of the scaling factors. */ |
| 917 | drm_rect_adjust_size(&src, |
| 918 | drm_rect_width(&dst) * hscale - drm_rect_width(&src), |
| 919 | drm_rect_height(&dst) * vscale - drm_rect_height(&src)); |
| 920 | |
| 921 | /* sanity check to make sure the src viewport wasn't enlarged */ |
| 922 | WARN_ON(src.x1 < (int) src_x || |
| 923 | src.y1 < (int) src_y || |
| 924 | src.x2 > (int) (src_x + src_w) || |
| 925 | src.y2 > (int) (src_y + src_h)); |
| 926 | |
| 927 | /* |
| 928 | * Hardware doesn't handle subpixel coordinates. |
| 929 | * Adjust to (macro)pixel boundary, but be careful not to |
| 930 | * increase the source viewport size, because that could |
| 931 | * push the downscaling factor out of bounds. |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 932 | */ |
| 933 | src_x = src.x1 >> 16; |
| 934 | src_w = drm_rect_width(&src) >> 16; |
| 935 | src_y = src.y1 >> 16; |
| 936 | src_h = drm_rect_height(&src) >> 16; |
| 937 | |
| 938 | if (format_is_yuv(fb->pixel_format)) { |
| 939 | src_x &= ~1; |
| 940 | src_w &= ~1; |
| 941 | |
| 942 | /* |
| 943 | * Must keep src and dst the |
| 944 | * same if we can't scale. |
| 945 | */ |
| 946 | if (!intel_plane->can_scale) |
| 947 | crtc_w &= ~1; |
| 948 | |
| 949 | if (crtc_w == 0) |
| 950 | visible = false; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | /* Check size restrictions when scaling */ |
| 955 | if (visible && (src_w != crtc_w || src_h != crtc_h)) { |
| 956 | unsigned int width_bytes; |
| 957 | |
| 958 | WARN_ON(!intel_plane->can_scale); |
| 959 | |
| 960 | /* FIXME interlacing min height is 6 */ |
| 961 | |
| 962 | if (crtc_w < 3 || crtc_h < 3) |
| 963 | visible = false; |
| 964 | |
| 965 | if (src_w < 3 || src_h < 3) |
| 966 | visible = false; |
| 967 | |
| 968 | width_bytes = ((src_x * pixel_size) & 63) + src_w * pixel_size; |
| 969 | |
| 970 | if (src_w > 2048 || src_h > 2048 || |
| 971 | width_bytes > 4096 || fb->pitches[0] > 4096) { |
| 972 | DRM_DEBUG_KMS("Source dimensions exceed hardware limits\n"); |
| 973 | return -EINVAL; |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | dst.x1 = crtc_x; |
| 978 | dst.x2 = crtc_x + crtc_w; |
| 979 | dst.y1 = crtc_y; |
| 980 | dst.y2 = crtc_y + crtc_h; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 981 | |
| 982 | /* |
| 983 | * If the sprite is completely covering the primary plane, |
| 984 | * we can disable the primary and save power. |
| 985 | */ |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 986 | primary_enabled = !drm_rect_equals(&dst, &clip) || colorkey_enabled(intel_plane); |
| 987 | WARN_ON(!primary_enabled && !visible && intel_crtc->active); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 988 | |
| 989 | mutex_lock(&dev->struct_mutex); |
| 990 | |
Chris Wilson | 693db18 | 2013-03-05 14:52:39 +0000 | [diff] [blame] | 991 | /* Note that this will apply the VT-d workaround for scanouts, |
| 992 | * which is more restrictive than required for sprites. (The |
| 993 | * primary plane requires 256KiB alignment with 64 PTE padding, |
| 994 | * the sprite planes only require 128KiB alignment and 32 PTE padding. |
| 995 | */ |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 996 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 997 | |
| 998 | mutex_unlock(&dev->struct_mutex); |
| 999 | |
Jesse Barnes | 00c2064b | 2012-01-13 15:48:39 -0800 | [diff] [blame] | 1000 | if (ret) |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1001 | return ret; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1002 | |
Ville Syrjälä | 098ebd6 | 2013-10-01 18:02:15 +0300 | [diff] [blame] | 1003 | intel_plane->crtc_x = orig.crtc_x; |
| 1004 | intel_plane->crtc_y = orig.crtc_y; |
| 1005 | intel_plane->crtc_w = orig.crtc_w; |
| 1006 | intel_plane->crtc_h = orig.crtc_h; |
| 1007 | intel_plane->src_x = orig.src_x; |
| 1008 | intel_plane->src_y = orig.src_y; |
| 1009 | intel_plane->src_w = orig.src_w; |
| 1010 | intel_plane->src_h = orig.src_h; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1011 | intel_plane->obj = obj; |
| 1012 | |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1013 | if (intel_crtc->active) { |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 1014 | bool primary_was_enabled = intel_crtc->primary_enabled; |
| 1015 | |
| 1016 | intel_crtc->primary_enabled = primary_enabled; |
| 1017 | |
| 1018 | if (primary_was_enabled && !primary_enabled) |
| 1019 | intel_pre_disable_primary(crtc); |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 1020 | |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1021 | if (visible) |
| 1022 | intel_plane->update_plane(plane, crtc, fb, obj, |
| 1023 | crtc_x, crtc_y, crtc_w, crtc_h, |
| 1024 | src_x, src_y, src_w, src_h); |
| 1025 | else |
| 1026 | intel_plane->disable_plane(plane, crtc); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1027 | |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 1028 | if (!primary_was_enabled && primary_enabled) |
| 1029 | intel_post_enable_primary(crtc); |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1030 | } |
Jesse Barnes | 175bd42 | 2011-12-13 13:19:39 -0800 | [diff] [blame] | 1031 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1032 | /* Unpin old obj after new one is active to avoid ugliness */ |
| 1033 | if (old_obj) { |
| 1034 | /* |
| 1035 | * It's fairly common to simply update the position of |
| 1036 | * an existing object. In that case, we don't need to |
| 1037 | * wait for vblank to avoid ugliness, we only need to |
| 1038 | * do the pin & ref bookkeeping. |
| 1039 | */ |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1040 | if (old_obj != obj && intel_crtc->active) |
Ville Syrjälä | 2afd9ef | 2013-10-01 18:02:14 +0300 | [diff] [blame] | 1041 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1042 | |
| 1043 | mutex_lock(&dev->struct_mutex); |
Chris Wilson | 1690e1e | 2011-12-14 13:57:08 +0100 | [diff] [blame] | 1044 | intel_unpin_fb_obj(old_obj); |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1045 | mutex_unlock(&dev->struct_mutex); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1046 | } |
| 1047 | |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1048 | return 0; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | static int |
| 1052 | intel_disable_plane(struct drm_plane *plane) |
| 1053 | { |
| 1054 | struct drm_device *dev = plane->dev; |
| 1055 | struct intel_plane *intel_plane = to_intel_plane(plane); |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1056 | struct intel_crtc *intel_crtc; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1057 | |
Ville Syrjälä | 88a94a5 | 2013-08-07 13:30:23 +0300 | [diff] [blame] | 1058 | if (!plane->fb) |
| 1059 | return 0; |
| 1060 | |
| 1061 | if (WARN_ON(!plane->crtc)) |
| 1062 | return -EINVAL; |
| 1063 | |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1064 | intel_crtc = to_intel_crtc(plane->crtc); |
| 1065 | |
| 1066 | if (intel_crtc->active) { |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 1067 | bool primary_was_enabled = intel_crtc->primary_enabled; |
| 1068 | |
| 1069 | intel_crtc->primary_enabled = true; |
| 1070 | |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1071 | intel_plane->disable_plane(plane, plane->crtc); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame^] | 1072 | |
| 1073 | if (!primary_was_enabled && intel_crtc->primary_enabled) |
| 1074 | intel_post_enable_primary(plane->crtc); |
Ville Syrjälä | 03c5b25 | 2013-10-01 18:02:11 +0300 | [diff] [blame] | 1075 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1076 | |
Ville Syrjälä | 5f3fb46 | 2013-10-01 18:02:13 +0300 | [diff] [blame] | 1077 | if (intel_plane->obj) { |
| 1078 | if (intel_crtc->active) |
| 1079 | intel_wait_for_vblank(dev, intel_plane->pipe); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1080 | |
Ville Syrjälä | 5f3fb46 | 2013-10-01 18:02:13 +0300 | [diff] [blame] | 1081 | mutex_lock(&dev->struct_mutex); |
| 1082 | intel_unpin_fb_obj(intel_plane->obj); |
| 1083 | mutex_unlock(&dev->struct_mutex); |
Ville Syrjälä | c626d31 | 2013-03-27 17:49:13 +0200 | [diff] [blame] | 1084 | |
Ville Syrjälä | 5f3fb46 | 2013-10-01 18:02:13 +0300 | [diff] [blame] | 1085 | intel_plane->obj = NULL; |
| 1086 | } |
Ville Syrjälä | 82284b6 | 2013-10-01 18:02:12 +0300 | [diff] [blame] | 1087 | |
Ville Syrjälä | 5f3fb46 | 2013-10-01 18:02:13 +0300 | [diff] [blame] | 1088 | return 0; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | static void intel_destroy_plane(struct drm_plane *plane) |
| 1092 | { |
| 1093 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 1094 | intel_disable_plane(plane); |
| 1095 | drm_plane_cleanup(plane); |
| 1096 | kfree(intel_plane); |
| 1097 | } |
| 1098 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1099 | int intel_sprite_set_colorkey(struct drm_device *dev, void *data, |
| 1100 | struct drm_file *file_priv) |
| 1101 | { |
| 1102 | struct drm_intel_sprite_colorkey *set = data; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1103 | struct drm_mode_object *obj; |
| 1104 | struct drm_plane *plane; |
| 1105 | struct intel_plane *intel_plane; |
| 1106 | int ret = 0; |
| 1107 | |
Daniel Vetter | 1cff8f6 | 2012-04-24 09:55:08 +0200 | [diff] [blame] | 1108 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 1109 | return -ENODEV; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1110 | |
| 1111 | /* Make sure we don't try to enable both src & dest simultaneously */ |
| 1112 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
| 1113 | return -EINVAL; |
| 1114 | |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 1115 | drm_modeset_lock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1116 | |
| 1117 | obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE); |
| 1118 | if (!obj) { |
Ville Syrjälä | 3f2c205 | 2013-10-17 13:35:03 +0300 | [diff] [blame] | 1119 | ret = -ENOENT; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1120 | goto out_unlock; |
| 1121 | } |
| 1122 | |
| 1123 | plane = obj_to_plane(obj); |
| 1124 | intel_plane = to_intel_plane(plane); |
| 1125 | ret = intel_plane->update_colorkey(plane, set); |
| 1126 | |
| 1127 | out_unlock: |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 1128 | drm_modeset_unlock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1129 | return ret; |
| 1130 | } |
| 1131 | |
| 1132 | int intel_sprite_get_colorkey(struct drm_device *dev, void *data, |
| 1133 | struct drm_file *file_priv) |
| 1134 | { |
| 1135 | struct drm_intel_sprite_colorkey *get = data; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1136 | struct drm_mode_object *obj; |
| 1137 | struct drm_plane *plane; |
| 1138 | struct intel_plane *intel_plane; |
| 1139 | int ret = 0; |
| 1140 | |
Daniel Vetter | 1cff8f6 | 2012-04-24 09:55:08 +0200 | [diff] [blame] | 1141 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
| 1142 | return -ENODEV; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1143 | |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 1144 | drm_modeset_lock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1145 | |
| 1146 | obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE); |
| 1147 | if (!obj) { |
Ville Syrjälä | 3f2c205 | 2013-10-17 13:35:03 +0300 | [diff] [blame] | 1148 | ret = -ENOENT; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1149 | goto out_unlock; |
| 1150 | } |
| 1151 | |
| 1152 | plane = obj_to_plane(obj); |
| 1153 | intel_plane = to_intel_plane(plane); |
| 1154 | intel_plane->get_colorkey(plane, get); |
| 1155 | |
| 1156 | out_unlock: |
Daniel Vetter | a0e99e6 | 2012-12-02 01:05:46 +0100 | [diff] [blame] | 1157 | drm_modeset_unlock_all(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1158 | return ret; |
| 1159 | } |
| 1160 | |
Jesse Barnes | 5e1bac2 | 2013-03-26 09:25:43 -0700 | [diff] [blame] | 1161 | void intel_plane_restore(struct drm_plane *plane) |
| 1162 | { |
| 1163 | struct intel_plane *intel_plane = to_intel_plane(plane); |
| 1164 | |
| 1165 | if (!plane->crtc || !plane->fb) |
| 1166 | return; |
| 1167 | |
| 1168 | intel_update_plane(plane, plane->crtc, plane->fb, |
| 1169 | intel_plane->crtc_x, intel_plane->crtc_y, |
| 1170 | intel_plane->crtc_w, intel_plane->crtc_h, |
| 1171 | intel_plane->src_x, intel_plane->src_y, |
| 1172 | intel_plane->src_w, intel_plane->src_h); |
| 1173 | } |
| 1174 | |
Ville Syrjälä | bb53d4a | 2013-06-04 13:49:04 +0300 | [diff] [blame] | 1175 | void intel_plane_disable(struct drm_plane *plane) |
| 1176 | { |
| 1177 | if (!plane->crtc || !plane->fb) |
| 1178 | return; |
| 1179 | |
| 1180 | intel_disable_plane(plane); |
| 1181 | } |
| 1182 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1183 | static const struct drm_plane_funcs intel_plane_funcs = { |
| 1184 | .update_plane = intel_update_plane, |
| 1185 | .disable_plane = intel_disable_plane, |
| 1186 | .destroy = intel_destroy_plane, |
| 1187 | }; |
| 1188 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1189 | static uint32_t ilk_plane_formats[] = { |
| 1190 | DRM_FORMAT_XRGB8888, |
| 1191 | DRM_FORMAT_YUYV, |
| 1192 | DRM_FORMAT_YVYU, |
| 1193 | DRM_FORMAT_UYVY, |
| 1194 | DRM_FORMAT_VYUY, |
| 1195 | }; |
| 1196 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1197 | static uint32_t snb_plane_formats[] = { |
| 1198 | DRM_FORMAT_XBGR8888, |
| 1199 | DRM_FORMAT_XRGB8888, |
| 1200 | DRM_FORMAT_YUYV, |
| 1201 | DRM_FORMAT_YVYU, |
| 1202 | DRM_FORMAT_UYVY, |
| 1203 | DRM_FORMAT_VYUY, |
| 1204 | }; |
| 1205 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1206 | static uint32_t vlv_plane_formats[] = { |
| 1207 | DRM_FORMAT_RGB565, |
| 1208 | DRM_FORMAT_ABGR8888, |
| 1209 | DRM_FORMAT_ARGB8888, |
| 1210 | DRM_FORMAT_XBGR8888, |
| 1211 | DRM_FORMAT_XRGB8888, |
| 1212 | DRM_FORMAT_XBGR2101010, |
| 1213 | DRM_FORMAT_ABGR2101010, |
| 1214 | DRM_FORMAT_YUYV, |
| 1215 | DRM_FORMAT_YVYU, |
| 1216 | DRM_FORMAT_UYVY, |
| 1217 | DRM_FORMAT_VYUY, |
| 1218 | }; |
| 1219 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1220 | int |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1221 | intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1222 | { |
| 1223 | struct intel_plane *intel_plane; |
| 1224 | unsigned long possible_crtcs; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1225 | const uint32_t *plane_formats; |
| 1226 | int num_plane_formats; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1227 | int ret; |
| 1228 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1229 | if (INTEL_INFO(dev)->gen < 5) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1230 | return -ENODEV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1231 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 1232 | intel_plane = kzalloc(sizeof(*intel_plane), GFP_KERNEL); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1233 | if (!intel_plane) |
| 1234 | return -ENOMEM; |
| 1235 | |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1236 | switch (INTEL_INFO(dev)->gen) { |
| 1237 | case 5: |
| 1238 | case 6: |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 1239 | intel_plane->can_scale = true; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1240 | intel_plane->max_downscale = 16; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1241 | intel_plane->update_plane = ilk_update_plane; |
| 1242 | intel_plane->disable_plane = ilk_disable_plane; |
| 1243 | intel_plane->update_colorkey = ilk_update_colorkey; |
| 1244 | intel_plane->get_colorkey = ilk_get_colorkey; |
| 1245 | |
| 1246 | if (IS_GEN6(dev)) { |
| 1247 | plane_formats = snb_plane_formats; |
| 1248 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
| 1249 | } else { |
| 1250 | plane_formats = ilk_plane_formats; |
| 1251 | num_plane_formats = ARRAY_SIZE(ilk_plane_formats); |
| 1252 | } |
| 1253 | break; |
| 1254 | |
| 1255 | case 7: |
Ben Widawsky | 4e0bbc3 | 2013-11-02 21:07:07 -0700 | [diff] [blame] | 1256 | case 8: |
Damien Lespiau | d49f709 | 2013-04-25 15:15:00 +0100 | [diff] [blame] | 1257 | if (IS_IVYBRIDGE(dev)) { |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 1258 | intel_plane->can_scale = true; |
Damien Lespiau | d49f709 | 2013-04-25 15:15:00 +0100 | [diff] [blame] | 1259 | intel_plane->max_downscale = 2; |
| 1260 | } else { |
| 1261 | intel_plane->can_scale = false; |
| 1262 | intel_plane->max_downscale = 1; |
| 1263 | } |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1264 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1265 | if (IS_VALLEYVIEW(dev)) { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1266 | intel_plane->update_plane = vlv_update_plane; |
| 1267 | intel_plane->disable_plane = vlv_disable_plane; |
| 1268 | intel_plane->update_colorkey = vlv_update_colorkey; |
| 1269 | intel_plane->get_colorkey = vlv_get_colorkey; |
| 1270 | |
| 1271 | plane_formats = vlv_plane_formats; |
| 1272 | num_plane_formats = ARRAY_SIZE(vlv_plane_formats); |
| 1273 | } else { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1274 | intel_plane->update_plane = ivb_update_plane; |
| 1275 | intel_plane->disable_plane = ivb_disable_plane; |
| 1276 | intel_plane->update_colorkey = ivb_update_colorkey; |
| 1277 | intel_plane->get_colorkey = ivb_get_colorkey; |
| 1278 | |
| 1279 | plane_formats = snb_plane_formats; |
| 1280 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
| 1281 | } |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1282 | break; |
| 1283 | |
| 1284 | default: |
Jesper Juhl | a8b0bba | 2012-06-27 00:55:37 +0200 | [diff] [blame] | 1285 | kfree(intel_plane); |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1286 | return -ENODEV; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1287 | } |
| 1288 | |
| 1289 | intel_plane->pipe = pipe; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1290 | intel_plane->plane = plane; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1291 | possible_crtcs = (1 << pipe); |
| 1292 | ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs, |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1293 | &intel_plane_funcs, |
| 1294 | plane_formats, num_plane_formats, |
| 1295 | false); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1296 | if (ret) |
| 1297 | kfree(intel_plane); |
| 1298 | |
| 1299 | return ret; |
| 1300 | } |