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