Commit fa7edcd2 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Use intel_attached_encoder()

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: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191204180549.1267-6-ville.syrjala@linux.intel.comReviewed-by: default avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
parent 6fe20299
...@@ -153,7 +153,7 @@ void intel_connector_attach_encoder(struct intel_connector *connector, ...@@ -153,7 +153,7 @@ void intel_connector_attach_encoder(struct intel_connector *connector,
bool intel_connector_get_hw_state(struct intel_connector *connector) bool intel_connector_get_hw_state(struct intel_connector *connector)
{ {
enum pipe pipe = 0; 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); return encoder->get_hw_state(encoder, &pipe);
} }
......
...@@ -2046,7 +2046,7 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector) ...@@ -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_device *dev = intel_connector->base.dev;
struct drm_i915_private *dev_priv = to_i915(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; int type = intel_connector->base.connector_type;
enum port port = encoder->port; enum port port = encoder->port;
enum transcoder cpu_transcoder; enum transcoder cpu_transcoder;
......
...@@ -7581,7 +7581,7 @@ static void intel_connector_verify_state(struct intel_crtc_state *crtc_state, ...@@ -7581,7 +7581,7 @@ static void intel_connector_verify_state(struct intel_crtc_state *crtc_state,
connector->base.name); connector->base.name);
if (connector->get_hw_state(connector)) { 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, I915_STATE_WARN(!crtc_state,
"connector enabled without attached crtc\n"); "connector enabled without attached crtc\n");
...@@ -18073,7 +18073,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) ...@@ -18073,7 +18073,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
connector->base.dpms = DRM_MODE_DPMS_ON; connector->base.dpms = DRM_MODE_DPMS_ON;
encoder = connector->encoder; encoder = intel_attached_encoder(connector);
connector->base.encoder = &encoder->base; connector->base.encoder = &encoder->base;
crtc = to_intel_crtc(encoder->base.crtc); crtc = to_intel_crtc(encoder->base.crtc);
......
...@@ -57,7 +57,7 @@ static void set_aux_backlight_enable(struct intel_dp *intel_dp, bool enable) ...@@ -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) 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 read_val[2] = { 0x0 };
u8 mode_reg; u8 mode_reg;
u16 level = 0; u16 level = 0;
...@@ -99,7 +99,7 @@ static void ...@@ -99,7 +99,7 @@ static void
intel_dp_aux_set_backlight(const struct drm_connector_state *conn_state, u32 level) 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_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 }; u8 vals[2] = { 0x0 };
vals[0] = level; vals[0] = level;
...@@ -127,7 +127,7 @@ intel_dp_aux_set_backlight(const struct drm_connector_state *conn_state, u32 lev ...@@ -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) static bool intel_dp_aux_set_pwm_freq(struct intel_connector *connector)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 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; const u8 pn = connector->panel.backlight.pwmgen_bit_count;
int freq, fxp, f, fxp_actual, fxp_min, fxp_max; 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 ...@@ -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) const struct drm_connector_state *conn_state)
{ {
struct intel_connector *connector = to_intel_connector(conn_state->connector); 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; struct intel_panel *panel = &connector->panel;
u8 dpcd_buf, new_dpcd_buf, edp_backlight_mode; 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 ...@@ -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) static u32 intel_dp_aux_calc_max_backlight(struct intel_connector *connector)
{ {
struct drm_i915_private *i915 = to_i915(connector->base.dev); 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; struct intel_panel *panel = &connector->panel;
u32 max_backlight = 0; u32 max_backlight = 0;
int freq, fxp, fxp_min, fxp_max, fxp_actual, f = 1; 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, ...@@ -311,7 +311,7 @@ static int intel_dp_aux_setup_backlight(struct intel_connector *connector,
static bool static bool
intel_dp_aux_display_control_capable(struct intel_connector *connector) 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 /* Check the eDP Display control capabilities registers to determine if
* the panel can support backlight control over the aux channel * the panel can support backlight control over the aux channel
......
...@@ -631,9 +631,9 @@ static const struct drm_encoder_funcs intel_dp_mst_enc_funcs = { ...@@ -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) 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; 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 false;
return true; return true;
} }
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
static u32 dcs_get_backlight(struct intel_connector *connector) 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 intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
struct mipi_dsi_device *dsi_device; struct mipi_dsi_device *dsi_device;
u8 data = 0; u8 data = 0;
...@@ -160,7 +160,7 @@ int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector) ...@@ -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_device *dev = intel_connector->base.dev;
struct drm_i915_private *dev_priv = to_i915(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; struct intel_panel *panel = &intel_connector->panel;
if (dev_priv->vbt.backlight.type != INTEL_BACKLIGHT_DSI_DCS) if (dev_priv->vbt.backlight.type != INTEL_BACKLIGHT_DSI_DCS)
......
...@@ -1527,7 +1527,7 @@ static int hdcp2_enable_encryption(struct intel_connector *connector) ...@@ -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 intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_hdcp *hdcp = &connector->hdcp; 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; enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
int ret; int ret;
...@@ -1565,7 +1565,7 @@ static int hdcp2_disable_encryption(struct intel_connector *connector) ...@@ -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 intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_hdcp *hdcp = &connector->hdcp; 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; enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
int ret; int ret;
...@@ -1676,7 +1676,7 @@ static int intel_hdcp2_check_link(struct intel_connector *connector) ...@@ -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 intel_digital_port *intel_dig_port = conn_to_dig_port(connector);
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_hdcp *hdcp = &connector->hdcp; struct intel_hdcp *hdcp = &connector->hdcp;
enum port port = connector->encoder->port; enum port port = intel_attached_encoder(connector)->port;
enum transcoder cpu_transcoder; enum transcoder cpu_transcoder;
int ret = 0; int ret = 0;
...@@ -1830,7 +1830,7 @@ static inline int initialize_hdcp_port_data(struct intel_connector *connector, ...@@ -1830,7 +1830,7 @@ static inline int initialize_hdcp_port_data(struct intel_connector *connector,
if (INTEL_GEN(dev_priv) < 12) if (INTEL_GEN(dev_priv) < 12)
data->fw_ddi = data->fw_ddi =
intel_get_mei_fw_ddi_index(connector->encoder->port); intel_get_mei_fw_ddi_index(intel_attached_encoder(connector)->port);
else else
/* /*
* As per ME FW API expectation, for GEN 12+, fw_ddi is filled * As per ME FW API expectation, for GEN 12+, fw_ddi is filled
......
...@@ -200,7 +200,7 @@ intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv) ...@@ -200,7 +200,7 @@ intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv)
continue; continue;
intel_connector = to_intel_connector(connector); intel_connector = to_intel_connector(connector);
intel_encoder = intel_connector->encoder; intel_encoder = intel_attached_encoder(intel_connector);
if (!intel_encoder) if (!intel_encoder)
continue; continue;
...@@ -255,7 +255,7 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) ...@@ -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 */ /* Don't check MST ports, they don't have pins */
if (!intel_connector->mst_port && 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) if (connector->polled != intel_connector->polled)
DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n",
connector->name); connector->name);
...@@ -389,9 +389,9 @@ static void i915_hotplug_work_func(struct work_struct *work) ...@@ -389,9 +389,9 @@ static void i915_hotplug_work_func(struct work_struct *work)
u32 hpd_bit; u32 hpd_bit;
intel_connector = to_intel_connector(connector); intel_connector = to_intel_connector(connector);
if (!intel_connector->encoder) if (!intel_attached_encoder(intel_connector))
continue; continue;
intel_encoder = intel_connector->encoder; intel_encoder = intel_attached_encoder(intel_connector);
hpd_bit = BIT(intel_encoder->hpd_pin); hpd_bit = BIT(intel_encoder->hpd_pin);
if ((hpd_event_bits | hpd_retry_bits) & hpd_bit) { if ((hpd_event_bits | hpd_retry_bits) & hpd_bit) {
DRM_DEBUG_KMS("Connector %s (pin %i) received hotplug event.\n", 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) ...@@ -621,7 +621,7 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
continue; continue;
if (!connector->polled && I915_HAS_HOTPLUG(dev_priv) && 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 ? connector->polled = enabled ?
DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_CONNECT |
DRM_CONNECTOR_POLL_DISCONNECT : DRM_CONNECTOR_POLL_DISCONNECT :
......
...@@ -1534,7 +1534,7 @@ void intel_psr_atomic_check(struct drm_connector *connector, ...@@ -1534,7 +1534,7 @@ void intel_psr_atomic_check(struct drm_connector *connector,
return; return;
intel_connector = to_intel_connector(connector); 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) if (dev_priv->psr.dp != &dig_port->dp)
return; return;
......
...@@ -1563,7 +1563,7 @@ static enum drm_panel_orientation ...@@ -1563,7 +1563,7 @@ static enum drm_panel_orientation
vlv_dsi_get_hw_panel_orientation(struct intel_connector *connector) vlv_dsi_get_hw_panel_orientation(struct intel_connector *connector)
{ {
struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 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 intel_display_power_domain power_domain;
enum drm_panel_orientation orientation; enum drm_panel_orientation orientation;
struct intel_plane *plane; struct intel_plane *plane;
......
...@@ -2391,7 +2391,7 @@ static void intel_hdcp_info(struct seq_file *m, ...@@ -2391,7 +2391,7 @@ static void intel_hdcp_info(struct seq_file *m,
static void intel_dp_info(struct seq_file *m, static void intel_dp_info(struct seq_file *m,
struct intel_connector *intel_connector) 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); struct intel_dp *intel_dp = enc_to_intel_dp(intel_encoder);
seq_printf(m, "\tDPCD rev: %x\n", intel_dp->dpcd[DP_DPCD_REV]); 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, ...@@ -2410,7 +2410,7 @@ static void intel_dp_info(struct seq_file *m,
static void intel_dp_mst_info(struct seq_file *m, static void intel_dp_mst_info(struct seq_file *m,
struct intel_connector *intel_connector) 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 = struct intel_dp_mst_encoder *intel_mst =
enc_to_mst(intel_encoder); enc_to_mst(intel_encoder);
struct intel_digital_port *intel_dig_port = intel_mst->primary; struct intel_digital_port *intel_dig_port = intel_mst->primary;
...@@ -2424,7 +2424,7 @@ static void intel_dp_mst_info(struct seq_file *m, ...@@ -2424,7 +2424,7 @@ static void intel_dp_mst_info(struct seq_file *m,
static void intel_hdmi_info(struct seq_file *m, static void intel_hdmi_info(struct seq_file *m,
struct intel_connector *intel_connector) 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); struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(intel_encoder);
seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio)); seq_printf(m, "\taudio support: %s\n", yesno(intel_hdmi->has_audio));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment