drm/i915: Use intel_attached_encoder()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 4 Dec 2019 18:05:45 +0000 (20:05 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 21 Jan 2020 16:16:34 +0000 (18:16 +0200)
It's easy to confuse the drm_connector->encoder (legacy state
adjusted during modeset) and intel_connector->encoder (the statically
(sans. MST) attached encoder of the connector). For the latter
let's use intel_attached_encoder() consistently.

@@
identifier F !~ "^intel_attached_encoder$";
struct intel_connector *C;
expression E;
@@
F(...)
{
<...
(
  C->encoder = E
|
- C->encoder
+ intel_attached_encoder(C)
)
...>
}

@@
identifier F !~ "^intel_attached_encoder$";
struct drm_connector *C;
expression E;
@@
F(...)
{
<...
(
  to_intel_connector(C)->encoder = E
|
- to_intel_connector(C)->encoder
+ intel_attached_encoder(to_intel_connector(C))
)
...>
}

v2: Regenerated

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191204180549.1267-6-ville.syrjala@linux.intel.com
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
drivers/gpu/drm/i915/display/intel_connector.c
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
drivers/gpu/drm/i915/display/intel_dp_mst.c
drivers/gpu/drm/i915/display/intel_dsi_dcs_backlight.c
drivers/gpu/drm/i915/display/intel_hdcp.c
drivers/gpu/drm/i915/display/intel_hotplug.c
drivers/gpu/drm/i915/display/intel_psr.c
drivers/gpu/drm/i915/display/vlv_dsi.c
drivers/gpu/drm/i915/i915_debugfs.c

