Commit eacba74d authored by Werner Sembach's avatar Werner Sembach Committed by Ville Syrjälä

drm/i915/display: New function to avoid duplicate code in upcomming commits

Moves some checks that later will be performed 2 times to an own function.
This avoids duplicate code later on.
Signed-off-by: default avatarWerner Sembach <wse@tuxedocomputers.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210510133349.14491-2-wse@tuxedocomputers.com
parent 5a9d38b2
...@@ -1863,6 +1863,32 @@ static int intel_hdmi_port_clock(int clock, int bpc) ...@@ -1863,6 +1863,32 @@ static int intel_hdmi_port_clock(int clock, int bpc)
return clock * bpc / 8; return clock * bpc / 8;
} }
static enum drm_mode_status
intel_hdmi_mode_clock_valid(struct intel_hdmi *hdmi, int clock, bool has_hdmi_sink)
{
struct drm_device *dev = intel_hdmi_to_dev(hdmi);
struct drm_i915_private *dev_priv = to_i915(dev);
enum drm_mode_status status;
/* check if we can do 8bpc */
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 8),
true, has_hdmi_sink);
if (has_hdmi_sink) {
/* if we can't do 8bpc we may still be able to do 12bpc */
if (status != MODE_OK && !HAS_GMCH(dev_priv))
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 12),
true, has_hdmi_sink);
/* if we can't do 8,12bpc we may still be able to do 10bpc */
if (status != MODE_OK && DISPLAY_VER(dev_priv) >= 11)
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 10),
true, has_hdmi_sink);
}
return status;
}
static enum drm_mode_status static enum drm_mode_status
intel_hdmi_mode_valid(struct drm_connector *connector, intel_hdmi_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode) struct drm_display_mode *mode)
...@@ -1893,21 +1919,7 @@ intel_hdmi_mode_valid(struct drm_connector *connector, ...@@ -1893,21 +1919,7 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
if (drm_mode_is_420_only(&connector->display_info, mode)) if (drm_mode_is_420_only(&connector->display_info, mode))
clock /= 2; clock /= 2;
/* check if we can do 8bpc */ status = intel_hdmi_mode_clock_valid(hdmi, clock, has_hdmi_sink);
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 8),
true, has_hdmi_sink);
if (has_hdmi_sink) {
/* if we can't do 8bpc we may still be able to do 12bpc */
if (status != MODE_OK && !HAS_GMCH(dev_priv))
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 12),
true, has_hdmi_sink);
/* if we can't do 8,12bpc we may still be able to do 10bpc */
if (status != MODE_OK && DISPLAY_VER(dev_priv) >= 11)
status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 10),
true, has_hdmi_sink);
}
if (status != MODE_OK) if (status != MODE_OK)
return status; return status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment