Skip to contentSkip to conversation

imx-drm: Add mx6 hdmi transmitter support

PATCH New Greg KH 4 participants 16 messages Oct 28, 2013 – Oct 30, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Greg KH

author maintainer
#1 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

This is based on the initial work done by Sascha Hauer and Tony Prisk.

What is "this"?

And why is new support being added to this driver instead of working to get it out of staging?

I thought we went through this already...

greg k-h

reviewer
#2 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Hi Greg,

Quoted 6 lines · Greg KH
Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

This is based on the initial work done by Sascha Hauer and Tony Prisk.

What is "this"?

Ok, I will improve the commit log.

Quoted 2 lines

And why is new support being added to this driver instead of working to get it out of staging?

Philipp Zabel mentioned that he will submit the imx-drm driver out of staging:
http://www.spinics.net/lists/dri-devel/msg46784.html

Quoted 1 line

I thought we went through this already...

My understading from your reply at:
http://www.spinics.net/lists/arm-kernel/msg280395.html

,was that the imx-hdmi driver could be moved out of staging (actually it is not even in staging yet), when it becomes in good shape.

As we had so many issues with the previous imx-hdmi patch version, I thought it was better to still send v3 to staging so that we could go through more reviews/testing. Please let me know if I should do it differently for v4.

Thanks,

Fabio Estevam

#3 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 8 lines · Fabio Estevam

Hi Greg,

Quoted 2 lines · Greg KH

And why is new support being added to this driver instead of working to get it out of staging?

Philipp Zabel mentioned that he will submit the imx-drm driver out of staging:
http://www.spinics.net/lists/dri-devel/msg46784.html

The issues surrounding DT and DRM were given an airing last week at kernel summit in a session chaired by David Airlie.

The Kernel Summit session was to discuss issues surrounding DT and DRM, or more specifically DT and componentised subsystems like DRM, ASoC and V4L2. Grant Likely has said that he will attempt to summarise some of the discussion there; unfortunately I'm not aware of anyone making any real "minutes" of what was discussed - it wasn't a formal session.

I also had discussions with David Airlie and, separately, with the Pengutronix folk about imx-drm.

It is very clear to me that David is against imx-drm moving into drivers/gpu/drm - the driver requires an amount of rework in various places. So I don't think it will move out of drivers/staging any time soon.

I have a few other bits to sort out first, but I've volunteered to try to resolve some of these blocking issues so that imx-drm can move forward and hopefully out of staging.

To put it another way, moving this driver out of staging is not as simple as moving the files; it requires real work to address the issues the subsystem maintainer has with this code.

reviewer
#4 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 17 lines · Russell King - ARM Linux

The issues surrounding DT and DRM were given an airing last week at kernel summit in a session chaired by David Airlie.

The Kernel Summit session was to discuss issues surrounding DT and DRM, or more specifically DT and componentised subsystems like DRM, ASoC and V4L2. Grant Likely has said that he will attempt to summarise some of the discussion there; unfortunately I'm not aware of anyone making any real "minutes" of what was discussed - it wasn't a formal session.

I also had discussions with David Airlie and, separately, with the Pengutronix folk about imx-drm.

It is very clear to me that David is against imx-drm moving into drivers/gpu/drm - the driver requires an amount of rework in various places. So I don't think it will move out of drivers/staging any time soon.

Quoted 7 lines

I have a few other bits to sort out first, but I've volunteered to try to resolve some of these blocking issues so that imx-drm can move forward and hopefully out of staging.

To put it another way, moving this driver out of staging is not as simple as moving the files; it requires real work to address the issues the subsystem maintainer has with this code.

Thanks for your detailed explanation, Russell.

#5 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

In reply to a message not in the archive
Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

This is based on the initial work done by Sascha Hauer and Tony Prisk.

It looks like you've also taken some of the suggestions I've made too - like the voltage drive and symbol transmit control settings.

It would be nice to identify the changes a bit better so that those of us who are testing your drivers (and have patches on top of them to make things work) know what's changed.

reviewer
#6 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 11 lines · Russell King - ARM Linux
Quoted 3 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

This is based on the initial work done by Sascha Hauer and Tony Prisk.

It looks like you've also taken some of the suggestions I've made too - like the voltage drive and symbol transmit control settings.

