Rev 3031 | Rev 3480 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3031 | Rev 3243 | ||
---|---|---|---|
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 "intel_drv.h" |
35 | #include "intel_drv.h" |
36 | #include |
36 | #include |
37 | #include "i915_drv.h" |
37 | #include "i915_drv.h" |
38 | 38 | ||
39 | static void |
39 | static void |
40 | ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
40 | ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
41 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
41 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
42 | unsigned int crtc_w, unsigned int crtc_h, |
42 | unsigned int crtc_w, unsigned int crtc_h, |
43 | uint32_t x, uint32_t y, |
43 | uint32_t x, uint32_t y, |
44 | uint32_t src_w, uint32_t src_h) |
44 | uint32_t src_w, uint32_t src_h) |
45 | { |
45 | { |
46 | struct drm_device *dev = plane->dev; |
46 | struct drm_device *dev = plane->dev; |
47 | struct drm_i915_private *dev_priv = dev->dev_private; |
47 | struct drm_i915_private *dev_priv = dev->dev_private; |
48 | struct intel_plane *intel_plane = to_intel_plane(plane); |
48 | struct intel_plane *intel_plane = to_intel_plane(plane); |
49 | int pipe = intel_plane->pipe; |
49 | int pipe = intel_plane->pipe; |
50 | u32 sprctl, sprscale = 0; |
50 | u32 sprctl, sprscale = 0; |
51 | int pixel_size; |
51 | unsigned long sprsurf_offset, linear_offset; |
- | 52 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
|
52 | 53 | ||
53 | sprctl = I915_READ(SPRCTL(pipe)); |
54 | sprctl = I915_READ(SPRCTL(pipe)); |
54 | 55 | ||
55 | /* Mask out pixel format bits in case we change it */ |
56 | /* Mask out pixel format bits in case we change it */ |
56 | sprctl &= ~SPRITE_PIXFORMAT_MASK; |
57 | sprctl &= ~SPRITE_PIXFORMAT_MASK; |
57 | sprctl &= ~SPRITE_RGB_ORDER_RGBX; |
58 | sprctl &= ~SPRITE_RGB_ORDER_RGBX; |
58 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; |
59 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; |
59 | sprctl &= ~SPRITE_TILED; |
60 | sprctl &= ~SPRITE_TILED; |
60 | 61 | ||
61 | switch (fb->pixel_format) { |
62 | switch (fb->pixel_format) { |
62 | case DRM_FORMAT_XBGR8888: |
63 | case DRM_FORMAT_XBGR8888: |
63 | sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX; |
64 | sprctl |= SPRITE_FORMAT_RGBX888 | SPRITE_RGB_ORDER_RGBX; |
64 | pixel_size = 4; |
- | |
65 | break; |
65 | break; |
66 | case DRM_FORMAT_XRGB8888: |
66 | case DRM_FORMAT_XRGB8888: |
67 | sprctl |= SPRITE_FORMAT_RGBX888; |
67 | sprctl |= SPRITE_FORMAT_RGBX888; |
68 | pixel_size = 4; |
- | |
69 | break; |
68 | break; |
70 | case DRM_FORMAT_YUYV: |
69 | case DRM_FORMAT_YUYV: |
71 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV; |
70 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YUYV; |
72 | pixel_size = 2; |
- | |
73 | break; |
71 | break; |
74 | case DRM_FORMAT_YVYU: |
72 | case DRM_FORMAT_YVYU: |
75 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU; |
73 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_YVYU; |
76 | pixel_size = 2; |
- | |
77 | break; |
74 | break; |
78 | case DRM_FORMAT_UYVY: |
75 | case DRM_FORMAT_UYVY: |
79 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY; |
76 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_UYVY; |
80 | pixel_size = 2; |
- | |
81 | break; |
77 | break; |
82 | case DRM_FORMAT_VYUY: |
78 | case DRM_FORMAT_VYUY: |
83 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY; |
79 | sprctl |= SPRITE_FORMAT_YUV422 | SPRITE_YUV_ORDER_VYUY; |
84 | pixel_size = 2; |
- | |
85 | break; |
80 | break; |
86 | default: |
81 | default: |
87 | DRM_DEBUG_DRIVER("bad pixel format, assuming RGBX888\n"); |
- | |
88 | sprctl |= SPRITE_FORMAT_RGBX888; |
- | |
89 | pixel_size = 4; |
- | |
90 | break; |
82 | BUG(); |
91 | } |
83 | } |
92 | 84 | ||
93 | if (obj->tiling_mode != I915_TILING_NONE) |
85 | if (obj->tiling_mode != I915_TILING_NONE) |
94 | sprctl |= SPRITE_TILED; |
86 | sprctl |= SPRITE_TILED; |
95 | 87 | ||
96 | /* must disable */ |
88 | /* must disable */ |
97 | sprctl |= SPRITE_TRICKLE_FEED_DISABLE; |
89 | sprctl |= SPRITE_TRICKLE_FEED_DISABLE; |
98 | sprctl |= SPRITE_ENABLE; |
90 | sprctl |= SPRITE_ENABLE; |
99 | 91 | ||
100 | /* Sizes are 0 based */ |
92 | /* Sizes are 0 based */ |
101 | src_w--; |
93 | src_w--; |
102 | src_h--; |
94 | src_h--; |
103 | crtc_w--; |
95 | crtc_w--; |
104 | crtc_h--; |
96 | crtc_h--; |
105 | 97 | ||
106 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
98 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
107 | 99 | ||
108 | /* |
100 | /* |
109 | * IVB workaround: must disable low power watermarks for at least |
101 | * IVB workaround: must disable low power watermarks for at least |
110 | * one frame before enabling scaling. LP watermarks can be re-enabled |
102 | * one frame before enabling scaling. LP watermarks can be re-enabled |
111 | * when scaling is disabled. |
103 | * when scaling is disabled. |
112 | */ |
104 | */ |
113 | if (crtc_w != src_w || crtc_h != src_h) { |
105 | if (crtc_w != src_w || crtc_h != src_h) { |
114 | if (!dev_priv->sprite_scaling_enabled) { |
106 | if (!dev_priv->sprite_scaling_enabled) { |
115 | dev_priv->sprite_scaling_enabled = true; |
107 | dev_priv->sprite_scaling_enabled = true; |
116 | intel_update_watermarks(dev); |
108 | intel_update_watermarks(dev); |
117 | intel_wait_for_vblank(dev, pipe); |
109 | intel_wait_for_vblank(dev, pipe); |
118 | } |
110 | } |
119 | sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; |
111 | sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h; |
120 | } else { |
112 | } else { |
121 | if (dev_priv->sprite_scaling_enabled) { |
113 | if (dev_priv->sprite_scaling_enabled) { |
122 | dev_priv->sprite_scaling_enabled = false; |
114 | dev_priv->sprite_scaling_enabled = false; |
123 | /* potentially re-enable LP watermarks */ |
115 | /* potentially re-enable LP watermarks */ |
124 | intel_update_watermarks(dev); |
116 | intel_update_watermarks(dev); |
125 | } |
117 | } |
126 | } |
118 | } |
127 | 119 | ||
128 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); |
120 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); |
129 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
121 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
- | 122 | ||
- | 123 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
|
- | 124 | sprsurf_offset = |
|
- | 125 | intel_gen4_compute_offset_xtiled(&x, &y, |
|
- | 126 | pixel_size, fb->pitches[0]); |
|
- | 127 | linear_offset -= sprsurf_offset; |
|
- | 128 | ||
- | 129 | /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET |
|
- | 130 | * register */ |
|
- | 131 | if (IS_HASWELL(dev)) |
|
- | 132 | I915_WRITE(SPROFFSET(pipe), (y << 16) | x); |
|
130 | if (obj->tiling_mode != I915_TILING_NONE) { |
133 | else if (obj->tiling_mode != I915_TILING_NONE) |
131 | I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x); |
134 | I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x); |
132 | } else { |
135 | else |
133 | unsigned long offset; |
136 | I915_WRITE(SPRLINOFF(pipe), linear_offset); |
134 | - | ||
135 | offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); |
- | |
136 | I915_WRITE(SPRLINOFF(pipe), offset); |
- | |
137 | } |
137 | |
- | 138 | I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w); |
|
138 | I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w); |
139 | if (intel_plane->can_scale) |
139 | I915_WRITE(SPRSCALE(pipe), sprscale); |
140 | I915_WRITE(SPRSCALE(pipe), sprscale); |
140 | I915_WRITE(SPRCTL(pipe), sprctl); |
141 | I915_WRITE(SPRCTL(pipe), sprctl); |
141 | I915_MODIFY_DISPBASE(SPRSURF(pipe), obj->gtt_offset); |
142 | I915_MODIFY_DISPBASE(SPRSURF(pipe), obj->gtt_offset + sprsurf_offset); |
142 | POSTING_READ(SPRSURF(pipe)); |
143 | POSTING_READ(SPRSURF(pipe)); |
143 | } |
144 | } |
144 | 145 | ||
145 | static void |
146 | static void |
146 | ivb_disable_plane(struct drm_plane *plane) |
147 | ivb_disable_plane(struct drm_plane *plane) |
147 | { |
148 | { |
148 | struct drm_device *dev = plane->dev; |
149 | struct drm_device *dev = plane->dev; |
149 | struct drm_i915_private *dev_priv = dev->dev_private; |
150 | struct drm_i915_private *dev_priv = dev->dev_private; |
150 | struct intel_plane *intel_plane = to_intel_plane(plane); |
151 | struct intel_plane *intel_plane = to_intel_plane(plane); |
151 | int pipe = intel_plane->pipe; |
152 | int pipe = intel_plane->pipe; |
152 | 153 | ||
153 | I915_WRITE(SPRCTL(pipe), I915_READ(SPRCTL(pipe)) & ~SPRITE_ENABLE); |
154 | I915_WRITE(SPRCTL(pipe), I915_READ(SPRCTL(pipe)) & ~SPRITE_ENABLE); |
154 | /* Can't leave the scaler enabled... */ |
155 | /* Can't leave the scaler enabled... */ |
- | 156 | if (intel_plane->can_scale) |
|
155 | I915_WRITE(SPRSCALE(pipe), 0); |
157 | I915_WRITE(SPRSCALE(pipe), 0); |
156 | /* Activate double buffered register update */ |
158 | /* Activate double buffered register update */ |
157 | I915_MODIFY_DISPBASE(SPRSURF(pipe), 0); |
159 | I915_MODIFY_DISPBASE(SPRSURF(pipe), 0); |
158 | POSTING_READ(SPRSURF(pipe)); |
160 | POSTING_READ(SPRSURF(pipe)); |
159 | 161 | ||
160 | dev_priv->sprite_scaling_enabled = false; |
162 | dev_priv->sprite_scaling_enabled = false; |
161 | intel_update_watermarks(dev); |
163 | intel_update_watermarks(dev); |
162 | } |
164 | } |
163 | 165 | ||
164 | static int |
166 | static int |
165 | ivb_update_colorkey(struct drm_plane *plane, |
167 | ivb_update_colorkey(struct drm_plane *plane, |
166 | struct drm_intel_sprite_colorkey *key) |
168 | struct drm_intel_sprite_colorkey *key) |
167 | { |
169 | { |
168 | struct drm_device *dev = plane->dev; |
170 | struct drm_device *dev = plane->dev; |
169 | struct drm_i915_private *dev_priv = dev->dev_private; |
171 | struct drm_i915_private *dev_priv = dev->dev_private; |
170 | struct intel_plane *intel_plane; |
172 | struct intel_plane *intel_plane; |
171 | u32 sprctl; |
173 | u32 sprctl; |
172 | int ret = 0; |
174 | int ret = 0; |
173 | 175 | ||
174 | intel_plane = to_intel_plane(plane); |
176 | intel_plane = to_intel_plane(plane); |
175 | 177 | ||
176 | I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value); |
178 | I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value); |
177 | I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value); |
179 | I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value); |
178 | I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask); |
180 | I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask); |
179 | 181 | ||
180 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
182 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
181 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); |
183 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); |
182 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
184 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
183 | sprctl |= SPRITE_DEST_KEY; |
185 | sprctl |= SPRITE_DEST_KEY; |
184 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
186 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
185 | sprctl |= SPRITE_SOURCE_KEY; |
187 | sprctl |= SPRITE_SOURCE_KEY; |
186 | I915_WRITE(SPRCTL(intel_plane->pipe), sprctl); |
188 | I915_WRITE(SPRCTL(intel_plane->pipe), sprctl); |
187 | 189 | ||
188 | POSTING_READ(SPRKEYMSK(intel_plane->pipe)); |
190 | POSTING_READ(SPRKEYMSK(intel_plane->pipe)); |
189 | 191 | ||
190 | return ret; |
192 | return ret; |
191 | } |
193 | } |
192 | 194 | ||
193 | static void |
195 | static void |
194 | ivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
196 | ivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
195 | { |
197 | { |
196 | struct drm_device *dev = plane->dev; |
198 | struct drm_device *dev = plane->dev; |
197 | struct drm_i915_private *dev_priv = dev->dev_private; |
199 | struct drm_i915_private *dev_priv = dev->dev_private; |
198 | struct intel_plane *intel_plane; |
200 | struct intel_plane *intel_plane; |
199 | u32 sprctl; |
201 | u32 sprctl; |
200 | 202 | ||
201 | intel_plane = to_intel_plane(plane); |
203 | intel_plane = to_intel_plane(plane); |
202 | 204 | ||
203 | key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe)); |
205 | key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe)); |
204 | key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe)); |
206 | key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe)); |
205 | key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe)); |
207 | key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe)); |
206 | key->flags = 0; |
208 | key->flags = 0; |
207 | 209 | ||
208 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
210 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); |
209 | 211 | ||
210 | if (sprctl & SPRITE_DEST_KEY) |
212 | if (sprctl & SPRITE_DEST_KEY) |
211 | key->flags = I915_SET_COLORKEY_DESTINATION; |
213 | key->flags = I915_SET_COLORKEY_DESTINATION; |
212 | else if (sprctl & SPRITE_SOURCE_KEY) |
214 | else if (sprctl & SPRITE_SOURCE_KEY) |
213 | key->flags = I915_SET_COLORKEY_SOURCE; |
215 | key->flags = I915_SET_COLORKEY_SOURCE; |
214 | else |
216 | else |
215 | key->flags = I915_SET_COLORKEY_NONE; |
217 | key->flags = I915_SET_COLORKEY_NONE; |
216 | } |
218 | } |
217 | 219 | ||
218 | static void |
220 | static void |
219 | ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
221 | ilk_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, |
220 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
222 | struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, |
221 | unsigned int crtc_w, unsigned int crtc_h, |
223 | unsigned int crtc_w, unsigned int crtc_h, |
222 | uint32_t x, uint32_t y, |
224 | uint32_t x, uint32_t y, |
223 | uint32_t src_w, uint32_t src_h) |
225 | uint32_t src_w, uint32_t src_h) |
224 | { |
226 | { |
225 | struct drm_device *dev = plane->dev; |
227 | struct drm_device *dev = plane->dev; |
226 | struct drm_i915_private *dev_priv = dev->dev_private; |
228 | struct drm_i915_private *dev_priv = dev->dev_private; |
227 | struct intel_plane *intel_plane = to_intel_plane(plane); |
229 | struct intel_plane *intel_plane = to_intel_plane(plane); |
228 | int pipe = intel_plane->pipe, pixel_size; |
230 | int pipe = intel_plane->pipe; |
- | 231 | unsigned long dvssurf_offset, linear_offset; |
|
229 | u32 dvscntr, dvsscale; |
232 | u32 dvscntr, dvsscale; |
- | 233 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
|
230 | 234 | ||
231 | dvscntr = I915_READ(DVSCNTR(pipe)); |
235 | dvscntr = I915_READ(DVSCNTR(pipe)); |
232 | 236 | ||
233 | /* Mask out pixel format bits in case we change it */ |
237 | /* Mask out pixel format bits in case we change it */ |
234 | dvscntr &= ~DVS_PIXFORMAT_MASK; |
238 | dvscntr &= ~DVS_PIXFORMAT_MASK; |
235 | dvscntr &= ~DVS_RGB_ORDER_XBGR; |
239 | dvscntr &= ~DVS_RGB_ORDER_XBGR; |
236 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; |
240 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; |
237 | dvscntr &= ~DVS_TILED; |
241 | dvscntr &= ~DVS_TILED; |
238 | 242 | ||
239 | switch (fb->pixel_format) { |
243 | switch (fb->pixel_format) { |
240 | case DRM_FORMAT_XBGR8888: |
244 | case DRM_FORMAT_XBGR8888: |
241 | dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR; |
245 | dvscntr |= DVS_FORMAT_RGBX888 | DVS_RGB_ORDER_XBGR; |
242 | pixel_size = 4; |
- | |
243 | break; |
246 | break; |
244 | case DRM_FORMAT_XRGB8888: |
247 | case DRM_FORMAT_XRGB8888: |
245 | dvscntr |= DVS_FORMAT_RGBX888; |
248 | dvscntr |= DVS_FORMAT_RGBX888; |
246 | pixel_size = 4; |
- | |
247 | break; |
249 | break; |
248 | case DRM_FORMAT_YUYV: |
250 | case DRM_FORMAT_YUYV: |
249 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV; |
251 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YUYV; |
250 | pixel_size = 2; |
- | |
251 | break; |
252 | break; |
252 | case DRM_FORMAT_YVYU: |
253 | case DRM_FORMAT_YVYU: |
253 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU; |
254 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_YVYU; |
254 | pixel_size = 2; |
- | |
255 | break; |
255 | break; |
256 | case DRM_FORMAT_UYVY: |
256 | case DRM_FORMAT_UYVY: |
257 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY; |
257 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_UYVY; |
258 | pixel_size = 2; |
- | |
259 | break; |
258 | break; |
260 | case DRM_FORMAT_VYUY: |
259 | case DRM_FORMAT_VYUY: |
261 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY; |
260 | dvscntr |= DVS_FORMAT_YUV422 | DVS_YUV_ORDER_VYUY; |
262 | pixel_size = 2; |
- | |
263 | break; |
261 | break; |
264 | default: |
262 | default: |
265 | DRM_DEBUG_DRIVER("bad pixel format, assuming RGBX888\n"); |
- | |
266 | dvscntr |= DVS_FORMAT_RGBX888; |
- | |
267 | pixel_size = 4; |
- | |
268 | break; |
263 | BUG(); |
269 | } |
264 | } |
270 | 265 | ||
271 | if (obj->tiling_mode != I915_TILING_NONE) |
266 | if (obj->tiling_mode != I915_TILING_NONE) |
272 | dvscntr |= DVS_TILED; |
267 | dvscntr |= DVS_TILED; |
273 | 268 | ||
274 | if (IS_GEN6(dev)) |
269 | if (IS_GEN6(dev)) |
275 | dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */ |
270 | dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */ |
276 | dvscntr |= DVS_ENABLE; |
271 | dvscntr |= DVS_ENABLE; |
277 | 272 | ||
278 | /* Sizes are 0 based */ |
273 | /* Sizes are 0 based */ |
279 | src_w--; |
274 | src_w--; |
280 | src_h--; |
275 | src_h--; |
281 | crtc_w--; |
276 | crtc_w--; |
282 | crtc_h--; |
277 | crtc_h--; |
283 | 278 | ||
284 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
279 | intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size); |
285 | 280 | ||
286 | dvsscale = 0; |
281 | dvsscale = 0; |
287 | if (IS_GEN5(dev) || crtc_w != src_w || crtc_h != src_h) |
282 | if (IS_GEN5(dev) || crtc_w != src_w || crtc_h != src_h) |
288 | dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; |
283 | dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h; |
289 | 284 | ||
290 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); |
285 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); |
291 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
286 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
- | 287 | ||
- | 288 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
|
- | 289 | dvssurf_offset = |
|
- | 290 | intel_gen4_compute_offset_xtiled(&x, &y, |
|
- | 291 | pixel_size, fb->pitches[0]); |
|
- | 292 | linear_offset -= dvssurf_offset; |
|
- | 293 | ||
292 | if (obj->tiling_mode != I915_TILING_NONE) { |
294 | if (obj->tiling_mode != I915_TILING_NONE) |
293 | I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x); |
295 | I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x); |
294 | } else { |
296 | else |
295 | unsigned long offset; |
297 | I915_WRITE(DVSLINOFF(pipe), linear_offset); |
296 | - | ||
297 | offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); |
- | |
298 | I915_WRITE(DVSLINOFF(pipe), offset); |
- | |
299 | } |
298 | |
300 | I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); |
299 | I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w); |
301 | I915_WRITE(DVSSCALE(pipe), dvsscale); |
300 | I915_WRITE(DVSSCALE(pipe), dvsscale); |
302 | I915_WRITE(DVSCNTR(pipe), dvscntr); |
301 | I915_WRITE(DVSCNTR(pipe), dvscntr); |
303 | I915_MODIFY_DISPBASE(DVSSURF(pipe), obj->gtt_offset); |
302 | I915_MODIFY_DISPBASE(DVSSURF(pipe), obj->gtt_offset + dvssurf_offset); |
304 | POSTING_READ(DVSSURF(pipe)); |
303 | POSTING_READ(DVSSURF(pipe)); |
305 | } |
304 | } |
306 | 305 | ||
307 | static void |
306 | static void |
308 | ilk_disable_plane(struct drm_plane *plane) |
307 | ilk_disable_plane(struct drm_plane *plane) |
309 | { |
308 | { |
310 | struct drm_device *dev = plane->dev; |
309 | struct drm_device *dev = plane->dev; |
311 | struct drm_i915_private *dev_priv = dev->dev_private; |
310 | struct drm_i915_private *dev_priv = dev->dev_private; |
312 | struct intel_plane *intel_plane = to_intel_plane(plane); |
311 | struct intel_plane *intel_plane = to_intel_plane(plane); |
313 | int pipe = intel_plane->pipe; |
312 | int pipe = intel_plane->pipe; |
314 | 313 | ||
315 | I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE); |
314 | I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE); |
316 | /* Disable the scaler */ |
315 | /* Disable the scaler */ |
317 | I915_WRITE(DVSSCALE(pipe), 0); |
316 | I915_WRITE(DVSSCALE(pipe), 0); |
318 | /* Flush double buffered register updates */ |
317 | /* Flush double buffered register updates */ |
319 | I915_MODIFY_DISPBASE(DVSSURF(pipe), 0); |
318 | I915_MODIFY_DISPBASE(DVSSURF(pipe), 0); |
320 | POSTING_READ(DVSSURF(pipe)); |
319 | POSTING_READ(DVSSURF(pipe)); |
321 | } |
320 | } |
322 | 321 | ||
323 | static void |
322 | static void |
324 | intel_enable_primary(struct drm_crtc *crtc) |
323 | intel_enable_primary(struct drm_crtc *crtc) |
325 | { |
324 | { |
326 | struct drm_device *dev = crtc->dev; |
325 | struct drm_device *dev = crtc->dev; |
327 | struct drm_i915_private *dev_priv = dev->dev_private; |
326 | struct drm_i915_private *dev_priv = dev->dev_private; |
328 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
327 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
329 | int reg = DSPCNTR(intel_crtc->plane); |
328 | int reg = DSPCNTR(intel_crtc->plane); |
330 | 329 | ||
331 | if (!intel_crtc->primary_disabled) |
330 | if (!intel_crtc->primary_disabled) |
332 | return; |
331 | return; |
333 | 332 | ||
334 | intel_crtc->primary_disabled = false; |
333 | intel_crtc->primary_disabled = false; |
335 | intel_update_fbc(dev); |
334 | intel_update_fbc(dev); |
336 | 335 | ||
337 | I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE); |
336 | I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE); |
338 | } |
337 | } |
339 | 338 | ||
340 | static void |
339 | static void |
341 | intel_disable_primary(struct drm_crtc *crtc) |
340 | intel_disable_primary(struct drm_crtc *crtc) |
342 | { |
341 | { |
343 | struct drm_device *dev = crtc->dev; |
342 | struct drm_device *dev = crtc->dev; |
344 | struct drm_i915_private *dev_priv = dev->dev_private; |
343 | struct drm_i915_private *dev_priv = dev->dev_private; |
345 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
344 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
346 | int reg = DSPCNTR(intel_crtc->plane); |
345 | int reg = DSPCNTR(intel_crtc->plane); |
347 | 346 | ||
348 | if (intel_crtc->primary_disabled) |
347 | if (intel_crtc->primary_disabled) |
349 | return; |
348 | return; |
350 | 349 | ||
351 | I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE); |
350 | I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE); |
352 | 351 | ||
353 | intel_crtc->primary_disabled = true; |
352 | intel_crtc->primary_disabled = true; |
354 | intel_update_fbc(dev); |
353 | intel_update_fbc(dev); |
355 | } |
354 | } |
356 | 355 | ||
357 | static int |
356 | static int |
358 | ilk_update_colorkey(struct drm_plane *plane, |
357 | ilk_update_colorkey(struct drm_plane *plane, |
359 | struct drm_intel_sprite_colorkey *key) |
358 | struct drm_intel_sprite_colorkey *key) |
360 | { |
359 | { |
361 | struct drm_device *dev = plane->dev; |
360 | struct drm_device *dev = plane->dev; |
362 | struct drm_i915_private *dev_priv = dev->dev_private; |
361 | struct drm_i915_private *dev_priv = dev->dev_private; |
363 | struct intel_plane *intel_plane; |
362 | struct intel_plane *intel_plane; |
364 | u32 dvscntr; |
363 | u32 dvscntr; |
365 | int ret = 0; |
364 | int ret = 0; |
366 | 365 | ||
367 | intel_plane = to_intel_plane(plane); |
366 | intel_plane = to_intel_plane(plane); |
368 | 367 | ||
369 | I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value); |
368 | I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value); |
370 | I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value); |
369 | I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value); |
371 | I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask); |
370 | I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask); |
372 | 371 | ||
373 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
372 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
374 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); |
373 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); |
375 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
374 | if (key->flags & I915_SET_COLORKEY_DESTINATION) |
376 | dvscntr |= DVS_DEST_KEY; |
375 | dvscntr |= DVS_DEST_KEY; |
377 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
376 | else if (key->flags & I915_SET_COLORKEY_SOURCE) |
378 | dvscntr |= DVS_SOURCE_KEY; |
377 | dvscntr |= DVS_SOURCE_KEY; |
379 | I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr); |
378 | I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr); |
380 | 379 | ||
381 | POSTING_READ(DVSKEYMSK(intel_plane->pipe)); |
380 | POSTING_READ(DVSKEYMSK(intel_plane->pipe)); |
382 | 381 | ||
383 | return ret; |
382 | return ret; |
384 | } |
383 | } |
385 | 384 | ||
386 | static void |
385 | static void |
387 | ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
386 | ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) |
388 | { |
387 | { |
389 | struct drm_device *dev = plane->dev; |
388 | struct drm_device *dev = plane->dev; |
390 | struct drm_i915_private *dev_priv = dev->dev_private; |
389 | struct drm_i915_private *dev_priv = dev->dev_private; |
391 | struct intel_plane *intel_plane; |
390 | struct intel_plane *intel_plane; |
392 | u32 dvscntr; |
391 | u32 dvscntr; |
393 | 392 | ||
394 | intel_plane = to_intel_plane(plane); |
393 | intel_plane = to_intel_plane(plane); |
395 | 394 | ||
396 | key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe)); |
395 | key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe)); |
397 | key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe)); |
396 | key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe)); |
398 | key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe)); |
397 | key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe)); |
399 | key->flags = 0; |
398 | key->flags = 0; |
400 | 399 | ||
401 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
400 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); |
402 | 401 | ||
403 | if (dvscntr & DVS_DEST_KEY) |
402 | if (dvscntr & DVS_DEST_KEY) |
404 | key->flags = I915_SET_COLORKEY_DESTINATION; |
403 | key->flags = I915_SET_COLORKEY_DESTINATION; |
405 | else if (dvscntr & DVS_SOURCE_KEY) |
404 | else if (dvscntr & DVS_SOURCE_KEY) |
406 | key->flags = I915_SET_COLORKEY_SOURCE; |
405 | key->flags = I915_SET_COLORKEY_SOURCE; |
407 | else |
406 | else |
408 | key->flags = I915_SET_COLORKEY_NONE; |
407 | key->flags = I915_SET_COLORKEY_NONE; |
409 | } |
408 | } |
410 | 409 | ||
411 | static int |
410 | static int |
412 | intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
411 | intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
413 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
412 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
414 | unsigned int crtc_w, unsigned int crtc_h, |
413 | unsigned int crtc_w, unsigned int crtc_h, |
415 | uint32_t src_x, uint32_t src_y, |
414 | uint32_t src_x, uint32_t src_y, |
416 | uint32_t src_w, uint32_t src_h) |
415 | uint32_t src_w, uint32_t src_h) |
417 | { |
416 | { |
418 | struct drm_device *dev = plane->dev; |
417 | struct drm_device *dev = plane->dev; |
419 | struct drm_i915_private *dev_priv = dev->dev_private; |
418 | struct drm_i915_private *dev_priv = dev->dev_private; |
420 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
419 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
421 | struct intel_plane *intel_plane = to_intel_plane(plane); |
420 | struct intel_plane *intel_plane = to_intel_plane(plane); |
422 | struct intel_framebuffer *intel_fb; |
421 | struct intel_framebuffer *intel_fb; |
423 | struct drm_i915_gem_object *obj, *old_obj; |
422 | struct drm_i915_gem_object *obj, *old_obj; |
424 | int pipe = intel_plane->pipe; |
423 | int pipe = intel_plane->pipe; |
- | 424 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
|
- | 425 | pipe); |
|
425 | int ret = 0; |
426 | int ret = 0; |
426 | int x = src_x >> 16, y = src_y >> 16; |
427 | int x = src_x >> 16, y = src_y >> 16; |
427 | int primary_w = crtc->mode.hdisplay, primary_h = crtc->mode.vdisplay; |
428 | int primary_w = crtc->mode.hdisplay, primary_h = crtc->mode.vdisplay; |
428 | bool disable_primary = false; |
429 | bool disable_primary = false; |
429 | 430 | ||
430 | intel_fb = to_intel_framebuffer(fb); |
431 | intel_fb = to_intel_framebuffer(fb); |
431 | obj = intel_fb->obj; |
432 | obj = intel_fb->obj; |
432 | 433 | ||
433 | old_obj = intel_plane->obj; |
434 | old_obj = intel_plane->obj; |
434 | 435 | ||
435 | src_w = src_w >> 16; |
436 | src_w = src_w >> 16; |
436 | src_h = src_h >> 16; |
437 | src_h = src_h >> 16; |
437 | 438 | ||
438 | /* Pipe must be running... */ |
439 | /* Pipe must be running... */ |
439 | if (!(I915_READ(PIPECONF(pipe)) & PIPECONF_ENABLE)) |
440 | if (!(I915_READ(PIPECONF(cpu_transcoder)) & PIPECONF_ENABLE)) |
440 | return -EINVAL; |
441 | return -EINVAL; |
441 | 442 | ||
442 | if (crtc_x >= primary_w || crtc_y >= primary_h) |
443 | if (crtc_x >= primary_w || crtc_y >= primary_h) |
443 | return -EINVAL; |
444 | return -EINVAL; |
444 | 445 | ||
445 | /* Don't modify another pipe's plane */ |
446 | /* Don't modify another pipe's plane */ |
446 | if (intel_plane->pipe != intel_crtc->pipe) |
447 | if (intel_plane->pipe != intel_crtc->pipe) |
447 | return -EINVAL; |
448 | return -EINVAL; |
- | 449 | ||
- | 450 | /* Sprite planes can be linear or x-tiled surfaces */ |
|
- | 451 | switch (obj->tiling_mode) { |
|
- | 452 | case I915_TILING_NONE: |
|
- | 453 | case I915_TILING_X: |
|
- | 454 | break; |
|
- | 455 | default: |
|
- | 456 | return -EINVAL; |
|
- | 457 | } |
|
448 | 458 | ||
449 | /* |
459 | /* |
450 | * Clamp the width & height into the visible area. Note we don't |
460 | * Clamp the width & height into the visible area. Note we don't |
451 | * try to scale the source if part of the visible region is offscreen. |
461 | * try to scale the source if part of the visible region is offscreen. |
452 | * The caller must handle that by adjusting source offset and size. |
462 | * The caller must handle that by adjusting source offset and size. |
453 | */ |
463 | */ |
454 | if ((crtc_x < 0) && ((crtc_x + crtc_w) > 0)) { |
464 | if ((crtc_x < 0) && ((crtc_x + crtc_w) > 0)) { |
455 | crtc_w += crtc_x; |
465 | crtc_w += crtc_x; |
456 | crtc_x = 0; |
466 | crtc_x = 0; |
457 | } |
467 | } |
458 | if ((crtc_x + crtc_w) <= 0) /* Nothing to display */ |
468 | if ((crtc_x + crtc_w) <= 0) /* Nothing to display */ |
459 | goto out; |
469 | goto out; |
460 | if ((crtc_x + crtc_w) > primary_w) |
470 | if ((crtc_x + crtc_w) > primary_w) |
461 | crtc_w = primary_w - crtc_x; |
471 | crtc_w = primary_w - crtc_x; |
462 | 472 | ||
463 | if ((crtc_y < 0) && ((crtc_y + crtc_h) > 0)) { |
473 | if ((crtc_y < 0) && ((crtc_y + crtc_h) > 0)) { |
464 | crtc_h += crtc_y; |
474 | crtc_h += crtc_y; |
465 | crtc_y = 0; |
475 | crtc_y = 0; |
466 | } |
476 | } |
467 | if ((crtc_y + crtc_h) <= 0) /* Nothing to display */ |
477 | if ((crtc_y + crtc_h) <= 0) /* Nothing to display */ |
468 | goto out; |
478 | goto out; |
469 | if (crtc_y + crtc_h > primary_h) |
479 | if (crtc_y + crtc_h > primary_h) |
470 | crtc_h = primary_h - crtc_y; |
480 | crtc_h = primary_h - crtc_y; |
471 | 481 | ||
472 | if (!crtc_w || !crtc_h) /* Again, nothing to display */ |
482 | if (!crtc_w || !crtc_h) /* Again, nothing to display */ |
473 | goto out; |
483 | goto out; |
474 | 484 | ||
475 | /* |
485 | /* |
- | 486 | * We may not have a scaler, eg. HSW does not have it any more |
|
- | 487 | */ |
|
- | 488 | if (!intel_plane->can_scale && (crtc_w != src_w || crtc_h != src_h)) |
|
- | 489 | return -EINVAL; |
|
- | 490 | ||
- | 491 | /* |
|
476 | * We can take a larger source and scale it down, but |
492 | * We can take a larger source and scale it down, but |
477 | * only so much... 16x is the max on SNB. |
493 | * only so much... 16x is the max on SNB. |
478 | */ |
494 | */ |
479 | if (((src_w * src_h) / (crtc_w * crtc_h)) > intel_plane->max_downscale) |
495 | if (((src_w * src_h) / (crtc_w * crtc_h)) > intel_plane->max_downscale) |
480 | return -EINVAL; |
496 | return -EINVAL; |
481 | 497 | ||
482 | /* |
498 | /* |
483 | * If the sprite is completely covering the primary plane, |
499 | * If the sprite is completely covering the primary plane, |
484 | * we can disable the primary and save power. |
500 | * we can disable the primary and save power. |
485 | */ |
501 | */ |
486 | if ((crtc_x == 0) && (crtc_y == 0) && |
502 | if ((crtc_x == 0) && (crtc_y == 0) && |
487 | (crtc_w == primary_w) && (crtc_h == primary_h)) |
503 | (crtc_w == primary_w) && (crtc_h == primary_h)) |
488 | disable_primary = true; |
504 | disable_primary = true; |
489 | 505 | ||
490 | mutex_lock(&dev->struct_mutex); |
506 | mutex_lock(&dev->struct_mutex); |
491 | 507 | ||
492 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
508 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
493 | if (ret) |
509 | if (ret) |
494 | goto out_unlock; |
510 | goto out_unlock; |
495 | 511 | ||
496 | intel_plane->obj = obj; |
512 | intel_plane->obj = obj; |
497 | 513 | ||
498 | /* |
514 | /* |
499 | * Be sure to re-enable the primary before the sprite is no longer |
515 | * Be sure to re-enable the primary before the sprite is no longer |
500 | * covering it fully. |
516 | * covering it fully. |
501 | */ |
517 | */ |
502 | if (!disable_primary) |
518 | if (!disable_primary) |
503 | intel_enable_primary(crtc); |
519 | intel_enable_primary(crtc); |
504 | 520 | ||
505 | intel_plane->update_plane(plane, fb, obj, crtc_x, crtc_y, |
521 | intel_plane->update_plane(plane, fb, obj, crtc_x, crtc_y, |
506 | crtc_w, crtc_h, x, y, src_w, src_h); |
522 | crtc_w, crtc_h, x, y, src_w, src_h); |
507 | 523 | ||
508 | if (disable_primary) |
524 | if (disable_primary) |
509 | intel_disable_primary(crtc); |
525 | intel_disable_primary(crtc); |
510 | 526 | ||
511 | /* Unpin old obj after new one is active to avoid ugliness */ |
527 | /* Unpin old obj after new one is active to avoid ugliness */ |
512 | if (old_obj) { |
528 | if (old_obj) { |
513 | /* |
529 | /* |
514 | * It's fairly common to simply update the position of |
530 | * It's fairly common to simply update the position of |
515 | * an existing object. In that case, we don't need to |
531 | * an existing object. In that case, we don't need to |
516 | * wait for vblank to avoid ugliness, we only need to |
532 | * wait for vblank to avoid ugliness, we only need to |
517 | * do the pin & ref bookkeeping. |
533 | * do the pin & ref bookkeeping. |
518 | */ |
534 | */ |
519 | if (old_obj != obj) { |
535 | if (old_obj != obj) { |
520 | mutex_unlock(&dev->struct_mutex); |
536 | mutex_unlock(&dev->struct_mutex); |
521 | intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); |
537 | intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe); |
522 | mutex_lock(&dev->struct_mutex); |
538 | mutex_lock(&dev->struct_mutex); |
523 | } |
539 | } |
524 | intel_unpin_fb_obj(old_obj); |
540 | intel_unpin_fb_obj(old_obj); |
525 | } |
541 | } |
526 | 542 | ||
527 | out_unlock: |
543 | out_unlock: |
528 | mutex_unlock(&dev->struct_mutex); |
544 | mutex_unlock(&dev->struct_mutex); |
529 | out: |
545 | out: |
530 | return ret; |
546 | return ret; |
531 | } |
547 | } |
532 | 548 | ||
533 | static int |
549 | static int |
534 | intel_disable_plane(struct drm_plane *plane) |
550 | intel_disable_plane(struct drm_plane *plane) |
535 | { |
551 | { |
536 | struct drm_device *dev = plane->dev; |
552 | struct drm_device *dev = plane->dev; |
537 | struct intel_plane *intel_plane = to_intel_plane(plane); |
553 | struct intel_plane *intel_plane = to_intel_plane(plane); |
538 | int ret = 0; |
554 | int ret = 0; |
539 | 555 | ||
540 | if (plane->crtc) |
556 | if (plane->crtc) |
541 | intel_enable_primary(plane->crtc); |
557 | intel_enable_primary(plane->crtc); |
542 | intel_plane->disable_plane(plane); |
558 | intel_plane->disable_plane(plane); |
543 | 559 | ||
544 | if (!intel_plane->obj) |
560 | if (!intel_plane->obj) |
545 | goto out; |
561 | goto out; |
546 | 562 | ||
547 | mutex_lock(&dev->struct_mutex); |
563 | mutex_lock(&dev->struct_mutex); |
548 | intel_unpin_fb_obj(intel_plane->obj); |
564 | intel_unpin_fb_obj(intel_plane->obj); |
549 | intel_plane->obj = NULL; |
565 | intel_plane->obj = NULL; |
550 | mutex_unlock(&dev->struct_mutex); |
566 | mutex_unlock(&dev->struct_mutex); |
551 | out: |
567 | out: |
552 | 568 | ||
553 | return ret; |
569 | return ret; |
554 | } |
570 | } |
555 | 571 | ||
556 | static void intel_destroy_plane(struct drm_plane *plane) |
572 | static void intel_destroy_plane(struct drm_plane *plane) |
557 | { |
573 | { |
558 | struct intel_plane *intel_plane = to_intel_plane(plane); |
574 | struct intel_plane *intel_plane = to_intel_plane(plane); |
559 | intel_disable_plane(plane); |
575 | intel_disable_plane(plane); |
560 | drm_plane_cleanup(plane); |
576 | drm_plane_cleanup(plane); |
561 | kfree(intel_plane); |
577 | kfree(intel_plane); |
562 | } |
578 | } |
563 | 579 | ||
564 | int intel_sprite_set_colorkey(struct drm_device *dev, void *data, |
580 | int intel_sprite_set_colorkey(struct drm_device *dev, void *data, |
565 | struct drm_file *file_priv) |
581 | struct drm_file *file_priv) |
566 | { |
582 | { |
567 | struct drm_intel_sprite_colorkey *set = data; |
583 | struct drm_intel_sprite_colorkey *set = data; |
568 | struct drm_mode_object *obj; |
584 | struct drm_mode_object *obj; |
569 | struct drm_plane *plane; |
585 | struct drm_plane *plane; |
570 | struct intel_plane *intel_plane; |
586 | struct intel_plane *intel_plane; |
571 | int ret = 0; |
587 | int ret = 0; |
572 | - | ||
573 | // if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
- | |
574 | // return -ENODEV; |
588 | |
575 | 589 | ||
576 | /* Make sure we don't try to enable both src & dest simultaneously */ |
590 | /* Make sure we don't try to enable both src & dest simultaneously */ |
577 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
591 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
578 | return -EINVAL; |
592 | return -EINVAL; |
579 | 593 | ||
580 | mutex_lock(&dev->mode_config.mutex); |
594 | mutex_lock(&dev->mode_config.mutex); |
581 | 595 | ||
582 | obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE); |
596 | obj = drm_mode_object_find(dev, set->plane_id, DRM_MODE_OBJECT_PLANE); |
583 | if (!obj) { |
597 | if (!obj) { |
584 | ret = -EINVAL; |
598 | ret = -EINVAL; |
585 | goto out_unlock; |
599 | goto out_unlock; |
586 | } |
600 | } |
587 | 601 | ||
588 | plane = obj_to_plane(obj); |
602 | plane = obj_to_plane(obj); |
589 | intel_plane = to_intel_plane(plane); |
603 | intel_plane = to_intel_plane(plane); |
590 | ret = intel_plane->update_colorkey(plane, set); |
604 | ret = intel_plane->update_colorkey(plane, set); |
591 | 605 | ||
592 | out_unlock: |
606 | out_unlock: |
593 | mutex_unlock(&dev->mode_config.mutex); |
607 | mutex_unlock(&dev->mode_config.mutex); |
594 | return ret; |
608 | return ret; |
595 | } |
609 | } |
596 | 610 | ||
597 | int intel_sprite_get_colorkey(struct drm_device *dev, void *data, |
611 | int intel_sprite_get_colorkey(struct drm_device *dev, void *data, |
598 | struct drm_file *file_priv) |
612 | struct drm_file *file_priv) |
599 | { |
613 | { |
600 | struct drm_intel_sprite_colorkey *get = data; |
614 | struct drm_intel_sprite_colorkey *get = data; |
601 | struct drm_mode_object *obj; |
615 | struct drm_mode_object *obj; |
602 | struct drm_plane *plane; |
616 | struct drm_plane *plane; |
603 | struct intel_plane *intel_plane; |
617 | struct intel_plane *intel_plane; |
604 | int ret = 0; |
618 | int ret = 0; |
605 | - | ||
606 | // if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
- | |
607 | // return -ENODEV; |
619 | |
608 | 620 | ||
609 | mutex_lock(&dev->mode_config.mutex); |
621 | mutex_lock(&dev->mode_config.mutex); |
610 | 622 | ||
611 | obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE); |
623 | obj = drm_mode_object_find(dev, get->plane_id, DRM_MODE_OBJECT_PLANE); |
612 | if (!obj) { |
624 | if (!obj) { |
613 | ret = -EINVAL; |
625 | ret = -EINVAL; |
614 | goto out_unlock; |
626 | goto out_unlock; |
615 | } |
627 | } |
616 | 628 | ||
617 | plane = obj_to_plane(obj); |
629 | plane = obj_to_plane(obj); |
618 | intel_plane = to_intel_plane(plane); |
630 | intel_plane = to_intel_plane(plane); |
619 | intel_plane->get_colorkey(plane, get); |
631 | intel_plane->get_colorkey(plane, get); |
620 | 632 | ||
621 | out_unlock: |
633 | out_unlock: |
622 | mutex_unlock(&dev->mode_config.mutex); |
634 | mutex_unlock(&dev->mode_config.mutex); |
623 | return ret; |
635 | return ret; |
624 | } |
636 | } |
625 | 637 | ||
626 | static const struct drm_plane_funcs intel_plane_funcs = { |
638 | static const struct drm_plane_funcs intel_plane_funcs = { |
627 | .update_plane = intel_update_plane, |
639 | .update_plane = intel_update_plane, |
628 | .disable_plane = intel_disable_plane, |
640 | .disable_plane = intel_disable_plane, |
629 | .destroy = intel_destroy_plane, |
641 | .destroy = intel_destroy_plane, |
630 | }; |
642 | }; |
631 | 643 | ||
632 | static uint32_t ilk_plane_formats[] = { |
644 | static uint32_t ilk_plane_formats[] = { |
633 | DRM_FORMAT_XRGB8888, |
645 | DRM_FORMAT_XRGB8888, |
634 | DRM_FORMAT_YUYV, |
646 | DRM_FORMAT_YUYV, |
635 | DRM_FORMAT_YVYU, |
647 | DRM_FORMAT_YVYU, |
636 | DRM_FORMAT_UYVY, |
648 | DRM_FORMAT_UYVY, |
637 | DRM_FORMAT_VYUY, |
649 | DRM_FORMAT_VYUY, |
638 | }; |
650 | }; |
639 | 651 | ||
640 | static uint32_t snb_plane_formats[] = { |
652 | static uint32_t snb_plane_formats[] = { |
641 | DRM_FORMAT_XBGR8888, |
653 | DRM_FORMAT_XBGR8888, |
642 | DRM_FORMAT_XRGB8888, |
654 | DRM_FORMAT_XRGB8888, |
643 | DRM_FORMAT_YUYV, |
655 | DRM_FORMAT_YUYV, |
644 | DRM_FORMAT_YVYU, |
656 | DRM_FORMAT_YVYU, |
645 | DRM_FORMAT_UYVY, |
657 | DRM_FORMAT_UYVY, |
646 | DRM_FORMAT_VYUY, |
658 | DRM_FORMAT_VYUY, |
647 | }; |
659 | }; |
648 | 660 | ||
649 | int |
661 | int |
650 | intel_plane_init(struct drm_device *dev, enum pipe pipe) |
662 | intel_plane_init(struct drm_device *dev, enum pipe pipe) |
651 | { |
663 | { |
652 | struct intel_plane *intel_plane; |
664 | struct intel_plane *intel_plane; |
653 | unsigned long possible_crtcs; |
665 | unsigned long possible_crtcs; |
654 | const uint32_t *plane_formats; |
666 | const uint32_t *plane_formats; |
655 | int num_plane_formats; |
667 | int num_plane_formats; |
656 | int ret; |
668 | int ret; |
657 | 669 | ||
658 | if (INTEL_INFO(dev)->gen < 5) |
670 | if (INTEL_INFO(dev)->gen < 5) |
659 | return -ENODEV; |
671 | return -ENODEV; |
660 | 672 | ||
661 | intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL); |
673 | intel_plane = kzalloc(sizeof(struct intel_plane), GFP_KERNEL); |
662 | if (!intel_plane) |
674 | if (!intel_plane) |
663 | return -ENOMEM; |
675 | return -ENOMEM; |
664 | 676 | ||
665 | switch (INTEL_INFO(dev)->gen) { |
677 | switch (INTEL_INFO(dev)->gen) { |
666 | case 5: |
678 | case 5: |
667 | case 6: |
679 | case 6: |
- | 680 | intel_plane->can_scale = true; |
|
668 | intel_plane->max_downscale = 16; |
681 | intel_plane->max_downscale = 16; |
669 | intel_plane->update_plane = ilk_update_plane; |
682 | intel_plane->update_plane = ilk_update_plane; |
670 | intel_plane->disable_plane = ilk_disable_plane; |
683 | intel_plane->disable_plane = ilk_disable_plane; |
671 | intel_plane->update_colorkey = ilk_update_colorkey; |
684 | intel_plane->update_colorkey = ilk_update_colorkey; |
672 | intel_plane->get_colorkey = ilk_get_colorkey; |
685 | intel_plane->get_colorkey = ilk_get_colorkey; |
673 | 686 | ||
674 | if (IS_GEN6(dev)) { |
687 | if (IS_GEN6(dev)) { |
675 | plane_formats = snb_plane_formats; |
688 | plane_formats = snb_plane_formats; |
676 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
689 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
677 | } else { |
690 | } else { |
678 | plane_formats = ilk_plane_formats; |
691 | plane_formats = ilk_plane_formats; |
679 | num_plane_formats = ARRAY_SIZE(ilk_plane_formats); |
692 | num_plane_formats = ARRAY_SIZE(ilk_plane_formats); |
680 | } |
693 | } |
681 | break; |
694 | break; |
682 | 695 | ||
683 | case 7: |
696 | case 7: |
- | 697 | if (IS_HASWELL(dev) || IS_VALLEYVIEW(dev)) |
|
- | 698 | intel_plane->can_scale = false; |
|
- | 699 | else |
|
- | 700 | intel_plane->can_scale = true; |
|
684 | intel_plane->max_downscale = 2; |
701 | intel_plane->max_downscale = 2; |
685 | intel_plane->update_plane = ivb_update_plane; |
702 | intel_plane->update_plane = ivb_update_plane; |
686 | intel_plane->disable_plane = ivb_disable_plane; |
703 | intel_plane->disable_plane = ivb_disable_plane; |
687 | intel_plane->update_colorkey = ivb_update_colorkey; |
704 | intel_plane->update_colorkey = ivb_update_colorkey; |
688 | intel_plane->get_colorkey = ivb_get_colorkey; |
705 | intel_plane->get_colorkey = ivb_get_colorkey; |
689 | 706 | ||
690 | plane_formats = snb_plane_formats; |
707 | plane_formats = snb_plane_formats; |
691 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
708 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
692 | break; |
709 | break; |
693 | 710 | ||
694 | default: |
711 | default: |
695 | kfree(intel_plane); |
712 | kfree(intel_plane); |
696 | return -ENODEV; |
713 | return -ENODEV; |
697 | } |
714 | } |
698 | 715 | ||
699 | intel_plane->pipe = pipe; |
716 | intel_plane->pipe = pipe; |
700 | possible_crtcs = (1 << pipe); |
717 | possible_crtcs = (1 << pipe); |
701 | ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs, |
718 | ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs, |
702 | &intel_plane_funcs, |
719 | &intel_plane_funcs, |
703 | plane_formats, num_plane_formats, |
720 | plane_formats, num_plane_formats, |
704 | false); |
721 | false); |
705 | if (ret) |
722 | if (ret) |
706 | kfree(intel_plane); |
723 | kfree(intel_plane); |
707 | 724 | ||
708 | return ret; |
725 | return ret; |
709 | }><>>=>>=>>><>><>><>><>><>><>><>><> |
726 | }><>>=>>=>>><>><>><>><>><>><>><>><>><> |