Skip to content

Commit b70709a

Browse files
mlankhorstdanvet
authored andcommitted
drm/i915: get rid of primary_enabled and use atomic state
This was an optimization from way back before we had primary plane support to be able to disable the primary plane. But with primary plane support userspace can tell the kernel this directly, so there's no big need for this any more. And it's getting in the way of the atomic conversion. If need be we can resurrect this later on properly again. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> [danvet: Explain why removing this is ok.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 27321ae commit b70709a

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,11 +2236,7 @@ static void intel_enable_primary_hw_plane(struct drm_plane *plane,
22362236

22372237
/* If the pipe isn't enabled, we can't pump pixels and may hang */
22382238
assert_pipe_enabled(dev_priv, intel_crtc->pipe);
2239-
2240-
if (intel_crtc->primary_enabled)
2241-
return;
2242-
2243-
intel_crtc->primary_enabled = true;
2239+
to_intel_plane_state(plane->state)->visible = true;
22442240

22452241
dev_priv->display.update_primary_plane(crtc, plane->fb,
22462242
crtc->x, crtc->y);
@@ -2661,14 +2657,16 @@ static void i9xx_update_primary_plane(struct drm_crtc *crtc,
26612657
struct drm_device *dev = crtc->dev;
26622658
struct drm_i915_private *dev_priv = dev->dev_private;
26632659
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2660+
struct drm_plane *primary = crtc->primary;
2661+
bool visible = to_intel_plane_state(primary->state)->visible;
26642662
struct drm_i915_gem_object *obj;
26652663
int plane = intel_crtc->plane;
26662664
unsigned long linear_offset;
26672665
u32 dspcntr;
26682666
u32 reg = DSPCNTR(plane);
26692667
int pixel_size;
26702668

2671-
if (!intel_crtc->primary_enabled || !fb) {
2669+
if (!visible || !fb) {
26722670
I915_WRITE(reg, 0);
26732671
if (INTEL_INFO(dev)->gen >= 4)
26742672
I915_WRITE(DSPSURF(plane), 0);
@@ -2790,14 +2788,16 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,
27902788
struct drm_device *dev = crtc->dev;
27912789
struct drm_i915_private *dev_priv = dev->dev_private;
27922790
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
2791+
struct drm_plane *primary = crtc->primary;
2792+
bool visible = to_intel_plane_state(primary->state)->visible;
27932793
struct drm_i915_gem_object *obj;
27942794
int plane = intel_crtc->plane;
27952795
unsigned long linear_offset;
27962796
u32 dspcntr;
27972797
u32 reg = DSPCNTR(plane);
27982798
int pixel_size;
27992799

2800-
if (!intel_crtc->primary_enabled || !fb) {
2800+
if (!visible || !fb) {
28012801
I915_WRITE(reg, 0);
28022802
I915_WRITE(DSPSURF(plane), 0);
28032803
POSTING_READ(reg);
@@ -3059,24 +3059,24 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
30593059
struct drm_device *dev = crtc->dev;
30603060
struct drm_i915_private *dev_priv = dev->dev_private;
30613061
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3062+
struct drm_plane *plane = crtc->primary;
3063+
bool visible = to_intel_plane_state(plane->state)->visible;
30623064
struct drm_i915_gem_object *obj;
30633065
int pipe = intel_crtc->pipe;
30643066
u32 plane_ctl, stride_div, stride;
30653067
u32 tile_height, plane_offset, plane_size;
30663068
unsigned int rotation;
30673069
int x_offset, y_offset;
30683070
unsigned long surf_addr;
3069-
struct drm_plane *plane;
30703071
struct intel_crtc_state *crtc_state = intel_crtc->config;
30713072
struct intel_plane_state *plane_state;
30723073
int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
30733074
int dst_x = 0, dst_y = 0, dst_w = 0, dst_h = 0;
30743075
int scaler_id = -1;
30753076

3076-
plane = crtc->primary;
30773077
plane_state = to_intel_plane_state(plane->state);
30783078

3079-
if (!intel_crtc->primary_enabled || !fb) {
3079+
if (!visible || !fb) {
30803080
I915_WRITE(PLANE_CTL(pipe, 0), 0);
30813081
I915_WRITE(PLANE_SURF(pipe, 0), 0);
30823082
POSTING_READ(PLANE_CTL(pipe, 0));
@@ -4783,7 +4783,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc)
47834783
hsw_disable_ips(intel_crtc);
47844784

47854785
intel_crtc_dpms_overlay(intel_crtc, false);
4786-
intel_crtc->primary_enabled = false;
47874786
for_each_intel_plane(dev, intel_plane) {
47884787
if (intel_plane->pipe == pipe) {
47894788
struct drm_crtc *from = intel_plane->base.crtc;
@@ -12891,6 +12890,9 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
1289112890
} else if (config->fb_changed) {
1289212891
struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc);
1289312892
struct drm_plane *primary = set->crtc->primary;
12893+
struct intel_plane_state *plane_state =
12894+
to_intel_plane_state(primary->state);
12895+
bool was_visible = plane_state->visible;
1289412896
int vdisplay, hdisplay;
1289512897

1289612898
drm_crtc_get_hv_timing(set->mode, &hdisplay, &vdisplay);
@@ -12903,7 +12905,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
1290312905
* We need to make sure the primary plane is re-enabled if it
1290412906
* has previously been turned off.
1290512907
*/
12906-
if (!intel_crtc->primary_enabled && ret == 0) {
12908+
plane_state = to_intel_plane_state(primary->state);
12909+
if (ret == 0 && !was_visible && plane_state->visible) {
1290712910
WARN_ON(!intel_crtc->active);
1290812911
intel_enable_primary_hw_plane(set->crtc->primary, set->crtc);
1290912912
}
@@ -13239,6 +13242,9 @@ intel_check_primary_plane(struct drm_plane *plane,
1323913242
return ret;
1324013243

1324113244
if (intel_crtc->active) {
13245+
struct intel_plane_state *old_state =
13246+
to_intel_plane_state(plane->state);
13247+
1324213248
intel_crtc->atomic.wait_for_flips = true;
1324313249

1324413250
/*
@@ -13251,20 +13257,20 @@ intel_check_primary_plane(struct drm_plane *plane,
1325113257
* one is done too late. We eventually need to unify
1325213258
* this.
1325313259
*/
13254-
if (intel_crtc->primary_enabled &&
13260+
if (state->visible &&
1325513261
INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) &&
1325613262
dev_priv->fbc.crtc == intel_crtc &&
1325713263
state->base.rotation != BIT(DRM_ROTATE_0)) {
1325813264
intel_crtc->atomic.disable_fbc = true;
1325913265
}
1326013266

13261-
if (state->visible) {
13267+
if (state->visible && !old_state->visible) {
1326213268
/*
1326313269
* BDW signals flip done immediately if the plane
1326413270
* is disabled, even if the plane enable is already
1326513271
* armed to occur at the next vblank :(
1326613272
*/
13267-
if (IS_BROADWELL(dev) && !intel_crtc->primary_enabled)
13273+
if (IS_BROADWELL(dev))
1326813274
intel_crtc->atomic.wait_vblank = true;
1326913275
}
1327013276

@@ -13306,8 +13312,6 @@ intel_commit_primary_plane(struct drm_plane *plane,
1330613312
crtc->y = src->y1 >> 16;
1330713313

1330813314
if (intel_crtc->active) {
13309-
intel_crtc->primary_enabled = state->visible;
13310-
1331113315
if (state->visible)
1331213316
/* FIXME: kill this fastboot hack */
1331313317
intel_update_pipe_size(intel_crtc);
@@ -13325,9 +13329,6 @@ intel_disable_primary_plane(struct drm_plane *plane,
1332513329
struct drm_device *dev = plane->dev;
1332613330
struct drm_i915_private *dev_priv = dev->dev_private;
1332713331

13328-
if (!force)
13329-
to_intel_crtc(crtc)->primary_enabled = false;
13330-
1333113332
dev_priv->display.update_primary_plane(crtc, NULL, 0, 0);
1333213333
}
1333313334

@@ -14791,8 +14792,8 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)
1479114792
* Temporarily change the plane mapping and disable everything
1479214793
* ... */
1479314794
plane = crtc->plane;
14795+
to_intel_plane_state(crtc->base.primary->state)->visible = true;
1479414796
crtc->plane = !plane;
14795-
crtc->primary_enabled = true;
1479614797
dev_priv->display.crtc_disable(&crtc->base);
1479714798
crtc->plane = plane;
1479814799

@@ -14969,6 +14970,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
1496914970
int i;
1497014971

1497114972
for_each_intel_crtc(dev, crtc) {
14973+
struct drm_plane *primary = crtc->base.primary;
14974+
struct intel_plane_state *plane_state;
14975+
1497214976
memset(crtc->config, 0, sizeof(*crtc->config));
1497314977

1497414978
crtc->config->quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
@@ -14978,7 +14982,9 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
1497814982

1497914983
crtc->base.state->enable = crtc->active;
1498014984
crtc->base.enabled = crtc->active;
14981-
crtc->primary_enabled = primary_get_hw_state(crtc);
14985+
14986+
plane_state = to_intel_plane_state(primary->state);
14987+
plane_state->visible = primary_get_hw_state(crtc);
1498214988

1498314989
DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
1498414990
crtc->base.base.id,

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ struct intel_crtc {
507507
*/
508508
bool active;
509509
unsigned long enabled_power_domains;
510-
bool primary_enabled; /* is the primary plane (partially) visible? */
511510
bool lowfreq_avail;
512511
struct intel_overlay *overlay;
513512
struct intel_unpin_work *unpin_work;

drivers/gpu/drm/i915/intel_fbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static struct drm_crtc *intel_fbc_find_crtc(struct drm_i915_private *dev_priv)
457457
tmp_crtc = dev_priv->pipe_to_crtc_mapping[pipe];
458458

459459
if (intel_crtc_active(tmp_crtc) &&
460-
to_intel_crtc(tmp_crtc)->primary_enabled) {
460+
to_intel_plane_state(tmp_crtc->primary->state)->visible) {
461461
if (one_pipe_only && crtc) {
462462
if (set_no_fbc_reason(dev_priv, FBC_MULTIPLE_PIPES))
463463
DRM_DEBUG_KMS("more than one pipe active, disabling compression\n");

0 commit comments

Comments
 (0)