It would be nice to identify the changes a bit better so that those of us who are testing your drivers (and have patches on top of them to make things work) know what's changed.

Yes, I have been out the two past weeks and tried to capture all of your inputs concerning the HDMI driver.

Today I was able to get access to a wandboard solo and the HDMI image does look different compared to a wandboard quad board:

- The Linux logo penguins are steady on mx6q, but on mx6solo the contour lines look like they flicker.
- The kernel log text appears in good white colour with mx6q, but not so white on mx6solo (tending to green).

Even the U-boot HDMI splash screen is not very steady on mx6solo.

I will try to look at these mx6 solo HDMI issues.

Regards,

Fabio Estevam

reviewer
#7 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 11 lines · Fabio Estevam

Today I was able to get access to a wandboard solo and the HDMI image does look different compared to a wandboard quad board:

- The Linux logo penguins are steady on mx6q, but on mx6solo the contour lines look like they flicker.
- The kernel log text appears in good white colour with mx6q, but not so white on mx6solo (tending to green).

Even the U-boot HDMI splash screen is not very steady on mx6solo.

I will try to look at these mx6 solo HDMI issues.

With the change below I am able to get a good HDMI quality image on mx6solo (and mx6quad as well):

drivers/staging/imx-drm/ipuv3-crtc.c +1 -1
@@ -238,7 +238,7 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
                sig_cfg.Vsync_pol = 1;
 
        sig_cfg.enable_pol = 1;
-       sig_cfg.clk_pol = 0;
+       sig_cfg.clk_pol = 1;
        sig_cfg.width = mode->hdisplay;
        sig_cfg.height = mode->vdisplay;
        sig_cfg.pixel_fmt = out_pixel_fmt;

Regards,

Fabio Estevam

#8 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 10 lines · Fabio Estevam
Quoted 8 lines · Fabio Estevam

Today I was able to get access to a wandboard solo and the HDMI image does look different compared to a wandboard quad board:

- The Linux logo penguins are steady on mx6q, but on mx6solo the contour lines look like they flicker.
- The kernel log text appears in good white colour with mx6q, but not so white on mx6solo (tending to green).

Quoted 6 lines
Quoted 3 lines

Even the U-boot HDMI splash screen is not very steady on mx6solo.

I will try to look at these mx6 solo HDMI issues.

With the change below I am able to get a good HDMI quality image on mx6solo (and mx6quad as well):

Yes, I need that too on the Carrier-1 board, as suggested by Sascha.

#9 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

In reply to a message not in the archive

Review

Quoted 11 lines · Fabio Estevam
(quoted diff) +11 -0
+	/*Wait for PHY PLL lock */
+	msec = 4;
+	val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
+	while (!val) {
+		udelay(1000);
+		if (msec-- == 0) {
+			dev_dbg(hdmi->dev, "PHY PLL not locked\n");
+			return -EINVAL;
+		}
+		val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
+	}

This loop is not always sufficient for the PLL to always lock. It's also buggy because it behaves like this:

msec = 4
read register
check bit - still one?
yes - wait 1ms
msec == 0?
no - msec = 3
read register
... msec eventually msec = 0
read register
check bit - still one
yes - wait 1ms
msec == 0?
yes - print debug and exit

So the last wait for 1ms performs no real function other than to delay the inevitable exit. If we really want to wait 5ms for the condition we're testing to become true, then do it like this:

	msec = 5;
	do {
		val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
		if (!val)
			break;
 
		if (msec == 0) {
			dev_err(hdmi->dev, "PHY PLL not locked\n");
			return -EINVAL;
		}
 
		udelay(1000);
		msec--;
	} while (1);

This way, we check for the success condition immediately before checking for the failure condition, and only waiting after that.

I'd also suggest making it a dev_err() so that it's obvious when it doesn't lock - the current dev_dbg() remains hidden and causes failures which don't seem to be visible to the user via the logs. Hence why this issue has been overlooked...

Review

