Skip to contentSkip to conversation

drm/i915: Remove "i2c_speed" nonsense from child device table

PATCH In review Adam Jackson 4 participants 18 messages Jun 16, 2011 – Apr 16, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/i915: Remove "i2c_speed" nonsense from child device table

I have no evidence for this byte being used this way, and lots of counterexamples. Restore the struct to its empirical definition and patch up gmbus setup to match.

---
 drivers/gpu/drm/i915/i915_drv.h   |    1 -
 drivers/gpu/drm/i915/intel_bios.c |    6 ++----
 drivers/gpu/drm/i915/intel_bios.h |    3 +--
 drivers/gpu/drm/i915/intel_sdvo.c |   12 +++++-------
 4 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index f63ee16..ee6a267 100644
@@ -138,7 +138,6 @@ struct sdvo_device_mapping {
 	u8 slave_addr;
 	u8 dvo_wiring;
 	u8 i2c_pin;
-	u8 i2c_speed;
 	u8 ddc_pin;
 };
 
drivers/gpu/drm/i915/intel_bios.c +2 -4
index 927442a..2da1d7f 100644
@@ -372,15 +372,13 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
 			p_mapping->dvo_wiring = p_child->dvo_wiring;
 			p_mapping->ddc_pin = p_child->ddc_pin;
 			p_mapping->i2c_pin = p_child->i2c_pin;
-			p_mapping->i2c_speed = p_child->i2c_speed;
 			p_mapping->initialized = 1;
-			DRM_DEBUG_KMS("SDVO device: dvo=%x, addr=%x, wiring=%d, ddc_pin=%d, i2c_pin=%d, i2c_speed=%d\n",
+			DRM_DEBUG_KMS("SDVO device: dvo=%x, addr=%x, wiring=%d, ddc_pin=%d, i2c_pin=%d\n",
 				      p_mapping->dvo_port,
 				      p_mapping->slave_addr,
 				      p_mapping->dvo_wiring,
 				      p_mapping->ddc_pin,
-				      p_mapping->i2c_pin,
-				      p_mapping->i2c_speed);
+				      p_mapping->i2c_pin);
 		} else {
 			DRM_DEBUG_KMS("Maybe one SDVO port is shared by "
 					 "two SDVO device.\n");
drivers/gpu/drm/i915/intel_bios.h +1 -2
index 5f8e4ed..4e67ede 100644
@@ -197,8 +197,7 @@ struct bdb_general_features {
 struct child_device_config {
 	u16 handle;
 	u16 device_type;
-	u8  i2c_speed;
-	u8  rsvd[9];
+	u8  device_id[10]; /* ascii string */
 	u16 addin_offset;
 	u8  dvo_port; /* See Device_PORT_* above */
 	u8  i2c_pin;
drivers/gpu/drm/i915/intel_sdvo.c +5 -7
index 30fe554..a6339f8 100644
@@ -1945,7 +1945,7 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
 			  struct intel_sdvo *sdvo, u32 reg)
 {
 	struct sdvo_device_mapping *mapping;
-	u8 pin, speed;
+	u8 pin;
 
 	if (IS_SDVOB(reg))
 		mapping = &dev_priv->sdvo_mappings[0];
@@ -1953,18 +1953,16 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
 		mapping = &dev_priv->sdvo_mappings[1];
 
 	pin = GMBUS_PORT_DPB;
-	speed = GMBUS_RATE_1MHZ >> 8;
-	if (mapping->initialized) {
+	if (mapping->initialized)
 		pin = mapping->i2c_pin;
-		speed = mapping->i2c_speed;
-	}
 
 	if (pin < GMBUS_NUM_PORTS) {
 		sdvo->i2c = &dev_priv->gmbus[pin].adapter;
-		intel_gmbus_set_speed(sdvo->i2c, speed);
+		intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ >> 8);
 		intel_gmbus_force_bit(sdvo->i2c, true);
-	} else
+	} else {
 		sdvo->i2c = &dev_priv->gmbus[GMBUS_PORT_DPB].adapter;
+	}
 }
 
 static bool
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/6 drm/i915: Fix multifunction SDVO detection

I can't think of any sensible reason to limit this to a mask of 0x0f, ie, SDVO_OUTPUT_{TMDS,RGB,CVBS,SVID}0.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +1 -2
index a6339f8..475f615 100644
@@ -1281,8 +1281,7 @@ static bool
 intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
 {
 	/* Is there more than one type of output? */
-	int caps = intel_sdvo->caps.output_flags & 0xf;
-	return caps & -caps;
+	return hweight16(intel_sdvo->caps.output_flags) > 1;
 }
 
 static struct edid *
Signature · 1 line
1.7.5.4
Reviewed-by on v1 2/6
#2 lore raw

Re: [PATCH 2/6] drm/i915: Fix multifunction SDVO detection

Quoted 2 lines · Adam Jackson

I can't think of any sensible reason to limit this to a mask of 0x0f, ie, SDVO_OUTPUT_{TMDS,RGB,CVBS,SVID}0.

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

