Commit 70a221b2 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Prefer intel_connector over drm_connector in hotplug code

Replace the drm_connector loops with intel_connector loops to
streamline the code.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200121171100.4370-2-ville.syrjala@linux.intel.comReviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
parent d1b2828a
...@@ -185,37 +185,36 @@ static void ...@@ -185,37 +185,36 @@ static void
intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv) intel_hpd_irq_storm_switch_to_polling(struct drm_i915_private *dev_priv)
{ {
struct drm_device *dev = &dev_priv->drm; struct drm_device *dev = &dev_priv->drm;
struct intel_connector *intel_connector;
struct intel_encoder *intel_encoder;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
enum hpd_pin pin; struct intel_connector *connector;
bool hpd_disabled = false; bool hpd_disabled = false;
lockdep_assert_held(&dev_priv->irq_lock); lockdep_assert_held(&dev_priv->irq_lock);
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { for_each_intel_connector_iter(connector, &conn_iter) {
if (connector->polled != DRM_CONNECTOR_POLL_HPD) struct intel_encoder *encoder;
enum hpd_pin pin;
if (connector->base.polled != DRM_CONNECTOR_POLL_HPD)
continue; continue;
intel_connector = to_intel_connector(connector); encoder = intel_attached_encoder(connector);
intel_encoder = intel_attached_encoder(intel_connector); if (!encoder)
if (!intel_encoder)
continue; continue;
pin = intel_encoder->hpd_pin; pin = encoder->hpd_pin;
if (pin == HPD_NONE || if (pin == HPD_NONE ||
dev_priv->hotplug.stats[pin].state != HPD_MARK_DISABLED) dev_priv->hotplug.stats[pin].state != HPD_MARK_DISABLED)
continue; continue;
DRM_INFO("HPD interrupt storm detected on connector %s: " DRM_INFO("HPD interrupt storm detected on connector %s: "
"switching from hotplug detection to polling\n", "switching from hotplug detection to polling\n",
connector->name); connector->base.name);
dev_priv->hotplug.stats[pin].state = HPD_DISABLED; dev_priv->hotplug.stats[pin].state = HPD_DISABLED;
connector->polled = DRM_CONNECTOR_POLL_CONNECT connector->base.polled = DRM_CONNECTOR_POLL_CONNECT |
| DRM_CONNECTOR_POLL_DISCONNECT; DRM_CONNECTOR_POLL_DISCONNECT;
hpd_disabled = true; hpd_disabled = true;
} }
drm_connector_list_iter_end(&conn_iter); drm_connector_list_iter_end(&conn_iter);
...@@ -241,8 +240,8 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) ...@@ -241,8 +240,8 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
spin_lock_irq(&dev_priv->irq_lock); spin_lock_irq(&dev_priv->irq_lock);
for_each_hpd_pin(pin) { for_each_hpd_pin(pin) {
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
struct intel_connector *connector;
if (dev_priv->hotplug.stats[pin].state != HPD_DISABLED) if (dev_priv->hotplug.stats[pin].state != HPD_DISABLED)
continue; continue;
...@@ -250,18 +249,16 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work) ...@@ -250,18 +249,16 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
dev_priv->hotplug.stats[pin].state = HPD_ENABLED; dev_priv->hotplug.stats[pin].state = HPD_ENABLED;
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { for_each_intel_connector_iter(connector, &conn_iter) {
struct intel_connector *intel_connector = to_intel_connector(connector);
/* 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 (!connector->mst_port &&
intel_attached_encoder(intel_connector)->hpd_pin == pin) { intel_attached_encoder(connector)->hpd_pin == pin) {
if (connector->polled != intel_connector->polled) if (connector->base.polled != connector->polled)
DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n", DRM_DEBUG_DRIVER("Reenabling HPD on connector %s\n",
connector->name); connector->base.name);
connector->polled = intel_connector->polled; connector->base.polled = connector->polled;
if (!connector->polled) if (!connector->base.polled)
connector->polled = DRM_CONNECTOR_POLL_HPD; connector->base.polled = DRM_CONNECTOR_POLL_HPD;
} }
} }
drm_connector_list_iter_end(&conn_iter); drm_connector_list_iter_end(&conn_iter);
...@@ -361,10 +358,8 @@ static void i915_hotplug_work_func(struct work_struct *work) ...@@ -361,10 +358,8 @@ static void i915_hotplug_work_func(struct work_struct *work)
container_of(work, struct drm_i915_private, container_of(work, struct drm_i915_private,
hotplug.hotplug_work.work); hotplug.hotplug_work.work);
struct drm_device *dev = &dev_priv->drm; struct drm_device *dev = &dev_priv->drm;
struct intel_connector *intel_connector;
struct intel_encoder *intel_encoder;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
struct intel_connector *connector;
u32 changed = 0, retry = 0; u32 changed = 0, retry = 0;
u32 hpd_event_bits; u32 hpd_event_bits;
u32 hpd_retry_bits; u32 hpd_retry_bits;
...@@ -385,20 +380,20 @@ static void i915_hotplug_work_func(struct work_struct *work) ...@@ -385,20 +380,20 @@ static void i915_hotplug_work_func(struct work_struct *work)
spin_unlock_irq(&dev_priv->irq_lock); spin_unlock_irq(&dev_priv->irq_lock);
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { for_each_intel_connector_iter(connector, &conn_iter) {
struct intel_encoder *encoder =
intel_attached_encoder(connector);
u32 hpd_bit; u32 hpd_bit;
intel_connector = to_intel_connector(connector); if (!encoder)
if (!intel_attached_encoder(intel_connector))
continue; continue;
intel_encoder = intel_attached_encoder(intel_connector);
hpd_bit = BIT(intel_encoder->hpd_pin); hpd_bit = BIT(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",
connector->name, intel_encoder->hpd_pin); connector->base.name, encoder->hpd_pin);
switch (intel_encoder->hotplug(intel_encoder, switch (encoder->hotplug(encoder, connector,
intel_connector,
hpd_event_bits & hpd_bit)) { hpd_event_bits & hpd_bit)) {
case INTEL_HOTPLUG_UNCHANGED: case INTEL_HOTPLUG_UNCHANGED:
break; break;
...@@ -601,8 +596,8 @@ static void i915_hpd_poll_init_work(struct work_struct *work) ...@@ -601,8 +596,8 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
container_of(work, struct drm_i915_private, container_of(work, struct drm_i915_private,
hotplug.poll_init_work); hotplug.poll_init_work);
struct drm_device *dev = &dev_priv->drm; struct drm_device *dev = &dev_priv->drm;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
struct intel_connector *connector;
bool enabled; bool enabled;
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
...@@ -610,19 +605,17 @@ static void i915_hpd_poll_init_work(struct work_struct *work) ...@@ -610,19 +605,17 @@ static void i915_hpd_poll_init_work(struct work_struct *work)
enabled = READ_ONCE(dev_priv->hotplug.poll_enabled); enabled = READ_ONCE(dev_priv->hotplug.poll_enabled);
drm_connector_list_iter_begin(dev, &conn_iter); drm_connector_list_iter_begin(dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) { for_each_intel_connector_iter(connector, &conn_iter) {
struct intel_connector *intel_connector = connector->base.polled = connector->polled;
to_intel_connector(connector);
connector->polled = intel_connector->polled;
/* MST has a dynamic intel_connector->encoder and it's reprobing /* MST has a dynamic intel_connector->encoder and it's reprobing
* is all handled by the MST helpers. */ * is all handled by the MST helpers. */
if (intel_connector->mst_port) if (connector->mst_port)
continue; continue;
if (!connector->polled && I915_HAS_HOTPLUG(dev_priv) && if (!connector->base.polled && I915_HAS_HOTPLUG(dev_priv) &&
intel_attached_encoder(intel_connector)->hpd_pin > HPD_NONE) { intel_attached_encoder(connector)->hpd_pin > HPD_NONE) {
connector->polled = enabled ? connector->base.polled = enabled ?
DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_CONNECT |
DRM_CONNECTOR_POLL_DISCONNECT : DRM_CONNECTOR_POLL_DISCONNECT :
DRM_CONNECTOR_POLL_HPD; DRM_CONNECTOR_POLL_HPD;
......
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