Quoted 12 lines
(quoted diff) +12 -0
+static void hdmi_av_composer(struct imx_hdmi *hdmi,
+			     const struct drm_display_mode *mode)
+{
+	u8 inv_val;
+	struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode;
+	int hblank, vblank, h_de_hs, v_de_vs, hsync_len, vsync_len;
+
+	vmode->mhsyncpolarity = !!(mode->flags & DRM_MODE_FLAG_PHSYNC);
+	vmode->mvsyncpolarity = !!(mode->flags & DRM_MODE_FLAG_PVSYNC);
+	vmode->minterlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
+	vmode->mpixelclock = mode->htotal * mode->vtotal *
+			     drm_mode_vrefresh(mode);

We can do better here:

	vmode->mpixelclock = mode->clock * 1000;

as the above is not quite correct when considering all the possibilities. Since we're given the pixel clock in the mode structure, we might as well make use it.

Review

Quoted 3 lines
(quoted diff) +3 -0
+	/* Set up VSYNC active edge delay (in pixel clks) */
+	vsync_len = mode->vsync_end - mode->vsync_start;
+	hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH);

Commentry - vsync len is in lines not pixel clocks.

Other than that, it seems to work here on the Carrier-1. Thanks.

#10 lore raw

PATCH v3 1/1 imx-drm: Add mx6 hdmi transmitter support

Quoted 1 line · Russell King - ARM Linux

Other than that, it seems to work here on the Carrier-1. Thanks.

Here's the remainder of my changes to the HDMI driver which are not part of your patch. I've dropped driverdevel and gregkh because this is really discussion between us at the moment.

#11 lore raw

PATCH 1/6 imx-drm: hdmi: fix PLL lock wait

In reply to Russell King - ARM Linux

Enabling the debug for PLL lock shows that this times out almost every time. Having such an event at debug level is probably a bug in itself because it hides this fact.

Waiting 5ms seems to allow it to lock. Also, adjust the loop so that we check for success before checking whether we've timed out: we don't want to wait and then fail without first checking whether we locked.

---
 drivers/staging/imx-drm/imx-hdmi.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +12 -8
index 2022635fffdf..ff00759b4d6f 100644
@@ -1032,16 +1032,20 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep,
 	imx_hdmi_phy_gen2_pddq(hdmi, 0);
 
 	/*Wait for PHY PLL lock */
-	msec = 4;
-	val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
-	while (!val) {
-		udelay(1000);
-		if (msec-- == 0) {
-			dev_dbg(hdmi->dev, "PHY PLL not locked\n");
+	msec = 5;
+	do {
+		val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
+		if (!val)
+			break;
+
+		if (msec == 0) {
+			dev_err(hdmi->dev, "PHY PLL not locked\n");
 			return -EINVAL;
 		}
-		val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK;
-	}
+
+		udelay(1000);
+		msec--;
+	} while (1);
 
 	return 0;
 }
Signature · 1 line
1.7.4.4
#12 lore raw

PATCH 2/6 imx-drm: hdmi: fix pixel clock

In reply to Russell King - ARM Linux

The correct pixel clock can be found in the drm_display_mode structure. Use this rather than trying to calculate it from the h/v total and the refresh rate, which can be inaccurate.

---
 drivers/staging/imx-drm/imx-hdmi.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +1 -2
index ff00759b4d6f..fe3a6779b620 100644
@@ -1206,8 +1206,7 @@ static void hdmi_av_composer(struct imx_hdmi *hdmi,
 	vmode->mhsyncpolarity = !!(mode->flags & DRM_MODE_FLAG_PHSYNC);
 	vmode->mvsyncpolarity = !!(mode->flags & DRM_MODE_FLAG_PVSYNC);
 	vmode->minterlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
-	vmode->mpixelclock = mode->htotal * mode->vtotal *
-			     drm_mode_vrefresh(mode);
+	vmode->mpixelclock = mode->clock * 1000;
 
 	dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock);
 
Signature · 1 line
1.7.4.4
#13 lore raw

PATCH 3/6 imx-drm: hdmi: fix wrong comment

In reply to Russell King - ARM Linux

The vsync active edge delay is in lines, not pixel clocks.

---
 drivers/staging/imx-drm/imx-hdmi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +1 -1