PATCH 3/6 drm/i915: Rename intel_sdvo_hdmi_sink_detect

In reply to Adam Jackson

This is general TMDS detect, not HDMI specifically.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +2 -2
index 475f615..6d3dd09 100644
@@ -1302,7 +1302,7 @@ intel_sdvo_get_analog_edid(struct drm_connector *connector)
 }
 
 enum drm_connector_status
-intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
+intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 {
 	struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
 	enum drm_connector_status status;
@@ -1397,7 +1397,7 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
 	if ((intel_sdvo_connector->output_flag & response) == 0)
 		ret = connector_status_disconnected;
 	else if (IS_TMDS(intel_sdvo_connector))
-		ret = intel_sdvo_hdmi_sink_detect(connector);
+		ret = intel_sdvo_tmds_sink_detect(connector);
 	else {
 		struct edid *edid;
 
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH 4/6 drm/i915: Try harder on multifunction SDVO DDC

In reply to Adam Jackson

The comment was wrong, bus 0 is the SPD ROM, as we discovered in 14571b4 and b108333.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +2 -5
index 6d3dd09..193919e 100644
@@ -1313,11 +1313,8 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 	if (edid == NULL && intel_sdvo_multifunc_encoder(intel_sdvo)) {
 		u8 ddc, saved_ddc = intel_sdvo->ddc_bus;
 
-		/*
-		 * Don't use the 1 as the argument of DDC bus switch to get
-		 * the EDID. It is used for SDVO SPD ROM.
-		 */
-		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 1; ddc >>= 1) {
+		/* Skip bus 0, it's the SDVO SPD ROM */
+		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 0; ddc >>= 1) {
 			intel_sdvo->ddc_bus = ddc;
 			edid = intel_sdvo_get_edid(connector);
 			if (edid)
Signature · 1 line
1.7.5.4
#6 lore raw

Re: [PATCH 4/6] drm/i915: Try harder on multifunction SDVO DDC

Rolf,

This looks to be the missing ingredient for your board. Can you please give it a test?
-Chris

Quoted 33 lines · Adam Jackson

The comment was wrong, bus 0 is the SPD ROM, as we discovered in 14571b4 and b108333.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +2 -5
index 6d3dd09..193919e 100644
@@ -1313,11 +1313,8 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 	if (edid == NULL && intel_sdvo_multifunc_encoder(intel_sdvo)) {
 		u8 ddc, saved_ddc = intel_sdvo->ddc_bus;
 
-		/*
-		 * Don't use the 1 as the argument of DDC bus switch to get
-		 * the EDID. It is used for SDVO SPD ROM.
-		 */
-		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 1; ddc >>= 1) {
+		/* Skip bus 0, it's the SDVO SPD ROM */
+		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 0; ddc >>= 1) {
 			intel_sdvo->ddc_bus = ddc;
 			edid = intel_sdvo_get_edid(connector);
 			if (edid)
Signature · 6 lines
1.7.5.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw

Re: [PATCH 4/6] drm/i915: Try harder on multifunction SDVO DDC

In reply to Adam Jackson
Quoted 4 lines · Adam Jackson

The comment was wrong, bus 0 is the SPD ROM, as we discovered in 14571b4 and b108333.

I've checked with the SDVO spec and the ddc bus switch command uses a bitflag array, and bit 0 (i.e. 1) is used for the spd rom. So the code seems to be correct.

But while looking through the git history I've noticed that this code got added before we've figured out the vbios sdvo ddc pin mappings game, so I'm inclined to just rip this out. Especially since we start at the ddc that does _not_ read our edid and don't unconditionally test all 3 ddc buses, potentially leaving out bus 3&2. Does anyone know why we've needed this or maybe even have the hw?

For reference, the commit that added this code originally is

commit 7c3f0a2726fed78e0e0afe3b6fc3c1f5b298e447

Author: Zhao Yakui <[email protected]>
Date:   Fri Jan 8 10:58:20 2010 +0800

drm/i915: try another possible DDC bus for the SDVO device with multiple outputs

Cheers, Daniel

Quoted 29 lines
---
 drivers/gpu/drm/i915/intel_sdvo.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +2 -5
index 6d3dd09..193919e 100644
@@ -1313,11 +1313,8 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 	if (edid == NULL && intel_sdvo_multifunc_encoder(intel_sdvo)) {
 		u8 ddc, saved_ddc = intel_sdvo->ddc_bus;
 
-		/*
-		 * Don't use the 1 as the argument of DDC bus switch to get
-		 * the EDID. It is used for SDVO SPD ROM.
-		 */
-		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 1; ddc >>= 1) {
+		/* Skip bus 0, it's the SDVO SPD ROM */
+		for (ddc = intel_sdvo->ddc_bus >> 1; ddc > 0; ddc >>= 1) {
 			intel_sdvo->ddc_bus = ddc;
 			edid = intel_sdvo_get_edid(connector);
 			if (edid)
Signature · 6 lines
1.7.5.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#9 lore raw

Re: [PATCH 4/6] drm/i915: Try harder on multifunction SDVO DDC

Quoted 6 lines · Daniel Vetter

But while looking through the git history I've noticed that this code got added before we've figured out the vbios sdvo ddc pin mappings game, so I'm inclined to just rip this out. Especially since we start at the ddc that does _not_ read our edid and don't unconditionally test all 3 ddc buses, potentially leaving out bus 3&2. Does anyone know why we've needed this or maybe even have the hw?

Yeah, I've never liked this path. Use the pin mappings.

- ajax

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

PATCH 5/6 drm/i915: Delete a misleading comment

In reply to Adam Jackson

It's not wrong, but the text and the code describe different predicates and my brain kept stumbling over it.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +1 -4
index 193919e..c2272f7 100644
@@ -1320,10 +1320,7 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 			if (edid)
 				break;
 		}
-		/*
-		 * If we found the EDID on the other bus,
-		 * assume that is the correct DDC bus.
-		 */
+
 		if (edid == NULL)
 			intel_sdvo->ddc_bus = saved_ddc;
 	}
Signature · 1 line
1.7.5.4
#11 lore raw

Re: [PATCH 5/6] drm/i915: Delete a misleading comment

Quoted 13 lines · Adam Jackson

It's not wrong, but the text and the code describe different predicates and my brain kept stumbling over it.

---
 drivers/gpu/drm/i915/intel_sdvo.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +0 -0
index 193919e..c2272f7 100644

drivers/gpu/drm/i915/intel_sdvo.c intel_sdvo_tmds_sink_detect(struct drm_connector *connector) · line 1323

Quoted 8 lines
drivers/gpu/drm/i915/intel_sdvo.c +1 -4
@@ -1320,10 +1320,7 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
 			if (edid)
 				break;
 		}
-		/*
-		 * If we found the EDID on the other bus,
-		 * assume that is the correct DDC bus.
-		 */
+

How about?

If we foudn the EDID on another bus, presume that is the correct DDC bus and keep using that bus for future queries. Otherwise, restore the original value.

Quoted 3 lines
drivers/gpu/drm/i915/intel_sdvo.c +0 -0
 		if (edid == NULL)
 			intel_sdvo->ddc_bus = saved_ddc;
 	}
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#12 lore raw

PATCH 6/6 drm/i915: Remove redundant bit shifting from intel_gmbus_set_speed

In reply to Adam Jackson
---
 drivers/gpu/drm/i915/intel_i2c.c  |    8 +-------
 drivers/gpu/drm/i915/intel_sdvo.c |    2 +-
 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_i2c.c +1 -7
index d3b903b..5d707c4 100644
@@ -423,13 +423,7 @@ void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed)
 {
 	struct intel_gmbus *bus = to_intel_gmbus(adapter);
 
-	/* speed:
-	 * 0x0 = 100 KHz
-	 * 0x1 = 50 KHz
-	 * 0x2 = 400 KHz
-	 * 0x3 = 1000 Khz
-	 */
-	bus->reg0 = (bus->reg0 & ~(0x3 << 8)) | (speed << 8);
+	bus->reg0 = (bus->reg0 & ~(0x3 << 8)) | speed;
 }
 
 void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit)
