@@ -569,12 +569,7 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
569569 return ;
570570 }
571571
572- /*
573- * The HSM rate needs to be slightly greater than the pixel clock, with
574- * a minimum of 108MHz.
575- * Use 101% as this is what the firmware uses.
576- */
577- hsm_rate = max_t (unsigned long , 108000000 , (pixel_rate / 100 ) * 101 );
572+ hsm_rate = vc4_hdmi -> variant -> calc_hsm_clock (vc4_hdmi , pixel_rate );
578573 ret = clk_set_rate (vc4_hdmi -> hsm_clock , hsm_rate );
579574 if (ret ) {
580575 DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret );
@@ -742,6 +737,28 @@ static u32 vc5_hdmi_get_hsm_clock(struct vc4_hdmi *vc4_hdmi)
742737 return 108000000 ;
743738}
744739
740+ static u32 vc4_hdmi_calc_hsm_clock (struct vc4_hdmi * vc4_hdmi , unsigned long pixel_rate )
741+ {
742+ /*
743+ * This is the rate that is set by the firmware. The number
744+ * needs to be a bit higher than the pixel clock rate
745+ * (generally 148.5Mhz).
746+ */
747+
748+ return 163682864 ;
749+ }
750+
751+ static u32 vc5_hdmi_calc_hsm_clock (struct vc4_hdmi * vc4_hdmi , unsigned long pixel_rate )
752+ {
753+ /*
754+ * The HSM rate needs to be slightly greater than the pixel clock, with
755+ * a minimum of 108MHz.
756+ * Use 101% as this is what the firmware uses.
757+ */
758+
759+ return max_t (unsigned long , 108000000 , (pixel_rate / 100 ) * 101 );
760+ }
761+
745762static u32 vc4_hdmi_channel_map (struct vc4_hdmi * vc4_hdmi , u32 channel_mask )
746763{
747764 int i ;
@@ -1737,6 +1754,7 @@ static const struct vc4_hdmi_variant bcm2835_variant = {
17371754 .phy_rng_enable = vc4_hdmi_phy_rng_enable ,
17381755 .phy_rng_disable = vc4_hdmi_phy_rng_disable ,
17391756 .get_hsm_clock = vc4_hdmi_get_hsm_clock ,
1757+ .calc_hsm_clock = vc4_hdmi_calc_hsm_clock ,
17401758 .channel_map = vc4_hdmi_channel_map ,
17411759};
17421760
@@ -1761,6 +1779,7 @@ static const struct vc4_hdmi_variant bcm2711_hdmi0_variant = {
17611779 .phy_rng_enable = vc5_hdmi_phy_rng_enable ,
17621780 .phy_rng_disable = vc5_hdmi_phy_rng_disable ,
17631781 .get_hsm_clock = vc5_hdmi_get_hsm_clock ,
1782+ .calc_hsm_clock = vc5_hdmi_calc_hsm_clock ,
17641783 .channel_map = vc5_hdmi_channel_map ,
17651784};
17661785
@@ -1785,6 +1804,7 @@ static const struct vc4_hdmi_variant bcm2711_hdmi1_variant = {
17851804 .phy_rng_enable = vc5_hdmi_phy_rng_enable ,
17861805 .phy_rng_disable = vc5_hdmi_phy_rng_disable ,
17871806 .get_hsm_clock = vc5_hdmi_get_hsm_clock ,
1807+ .calc_hsm_clock = vc5_hdmi_calc_hsm_clock ,
17881808 .channel_map = vc5_hdmi_channel_map ,
17891809};
17901810
0 commit comments