Skip to contentSkip to conversation

drm/i915/hdmi: Compute port_clock for 27.027 pixel replicated modes

PATCH In review [email protected] 3 participants 8 messages Sep 24, 2014 – Oct 8, 2014

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

PATCH 1/1 drm/i915/hdmi: Compute port_clock for 27.027 pixel replicated modes

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz. Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
 drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
index 29ec153..a0786d6 100644
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
 	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
 		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}
 	}
 
 	if (intel_hdmi->color_range)
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

Quoted 13 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
 drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
 	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
 		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
 	}
 
 	if (intel_hdmi->color_range)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
#2 lore raw
Quoted 10 lines · Ville Syrjälä
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

I didn't really drill down into the issue once I saw the WRPLL was being computed differently for 480i@60 and the port clock was being passed as 27026.

Quoted 15 lines
Quoted 15 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
  drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
  	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
  		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

I don't like using the 13MHz family in the mode table for this very reason. Maybe I should revisit the pixel clock setting and computation for pixel doubled modes in the i915 code.

Quoted 3 lines

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

What's the best way to enter into 12bpc mode? I tried to force the mode in hdmi_compute_config(), but I wasn't able to get output.

Quoted 4 lines

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

I had that on my TODO list and when I went to look at the modes (576i @200Hz) they were already correct. Magic happens!!

-Clint

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
  	}
 
  	if (intel_hdmi->color_range)
--

1.7.9.5

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

#3 lore raw
Quoted 45 lines · Clint Taylor
Quoted 10 lines · Ville Syrjälä
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

I didn't really drill down into the issue once I saw the WRPLL was being computed differently for 480i@60 and the port clock was being passed as 27026.

Quoted 15 lines
Quoted 15 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
  drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
  	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
  		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

Quoted 3 lines

I don't like using the 13MHz family in the mode table for this very reason. Maybe I should revisit the pixel clock setting and computation for pixel doubled modes in the i915 code.

That has certain appeal, but it will force userspace to adjust the clock for double clocked modes when it wants to calculate the refresh rate. I don't really like even exposing the DBLCLK flag to userspace since it's basically an internal implementation detail. Some of the modes also allow higher pixel repeat factors, and we have no way to inform userspace about those. So I think that forcing userspace to deal with the multiplied clock is not a good idea.

Quoted 7 lines
Quoted 4 lines

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

What's the best way to enter into 12bpc mode? I tried to force the mode in hdmi_compute_config(), but I wasn't able to get output.

Looks like our 12bpc suppor is pretty broken. I did manage to make it work on my IVB here but that was after I wrote several patches to fix things. I don't have time to clean those up right now, but if anyone else wants to work on that I can share them.

Quoted 22 lines
Quoted 5 lines

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

I had that on my TODO list and when I went to look at the modes (576i @200Hz) they were already correct. Magic happens!!

-Clint

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
  	}
 
  	if (intel_hdmi->color_range)
--

1.7.9.5

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

Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw
Quoted 63 lines · Ville Syrjälä
Quoted 45 lines · Clint Taylor
Quoted 10 lines · Ville Syrjälä
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

I didn't really drill down into the issue once I saw the WRPLL was being computed differently for 480i@60 and the port clock was being passed as 27026.

Quoted 15 lines
Quoted 15 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
   drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
   1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
   	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
   		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

Quoted 3 lines

I don't like using the 13MHz family in the mode table for this very reason. Maybe I should revisit the pixel clock setting and computation for pixel doubled modes in the i915 code.

That has certain appeal, but it will force userspace to adjust the clock for double clocked modes when it wants to calculate the refresh rate. I don't really like even exposing the DBLCLK flag to userspace since it's basically an internal implementation detail. Some of the modes also allow higher pixel repeat factors, and we have no way to inform userspace about those. So I think that forcing userspace to deal with the multiplied clock is not a good idea.

Quoted 5 lines
Quoted 4 lines

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

Quoted 7 lines
Quoted 2 lines

What's the best way to enter into 12bpc mode? I tried to force the mode in hdmi_compute_config(), but I wasn't able to get output.

Looks like our 12bpc suppor is pretty broken. I did manage to make it work on my IVB here but that was after I wrote several patches to fix things. I don't have time to clean those up right now, but if anyone else wants to work on that I can share them.

Send me the patches and I can look at the 12bpc support. My main concern with 12bpc is we don't automatically switch to 12 bit when the HDMI monitor supports it and nobody would take the time to manually switch to 12bpc using an x11 property every time they boot. I've never had an issue with sending Deep Color to a TV that supports it, but I'm also not ready to try and make it automatic in the driver.

-Clint

Quoted 24 lines
Quoted 23 lines
Quoted 6 lines

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

I had that on my TODO list and when I went to look at the modes (576i @200Hz) they were already correct. Magic happens!!

-Clint

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
   	}
 
   	if (intel_hdmi->color_range)
