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