diff options
| -rw-r--r-- | drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index dda904ec0534..c12f9bd12904 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | |||
| @@ -208,8 +208,27 @@ static int sun4i_hdmi_get_modes(struct drm_connector *connector) | |||
| 208 | return ret; | 208 | return ret; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | static int sun4i_hdmi_mode_valid(struct drm_connector *connector, | ||
| 212 | struct drm_display_mode *mode) | ||
| 213 | { | ||
| 214 | struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector); | ||
| 215 | long rate = mode->clock * 1000; | ||
| 216 | long diff = rate / 200; /* +-0.5% allowed by HDMI spec */ | ||
| 217 | long rounded_rate; | ||
| 218 | |||
| 219 | /* 165 MHz is the typical max pixelclock frequency for HDMI <= 1.2 */ | ||
| 220 | if (rate > 165000000) | ||
| 221 | return MODE_CLOCK_HIGH; | ||
| 222 | rounded_rate = clk_round_rate(hdmi->tmds_clk, rate); | ||
| 223 | if (max(rounded_rate, rate) - min(rounded_rate, rate) < diff && | ||
| 224 | rounded_rate > 0) | ||
| 225 | return MODE_OK; | ||
| 226 | return MODE_NOCLOCK; | ||
| 227 | } | ||
| 228 | |||
| 211 | static const struct drm_connector_helper_funcs sun4i_hdmi_connector_helper_funcs = { | 229 | static const struct drm_connector_helper_funcs sun4i_hdmi_connector_helper_funcs = { |
| 212 | .get_modes = sun4i_hdmi_get_modes, | 230 | .get_modes = sun4i_hdmi_get_modes, |
| 231 | .mode_valid = sun4i_hdmi_mode_valid, | ||
| 213 | }; | 232 | }; |
| 214 | 233 | ||
| 215 | static enum drm_connector_status | 234 | static enum drm_connector_status |