index fe3a6779b620..0cba5d4a9966 100644
@@ -1275,7 +1275,7 @@ static void hdmi_av_composer(struct imx_hdmi *hdmi,
 	hdmi_writeb(hdmi, hsync_len >> 8, HDMI_FC_HSYNCINWIDTH1);
 	hdmi_writeb(hdmi, hsync_len, HDMI_FC_HSYNCINWIDTH0);
 
-	/* Set up VSYNC active edge delay (in pixel clks) */
+	/* Set up VSYNC active edge delay (in lines) */
 	vsync_len = mode->vsync_end - mode->vsync_start;
 	hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH);
 }
Signature · 1 line
1.7.4.4
#14 lore raw

PATCH 4/6 imx-drm: hdmi: get rid of pointless fb_reg

In reply to Russell King - ARM Linux

fb_reg provides no real benefit to the driver: imx_hdmi_fb_registered() will never be called multiple times. Let's get rid of this.

---
 drivers/staging/imx-drm/imx-hdmi.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +0 -6
index 0cba5d4a9966..267d3c9114c6 100644
@@ -130,7 +130,6 @@ struct imx_hdmi {
 	int vic;
 
 	u8 edid[HDMI_EDID_LEN];
-	bool fb_reg;
 	bool cable_plugin;
 
 	bool phy_enabled;
@@ -1451,9 +1450,6 @@ static int imx_hdmi_fb_registered(struct imx_hdmi *hdmi)
 {
 	int ret;
 
-	if (hdmi->fb_reg)
-		return 0;
-
 	ret = clk_prepare_enable(hdmi->iahb_clk);
 	if (ret)
 		return ret;
@@ -1474,8 +1470,6 @@ static int imx_hdmi_fb_registered(struct imx_hdmi *hdmi)
 	/* Unmute interrupts */
 	hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
 
-	hdmi->fb_reg = true;
-
 	clk_disable_unprepare(hdmi->iahb_clk);
 
 	return 0;
Signature · 1 line
1.7.4.4
#15 lore raw

PATCH 5/6 imx-drm: hdmi: get rid of clk manipulations in imx_hdmi_fb_registered()

In reply to Russell King - ARM Linux

The clock manipulations do nothing for us: the clock is already enabled by the only caller (imx_hdmi_platform_probe()). Get rid of these and simplify the code.

---
 drivers/staging/imx-drm/imx-hdmi.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +0 -8
index 267d3c9114c6..1eb12c57aa3e 100644
@@ -1448,12 +1448,6 @@ static int imx_hdmi_setup(struct imx_hdmi *hdmi, struct drm_display_mode *mode)
 /* Wait until we are registered to enable interrupts */
 static int imx_hdmi_fb_registered(struct imx_hdmi *hdmi)
 {
-	int ret;
-
-	ret = clk_prepare_enable(hdmi->iahb_clk);
-	if (ret)
-		return ret;
-
 	hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL,
 		    HDMI_PHY_I2CM_INT_ADDR);
 
@@ -1470,8 +1464,6 @@ static int imx_hdmi_fb_registered(struct imx_hdmi *hdmi)
 	/* Unmute interrupts */
 	hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
 
-	clk_disable_unprepare(hdmi->iahb_clk);
-
 	return 0;
 }
 
Signature · 1 line
1.7.4.4
#16 lore raw

PATCH 6/6 imx-drm: hdmi: minor cleanups

In reply to Russell King - ARM Linux

Some minor cleanups to the HDMI driver.

---
 drivers/staging/imx-drm/imx-hdmi.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/imx-drm/imx-hdmi.c +2 -3
index 1eb12c57aa3e..ee0fceb7b5b2 100644
@@ -19,7 +19,6 @@
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
-
 #include <linux/of_device.h>
 
 #include <drm/drmP.h>
@@ -37,7 +36,7 @@
 #define YCBCR444		1
 #define YCBCR422_16BITS		2
 #define YCBCR422_8BITS		3
-#define	XVYCC444		4
+#define XVYCC444		4
 
 enum hdmi_datamap {
 	RGB444_8B = 0x01,
@@ -1762,8 +1761,8 @@ static int imx_hdmi_platform_probe(struct platform_device *pdev)
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *ddc_node;
 	struct imx_hdmi *hdmi;
-	int ret, irq;
 	struct resource *iores;
+	int ret, irq;
 
 	hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
 	if (!hdmi)
Signature · 1 line
1.7.4.4