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> |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 33 | #include <drm/drm_atomic_helper.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 34 | #include <drm/drm_crtc.h> |
| 35 | #include <drm/drm_fourcc.h> |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 36 | #include <drm/drm_rect.h> |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 37 | #include <drm/drm_atomic.h> |
Matt Roper | ea2c67b | 2014-12-23 10:41:52 -0800 | [diff] [blame] | 38 | #include <drm/drm_plane_helper.h> |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 39 | #include "intel_drv.h" |
Chris Wilson | 5d723d7 | 2016-08-04 16:32:35 +0100 | [diff] [blame] | 40 | #include "intel_frontbuffer.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 41 | #include <drm/i915_drm.h> |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 42 | #include "i915_drv.h" |
| 43 | |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 44 | static bool |
| 45 | format_is_yuv(uint32_t format) |
| 46 | { |
| 47 | switch (format) { |
| 48 | case DRM_FORMAT_YUYV: |
| 49 | case DRM_FORMAT_UYVY: |
| 50 | case DRM_FORMAT_VYUY: |
| 51 | case DRM_FORMAT_YVYU: |
| 52 | return true; |
| 53 | default: |
| 54 | return false; |
| 55 | } |
| 56 | } |
| 57 | |
Ville Syrjälä | dfd2e9a | 2016-05-18 11:34:38 +0300 | [diff] [blame] | 58 | int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode, |
| 59 | int usecs) |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 60 | { |
| 61 | /* paranoia */ |
Ville Syrjälä | 5e7234c | 2015-09-25 16:37:43 +0300 | [diff] [blame] | 62 | if (!adjusted_mode->crtc_htotal) |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 63 | return 1; |
| 64 | |
Ville Syrjälä | 5e7234c | 2015-09-25 16:37:43 +0300 | [diff] [blame] | 65 | return DIV_ROUND_UP(usecs * adjusted_mode->crtc_clock, |
| 66 | 1000 * adjusted_mode->crtc_htotal); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 67 | } |
| 68 | |
Maarten Lankhorst | e1edbd4 | 2017-02-28 15:28:48 +0100 | [diff] [blame] | 69 | #define VBLANK_EVASION_TIME_US 100 |
| 70 | |
Ander Conselvan de Oliveira | 26ff276 | 2014-10-28 15:10:12 +0200 | [diff] [blame] | 71 | /** |
| 72 | * intel_pipe_update_start() - start update of a set of display registers |
| 73 | * @crtc: the crtc of which the registers are going to be updated |
| 74 | * @start_vbl_count: vblank counter return pointer used for error checking |
| 75 | * |
| 76 | * Mark the start of an update to pipe registers that should be updated |
| 77 | * atomically regarding vblank. If the next vblank will happens within |
| 78 | * the next 100 us, this function waits until the vblank passes. |
| 79 | * |
| 80 | * After a successful call to this function, interrupts will be disabled |
| 81 | * until a subsequent call to intel_pipe_update_end(). That is done to |
| 82 | * avoid random delays. The value written to @start_vbl_count should be |
| 83 | * supplied to intel_pipe_update_end() for error checking. |
Ander Conselvan de Oliveira | 26ff276 | 2014-10-28 15:10:12 +0200 | [diff] [blame] | 84 | */ |
Maarten Lankhorst | 34e0adb | 2015-08-31 13:04:25 +0200 | [diff] [blame] | 85 | void intel_pipe_update_start(struct intel_crtc *crtc) |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 86 | { |
Ville Syrjälä | ec1b4ee | 2016-12-15 19:47:34 +0200 | [diff] [blame] | 87 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Ville Syrjälä | 124abe0 | 2015-09-08 13:40:45 +0300 | [diff] [blame] | 88 | const struct drm_display_mode *adjusted_mode = &crtc->config->base.adjusted_mode; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 89 | long timeout = msecs_to_jiffies_timeout(1); |
| 90 | int scanline, min, max, vblank_start; |
Ville Syrjälä | 210871b6 | 2014-05-22 19:00:50 +0300 | [diff] [blame] | 91 | wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); |
Ville Syrjälä | ec1b4ee | 2016-12-15 19:47:34 +0200 | [diff] [blame] | 92 | bool need_vlv_dsi_wa = (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
| 93 | intel_crtc_has_type(crtc->config, INTEL_OUTPUT_DSI); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 94 | DEFINE_WAIT(wait); |
| 95 | |
Ville Syrjälä | 124abe0 | 2015-09-08 13:40:45 +0300 | [diff] [blame] | 96 | vblank_start = adjusted_mode->crtc_vblank_start; |
| 97 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 98 | vblank_start = DIV_ROUND_UP(vblank_start, 2); |
| 99 | |
| 100 | /* FIXME needs to be calibrated sensibly */ |
Maarten Lankhorst | e1edbd4 | 2017-02-28 15:28:48 +0100 | [diff] [blame] | 101 | min = vblank_start - intel_usecs_to_scanlines(adjusted_mode, |
| 102 | VBLANK_EVASION_TIME_US); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 103 | max = vblank_start - 1; |
| 104 | |
Maarten Lankhorst | 8f539a83 | 2015-07-13 16:30:32 +0200 | [diff] [blame] | 105 | local_irq_disable(); |
Maarten Lankhorst | 8f539a83 | 2015-07-13 16:30:32 +0200 | [diff] [blame] | 106 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 107 | if (min <= 0 || max <= 0) |
Maarten Lankhorst | 8f539a83 | 2015-07-13 16:30:32 +0200 | [diff] [blame] | 108 | return; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 109 | |
Daniel Vetter | 1e3feef | 2015-02-13 21:03:45 +0100 | [diff] [blame] | 110 | if (WARN_ON(drm_crtc_vblank_get(&crtc->base))) |
Maarten Lankhorst | 8f539a83 | 2015-07-13 16:30:32 +0200 | [diff] [blame] | 111 | return; |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 112 | |
Jesse Barnes | d637ce3 | 2015-09-17 08:08:32 -0700 | [diff] [blame] | 113 | crtc->debug.min_vbl = min; |
| 114 | crtc->debug.max_vbl = max; |
| 115 | trace_i915_pipe_update_start(crtc); |
Ville Syrjälä | 25ef284 | 2014-04-29 13:35:48 +0300 | [diff] [blame] | 116 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 117 | for (;;) { |
| 118 | /* |
| 119 | * prepare_to_wait() has a memory barrier, which guarantees |
| 120 | * other CPUs can see the task state update by the time we |
| 121 | * read the scanline. |
| 122 | */ |
Ville Syrjälä | 210871b6 | 2014-05-22 19:00:50 +0300 | [diff] [blame] | 123 | prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 124 | |
| 125 | scanline = intel_get_crtc_scanline(crtc); |
| 126 | if (scanline < min || scanline > max) |
| 127 | break; |
| 128 | |
| 129 | if (timeout <= 0) { |
| 130 | DRM_ERROR("Potential atomic update failure on pipe %c\n", |
| 131 | pipe_name(crtc->pipe)); |
| 132 | break; |
| 133 | } |
| 134 | |
| 135 | local_irq_enable(); |
| 136 | |
| 137 | timeout = schedule_timeout(timeout); |
| 138 | |
| 139 | local_irq_disable(); |
| 140 | } |
| 141 | |
Ville Syrjälä | 210871b6 | 2014-05-22 19:00:50 +0300 | [diff] [blame] | 142 | finish_wait(wq, &wait); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 143 | |
Daniel Vetter | 1e3feef | 2015-02-13 21:03:45 +0100 | [diff] [blame] | 144 | drm_crtc_vblank_put(&crtc->base); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 145 | |
Ville Syrjälä | ec1b4ee | 2016-12-15 19:47:34 +0200 | [diff] [blame] | 146 | /* |
| 147 | * On VLV/CHV DSI the scanline counter would appear to |
| 148 | * increment approx. 1/3 of a scanline before start of vblank. |
| 149 | * The registers still get latched at start of vblank however. |
| 150 | * This means we must not write any registers on the first |
| 151 | * line of vblank (since not the whole line is actually in |
| 152 | * vblank). And unfortunately we can't use the interrupt to |
| 153 | * wait here since it will fire too soon. We could use the |
| 154 | * frame start interrupt instead since it will fire after the |
| 155 | * critical scanline, but that would require more changes |
| 156 | * in the interrupt code. So for now we'll just do the nasty |
| 157 | * thing and poll for the bad scanline to pass us by. |
| 158 | * |
| 159 | * FIXME figure out if BXT+ DSI suffers from this as well |
| 160 | */ |
| 161 | while (need_vlv_dsi_wa && scanline == vblank_start) |
| 162 | scanline = intel_get_crtc_scanline(crtc); |
| 163 | |
Jesse Barnes | eb120ef | 2015-09-15 14:19:32 -0700 | [diff] [blame] | 164 | crtc->debug.scanline_start = scanline; |
| 165 | crtc->debug.start_vbl_time = ktime_get(); |
Maarten Lankhorst | a299141 | 2016-05-17 15:07:48 +0200 | [diff] [blame] | 166 | crtc->debug.start_vbl_count = intel_crtc_get_vblank_counter(crtc); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 167 | |
Jesse Barnes | d637ce3 | 2015-09-17 08:08:32 -0700 | [diff] [blame] | 168 | trace_i915_pipe_update_vblank_evaded(crtc); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 169 | } |
| 170 | |
Ander Conselvan de Oliveira | 26ff276 | 2014-10-28 15:10:12 +0200 | [diff] [blame] | 171 | /** |
| 172 | * intel_pipe_update_end() - end update of a set of display registers |
| 173 | * @crtc: the crtc of which the registers were updated |
| 174 | * @start_vbl_count: start vblank counter (used for error checking) |
| 175 | * |
| 176 | * Mark the end of an update started with intel_pipe_update_start(). This |
| 177 | * re-enables interrupts and verifies the update was actually completed |
| 178 | * before a vblank using the value of @start_vbl_count. |
| 179 | */ |
Daniel Vetter | 8b5d27b | 2017-07-20 19:57:53 +0200 | [diff] [blame] | 180 | void intel_pipe_update_end(struct intel_crtc *crtc) |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 181 | { |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 182 | enum pipe pipe = crtc->pipe; |
Jesse Barnes | eb120ef | 2015-09-15 14:19:32 -0700 | [diff] [blame] | 183 | int scanline_end = intel_get_crtc_scanline(crtc); |
Maarten Lankhorst | a299141 | 2016-05-17 15:07:48 +0200 | [diff] [blame] | 184 | u32 end_vbl_count = intel_crtc_get_vblank_counter(crtc); |
Maarten Lankhorst | 85a62bf | 2015-09-01 12:15:33 +0200 | [diff] [blame] | 185 | ktime_t end_vbl_time = ktime_get(); |
Bing Niu | a94f2b9 | 2017-03-08 15:14:03 -0500 | [diff] [blame] | 186 | struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 187 | |
Jesse Barnes | d637ce3 | 2015-09-17 08:08:32 -0700 | [diff] [blame] | 188 | trace_i915_pipe_update_end(crtc, end_vbl_count, scanline_end); |
Ville Syrjälä | 25ef284 | 2014-04-29 13:35:48 +0300 | [diff] [blame] | 189 | |
Daniel Vetter | 1f7528c | 2016-06-13 16:13:45 +0200 | [diff] [blame] | 190 | /* We're still in the vblank-evade critical section, this can't race. |
| 191 | * Would be slightly nice to just grab the vblank count and arm the |
| 192 | * event outside of the critical section - the spinlock might spin for a |
| 193 | * while ... */ |
| 194 | if (crtc->base.state->event) { |
| 195 | WARN_ON(drm_crtc_vblank_get(&crtc->base) != 0); |
| 196 | |
| 197 | spin_lock(&crtc->base.dev->event_lock); |
| 198 | drm_crtc_arm_vblank_event(&crtc->base, crtc->base.state->event); |
| 199 | spin_unlock(&crtc->base.dev->event_lock); |
| 200 | |
| 201 | crtc->base.state->event = NULL; |
| 202 | } |
| 203 | |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 204 | local_irq_enable(); |
| 205 | |
Bing Niu | a94f2b9 | 2017-03-08 15:14:03 -0500 | [diff] [blame] | 206 | if (intel_vgpu_active(dev_priv)) |
| 207 | return; |
| 208 | |
Jesse Barnes | eb120ef | 2015-09-15 14:19:32 -0700 | [diff] [blame] | 209 | if (crtc->debug.start_vbl_count && |
| 210 | crtc->debug.start_vbl_count != end_vbl_count) { |
| 211 | DRM_ERROR("Atomic update failure on pipe %c (start=%u end=%u) time %lld us, min %d, max %d, scanline start %d, end %d\n", |
| 212 | pipe_name(pipe), crtc->debug.start_vbl_count, |
| 213 | end_vbl_count, |
| 214 | ktime_us_delta(end_vbl_time, crtc->debug.start_vbl_time), |
| 215 | crtc->debug.min_vbl, crtc->debug.max_vbl, |
| 216 | crtc->debug.scanline_start, scanline_end); |
Ville Syrjälä | 7b8cd33 | 2017-05-07 20:12:52 +0300 | [diff] [blame] | 217 | } |
| 218 | #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE |
| 219 | else if (ktime_us_delta(end_vbl_time, crtc->debug.start_vbl_time) > |
| 220 | VBLANK_EVASION_TIME_US) |
Maarten Lankhorst | e1edbd4 | 2017-02-28 15:28:48 +0100 | [diff] [blame] | 221 | DRM_WARN("Atomic update on pipe (%c) took %lld us, max time under evasion is %u us\n", |
| 222 | pipe_name(pipe), |
| 223 | ktime_us_delta(end_vbl_time, crtc->debug.start_vbl_time), |
| 224 | VBLANK_EVASION_TIME_US); |
Ville Syrjälä | 7b8cd33 | 2017-05-07 20:12:52 +0300 | [diff] [blame] | 225 | #endif |
Ville Syrjälä | 8d7849d | 2014-04-29 13:35:46 +0300 | [diff] [blame] | 226 | } |
| 227 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 228 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 229 | skl_update_plane(struct intel_plane *plane, |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 230 | const struct intel_crtc_state *crtc_state, |
| 231 | const struct intel_plane_state *plane_state) |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 232 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 233 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 234 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 235 | enum plane_id plane_id = plane->id; |
| 236 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 237 | u32 plane_ctl = plane_state->ctl; |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 238 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
Ville Syrjälä | b63a16f | 2016-01-28 16:53:54 +0200 | [diff] [blame] | 239 | u32 surf_addr = plane_state->main.offset; |
Ville Syrjälä | 8d0deca | 2016-02-15 22:54:41 +0200 | [diff] [blame] | 240 | unsigned int rotation = plane_state->base.rotation; |
Ville Syrjälä | d219677 | 2016-01-28 18:33:11 +0200 | [diff] [blame] | 241 | u32 stride = skl_plane_stride(fb, 0, rotation); |
Ville Syrjälä | 2e2adb0 | 2017-08-01 09:58:13 -0700 | [diff] [blame] | 242 | u32 aux_stride = skl_plane_stride(fb, 1, rotation); |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 243 | int crtc_x = plane_state->base.dst.x1; |
| 244 | int crtc_y = plane_state->base.dst.y1; |
| 245 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); |
| 246 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); |
Ville Syrjälä | b63a16f | 2016-01-28 16:53:54 +0200 | [diff] [blame] | 247 | uint32_t x = plane_state->main.x; |
| 248 | uint32_t y = plane_state->main.y; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 249 | uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; |
| 250 | uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 251 | unsigned long irqflags; |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 252 | |
Ville Syrjälä | 6687c90 | 2015-09-15 13:16:41 +0300 | [diff] [blame] | 253 | /* Sizes are 0 based */ |
| 254 | src_w--; |
| 255 | src_h--; |
| 256 | crtc_w--; |
| 257 | crtc_h--; |
| 258 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 259 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 260 | |
Rodrigo Vivi | 6602be0 | 2017-07-06 14:01:13 -0700 | [diff] [blame] | 261 | if (IS_GEMINILAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 262 | I915_WRITE_FW(PLANE_COLOR_CTL(pipe, plane_id), |
| 263 | PLANE_COLOR_PIPE_GAMMA_ENABLE | |
| 264 | PLANE_COLOR_PIPE_CSC_ENABLE | |
| 265 | PLANE_COLOR_PLANE_GAMMA_DISABLE); |
Ville Syrjälä | 78587de | 2017-03-09 17:44:32 +0200 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | if (key->flags) { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 269 | I915_WRITE_FW(PLANE_KEYVAL(pipe, plane_id), key->min_value); |
| 270 | I915_WRITE_FW(PLANE_KEYMAX(pipe, plane_id), key->max_value); |
| 271 | I915_WRITE_FW(PLANE_KEYMSK(pipe, plane_id), key->channel_mask); |
Ville Syrjälä | 78587de | 2017-03-09 17:44:32 +0200 | [diff] [blame] | 272 | } |
| 273 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 274 | I915_WRITE_FW(PLANE_OFFSET(pipe, plane_id), (y << 16) | x); |
| 275 | I915_WRITE_FW(PLANE_STRIDE(pipe, plane_id), stride); |
| 276 | I915_WRITE_FW(PLANE_SIZE(pipe, plane_id), (src_h << 16) | src_w); |
Ville Syrjälä | 2e2adb0 | 2017-08-01 09:58:13 -0700 | [diff] [blame] | 277 | I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id), |
| 278 | (plane_state->aux.offset - surf_addr) | aux_stride); |
| 279 | I915_WRITE_FW(PLANE_AUX_OFFSET(pipe, plane_id), |
| 280 | (plane_state->aux.y << 16) | plane_state->aux.x); |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 281 | |
| 282 | /* program plane scaler */ |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 283 | if (plane_state->scaler_id >= 0) { |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 284 | int scaler_id = plane_state->scaler_id; |
Imre Deak | 7494bcd | 2016-05-12 16:18:49 +0300 | [diff] [blame] | 285 | const struct intel_scaler *scaler; |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 286 | |
Imre Deak | 7494bcd | 2016-05-12 16:18:49 +0300 | [diff] [blame] | 287 | scaler = &crtc_state->scaler_state.scalers[scaler_id]; |
| 288 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 289 | I915_WRITE_FW(SKL_PS_CTRL(pipe, scaler_id), |
| 290 | PS_SCALER_EN | PS_PLANE_SEL(plane_id) | scaler->mode); |
| 291 | I915_WRITE_FW(SKL_PS_PWR_GATE(pipe, scaler_id), 0); |
| 292 | I915_WRITE_FW(SKL_PS_WIN_POS(pipe, scaler_id), (crtc_x << 16) | crtc_y); |
| 293 | I915_WRITE_FW(SKL_PS_WIN_SZ(pipe, scaler_id), |
| 294 | ((crtc_w + 1) << 16)|(crtc_h + 1)); |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 295 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 296 | I915_WRITE_FW(PLANE_POS(pipe, plane_id), 0); |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 297 | } else { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 298 | I915_WRITE_FW(PLANE_POS(pipe, plane_id), (crtc_y << 16) | crtc_x); |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 301 | I915_WRITE_FW(PLANE_CTL(pipe, plane_id), plane_ctl); |
| 302 | I915_WRITE_FW(PLANE_SURF(pipe, plane_id), |
| 303 | intel_plane_ggtt_offset(plane_state) + surf_addr); |
| 304 | POSTING_READ_FW(PLANE_SURF(pipe, plane_id)); |
| 305 | |
| 306 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 310 | skl_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 311 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 312 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 313 | enum plane_id plane_id = plane->id; |
| 314 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 315 | unsigned long irqflags; |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 316 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 317 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 318 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 319 | I915_WRITE_FW(PLANE_CTL(pipe, plane_id), 0); |
| 320 | |
| 321 | I915_WRITE_FW(PLANE_SURF(pipe, plane_id), 0); |
| 322 | POSTING_READ_FW(PLANE_SURF(pipe, plane_id)); |
| 323 | |
| 324 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 327 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 328 | chv_update_csc(struct intel_plane *plane, uint32_t format) |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 329 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 330 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 331 | enum plane_id plane_id = plane->id; |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 332 | |
| 333 | /* Seems RGB data bypasses the CSC always */ |
| 334 | if (!format_is_yuv(format)) |
| 335 | return; |
| 336 | |
| 337 | /* |
| 338 | * BT.601 limited range YCbCr -> full range RGB |
| 339 | * |
| 340 | * |r| | 6537 4769 0| |cr | |
| 341 | * |g| = |-3330 4769 -1605| x |y-64| |
| 342 | * |b| | 0 4769 8263| |cb | |
| 343 | * |
| 344 | * Cb and Cr apparently come in as signed already, so no |
| 345 | * need for any offset. For Y we need to remove the offset. |
| 346 | */ |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 347 | I915_WRITE_FW(SPCSCYGOFF(plane_id), SPCSC_OOFF(0) | SPCSC_IOFF(-64)); |
| 348 | I915_WRITE_FW(SPCSCCBOFF(plane_id), SPCSC_OOFF(0) | SPCSC_IOFF(0)); |
| 349 | I915_WRITE_FW(SPCSCCROFF(plane_id), SPCSC_OOFF(0) | SPCSC_IOFF(0)); |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 350 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 351 | I915_WRITE_FW(SPCSCC01(plane_id), SPCSC_C1(4769) | SPCSC_C0(6537)); |
| 352 | I915_WRITE_FW(SPCSCC23(plane_id), SPCSC_C1(-3330) | SPCSC_C0(0)); |
| 353 | I915_WRITE_FW(SPCSCC45(plane_id), SPCSC_C1(-1605) | SPCSC_C0(4769)); |
| 354 | I915_WRITE_FW(SPCSCC67(plane_id), SPCSC_C1(4769) | SPCSC_C0(0)); |
| 355 | I915_WRITE_FW(SPCSCC8(plane_id), SPCSC_C0(8263)); |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 356 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 357 | I915_WRITE_FW(SPCSCYGICLAMP(plane_id), SPCSC_IMAX(940) | SPCSC_IMIN(64)); |
| 358 | I915_WRITE_FW(SPCSCCBICLAMP(plane_id), SPCSC_IMAX(448) | SPCSC_IMIN(-448)); |
| 359 | I915_WRITE_FW(SPCSCCRICLAMP(plane_id), SPCSC_IMAX(448) | SPCSC_IMIN(-448)); |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 360 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 361 | I915_WRITE_FW(SPCSCYGOCLAMP(plane_id), SPCSC_OMAX(1023) | SPCSC_OMIN(0)); |
| 362 | I915_WRITE_FW(SPCSCCBOCLAMP(plane_id), SPCSC_OMAX(1023) | SPCSC_OMIN(0)); |
| 363 | I915_WRITE_FW(SPCSCCROCLAMP(plane_id), SPCSC_OMAX(1023) | SPCSC_OMIN(0)); |
Ville Syrjälä | 6ca2aeb | 2014-10-20 19:47:53 +0300 | [diff] [blame] | 364 | } |
| 365 | |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 366 | static u32 vlv_sprite_ctl(const struct intel_crtc_state *crtc_state, |
| 367 | const struct intel_plane_state *plane_state) |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 368 | { |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 369 | const struct drm_framebuffer *fb = plane_state->base.fb; |
Ville Syrjälä | 11df4d9 | 2016-11-07 22:20:55 +0200 | [diff] [blame] | 370 | unsigned int rotation = plane_state->base.rotation; |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 371 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 372 | u32 sprctl; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 373 | |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 374 | sprctl = SP_ENABLE | SP_GAMMA_ENABLE; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 375 | |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 376 | switch (fb->format->format) { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 377 | case DRM_FORMAT_YUYV: |
| 378 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV; |
| 379 | break; |
| 380 | case DRM_FORMAT_YVYU: |
| 381 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YVYU; |
| 382 | break; |
| 383 | case DRM_FORMAT_UYVY: |
| 384 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_UYVY; |
| 385 | break; |
| 386 | case DRM_FORMAT_VYUY: |
| 387 | sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_VYUY; |
| 388 | break; |
| 389 | case DRM_FORMAT_RGB565: |
| 390 | sprctl |= SP_FORMAT_BGR565; |
| 391 | break; |
| 392 | case DRM_FORMAT_XRGB8888: |
| 393 | sprctl |= SP_FORMAT_BGRX8888; |
| 394 | break; |
| 395 | case DRM_FORMAT_ARGB8888: |
| 396 | sprctl |= SP_FORMAT_BGRA8888; |
| 397 | break; |
| 398 | case DRM_FORMAT_XBGR2101010: |
| 399 | sprctl |= SP_FORMAT_RGBX1010102; |
| 400 | break; |
| 401 | case DRM_FORMAT_ABGR2101010: |
| 402 | sprctl |= SP_FORMAT_RGBA1010102; |
| 403 | break; |
| 404 | case DRM_FORMAT_XBGR8888: |
| 405 | sprctl |= SP_FORMAT_RGBX8888; |
| 406 | break; |
| 407 | case DRM_FORMAT_ABGR8888: |
| 408 | sprctl |= SP_FORMAT_RGBA8888; |
| 409 | break; |
| 410 | default: |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 411 | MISSING_CASE(fb->format->format); |
| 412 | return 0; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 415 | if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 416 | sprctl |= SP_TILED; |
| 417 | |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 418 | if (rotation & DRM_MODE_ROTATE_180) |
Ville Syrjälä | df0cd45 | 2016-11-14 18:53:59 +0200 | [diff] [blame] | 419 | sprctl |= SP_ROTATE_180; |
| 420 | |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 421 | if (rotation & DRM_MODE_REFLECT_X) |
Ville Syrjälä | 4ea7be2 | 2016-11-14 18:54:00 +0200 | [diff] [blame] | 422 | sprctl |= SP_MIRROR; |
| 423 | |
Ville Syrjälä | 78587de | 2017-03-09 17:44:32 +0200 | [diff] [blame] | 424 | if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 425 | sprctl |= SP_SOURCE_KEY; |
| 426 | |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 427 | return sprctl; |
| 428 | } |
| 429 | |
| 430 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 431 | vlv_update_plane(struct intel_plane *plane, |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 432 | const struct intel_crtc_state *crtc_state, |
| 433 | const struct intel_plane_state *plane_state) |
| 434 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 435 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 436 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 437 | enum pipe pipe = plane->pipe; |
| 438 | enum plane_id plane_id = plane->id; |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 439 | u32 sprctl = plane_state->ctl; |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 440 | u32 sprsurf_offset = plane_state->main.offset; |
| 441 | u32 linear_offset; |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 442 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
| 443 | int crtc_x = plane_state->base.dst.x1; |
| 444 | int crtc_y = plane_state->base.dst.y1; |
| 445 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); |
| 446 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 447 | uint32_t x = plane_state->main.x; |
| 448 | uint32_t y = plane_state->main.y; |
Ville Syrjälä | 96ef685 | 2017-03-17 23:17:58 +0200 | [diff] [blame] | 449 | unsigned long irqflags; |
| 450 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 451 | /* Sizes are 0 based */ |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 452 | crtc_w--; |
| 453 | crtc_h--; |
| 454 | |
Ville Syrjälä | 2949056 | 2016-01-20 18:02:50 +0200 | [diff] [blame] | 455 | linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0); |
Ville Syrjälä | 6687c90 | 2015-09-15 13:16:41 +0300 | [diff] [blame] | 456 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 457 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 458 | |
Ville Syrjälä | 78587de | 2017-03-09 17:44:32 +0200 | [diff] [blame] | 459 | if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B) |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 460 | chv_update_csc(plane, fb->format->format); |
Ville Syrjälä | 78587de | 2017-03-09 17:44:32 +0200 | [diff] [blame] | 461 | |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 462 | if (key->flags) { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 463 | I915_WRITE_FW(SPKEYMINVAL(pipe, plane_id), key->min_value); |
| 464 | I915_WRITE_FW(SPKEYMAXVAL(pipe, plane_id), key->max_value); |
| 465 | I915_WRITE_FW(SPKEYMSK(pipe, plane_id), key->channel_mask); |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 466 | } |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 467 | I915_WRITE_FW(SPSTRIDE(pipe, plane_id), fb->pitches[0]); |
| 468 | I915_WRITE_FW(SPPOS(pipe, plane_id), (crtc_y << 16) | crtc_x); |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 469 | |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 470 | if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 471 | I915_WRITE_FW(SPTILEOFF(pipe, plane_id), (y << 16) | x); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 472 | else |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 473 | I915_WRITE_FW(SPLINOFF(pipe, plane_id), linear_offset); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 474 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 475 | I915_WRITE_FW(SPCONSTALPHA(pipe, plane_id), 0); |
Ville Syrjälä | c14b048 | 2014-10-16 20:52:34 +0300 | [diff] [blame] | 476 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 477 | I915_WRITE_FW(SPSIZE(pipe, plane_id), (crtc_h << 16) | crtc_w); |
| 478 | I915_WRITE_FW(SPCNTR(pipe, plane_id), sprctl); |
| 479 | I915_WRITE_FW(SPSURF(pipe, plane_id), |
| 480 | intel_plane_ggtt_offset(plane_state) + sprsurf_offset); |
| 481 | POSTING_READ_FW(SPSURF(pipe, plane_id)); |
| 482 | |
| 483 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 487 | vlv_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 488 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 489 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 490 | enum pipe pipe = plane->pipe; |
| 491 | enum plane_id plane_id = plane->id; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 492 | unsigned long irqflags; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 493 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 494 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
Ville Syrjälä | 48fe469 | 2015-03-19 17:57:13 +0200 | [diff] [blame] | 495 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 496 | I915_WRITE_FW(SPCNTR(pipe, plane_id), 0); |
| 497 | |
| 498 | I915_WRITE_FW(SPSURF(pipe, plane_id), 0); |
| 499 | POSTING_READ_FW(SPSURF(pipe, plane_id)); |
| 500 | |
| 501 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Ville Syrjälä | 45dea7b | 2017-03-17 23:17:59 +0200 | [diff] [blame] | 504 | static u32 ivb_sprite_ctl(const struct intel_crtc_state *crtc_state, |
| 505 | const struct intel_plane_state *plane_state) |
| 506 | { |
| 507 | struct drm_i915_private *dev_priv = |
| 508 | to_i915(plane_state->base.plane->dev); |
| 509 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 510 | unsigned int rotation = plane_state->base.rotation; |
| 511 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
| 512 | u32 sprctl; |
| 513 | |
| 514 | sprctl = SPRITE_ENABLE | SPRITE_GAMMA_ENABLE; |
| 515 | |
| 516 | if (IS_IVYBRIDGE(dev_priv)) |
| 517 | sprctl |= SPRITE_TRICKLE_FEED_DISABLE; |
| 518 | |
| 519 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
| 520 | sprctl |= SPRITE_PIPE_CSC_ENABLE; |
| 521 | |
| 522 | switch (fb->format->format) { |
| 523 | case DRM_FORMAT_XBGR8888: |
| 524 | sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX; |
| 525 | break; |
| 526 | case DRM_FORMAT_XRGB8888: |
| 527 | sprctl |= SPRITE_FORMAT_RGBX888; |
| 528 | break; |
| 529 | case DRM_FORMAT_YUYV: |
| 530 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV; |
| 531 | break; |
| 532 | case DRM_FORMAT_YVYU: |
| 533 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU; |
| 534 | break; |
| 535 | case DRM_FORMAT_UYVY: |
| 536 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY; |
| 537 | break; |
| 538 | case DRM_FORMAT_VYUY: |
| 539 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY; |
| 540 | break; |
| 541 | default: |
| 542 | MISSING_CASE(fb->format->format); |
| 543 | return 0; |
| 544 | } |
| 545 | |
| 546 | if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
| 547 | sprctl |= SPRITE_TILED; |
| 548 | |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 549 | if (rotation & DRM_MODE_ROTATE_180) |
Ville Syrjälä | 45dea7b | 2017-03-17 23:17:59 +0200 | [diff] [blame] | 550 | sprctl |= SPRITE_ROTATE_180; |
| 551 | |
| 552 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 553 | sprctl |= SPRITE_DEST_KEY; |
| 554 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 555 | sprctl |= SPRITE_SOURCE_KEY; |
| 556 | |
| 557 | return sprctl; |
| 558 | } |
| 559 | |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 560 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 561 | ivb_update_plane(struct intel_plane *plane, |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 562 | const struct intel_crtc_state *crtc_state, |
| 563 | const struct intel_plane_state *plane_state) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 564 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 565 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 566 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 567 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 568 | u32 sprctl = plane_state->ctl, sprscale = 0; |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 569 | u32 sprsurf_offset = plane_state->main.offset; |
| 570 | u32 linear_offset; |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 571 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 572 | int crtc_x = plane_state->base.dst.x1; |
| 573 | int crtc_y = plane_state->base.dst.y1; |
| 574 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); |
| 575 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 576 | uint32_t x = plane_state->main.x; |
| 577 | uint32_t y = plane_state->main.y; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 578 | uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; |
| 579 | uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 580 | unsigned long irqflags; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 581 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 582 | /* Sizes are 0 based */ |
| 583 | src_w--; |
| 584 | src_h--; |
| 585 | crtc_w--; |
| 586 | crtc_h--; |
| 587 | |
Ville Syrjälä | 8553c18 | 2013-12-05 15:51:39 +0200 | [diff] [blame] | 588 | if (crtc_w != src_w || crtc_h != src_h) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 589 | sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 590 | |
Ville Syrjälä | 2949056 | 2016-01-20 18:02:50 +0200 | [diff] [blame] | 591 | linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0); |
Ville Syrjälä | 6687c90 | 2015-09-15 13:16:41 +0300 | [diff] [blame] | 592 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 593 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 594 | |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 595 | if (key->flags) { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 596 | I915_WRITE_FW(SPRKEYVAL(pipe), key->min_value); |
| 597 | I915_WRITE_FW(SPRKEYMAX(pipe), key->max_value); |
| 598 | I915_WRITE_FW(SPRKEYMSK(pipe), key->channel_mask); |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 599 | } |
| 600 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 601 | I915_WRITE_FW(SPRSTRIDE(pipe), fb->pitches[0]); |
| 602 | I915_WRITE_FW(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 603 | |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 604 | /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET |
| 605 | * register */ |
Tvrtko Ursulin | 8652744 | 2016-10-13 11:03:00 +0100 | [diff] [blame] | 606 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 607 | I915_WRITE_FW(SPROFFSET(pipe), (y << 16) | x); |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 608 | else if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 609 | I915_WRITE_FW(SPRTILEOFF(pipe), (y << 16) | x); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 610 | else |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 611 | I915_WRITE_FW(SPRLINOFF(pipe), linear_offset); |
Damien Lespiau | c54173a | 2012-10-26 18:20:11 +0100 | [diff] [blame] | 612 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 613 | I915_WRITE_FW(SPRSIZE(pipe), (crtc_h << 16) | crtc_w); |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 614 | if (plane->can_scale) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 615 | I915_WRITE_FW(SPRSCALE(pipe), sprscale); |
| 616 | I915_WRITE_FW(SPRCTL(pipe), sprctl); |
| 617 | I915_WRITE_FW(SPRSURF(pipe), |
| 618 | intel_plane_ggtt_offset(plane_state) + sprsurf_offset); |
| 619 | POSTING_READ_FW(SPRSURF(pipe)); |
| 620 | |
| 621 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 625 | ivb_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 626 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 627 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 628 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 629 | unsigned long irqflags; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 630 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 631 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 632 | |
| 633 | I915_WRITE_FW(SPRCTL(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 634 | /* Can't leave the scaler enabled... */ |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 635 | if (plane->can_scale) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 636 | I915_WRITE_FW(SPRSCALE(pipe), 0); |
Ville Syrjälä | 5b633d6 | 2014-04-29 13:35:47 +0300 | [diff] [blame] | 637 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 638 | I915_WRITE_FW(SPRSURF(pipe), 0); |
| 639 | POSTING_READ_FW(SPRSURF(pipe)); |
| 640 | |
| 641 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 642 | } |
| 643 | |
Ville Syrjälä | ab33081 | 2017-04-21 21:14:32 +0300 | [diff] [blame] | 644 | static u32 g4x_sprite_ctl(const struct intel_crtc_state *crtc_state, |
Ville Syrjälä | 0a37514 | 2017-03-17 23:18:00 +0200 | [diff] [blame] | 645 | const struct intel_plane_state *plane_state) |
| 646 | { |
| 647 | struct drm_i915_private *dev_priv = |
| 648 | to_i915(plane_state->base.plane->dev); |
| 649 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 650 | unsigned int rotation = plane_state->base.rotation; |
| 651 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
| 652 | u32 dvscntr; |
| 653 | |
| 654 | dvscntr = DVS_ENABLE | DVS_GAMMA_ENABLE; |
| 655 | |
| 656 | if (IS_GEN6(dev_priv)) |
| 657 | dvscntr |= DVS_TRICKLE_FEED_DISABLE; |
| 658 | |
| 659 | switch (fb->format->format) { |
| 660 | case DRM_FORMAT_XBGR8888: |
| 661 | dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR; |
| 662 | break; |
| 663 | case DRM_FORMAT_XRGB8888: |
| 664 | dvscntr |= DVS_FORMAT_RGBX888; |
| 665 | break; |
| 666 | case DRM_FORMAT_YUYV: |
| 667 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV; |
| 668 | break; |
| 669 | case DRM_FORMAT_YVYU: |
| 670 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU; |
| 671 | break; |
| 672 | case DRM_FORMAT_UYVY: |
| 673 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY; |
| 674 | break; |
| 675 | case DRM_FORMAT_VYUY: |
| 676 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY; |
| 677 | break; |
| 678 | default: |
| 679 | MISSING_CASE(fb->format->format); |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
| 684 | dvscntr |= DVS_TILED; |
| 685 | |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 686 | if (rotation & DRM_MODE_ROTATE_180) |
Ville Syrjälä | 0a37514 | 2017-03-17 23:18:00 +0200 | [diff] [blame] | 687 | dvscntr |= DVS_ROTATE_180; |
| 688 | |
| 689 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
| 690 | dvscntr |= DVS_DEST_KEY; |
| 691 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
| 692 | dvscntr |= DVS_SOURCE_KEY; |
| 693 | |
| 694 | return dvscntr; |
| 695 | } |
| 696 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 697 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 698 | g4x_update_plane(struct intel_plane *plane, |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 699 | const struct intel_crtc_state *crtc_state, |
| 700 | const struct intel_plane_state *plane_state) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 701 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 702 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 703 | const struct drm_framebuffer *fb = plane_state->base.fb; |
| 704 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 705 | u32 dvscntr = plane_state->ctl, dvsscale = 0; |
| 706 | u32 dvssurf_offset = plane_state->main.offset; |
| 707 | u32 linear_offset; |
Maarten Lankhorst | 2fde139 | 2016-01-07 11:54:06 +0100 | [diff] [blame] | 708 | const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 709 | int crtc_x = plane_state->base.dst.x1; |
| 710 | int crtc_y = plane_state->base.dst.y1; |
| 711 | uint32_t crtc_w = drm_rect_width(&plane_state->base.dst); |
| 712 | uint32_t crtc_h = drm_rect_height(&plane_state->base.dst); |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 713 | uint32_t x = plane_state->main.x; |
| 714 | uint32_t y = plane_state->main.y; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 715 | uint32_t src_w = drm_rect_width(&plane_state->base.src) >> 16; |
| 716 | uint32_t src_h = drm_rect_height(&plane_state->base.src) >> 16; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 717 | unsigned long irqflags; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 718 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 719 | /* Sizes are 0 based */ |
| 720 | src_w--; |
| 721 | src_h--; |
| 722 | crtc_w--; |
| 723 | crtc_h--; |
| 724 | |
Ville Syrjälä | 8368f01 | 2013-12-05 15:51:31 +0200 | [diff] [blame] | 725 | if (crtc_w != src_w || crtc_h != src_h) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 726 | dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; |
| 727 | |
Ville Syrjälä | 2949056 | 2016-01-20 18:02:50 +0200 | [diff] [blame] | 728 | linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0); |
Ville Syrjälä | 6687c90 | 2015-09-15 13:16:41 +0300 | [diff] [blame] | 729 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 730 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 731 | |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 732 | if (key->flags) { |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 733 | I915_WRITE_FW(DVSKEYVAL(pipe), key->min_value); |
| 734 | I915_WRITE_FW(DVSKEYMAX(pipe), key->max_value); |
| 735 | I915_WRITE_FW(DVSKEYMSK(pipe), key->channel_mask); |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 736 | } |
| 737 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 738 | I915_WRITE_FW(DVSSTRIDE(pipe), fb->pitches[0]); |
| 739 | I915_WRITE_FW(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
Ville Syrjälä | ca6ad02 | 2014-01-17 20:09:03 +0200 | [diff] [blame] | 740 | |
Ville Syrjälä | bae781b | 2016-11-16 13:33:16 +0200 | [diff] [blame] | 741 | if (fb->modifier == I915_FORMAT_MOD_X_TILED) |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 742 | I915_WRITE_FW(DVSTILEOFF(pipe), (y << 16) | x); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 743 | else |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 744 | I915_WRITE_FW(DVSLINOFF(pipe), linear_offset); |
Damien Lespiau | 5a35e99 | 2012-10-26 18:20:12 +0100 | [diff] [blame] | 745 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 746 | I915_WRITE_FW(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); |
| 747 | I915_WRITE_FW(DVSSCALE(pipe), dvsscale); |
| 748 | I915_WRITE_FW(DVSCNTR(pipe), dvscntr); |
| 749 | I915_WRITE_FW(DVSSURF(pipe), |
| 750 | intel_plane_ggtt_offset(plane_state) + dvssurf_offset); |
| 751 | POSTING_READ_FW(DVSSURF(pipe)); |
| 752 | |
| 753 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | static void |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 757 | g4x_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 758 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 759 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 760 | enum pipe pipe = plane->pipe; |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 761 | unsigned long irqflags; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 762 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 763 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
| 764 | |
| 765 | I915_WRITE_FW(DVSCNTR(pipe), 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 766 | /* Disable the scaler */ |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 767 | I915_WRITE_FW(DVSSCALE(pipe), 0); |
Ville Syrjälä | 48fe469 | 2015-03-19 17:57:13 +0200 | [diff] [blame] | 768 | |
Ville Syrjälä | dd584fc | 2017-03-09 17:44:33 +0200 | [diff] [blame] | 769 | I915_WRITE_FW(DVSSURF(pipe), 0); |
| 770 | POSTING_READ_FW(DVSSURF(pipe)); |
| 771 | |
| 772 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 773 | } |
| 774 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 775 | static int |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 776 | intel_check_sprite_plane(struct intel_plane *plane, |
Maarten Lankhorst | 061e4b8 | 2015-06-15 12:33:46 +0200 | [diff] [blame] | 777 | struct intel_crtc_state *crtc_state, |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 778 | struct intel_plane_state *state) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 779 | { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 780 | struct drm_i915_private *dev_priv = to_i915(plane->base.dev); |
| 781 | struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); |
Matt Roper | 2b875c2 | 2014-12-01 15:40:13 -0800 | [diff] [blame] | 782 | struct drm_framebuffer *fb = state->base.fb; |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 783 | int crtc_x, crtc_y; |
| 784 | unsigned int crtc_w, crtc_h; |
| 785 | uint32_t src_x, src_y, src_w, src_h; |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 786 | struct drm_rect *src = &state->base.src; |
| 787 | struct drm_rect *dst = &state->base.dst; |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 788 | const struct drm_rect *clip = &state->clip; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 789 | int hscale, vscale; |
| 790 | int max_scale, min_scale; |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 791 | bool can_scale; |
Ville Syrjälä | b63a16f | 2016-01-28 16:53:54 +0200 | [diff] [blame] | 792 | int ret; |
Matt Roper | cf4c7c1 | 2014-12-04 10:27:42 -0800 | [diff] [blame] | 793 | |
Rob Clark | 1638d30 | 2016-11-05 11:08:08 -0400 | [diff] [blame] | 794 | *src = drm_plane_state_src(&state->base); |
| 795 | *dst = drm_plane_state_dest(&state->base); |
Ville Syrjälä | f8856a4 | 2016-07-26 19:07:00 +0300 | [diff] [blame] | 796 | |
Matt Roper | cf4c7c1 | 2014-12-04 10:27:42 -0800 | [diff] [blame] | 797 | if (!fb) { |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 798 | state->base.visible = false; |
Maarten Lankhorst | da20eab | 2015-06-15 12:33:44 +0200 | [diff] [blame] | 799 | return 0; |
Matt Roper | cf4c7c1 | 2014-12-04 10:27:42 -0800 | [diff] [blame] | 800 | } |
Jesse Barnes | 5e1bac2 | 2013-03-26 09:25:43 -0700 | [diff] [blame] | 801 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 802 | /* Don't modify another pipe's plane */ |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 803 | if (plane->pipe != crtc->pipe) { |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 804 | DRM_DEBUG_KMS("Wrong plane <-> crtc mapping\n"); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 805 | return -EINVAL; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | /* FIXME check all gen limits */ |
| 809 | if (fb->width < 3 || fb->height < 3 || fb->pitches[0] > 16384) { |
| 810 | DRM_DEBUG_KMS("Unsuitable framebuffer for plane\n"); |
| 811 | return -EINVAL; |
| 812 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 813 | |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 814 | /* setup can_scale, min_scale, max_scale */ |
Tvrtko Ursulin | 55b8f2a | 2016-10-14 09:17:22 +0100 | [diff] [blame] | 815 | if (INTEL_GEN(dev_priv) >= 9) { |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 816 | /* use scaler when colorkey is not required */ |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 817 | if (state->ckey.flags == I915_SET_COLORKEY_NONE) { |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 818 | can_scale = 1; |
| 819 | min_scale = 1; |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 820 | max_scale = skl_max_scale(crtc, crtc_state); |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 821 | } else { |
| 822 | can_scale = 0; |
| 823 | min_scale = DRM_PLANE_HELPER_NO_SCALING; |
| 824 | max_scale = DRM_PLANE_HELPER_NO_SCALING; |
| 825 | } |
| 826 | } else { |
Ville Syrjälä | 282dbf9 | 2017-03-27 21:55:33 +0300 | [diff] [blame] | 827 | can_scale = plane->can_scale; |
| 828 | max_scale = plane->max_downscale << 16; |
| 829 | min_scale = plane->can_scale ? 1 : (1 << 16); |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 832 | /* |
| 833 | * FIXME the following code does a bunch of fuzzy adjustments to the |
| 834 | * coordinates and sizes. We probably need some way to decide whether |
| 835 | * more strict checking should be done instead. |
| 836 | */ |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 837 | drm_rect_rotate(src, fb->width << 16, fb->height << 16, |
Matt Roper | 8e7d688 | 2015-01-21 16:35:41 -0800 | [diff] [blame] | 838 | state->base.rotation); |
Ville Syrjälä | 76eebda | 2014-08-05 11:26:52 +0530 | [diff] [blame] | 839 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 840 | hscale = drm_rect_calc_hscale_relaxed(src, dst, min_scale, max_scale); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 841 | BUG_ON(hscale < 0); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 842 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 843 | vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 844 | BUG_ON(vscale < 0); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 845 | |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 846 | state->base.visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 847 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 848 | crtc_x = dst->x1; |
| 849 | crtc_y = dst->y1; |
| 850 | crtc_w = drm_rect_width(dst); |
| 851 | crtc_h = drm_rect_height(dst); |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 852 | |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 853 | if (state->base.visible) { |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 854 | /* check again in case clipping clamped the results */ |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 855 | hscale = drm_rect_calc_hscale(src, dst, min_scale, max_scale); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 856 | if (hscale < 0) { |
| 857 | DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n"); |
Ville Syrjälä | c70f577 | 2015-11-16 17:02:36 +0200 | [diff] [blame] | 858 | drm_rect_debug_print("src: ", src, true); |
| 859 | drm_rect_debug_print("dst: ", dst, false); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 860 | |
| 861 | return hscale; |
| 862 | } |
| 863 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 864 | vscale = drm_rect_calc_vscale(src, dst, min_scale, max_scale); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 865 | if (vscale < 0) { |
| 866 | DRM_DEBUG_KMS("Vertical scaling factor out of limits\n"); |
Ville Syrjälä | c70f577 | 2015-11-16 17:02:36 +0200 | [diff] [blame] | 867 | drm_rect_debug_print("src: ", src, true); |
| 868 | drm_rect_debug_print("dst: ", dst, false); |
Ville Syrjälä | 3c3686c | 2013-04-24 18:52:39 +0300 | [diff] [blame] | 869 | |
| 870 | return vscale; |
| 871 | } |
| 872 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 873 | /* Make the source viewport size an exact multiple of the scaling factors. */ |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 874 | drm_rect_adjust_size(src, |
| 875 | drm_rect_width(dst) * hscale - drm_rect_width(src), |
| 876 | drm_rect_height(dst) * vscale - drm_rect_height(src)); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 877 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 878 | drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, |
Matt Roper | 8e7d688 | 2015-01-21 16:35:41 -0800 | [diff] [blame] | 879 | state->base.rotation); |
Ville Syrjälä | 76eebda | 2014-08-05 11:26:52 +0530 | [diff] [blame] | 880 | |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 881 | /* sanity check to make sure the src viewport wasn't enlarged */ |
Matt Roper | ea2c67b | 2014-12-23 10:41:52 -0800 | [diff] [blame] | 882 | WARN_ON(src->x1 < (int) state->base.src_x || |
| 883 | src->y1 < (int) state->base.src_y || |
| 884 | src->x2 > (int) state->base.src_x + state->base.src_w || |
| 885 | src->y2 > (int) state->base.src_y + state->base.src_h); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 886 | |
| 887 | /* |
| 888 | * Hardware doesn't handle subpixel coordinates. |
| 889 | * Adjust to (macro)pixel boundary, but be careful not to |
| 890 | * increase the source viewport size, because that could |
| 891 | * push the downscaling factor out of bounds. |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 892 | */ |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 893 | src_x = src->x1 >> 16; |
| 894 | src_w = drm_rect_width(src) >> 16; |
| 895 | src_y = src->y1 >> 16; |
| 896 | src_h = drm_rect_height(src) >> 16; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 897 | |
Ville Syrjälä | 438b74a | 2016-12-14 23:32:55 +0200 | [diff] [blame] | 898 | if (format_is_yuv(fb->format->format)) { |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 899 | src_x &= ~1; |
| 900 | src_w &= ~1; |
| 901 | |
| 902 | /* |
| 903 | * Must keep src and dst the |
| 904 | * same if we can't scale. |
| 905 | */ |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 906 | if (!can_scale) |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 907 | crtc_w &= ~1; |
| 908 | |
| 909 | if (crtc_w == 0) |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 910 | state->base.visible = false; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | |
| 914 | /* Check size restrictions when scaling */ |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 915 | if (state->base.visible && (src_w != crtc_w || src_h != crtc_h)) { |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 916 | unsigned int width_bytes; |
Ville Syrjälä | 353c859 | 2016-12-14 23:30:57 +0200 | [diff] [blame] | 917 | int cpp = fb->format->cpp[0]; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 918 | |
Chandra Konduru | 225c228 | 2015-05-18 16:18:44 -0700 | [diff] [blame] | 919 | WARN_ON(!can_scale); |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 920 | |
| 921 | /* FIXME interlacing min height is 6 */ |
| 922 | |
| 923 | if (crtc_w < 3 || crtc_h < 3) |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 924 | state->base.visible = false; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 925 | |
| 926 | if (src_w < 3 || src_h < 3) |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 927 | state->base.visible = false; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 928 | |
Ville Syrjälä | ac48496 | 2016-01-20 21:05:26 +0200 | [diff] [blame] | 929 | width_bytes = ((src_x * cpp) & 63) + src_w * cpp; |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 930 | |
Tvrtko Ursulin | 55b8f2a | 2016-10-14 09:17:22 +0100 | [diff] [blame] | 931 | if (INTEL_GEN(dev_priv) < 9 && (src_w > 2048 || src_h > 2048 || |
Chandra Konduru | c331879 | 2015-04-15 15:15:02 -0700 | [diff] [blame] | 932 | width_bytes > 4096 || fb->pitches[0] > 4096)) { |
Ville Syrjälä | 1731693 | 2013-04-24 18:52:38 +0300 | [diff] [blame] | 933 | DRM_DEBUG_KMS("Source dimensions exceed hardware limits\n"); |
| 934 | return -EINVAL; |
| 935 | } |
| 936 | } |
| 937 | |
Ville Syrjälä | 936e71e | 2016-07-26 19:06:59 +0300 | [diff] [blame] | 938 | if (state->base.visible) { |
Chandra Konduru | 0a5ae1b | 2015-04-09 16:41:54 -0700 | [diff] [blame] | 939 | src->x1 = src_x << 16; |
| 940 | src->x2 = (src_x + src_w) << 16; |
| 941 | src->y1 = src_y << 16; |
| 942 | src->y2 = (src_y + src_h) << 16; |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | dst->x1 = crtc_x; |
| 946 | dst->x2 = crtc_x + crtc_w; |
| 947 | dst->y1 = crtc_y; |
| 948 | dst->y2 = crtc_y + crtc_h; |
| 949 | |
Tvrtko Ursulin | 55b8f2a | 2016-10-14 09:17:22 +0100 | [diff] [blame] | 950 | if (INTEL_GEN(dev_priv) >= 9) { |
Ville Syrjälä | b63a16f | 2016-01-28 16:53:54 +0200 | [diff] [blame] | 951 | ret = skl_check_plane_surface(state); |
| 952 | if (ret) |
| 953 | return ret; |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 954 | |
| 955 | state->ctl = skl_plane_ctl(crtc_state, state); |
| 956 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 957 | ret = i9xx_check_plane_surface(state); |
| 958 | if (ret) |
| 959 | return ret; |
| 960 | |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 961 | state->ctl = vlv_sprite_ctl(crtc_state, state); |
| 962 | } else if (INTEL_GEN(dev_priv) >= 7) { |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 963 | ret = i9xx_check_plane_surface(state); |
| 964 | if (ret) |
| 965 | return ret; |
| 966 | |
Ville Syrjälä | a0864d5 | 2017-03-23 21:27:09 +0200 | [diff] [blame] | 967 | state->ctl = ivb_sprite_ctl(crtc_state, state); |
| 968 | } else { |
Ville Syrjälä | f9407ae | 2017-03-23 21:27:12 +0200 | [diff] [blame] | 969 | ret = i9xx_check_plane_surface(state); |
| 970 | if (ret) |
| 971 | return ret; |
| 972 | |
Ville Syrjälä | ab33081 | 2017-04-21 21:14:32 +0300 | [diff] [blame] | 973 | state->ctl = g4x_sprite_ctl(crtc_state, state); |
Ville Syrjälä | b63a16f | 2016-01-28 16:53:54 +0200 | [diff] [blame] | 974 | } |
| 975 | |
Gustavo Padovan | 96d61a7 | 2014-09-05 17:04:47 -0300 | [diff] [blame] | 976 | return 0; |
| 977 | } |
| 978 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 979 | int intel_sprite_set_colorkey(struct drm_device *dev, void *data, |
| 980 | struct drm_file *file_priv) |
| 981 | { |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 982 | struct drm_i915_private *dev_priv = to_i915(dev); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 983 | struct drm_intel_sprite_colorkey *set = data; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 984 | struct drm_plane *plane; |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 985 | struct drm_plane_state *plane_state; |
| 986 | struct drm_atomic_state *state; |
| 987 | struct drm_modeset_acquire_ctx ctx; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 988 | int ret = 0; |
| 989 | |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 990 | /* Make sure we don't try to enable both src & dest simultaneously */ |
| 991 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
| 992 | return -EINVAL; |
| 993 | |
Tvrtko Ursulin | 920a14b | 2016-10-14 10:13:44 +0100 | [diff] [blame] | 994 | if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && |
Ville Syrjälä | 47ecbb2 | 2015-03-19 21:18:57 +0200 | [diff] [blame] | 995 | set->flags & I915_SET_COLORKEY_DESTINATION) |
| 996 | return -EINVAL; |
| 997 | |
Rob Clark | 7707e65 | 2014-07-17 23:30:04 -0400 | [diff] [blame] | 998 | plane = drm_plane_find(dev, set->plane_id); |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 999 | if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) |
| 1000 | return -ENOENT; |
| 1001 | |
| 1002 | drm_modeset_acquire_init(&ctx, 0); |
| 1003 | |
| 1004 | state = drm_atomic_state_alloc(plane->dev); |
| 1005 | if (!state) { |
| 1006 | ret = -ENOMEM; |
| 1007 | goto out; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1008 | } |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 1009 | state->acquire_ctx = &ctx; |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1010 | |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 1011 | while (1) { |
| 1012 | plane_state = drm_atomic_get_plane_state(state, plane); |
| 1013 | ret = PTR_ERR_OR_ZERO(plane_state); |
| 1014 | if (!ret) { |
| 1015 | to_intel_plane_state(plane_state)->ckey = *set; |
| 1016 | ret = drm_atomic_commit(state); |
Chandra Konduru | 6156a45 | 2015-04-27 13:48:39 -0700 | [diff] [blame] | 1017 | } |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 1018 | |
| 1019 | if (ret != -EDEADLK) |
| 1020 | break; |
| 1021 | |
| 1022 | drm_atomic_state_clear(state); |
| 1023 | drm_modeset_backoff(&ctx); |
Chandra Konduru | 6156a45 | 2015-04-27 13:48:39 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
Chris Wilson | 0853695 | 2016-10-14 13:18:18 +0100 | [diff] [blame] | 1026 | drm_atomic_state_put(state); |
Maarten Lankhorst | 818ed96 | 2015-06-15 12:33:54 +0200 | [diff] [blame] | 1027 | out: |
| 1028 | drm_modeset_drop_locks(&ctx); |
| 1029 | drm_modeset_acquire_fini(&ctx); |
Jesse Barnes | 8ea3086 | 2012-01-03 08:05:39 -0800 | [diff] [blame] | 1030 | return ret; |
| 1031 | } |
| 1032 | |
Ville Syrjälä | ab33081 | 2017-04-21 21:14:32 +0300 | [diff] [blame] | 1033 | static const uint32_t g4x_plane_formats[] = { |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1034 | DRM_FORMAT_XRGB8888, |
| 1035 | DRM_FORMAT_YUYV, |
| 1036 | DRM_FORMAT_YVYU, |
| 1037 | DRM_FORMAT_UYVY, |
| 1038 | DRM_FORMAT_VYUY, |
| 1039 | }; |
| 1040 | |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1041 | static const uint64_t i9xx_plane_format_modifiers[] = { |
| 1042 | I915_FORMAT_MOD_X_TILED, |
| 1043 | DRM_FORMAT_MOD_LINEAR, |
| 1044 | DRM_FORMAT_MOD_INVALID |
| 1045 | }; |
| 1046 | |
Damien Lespiau | dada2d5 | 2015-05-12 16:13:22 +0100 | [diff] [blame] | 1047 | static const uint32_t snb_plane_formats[] = { |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1048 | DRM_FORMAT_XBGR8888, |
| 1049 | DRM_FORMAT_XRGB8888, |
| 1050 | DRM_FORMAT_YUYV, |
| 1051 | DRM_FORMAT_YVYU, |
| 1052 | DRM_FORMAT_UYVY, |
| 1053 | DRM_FORMAT_VYUY, |
| 1054 | }; |
| 1055 | |
Damien Lespiau | dada2d5 | 2015-05-12 16:13:22 +0100 | [diff] [blame] | 1056 | static const uint32_t vlv_plane_formats[] = { |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1057 | DRM_FORMAT_RGB565, |
| 1058 | DRM_FORMAT_ABGR8888, |
| 1059 | DRM_FORMAT_ARGB8888, |
| 1060 | DRM_FORMAT_XBGR8888, |
| 1061 | DRM_FORMAT_XRGB8888, |
| 1062 | DRM_FORMAT_XBGR2101010, |
| 1063 | DRM_FORMAT_ABGR2101010, |
| 1064 | DRM_FORMAT_YUYV, |
| 1065 | DRM_FORMAT_YVYU, |
| 1066 | DRM_FORMAT_UYVY, |
| 1067 | DRM_FORMAT_VYUY, |
| 1068 | }; |
| 1069 | |
Damien Lespiau | dc2a41b | 2013-12-04 00:49:41 +0000 | [diff] [blame] | 1070 | static uint32_t skl_plane_formats[] = { |
| 1071 | DRM_FORMAT_RGB565, |
| 1072 | DRM_FORMAT_ABGR8888, |
| 1073 | DRM_FORMAT_ARGB8888, |
| 1074 | DRM_FORMAT_XBGR8888, |
| 1075 | DRM_FORMAT_XRGB8888, |
| 1076 | DRM_FORMAT_YUYV, |
| 1077 | DRM_FORMAT_YVYU, |
| 1078 | DRM_FORMAT_UYVY, |
| 1079 | DRM_FORMAT_VYUY, |
| 1080 | }; |
| 1081 | |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1082 | static const uint64_t skl_plane_format_modifiers[] = { |
| 1083 | I915_FORMAT_MOD_X_TILED, |
| 1084 | DRM_FORMAT_MOD_LINEAR, |
| 1085 | DRM_FORMAT_MOD_INVALID |
| 1086 | }; |
| 1087 | |
| 1088 | static bool g4x_sprite_plane_format_mod_supported(struct drm_plane *plane, |
| 1089 | uint32_t format, |
| 1090 | uint64_t modifier) |
| 1091 | { |
| 1092 | switch (format) { |
| 1093 | case DRM_FORMAT_XBGR8888: |
| 1094 | case DRM_FORMAT_XRGB8888: |
| 1095 | case DRM_FORMAT_YUYV: |
| 1096 | case DRM_FORMAT_YVYU: |
| 1097 | case DRM_FORMAT_UYVY: |
| 1098 | case DRM_FORMAT_VYUY: |
| 1099 | if (modifier == DRM_FORMAT_MOD_LINEAR || |
| 1100 | modifier == I915_FORMAT_MOD_X_TILED) |
| 1101 | return true; |
| 1102 | /* fall through */ |
| 1103 | default: |
| 1104 | return false; |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | static bool vlv_sprite_plane_format_mod_supported(struct drm_plane *plane, |
| 1109 | uint32_t format, |
| 1110 | uint64_t modifier) |
| 1111 | { |
| 1112 | switch (format) { |
| 1113 | case DRM_FORMAT_YUYV: |
| 1114 | case DRM_FORMAT_YVYU: |
| 1115 | case DRM_FORMAT_UYVY: |
| 1116 | case DRM_FORMAT_VYUY: |
| 1117 | case DRM_FORMAT_RGB565: |
| 1118 | case DRM_FORMAT_XRGB8888: |
| 1119 | case DRM_FORMAT_ARGB8888: |
| 1120 | case DRM_FORMAT_XBGR2101010: |
| 1121 | case DRM_FORMAT_ABGR2101010: |
| 1122 | case DRM_FORMAT_XBGR8888: |
| 1123 | case DRM_FORMAT_ABGR8888: |
| 1124 | if (modifier == DRM_FORMAT_MOD_LINEAR || |
| 1125 | modifier == I915_FORMAT_MOD_X_TILED) |
| 1126 | return true; |
| 1127 | /* fall through */ |
| 1128 | default: |
| 1129 | return false; |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | static bool skl_sprite_plane_format_mod_supported(struct drm_plane *plane, |
| 1134 | uint32_t format, |
| 1135 | uint64_t modifier) |
| 1136 | { |
| 1137 | /* This is the same as primary plane since SKL has universal planes */ |
| 1138 | switch (format) { |
| 1139 | case DRM_FORMAT_XRGB8888: |
| 1140 | case DRM_FORMAT_XBGR8888: |
| 1141 | case DRM_FORMAT_ARGB8888: |
| 1142 | case DRM_FORMAT_ABGR8888: |
| 1143 | case DRM_FORMAT_RGB565: |
| 1144 | case DRM_FORMAT_XRGB2101010: |
| 1145 | case DRM_FORMAT_XBGR2101010: |
| 1146 | case DRM_FORMAT_YUYV: |
| 1147 | case DRM_FORMAT_YVYU: |
| 1148 | case DRM_FORMAT_UYVY: |
| 1149 | case DRM_FORMAT_VYUY: |
| 1150 | if (modifier == I915_FORMAT_MOD_Yf_TILED) |
| 1151 | return true; |
| 1152 | /* fall through */ |
| 1153 | case DRM_FORMAT_C8: |
| 1154 | if (modifier == DRM_FORMAT_MOD_LINEAR || |
| 1155 | modifier == I915_FORMAT_MOD_X_TILED || |
| 1156 | modifier == I915_FORMAT_MOD_Y_TILED) |
| 1157 | return true; |
| 1158 | /* fall through */ |
| 1159 | default: |
| 1160 | return false; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | static bool intel_sprite_plane_format_mod_supported(struct drm_plane *plane, |
| 1165 | uint32_t format, |
| 1166 | uint64_t modifier) |
| 1167 | { |
| 1168 | struct drm_i915_private *dev_priv = to_i915(plane->dev); |
| 1169 | |
| 1170 | if (WARN_ON(modifier == DRM_FORMAT_MOD_INVALID)) |
| 1171 | return false; |
| 1172 | |
| 1173 | if ((modifier >> 56) != DRM_FORMAT_MOD_VENDOR_INTEL && |
| 1174 | modifier != DRM_FORMAT_MOD_LINEAR) |
| 1175 | return false; |
| 1176 | |
| 1177 | if (INTEL_GEN(dev_priv) >= 9) |
| 1178 | return skl_sprite_plane_format_mod_supported(plane, format, modifier); |
| 1179 | else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) |
| 1180 | return vlv_sprite_plane_format_mod_supported(plane, format, modifier); |
| 1181 | else |
| 1182 | return g4x_sprite_plane_format_mod_supported(plane, format, modifier); |
| 1183 | |
| 1184 | unreachable(); |
| 1185 | } |
| 1186 | |
Colin Ian King | 2d56758 | 2017-08-11 14:49:38 +0100 | [diff] [blame] | 1187 | static const struct drm_plane_funcs intel_sprite_plane_funcs = { |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1188 | .update_plane = drm_atomic_helper_update_plane, |
| 1189 | .disable_plane = drm_atomic_helper_disable_plane, |
| 1190 | .destroy = intel_plane_destroy, |
| 1191 | .atomic_get_property = intel_plane_atomic_get_property, |
| 1192 | .atomic_set_property = intel_plane_atomic_set_property, |
| 1193 | .atomic_duplicate_state = intel_plane_duplicate_state, |
| 1194 | .atomic_destroy_state = intel_plane_destroy_state, |
| 1195 | .format_mod_supported = intel_sprite_plane_format_mod_supported, |
| 1196 | }; |
| 1197 | |
Ville Syrjälä | b079bd17 | 2016-10-25 18:58:02 +0300 | [diff] [blame] | 1198 | struct intel_plane * |
Ville Syrjälä | 580503c | 2016-10-31 22:37:00 +0200 | [diff] [blame] | 1199 | intel_sprite_plane_create(struct drm_i915_private *dev_priv, |
| 1200 | enum pipe pipe, int plane) |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1201 | { |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1202 | struct intel_plane *intel_plane = NULL; |
| 1203 | struct intel_plane_state *state = NULL; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1204 | unsigned long possible_crtcs; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1205 | const uint32_t *plane_formats; |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1206 | const uint64_t *modifiers; |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1207 | unsigned int supported_rotations; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1208 | int num_plane_formats; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1209 | int ret; |
| 1210 | |
Daniel Vetter | b14c567 | 2013-09-19 12:18:32 +0200 | [diff] [blame] | 1211 | intel_plane = kzalloc(sizeof(*intel_plane), GFP_KERNEL); |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1212 | if (!intel_plane) { |
| 1213 | ret = -ENOMEM; |
| 1214 | goto fail; |
| 1215 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1216 | |
Matt Roper | 8e7d688 | 2015-01-21 16:35:41 -0800 | [diff] [blame] | 1217 | state = intel_create_plane_state(&intel_plane->base); |
| 1218 | if (!state) { |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1219 | ret = -ENOMEM; |
| 1220 | goto fail; |
Matt Roper | ea2c67b | 2014-12-23 10:41:52 -0800 | [diff] [blame] | 1221 | } |
Matt Roper | 8e7d688 | 2015-01-21 16:35:41 -0800 | [diff] [blame] | 1222 | intel_plane->base.state = &state->base; |
Matt Roper | ea2c67b | 2014-12-23 10:41:52 -0800 | [diff] [blame] | 1223 | |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1224 | if (INTEL_GEN(dev_priv) >= 10) { |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1225 | intel_plane->can_scale = true; |
| 1226 | state->scaler_id = -1; |
| 1227 | |
| 1228 | intel_plane->update_plane = skl_update_plane; |
| 1229 | intel_plane->disable_plane = skl_disable_plane; |
| 1230 | |
| 1231 | plane_formats = skl_plane_formats; |
| 1232 | num_plane_formats = ARRAY_SIZE(skl_plane_formats); |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1233 | modifiers = skl_plane_format_modifiers; |
| 1234 | } else if (INTEL_GEN(dev_priv) >= 9) { |
| 1235 | intel_plane->can_scale = true; |
| 1236 | state->scaler_id = -1; |
| 1237 | |
| 1238 | intel_plane->update_plane = skl_update_plane; |
| 1239 | intel_plane->disable_plane = skl_disable_plane; |
| 1240 | |
| 1241 | plane_formats = skl_plane_formats; |
| 1242 | num_plane_formats = ARRAY_SIZE(skl_plane_formats); |
| 1243 | modifiers = skl_plane_format_modifiers; |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1244 | } else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { |
| 1245 | intel_plane->can_scale = false; |
| 1246 | intel_plane->max_downscale = 1; |
| 1247 | |
| 1248 | intel_plane->update_plane = vlv_update_plane; |
| 1249 | intel_plane->disable_plane = vlv_disable_plane; |
| 1250 | |
| 1251 | plane_formats = vlv_plane_formats; |
| 1252 | num_plane_formats = ARRAY_SIZE(vlv_plane_formats); |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1253 | modifiers = i9xx_plane_format_modifiers; |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1254 | } else if (INTEL_GEN(dev_priv) >= 7) { |
| 1255 | if (IS_IVYBRIDGE(dev_priv)) { |
| 1256 | intel_plane->can_scale = true; |
| 1257 | intel_plane->max_downscale = 2; |
| 1258 | } else { |
| 1259 | intel_plane->can_scale = false; |
| 1260 | intel_plane->max_downscale = 1; |
| 1261 | } |
| 1262 | |
| 1263 | intel_plane->update_plane = ivb_update_plane; |
| 1264 | intel_plane->disable_plane = ivb_disable_plane; |
| 1265 | |
| 1266 | plane_formats = snb_plane_formats; |
| 1267 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1268 | modifiers = i9xx_plane_format_modifiers; |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1269 | } else { |
Damien Lespiau | 2d354c3 | 2012-10-22 18:19:27 +0100 | [diff] [blame] | 1270 | intel_plane->can_scale = true; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1271 | intel_plane->max_downscale = 16; |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1272 | |
Ville Syrjälä | ab33081 | 2017-04-21 21:14:32 +0300 | [diff] [blame] | 1273 | intel_plane->update_plane = g4x_update_plane; |
| 1274 | intel_plane->disable_plane = g4x_disable_plane; |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1275 | |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1276 | modifiers = i9xx_plane_format_modifiers; |
Tvrtko Ursulin | 5db9401 | 2016-10-13 11:03:10 +0100 | [diff] [blame] | 1277 | if (IS_GEN6(dev_priv)) { |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1278 | plane_formats = snb_plane_formats; |
| 1279 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
| 1280 | } else { |
Ville Syrjälä | ab33081 | 2017-04-21 21:14:32 +0300 | [diff] [blame] | 1281 | plane_formats = g4x_plane_formats; |
| 1282 | num_plane_formats = ARRAY_SIZE(g4x_plane_formats); |
Chris Wilson | d1686ae | 2012-04-10 11:41:49 +0100 | [diff] [blame] | 1283 | } |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1284 | } |
| 1285 | |
Dave Airlie | 5481e27 | 2016-10-25 16:36:13 +1000 | [diff] [blame] | 1286 | if (INTEL_GEN(dev_priv) >= 9) { |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1287 | supported_rotations = |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 1288 | DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | |
| 1289 | DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270; |
Ville Syrjälä | 4ea7be2 | 2016-11-14 18:54:00 +0200 | [diff] [blame] | 1290 | } else if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B) { |
| 1291 | supported_rotations = |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 1292 | DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 | |
| 1293 | DRM_MODE_REFLECT_X; |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1294 | } else { |
| 1295 | supported_rotations = |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 1296 | DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180; |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1297 | } |
| 1298 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1299 | intel_plane->pipe = pipe; |
Jesse Barnes | 7f1f385 | 2013-04-02 11:22:20 -0700 | [diff] [blame] | 1300 | intel_plane->plane = plane; |
Ville Syrjälä | b14e584 | 2016-11-22 18:01:56 +0200 | [diff] [blame] | 1301 | intel_plane->id = PLANE_SPRITE0 + plane; |
Sagar Arun Kamble | d1b9d03 | 2015-09-14 21:35:42 +0530 | [diff] [blame] | 1302 | intel_plane->frontbuffer_bit = INTEL_FRONTBUFFER_SPRITE(pipe, plane); |
Matt Roper | c59cb17 | 2014-12-01 15:40:16 -0800 | [diff] [blame] | 1303 | intel_plane->check_plane = intel_check_sprite_plane; |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1304 | |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1305 | possible_crtcs = (1 << pipe); |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1306 | |
Ville Syrjälä | 1890ae6 | 2016-10-25 18:58:03 +0300 | [diff] [blame] | 1307 | if (INTEL_GEN(dev_priv) >= 9) |
Ville Syrjälä | 580503c | 2016-10-31 22:37:00 +0200 | [diff] [blame] | 1308 | ret = drm_universal_plane_init(&dev_priv->drm, &intel_plane->base, |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1309 | possible_crtcs, &intel_sprite_plane_funcs, |
Ville Syrjälä | 38573dc | 2016-05-27 20:59:23 +0300 | [diff] [blame] | 1310 | plane_formats, num_plane_formats, |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1311 | modifiers, |
| 1312 | DRM_PLANE_TYPE_OVERLAY, |
Ville Syrjälä | 38573dc | 2016-05-27 20:59:23 +0300 | [diff] [blame] | 1313 | "plane %d%c", plane + 2, pipe_name(pipe)); |
| 1314 | else |
Ville Syrjälä | 580503c | 2016-10-31 22:37:00 +0200 | [diff] [blame] | 1315 | ret = drm_universal_plane_init(&dev_priv->drm, &intel_plane->base, |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1316 | possible_crtcs, &intel_sprite_plane_funcs, |
Ville Syrjälä | 38573dc | 2016-05-27 20:59:23 +0300 | [diff] [blame] | 1317 | plane_formats, num_plane_formats, |
Ben Widawsky | 714244e | 2017-08-01 09:58:16 -0700 | [diff] [blame] | 1318 | modifiers, |
| 1319 | DRM_PLANE_TYPE_OVERLAY, |
Ville Syrjälä | 38573dc | 2016-05-27 20:59:23 +0300 | [diff] [blame] | 1320 | "sprite %c", sprite_name(pipe, plane)); |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1321 | if (ret) |
| 1322 | goto fail; |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1323 | |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1324 | drm_plane_create_rotation_property(&intel_plane->base, |
Robert Foss | c2c446a | 2017-05-19 16:50:17 -0400 | [diff] [blame] | 1325 | DRM_MODE_ROTATE_0, |
Ville Syrjälä | 93ca7e0 | 2016-09-26 19:30:56 +0300 | [diff] [blame] | 1326 | supported_rotations); |
Ville Syrjälä | 7ed6eee | 2014-08-05 11:26:55 +0530 | [diff] [blame] | 1327 | |
Matt Roper | ea2c67b | 2014-12-23 10:41:52 -0800 | [diff] [blame] | 1328 | drm_plane_helper_add(&intel_plane->base, &intel_plane_helper_funcs); |
| 1329 | |
Ville Syrjälä | b079bd17 | 2016-10-25 18:58:02 +0300 | [diff] [blame] | 1330 | return intel_plane; |
Ville Syrjälä | fca0ce2 | 2016-03-21 14:43:22 +0000 | [diff] [blame] | 1331 | |
| 1332 | fail: |
| 1333 | kfree(state); |
| 1334 | kfree(intel_plane); |
| 1335 | |
Ville Syrjälä | b079bd17 | 2016-10-25 18:58:02 +0300 | [diff] [blame] | 1336 | return ERR_PTR(ret); |
Jesse Barnes | b840d907f | 2011-12-13 13:19:38 -0800 | [diff] [blame] | 1337 | } |