Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2009 |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the next |
| 12 | * paragraph) shall be included in all copies or substantial portions of the |
| 13 | * Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | * SOFTWARE. |
| 22 | * |
| 23 | * Authors: |
| 24 | * Daniel Vetter <daniel@ffwll.ch> |
| 25 | * |
| 26 | * Derived from Xorg ddx, xf86-video-intel, src/i830_video.c |
| 27 | */ |
Andrew Morton | e167976 | 2010-08-24 16:35:52 -0700 | [diff] [blame] | 28 | |
| 29 | #include <linux/seq_file.h> |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 30 | #include "drmP.h" |
| 31 | #include "drm.h" |
| 32 | #include "i915_drm.h" |
| 33 | #include "i915_drv.h" |
| 34 | #include "i915_reg.h" |
| 35 | #include "intel_drv.h" |
| 36 | |
| 37 | /* Limits for overlay size. According to intel doc, the real limits are: |
| 38 | * Y width: 4095, UV width (planar): 2047, Y height: 2047, |
| 39 | * UV width (planar): * 1023. But the xorg thinks 2048 for height and width. Use |
| 40 | * the mininum of both. */ |
| 41 | #define IMAGE_MAX_WIDTH 2048 |
| 42 | #define IMAGE_MAX_HEIGHT 2046 /* 2 * 1023 */ |
| 43 | /* on 830 and 845 these large limits result in the card hanging */ |
| 44 | #define IMAGE_MAX_WIDTH_LEGACY 1024 |
| 45 | #define IMAGE_MAX_HEIGHT_LEGACY 1088 |
| 46 | |
| 47 | /* overlay register definitions */ |
| 48 | /* OCMD register */ |
| 49 | #define OCMD_TILED_SURFACE (0x1<<19) |
| 50 | #define OCMD_MIRROR_MASK (0x3<<17) |
| 51 | #define OCMD_MIRROR_MODE (0x3<<17) |
| 52 | #define OCMD_MIRROR_HORIZONTAL (0x1<<17) |
| 53 | #define OCMD_MIRROR_VERTICAL (0x2<<17) |
| 54 | #define OCMD_MIRROR_BOTH (0x3<<17) |
| 55 | #define OCMD_BYTEORDER_MASK (0x3<<14) /* zero for YUYV or FOURCC YUY2 */ |
| 56 | #define OCMD_UV_SWAP (0x1<<14) /* YVYU */ |
| 57 | #define OCMD_Y_SWAP (0x2<<14) /* UYVY or FOURCC UYVY */ |
| 58 | #define OCMD_Y_AND_UV_SWAP (0x3<<14) /* VYUY */ |
| 59 | #define OCMD_SOURCE_FORMAT_MASK (0xf<<10) |
| 60 | #define OCMD_RGB_888 (0x1<<10) /* not in i965 Intel docs */ |
| 61 | #define OCMD_RGB_555 (0x2<<10) /* not in i965 Intel docs */ |
| 62 | #define OCMD_RGB_565 (0x3<<10) /* not in i965 Intel docs */ |
| 63 | #define OCMD_YUV_422_PACKED (0x8<<10) |
| 64 | #define OCMD_YUV_411_PACKED (0x9<<10) /* not in i965 Intel docs */ |
| 65 | #define OCMD_YUV_420_PLANAR (0xc<<10) |
| 66 | #define OCMD_YUV_422_PLANAR (0xd<<10) |
| 67 | #define OCMD_YUV_410_PLANAR (0xe<<10) /* also 411 */ |
| 68 | #define OCMD_TVSYNCFLIP_PARITY (0x1<<9) |
| 69 | #define OCMD_TVSYNCFLIP_ENABLE (0x1<<7) |
Chris Wilson | d796136 | 2010-07-13 13:52:17 +0100 | [diff] [blame] | 70 | #define OCMD_BUF_TYPE_MASK (0x1<<5) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 71 | #define OCMD_BUF_TYPE_FRAME (0x0<<5) |
| 72 | #define OCMD_BUF_TYPE_FIELD (0x1<<5) |
| 73 | #define OCMD_TEST_MODE (0x1<<4) |
| 74 | #define OCMD_BUFFER_SELECT (0x3<<2) |
| 75 | #define OCMD_BUFFER0 (0x0<<2) |
| 76 | #define OCMD_BUFFER1 (0x1<<2) |
| 77 | #define OCMD_FIELD_SELECT (0x1<<2) |
| 78 | #define OCMD_FIELD0 (0x0<<1) |
| 79 | #define OCMD_FIELD1 (0x1<<1) |
| 80 | #define OCMD_ENABLE (0x1<<0) |
| 81 | |
| 82 | /* OCONFIG register */ |
| 83 | #define OCONF_PIPE_MASK (0x1<<18) |
| 84 | #define OCONF_PIPE_A (0x0<<18) |
| 85 | #define OCONF_PIPE_B (0x1<<18) |
| 86 | #define OCONF_GAMMA2_ENABLE (0x1<<16) |
| 87 | #define OCONF_CSC_MODE_BT601 (0x0<<5) |
| 88 | #define OCONF_CSC_MODE_BT709 (0x1<<5) |
| 89 | #define OCONF_CSC_BYPASS (0x1<<4) |
| 90 | #define OCONF_CC_OUT_8BIT (0x1<<3) |
| 91 | #define OCONF_TEST_MODE (0x1<<2) |
| 92 | #define OCONF_THREE_LINE_BUFFER (0x1<<0) |
| 93 | #define OCONF_TWO_LINE_BUFFER (0x0<<0) |
| 94 | |
| 95 | /* DCLRKM (dst-key) register */ |
| 96 | #define DST_KEY_ENABLE (0x1<<31) |
| 97 | #define CLK_RGB24_MASK 0x0 |
| 98 | #define CLK_RGB16_MASK 0x070307 |
| 99 | #define CLK_RGB15_MASK 0x070707 |
| 100 | #define CLK_RGB8I_MASK 0xffffff |
| 101 | |
| 102 | #define RGB16_TO_COLORKEY(c) \ |
| 103 | (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3)) |
| 104 | #define RGB15_TO_COLORKEY(c) \ |
| 105 | (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3)) |
| 106 | |
| 107 | /* overlay flip addr flag */ |
| 108 | #define OFC_UPDATE 0x1 |
| 109 | |
| 110 | /* polyphase filter coefficients */ |
| 111 | #define N_HORIZ_Y_TAPS 5 |
| 112 | #define N_VERT_Y_TAPS 3 |
| 113 | #define N_HORIZ_UV_TAPS 3 |
| 114 | #define N_VERT_UV_TAPS 3 |
| 115 | #define N_PHASES 17 |
| 116 | #define MAX_TAPS 5 |
| 117 | |
| 118 | /* memory bufferd overlay registers */ |
| 119 | struct overlay_registers { |
| 120 | u32 OBUF_0Y; |
| 121 | u32 OBUF_1Y; |
| 122 | u32 OBUF_0U; |
| 123 | u32 OBUF_0V; |
| 124 | u32 OBUF_1U; |
| 125 | u32 OBUF_1V; |
| 126 | u32 OSTRIDE; |
| 127 | u32 YRGB_VPH; |
| 128 | u32 UV_VPH; |
| 129 | u32 HORZ_PH; |
| 130 | u32 INIT_PHS; |
| 131 | u32 DWINPOS; |
| 132 | u32 DWINSZ; |
| 133 | u32 SWIDTH; |
| 134 | u32 SWIDTHSW; |
| 135 | u32 SHEIGHT; |
| 136 | u32 YRGBSCALE; |
| 137 | u32 UVSCALE; |
| 138 | u32 OCLRC0; |
| 139 | u32 OCLRC1; |
| 140 | u32 DCLRKV; |
| 141 | u32 DCLRKM; |
| 142 | u32 SCLRKVH; |
| 143 | u32 SCLRKVL; |
| 144 | u32 SCLRKEN; |
| 145 | u32 OCONFIG; |
| 146 | u32 OCMD; |
| 147 | u32 RESERVED1; /* 0x6C */ |
| 148 | u32 OSTART_0Y; |
| 149 | u32 OSTART_1Y; |
| 150 | u32 OSTART_0U; |
| 151 | u32 OSTART_0V; |
| 152 | u32 OSTART_1U; |
| 153 | u32 OSTART_1V; |
| 154 | u32 OTILEOFF_0Y; |
| 155 | u32 OTILEOFF_1Y; |
| 156 | u32 OTILEOFF_0U; |
| 157 | u32 OTILEOFF_0V; |
| 158 | u32 OTILEOFF_1U; |
| 159 | u32 OTILEOFF_1V; |
| 160 | u32 FASTHSCALE; /* 0xA0 */ |
| 161 | u32 UVSCALEV; /* 0xA4 */ |
| 162 | u32 RESERVEDC[(0x200 - 0xA8) / 4]; /* 0xA8 - 0x1FC */ |
| 163 | u16 Y_VCOEFS[N_VERT_Y_TAPS * N_PHASES]; /* 0x200 */ |
| 164 | u16 RESERVEDD[0x100 / 2 - N_VERT_Y_TAPS * N_PHASES]; |
| 165 | u16 Y_HCOEFS[N_HORIZ_Y_TAPS * N_PHASES]; /* 0x300 */ |
| 166 | u16 RESERVEDE[0x200 / 2 - N_HORIZ_Y_TAPS * N_PHASES]; |
| 167 | u16 UV_VCOEFS[N_VERT_UV_TAPS * N_PHASES]; /* 0x500 */ |
| 168 | u16 RESERVEDF[0x100 / 2 - N_VERT_UV_TAPS * N_PHASES]; |
| 169 | u16 UV_HCOEFS[N_HORIZ_UV_TAPS * N_PHASES]; /* 0x600 */ |
| 170 | u16 RESERVEDG[0x100 / 2 - N_HORIZ_UV_TAPS * N_PHASES]; |
| 171 | }; |
| 172 | |
| 173 | /* overlay flip addr flag */ |
| 174 | #define OFC_UPDATE 0x1 |
| 175 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 176 | static struct overlay_registers *intel_overlay_map_regs_atomic(struct intel_overlay *overlay) |
| 177 | { |
| 178 | drm_i915_private_t *dev_priv = overlay->dev->dev_private; |
| 179 | struct overlay_registers *regs; |
| 180 | |
| 181 | /* no recursive mappings */ |
| 182 | BUG_ON(overlay->virt_addr); |
| 183 | |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 184 | if (OVERLAY_NEEDS_PHYSICAL(overlay->dev)) { |
| 185 | regs = overlay->reg_bo->phys_obj->handle->vaddr; |
| 186 | } else { |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 187 | regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping, |
Chris Wilson | fca3ec0 | 2010-08-04 14:34:24 +0100 | [diff] [blame] | 188 | overlay->reg_bo->gtt_offset, |
| 189 | KM_USER0); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 190 | |
| 191 | if (!regs) { |
| 192 | DRM_ERROR("failed to map overlay regs in GTT\n"); |
| 193 | return NULL; |
| 194 | } |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 195 | } |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 196 | |
| 197 | return overlay->virt_addr = regs; |
| 198 | } |
| 199 | |
| 200 | static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay) |
| 201 | { |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 202 | if (!OVERLAY_NEEDS_PHYSICAL(overlay->dev)) |
Chris Wilson | fca3ec0 | 2010-08-04 14:34:24 +0100 | [diff] [blame] | 203 | io_mapping_unmap_atomic(overlay->virt_addr, KM_USER0); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 204 | |
| 205 | overlay->virt_addr = NULL; |
| 206 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 207 | return; |
| 208 | } |
| 209 | |
| 210 | /* overlay needs to be disable in OCMD reg */ |
| 211 | static int intel_overlay_on(struct intel_overlay *overlay) |
| 212 | { |
| 213 | struct drm_device *dev = overlay->dev; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 214 | int ret; |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 215 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 216 | |
| 217 | BUG_ON(overlay->active); |
| 218 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 219 | overlay->active = 1; |
| 220 | overlay->hw_wedged = NEEDS_WAIT_FOR_FLIP; |
| 221 | |
Daniel Vetter | 4f8a567 | 2010-02-11 14:14:43 +0100 | [diff] [blame] | 222 | BEGIN_LP_RING(4); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 223 | OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_ON); |
| 224 | OUT_RING(overlay->flip_addr | OFC_UPDATE); |
| 225 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); |
| 226 | OUT_RING(MI_NOOP); |
| 227 | ADVANCE_LP_RING(); |
| 228 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 229 | overlay->last_flip_req = |
Daniel Vetter | 8a1a49f | 2010-02-11 22:29:04 +0100 | [diff] [blame] | 230 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 231 | if (overlay->last_flip_req == 0) |
| 232 | return -ENOMEM; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 233 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 234 | ret = i915_do_wait_request(dev, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 235 | overlay->last_flip_req, true, |
| 236 | &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 237 | if (ret != 0) |
| 238 | return ret; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 239 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 240 | overlay->hw_wedged = 0; |
| 241 | overlay->last_flip_req = 0; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | /* overlay needs to be enabled in OCMD reg */ |
| 246 | static void intel_overlay_continue(struct intel_overlay *overlay, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 247 | bool load_polyphase_filter) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 248 | { |
| 249 | struct drm_device *dev = overlay->dev; |
| 250 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 251 | u32 flip_addr = overlay->flip_addr; |
| 252 | u32 tmp; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 253 | |
| 254 | BUG_ON(!overlay->active); |
| 255 | |
| 256 | if (load_polyphase_filter) |
| 257 | flip_addr |= OFC_UPDATE; |
| 258 | |
| 259 | /* check for underruns */ |
| 260 | tmp = I915_READ(DOVSTA); |
| 261 | if (tmp & (1 << 17)) |
| 262 | DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp); |
| 263 | |
Daniel Vetter | 4f8a567 | 2010-02-11 14:14:43 +0100 | [diff] [blame] | 264 | BEGIN_LP_RING(2); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 265 | OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE); |
| 266 | OUT_RING(flip_addr); |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 267 | ADVANCE_LP_RING(); |
| 268 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 269 | overlay->last_flip_req = |
Daniel Vetter | 8a1a49f | 2010-02-11 22:29:04 +0100 | [diff] [blame] | 270 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | static int intel_overlay_wait_flip(struct intel_overlay *overlay) |
| 274 | { |
| 275 | struct drm_device *dev = overlay->dev; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 276 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 277 | int ret; |
| 278 | u32 tmp; |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 279 | |
| 280 | if (overlay->last_flip_req != 0) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 281 | ret = i915_do_wait_request(dev, |
| 282 | overlay->last_flip_req, true, |
| 283 | &dev_priv->render_ring); |
Daniel Vetter | 5c5a435 | 2009-10-04 15:00:36 +0200 | [diff] [blame] | 284 | if (ret == 0) { |
| 285 | overlay->last_flip_req = 0; |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 286 | |
Daniel Vetter | 5c5a435 | 2009-10-04 15:00:36 +0200 | [diff] [blame] | 287 | tmp = I915_READ(ISR); |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 288 | |
Daniel Vetter | 5c5a435 | 2009-10-04 15:00:36 +0200 | [diff] [blame] | 289 | if (!(tmp & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT)) |
| 290 | return 0; |
| 291 | } |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /* synchronous slowpath */ |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 295 | overlay->hw_wedged = RELEASE_OLD_VID; |
| 296 | |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 297 | BEGIN_LP_RING(2); |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 298 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); |
| 299 | OUT_RING(MI_NOOP); |
| 300 | ADVANCE_LP_RING(); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 301 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 302 | overlay->last_flip_req = |
Daniel Vetter | 8a1a49f | 2010-02-11 22:29:04 +0100 | [diff] [blame] | 303 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 304 | if (overlay->last_flip_req == 0) |
| 305 | return -ENOMEM; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 306 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 307 | ret = i915_do_wait_request(dev, |
| 308 | overlay->last_flip_req, true, |
| 309 | &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 310 | if (ret != 0) |
| 311 | return ret; |
| 312 | |
| 313 | overlay->hw_wedged = 0; |
| 314 | overlay->last_flip_req = 0; |
| 315 | return 0; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | /* overlay needs to be disabled in OCMD reg */ |
| 319 | static int intel_overlay_off(struct intel_overlay *overlay) |
| 320 | { |
| 321 | u32 flip_addr = overlay->flip_addr; |
| 322 | struct drm_device *dev = overlay->dev; |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 323 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 324 | int ret; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 325 | |
| 326 | BUG_ON(!overlay->active); |
| 327 | |
| 328 | /* According to intel docs the overlay hw may hang (when switching |
| 329 | * off) without loading the filter coeffs. It is however unclear whether |
| 330 | * this applies to the disabling of the overlay or to the switching off |
| 331 | * of the hw. Do it in both cases */ |
| 332 | flip_addr |= OFC_UPDATE; |
| 333 | |
| 334 | /* wait for overlay to go idle */ |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 335 | overlay->hw_wedged = SWITCH_OFF_STAGE_1; |
| 336 | |
Daniel Vetter | 4f8a567 | 2010-02-11 14:14:43 +0100 | [diff] [blame] | 337 | BEGIN_LP_RING(4); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 338 | OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE); |
| 339 | OUT_RING(flip_addr); |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 340 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); |
| 341 | OUT_RING(MI_NOOP); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 342 | ADVANCE_LP_RING(); |
| 343 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 344 | overlay->last_flip_req = |
Daniel Vetter | 8a1a49f | 2010-02-11 22:29:04 +0100 | [diff] [blame] | 345 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 346 | if (overlay->last_flip_req == 0) |
| 347 | return -ENOMEM; |
| 348 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 349 | ret = i915_do_wait_request(dev, |
| 350 | overlay->last_flip_req, true, |
| 351 | &dev_priv->render_ring); |
| 352 | if (ret != 0) |
| 353 | return ret; |
| 354 | |
| 355 | /* turn overlay off */ |
| 356 | overlay->hw_wedged = SWITCH_OFF_STAGE_2; |
| 357 | |
| 358 | BEGIN_LP_RING(4); |
| 359 | OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_OFF); |
| 360 | OUT_RING(flip_addr); |
| 361 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); |
| 362 | OUT_RING(MI_NOOP); |
| 363 | ADVANCE_LP_RING(); |
| 364 | |
| 365 | overlay->last_flip_req = |
| 366 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
| 367 | if (overlay->last_flip_req == 0) |
| 368 | return -ENOMEM; |
| 369 | |
| 370 | ret = i915_do_wait_request(dev, |
| 371 | overlay->last_flip_req, true, |
| 372 | &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 373 | if (ret != 0) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 374 | return ret; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 375 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 376 | overlay->hw_wedged = 0; |
| 377 | overlay->last_flip_req = 0; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 378 | return ret; |
| 379 | } |
| 380 | |
Daniel Vetter | 12ca45f | 2037-04-25 10:08:26 +0200 | [diff] [blame] | 381 | static void intel_overlay_off_tail(struct intel_overlay *overlay) |
| 382 | { |
| 383 | struct drm_gem_object *obj; |
| 384 | |
| 385 | /* never have the overlay hw on without showing a frame */ |
| 386 | BUG_ON(!overlay->vid_bo); |
Daniel Vetter | a8089e8 | 2010-04-09 19:05:09 +0000 | [diff] [blame] | 387 | obj = &overlay->vid_bo->base; |
Daniel Vetter | 12ca45f | 2037-04-25 10:08:26 +0200 | [diff] [blame] | 388 | |
| 389 | i915_gem_object_unpin(obj); |
| 390 | drm_gem_object_unreference(obj); |
| 391 | overlay->vid_bo = NULL; |
| 392 | |
| 393 | overlay->crtc->overlay = NULL; |
| 394 | overlay->crtc = NULL; |
| 395 | overlay->active = 0; |
| 396 | } |
| 397 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 398 | /* recover from an interruption due to a signal |
| 399 | * We have to be careful not to repeat work forever an make forward progess. */ |
| 400 | int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 401 | bool interruptible) |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 402 | { |
| 403 | struct drm_device *dev = overlay->dev; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 404 | struct drm_gem_object *obj; |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 405 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 406 | u32 flip_addr; |
| 407 | int ret; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 408 | |
| 409 | if (overlay->hw_wedged == HW_WEDGED) |
| 410 | return -EIO; |
| 411 | |
| 412 | if (overlay->last_flip_req == 0) { |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 413 | overlay->last_flip_req = |
Daniel Vetter | 8a1a49f | 2010-02-11 22:29:04 +0100 | [diff] [blame] | 414 | i915_add_request(dev, NULL, &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 415 | if (overlay->last_flip_req == 0) |
| 416 | return -ENOMEM; |
| 417 | } |
| 418 | |
Zou Nan hai | 852835f | 2010-05-21 09:08:56 +0800 | [diff] [blame] | 419 | ret = i915_do_wait_request(dev, overlay->last_flip_req, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 420 | interruptible, &dev_priv->render_ring); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 421 | if (ret != 0) |
| 422 | return ret; |
| 423 | |
| 424 | switch (overlay->hw_wedged) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 425 | case RELEASE_OLD_VID: |
| 426 | obj = &overlay->old_vid_bo->base; |
| 427 | i915_gem_object_unpin(obj); |
| 428 | drm_gem_object_unreference(obj); |
| 429 | overlay->old_vid_bo = NULL; |
| 430 | break; |
| 431 | case SWITCH_OFF_STAGE_1: |
| 432 | flip_addr = overlay->flip_addr; |
| 433 | flip_addr |= OFC_UPDATE; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 434 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 435 | overlay->hw_wedged = SWITCH_OFF_STAGE_2; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 436 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 437 | BEGIN_LP_RING(4); |
| 438 | OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_OFF); |
| 439 | OUT_RING(flip_addr); |
| 440 | OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); |
| 441 | OUT_RING(MI_NOOP); |
| 442 | ADVANCE_LP_RING(); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 443 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 444 | overlay->last_flip_req = |
| 445 | i915_add_request(dev, NULL, |
| 446 | &dev_priv->render_ring); |
| 447 | if (overlay->last_flip_req == 0) |
| 448 | return -ENOMEM; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 449 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 450 | ret = i915_do_wait_request(dev, overlay->last_flip_req, |
| 451 | interruptible, |
| 452 | &dev_priv->render_ring); |
| 453 | if (ret != 0) |
| 454 | return ret; |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 455 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 456 | case SWITCH_OFF_STAGE_2: |
| 457 | intel_overlay_off_tail(overlay); |
| 458 | break; |
| 459 | default: |
| 460 | BUG_ON(overlay->hw_wedged != NEEDS_WAIT_FOR_FLIP); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | overlay->hw_wedged = 0; |
| 464 | overlay->last_flip_req = 0; |
| 465 | return 0; |
| 466 | } |
| 467 | |
Daniel Vetter | 5a5a0c6 | 2009-09-15 22:57:36 +0200 | [diff] [blame] | 468 | /* Wait for pending overlay flip and release old frame. |
| 469 | * Needs to be called before the overlay register are changed |
| 470 | * via intel_overlay_(un)map_regs_atomic */ |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 471 | static int intel_overlay_release_old_vid(struct intel_overlay *overlay) |
| 472 | { |
| 473 | int ret; |
| 474 | struct drm_gem_object *obj; |
| 475 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 476 | /* only wait if there is actually an old frame to release to |
| 477 | * guarantee forward progress */ |
| 478 | if (!overlay->old_vid_bo) |
| 479 | return 0; |
| 480 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 481 | ret = intel_overlay_wait_flip(overlay); |
| 482 | if (ret != 0) |
| 483 | return ret; |
| 484 | |
Daniel Vetter | a8089e8 | 2010-04-09 19:05:09 +0000 | [diff] [blame] | 485 | obj = &overlay->old_vid_bo->base; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 486 | i915_gem_object_unpin(obj); |
| 487 | drm_gem_object_unreference(obj); |
| 488 | overlay->old_vid_bo = NULL; |
| 489 | |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | struct put_image_params { |
| 494 | int format; |
| 495 | short dst_x; |
| 496 | short dst_y; |
| 497 | short dst_w; |
| 498 | short dst_h; |
| 499 | short src_w; |
| 500 | short src_scan_h; |
| 501 | short src_scan_w; |
| 502 | short src_h; |
| 503 | short stride_Y; |
| 504 | short stride_UV; |
| 505 | int offset_Y; |
| 506 | int offset_U; |
| 507 | int offset_V; |
| 508 | }; |
| 509 | |
| 510 | static int packed_depth_bytes(u32 format) |
| 511 | { |
| 512 | switch (format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 513 | case I915_OVERLAY_YUV422: |
| 514 | return 4; |
| 515 | case I915_OVERLAY_YUV411: |
| 516 | /* return 6; not implemented */ |
| 517 | default: |
| 518 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | static int packed_width_bytes(u32 format, short width) |
| 523 | { |
| 524 | switch (format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 525 | case I915_OVERLAY_YUV422: |
| 526 | return width << 1; |
| 527 | default: |
| 528 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 529 | } |
| 530 | } |
| 531 | |
| 532 | static int uv_hsubsampling(u32 format) |
| 533 | { |
| 534 | switch (format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 535 | case I915_OVERLAY_YUV422: |
| 536 | case I915_OVERLAY_YUV420: |
| 537 | return 2; |
| 538 | case I915_OVERLAY_YUV411: |
| 539 | case I915_OVERLAY_YUV410: |
| 540 | return 4; |
| 541 | default: |
| 542 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | |
| 546 | static int uv_vsubsampling(u32 format) |
| 547 | { |
| 548 | switch (format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 549 | case I915_OVERLAY_YUV420: |
| 550 | case I915_OVERLAY_YUV410: |
| 551 | return 2; |
| 552 | case I915_OVERLAY_YUV422: |
| 553 | case I915_OVERLAY_YUV411: |
| 554 | return 1; |
| 555 | default: |
| 556 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | |
| 560 | static u32 calc_swidthsw(struct drm_device *dev, u32 offset, u32 width) |
| 561 | { |
| 562 | u32 mask, shift, ret; |
| 563 | if (IS_I9XX(dev)) { |
| 564 | mask = 0x3f; |
| 565 | shift = 6; |
| 566 | } else { |
| 567 | mask = 0x1f; |
| 568 | shift = 5; |
| 569 | } |
| 570 | ret = ((offset + width + mask) >> shift) - (offset >> shift); |
| 571 | if (IS_I9XX(dev)) |
| 572 | ret <<= 1; |
| 573 | ret -=1; |
| 574 | return ret << 2; |
| 575 | } |
| 576 | |
| 577 | static const u16 y_static_hcoeffs[N_HORIZ_Y_TAPS * N_PHASES] = { |
| 578 | 0x3000, 0xb4a0, 0x1930, 0x1920, 0xb4a0, |
| 579 | 0x3000, 0xb500, 0x19d0, 0x1880, 0xb440, |
| 580 | 0x3000, 0xb540, 0x1a88, 0x2f80, 0xb3e0, |
| 581 | 0x3000, 0xb580, 0x1b30, 0x2e20, 0xb380, |
| 582 | 0x3000, 0xb5c0, 0x1bd8, 0x2cc0, 0xb320, |
| 583 | 0x3020, 0xb5e0, 0x1c60, 0x2b80, 0xb2c0, |
| 584 | 0x3020, 0xb5e0, 0x1cf8, 0x2a20, 0xb260, |
| 585 | 0x3020, 0xb5e0, 0x1d80, 0x28e0, 0xb200, |
| 586 | 0x3020, 0xb5c0, 0x1e08, 0x3f40, 0xb1c0, |
| 587 | 0x3020, 0xb580, 0x1e78, 0x3ce0, 0xb160, |
| 588 | 0x3040, 0xb520, 0x1ed8, 0x3aa0, 0xb120, |
| 589 | 0x3040, 0xb4a0, 0x1f30, 0x3880, 0xb0e0, |
| 590 | 0x3040, 0xb400, 0x1f78, 0x3680, 0xb0a0, |
| 591 | 0x3020, 0xb340, 0x1fb8, 0x34a0, 0xb060, |
| 592 | 0x3020, 0xb240, 0x1fe0, 0x32e0, 0xb040, |
| 593 | 0x3020, 0xb140, 0x1ff8, 0x3160, 0xb020, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 594 | 0xb000, 0x3000, 0x0800, 0x3000, 0xb000 |
| 595 | }; |
| 596 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 597 | static const u16 uv_static_hcoeffs[N_HORIZ_UV_TAPS * N_PHASES] = { |
| 598 | 0x3000, 0x1800, 0x1800, 0xb000, 0x18d0, 0x2e60, |
| 599 | 0xb000, 0x1990, 0x2ce0, 0xb020, 0x1a68, 0x2b40, |
| 600 | 0xb040, 0x1b20, 0x29e0, 0xb060, 0x1bd8, 0x2880, |
| 601 | 0xb080, 0x1c88, 0x3e60, 0xb0a0, 0x1d28, 0x3c00, |
| 602 | 0xb0c0, 0x1db8, 0x39e0, 0xb0e0, 0x1e40, 0x37e0, |
| 603 | 0xb100, 0x1eb8, 0x3620, 0xb100, 0x1f18, 0x34a0, |
| 604 | 0xb100, 0x1f68, 0x3360, 0xb0e0, 0x1fa8, 0x3240, |
| 605 | 0xb0c0, 0x1fe0, 0x3140, 0xb060, 0x1ff0, 0x30a0, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 606 | 0x3000, 0x0800, 0x3000 |
| 607 | }; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 608 | |
| 609 | static void update_polyphase_filter(struct overlay_registers *regs) |
| 610 | { |
| 611 | memcpy(regs->Y_HCOEFS, y_static_hcoeffs, sizeof(y_static_hcoeffs)); |
| 612 | memcpy(regs->UV_HCOEFS, uv_static_hcoeffs, sizeof(uv_static_hcoeffs)); |
| 613 | } |
| 614 | |
| 615 | static bool update_scaling_factors(struct intel_overlay *overlay, |
| 616 | struct overlay_registers *regs, |
| 617 | struct put_image_params *params) |
| 618 | { |
| 619 | /* fixed point with a 12 bit shift */ |
| 620 | u32 xscale, yscale, xscale_UV, yscale_UV; |
| 621 | #define FP_SHIFT 12 |
| 622 | #define FRACT_MASK 0xfff |
| 623 | bool scale_changed = false; |
| 624 | int uv_hscale = uv_hsubsampling(params->format); |
| 625 | int uv_vscale = uv_vsubsampling(params->format); |
| 626 | |
| 627 | if (params->dst_w > 1) |
| 628 | xscale = ((params->src_scan_w - 1) << FP_SHIFT) |
| 629 | /(params->dst_w); |
| 630 | else |
| 631 | xscale = 1 << FP_SHIFT; |
| 632 | |
| 633 | if (params->dst_h > 1) |
| 634 | yscale = ((params->src_scan_h - 1) << FP_SHIFT) |
| 635 | /(params->dst_h); |
| 636 | else |
| 637 | yscale = 1 << FP_SHIFT; |
| 638 | |
| 639 | /*if (params->format & I915_OVERLAY_YUV_PLANAR) {*/ |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 640 | xscale_UV = xscale/uv_hscale; |
| 641 | yscale_UV = yscale/uv_vscale; |
| 642 | /* make the Y scale to UV scale ratio an exact multiply */ |
| 643 | xscale = xscale_UV * uv_hscale; |
| 644 | yscale = yscale_UV * uv_vscale; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 645 | /*} else { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 646 | xscale_UV = 0; |
| 647 | yscale_UV = 0; |
| 648 | }*/ |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 649 | |
| 650 | if (xscale != overlay->old_xscale || yscale != overlay->old_yscale) |
| 651 | scale_changed = true; |
| 652 | overlay->old_xscale = xscale; |
| 653 | overlay->old_yscale = yscale; |
| 654 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 655 | regs->YRGBSCALE = (((yscale & FRACT_MASK) << 20) | |
| 656 | ((xscale >> FP_SHIFT) << 16) | |
| 657 | ((xscale & FRACT_MASK) << 3)); |
| 658 | |
| 659 | regs->UVSCALE = (((yscale_UV & FRACT_MASK) << 20) | |
| 660 | ((xscale_UV >> FP_SHIFT) << 16) | |
| 661 | ((xscale_UV & FRACT_MASK) << 3)); |
| 662 | |
| 663 | regs->UVSCALEV = ((((yscale >> FP_SHIFT) << 16) | |
| 664 | ((yscale_UV >> FP_SHIFT) << 0))); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 665 | |
| 666 | if (scale_changed) |
| 667 | update_polyphase_filter(regs); |
| 668 | |
| 669 | return scale_changed; |
| 670 | } |
| 671 | |
| 672 | static void update_colorkey(struct intel_overlay *overlay, |
| 673 | struct overlay_registers *regs) |
| 674 | { |
| 675 | u32 key = overlay->color_key; |
Chris Wilson | 6ba3ddd | 2010-08-12 09:30:58 +0100 | [diff] [blame] | 676 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 677 | switch (overlay->crtc->base.fb->bits_per_pixel) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 678 | case 8: |
| 679 | regs->DCLRKV = 0; |
| 680 | regs->DCLRKM = CLK_RGB8I_MASK | DST_KEY_ENABLE; |
Chris Wilson | 6ba3ddd | 2010-08-12 09:30:58 +0100 | [diff] [blame] | 681 | break; |
| 682 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 683 | case 16: |
| 684 | if (overlay->crtc->base.fb->depth == 15) { |
| 685 | regs->DCLRKV = RGB15_TO_COLORKEY(key); |
| 686 | regs->DCLRKM = CLK_RGB15_MASK | DST_KEY_ENABLE; |
| 687 | } else { |
| 688 | regs->DCLRKV = RGB16_TO_COLORKEY(key); |
| 689 | regs->DCLRKM = CLK_RGB16_MASK | DST_KEY_ENABLE; |
| 690 | } |
Chris Wilson | 6ba3ddd | 2010-08-12 09:30:58 +0100 | [diff] [blame] | 691 | break; |
| 692 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 693 | case 24: |
| 694 | case 32: |
| 695 | regs->DCLRKV = key; |
| 696 | regs->DCLRKM = CLK_RGB24_MASK | DST_KEY_ENABLE; |
Chris Wilson | 6ba3ddd | 2010-08-12 09:30:58 +0100 | [diff] [blame] | 697 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 698 | } |
| 699 | } |
| 700 | |
| 701 | static u32 overlay_cmd_reg(struct put_image_params *params) |
| 702 | { |
| 703 | u32 cmd = OCMD_ENABLE | OCMD_BUF_TYPE_FRAME | OCMD_BUFFER0; |
| 704 | |
| 705 | if (params->format & I915_OVERLAY_YUV_PLANAR) { |
| 706 | switch (params->format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 707 | case I915_OVERLAY_YUV422: |
| 708 | cmd |= OCMD_YUV_422_PLANAR; |
| 709 | break; |
| 710 | case I915_OVERLAY_YUV420: |
| 711 | cmd |= OCMD_YUV_420_PLANAR; |
| 712 | break; |
| 713 | case I915_OVERLAY_YUV411: |
| 714 | case I915_OVERLAY_YUV410: |
| 715 | cmd |= OCMD_YUV_410_PLANAR; |
| 716 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 717 | } |
| 718 | } else { /* YUV packed */ |
| 719 | switch (params->format & I915_OVERLAY_DEPTH_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 720 | case I915_OVERLAY_YUV422: |
| 721 | cmd |= OCMD_YUV_422_PACKED; |
| 722 | break; |
| 723 | case I915_OVERLAY_YUV411: |
| 724 | cmd |= OCMD_YUV_411_PACKED; |
| 725 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | switch (params->format & I915_OVERLAY_SWAP_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 729 | case I915_OVERLAY_NO_SWAP: |
| 730 | break; |
| 731 | case I915_OVERLAY_UV_SWAP: |
| 732 | cmd |= OCMD_UV_SWAP; |
| 733 | break; |
| 734 | case I915_OVERLAY_Y_SWAP: |
| 735 | cmd |= OCMD_Y_SWAP; |
| 736 | break; |
| 737 | case I915_OVERLAY_Y_AND_UV_SWAP: |
| 738 | cmd |= OCMD_Y_AND_UV_SWAP; |
| 739 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 740 | } |
| 741 | } |
| 742 | |
| 743 | return cmd; |
| 744 | } |
| 745 | |
| 746 | int intel_overlay_do_put_image(struct intel_overlay *overlay, |
| 747 | struct drm_gem_object *new_bo, |
| 748 | struct put_image_params *params) |
| 749 | { |
| 750 | int ret, tmp_width; |
| 751 | struct overlay_registers *regs; |
| 752 | bool scale_changed = false; |
Daniel Vetter | 23010e4 | 2010-03-08 13:35:02 +0100 | [diff] [blame] | 753 | struct drm_i915_gem_object *bo_priv = to_intel_bo(new_bo); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 754 | struct drm_device *dev = overlay->dev; |
| 755 | |
| 756 | BUG_ON(!mutex_is_locked(&dev->struct_mutex)); |
| 757 | BUG_ON(!mutex_is_locked(&dev->mode_config.mutex)); |
| 758 | BUG_ON(!overlay); |
| 759 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 760 | ret = intel_overlay_release_old_vid(overlay); |
| 761 | if (ret != 0) |
| 762 | return ret; |
| 763 | |
| 764 | ret = i915_gem_object_pin(new_bo, PAGE_SIZE); |
| 765 | if (ret != 0) |
| 766 | return ret; |
| 767 | |
| 768 | ret = i915_gem_object_set_to_gtt_domain(new_bo, 0); |
| 769 | if (ret != 0) |
| 770 | goto out_unpin; |
| 771 | |
| 772 | if (!overlay->active) { |
| 773 | regs = intel_overlay_map_regs_atomic(overlay); |
| 774 | if (!regs) { |
| 775 | ret = -ENOMEM; |
| 776 | goto out_unpin; |
| 777 | } |
| 778 | regs->OCONFIG = OCONF_CC_OUT_8BIT; |
| 779 | if (IS_I965GM(overlay->dev)) |
| 780 | regs->OCONFIG |= OCONF_CSC_MODE_BT709; |
| 781 | regs->OCONFIG |= overlay->crtc->pipe == 0 ? |
| 782 | OCONF_PIPE_A : OCONF_PIPE_B; |
| 783 | intel_overlay_unmap_regs_atomic(overlay); |
| 784 | |
| 785 | ret = intel_overlay_on(overlay); |
| 786 | if (ret != 0) |
| 787 | goto out_unpin; |
| 788 | } |
| 789 | |
| 790 | regs = intel_overlay_map_regs_atomic(overlay); |
| 791 | if (!regs) { |
| 792 | ret = -ENOMEM; |
| 793 | goto out_unpin; |
| 794 | } |
| 795 | |
| 796 | regs->DWINPOS = (params->dst_y << 16) | params->dst_x; |
| 797 | regs->DWINSZ = (params->dst_h << 16) | params->dst_w; |
| 798 | |
| 799 | if (params->format & I915_OVERLAY_YUV_PACKED) |
| 800 | tmp_width = packed_width_bytes(params->format, params->src_w); |
| 801 | else |
| 802 | tmp_width = params->src_w; |
| 803 | |
| 804 | regs->SWIDTH = params->src_w; |
| 805 | regs->SWIDTHSW = calc_swidthsw(overlay->dev, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 806 | params->offset_Y, tmp_width); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 807 | regs->SHEIGHT = params->src_h; |
| 808 | regs->OBUF_0Y = bo_priv->gtt_offset + params-> offset_Y; |
| 809 | regs->OSTRIDE = params->stride_Y; |
| 810 | |
| 811 | if (params->format & I915_OVERLAY_YUV_PLANAR) { |
| 812 | int uv_hscale = uv_hsubsampling(params->format); |
| 813 | int uv_vscale = uv_vsubsampling(params->format); |
| 814 | u32 tmp_U, tmp_V; |
| 815 | regs->SWIDTH |= (params->src_w/uv_hscale) << 16; |
| 816 | tmp_U = calc_swidthsw(overlay->dev, params->offset_U, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 817 | params->src_w/uv_hscale); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 818 | tmp_V = calc_swidthsw(overlay->dev, params->offset_V, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 819 | params->src_w/uv_hscale); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 820 | regs->SWIDTHSW |= max_t(u32, tmp_U, tmp_V) << 16; |
| 821 | regs->SHEIGHT |= (params->src_h/uv_vscale) << 16; |
| 822 | regs->OBUF_0U = bo_priv->gtt_offset + params->offset_U; |
| 823 | regs->OBUF_0V = bo_priv->gtt_offset + params->offset_V; |
| 824 | regs->OSTRIDE |= params->stride_UV << 16; |
| 825 | } |
| 826 | |
| 827 | scale_changed = update_scaling_factors(overlay, regs, params); |
| 828 | |
| 829 | update_colorkey(overlay, regs); |
| 830 | |
| 831 | regs->OCMD = overlay_cmd_reg(params); |
| 832 | |
| 833 | intel_overlay_unmap_regs_atomic(overlay); |
| 834 | |
| 835 | intel_overlay_continue(overlay, scale_changed); |
| 836 | |
| 837 | overlay->old_vid_bo = overlay->vid_bo; |
Daniel Vetter | 23010e4 | 2010-03-08 13:35:02 +0100 | [diff] [blame] | 838 | overlay->vid_bo = to_intel_bo(new_bo); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 839 | |
| 840 | return 0; |
| 841 | |
| 842 | out_unpin: |
| 843 | i915_gem_object_unpin(new_bo); |
| 844 | return ret; |
| 845 | } |
| 846 | |
| 847 | int intel_overlay_switch_off(struct intel_overlay *overlay) |
| 848 | { |
| 849 | int ret; |
| 850 | struct overlay_registers *regs; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 851 | struct drm_device *dev = overlay->dev; |
| 852 | |
| 853 | BUG_ON(!mutex_is_locked(&dev->struct_mutex)); |
| 854 | BUG_ON(!mutex_is_locked(&dev->mode_config.mutex)); |
| 855 | |
Daniel Vetter | 9bedb97 | 2009-11-30 15:55:49 +0100 | [diff] [blame] | 856 | if (overlay->hw_wedged) { |
| 857 | ret = intel_overlay_recover_from_interrupt(overlay, 1); |
| 858 | if (ret != 0) |
| 859 | return ret; |
| 860 | } |
| 861 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 862 | if (!overlay->active) |
| 863 | return 0; |
| 864 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 865 | ret = intel_overlay_release_old_vid(overlay); |
| 866 | if (ret != 0) |
| 867 | return ret; |
| 868 | |
| 869 | regs = intel_overlay_map_regs_atomic(overlay); |
| 870 | regs->OCMD = 0; |
| 871 | intel_overlay_unmap_regs_atomic(overlay); |
| 872 | |
| 873 | ret = intel_overlay_off(overlay); |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 874 | if (ret != 0) |
| 875 | return ret; |
| 876 | |
Daniel Vetter | 12ca45f | 2037-04-25 10:08:26 +0200 | [diff] [blame] | 877 | intel_overlay_off_tail(overlay); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 878 | |
| 879 | return 0; |
| 880 | } |
| 881 | |
| 882 | static int check_overlay_possible_on_crtc(struct intel_overlay *overlay, |
| 883 | struct intel_crtc *crtc) |
| 884 | { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 885 | drm_i915_private_t *dev_priv = overlay->dev->dev_private; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 886 | u32 pipeconf; |
| 887 | int pipeconf_reg = (crtc->pipe == 0) ? PIPEACONF : PIPEBCONF; |
| 888 | |
| 889 | if (!crtc->base.enabled || crtc->dpms_mode != DRM_MODE_DPMS_ON) |
| 890 | return -EINVAL; |
| 891 | |
| 892 | pipeconf = I915_READ(pipeconf_reg); |
| 893 | |
| 894 | /* can't use the overlay with double wide pipe */ |
| 895 | if (!IS_I965G(overlay->dev) && pipeconf & PIPEACONF_DOUBLE_WIDE) |
| 896 | return -EINVAL; |
| 897 | |
| 898 | return 0; |
| 899 | } |
| 900 | |
| 901 | static void update_pfit_vscale_ratio(struct intel_overlay *overlay) |
| 902 | { |
| 903 | struct drm_device *dev = overlay->dev; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 904 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 905 | u32 ratio; |
| 906 | u32 pfit_control = I915_READ(PFIT_CONTROL); |
| 907 | |
| 908 | /* XXX: This is not the same logic as in the xorg driver, but more in |
| 909 | * line with the intel documentation for the i965 */ |
| 910 | if (!IS_I965G(dev) && (pfit_control & VERT_AUTO_SCALE)) { |
| 911 | ratio = I915_READ(PFIT_AUTO_RATIOS) >> PFIT_VERT_SCALE_SHIFT; |
| 912 | } else { /* on i965 use the PGM reg to read out the autoscaler values */ |
| 913 | ratio = I915_READ(PFIT_PGM_RATIOS); |
| 914 | if (IS_I965G(dev)) |
| 915 | ratio >>= PFIT_VERT_SCALE_SHIFT_965; |
| 916 | else |
| 917 | ratio >>= PFIT_VERT_SCALE_SHIFT; |
| 918 | } |
| 919 | |
| 920 | overlay->pfit_vscale_ratio = ratio; |
| 921 | } |
| 922 | |
| 923 | static int check_overlay_dst(struct intel_overlay *overlay, |
| 924 | struct drm_intel_overlay_put_image *rec) |
| 925 | { |
| 926 | struct drm_display_mode *mode = &overlay->crtc->base.mode; |
| 927 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 928 | if (rec->dst_x < mode->crtc_hdisplay && |
| 929 | rec->dst_x + rec->dst_width <= mode->crtc_hdisplay && |
| 930 | rec->dst_y < mode->crtc_vdisplay && |
| 931 | rec->dst_y + rec->dst_height <= mode->crtc_vdisplay) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 932 | return 0; |
| 933 | else |
| 934 | return -EINVAL; |
| 935 | } |
| 936 | |
| 937 | static int check_overlay_scaling(struct put_image_params *rec) |
| 938 | { |
| 939 | u32 tmp; |
| 940 | |
| 941 | /* downscaling limit is 8.0 */ |
| 942 | tmp = ((rec->src_scan_h << 16) / rec->dst_h) >> 16; |
| 943 | if (tmp > 7) |
| 944 | return -EINVAL; |
| 945 | tmp = ((rec->src_scan_w << 16) / rec->dst_w) >> 16; |
| 946 | if (tmp > 7) |
| 947 | return -EINVAL; |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
| 952 | static int check_overlay_src(struct drm_device *dev, |
| 953 | struct drm_intel_overlay_put_image *rec, |
| 954 | struct drm_gem_object *new_bo) |
| 955 | { |
| 956 | u32 stride_mask; |
| 957 | int depth; |
| 958 | int uv_hscale = uv_hsubsampling(rec->flags); |
| 959 | int uv_vscale = uv_vsubsampling(rec->flags); |
| 960 | size_t tmp; |
| 961 | |
| 962 | /* check src dimensions */ |
| 963 | if (IS_845G(dev) || IS_I830(dev)) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 964 | if (rec->src_height > IMAGE_MAX_HEIGHT_LEGACY || |
| 965 | rec->src_width > IMAGE_MAX_WIDTH_LEGACY) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 966 | return -EINVAL; |
| 967 | } else { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 968 | if (rec->src_height > IMAGE_MAX_HEIGHT || |
| 969 | rec->src_width > IMAGE_MAX_WIDTH) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 970 | return -EINVAL; |
| 971 | } |
| 972 | /* better safe than sorry, use 4 as the maximal subsampling ratio */ |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 973 | if (rec->src_height < N_VERT_Y_TAPS*4 || |
| 974 | rec->src_width < N_HORIZ_Y_TAPS*4) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 975 | return -EINVAL; |
| 976 | |
Chris Wilson | a1efd14 | 2010-07-12 19:35:38 +0100 | [diff] [blame] | 977 | /* check alignment constraints */ |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 978 | switch (rec->flags & I915_OVERLAY_TYPE_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 979 | case I915_OVERLAY_RGB: |
| 980 | /* not implemented */ |
| 981 | return -EINVAL; |
| 982 | case I915_OVERLAY_YUV_PACKED: |
| 983 | depth = packed_depth_bytes(rec->flags); |
| 984 | if (uv_vscale != 1) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 985 | return -EINVAL; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 986 | if (depth < 0) |
| 987 | return depth; |
| 988 | /* ignore UV planes */ |
| 989 | rec->stride_UV = 0; |
| 990 | rec->offset_U = 0; |
| 991 | rec->offset_V = 0; |
| 992 | /* check pixel alignment */ |
| 993 | if (rec->offset_Y % depth) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 994 | return -EINVAL; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 995 | break; |
| 996 | case I915_OVERLAY_YUV_PLANAR: |
| 997 | if (uv_vscale < 0 || uv_hscale < 0) |
| 998 | return -EINVAL; |
| 999 | /* no offset restrictions for planar formats */ |
| 1000 | break; |
| 1001 | default: |
| 1002 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | if (rec->src_width % uv_hscale) |
| 1006 | return -EINVAL; |
| 1007 | |
| 1008 | /* stride checking */ |
Chris Wilson | a1efd14 | 2010-07-12 19:35:38 +0100 | [diff] [blame] | 1009 | if (IS_I830(dev) || IS_845G(dev)) |
| 1010 | stride_mask = 255; |
| 1011 | else |
| 1012 | stride_mask = 63; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1013 | |
| 1014 | if (rec->stride_Y & stride_mask || rec->stride_UV & stride_mask) |
| 1015 | return -EINVAL; |
| 1016 | if (IS_I965G(dev) && rec->stride_Y < 512) |
| 1017 | return -EINVAL; |
| 1018 | |
| 1019 | tmp = (rec->flags & I915_OVERLAY_TYPE_MASK) == I915_OVERLAY_YUV_PLANAR ? |
| 1020 | 4 : 8; |
| 1021 | if (rec->stride_Y > tmp*1024 || rec->stride_UV > 2*1024) |
| 1022 | return -EINVAL; |
| 1023 | |
| 1024 | /* check buffer dimensions */ |
| 1025 | switch (rec->flags & I915_OVERLAY_TYPE_MASK) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1026 | case I915_OVERLAY_RGB: |
| 1027 | case I915_OVERLAY_YUV_PACKED: |
| 1028 | /* always 4 Y values per depth pixels */ |
| 1029 | if (packed_width_bytes(rec->flags, rec->src_width) > rec->stride_Y) |
| 1030 | return -EINVAL; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1031 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1032 | tmp = rec->stride_Y*rec->src_height; |
| 1033 | if (rec->offset_Y + tmp > new_bo->size) |
| 1034 | return -EINVAL; |
| 1035 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1036 | |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1037 | case I915_OVERLAY_YUV_PLANAR: |
| 1038 | if (rec->src_width > rec->stride_Y) |
| 1039 | return -EINVAL; |
| 1040 | if (rec->src_width/uv_hscale > rec->stride_UV) |
| 1041 | return -EINVAL; |
| 1042 | |
| 1043 | tmp = rec->stride_Y*rec->src_height; |
| 1044 | if (rec->offset_Y + tmp > new_bo->size) |
| 1045 | return -EINVAL; |
| 1046 | tmp = rec->stride_UV*rec->src_height; |
| 1047 | tmp /= uv_vscale; |
| 1048 | if (rec->offset_U + tmp > new_bo->size || |
| 1049 | rec->offset_V + tmp > new_bo->size) |
| 1050 | return -EINVAL; |
| 1051 | break; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | return 0; |
| 1055 | } |
| 1056 | |
| 1057 | int intel_overlay_put_image(struct drm_device *dev, void *data, |
| 1058 | struct drm_file *file_priv) |
| 1059 | { |
| 1060 | struct drm_intel_overlay_put_image *put_image_rec = data; |
| 1061 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1062 | struct intel_overlay *overlay; |
| 1063 | struct drm_mode_object *drmmode_obj; |
| 1064 | struct intel_crtc *crtc; |
| 1065 | struct drm_gem_object *new_bo; |
| 1066 | struct put_image_params *params; |
| 1067 | int ret; |
| 1068 | |
| 1069 | if (!dev_priv) { |
| 1070 | DRM_ERROR("called with no initialization\n"); |
| 1071 | return -EINVAL; |
| 1072 | } |
| 1073 | |
| 1074 | overlay = dev_priv->overlay; |
| 1075 | if (!overlay) { |
| 1076 | DRM_DEBUG("userspace bug: no overlay\n"); |
| 1077 | return -ENODEV; |
| 1078 | } |
| 1079 | |
| 1080 | if (!(put_image_rec->flags & I915_OVERLAY_ENABLE)) { |
| 1081 | mutex_lock(&dev->mode_config.mutex); |
| 1082 | mutex_lock(&dev->struct_mutex); |
| 1083 | |
| 1084 | ret = intel_overlay_switch_off(overlay); |
| 1085 | |
| 1086 | mutex_unlock(&dev->struct_mutex); |
| 1087 | mutex_unlock(&dev->mode_config.mutex); |
| 1088 | |
| 1089 | return ret; |
| 1090 | } |
| 1091 | |
| 1092 | params = kmalloc(sizeof(struct put_image_params), GFP_KERNEL); |
| 1093 | if (!params) |
| 1094 | return -ENOMEM; |
| 1095 | |
| 1096 | drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1097 | DRM_MODE_OBJECT_CRTC); |
Dan Carpenter | 915a428 | 2010-03-06 14:05:39 +0300 | [diff] [blame] | 1098 | if (!drmmode_obj) { |
| 1099 | ret = -ENOENT; |
| 1100 | goto out_free; |
| 1101 | } |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1102 | crtc = to_intel_crtc(obj_to_crtc(drmmode_obj)); |
| 1103 | |
| 1104 | new_bo = drm_gem_object_lookup(dev, file_priv, |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1105 | put_image_rec->bo_handle); |
Dan Carpenter | 915a428 | 2010-03-06 14:05:39 +0300 | [diff] [blame] | 1106 | if (!new_bo) { |
| 1107 | ret = -ENOENT; |
| 1108 | goto out_free; |
| 1109 | } |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1110 | |
| 1111 | mutex_lock(&dev->mode_config.mutex); |
| 1112 | mutex_lock(&dev->struct_mutex); |
| 1113 | |
Daniel Vetter | 03f77ea | 2009-09-15 22:57:37 +0200 | [diff] [blame] | 1114 | if (overlay->hw_wedged) { |
| 1115 | ret = intel_overlay_recover_from_interrupt(overlay, 1); |
| 1116 | if (ret != 0) |
| 1117 | goto out_unlock; |
| 1118 | } |
| 1119 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1120 | if (overlay->crtc != crtc) { |
| 1121 | struct drm_display_mode *mode = &crtc->base.mode; |
| 1122 | ret = intel_overlay_switch_off(overlay); |
| 1123 | if (ret != 0) |
| 1124 | goto out_unlock; |
| 1125 | |
| 1126 | ret = check_overlay_possible_on_crtc(overlay, crtc); |
| 1127 | if (ret != 0) |
| 1128 | goto out_unlock; |
| 1129 | |
| 1130 | overlay->crtc = crtc; |
| 1131 | crtc->overlay = overlay; |
| 1132 | |
| 1133 | if (intel_panel_fitter_pipe(dev) == crtc->pipe |
| 1134 | /* and line to wide, i.e. one-line-mode */ |
| 1135 | && mode->hdisplay > 1024) { |
| 1136 | overlay->pfit_active = 1; |
| 1137 | update_pfit_vscale_ratio(overlay); |
| 1138 | } else |
| 1139 | overlay->pfit_active = 0; |
| 1140 | } |
| 1141 | |
| 1142 | ret = check_overlay_dst(overlay, put_image_rec); |
| 1143 | if (ret != 0) |
| 1144 | goto out_unlock; |
| 1145 | |
| 1146 | if (overlay->pfit_active) { |
| 1147 | params->dst_y = ((((u32)put_image_rec->dst_y) << 12) / |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1148 | overlay->pfit_vscale_ratio); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1149 | /* shifting right rounds downwards, so add 1 */ |
| 1150 | params->dst_h = ((((u32)put_image_rec->dst_height) << 12) / |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1151 | overlay->pfit_vscale_ratio) + 1; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1152 | } else { |
| 1153 | params->dst_y = put_image_rec->dst_y; |
| 1154 | params->dst_h = put_image_rec->dst_height; |
| 1155 | } |
| 1156 | params->dst_x = put_image_rec->dst_x; |
| 1157 | params->dst_w = put_image_rec->dst_width; |
| 1158 | |
| 1159 | params->src_w = put_image_rec->src_width; |
| 1160 | params->src_h = put_image_rec->src_height; |
| 1161 | params->src_scan_w = put_image_rec->src_scan_width; |
| 1162 | params->src_scan_h = put_image_rec->src_scan_height; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1163 | if (params->src_scan_h > params->src_h || |
| 1164 | params->src_scan_w > params->src_w) { |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1165 | ret = -EINVAL; |
| 1166 | goto out_unlock; |
| 1167 | } |
| 1168 | |
| 1169 | ret = check_overlay_src(dev, put_image_rec, new_bo); |
| 1170 | if (ret != 0) |
| 1171 | goto out_unlock; |
| 1172 | params->format = put_image_rec->flags & ~I915_OVERLAY_FLAGS_MASK; |
| 1173 | params->stride_Y = put_image_rec->stride_Y; |
| 1174 | params->stride_UV = put_image_rec->stride_UV; |
| 1175 | params->offset_Y = put_image_rec->offset_Y; |
| 1176 | params->offset_U = put_image_rec->offset_U; |
| 1177 | params->offset_V = put_image_rec->offset_V; |
| 1178 | |
| 1179 | /* Check scaling after src size to prevent a divide-by-zero. */ |
| 1180 | ret = check_overlay_scaling(params); |
| 1181 | if (ret != 0) |
| 1182 | goto out_unlock; |
| 1183 | |
| 1184 | ret = intel_overlay_do_put_image(overlay, new_bo, params); |
| 1185 | if (ret != 0) |
| 1186 | goto out_unlock; |
| 1187 | |
| 1188 | mutex_unlock(&dev->struct_mutex); |
| 1189 | mutex_unlock(&dev->mode_config.mutex); |
| 1190 | |
| 1191 | kfree(params); |
| 1192 | |
| 1193 | return 0; |
| 1194 | |
| 1195 | out_unlock: |
| 1196 | mutex_unlock(&dev->struct_mutex); |
| 1197 | mutex_unlock(&dev->mode_config.mutex); |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 1198 | drm_gem_object_unreference_unlocked(new_bo); |
Dan Carpenter | 915a428 | 2010-03-06 14:05:39 +0300 | [diff] [blame] | 1199 | out_free: |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1200 | kfree(params); |
| 1201 | |
| 1202 | return ret; |
| 1203 | } |
| 1204 | |
| 1205 | static void update_reg_attrs(struct intel_overlay *overlay, |
| 1206 | struct overlay_registers *regs) |
| 1207 | { |
| 1208 | regs->OCLRC0 = (overlay->contrast << 18) | (overlay->brightness & 0xff); |
| 1209 | regs->OCLRC1 = overlay->saturation; |
| 1210 | } |
| 1211 | |
| 1212 | static bool check_gamma_bounds(u32 gamma1, u32 gamma2) |
| 1213 | { |
| 1214 | int i; |
| 1215 | |
| 1216 | if (gamma1 & 0xff000000 || gamma2 & 0xff000000) |
| 1217 | return false; |
| 1218 | |
| 1219 | for (i = 0; i < 3; i++) { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1220 | if (((gamma1 >> i*8) & 0xff) >= ((gamma2 >> i*8) & 0xff)) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1221 | return false; |
| 1222 | } |
| 1223 | |
| 1224 | return true; |
| 1225 | } |
| 1226 | |
| 1227 | static bool check_gamma5_errata(u32 gamma5) |
| 1228 | { |
| 1229 | int i; |
| 1230 | |
| 1231 | for (i = 0; i < 3; i++) { |
| 1232 | if (((gamma5 >> i*8) & 0xff) == 0x80) |
| 1233 | return false; |
| 1234 | } |
| 1235 | |
| 1236 | return true; |
| 1237 | } |
| 1238 | |
| 1239 | static int check_gamma(struct drm_intel_overlay_attrs *attrs) |
| 1240 | { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1241 | if (!check_gamma_bounds(0, attrs->gamma0) || |
| 1242 | !check_gamma_bounds(attrs->gamma0, attrs->gamma1) || |
| 1243 | !check_gamma_bounds(attrs->gamma1, attrs->gamma2) || |
| 1244 | !check_gamma_bounds(attrs->gamma2, attrs->gamma3) || |
| 1245 | !check_gamma_bounds(attrs->gamma3, attrs->gamma4) || |
| 1246 | !check_gamma_bounds(attrs->gamma4, attrs->gamma5) || |
| 1247 | !check_gamma_bounds(attrs->gamma5, 0x00ffffff)) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1248 | return -EINVAL; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1249 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1250 | if (!check_gamma5_errata(attrs->gamma5)) |
| 1251 | return -EINVAL; |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1252 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1253 | return 0; |
| 1254 | } |
| 1255 | |
| 1256 | int intel_overlay_attrs(struct drm_device *dev, void *data, |
| 1257 | struct drm_file *file_priv) |
| 1258 | { |
| 1259 | struct drm_intel_overlay_attrs *attrs = data; |
| 1260 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1261 | struct intel_overlay *overlay; |
| 1262 | struct overlay_registers *regs; |
| 1263 | int ret; |
| 1264 | |
| 1265 | if (!dev_priv) { |
| 1266 | DRM_ERROR("called with no initialization\n"); |
| 1267 | return -EINVAL; |
| 1268 | } |
| 1269 | |
| 1270 | overlay = dev_priv->overlay; |
| 1271 | if (!overlay) { |
| 1272 | DRM_DEBUG("userspace bug: no overlay\n"); |
| 1273 | return -ENODEV; |
| 1274 | } |
| 1275 | |
| 1276 | mutex_lock(&dev->mode_config.mutex); |
| 1277 | mutex_lock(&dev->struct_mutex); |
| 1278 | |
| 1279 | if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) { |
| 1280 | attrs->color_key = overlay->color_key; |
| 1281 | attrs->brightness = overlay->brightness; |
| 1282 | attrs->contrast = overlay->contrast; |
| 1283 | attrs->saturation = overlay->saturation; |
| 1284 | |
| 1285 | if (IS_I9XX(dev)) { |
| 1286 | attrs->gamma0 = I915_READ(OGAMC0); |
| 1287 | attrs->gamma1 = I915_READ(OGAMC1); |
| 1288 | attrs->gamma2 = I915_READ(OGAMC2); |
| 1289 | attrs->gamma3 = I915_READ(OGAMC3); |
| 1290 | attrs->gamma4 = I915_READ(OGAMC4); |
| 1291 | attrs->gamma5 = I915_READ(OGAMC5); |
| 1292 | } |
| 1293 | ret = 0; |
| 1294 | } else { |
| 1295 | overlay->color_key = attrs->color_key; |
| 1296 | if (attrs->brightness >= -128 && attrs->brightness <= 127) { |
| 1297 | overlay->brightness = attrs->brightness; |
| 1298 | } else { |
| 1299 | ret = -EINVAL; |
| 1300 | goto out_unlock; |
| 1301 | } |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1302 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1303 | if (attrs->contrast <= 255) { |
| 1304 | overlay->contrast = attrs->contrast; |
| 1305 | } else { |
| 1306 | ret = -EINVAL; |
| 1307 | goto out_unlock; |
| 1308 | } |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1309 | |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1310 | if (attrs->saturation <= 1023) { |
| 1311 | overlay->saturation = attrs->saturation; |
| 1312 | } else { |
| 1313 | ret = -EINVAL; |
| 1314 | goto out_unlock; |
| 1315 | } |
| 1316 | |
| 1317 | regs = intel_overlay_map_regs_atomic(overlay); |
| 1318 | if (!regs) { |
| 1319 | ret = -ENOMEM; |
| 1320 | goto out_unlock; |
| 1321 | } |
| 1322 | |
| 1323 | update_reg_attrs(overlay, regs); |
| 1324 | |
| 1325 | intel_overlay_unmap_regs_atomic(overlay); |
| 1326 | |
| 1327 | if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { |
| 1328 | if (!IS_I9XX(dev)) { |
| 1329 | ret = -EINVAL; |
| 1330 | goto out_unlock; |
| 1331 | } |
| 1332 | |
| 1333 | if (overlay->active) { |
| 1334 | ret = -EBUSY; |
| 1335 | goto out_unlock; |
| 1336 | } |
| 1337 | |
| 1338 | ret = check_gamma(attrs); |
| 1339 | if (ret != 0) |
| 1340 | goto out_unlock; |
| 1341 | |
| 1342 | I915_WRITE(OGAMC0, attrs->gamma0); |
| 1343 | I915_WRITE(OGAMC1, attrs->gamma1); |
| 1344 | I915_WRITE(OGAMC2, attrs->gamma2); |
| 1345 | I915_WRITE(OGAMC3, attrs->gamma3); |
| 1346 | I915_WRITE(OGAMC4, attrs->gamma4); |
| 1347 | I915_WRITE(OGAMC5, attrs->gamma5); |
| 1348 | } |
| 1349 | ret = 0; |
| 1350 | } |
| 1351 | |
| 1352 | out_unlock: |
| 1353 | mutex_unlock(&dev->struct_mutex); |
| 1354 | mutex_unlock(&dev->mode_config.mutex); |
| 1355 | |
| 1356 | return ret; |
| 1357 | } |
| 1358 | |
| 1359 | void intel_setup_overlay(struct drm_device *dev) |
| 1360 | { |
| 1361 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1362 | struct intel_overlay *overlay; |
| 1363 | struct drm_gem_object *reg_bo; |
| 1364 | struct overlay_registers *regs; |
| 1365 | int ret; |
| 1366 | |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 1367 | if (!HAS_OVERLAY(dev)) |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1368 | return; |
| 1369 | |
| 1370 | overlay = kzalloc(sizeof(struct intel_overlay), GFP_KERNEL); |
| 1371 | if (!overlay) |
| 1372 | return; |
| 1373 | overlay->dev = dev; |
| 1374 | |
Daniel Vetter | ac52bc5 | 2010-04-09 19:05:06 +0000 | [diff] [blame] | 1375 | reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1376 | if (!reg_bo) |
| 1377 | goto out_free; |
Daniel Vetter | 23010e4 | 2010-03-08 13:35:02 +0100 | [diff] [blame] | 1378 | overlay->reg_bo = to_intel_bo(reg_bo); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1379 | |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 1380 | if (OVERLAY_NEEDS_PHYSICAL(dev)) { |
| 1381 | ret = i915_gem_attach_phys_object(dev, reg_bo, |
| 1382 | I915_GEM_PHYS_OVERLAY_REGS, |
| 1383 | 0); |
| 1384 | if (ret) { |
| 1385 | DRM_ERROR("failed to attach phys overlay regs\n"); |
| 1386 | goto out_free_bo; |
| 1387 | } |
| 1388 | overlay->flip_addr = overlay->reg_bo->phys_obj->handle->busaddr; |
| 1389 | } else { |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1390 | ret = i915_gem_object_pin(reg_bo, PAGE_SIZE); |
| 1391 | if (ret) { |
| 1392 | DRM_ERROR("failed to pin overlay register bo\n"); |
| 1393 | goto out_free_bo; |
| 1394 | } |
| 1395 | overlay->flip_addr = overlay->reg_bo->gtt_offset; |
Chris Wilson | 0ddc128 | 2010-08-12 09:35:00 +0100 | [diff] [blame] | 1396 | |
| 1397 | ret = i915_gem_object_set_to_gtt_domain(reg_bo, true); |
| 1398 | if (ret) { |
| 1399 | DRM_ERROR("failed to move overlay register bo into the GTT\n"); |
| 1400 | goto out_unpin_bo; |
| 1401 | } |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /* init all values */ |
| 1405 | overlay->color_key = 0x0101fe; |
| 1406 | overlay->brightness = -19; |
| 1407 | overlay->contrast = 75; |
| 1408 | overlay->saturation = 146; |
| 1409 | |
| 1410 | regs = intel_overlay_map_regs_atomic(overlay); |
| 1411 | if (!regs) |
| 1412 | goto out_free_bo; |
| 1413 | |
| 1414 | memset(regs, 0, sizeof(struct overlay_registers)); |
| 1415 | update_polyphase_filter(regs); |
| 1416 | |
| 1417 | update_reg_attrs(overlay, regs); |
| 1418 | |
| 1419 | intel_overlay_unmap_regs_atomic(overlay); |
| 1420 | |
| 1421 | dev_priv->overlay = overlay; |
| 1422 | DRM_INFO("initialized overlay support\n"); |
| 1423 | return; |
| 1424 | |
Chris Wilson | 0ddc128 | 2010-08-12 09:35:00 +0100 | [diff] [blame] | 1425 | out_unpin_bo: |
| 1426 | i915_gem_object_unpin(reg_bo); |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1427 | out_free_bo: |
| 1428 | drm_gem_object_unreference(reg_bo); |
| 1429 | out_free: |
| 1430 | kfree(overlay); |
| 1431 | return; |
| 1432 | } |
| 1433 | |
| 1434 | void intel_cleanup_overlay(struct drm_device *dev) |
| 1435 | { |
Chris Wilson | 722506f | 2010-08-12 09:28:50 +0100 | [diff] [blame] | 1436 | drm_i915_private_t *dev_priv = dev->dev_private; |
Daniel Vetter | 02e792f | 2009-09-15 22:57:34 +0200 | [diff] [blame] | 1437 | |
| 1438 | if (dev_priv->overlay) { |
| 1439 | /* The bo's should be free'd by the generic code already. |
| 1440 | * Furthermore modesetting teardown happens beforehand so the |
| 1441 | * hardware should be off already */ |
| 1442 | BUG_ON(dev_priv->overlay->active); |
| 1443 | |
| 1444 | kfree(dev_priv->overlay); |
| 1445 | } |
| 1446 | } |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 1447 | |
| 1448 | struct intel_overlay_error_state { |
| 1449 | struct overlay_registers regs; |
| 1450 | unsigned long base; |
| 1451 | u32 dovsta; |
| 1452 | u32 isr; |
| 1453 | }; |
| 1454 | |
| 1455 | struct intel_overlay_error_state * |
| 1456 | intel_overlay_capture_error_state(struct drm_device *dev) |
| 1457 | { |
| 1458 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 1459 | struct intel_overlay *overlay = dev_priv->overlay; |
| 1460 | struct intel_overlay_error_state *error; |
| 1461 | struct overlay_registers __iomem *regs; |
| 1462 | |
| 1463 | if (!overlay || !overlay->active) |
| 1464 | return NULL; |
| 1465 | |
| 1466 | error = kmalloc(sizeof(*error), GFP_ATOMIC); |
| 1467 | if (error == NULL) |
| 1468 | return NULL; |
| 1469 | |
| 1470 | error->dovsta = I915_READ(DOVSTA); |
| 1471 | error->isr = I915_READ(ISR); |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 1472 | if (OVERLAY_NEEDS_PHYSICAL(overlay->dev)) |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 1473 | error->base = (long) overlay->reg_bo->phys_obj->handle->vaddr; |
Chris Wilson | 31578148 | 2010-08-12 09:42:51 +0100 | [diff] [blame^] | 1474 | else |
| 1475 | error->base = (long) overlay->reg_bo->gtt_offset; |
Chris Wilson | 6ef3d42 | 2010-08-04 20:26:07 +0100 | [diff] [blame] | 1476 | |
| 1477 | regs = intel_overlay_map_regs_atomic(overlay); |
| 1478 | if (!regs) |
| 1479 | goto err; |
| 1480 | |
| 1481 | memcpy_fromio(&error->regs, regs, sizeof(struct overlay_registers)); |
| 1482 | intel_overlay_unmap_regs_atomic(overlay); |
| 1483 | |
| 1484 | return error; |
| 1485 | |
| 1486 | err: |
| 1487 | kfree(error); |
| 1488 | return NULL; |
| 1489 | } |
| 1490 | |
| 1491 | void |
| 1492 | intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error) |
| 1493 | { |
| 1494 | seq_printf(m, "Overlay, status: 0x%08x, interrupt: 0x%08x\n", |
| 1495 | error->dovsta, error->isr); |
| 1496 | seq_printf(m, " Register file at 0x%08lx:\n", |
| 1497 | error->base); |
| 1498 | |
| 1499 | #define P(x) seq_printf(m, " " #x ": 0x%08x\n", error->regs.x) |
| 1500 | P(OBUF_0Y); |
| 1501 | P(OBUF_1Y); |
| 1502 | P(OBUF_0U); |
| 1503 | P(OBUF_0V); |
| 1504 | P(OBUF_1U); |
| 1505 | P(OBUF_1V); |
| 1506 | P(OSTRIDE); |
| 1507 | P(YRGB_VPH); |
| 1508 | P(UV_VPH); |
| 1509 | P(HORZ_PH); |
| 1510 | P(INIT_PHS); |
| 1511 | P(DWINPOS); |
| 1512 | P(DWINSZ); |
| 1513 | P(SWIDTH); |
| 1514 | P(SWIDTHSW); |
| 1515 | P(SHEIGHT); |
| 1516 | P(YRGBSCALE); |
| 1517 | P(UVSCALE); |
| 1518 | P(OCLRC0); |
| 1519 | P(OCLRC1); |
| 1520 | P(DCLRKV); |
| 1521 | P(DCLRKM); |
| 1522 | P(SCLRKVH); |
| 1523 | P(SCLRKVL); |
| 1524 | P(SCLRKEN); |
| 1525 | P(OCONFIG); |
| 1526 | P(OCMD); |
| 1527 | P(OSTART_0Y); |
| 1528 | P(OSTART_1Y); |
| 1529 | P(OSTART_0U); |
| 1530 | P(OSTART_0V); |
| 1531 | P(OSTART_1U); |
| 1532 | P(OSTART_1V); |
| 1533 | P(OTILEOFF_0Y); |
| 1534 | P(OTILEOFF_1Y); |
| 1535 | P(OTILEOFF_0U); |
| 1536 | P(OTILEOFF_0V); |
| 1537 | P(OTILEOFF_1U); |
| 1538 | P(OTILEOFF_1V); |
| 1539 | P(FASTHSCALE); |
| 1540 | P(UVSCALEV); |
| 1541 | #undef P |
| 1542 | } |