2 * Copyright © 2014 Intel Corporation
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * DOC: Frame Buffer Compression (FBC)
27 * FBC tries to save memory bandwidth (and so power consumption) by
28 * compressing the amount of memory used by the display. It is total
29 * transparent to user space and completely handled in the kernel.
31 * The benefits of FBC are mostly visible with solid backgrounds and
32 * variation-less patterns. It comes from keeping the memory footprint small
33 * and having fewer memory pages opened and accessed for refreshing the display.
35 * i915 is responsible to reserve stolen memory for FBC and configure its
36 * offset on proper registers. The hardware takes care of all
37 * compress/decompress. However there are many known cases where we have to
38 * forcibly disable it to allow proper screen updates.
41 #include "intel_drv.h"
44 static void i8xx_fbc_disable(struct drm_device
*dev
)
46 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
49 dev_priv
->fbc
.enabled
= false;
51 /* Disable compression */
52 fbc_ctl
= I915_READ(FBC_CONTROL
);
53 if ((fbc_ctl
& FBC_CTL_EN
) == 0)
56 fbc_ctl
&= ~FBC_CTL_EN
;
57 I915_WRITE(FBC_CONTROL
, fbc_ctl
);
59 /* Wait for compressing bit to clear */
60 if (wait_for((I915_READ(FBC_STATUS
) & FBC_STAT_COMPRESSING
) == 0, 10)) {
61 DRM_DEBUG_KMS("FBC idle timed out\n");
65 DRM_DEBUG_KMS("disabled FBC\n");
68 static void i8xx_fbc_enable(struct drm_crtc
*crtc
)
70 struct drm_device
*dev
= crtc
->dev
;
71 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
72 struct drm_framebuffer
*fb
= crtc
->primary
->fb
;
73 struct drm_i915_gem_object
*obj
= intel_fb_obj(fb
);
74 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
79 dev_priv
->fbc
.enabled
= true;
81 /* Note: fbc.threshold == 1 for i8xx */
82 cfb_pitch
= dev_priv
->fbc
.uncompressed_size
/ FBC_LL_SIZE
;
83 if (fb
->pitches
[0] < cfb_pitch
)
84 cfb_pitch
= fb
->pitches
[0];
86 /* FBC_CTL wants 32B or 64B units */
88 cfb_pitch
= (cfb_pitch
/ 32) - 1;
90 cfb_pitch
= (cfb_pitch
/ 64) - 1;
93 for (i
= 0; i
< (FBC_LL_SIZE
/ 32) + 1; i
++)
94 I915_WRITE(FBC_TAG
+ (i
* 4), 0);
100 fbc_ctl2
= FBC_CTL_FENCE_DBL
| FBC_CTL_IDLE_IMM
| FBC_CTL_CPU_FENCE
;
101 fbc_ctl2
|= FBC_CTL_PLANE(intel_crtc
->plane
);
102 I915_WRITE(FBC_CONTROL2
, fbc_ctl2
);
103 I915_WRITE(FBC_FENCE_OFF
, crtc
->y
);
107 fbc_ctl
= I915_READ(FBC_CONTROL
);
108 fbc_ctl
&= 0x3fff << FBC_CTL_INTERVAL_SHIFT
;
109 fbc_ctl
|= FBC_CTL_EN
| FBC_CTL_PERIODIC
;
111 fbc_ctl
|= FBC_CTL_C3_IDLE
; /* 945 needs special SR handling */
112 fbc_ctl
|= (cfb_pitch
& 0xff) << FBC_CTL_STRIDE_SHIFT
;
113 fbc_ctl
|= obj
->fence_reg
;
114 I915_WRITE(FBC_CONTROL
, fbc_ctl
);
116 DRM_DEBUG_KMS("enabled FBC, pitch %d, yoff %d, plane %c\n",
117 cfb_pitch
, crtc
->y
, plane_name(intel_crtc
->plane
));
120 static bool i8xx_fbc_enabled(struct drm_device
*dev
)
122 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
124 return I915_READ(FBC_CONTROL
) & FBC_CTL_EN
;
127 static void g4x_fbc_enable(struct drm_crtc
*crtc
)
129 struct drm_device
*dev
= crtc
->dev
;
130 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
131 struct drm_framebuffer
*fb
= crtc
->primary
->fb
;
132 struct drm_i915_gem_object
*obj
= intel_fb_obj(fb
);
133 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
136 dev_priv
->fbc
.enabled
= true;
138 dpfc_ctl
= DPFC_CTL_PLANE(intel_crtc
->plane
) | DPFC_SR_EN
;
139 if (drm_format_plane_cpp(fb
->pixel_format
, 0) == 2)
140 dpfc_ctl
|= DPFC_CTL_LIMIT_2X
;
142 dpfc_ctl
|= DPFC_CTL_LIMIT_1X
;
143 dpfc_ctl
|= DPFC_CTL_FENCE_EN
| obj
->fence_reg
;
145 I915_WRITE(DPFC_FENCE_YOFF
, crtc
->y
);
148 I915_WRITE(DPFC_CONTROL
, dpfc_ctl
| DPFC_CTL_EN
);
150 DRM_DEBUG_KMS("enabled fbc on plane %c\n", plane_name(intel_crtc
->plane
));
153 static void g4x_fbc_disable(struct drm_device
*dev
)
155 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
158 dev_priv
->fbc
.enabled
= false;
160 /* Disable compression */
161 dpfc_ctl
= I915_READ(DPFC_CONTROL
);
162 if (dpfc_ctl
& DPFC_CTL_EN
) {
163 dpfc_ctl
&= ~DPFC_CTL_EN
;
164 I915_WRITE(DPFC_CONTROL
, dpfc_ctl
);
166 DRM_DEBUG_KMS("disabled FBC\n");
170 static bool g4x_fbc_enabled(struct drm_device
*dev
)
172 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
174 return I915_READ(DPFC_CONTROL
) & DPFC_CTL_EN
;
177 static void snb_fbc_blit_update(struct drm_device
*dev
)
179 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
182 /* Make sure blitter notifies FBC of writes */
184 /* Blitter is part of Media powerwell on VLV. No impact of
185 * his param in other platforms for now */
186 intel_uncore_forcewake_get(dev_priv
, FORCEWAKE_MEDIA
);
188 blt_ecoskpd
= I915_READ(GEN6_BLITTER_ECOSKPD
);
189 blt_ecoskpd
|= GEN6_BLITTER_FBC_NOTIFY
<<
190 GEN6_BLITTER_LOCK_SHIFT
;
191 I915_WRITE(GEN6_BLITTER_ECOSKPD
, blt_ecoskpd
);
192 blt_ecoskpd
|= GEN6_BLITTER_FBC_NOTIFY
;
193 I915_WRITE(GEN6_BLITTER_ECOSKPD
, blt_ecoskpd
);
194 blt_ecoskpd
&= ~(GEN6_BLITTER_FBC_NOTIFY
<<
195 GEN6_BLITTER_LOCK_SHIFT
);
196 I915_WRITE(GEN6_BLITTER_ECOSKPD
, blt_ecoskpd
);
197 POSTING_READ(GEN6_BLITTER_ECOSKPD
);
199 intel_uncore_forcewake_put(dev_priv
, FORCEWAKE_MEDIA
);
202 static void ilk_fbc_enable(struct drm_crtc
*crtc
)
204 struct drm_device
*dev
= crtc
->dev
;
205 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
206 struct drm_framebuffer
*fb
= crtc
->primary
->fb
;
207 struct drm_i915_gem_object
*obj
= intel_fb_obj(fb
);
208 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
211 dev_priv
->fbc
.enabled
= true;
213 dpfc_ctl
= DPFC_CTL_PLANE(intel_crtc
->plane
);
214 if (drm_format_plane_cpp(fb
->pixel_format
, 0) == 2)
215 dev_priv
->fbc
.threshold
++;
217 switch (dev_priv
->fbc
.threshold
) {
220 dpfc_ctl
|= DPFC_CTL_LIMIT_4X
;
223 dpfc_ctl
|= DPFC_CTL_LIMIT_2X
;
226 dpfc_ctl
|= DPFC_CTL_LIMIT_1X
;
229 dpfc_ctl
|= DPFC_CTL_FENCE_EN
;
231 dpfc_ctl
|= obj
->fence_reg
;
233 I915_WRITE(ILK_DPFC_FENCE_YOFF
, crtc
->y
);
234 I915_WRITE(ILK_FBC_RT_BASE
, i915_gem_obj_ggtt_offset(obj
) | ILK_FBC_RT_VALID
);
236 I915_WRITE(ILK_DPFC_CONTROL
, dpfc_ctl
| DPFC_CTL_EN
);
239 I915_WRITE(SNB_DPFC_CTL_SA
,
240 SNB_CPU_FENCE_ENABLE
| obj
->fence_reg
);
241 I915_WRITE(DPFC_CPU_FENCE_OFFSET
, crtc
->y
);
242 snb_fbc_blit_update(dev
);
245 DRM_DEBUG_KMS("enabled fbc on plane %c\n", plane_name(intel_crtc
->plane
));
248 static void ilk_fbc_disable(struct drm_device
*dev
)
250 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
253 dev_priv
->fbc
.enabled
= false;
255 /* Disable compression */
256 dpfc_ctl
= I915_READ(ILK_DPFC_CONTROL
);
257 if (dpfc_ctl
& DPFC_CTL_EN
) {
258 dpfc_ctl
&= ~DPFC_CTL_EN
;
259 I915_WRITE(ILK_DPFC_CONTROL
, dpfc_ctl
);
261 DRM_DEBUG_KMS("disabled FBC\n");
265 static bool ilk_fbc_enabled(struct drm_device
*dev
)
267 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
269 return I915_READ(ILK_DPFC_CONTROL
) & DPFC_CTL_EN
;
272 static void gen7_fbc_enable(struct drm_crtc
*crtc
)
274 struct drm_device
*dev
= crtc
->dev
;
275 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
276 struct drm_framebuffer
*fb
= crtc
->primary
->fb
;
277 struct drm_i915_gem_object
*obj
= intel_fb_obj(fb
);
278 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
281 dev_priv
->fbc
.enabled
= true;
283 dpfc_ctl
= IVB_DPFC_CTL_PLANE(intel_crtc
->plane
);
284 if (drm_format_plane_cpp(fb
->pixel_format
, 0) == 2)
285 dev_priv
->fbc
.threshold
++;
287 switch (dev_priv
->fbc
.threshold
) {
290 dpfc_ctl
|= DPFC_CTL_LIMIT_4X
;
293 dpfc_ctl
|= DPFC_CTL_LIMIT_2X
;
296 dpfc_ctl
|= DPFC_CTL_LIMIT_1X
;
300 dpfc_ctl
|= IVB_DPFC_CTL_FENCE_EN
;
302 if (dev_priv
->fbc
.false_color
)
303 dpfc_ctl
|= FBC_CTL_FALSE_COLOR
;
305 I915_WRITE(ILK_DPFC_CONTROL
, dpfc_ctl
| DPFC_CTL_EN
);
307 if (IS_IVYBRIDGE(dev
)) {
308 /* WaFbcAsynchFlipDisableFbcQueue:ivb */
309 I915_WRITE(ILK_DISPLAY_CHICKEN1
,
310 I915_READ(ILK_DISPLAY_CHICKEN1
) |
313 /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
314 I915_WRITE(CHICKEN_PIPESL_1(intel_crtc
->pipe
),
315 I915_READ(CHICKEN_PIPESL_1(intel_crtc
->pipe
)) |
319 I915_WRITE(SNB_DPFC_CTL_SA
,
320 SNB_CPU_FENCE_ENABLE
| obj
->fence_reg
);
321 I915_WRITE(DPFC_CPU_FENCE_OFFSET
, crtc
->y
);
323 snb_fbc_blit_update(dev
);
325 DRM_DEBUG_KMS("enabled fbc on plane %c\n", plane_name(intel_crtc
->plane
));
329 * intel_fbc_enabled - Is FBC enabled?
330 * @dev: the drm_device
332 * This function is used to verify the current state of FBC.
333 * FIXME: This should be tracked in the plane config eventually
334 * instead of queried at runtime for most callers.
336 bool intel_fbc_enabled(struct drm_device
*dev
)
338 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
340 return dev_priv
->fbc
.enabled
;
343 void bdw_fbc_sw_flush(struct drm_device
*dev
, u32 value
)
345 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
350 if (!intel_fbc_enabled(dev
))
353 I915_WRITE(MSG_FBC_REND_STATE
, value
);
356 static void intel_fbc_work_fn(struct work_struct
*__work
)
358 struct intel_fbc_work
*work
=
359 container_of(to_delayed_work(__work
),
360 struct intel_fbc_work
, work
);
361 struct drm_device
*dev
= work
->crtc
->dev
;
362 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
364 mutex_lock(&dev
->struct_mutex
);
365 if (work
== dev_priv
->fbc
.fbc_work
) {
366 /* Double check that we haven't switched fb without cancelling
369 if (work
->crtc
->primary
->fb
== work
->fb
) {
370 dev_priv
->display
.enable_fbc(work
->crtc
);
372 dev_priv
->fbc
.crtc
= to_intel_crtc(work
->crtc
);
373 dev_priv
->fbc
.fb_id
= work
->crtc
->primary
->fb
->base
.id
;
374 dev_priv
->fbc
.y
= work
->crtc
->y
;
377 dev_priv
->fbc
.fbc_work
= NULL
;
379 mutex_unlock(&dev
->struct_mutex
);
384 static void intel_fbc_cancel_work(struct drm_i915_private
*dev_priv
)
386 if (dev_priv
->fbc
.fbc_work
== NULL
)
389 DRM_DEBUG_KMS("cancelling pending FBC enable\n");
391 /* Synchronisation is provided by struct_mutex and checking of
392 * dev_priv->fbc.fbc_work, so we can perform the cancellation
393 * entirely asynchronously.
395 if (cancel_delayed_work(&dev_priv
->fbc
.fbc_work
->work
))
396 /* tasklet was killed before being run, clean up */
397 kfree(dev_priv
->fbc
.fbc_work
);
399 /* Mark the work as no longer wanted so that if it does
400 * wake-up (because the work was already running and waiting
401 * for our mutex), it will discover that is no longer
404 dev_priv
->fbc
.fbc_work
= NULL
;
407 static void intel_fbc_enable(struct drm_crtc
*crtc
)
409 struct intel_fbc_work
*work
;
410 struct drm_device
*dev
= crtc
->dev
;
411 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
413 if (!dev_priv
->display
.enable_fbc
)
416 intel_fbc_cancel_work(dev_priv
);
418 work
= kzalloc(sizeof(*work
), GFP_KERNEL
);
420 DRM_ERROR("Failed to allocate FBC work structure\n");
421 dev_priv
->display
.enable_fbc(crtc
);
426 work
->fb
= crtc
->primary
->fb
;
427 INIT_DELAYED_WORK(&work
->work
, intel_fbc_work_fn
);
429 dev_priv
->fbc
.fbc_work
= work
;
431 /* Delay the actual enabling to let pageflipping cease and the
432 * display to settle before starting the compression. Note that
433 * this delay also serves a second purpose: it allows for a
434 * vblank to pass after disabling the FBC before we attempt
435 * to modify the control registers.
437 * A more complicated solution would involve tracking vblanks
438 * following the termination of the page-flipping sequence
439 * and indeed performing the enable as a co-routine and not
440 * waiting synchronously upon the vblank.
442 * WaFbcWaitForVBlankBeforeEnable:ilk,snb
444 schedule_delayed_work(&work
->work
, msecs_to_jiffies(50));
448 * intel_fbc_disable - disable FBC
449 * @dev: the drm_device
451 * This function disables FBC.
453 void intel_fbc_disable(struct drm_device
*dev
)
455 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
457 intel_fbc_cancel_work(dev_priv
);
459 if (!dev_priv
->display
.disable_fbc
)
462 dev_priv
->display
.disable_fbc(dev
);
463 dev_priv
->fbc
.crtc
= NULL
;
466 static bool set_no_fbc_reason(struct drm_i915_private
*dev_priv
,
467 enum no_fbc_reason reason
)
469 if (dev_priv
->fbc
.no_fbc_reason
== reason
)
472 dev_priv
->fbc
.no_fbc_reason
= reason
;
476 static struct drm_crtc
*intel_fbc_find_crtc(struct drm_i915_private
*dev_priv
)
478 struct drm_crtc
*crtc
= NULL
, *tmp_crtc
;
480 bool pipe_a_only
= false, one_pipe_only
= false;
482 if (IS_HASWELL(dev_priv
) || INTEL_INFO(dev_priv
)->gen
>= 8)
484 else if (INTEL_INFO(dev_priv
)->gen
<= 4)
485 one_pipe_only
= true;
487 for_each_pipe(dev_priv
, pipe
) {
488 tmp_crtc
= dev_priv
->pipe_to_crtc_mapping
[pipe
];
490 if (intel_crtc_active(tmp_crtc
) &&
491 to_intel_crtc(tmp_crtc
)->primary_enabled
) {
492 if (one_pipe_only
&& crtc
) {
493 if (set_no_fbc_reason(dev_priv
, FBC_MULTIPLE_PIPES
))
494 DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");
504 if (!crtc
|| crtc
->primary
->fb
== NULL
) {
505 if (set_no_fbc_reason(dev_priv
, FBC_NO_OUTPUT
))
506 DRM_DEBUG_KMS("no output, disabling\n");
514 * intel_fbc_update - enable/disable FBC as needed
515 * @dev: the drm_device
517 * Set up the framebuffer compression hardware at mode set time. We
518 * enable it if possible:
519 * - plane A only (on pre-965)
520 * - no pixel mulitply/line duplication
521 * - no alpha buffer discard
523 * - framebuffer <= max_hdisplay in width, max_vdisplay in height
525 * We can't assume that any compression will take place (worst case),
526 * so the compressed buffer has to be the same size as the uncompressed
527 * one. It also must reside (along with the line length buffer) in
530 * We need to enable/disable FBC on a global basis.
532 void intel_fbc_update(struct drm_device
*dev
)
534 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
535 struct drm_crtc
*crtc
= NULL
;
536 struct intel_crtc
*intel_crtc
;
537 struct drm_framebuffer
*fb
;
538 struct drm_i915_gem_object
*obj
;
539 const struct drm_display_mode
*adjusted_mode
;
540 unsigned int max_width
, max_height
;
545 /* disable framebuffer compression in vGPU */
546 if (intel_vgpu_active(dev
))
549 if (i915
.enable_fbc
< 0) {
550 if (set_no_fbc_reason(dev_priv
, FBC_CHIP_DEFAULT
))
551 DRM_DEBUG_KMS("disabled per chip default\n");
555 if (!i915
.enable_fbc
|| !i915
.powersave
) {
556 if (set_no_fbc_reason(dev_priv
, FBC_MODULE_PARAM
))
557 DRM_DEBUG_KMS("fbc disabled per module param\n");
562 * If FBC is already on, we just have to verify that we can
563 * keep it that way...
564 * Need to disable if:
565 * - more than one pipe is active
566 * - changing FBC params (stride, fence, mode)
567 * - new fb is too large to fit in compressed buffer
568 * - going to an unsupported config (interlace, pixel multiply, etc.)
570 crtc
= intel_fbc_find_crtc(dev_priv
);
574 intel_crtc
= to_intel_crtc(crtc
);
575 fb
= crtc
->primary
->fb
;
576 obj
= intel_fb_obj(fb
);
577 adjusted_mode
= &intel_crtc
->config
->base
.adjusted_mode
;
579 if ((adjusted_mode
->flags
& DRM_MODE_FLAG_INTERLACE
) ||
580 (adjusted_mode
->flags
& DRM_MODE_FLAG_DBLSCAN
)) {
581 if (set_no_fbc_reason(dev_priv
, FBC_UNSUPPORTED_MODE
))
582 DRM_DEBUG_KMS("mode incompatible with compression, "
587 if (INTEL_INFO(dev
)->gen
>= 8 || IS_HASWELL(dev
)) {
590 } else if (IS_G4X(dev
) || INTEL_INFO(dev
)->gen
>= 5) {
597 if (intel_crtc
->config
->pipe_src_w
> max_width
||
598 intel_crtc
->config
->pipe_src_h
> max_height
) {
599 if (set_no_fbc_reason(dev_priv
, FBC_MODE_TOO_LARGE
))
600 DRM_DEBUG_KMS("mode too large for compression, disabling\n");
603 if ((INTEL_INFO(dev
)->gen
< 4 || HAS_DDI(dev
)) &&
604 intel_crtc
->plane
!= PLANE_A
) {
605 if (set_no_fbc_reason(dev_priv
, FBC_BAD_PLANE
))
606 DRM_DEBUG_KMS("plane not A, disabling compression\n");
610 /* The use of a CPU fence is mandatory in order to detect writes
611 * by the CPU to the scanout and trigger updates to the FBC.
613 if (obj
->tiling_mode
!= I915_TILING_X
||
614 obj
->fence_reg
== I915_FENCE_REG_NONE
) {
615 if (set_no_fbc_reason(dev_priv
, FBC_NOT_TILED
))
616 DRM_DEBUG_KMS("framebuffer not tiled or fenced, disabling compression\n");
619 if (INTEL_INFO(dev
)->gen
<= 4 && !IS_G4X(dev
) &&
620 crtc
->primary
->state
->rotation
!= BIT(DRM_ROTATE_0
)) {
621 if (set_no_fbc_reason(dev_priv
, FBC_UNSUPPORTED_MODE
))
622 DRM_DEBUG_KMS("Rotation unsupported, disabling\n");
626 /* If the kernel debugger is active, always disable compression */
630 if (i915_gem_stolen_setup_compression(dev
, obj
->base
.size
,
631 drm_format_plane_cpp(fb
->pixel_format
, 0))) {
632 if (set_no_fbc_reason(dev_priv
, FBC_STOLEN_TOO_SMALL
))
633 DRM_DEBUG_KMS("framebuffer too large, disabling compression\n");
637 /* If the scanout has not changed, don't modify the FBC settings.
638 * Note that we make the fundamental assumption that the fb->obj
639 * cannot be unpinned (and have its GTT offset and fence revoked)
640 * without first being decoupled from the scanout and FBC disabled.
642 if (dev_priv
->fbc
.crtc
== intel_crtc
&&
643 dev_priv
->fbc
.fb_id
== fb
->base
.id
&&
644 dev_priv
->fbc
.y
== crtc
->y
)
647 if (intel_fbc_enabled(dev
)) {
648 /* We update FBC along two paths, after changing fb/crtc
649 * configuration (modeswitching) and after page-flipping
650 * finishes. For the latter, we know that not only did
651 * we disable the FBC at the start of the page-flip
652 * sequence, but also more than one vblank has passed.
654 * For the former case of modeswitching, it is possible
655 * to switch between two FBC valid configurations
656 * instantaneously so we do need to disable the FBC
657 * before we can modify its control registers. We also
658 * have to wait for the next vblank for that to take
659 * effect. However, since we delay enabling FBC we can
660 * assume that a vblank has passed since disabling and
661 * that we can safely alter the registers in the deferred
664 * In the scenario that we go from a valid to invalid
665 * and then back to valid FBC configuration we have
666 * no strict enforcement that a vblank occurred since
667 * disabling the FBC. However, along all current pipe
668 * disabling paths we do need to wait for a vblank at
669 * some point. And we wait before enabling FBC anyway.
671 DRM_DEBUG_KMS("disabling active FBC for update\n");
672 intel_fbc_disable(dev
);
675 intel_fbc_enable(crtc
);
676 dev_priv
->fbc
.no_fbc_reason
= FBC_OK
;
680 /* Multiple disables should be harmless */
681 if (intel_fbc_enabled(dev
)) {
682 DRM_DEBUG_KMS("unsupported config, disabling FBC\n");
683 intel_fbc_disable(dev
);
685 i915_gem_stolen_cleanup_compression(dev
);
689 * intel_fbc_init - Initialize FBC
690 * @dev_priv: the i915 device
692 * This function might be called during PM init process.
694 void intel_fbc_init(struct drm_i915_private
*dev_priv
)
696 if (!HAS_FBC(dev_priv
)) {
697 dev_priv
->fbc
.enabled
= false;
698 dev_priv
->fbc
.no_fbc_reason
= FBC_UNSUPPORTED
;
702 if (INTEL_INFO(dev_priv
)->gen
>= 7) {
703 dev_priv
->display
.fbc_enabled
= ilk_fbc_enabled
;
704 dev_priv
->display
.enable_fbc
= gen7_fbc_enable
;
705 dev_priv
->display
.disable_fbc
= ilk_fbc_disable
;
706 } else if (INTEL_INFO(dev_priv
)->gen
>= 5) {
707 dev_priv
->display
.fbc_enabled
= ilk_fbc_enabled
;
708 dev_priv
->display
.enable_fbc
= ilk_fbc_enable
;
709 dev_priv
->display
.disable_fbc
= ilk_fbc_disable
;
710 } else if (IS_GM45(dev_priv
)) {
711 dev_priv
->display
.fbc_enabled
= g4x_fbc_enabled
;
712 dev_priv
->display
.enable_fbc
= g4x_fbc_enable
;
713 dev_priv
->display
.disable_fbc
= g4x_fbc_disable
;
715 dev_priv
->display
.fbc_enabled
= i8xx_fbc_enabled
;
716 dev_priv
->display
.enable_fbc
= i8xx_fbc_enable
;
717 dev_priv
->display
.disable_fbc
= i8xx_fbc_disable
;
719 /* This value was pulled out of someone's hat */
720 I915_WRITE(FBC_CONTROL
, 500 << FBC_CTL_INTERVAL_SHIFT
);
723 dev_priv
->fbc
.enabled
= dev_priv
->display
.fbc_enabled(dev_priv
->dev
);
This page took 0.073538 seconds and 5 git commands to generate.