Skip to content

Commit a4c74b2

Browse files
committed
drm/i915/fbc: Parametrize FBC_CONTROL
Parametrize the FBC_CONTROL bits for neater code. Also add the one missing bit: "stop compression on modification". Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: José Roberto de Souza <[email protected]>
1 parent d838962 commit a4c74b2

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

drivers/gpu/drm/i915/display/intel_fbc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ static void i8xx_fbc_activate(struct drm_i915_private *dev_priv)
133133

134134
/* enable it... */
135135
fbc_ctl = intel_de_read(dev_priv, FBC_CONTROL);
136-
fbc_ctl &= 0x3fff << FBC_CTL_INTERVAL_SHIFT;
136+
fbc_ctl &= FBC_CTL_INTERVAL(0x3fff);
137137
fbc_ctl |= FBC_CTL_EN | FBC_CTL_PERIODIC;
138138
if (IS_I945GM(dev_priv))
139139
fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */
140-
fbc_ctl |= (cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT;
140+
fbc_ctl |= FBC_CTL_STRIDE(cfb_pitch & 0xff);
141141
if (params->fence_id >= 0)
142-
fbc_ctl |= params->fence_id;
142+
fbc_ctl |= FBC_CTL_FENCENO(params->fence_id);
143143
intel_de_write(dev_priv, FBC_CONTROL, fbc_ctl);
144144
}
145145

@@ -1423,7 +1423,7 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)
14231423
/* This value was pulled out of someone's hat */
14241424
if (INTEL_GEN(dev_priv) <= 4 && !IS_GM45(dev_priv))
14251425
intel_de_write(dev_priv, FBC_CONTROL,
1426-
500 << FBC_CTL_INTERVAL_SHIFT);
1426+
FBC_CTL_INTERVAL(500));
14271427

14281428
/* We still don't have any sort of hardware state readout for FBC, so
14291429
* deactivate it in case the BIOS activated it to make sure software

drivers/gpu/drm/i915/i915_reg.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,13 +3208,17 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
32083208
#define FBC_CFB_BASE _MMIO(0x3200) /* 4k page aligned */
32093209
#define FBC_LL_BASE _MMIO(0x3204) /* 4k page aligned */
32103210
#define FBC_CONTROL _MMIO(0x3208)
3211-
#define FBC_CTL_EN (1 << 31)
3212-
#define FBC_CTL_PERIODIC (1 << 30)
3213-
#define FBC_CTL_INTERVAL_SHIFT (16)
3214-
#define FBC_CTL_UNCOMPRESSIBLE (1 << 14)
3215-
#define FBC_CTL_C3_IDLE (1 << 13)
3216-
#define FBC_CTL_STRIDE_SHIFT (5)
3217-
#define FBC_CTL_FENCENO_SHIFT (0)
3211+
#define FBC_CTL_EN REG_BIT(31)
3212+
#define FBC_CTL_PERIODIC REG_BIT(30)
3213+
#define FBC_CTL_INTERVAL_MASK REG_GENMASK(29, 16)
3214+
#define FBC_CTL_INTERVAL(x) REG_FIELD_PREP(FBC_CTL_INTERVAL_MASK, (x))
3215+
#define FBC_CTL_STOP_ON_MOD REG_BIT(15)
3216+
#define FBC_CTL_UNCOMPRESSIBLE REG_BIT(14) /* i915+ */
3217+
#define FBC_CTL_C3_IDLE REG_BIT(13) /* i945gm */
3218+
#define FBC_CTL_STRIDE_MASK REG_GENMASK(12, 5)
3219+
#define FBC_CTL_STRIDE(x) REG_FIELD_PREP(FBC_CTL_STRIDE_MASK, (x))
3220+
#define FBC_CTL_FENCENO_MASK REG_GENMASK(3, 0)
3221+
#define FBC_CTL_FENCENO(x) REG_FIELD_PREP(FBC_CTL_FENCENO_MASK, (x))
32183222
#define FBC_COMMAND _MMIO(0x320c)
32193223
#define FBC_CMD_COMPRESS (1 << 0)
32203224
#define FBC_STATUS _MMIO(0x3210)

0 commit comments

Comments
 (0)