@@ -950,7 +950,8 @@ static bool intel_psr2_config_valid(struct intel_dp *intel_dp,
950
950
}
951
951
952
952
void intel_psr_compute_config (struct intel_dp * intel_dp ,
953
- struct intel_crtc_state * crtc_state )
953
+ struct intel_crtc_state * crtc_state ,
954
+ struct drm_connector_state * conn_state )
954
955
{
955
956
struct drm_i915_private * dev_priv = dp_to_i915 (intel_dp );
956
957
const struct drm_display_mode * adjusted_mode =
@@ -1002,7 +1003,10 @@ void intel_psr_compute_config(struct intel_dp *intel_dp,
1002
1003
1003
1004
crtc_state -> has_psr = true;
1004
1005
crtc_state -> has_psr2 = intel_psr2_config_valid (intel_dp , crtc_state );
1006
+
1005
1007
crtc_state -> infoframes .enable |= intel_hdmi_infoframe_enable (DP_SDP_VSC );
1008
+ intel_dp_compute_psr_vsc_sdp (intel_dp , crtc_state , conn_state ,
1009
+ & crtc_state -> psr_vsc );
1006
1010
}
1007
1011
1008
1012
void intel_psr_get_config (struct intel_encoder * encoder ,
@@ -1182,8 +1186,7 @@ static bool psr_interrupt_error_check(struct intel_dp *intel_dp)
1182
1186
}
1183
1187
1184
1188
static void intel_psr_enable_locked (struct intel_dp * intel_dp ,
1185
- const struct intel_crtc_state * crtc_state ,
1186
- const struct drm_connector_state * conn_state )
1189
+ const struct intel_crtc_state * crtc_state )
1187
1190
{
1188
1191
struct intel_digital_port * dig_port = dp_to_dig_port (intel_dp );
1189
1192
struct drm_i915_private * dev_priv = dp_to_i915 (intel_dp );
@@ -1210,9 +1213,7 @@ static void intel_psr_enable_locked(struct intel_dp *intel_dp,
1210
1213
1211
1214
drm_dbg_kms (& dev_priv -> drm , "Enabling PSR%s\n" ,
1212
1215
intel_dp -> psr .psr2_enabled ? "2" : "1" );
1213
- intel_dp_compute_psr_vsc_sdp (intel_dp , crtc_state , conn_state ,
1214
- & intel_dp -> psr .vsc );
1215
- intel_write_dp_vsc_sdp (encoder , crtc_state , & intel_dp -> psr .vsc );
1216
+ intel_write_dp_vsc_sdp (encoder , crtc_state , & crtc_state -> psr_vsc );
1216
1217
intel_snps_phy_update_psr_power_state (dev_priv , phy , true);
1217
1218
intel_psr_enable_sink (intel_dp );
1218
1219
intel_psr_enable_source (intel_dp );
@@ -1222,33 +1223,6 @@ static void intel_psr_enable_locked(struct intel_dp *intel_dp,
1222
1223
intel_psr_activate (intel_dp );
1223
1224
}
1224
1225
1225
- /**
1226
- * intel_psr_enable - Enable PSR
1227
- * @intel_dp: Intel DP
1228
- * @crtc_state: new CRTC state
1229
- * @conn_state: new CONNECTOR state
1230
- *
1231
- * This function can only be called after the pipe is fully trained and enabled.
1232
- */
1233
- void intel_psr_enable (struct intel_dp * intel_dp ,
1234
- const struct intel_crtc_state * crtc_state ,
1235
- const struct drm_connector_state * conn_state )
1236
- {
1237
- struct drm_i915_private * dev_priv = dp_to_i915 (intel_dp );
1238
-
1239
- if (!CAN_PSR (intel_dp ))
1240
- return ;
1241
-
1242
- if (!crtc_state -> has_psr )
1243
- return ;
1244
-
1245
- drm_WARN_ON (& dev_priv -> drm , dev_priv -> drrs .dp );
1246
-
1247
- mutex_lock (& intel_dp -> psr .lock );
1248
- intel_psr_enable_locked (intel_dp , crtc_state , conn_state );
1249
- mutex_unlock (& intel_dp -> psr .lock );
1250
- }
1251
-
1252
1226
static void intel_psr_exit (struct intel_dp * intel_dp )
1253
1227
{
1254
1228
struct drm_i915_private * dev_priv = dp_to_i915 (intel_dp );
@@ -1734,48 +1708,92 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state,
1734
1708
return 0 ;
1735
1709
}
1736
1710
1737
- /**
1738
- * intel_psr_update - Update PSR state
1739
- * @intel_dp: Intel DP
1740
- * @crtc_state: new CRTC state
1741
- * @conn_state: new CONNECTOR state
1742
- *
1743
- * This functions will update PSR states, disabling, enabling or switching PSR
1744
- * version when executing fastsets. For full modeset, intel_psr_disable() and
1745
- * intel_psr_enable() should be called instead.
1746
- */
1747
- void intel_psr_update (struct intel_dp * intel_dp ,
1748
- const struct intel_crtc_state * crtc_state ,
1749
- const struct drm_connector_state * conn_state )
1711
+ static void _intel_psr_pre_plane_update (const struct intel_atomic_state * state ,
1712
+ const struct intel_crtc_state * crtc_state )
1750
1713
{
1751
- struct intel_psr * psr = & intel_dp -> psr ;
1752
- bool enable , psr2_enable ;
1714
+ struct intel_encoder * encoder ;
1753
1715
1754
- if (!CAN_PSR (intel_dp ))
1716
+ for_each_intel_encoder_mask_with_psr (state -> base .dev , encoder ,
1717
+ crtc_state -> uapi .encoder_mask ) {
1718
+ struct intel_dp * intel_dp = enc_to_intel_dp (encoder );
1719
+ struct intel_psr * psr = & intel_dp -> psr ;
1720
+ bool needs_to_disable = false;
1721
+
1722
+ mutex_lock (& psr -> lock );
1723
+
1724
+ /*
1725
+ * Reasons to disable:
1726
+ * - PSR disabled in new state
1727
+ * - All planes will go inactive
1728
+ * - Changing between PSR versions
1729
+ */
1730
+ needs_to_disable |= !crtc_state -> has_psr ;
1731
+ needs_to_disable |= !crtc_state -> active_planes ;
1732
+ needs_to_disable |= crtc_state -> has_psr2 != psr -> psr2_enabled ;
1733
+
1734
+ if (psr -> enabled && needs_to_disable )
1735
+ intel_psr_disable_locked (intel_dp );
1736
+
1737
+ mutex_unlock (& psr -> lock );
1738
+ }
1739
+ }
1740
+
1741
+ void intel_psr_pre_plane_update (const struct intel_atomic_state * state )
1742
+ {
1743
+ struct drm_i915_private * dev_priv = to_i915 (state -> base .dev );
1744
+ struct intel_crtc_state * crtc_state ;
1745
+ struct intel_crtc * crtc ;
1746
+ int i ;
1747
+
1748
+ if (!HAS_PSR (dev_priv ))
1755
1749
return ;
1756
1750
1757
- mutex_lock (& intel_dp -> psr .lock );
1751
+ for_each_new_intel_crtc_in_state (state , crtc , crtc_state , i )
1752
+ _intel_psr_pre_plane_update (state , crtc_state );
1753
+ }
1758
1754
1759
- enable = crtc_state -> has_psr ;
1760
- psr2_enable = crtc_state -> has_psr2 ;
1755
+ static void _intel_psr_post_plane_update (const struct intel_atomic_state * state ,
1756
+ const struct intel_crtc_state * crtc_state )
1757
+ {
1758
+ struct drm_i915_private * dev_priv = to_i915 (state -> base .dev );
1759
+ struct intel_encoder * encoder ;
1760
+
1761
+ if (!crtc_state -> has_psr )
1762
+ return ;
1763
+
1764
+ for_each_intel_encoder_mask_with_psr (state -> base .dev , encoder ,
1765
+ crtc_state -> uapi .encoder_mask ) {
1766
+ struct intel_dp * intel_dp = enc_to_intel_dp (encoder );
1767
+ struct intel_psr * psr = & intel_dp -> psr ;
1768
+
1769
+ mutex_lock (& psr -> lock );
1770
+
1771
+ drm_WARN_ON (& dev_priv -> drm , psr -> enabled && !crtc_state -> active_planes );
1772
+
1773
+ /* Only enable if there is active planes */
1774
+ if (!psr -> enabled && crtc_state -> active_planes )
1775
+ intel_psr_enable_locked (intel_dp , crtc_state );
1761
1776
1762
- if (enable == psr -> enabled && psr2_enable == psr -> psr2_enabled &&
1763
- crtc_state -> enable_psr2_sel_fetch == psr -> psr2_sel_fetch_enabled ) {
1764
1777
/* Force a PSR exit when enabling CRC to avoid CRC timeouts */
1765
1778
if (crtc_state -> crc_enabled && psr -> enabled )
1766
1779
psr_force_hw_tracking_exit (intel_dp );
1767
1780
1768
- goto unlock ;
1781
+ mutex_unlock ( & psr -> lock ) ;
1769
1782
}
1783
+ }
1770
1784
1771
- if (psr -> enabled )
1772
- intel_psr_disable_locked (intel_dp );
1785
+ void intel_psr_post_plane_update (const struct intel_atomic_state * state )
1786
+ {
1787
+ struct drm_i915_private * dev_priv = to_i915 (state -> base .dev );
1788
+ struct intel_crtc_state * crtc_state ;
1789
+ struct intel_crtc * crtc ;
1790
+ int i ;
1773
1791
1774
- if (enable )
1775
- intel_psr_enable_locked ( intel_dp , crtc_state , conn_state ) ;
1792
+ if (! HAS_PSR ( dev_priv ) )
1793
+ return ;
1776
1794
1777
- unlock :
1778
- mutex_unlock ( & intel_dp -> psr . lock );
1795
+ for_each_new_intel_crtc_in_state ( state , crtc , crtc_state , i )
1796
+ _intel_psr_post_plane_update ( state , crtc_state );
1779
1797
}
1780
1798
1781
1799
/**
0 commit comments