drivers/gpu/drm/i915/intel_sdvo.c +1 -1
index c2272f7..82296c3 100644
@@ -1951,7 +1951,7 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
 
 	if (pin < GMBUS_NUM_PORTS) {
 		sdvo->i2c = &dev_priv->gmbus[pin].adapter;
-		intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ >> 8);
+		intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ);
 		intel_gmbus_force_bit(sdvo->i2c, true);
 	} else {
 		sdvo->i2c = &dev_priv->gmbus[GMBUS_PORT_DPB].adapter;
Signature · 1 line
1.7.5.4
#15 lore raw
In reply to Adam Jackson
Quoted 5 lines · Adam Jackson

I have no evidence for this byte being used this way, and lots of counterexamples. Restore the struct to its empirical definition and patch up gmbus setup to match.

This code is still present in Linus' tree, and still crap. Any reviewers for this series?

- ajax

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw
Quoted 2 lines · Adam Jackson

This code is still present in Linus' tree, and still crap. Any reviewers for this series?

It all looks reasonable to me, and Chris reviewed or ack'd every patch but #4, which looks reasonable on the surface to me.

Are you thinking this should land in 3.1? Or 3.2?

Signature · 1 line
[email protected]

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw
Quoted 9 lines · Keith Packard
Quoted 2 lines · Adam Jackson

This code is still present in Linus' tree, and still crap. Any reviewers for this series?

It all looks reasonable to me, and Chris reviewed or ack'd every patch but #4, which looks reasonable on the surface to me.

Are you thinking this should land in 3.1? Or 3.2?

#1 should definitely land in 3.1 if at all possible. The rest can wait I guess.

I'd still like to get more dialogue about #4 from Rolf or someone else with multifunc sdvo. That, or such a device on my shelf. I can buy one if someone knows what I should buy.

- ajax

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx