Check if the bus is valid prior to discovering edid.
Subsystems (2)
PATCH 1/1 Check if the bus is valid prior to discovering edid.
From: Eugeni Dodonov <[email protected]>
This adds a new function intel_drm_get_valid_edid, which attempts to detect EDID values from available devices and returns quickly in case no connection is present. We detect non-existing devices by checking the i2c_transfer status, and if it fails with the -ENXIO result, we know that the i2c_algo_bit was unable to locate the hardware, so we give up on further edid discovery.
This should improve the edid detection timeouts by a large margin in some cases, as noted in
https://bugs.freedesktop.org/show_bug.cgi?id=41059.
This also removes intel_ddc_probe, whose functionality is now done by intel_drm_get_valid_edid.
v2: change printk level to KERN_DEBUG to avoid filling up dmesg
v3: removed intel_ddc_probe and merged its functionality into intel_drm_get_valid_edid, as suggested by Ben Widawsky. Also, replace printk with DRM_DEBUG_KMS to avoid spamming dmesg, as noticed by Jesse Barnes.
--- drivers/gpu/drm/i915/intel_crt.c | 48 ++++++++++++++++++------------------ drivers/gpu/drm/i915/intel_dp.c | 4 +- drivers/gpu/drm/i915/intel_drv.h | 3 +- drivers/gpu/drm/i915/intel_hdmi.c | 4 +- drivers/gpu/drm/i915/intel_i2c.c | 42 +++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_lvds.c | 2 +- drivers/gpu/drm/i915/intel_modes.c | 29 +--------------------- drivers/gpu/drm/i915/intel_sdvo.c | 4 +- 8 files changed, 76 insertions(+), 60 deletions(-)
drivers/gpu/drm/i915/intel_crt.c +23 -23
@@ -273,36 +273,36 @@ static bool intel_crt_detect_ddc(struct drm_connector *connector) {struct intel_crt *crt =intel_attached_crt (connector);struct drm_i915_private *dev_priv = crt->base.base.dev->dev_private; +struct edid *edid =NULL ; +bool is_digital = false;/* CRT should always be at 0, but check anyway */ if (crt->base.type !=INTEL_OUTPUT_ANALOG )return false; -if (intel_ddc_probe (&crt->base, dev_priv->crt_ddc_pin)) { -struct edid *edid; -bool is_digital = false; + edid =intel_drm_get_valid_edid (connector, + &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter); +if (!edid) +return false; - edid =drm_get_edid (connector, - &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter); -/* -* This may be a DVI-I connector with a shared DDC -* link between analog and digital outputs, so we -* have to check the EDID input spec of the attached device. -* -* On the other hand, what should we do if it is a broken EDID? -*/ -if (edid !=NULL ) { - is_digital = edid->input &DRM_EDID_INPUT_DIGITAL ; - connector->display_info.raw_edid =NULL ; -kfree (edid); - } +/* +* This may be a DVI-I connector with a shared DDC +* link between analog and digital outputs, so we +* have to check the EDID input spec of the attached device. +* +* On the other hand, what should we do if it is a broken EDID? +*/ +if (edid !=NULL ) { + is_digital = edid->input &DRM_EDID_INPUT_DIGITAL ; + connector->display_info.raw_edid =NULL ; +kfree (edid); + } -if (!is_digital) { -DRM_DEBUG_KMS ("CRT detected via DDC:0x50 [EDID]\n" ); -return true; - }else { -DRM_DEBUG_KMS ("CRT not detected via DDC:0x50 [EDID reports a digital panel]\n" ); - } +if (!is_digital) { +DRM_DEBUG_KMS ("CRT detected via DDC:0x50 [EDID]\n" ); +return true; + }else { +DRM_DEBUG_KMS ("CRT not detected via DDC:0x50 [EDID reports a digital panel]\n" ); }return false;
drivers/gpu/drm/i915/intel_dp.c +2 -2
@@ -1715,7 +1715,7 @@ intel_dp_detect(struct drm_connector *connector, bool force)if (intel_dp->force_audio) { intel_dp->has_audio = intel_dp->force_audio >0 ; }else { - edid =drm_get_edid (connector, &intel_dp->adapter); + edid =intel_drm_get_valid_edid (connector, &intel_dp->adapter);if (edid) { intel_dp->has_audio =drm_detect_monitor_audio (edid); connector->display_info.raw_edid =NULL ;
@@ -1772,7 +1772,7 @@ intel_dp_detect_audio(struct drm_connector *connector)struct edid *edid;bool has_audio = false; - edid =drm_get_edid (connector, &intel_dp->adapter); + edid =intel_drm_get_valid_edid (connector, &intel_dp->adapter);if (edid) { has_audio =drm_detect_monitor_audio (edid);
drivers/gpu/drm/i915/intel_drv.h +2 -1
@@ -264,8 +264,9 @@ struct intel_fbc_work {int interval; }; +struct edid *intel_drm_get_valid_edid (struct drm_connector *connector, +struct i2c_adapter *adapter);int intel_ddc_get_modes (struct drm_connector *c,struct i2c_adapter *adapter); -extern bool intel_ddc_probe (struct intel_encoder *intel_encoder,int ddc_bus);extern void intel_attach_force_audio_property (struct drm_connector *connector);extern void intel_attach_broadcast_rgb_property (struct drm_connector *connector);
drivers/gpu/drm/i915/intel_hdmi.c +2 -2
@@ -329,7 +329,7 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) intel_hdmi->has_hdmi_sink = false; intel_hdmi->has_audio = false; - edid =drm_get_edid (connector, + edid =intel_drm_get_valid_edid (connector, &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);if (edid) {
@@ -371,7 +371,7 @@ intel_hdmi_detect_audio(struct drm_connector *connector)struct edid *edid;bool has_audio = false; - edid =drm_get_edid (connector, + edid =intel_drm_get_valid_edid (connector, &dev_priv->gmbus[intel_hdmi->ddc_bus].adapter);if (edid) {if (edid->input &DRM_EDID_INPUT_DIGITAL )
drivers/gpu/drm/i915/intel_i2c.c +42 -0
45 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lvds.c +1 -1
@@ -921,7 +921,7 @@ bool intel_lvds_init(struct drm_device *dev)* Attempt to get the fixed panel mode from DDC. Assume that the * preferred mode is the right one. */ - intel_lvds->edid =drm_get_edid (connector, + intel_lvds->edid =intel_drm_get_valid_edid (connector, &dev_priv->gmbus[pin].adapter);if (intel_lvds->edid) { if (drm_add_edid_modes(connector,
drivers/gpu/drm/i915/intel_modes.c +1 -28
@@ -31,33 +31,6 @@#include "i915_drv.h" /** -* intel_ddc_probe -* -*/ -bool intel_ddc_probe (struct intel_encoder *intel_encoder,int ddc_bus) -{ -struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private; -u8 out_buf[] = {0x0 ,0x0 }; -u8 buf[2 ]; -struct i2c_msg msgs[] = { - { - .addr =0x50 , - .flags =0 , - .len =1 , - .buf = out_buf, - }, - { - .addr =0x50 , - .flags =I2C_M_RD , - .len =1 , - .buf = buf, - } - }; - -return i2c_transfer (&dev_priv->gmbus[ddc_bus].adapter, msgs,2 ) ==2 ; -} - -/** * intel_ddc_get_modes - get modelist from monitor * @connector: DRM connector device to use * @adapter: i2c adapter
@@ -70,7 +43,7 @@ int intel_ddc_get_modes(struct drm_connector *connector,struct edid *edid;int ret =0 ; - edid =drm_get_edid (connector, adapter); + edid =intel_drm_get_valid_edid (connector, adapter);if (edid) {drm_mode_connector_update_edid_property (connector, edid); ret =drm_add_edid_modes (connector, edid);
drivers/gpu/drm/i915/intel_sdvo.c +2 -2
@@ -1240,7 +1240,7 @@ static struct edid * intel_sdvo_get_edid(struct drm_connector *connector) {struct intel_sdvo *sdvo =intel_attached_sdvo (connector); -return drm_get_edid (connector, &sdvo->ddc); +return intel_drm_get_valid_edid (connector, &sdvo->ddc); }/* Mac mini hack -- use the same DDC as the analog connector */
@@ -1249,7 +1249,7 @@ intel_sdvo_get_analog_edid(struct drm_connector *connector) {struct drm_i915_private *dev_priv = connector->dev->dev_private; -return drm_get_edid (connector, +return intel_drm_get_valid_edid (connector, &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter); }
Signature · 1 line
1.7.6.3
Quoted 33 lines · Eugeni Dodonov
drivers/gpu/drm/i915/intel_i2c.c +25
-0@@ -470,3 +470,45 @@ void intel_teardown_gmbus(struct drm_device *dev)kfree (dev_priv->gmbus); dev_priv->gmbus =NULL ; } + +/** +* intel_drm_get_valid_edid - gets edid from existent adapters only +* @connector: DRM connector device to use +* @adapter: i2c adapter +* +* Verifies if the i2c adapter is responding to our queries before +* attempting to do proper communication with it. If it does, +* retreive the EDID with help of drm_get_edid +*/ +struct edid * +intel_drm_get_valid_edid (struct drm_connector *connector, +struct i2c_adapter *adapter) +{ +int ret; +u8 out_buf[] = {0x0 ,0x0 }; +u8 buf[2 ]; +struct i2c_msg msgs[] = { + { + .addr =0x50 , + .flags =0 , + .len =1 , + .buf = out_buf, + }, + {
drivers/gpu/drm/i915/intel_i2c.c void intel_teardown_gmbus(struct drm_device *dev) · line 507
Quoted 10 lines
drivers/gpu/drm/i915/intel_i2c.c +10
-0+ .addr = 0x50, + .flags = I2C_M_RD, + .len = 1, + .buf = buf, + } + }; + +/* We just check for -ENXIO - drm_get_edid checks if the transfer +* works and manages the remaining parts of the EDID */ + ret =i2c_transfer (adapter, msgs,2 );
This seems like it should be the implementation body of drm_probe_ddc, and like that function should be EXPORT_SYMBOL()'d. Other people want to do zero-length reads too, you know.
- ajax
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 51 lines · Adam Jackson
Review
Quoted 1 line · Eugeni Dodonov
(quoted diff) +0
-0
b/drivers/gpu/drm/i915/intel_i2c.cQuoted 32 lines
index d98cee6..b3a6eda 100644
drivers/gpu/drm/i915/intel_i2c.c +25
-0@@ -470,3 +470,45 @@ void intel_teardown_gmbus(struct drm_device *dev)kfree (dev_priv->gmbus); dev_priv->gmbus =NULL ; } + +/** +* intel_drm_get_valid_edid - gets edid from existent adapters only +* @connector: DRM connector device to use +* @adapter: i2c adapter +* +* Verifies if the i2c adapter is responding to our queries before +* attempting to do proper communication with it. If it does, +* retreive the EDID with help of drm_get_edid +*/ +struct edid * +intel_drm_get_valid_edid (struct drm_connector *connector, +struct i2c_adapter *adapter) +{ +int ret; +u8 out_buf[] = {0x0 ,0x0 }; +u8 buf[2 ]; +struct i2c_msg msgs[] = { + { + .addr =0x50 , + .flags =0 , + .len =1 , + .buf = out_buf, + }, + {drivers/gpu/drm/i915/intel_i2c.c void intel_teardown_gmbus(struct drm_device *dev) · line 507
Quoted 10 lines
drivers/gpu/drm/i915/intel_i2c.c +10
-0+ .addr = 0x50, + .flags = I2C_M_RD, + .len = 1, + .buf = buf, + } + }; + +/* We just check for -ENXIO - drm_get_edid checks if the transfer +* works and manages the remaining parts of the EDID */ + ret =i2c_transfer (adapter, msgs,2 );This seems like it should be the implementation body of
drm_probe_ddc, and like that function should be EXPORT_SYMBOL()'d. Other people want to do zero-length reads too, you know.
Quoted 2 lines
- ajax
My other patch in the previous series (
http://www.mail-archive.com/[email protected]/msg05828.html)
did exactly that, but it haven't received any comments, and there was one report saying that it decreased the detection timing on a radeon card. I don't have any to test, so I prefer to focus on Intel ones (which I have) :).
Signature · 2 lines
Eugeni Dodonov <http://eugeni.dodonov.net/>
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Dave Airlie
maintainerQuoted 53 lines · Eugeni Dodonov
Quoted 52 lines · Adam Jackson
Quoted 34 lines · Eugeni Dodonov
drivers/gpu/drm/i915/intel_i2c.c +25
-0@@ -470,3 +470,45 @@ void intel_teardown_gmbus(struct drm_device *dev) kfree(dev_priv->gmbus); dev_priv->gmbus = NULL; } + +/** +* intel_drm_get_valid_edid - gets edid from existent adapters only +* @connector: DRM connector device to use +* @adapter: i2c adapter +* +* Verifies if the i2c adapter is responding to our queries before +* attempting to do proper communication with it. If it does, +* retreive the EDID with help of drm_get_edid +*/ +struct edid * +intel_drm_get_valid_edid (struct drm_connector *connector, + struct i2c_adapter *adapter) +{ + int ret; + u8 out_buf[] = { 0x0, 0x0}; + u8 buf[2]; + struct i2c_msg msgs[] = { + { + .addr = 0x50, + .flags = 0, + .len = 1, + .buf = out_buf, + }, + {drivers/gpu/drm/i915/intel_i2c.c void intel_teardown_gmbus(struct drm_device *dev) · line 507
Quoted 10 lines
drivers/gpu/drm/i915/intel_i2c.c +10
-0+ .addr = 0x50, + .flags = I2C_M_RD, + .len = 1, + .buf = buf, + } + }; + + /* We just check for -ENXIO - drm_get_edid checks if the transfer + * works and manages the remaining parts of the EDID */ + ret = i2c_transfer(adapter, msgs, 2);This seems like it should be the implementation body of
drm_probe_ddc, and like that function should be EXPORT_SYMBOL()'d. Other people want to do zero-length reads too, you know.
Quoted 8 lines
Quoted 1 line
- ajax
My other patch in the previous series
(http://www.mail-archive.com/[email protected]/msg05828.html)
did exactly that, but it haven't received any comments, and there was one report saying that it decreased the detection timing on a radeon card. I don't have any to test, so I prefer to focus on Intel ones (which I have) :).
Thats not how we develop in the kernel btw.
You should go around trying to poke developers from other drivers to test the patch.
Dave.