index 1133c4e97bb4b2a8be9522542fc59a3d73b49988..54891a4ed2f300893d9a3fec6c2f76f3e368c5ef 100644 (file)
@@ -153,7 +153,7 @@ void intel_connector_attach_encoder(struct intel_connector *connector,
 bool intel_connector_get_hw_state(struct intel_connector *connector)
 {
        enum pipe pipe = 0;
-       struct intel_encoder *encoder = connector->encoder;
+       struct intel_encoder *encoder = intel_attached_encoder(connector);
 
        return encoder->get_hw_state(encoder, &pipe);
 }
index 18a8186699f9be7cff715e841e06d108fc0b6efd..bbf1c0a243a2c38ab769144b347bb0cb99fd9c01 100644 (file)
@@ -2046,7 +2046,7 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
 {
        struct drm_device *dev = intel_connector->base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
-       struct intel_encoder *encoder = intel_connector->encoder;
+       struct intel_encoder *encoder = intel_attached_encoder(intel_connector);
        int type = intel_connector->base.connector_type;
        enum port port = encoder->port;
        enum transcoder cpu_transcoder;
index 76c17341df2b111f83ff93dca1a66dde1a96cb0e..e6aea716818fa5eb019f14b99fc3164c02398f56 100644 (file)
@@ -7581,7 +7581,7 @@ static void intel_connector_verify_state(struct intel_crtc_state *crtc_state,
                      connector->base.name);
 
        if (connector->get_hw_state(connector)) {
-               struct intel_encoder *encoder = connector->encoder;
+               struct intel_encoder *encoder = intel_attached_encoder(connector);
 
                I915_STATE_WARN(!crtc_state,
                         "connector enabled without attached crtc\n");
@@ -18073,7 +18073,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
 
                        connector->base.dpms = DRM_MODE_DPMS_ON;
 
-                       encoder = connector->encoder;
+                       encoder = intel_attached_encoder(connector);
                        connector->base.encoder = &encoder->base;
 
                        crtc = to_intel_crtc(encoder->base.crtc);
index 77a759361c5c74d4997018362b7d4c8d58009842..e251ccd5bf6ce4dea34fe252c75480779bcb5e88 100644 (file)
@@ -57,7 +57,7 @@ static void set_aux_backlight_enable(struct intel_dp *intel_dp, bool enable)
  */
 static u32 intel_dp_aux_get_backlight(struct intel_connector *connector)
 {
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
        u8 read_val[2] = { 0x0 };
        u8 mode_reg;
        u16 level = 0;
@@ -99,7 +99,7 @@ static void
 intel_dp_aux_set_backlight(const struct drm_connector_state *conn_state, u32 level)
 {
        struct intel_connector *connector = to_intel_connector(conn_state->connector);
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
        u8 vals[2] = { 0x0 };
 
        vals[0] = level;
@@ -127,7 +127,7 @@ intel_dp_aux_set_backlight(const struct drm_connector_state *conn_state, u32 lev
 static bool intel_dp_aux_set_pwm_freq(struct intel_connector *connector)
 {
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
        const u8 pn = connector->panel.backlight.pwmgen_bit_count;
        int freq, fxp, f, fxp_actual, fxp_min, fxp_max;
 
@@ -162,7 +162,7 @@ static void intel_dp_aux_enable_backlight(const struct intel_crtc_state *crtc_st
                                          const struct drm_connector_state *conn_state)
 {
        struct intel_connector *connector = to_intel_connector(conn_state->connector);
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
        struct intel_panel *panel = &connector->panel;
        u8 dpcd_buf, new_dpcd_buf, edp_backlight_mode;
 
@@ -221,7 +221,7 @@ static void intel_dp_aux_disable_backlight(const struct drm_connector_state *old
 static u32 intel_dp_aux_calc_max_backlight(struct intel_connector *connector)
 {
        struct drm_i915_private *i915 = to_i915(connector->base.dev);
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
        struct intel_panel *panel = &connector->panel;
        u32 max_backlight = 0;
        int freq, fxp, fxp_min, fxp_max, fxp_actual, f = 1;
@@ -311,7 +311,7 @@ static int intel_dp_aux_setup_backlight(struct intel_connector *connector,
 static bool
 intel_dp_aux_display_control_capable(struct intel_connector *connector)
 {
-       struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
+       struct intel_dp *intel_dp = enc_to_intel_dp(intel_attached_encoder(connector));
 
        /* Check the eDP Display control capabilities registers to determine if
         * the panel can support backlight control over the aux channel
index d98988da3d06d1d07106c87877ffa335bc7350ad..ab2315acd5f762deabe929353f53c3238b6b7bdd 100644 (file)
@@ -631,9 +631,9 @@ static const struct drm_encoder_funcs intel_dp_mst_enc_funcs = {
 
 static bool intel_dp_mst_get_hw_state(struct intel_connector *connector)
 {
-       if (connector->encoder && connector->base.state->crtc) {
+       if (intel_attached_encoder(connector) && connector->base.state->crtc) {
                enum pipe pipe;
-               if (!connector->encoder->get_hw_state(connector->encoder, &pipe))
+               if (!intel_attached_encoder(connector)->get_hw_state(intel_attached_encoder(connector), &pipe))
                        return false;
                return true;
        }
index c87838843d0bb85c70b07ea230ccd32561bc3157..ac3eff26df12cdd3677d3348c4f7a105ad63cb19 100644 (file)
@@ -45,7 +45,7 @@
 
 static u32 dcs_get_backlight(struct intel_connector *connector)
 {
-       struct intel_encoder *encoder = connector->encoder;
+       struct intel_encoder *encoder = intel_attached_encoder(connector);
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
        struct mipi_dsi_device *dsi_device;
        u8 data = 0;
@@ -160,7 +160,7 @@ int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector)
 {
        struct drm_device *dev = intel_connector->base.dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
-       struct intel_encoder *encoder = intel_connector->encoder;
+       struct intel_encoder *encoder = intel_attached_encoder(intel_connector);
        struct intel_panel *panel = &intel_connector->panel;
 
        if (dev_priv->vbt.backlight.type != INTEL_BACKLIGHT_DSI_DCS)
index 0fdbd39f664148021292af6d0888792811f4015d..2859230671ae8af89e7d3066b16aa4a919441c5d 100644 (file)
@@ -1527,7 +1527,7 @@ static int hdcp2_enable_encryption(struct intel_connector *connector)
        struct intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
        struct intel_hdcp *hdcp = &connector->hdcp;
-       enum port port = connector->encoder->port;
+       enum port port = intel_attached_encoder(connector)->port;
        enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
        int ret;
 
@@ -1565,7 +1565,7 @@ static int hdcp2_disable_encryption(struct intel_connector *connector)
        struct intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
        struct intel_hdcp *hdcp = &connector->hdcp;
-       enum port port = connector->encoder->port;
+       enum port port = intel_attached_encoder(connector)->port;
        enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
        int ret;
 
@@ -1676,7 +1676,7 @@ static int intel_hdcp2_check_link(struct intel_connector *connector)
        struct intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
        struct intel_hdcp *hdcp = &connector->hdcp;
-       enum port port = connector->encoder->port;
+       enum port port = intel_attached_encoder(connector)->port;
        enum transcoder cpu_transcoder;
        int ret = 0;
 
@@ -1830,7 +1830,7 @@ static inline int initialize_hdcp_port_data(struct intel_connector *connector,
 
        if (INTEL_GEN(dev_priv) < 12)
                data->fw_ddi =
-                       intel_get_mei_fw_ddi_index(connector->encoder->port);
+                       intel_get_mei_fw_ddi_index(intel_attached_encoder(connector)->port);
        else
                /*
                 * As per ME FW API expectation, for GEN 12+, fw_ddi is filled
index 99d3a3c7989e19cb7ea63df834f45435b3fb83f4..c3a48af35997f8757c1d9e98d2a92eee1a822b8f 100644 (file)
@@ -200,7 +200,7 @@ intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv)
                        continue;
 
                intel_connector = to_intel_connector(connector);
-               intel_encoder = intel_connector->encoder;
+               intel_encoder = intel_attached_encoder(intel_connector);
                if (!intel_encoder)
                        continue;
 
@@ -255,7 +255,7 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
 
                        /* Don't check MST ports, they don't have pins */
                        if (!intel_connector->mst_port &&
-                           intel_connector->encoder->hpd_pin == pin) {
+                           intel_attached_encoder(intel_connector)->hpd_pin == pin) {
                                if (connector->polled != intel_connector->polled)
                                        DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n",
                                                         connector->name);
@@ -389,9 +389,9 @@ static void i915_hotplug_work_func(struct work_struct *work)
                u32 hpd_bit;
 
                intel_connector = to_intel_connector(connector);
-               if (!intel_connector->encoder)
+               if (!intel_attached_encoder(intel_connector))
                        continue;
-               intel_encoder = intel_connector->encoder;
+               intel_encoder = intel_attached_encoder(intel_connector);
                hpd_bit = BIT(intel_encoder->hpd_pin);
                if ((hpd_event_bits | hpd_retry_bits) & hpd_bit) {
                        DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n",
@@ -621,7 +621,7 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
                        continue;
 
                if (!connector->polled && I915_HAS_HOTPLUG(dev_priv) &&
-                   intel_connector->encoder->hpd_pin > HPD_NONE) {
+                   intel_attached_encoder(intel_connector)->hpd_pin > HPD_NONE) {
                        connector->polled = enabled ?
                                DRM_CONNECTOR_POLL_CONNECT |
                                DRM_CONNECTOR_POLL_DISCONNECT :
index 1d2fd1a8925a6f2bb437699b900b14b19f2c2126..7f4056057f0c64511bc58cc86f58904655bac51e 100644 (file)
@@ -1534,7 +1534,7 @@ void intel_psr_atomic_check(struct drm_connector *connector,
                return;
 
        intel_connector = to_intel_connector(connector);
-       dig_port = enc_to_dig_port(intel_connector->encoder);
+       dig_port = enc_to_dig_port(intel_attached_encoder(intel_connector));
        if (dev_priv->psr.dp != &dig_port->dp)
                return;
 
index daf4fc3dab6f180454126c245584a311555834b2..7963cb881566fd4b877556c708f6cc1c5a176172 100644 (file)
@@ -1563,7 +1563,7 @@ static enum drm_panel_orientation
 vlv_dsi_get_hw_panel_orientation(struct intel_connector *connector)
 {
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
-       struct intel_encoder *encoder = connector->encoder;
+       struct intel_encoder *encoder = intel_attached_encoder(connector);
        enum intel_display_power_domain power_domain;
        enum drm_panel_orientation orientation;
        struct intel_plane *plane;
index c05fa4205de887187cbcca1d106e248fe41a1b38..49291f1423866b84f0ef05e5e1052b752dc6d6ae 100644 (file)
@@ -2391,7 +2391,7 @@ static void intel_hdcp_info(struct seq_file *m,
 static void intel_dp_info(struct seq_file *m,
                          struct intel_connector *intel_connector)
 {
-       struct intel_encoder *intel_encoder = intel_connector->encoder;
+       struct intel_encoder *intel_encoder = intel_attached_encoder(intel_connector);
        struct intel_dp *intel_dp = enc_to_intel_dp(intel_encoder);
 
        seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]);
@@ -2410,7 +2410,7 @@ static void intel_dp_info(struct seq_file *m,
 static void intel_dp_mst_info(struct seq_file *m,
                          struct intel_connector *intel_connector)
 {
-       struct intel_encoder *intel_encoder = intel_connector->encoder;
+       struct intel_encoder *intel_encoder = intel_attached_encoder(intel_connector);
        struct intel_dp_mst_encoder *intel_mst =
                enc_to_mst(intel_encoder);
        struct intel_digital_port *intel_dig_port = intel_mst->primary;
@@ -2424,7 +2424,7 @@ static void intel_dp_mst_info(struct seq_file *m,
 static void intel_hdmi_info(struct seq_file *m,
                            struct intel_connector *intel_connector)
 {
-       struct intel_encoder *intel_encoder = intel_connector->encoder;
+       struct intel_encoder *intel_encoder = intel_attached_encoder(intel_connector);
        struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(intel_encoder);
 
        seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));