--

1.7.9.5

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

#5 lore raw
Quoted 72 lines · Clint Taylor
Quoted 63 lines · Ville Syrjälä
Quoted 45 lines · Clint Taylor
Quoted 10 lines · Ville Syrjälä
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

I didn't really drill down into the issue once I saw the WRPLL was being computed differently for 480i@60 and the port clock was being passed as 27026.

Quoted 15 lines
Quoted 15 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
   drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
   1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
   	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
   		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

Quoted 3 lines

I don't like using the 13MHz family in the mode table for this very reason. Maybe I should revisit the pixel clock setting and computation for pixel doubled modes in the i915 code.

That has certain appeal, but it will force userspace to adjust the clock for double clocked modes when it wants to calculate the refresh rate. I don't really like even exposing the DBLCLK flag to userspace since it's basically an internal implementation detail. Some of the modes also allow higher pixel repeat factors, and we have no way to inform userspace about those. So I think that forcing userspace to deal with the multiplied clock is not a good idea.

Quoted 5 lines
Quoted 4 lines

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

Quoted 7 lines
Quoted 2 lines

What's the best way to enter into 12bpc mode? I tried to force the mode in hdmi_compute_config(), but I wasn't able to get output.

Looks like our 12bpc suppor is pretty broken. I did manage to make it work on my IVB here but that was after I wrote several patches to fix things. I don't have time to clean those up right now, but if anyone else wants to work on that I can share them.

Quoted 6 lines

Send me the patches and I can look at the 12bpc support. My main concern with 12bpc is we don't automatically switch to 12 bit when the HDMI monitor supports it and nobody would take the time to manually switch to 12bpc using an x11 property every time they boot. I've never had an issue with sending Deep Color to a TV that supports it, but I'm also not ready to try and make it automatic in the driver.

We do it automagically but we make the decision based on the primary plane pixel format which is a bit silly considering there are sprites and whatnot to consider. Maybe we should just always go for deep color whenever possible? Anyway that's a separate topic.

I did manage to clean up the patches a bit while I had nothing else to do. I'll give them a quick spin and if they still work I'll toss them onto the mailing list.

Quoted 27 lines

-Clint

Quoted 24 lines
Quoted 23 lines
Quoted 6 lines

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

I had that on my TODO list and when I went to look at the modes (576i @200Hz) they were already correct. Magic happens!!

-Clint

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
   	}
 
   	if (intel_hdmi->color_range)
--

1.7.9.5

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

Signature · 2 lines
Ville Syrjälä
Intel OTC
#6 lore raw
Quoted 4 lines · Ville Syrjälä

We do it automagically but we make the decision based on the primary plane pixel format which is a bit silly considering there are sprites and whatnot to consider. Maybe we should just always go for deep color whenever possible? Anyway that's a separate topic.

Yes and yes. The one thing I'm not sure about (and why I haven't) submitted that patch is that I'm not sure about what do to with the dither bit on the different platforms.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
In reply to Ville Syrjälä
Quoted 39 lines · Ville Syrjälä
Quoted 6 lines · On Wed, Sep 24, 2014 at 03:49:39PM -0700, [email protected] wrote:

From: Clint Taylor <[email protected]>

port_clock was being incorrectly computed and WRPLL was incorrectly programmed for pixel doubled modes using a 27.027MHz pixel clock. port_clock was set to 27.026 resulting in an output pixel clock matching 27.000MHz.

I don't understand how this 27.000MHz clock would come about. Can you explain further?

Quoted 13 lines

Since there is no way to correctly half the 27.027 frequency as an integer just set port_clock to 27027 for these modes.

---
  drivers/gpu/drm/i915/intel_hdmi.c |    5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 29ec153..a0786d6 100644

drivers/gpu/drm/i915/intel_hdmi.c bool intel_hdmi_compute_config(struct intel_encoder *encoder, · line 940

Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -0
@@ -933,6 +933,11 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
 
  	if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) {
  		pipe_config->pixel_multiplier = 2;
+
+		/* Fix up port_clock since 27027 is not divisible by 2 */
+		if (pipe_config->adjusted_mode.crtc_clock == 13513) {
+			pipe_config->port_clock = 27027;
+		}

Ugh. Oh well I suppose we'll want to be as accurate as possible. Would be nice if would could someone do this fixup already in drm core, but that would probably require changing to smaller clock units all over the place which doesn't sound fun at all. So I guess we get to leave the kludge in the driver :(

Quoted 6 lines

This also got me thinking about the 12bpc case as well. It's clearly busted with double clocked modes now. Care to fix that up as well?

PS. did you ever send that separate patch to fix up the interlace flags in some of the double clocked modes? I don't remember seeing such a patch at least.

Actually I just checked again and it was the 576i@100Hz modes and they are still incorrect. Let me send out the patch.

Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
  	}
 
  	if (intel_hdmi->color_range)
--

1.7.9.5

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