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:
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
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
24 * Daniel Vetter <daniel@ffwll.ch>
26 * Derived from Xorg ddx, xf86-video-intel, src/i830_video.c
33 #include "intel_drv.h"
35 /* Limits for overlay size. According to intel doc, the real limits are:
36 * Y width: 4095, UV width (planar): 2047, Y height: 2047,
37 * UV width (planar): * 1023. But the xorg thinks 2048 for height and width. Use
38 * the mininum of both. */
39 #define IMAGE_MAX_WIDTH 2048
40 #define IMAGE_MAX_HEIGHT 2046 /* 2 * 1023 */
41 /* on 830 and 845 these large limits result in the card hanging */
42 #define IMAGE_MAX_WIDTH_LEGACY 1024
43 #define IMAGE_MAX_HEIGHT_LEGACY 1088
45 /* overlay register definitions */
47 #define OCMD_TILED_SURFACE (0x1<<19)
48 #define OCMD_MIRROR_MASK (0x3<<17)
49 #define OCMD_MIRROR_MODE (0x3<<17)
50 #define OCMD_MIRROR_HORIZONTAL (0x1<<17)
51 #define OCMD_MIRROR_VERTICAL (0x2<<17)
52 #define OCMD_MIRROR_BOTH (0x3<<17)
53 #define OCMD_BYTEORDER_MASK (0x3<<14) /* zero for YUYV or FOURCC YUY2 */
54 #define OCMD_UV_SWAP (0x1<<14) /* YVYU */
55 #define OCMD_Y_SWAP (0x2<<14) /* UYVY or FOURCC UYVY */
56 #define OCMD_Y_AND_UV_SWAP (0x3<<14) /* VYUY */
57 #define OCMD_SOURCE_FORMAT_MASK (0xf<<10)
58 #define OCMD_RGB_888 (0x1<<10) /* not in i965 Intel docs */
59 #define OCMD_RGB_555 (0x2<<10) /* not in i965 Intel docs */
60 #define OCMD_RGB_565 (0x3<<10) /* not in i965 Intel docs */
61 #define OCMD_YUV_422_PACKED (0x8<<10)
62 #define OCMD_YUV_411_PACKED (0x9<<10) /* not in i965 Intel docs */
63 #define OCMD_YUV_420_PLANAR (0xc<<10)
64 #define OCMD_YUV_422_PLANAR (0xd<<10)
65 #define OCMD_YUV_410_PLANAR (0xe<<10) /* also 411 */
66 #define OCMD_TVSYNCFLIP_PARITY (0x1<<9)
67 #define OCMD_TVSYNCFLIP_ENABLE (0x1<<7)
68 #define OCMD_BUF_TYPE_MASK (0x1<<5)
69 #define OCMD_BUF_TYPE_FRAME (0x0<<5)
70 #define OCMD_BUF_TYPE_FIELD (0x1<<5)
71 #define OCMD_TEST_MODE (0x1<<4)
72 #define OCMD_BUFFER_SELECT (0x3<<2)
73 #define OCMD_BUFFER0 (0x0<<2)
74 #define OCMD_BUFFER1 (0x1<<2)
75 #define OCMD_FIELD_SELECT (0x1<<2)
76 #define OCMD_FIELD0 (0x0<<1)
77 #define OCMD_FIELD1 (0x1<<1)
78 #define OCMD_ENABLE (0x1<<0)
80 /* OCONFIG register */
81 #define OCONF_PIPE_MASK (0x1<<18)
82 #define OCONF_PIPE_A (0x0<<18)
83 #define OCONF_PIPE_B (0x1<<18)
84 #define OCONF_GAMMA2_ENABLE (0x1<<16)
85 #define OCONF_CSC_MODE_BT601 (0x0<<5)
86 #define OCONF_CSC_MODE_BT709 (0x1<<5)
87 #define OCONF_CSC_BYPASS (0x1<<4)
88 #define OCONF_CC_OUT_8BIT (0x1<<3)
89 #define OCONF_TEST_MODE (0x1<<2)
90 #define OCONF_THREE_LINE_BUFFER (0x1<<0)
91 #define OCONF_TWO_LINE_BUFFER (0x0<<0)
93 /* DCLRKM (dst-key) register */
94 #define DST_KEY_ENABLE (0x1<<31)
95 #define CLK_RGB24_MASK 0x0
96 #define CLK_RGB16_MASK 0x070307
97 #define CLK_RGB15_MASK 0x070707
98 #define CLK_RGB8I_MASK 0xffffff
100 #define RGB16_TO_COLORKEY(c) \
101 (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3))
102 #define RGB15_TO_COLORKEY(c) \
103 (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3))
105 /* overlay flip addr flag */
106 #define OFC_UPDATE 0x1
108 /* polyphase filter coefficients */
109 #define N_HORIZ_Y_TAPS 5
110 #define N_VERT_Y_TAPS 3
111 #define N_HORIZ_UV_TAPS 3
112 #define N_VERT_UV_TAPS 3
116 /* memory bufferd overlay registers */
117 struct overlay_registers {
145 u32 RESERVED1; /* 0x6C */
158 u32 FASTHSCALE; /* 0xA0 */
159 u32 UVSCALEV; /* 0xA4 */
160 u32 RESERVEDC[(0x200 - 0xA8) / 4]; /* 0xA8 - 0x1FC */
161 u16 Y_VCOEFS[N_VERT_Y_TAPS * N_PHASES]; /* 0x200 */
162 u16 RESERVEDD[0x100 / 2 - N_VERT_Y_TAPS * N_PHASES];
163 u16 Y_HCOEFS[N_HORIZ_Y_TAPS * N_PHASES]; /* 0x300 */
164 u16 RESERVEDE[0x200 / 2 - N_HORIZ_Y_TAPS * N_PHASES];
165 u16 UV_VCOEFS[N_VERT_UV_TAPS * N_PHASES]; /* 0x500 */
166 u16 RESERVEDF[0x100 / 2 - N_VERT_UV_TAPS * N_PHASES];
167 u16 UV_HCOEFS[N_HORIZ_UV_TAPS * N_PHASES]; /* 0x600 */
168 u16 RESERVEDG[0x100 / 2 - N_HORIZ_UV_TAPS * N_PHASES];
171 struct intel_overlay {
172 struct drm_device *dev;
173 struct intel_crtc *crtc;
174 struct drm_i915_gem_object *vid_bo;
175 struct drm_i915_gem_object *old_vid_bo;
178 u32 pfit_vscale_ratio; /* shifted-point number, (1<<12) == 1.0 */
180 u32 brightness, contrast, saturation;
181 u32 old_xscale, old_yscale;
182 /* register access */
184 struct drm_i915_gem_object *reg_bo;
186 uint32_t last_flip_req;
187 void (*flip_tail)(struct intel_overlay *);
190 static struct overlay_registers __iomem *
191 intel_overlay_map_regs(struct intel_overlay *overlay)
193 drm_i915_private_t *dev_priv = overlay->dev->dev_private;
194 struct overlay_registers __iomem *regs;
196 if (OVERLAY_NEEDS_PHYSICAL(overlay->dev))
197 regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_obj->handle->vaddr;
199 regs = io_mapping_map_wc(dev_priv->mm.gtt_mapping,
200 overlay->reg_bo->gtt_offset);
205 static void intel_overlay_unmap_regs(struct intel_overlay *overlay,
206 struct overlay_registers __iomem *regs)
208 if (!OVERLAY_NEEDS_PHYSICAL(overlay->dev))
209 io_mapping_unmap(regs);
212 static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
213 struct drm_i915_gem_request *request,
214 void (*tail)(struct intel_overlay *))
216 struct drm_device *dev = overlay->dev;
217 drm_i915_private_t *dev_priv = dev->dev_private;
218 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
221 BUG_ON(overlay->last_flip_req);
222 ret = i915_add_request(ring, NULL, request);
227 overlay->last_flip_req = request->seqno;
228 overlay->flip_tail = tail;
229 ret = i915_wait_request(ring, overlay->last_flip_req);
232 i915_gem_retire_requests(dev);
234 overlay->last_flip_req = 0;
238 /* Workaround for i830 bug where pipe a must be enable to change control regs */
240 i830_activate_pipe_a(struct drm_device *dev)
242 drm_i915_private_t *dev_priv = dev->dev_private;
243 struct intel_crtc *crtc;
244 struct drm_crtc_helper_funcs *crtc_funcs;
245 struct drm_display_mode vesa_640x480 = {
246 DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
247 752, 800, 0, 480, 489, 492, 525, 0,
248 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC)
251 crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[0]);
252 if (crtc->dpms_mode == DRM_MODE_DPMS_ON)
255 /* most i8xx have pipe a forced on, so don't trust dpms mode */
256 if (I915_READ(_PIPEACONF) & PIPECONF_ENABLE)
259 crtc_funcs = crtc->base.helper_private;
260 if (crtc_funcs->dpms == NULL)
263 DRM_DEBUG_DRIVER("Enabling pipe A in order to enable overlay\n");
265 mode = drm_mode_duplicate(dev, &vesa_640x480);
267 if (!drm_crtc_helper_set_mode(&crtc->base, mode,
268 crtc->base.x, crtc->base.y,
272 crtc_funcs->dpms(&crtc->base, DRM_MODE_DPMS_ON);
277 i830_deactivate_pipe_a(struct drm_device *dev)
279 drm_i915_private_t *dev_priv = dev->dev_private;
280 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[0];
281 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
283 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
286 /* overlay needs to be disable in OCMD reg */
287 static int intel_overlay_on(struct intel_overlay *overlay)
289 struct drm_device *dev = overlay->dev;
290 struct drm_i915_private *dev_priv = dev->dev_private;
291 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
292 struct drm_i915_gem_request *request;
293 int pipe_a_quirk = 0;
296 BUG_ON(overlay->active);
300 pipe_a_quirk = i830_activate_pipe_a(dev);
301 if (pipe_a_quirk < 0)
305 request = kzalloc(sizeof(*request), GFP_KERNEL);
306 if (request == NULL) {
311 ret = intel_ring_begin(ring, 4);
317 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_ON);
318 intel_ring_emit(ring, overlay->flip_addr | OFC_UPDATE);
319 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
320 intel_ring_emit(ring, MI_NOOP);
321 intel_ring_advance(ring);
323 ret = intel_overlay_do_wait_request(overlay, request, NULL);
326 i830_deactivate_pipe_a(dev);
331 /* overlay needs to be enabled in OCMD reg */
332 static int intel_overlay_continue(struct intel_overlay *overlay,
333 bool load_polyphase_filter)
335 struct drm_device *dev = overlay->dev;
336 drm_i915_private_t *dev_priv = dev->dev_private;
337 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
338 struct drm_i915_gem_request *request;
339 u32 flip_addr = overlay->flip_addr;
343 BUG_ON(!overlay->active);
345 request = kzalloc(sizeof(*request), GFP_KERNEL);
349 if (load_polyphase_filter)
350 flip_addr |= OFC_UPDATE;
352 /* check for underruns */
353 tmp = I915_READ(DOVSTA);
355 DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp);
357 ret = intel_ring_begin(ring, 2);
362 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
363 intel_ring_emit(ring, flip_addr);
364 intel_ring_advance(ring);
366 ret = i915_add_request(ring, NULL, request);
372 overlay->last_flip_req = request->seqno;
376 static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
378 struct drm_i915_gem_object *obj = overlay->old_vid_bo;
380 i915_gem_object_unpin(obj);
381 drm_gem_object_unreference(&obj->base);
383 overlay->old_vid_bo = NULL;
386 static void intel_overlay_off_tail(struct intel_overlay *overlay)
388 struct drm_i915_gem_object *obj = overlay->vid_bo;
390 /* never have the overlay hw on without showing a frame */
391 BUG_ON(!overlay->vid_bo);
393 i915_gem_object_unpin(obj);
394 drm_gem_object_unreference(&obj->base);
395 overlay->vid_bo = NULL;
397 overlay->crtc->overlay = NULL;
398 overlay->crtc = NULL;
402 /* overlay needs to be disabled in OCMD reg */
403 static int intel_overlay_off(struct intel_overlay *overlay)
405 struct drm_device *dev = overlay->dev;
406 struct drm_i915_private *dev_priv = dev->dev_private;
407 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
408 u32 flip_addr = overlay->flip_addr;
409 struct drm_i915_gem_request *request;
412 BUG_ON(!overlay->active);
414 request = kzalloc(sizeof(*request), GFP_KERNEL);
418 /* According to intel docs the overlay hw may hang (when switching
419 * off) without loading the filter coeffs. It is however unclear whether
420 * this applies to the disabling of the overlay or to the switching off
421 * of the hw. Do it in both cases */
422 flip_addr |= OFC_UPDATE;
424 ret = intel_ring_begin(ring, 6);
429 /* wait for overlay to go idle */
430 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
431 intel_ring_emit(ring, flip_addr);
432 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
433 /* turn overlay off */
434 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_OFF);
435 intel_ring_emit(ring, flip_addr);
436 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
437 intel_ring_advance(ring);
439 return intel_overlay_do_wait_request(overlay, request,
440 intel_overlay_off_tail);
443 /* recover from an interruption due to a signal
444 * We have to be careful not to repeat work forever an make forward progess. */
445 static int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
447 struct drm_device *dev = overlay->dev;
448 drm_i915_private_t *dev_priv = dev->dev_private;
449 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
452 if (overlay->last_flip_req == 0)
455 ret = i915_wait_request(ring, overlay->last_flip_req);
458 i915_gem_retire_requests(dev);
460 if (overlay->flip_tail)
461 overlay->flip_tail(overlay);
463 overlay->last_flip_req = 0;
467 /* Wait for pending overlay flip and release old frame.
468 * Needs to be called before the overlay register are changed
469 * via intel_overlay_(un)map_regs
471 static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
473 struct drm_device *dev = overlay->dev;
474 drm_i915_private_t *dev_priv = dev->dev_private;
475 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
478 /* Only wait if there is actually an old frame to release to
479 * guarantee forward progress.
481 if (!overlay->old_vid_bo)
484 if (I915_READ(ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT) {
485 struct drm_i915_gem_request *request;
487 /* synchronous slowpath */
488 request = kzalloc(sizeof(*request), GFP_KERNEL);
492 ret = intel_ring_begin(ring, 2);
498 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
499 intel_ring_emit(ring, MI_NOOP);
500 intel_ring_advance(ring);
502 ret = intel_overlay_do_wait_request(overlay, request,
503 intel_overlay_release_old_vid_tail);
508 intel_overlay_release_old_vid_tail(overlay);
512 struct put_image_params {
529 static int packed_depth_bytes(u32 format)
531 switch (format & I915_OVERLAY_DEPTH_MASK) {
532 case I915_OVERLAY_YUV422:
534 case I915_OVERLAY_YUV411:
535 /* return 6; not implemented */
541 static int packed_width_bytes(u32 format, short width)
543 switch (format & I915_OVERLAY_DEPTH_MASK) {
544 case I915_OVERLAY_YUV422:
551 static int uv_hsubsampling(u32 format)
553 switch (format & I915_OVERLAY_DEPTH_MASK) {
554 case I915_OVERLAY_YUV422:
555 case I915_OVERLAY_YUV420:
557 case I915_OVERLAY_YUV411:
558 case I915_OVERLAY_YUV410:
565 static int uv_vsubsampling(u32 format)
567 switch (format & I915_OVERLAY_DEPTH_MASK) {
568 case I915_OVERLAY_YUV420:
569 case I915_OVERLAY_YUV410:
571 case I915_OVERLAY_YUV422:
572 case I915_OVERLAY_YUV411:
579 static u32 calc_swidthsw(struct drm_device *dev, u32 offset, u32 width)
581 u32 mask, shift, ret;
589 ret = ((offset + width + mask) >> shift) - (offset >> shift);
596 static const u16 y_static_hcoeffs[N_HORIZ_Y_TAPS * N_PHASES] = {
597 0x3000, 0xb4a0, 0x1930, 0x1920, 0xb4a0,
598 0x3000, 0xb500, 0x19d0, 0x1880, 0xb440,
599 0x3000, 0xb540, 0x1a88, 0x2f80, 0xb3e0,
600 0x3000, 0xb580, 0x1b30, 0x2e20, 0xb380,
601 0x3000, 0xb5c0, 0x1bd8, 0x2cc0, 0xb320,
602 0x3020, 0xb5e0, 0x1c60, 0x2b80, 0xb2c0,
603 0x3020, 0xb5e0, 0x1cf8, 0x2a20, 0xb260,
604 0x3020, 0xb5e0, 0x1d80, 0x28e0, 0xb200,
605 0x3020, 0xb5c0, 0x1e08, 0x3f40, 0xb1c0,
606 0x3020, 0xb580, 0x1e78, 0x3ce0, 0xb160,
607 0x3040, 0xb520, 0x1ed8, 0x3aa0, 0xb120,
608 0x3040, 0xb4a0, 0x1f30, 0x3880, 0xb0e0,
609 0x3040, 0xb400, 0x1f78, 0x3680, 0xb0a0,
610 0x3020, 0xb340, 0x1fb8, 0x34a0, 0xb060,
611 0x3020, 0xb240, 0x1fe0, 0x32e0, 0xb040,
612 0x3020, 0xb140, 0x1ff8, 0x3160, 0xb020,
613 0xb000, 0x3000, 0x0800, 0x3000, 0xb000
616 static const u16 uv_static_hcoeffs[N_HORIZ_UV_TAPS * N_PHASES] = {
617 0x3000, 0x1800, 0x1800, 0xb000, 0x18d0, 0x2e60,
618 0xb000, 0x1990, 0x2ce0, 0xb020, 0x1a68, 0x2b40,
619 0xb040, 0x1b20, 0x29e0, 0xb060, 0x1bd8, 0x2880,
620 0xb080, 0x1c88, 0x3e60, 0xb0a0, 0x1d28, 0x3c00,
621 0xb0c0, 0x1db8, 0x39e0, 0xb0e0, 0x1e40, 0x37e0,
622 0xb100, 0x1eb8, 0x3620, 0xb100, 0x1f18, 0x34a0,
623 0xb100, 0x1f68, 0x3360, 0xb0e0, 0x1fa8, 0x3240,
624 0xb0c0, 0x1fe0, 0x3140, 0xb060, 0x1ff0, 0x30a0,
625 0x3000, 0x0800, 0x3000
628 static void update_polyphase_filter(struct overlay_registers __iomem *regs)
630 memcpy_toio(regs->Y_HCOEFS, y_static_hcoeffs, sizeof(y_static_hcoeffs));
631 memcpy_toio(regs->UV_HCOEFS, uv_static_hcoeffs,
632 sizeof(uv_static_hcoeffs));
635 static bool update_scaling_factors(struct intel_overlay *overlay,
636 struct overlay_registers __iomem *regs,
637 struct put_image_params *params)
639 /* fixed point with a 12 bit shift */
640 u32 xscale, yscale, xscale_UV, yscale_UV;
642 #define FRACT_MASK 0xfff
643 bool scale_changed = false;
644 int uv_hscale = uv_hsubsampling(params->format);
645 int uv_vscale = uv_vsubsampling(params->format);
647 if (params->dst_w > 1)
648 xscale = ((params->src_scan_w - 1) << FP_SHIFT)
651 xscale = 1 << FP_SHIFT;
653 if (params->dst_h > 1)
654 yscale = ((params->src_scan_h - 1) << FP_SHIFT)
657 yscale = 1 << FP_SHIFT;
659 /*if (params->format & I915_OVERLAY_YUV_PLANAR) {*/
660 xscale_UV = xscale/uv_hscale;
661 yscale_UV = yscale/uv_vscale;
662 /* make the Y scale to UV scale ratio an exact multiply */
663 xscale = xscale_UV * uv_hscale;
664 yscale = yscale_UV * uv_vscale;
670 if (xscale != overlay->old_xscale || yscale != overlay->old_yscale)
671 scale_changed = true;
672 overlay->old_xscale = xscale;
673 overlay->old_yscale = yscale;
675 iowrite32(((yscale & FRACT_MASK) << 20) |
676 ((xscale >> FP_SHIFT) << 16) |
677 ((xscale & FRACT_MASK) << 3),
680 iowrite32(((yscale_UV & FRACT_MASK) << 20) |
681 ((xscale_UV >> FP_SHIFT) << 16) |
682 ((xscale_UV & FRACT_MASK) << 3),
685 iowrite32((((yscale >> FP_SHIFT) << 16) |
686 ((yscale_UV >> FP_SHIFT) << 0)),
690 update_polyphase_filter(regs);
692 return scale_changed;
695 static void update_colorkey(struct intel_overlay *overlay,
696 struct overlay_registers __iomem *regs)
698 u32 key = overlay->color_key;
700 switch (overlay->crtc->base.fb->bits_per_pixel) {
702 iowrite32(0, ®s->DCLRKV);
703 iowrite32(CLK_RGB8I_MASK | DST_KEY_ENABLE, ®s->DCLRKM);
707 if (overlay->crtc->base.fb->depth == 15) {
708 iowrite32(RGB15_TO_COLORKEY(key), ®s->DCLRKV);
709 iowrite32(CLK_RGB15_MASK | DST_KEY_ENABLE,
712 iowrite32(RGB16_TO_COLORKEY(key), ®s->DCLRKV);
713 iowrite32(CLK_RGB16_MASK | DST_KEY_ENABLE,
720 iowrite32(key, ®s->DCLRKV);
721 iowrite32(CLK_RGB24_MASK | DST_KEY_ENABLE, ®s->DCLRKM);
726 static u32 overlay_cmd_reg(struct put_image_params *params)
728 u32 cmd = OCMD_ENABLE | OCMD_BUF_TYPE_FRAME | OCMD_BUFFER0;
730 if (params->format & I915_OVERLAY_YUV_PLANAR) {
731 switch (params->format & I915_OVERLAY_DEPTH_MASK) {
732 case I915_OVERLAY_YUV422:
733 cmd |= OCMD_YUV_422_PLANAR;
735 case I915_OVERLAY_YUV420:
736 cmd |= OCMD_YUV_420_PLANAR;
738 case I915_OVERLAY_YUV411:
739 case I915_OVERLAY_YUV410:
740 cmd |= OCMD_YUV_410_PLANAR;
743 } else { /* YUV packed */
744 switch (params->format & I915_OVERLAY_DEPTH_MASK) {
745 case I915_OVERLAY_YUV422:
746 cmd |= OCMD_YUV_422_PACKED;
748 case I915_OVERLAY_YUV411:
749 cmd |= OCMD_YUV_411_PACKED;
753 switch (params->format & I915_OVERLAY_SWAP_MASK) {
754 case I915_OVERLAY_NO_SWAP:
756 case I915_OVERLAY_UV_SWAP:
759 case I915_OVERLAY_Y_SWAP:
762 case I915_OVERLAY_Y_AND_UV_SWAP:
763 cmd |= OCMD_Y_AND_UV_SWAP;
771 static int intel_overlay_do_put_image(struct intel_overlay *overlay,
772 struct drm_i915_gem_object *new_bo,
773 struct put_image_params *params)
776 struct overlay_registers __iomem *regs;
777 bool scale_changed = false;
778 struct drm_device *dev = overlay->dev;
779 u32 swidth, swidthsw, sheight, ostride;
781 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
782 BUG_ON(!mutex_is_locked(&dev->mode_config.mutex));
785 ret = intel_overlay_release_old_vid(overlay);
789 ret = i915_gem_object_pin_to_display_plane(new_bo, 0, NULL);
793 ret = i915_gem_object_put_fence(new_bo);
797 if (!overlay->active) {
799 regs = intel_overlay_map_regs(overlay);
804 oconfig = OCONF_CC_OUT_8BIT;
805 if (IS_GEN4(overlay->dev))
806 oconfig |= OCONF_CSC_MODE_BT709;
807 oconfig |= overlay->crtc->pipe == 0 ?
808 OCONF_PIPE_A : OCONF_PIPE_B;
809 iowrite32(oconfig, ®s->OCONFIG);
810 intel_overlay_unmap_regs(overlay, regs);
812 ret = intel_overlay_on(overlay);
817 regs = intel_overlay_map_regs(overlay);
823 iowrite32((params->dst_y << 16) | params->dst_x, ®s->DWINPOS);
824 iowrite32((params->dst_h << 16) | params->dst_w, ®s->DWINSZ);
826 if (params->format & I915_OVERLAY_YUV_PACKED)
827 tmp_width = packed_width_bytes(params->format, params->src_w);
829 tmp_width = params->src_w;
831 swidth = params->src_w;
832 swidthsw = calc_swidthsw(overlay->dev, params->offset_Y, tmp_width);
833 sheight = params->src_h;
834 iowrite32(new_bo->gtt_offset + params->offset_Y, ®s->OBUF_0Y);
835 ostride = params->stride_Y;
837 if (params->format & I915_OVERLAY_YUV_PLANAR) {
838 int uv_hscale = uv_hsubsampling(params->format);
839 int uv_vscale = uv_vsubsampling(params->format);
841 swidth |= (params->src_w/uv_hscale) << 16;
842 tmp_U = calc_swidthsw(overlay->dev, params->offset_U,
843 params->src_w/uv_hscale);
844 tmp_V = calc_swidthsw(overlay->dev, params->offset_V,
845 params->src_w/uv_hscale);
846 swidthsw |= max_t(u32, tmp_U, tmp_V) << 16;
847 sheight |= (params->src_h/uv_vscale) << 16;
848 iowrite32(new_bo->gtt_offset + params->offset_U, ®s->OBUF_0U);
849 iowrite32(new_bo->gtt_offset + params->offset_V, ®s->OBUF_0V);
850 ostride |= params->stride_UV << 16;
853 iowrite32(swidth, ®s->SWIDTH);
854 iowrite32(swidthsw, ®s->SWIDTHSW);
855 iowrite32(sheight, ®s->SHEIGHT);
856 iowrite32(ostride, ®s->OSTRIDE);
858 scale_changed = update_scaling_factors(overlay, regs, params);
860 update_colorkey(overlay, regs);
862 iowrite32(overlay_cmd_reg(params), ®s->OCMD);
864 intel_overlay_unmap_regs(overlay, regs);
866 ret = intel_overlay_continue(overlay, scale_changed);
870 overlay->old_vid_bo = overlay->vid_bo;
871 overlay->vid_bo = new_bo;
876 i915_gem_object_unpin(new_bo);
880 int intel_overlay_switch_off(struct intel_overlay *overlay)
882 struct overlay_registers __iomem *regs;
883 struct drm_device *dev = overlay->dev;
886 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
887 BUG_ON(!mutex_is_locked(&dev->mode_config.mutex));
889 ret = intel_overlay_recover_from_interrupt(overlay);
893 if (!overlay->active)
896 ret = intel_overlay_release_old_vid(overlay);
900 regs = intel_overlay_map_regs(overlay);
901 iowrite32(0, ®s->OCMD);
902 intel_overlay_unmap_regs(overlay, regs);
904 ret = intel_overlay_off(overlay);
908 intel_overlay_off_tail(overlay);
912 static int check_overlay_possible_on_crtc(struct intel_overlay *overlay,
913 struct intel_crtc *crtc)
915 drm_i915_private_t *dev_priv = overlay->dev->dev_private;
920 /* can't use the overlay with double wide pipe */
921 if (INTEL_INFO(overlay->dev)->gen < 4 &&
922 (I915_READ(PIPECONF(crtc->pipe)) & (PIPECONF_DOUBLE_WIDE | PIPECONF_ENABLE)) != PIPECONF_ENABLE)
928 static void update_pfit_vscale_ratio(struct intel_overlay *overlay)
930 struct drm_device *dev = overlay->dev;
931 drm_i915_private_t *dev_priv = dev->dev_private;
932 u32 pfit_control = I915_READ(PFIT_CONTROL);
935 /* XXX: This is not the same logic as in the xorg driver, but more in
936 * line with the intel documentation for the i965
938 if (INTEL_INFO(dev)->gen >= 4) {
939 /* on i965 use the PGM reg to read out the autoscaler values */
940 ratio = I915_READ(PFIT_PGM_RATIOS) >> PFIT_VERT_SCALE_SHIFT_965;
942 if (pfit_control & VERT_AUTO_SCALE)
943 ratio = I915_READ(PFIT_AUTO_RATIOS);
945 ratio = I915_READ(PFIT_PGM_RATIOS);
946 ratio >>= PFIT_VERT_SCALE_SHIFT;
949 overlay->pfit_vscale_ratio = ratio;
952 static int check_overlay_dst(struct intel_overlay *overlay,
953 struct drm_intel_overlay_put_image *rec)
955 struct drm_display_mode *mode = &overlay->crtc->base.mode;
957 if (rec->dst_x < mode->hdisplay &&
958 rec->dst_x + rec->dst_width <= mode->hdisplay &&
959 rec->dst_y < mode->vdisplay &&
960 rec->dst_y + rec->dst_height <= mode->vdisplay)
966 static int check_overlay_scaling(struct put_image_params *rec)
970 /* downscaling limit is 8.0 */
971 tmp = ((rec->src_scan_h << 16) / rec->dst_h) >> 16;
974 tmp = ((rec->src_scan_w << 16) / rec->dst_w) >> 16;
981 static int check_overlay_src(struct drm_device *dev,
982 struct drm_intel_overlay_put_image *rec,
983 struct drm_i915_gem_object *new_bo)
985 int uv_hscale = uv_hsubsampling(rec->flags);
986 int uv_vscale = uv_vsubsampling(rec->flags);
991 /* check src dimensions */
992 if (IS_845G(dev) || IS_I830(dev)) {
993 if (rec->src_height > IMAGE_MAX_HEIGHT_LEGACY ||
994 rec->src_width > IMAGE_MAX_WIDTH_LEGACY)
997 if (rec->src_height > IMAGE_MAX_HEIGHT ||
998 rec->src_width > IMAGE_MAX_WIDTH)
1002 /* better safe than sorry, use 4 as the maximal subsampling ratio */
1003 if (rec->src_height < N_VERT_Y_TAPS*4 ||
1004 rec->src_width < N_HORIZ_Y_TAPS*4)
1007 /* check alignment constraints */
1008 switch (rec->flags & I915_OVERLAY_TYPE_MASK) {
1009 case I915_OVERLAY_RGB:
1010 /* not implemented */
1013 case I915_OVERLAY_YUV_PACKED:
1017 depth = packed_depth_bytes(rec->flags);
1021 /* ignore UV planes */
1025 /* check pixel alignment */
1026 if (rec->offset_Y % depth)
1030 case I915_OVERLAY_YUV_PLANAR:
1031 if (uv_vscale < 0 || uv_hscale < 0)
1033 /* no offset restrictions for planar formats */
1040 if (rec->src_width % uv_hscale)
1043 /* stride checking */
1044 if (IS_I830(dev) || IS_845G(dev))
1049 if (rec->stride_Y & stride_mask || rec->stride_UV & stride_mask)
1051 if (IS_GEN4(dev) && rec->stride_Y < 512)
1054 tmp = (rec->flags & I915_OVERLAY_TYPE_MASK) == I915_OVERLAY_YUV_PLANAR ?
1056 if (rec->stride_Y > tmp || rec->stride_UV > 2*1024)
1059 /* check buffer dimensions */
1060 switch (rec->flags & I915_OVERLAY_TYPE_MASK) {
1061 case I915_OVERLAY_RGB:
1062 case I915_OVERLAY_YUV_PACKED:
1063 /* always 4 Y values per depth pixels */
1064 if (packed_width_bytes(rec->flags, rec->src_width) > rec->stride_Y)
1067 tmp = rec->stride_Y*rec->src_height;
1068 if (rec->offset_Y + tmp > new_bo->base.size)
1072 case I915_OVERLAY_YUV_PLANAR:
1073 if (rec->src_width > rec->stride_Y)
1075 if (rec->src_width/uv_hscale > rec->stride_UV)
1078 tmp = rec->stride_Y * rec->src_height;
1079 if (rec->offset_Y + tmp > new_bo->base.size)
1082 tmp = rec->stride_UV * (rec->src_height / uv_vscale);
1083 if (rec->offset_U + tmp > new_bo->base.size ||
1084 rec->offset_V + tmp > new_bo->base.size)
1093 * Return the pipe currently connected to the panel fitter,
1094 * or -1 if the panel fitter is not present or not in use
1096 static int intel_panel_fitter_pipe(struct drm_device *dev)
1098 struct drm_i915_private *dev_priv = dev->dev_private;
1101 /* i830 doesn't have a panel fitter */
1105 pfit_control = I915_READ(PFIT_CONTROL);
1107 /* See if the panel fitter is in use */
1108 if ((pfit_control & PFIT_ENABLE) == 0)
1111 /* 965 can place panel fitter on either pipe */
1113 return (pfit_control >> 29) & 0x3;
1115 /* older chips can only use pipe 1 */
1119 int intel_overlay_put_image(struct drm_device *dev, void *data,
1120 struct drm_file *file_priv)
1122 struct drm_intel_overlay_put_image *put_image_rec = data;
1123 drm_i915_private_t *dev_priv = dev->dev_private;
1124 struct intel_overlay *overlay;
1125 struct drm_mode_object *drmmode_obj;
1126 struct intel_crtc *crtc;
1127 struct drm_i915_gem_object *new_bo;
1128 struct put_image_params *params;
1131 /* No need to check for DRIVER_MODESET - we don't set it up then. */
1132 overlay = dev_priv->overlay;
1134 DRM_DEBUG("userspace bug: no overlay\n");
1138 if (!(put_image_rec->flags & I915_OVERLAY_ENABLE)) {
1139 mutex_lock(&dev->mode_config.mutex);
1140 mutex_lock(&dev->struct_mutex);
1142 ret = intel_overlay_switch_off(overlay);
1144 mutex_unlock(&dev->struct_mutex);
1145 mutex_unlock(&dev->mode_config.mutex);
1150 params = kmalloc(sizeof(struct put_image_params), GFP_KERNEL);
1154 drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id,
1155 DRM_MODE_OBJECT_CRTC);
1160 crtc = to_intel_crtc(obj_to_crtc(drmmode_obj));
1162 new_bo = to_intel_bo(drm_gem_object_lookup(dev, file_priv,
1163 put_image_rec->bo_handle));
1164 if (&new_bo->base == NULL) {
1169 mutex_lock(&dev->mode_config.mutex);
1170 mutex_lock(&dev->struct_mutex);
1172 if (new_bo->tiling_mode) {
1173 DRM_ERROR("buffer used for overlay image can not be tiled\n");
1178 ret = intel_overlay_recover_from_interrupt(overlay);
1182 if (overlay->crtc != crtc) {
1183 struct drm_display_mode *mode = &crtc->base.mode;
1184 ret = intel_overlay_switch_off(overlay);
1188 ret = check_overlay_possible_on_crtc(overlay, crtc);
1192 overlay->crtc = crtc;
1193 crtc->overlay = overlay;
1195 /* line too wide, i.e. one-line-mode */
1196 if (mode->hdisplay > 1024 &&
1197 intel_panel_fitter_pipe(dev) == crtc->pipe) {
1198 overlay->pfit_active = 1;
1199 update_pfit_vscale_ratio(overlay);
1201 overlay->pfit_active = 0;
1204 ret = check_overlay_dst(overlay, put_image_rec);
1208 if (overlay->pfit_active) {
1209 params->dst_y = ((((u32)put_image_rec->dst_y) << 12) /
1210 overlay->pfit_vscale_ratio);
1211 /* shifting right rounds downwards, so add 1 */
1212 params->dst_h = ((((u32)put_image_rec->dst_height) << 12) /
1213 overlay->pfit_vscale_ratio) + 1;
1215 params->dst_y = put_image_rec->dst_y;
1216 params->dst_h = put_image_rec->dst_height;
1218 params->dst_x = put_image_rec->dst_x;
1219 params->dst_w = put_image_rec->dst_width;
1221 params->src_w = put_image_rec->src_width;
1222 params->src_h = put_image_rec->src_height;
1223 params->src_scan_w = put_image_rec->src_scan_width;
1224 params->src_scan_h = put_image_rec->src_scan_height;
1225 if (params->src_scan_h > params->src_h ||
1226 params->src_scan_w > params->src_w) {
1231 ret = check_overlay_src(dev, put_image_rec, new_bo);
1234 params->format = put_image_rec->flags & ~I915_OVERLAY_FLAGS_MASK;
1235 params->stride_Y = put_image_rec->stride_Y;
1236 params->stride_UV = put_image_rec->stride_UV;
1237 params->offset_Y = put_image_rec->offset_Y;
1238 params->offset_U = put_image_rec->offset_U;
1239 params->offset_V = put_image_rec->offset_V;
1241 /* Check scaling after src size to prevent a divide-by-zero. */
1242 ret = check_overlay_scaling(params);
1246 ret = intel_overlay_do_put_image(overlay, new_bo, params);
1250 mutex_unlock(&dev->struct_mutex);
1251 mutex_unlock(&dev->mode_config.mutex);
1258 mutex_unlock(&dev->struct_mutex);
1259 mutex_unlock(&dev->mode_config.mutex);
1260 drm_gem_object_unreference_unlocked(&new_bo->base);
1267 static void update_reg_attrs(struct intel_overlay *overlay,
1268 struct overlay_registers __iomem *regs)
1270 iowrite32((overlay->contrast << 18) | (overlay->brightness & 0xff),
1272 iowrite32(overlay->saturation, ®s->OCLRC1);
1275 static bool check_gamma_bounds(u32 gamma1, u32 gamma2)
1279 if (gamma1 & 0xff000000 || gamma2 & 0xff000000)
1282 for (i = 0; i < 3; i++) {
1283 if (((gamma1 >> i*8) & 0xff) >= ((gamma2 >> i*8) & 0xff))
1290 static bool check_gamma5_errata(u32 gamma5)
1294 for (i = 0; i < 3; i++) {
1295 if (((gamma5 >> i*8) & 0xff) == 0x80)
1302 static int check_gamma(struct drm_intel_overlay_attrs *attrs)
1304 if (!check_gamma_bounds(0, attrs->gamma0) ||
1305 !check_gamma_bounds(attrs->gamma0, attrs->gamma1) ||
1306 !check_gamma_bounds(attrs->gamma1, attrs->gamma2) ||
1307 !check_gamma_bounds(attrs->gamma2, attrs->gamma3) ||
1308 !check_gamma_bounds(attrs->gamma3, attrs->gamma4) ||
1309 !check_gamma_bounds(attrs->gamma4, attrs->gamma5) ||
1310 !check_gamma_bounds(attrs->gamma5, 0x00ffffff))
1313 if (!check_gamma5_errata(attrs->gamma5))
1319 int intel_overlay_attrs(struct drm_device *dev, void *data,
1320 struct drm_file *file_priv)
1322 struct drm_intel_overlay_attrs *attrs = data;
1323 drm_i915_private_t *dev_priv = dev->dev_private;
1324 struct intel_overlay *overlay;
1325 struct overlay_registers __iomem *regs;
1328 /* No need to check for DRIVER_MODESET - we don't set it up then. */
1329 overlay = dev_priv->overlay;
1331 DRM_DEBUG("userspace bug: no overlay\n");
1335 mutex_lock(&dev->mode_config.mutex);
1336 mutex_lock(&dev->struct_mutex);
1339 if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) {
1340 attrs->color_key = overlay->color_key;
1341 attrs->brightness = overlay->brightness;
1342 attrs->contrast = overlay->contrast;
1343 attrs->saturation = overlay->saturation;
1345 if (!IS_GEN2(dev)) {
1346 attrs->gamma0 = I915_READ(OGAMC0);
1347 attrs->gamma1 = I915_READ(OGAMC1);
1348 attrs->gamma2 = I915_READ(OGAMC2);
1349 attrs->gamma3 = I915_READ(OGAMC3);
1350 attrs->gamma4 = I915_READ(OGAMC4);
1351 attrs->gamma5 = I915_READ(OGAMC5);
1354 if (attrs->brightness < -128 || attrs->brightness > 127)
1356 if (attrs->contrast > 255)
1358 if (attrs->saturation > 1023)
1361 overlay->color_key = attrs->color_key;
1362 overlay->brightness = attrs->brightness;
1363 overlay->contrast = attrs->contrast;
1364 overlay->saturation = attrs->saturation;
1366 regs = intel_overlay_map_regs(overlay);
1372 update_reg_attrs(overlay, regs);
1374 intel_overlay_unmap_regs(overlay, regs);
1376 if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) {
1380 if (overlay->active) {
1385 ret = check_gamma(attrs);
1389 I915_WRITE(OGAMC0, attrs->gamma0);
1390 I915_WRITE(OGAMC1, attrs->gamma1);
1391 I915_WRITE(OGAMC2, attrs->gamma2);
1392 I915_WRITE(OGAMC3, attrs->gamma3);
1393 I915_WRITE(OGAMC4, attrs->gamma4);
1394 I915_WRITE(OGAMC5, attrs->gamma5);
1400 mutex_unlock(&dev->struct_mutex);
1401 mutex_unlock(&dev->mode_config.mutex);
1406 void intel_setup_overlay(struct drm_device *dev)
1408 drm_i915_private_t *dev_priv = dev->dev_private;
1409 struct intel_overlay *overlay;
1410 struct drm_i915_gem_object *reg_bo;
1411 struct overlay_registers __iomem *regs;
1414 if (!HAS_OVERLAY(dev))
1417 overlay = kzalloc(sizeof(struct intel_overlay), GFP_KERNEL);
1421 mutex_lock(&dev->struct_mutex);
1422 if (WARN_ON(dev_priv->overlay))
1427 reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE);
1430 overlay->reg_bo = reg_bo;
1432 if (OVERLAY_NEEDS_PHYSICAL(dev)) {
1433 ret = i915_gem_attach_phys_object(dev, reg_bo,
1434 I915_GEM_PHYS_OVERLAY_REGS,
1437 DRM_ERROR("failed to attach phys overlay regs\n");
1440 overlay->flip_addr = reg_bo->phys_obj->handle->busaddr;
1442 ret = i915_gem_object_pin(reg_bo, PAGE_SIZE, true);
1444 DRM_ERROR("failed to pin overlay register bo\n");
1447 overlay->flip_addr = reg_bo->gtt_offset;
1449 ret = i915_gem_object_set_to_gtt_domain(reg_bo, true);
1451 DRM_ERROR("failed to move overlay register bo into the GTT\n");
1456 /* init all values */
1457 overlay->color_key = 0x0101fe;
1458 overlay->brightness = -19;
1459 overlay->contrast = 75;
1460 overlay->saturation = 146;
1462 regs = intel_overlay_map_regs(overlay);
1466 memset_io(regs, 0, sizeof(struct overlay_registers));
1467 update_polyphase_filter(regs);
1468 update_reg_attrs(overlay, regs);
1470 intel_overlay_unmap_regs(overlay, regs);
1472 dev_priv->overlay = overlay;
1473 mutex_unlock(&dev->struct_mutex);
1474 DRM_INFO("initialized overlay support\n");
1478 if (!OVERLAY_NEEDS_PHYSICAL(dev))
1479 i915_gem_object_unpin(reg_bo);
1481 drm_gem_object_unreference(®_bo->base);
1483 mutex_unlock(&dev->struct_mutex);
1488 void intel_cleanup_overlay(struct drm_device *dev)
1490 drm_i915_private_t *dev_priv = dev->dev_private;
1492 if (!dev_priv->overlay)
1495 /* The bo's should be free'd by the generic code already.
1496 * Furthermore modesetting teardown happens beforehand so the
1497 * hardware should be off already */
1498 BUG_ON(dev_priv->overlay->active);
1500 drm_gem_object_unreference_unlocked(&dev_priv->overlay->reg_bo->base);
1501 kfree(dev_priv->overlay);
1504 #ifdef CONFIG_DEBUG_FS
1505 #include <linux/seq_file.h>
1507 struct intel_overlay_error_state {
1508 struct overlay_registers regs;
1514 static struct overlay_registers __iomem *
1515 intel_overlay_map_regs_atomic(struct intel_overlay *overlay)
1517 drm_i915_private_t *dev_priv = overlay->dev->dev_private;
1518 struct overlay_registers __iomem *regs;
1520 if (OVERLAY_NEEDS_PHYSICAL(overlay->dev))
1521 /* Cast to make sparse happy, but it's wc memory anyway, so
1522 * equivalent to the wc io mapping on X86. */
1523 regs = (struct overlay_registers __iomem *)
1524 overlay->reg_bo->phys_obj->handle->vaddr;
1526 regs = io_mapping_map_atomic_wc(dev_priv->mm.gtt_mapping,
1527 overlay->reg_bo->gtt_offset);
1532 static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay,
1533 struct overlay_registers __iomem *regs)
1535 if (!OVERLAY_NEEDS_PHYSICAL(overlay->dev))
1536 io_mapping_unmap_atomic(regs);
1540 struct intel_overlay_error_state *
1541 intel_overlay_capture_error_state(struct drm_device *dev)
1543 drm_i915_private_t *dev_priv = dev->dev_private;
1544 struct intel_overlay *overlay = dev_priv->overlay;
1545 struct intel_overlay_error_state *error;
1546 struct overlay_registers __iomem *regs;
1548 if (!overlay || !overlay->active)
1551 error = kmalloc(sizeof(*error), GFP_ATOMIC);
1555 error->dovsta = I915_READ(DOVSTA);
1556 error->isr = I915_READ(ISR);
1557 if (OVERLAY_NEEDS_PHYSICAL(overlay->dev))
1558 error->base = (__force long)overlay->reg_bo->phys_obj->handle->vaddr;
1560 error->base = overlay->reg_bo->gtt_offset;
1562 regs = intel_overlay_map_regs_atomic(overlay);
1566 memcpy_fromio(&error->regs, regs, sizeof(struct overlay_registers));
1567 intel_overlay_unmap_regs_atomic(overlay, regs);
1577 intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error)
1579 seq_printf(m, "Overlay, status: 0x%08x, interrupt: 0x%08x\n",
1580 error->dovsta, error->isr);
1581 seq_printf(m, " Register file at 0x%08lx:\n",
1584 #define P(x) seq_printf(m, " " #x ": 0x%08x\n", error->regs.x)