drm/edid: Introduce drm_default_rgb_quant_range()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 11 Jan 2017 14:18:35 +0000 (16:18 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 26 Jan 2017 16:37:13 +0000 (18:37 +0200)
Make the code selecting the RGB quantization range a little less magicy
by wrapping it up in a small helper.

v2: s/adjusted_mode/mode in vc4 to make it actually compile
v3: Add a comment proposed by Eric

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170111141835.25369-1-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/vc4/vc4_hdmi.c
include/drm/drm_edid.h

index 4ff04aa84dd068ad6874dec0e0fab98980a6676b..9d0a506fc8ff171a074bb82d22db8475a6a6dbb9 100644 (file)
@@ -3768,6 +3768,25 @@ bool drm_rgb_quant_range_selectable(struct edid *edid)
 }
 EXPORT_SYMBOL(drm_rgb_quant_range_selectable);
 
+/**
+ * drm_default_rgb_quant_range - default RGB quantization range
+ * @mode: display mode
+ *
+ * Determine the default RGB quantization range for the mode,
+ * as specified in CEA-861.
+ *
+ * Return: The default RGB quantization range for the mode
+ */
+enum hdmi_quantization_range
+drm_default_rgb_quant_range(const struct drm_display_mode *mode)
+{
+       /* All CEA modes other than VIC 1 use limited quantization range. */
+       return drm_match_cea_mode(mode) > 1 ?
+               HDMI_QUANTIZATION_RANGE_LIMITED :
+               HDMI_QUANTIZATION_RANGE_FULL;
+}
+EXPORT_SYMBOL(drm_default_rgb_quant_range);
+
 static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector,
                                           const u8 *hdmi)
 {
index fb12896bafee7af9683747ab4840045d7fb74c3b..be89aca0dbe8f971793d2c508e1ee26fcca61b6c 100644 (file)
@@ -1713,7 +1713,9 @@ found:
                 * VESA DisplayPort Ver.1.2a - 5.1.1.1 Video Colorimetry
                 */
                pipe_config->limited_color_range =
-                       bpp != 18 && drm_match_cea_mode(adjusted_mode) > 1;
+                       bpp != 18 &&
+                       drm_default_rgb_quant_range(adjusted_mode) ==
+                       HDMI_QUANTIZATION_RANGE_LIMITED;
        } else {
                pipe_config->limited_color_range =
                        intel_dp->limited_color_range;
index 0bcfead14571d76d61f640014d8f6d586164ffc4..19bd13f53729fd3f052453933681cdb3d36390bb 100644 (file)
@@ -1330,7 +1330,8 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
                /* See CEA-861-E - 5.1 Default Encoding Parameters */
                pipe_config->limited_color_range =
                        pipe_config->has_hdmi_sink &&
-                       drm_match_cea_mode(adjusted_mode) > 1;
+                       drm_default_rgb_quant_range(adjusted_mode) ==
+                       HDMI_QUANTIZATION_RANGE_LIMITED;
        } else {
                pipe_config->limited_color_range =
                        intel_hdmi->limited_color_range;
index c4cb2e26de32f06db0abf3fd94b3117c3292eed5..5d49bf9481624f0d62e1acf11959b9433cead5f4 100644 (file)
@@ -463,7 +463,9 @@ static void vc4_hdmi_encoder_mode_set(struct drm_encoder *encoder,
        csc_ctl = VC4_SET_FIELD(VC4_HD_CSC_CTL_ORDER_BGR,
                                VC4_HD_CSC_CTL_ORDER);
 
-       if (vc4_encoder->hdmi_monitor && drm_match_cea_mode(mode) > 1) {
+       if (vc4_encoder->hdmi_monitor &&
+           drm_default_rgb_quant_range(mode) ==
+           HDMI_QUANTIZATION_RANGE_LIMITED) {
                /* CEA VICs other than #1 requre limited range RGB
                 * output unless overridden by an AVI infoframe.
                 * Apply a colorspace conversion to squash 0-255 down
index 838eaf2b42e95335d4b7d537b7e5e0f4c1033bc7..25cdf5f7a0d866df72c12c64ed0295f9e1331cd2 100644 (file)
@@ -441,6 +441,8 @@ enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
 bool drm_detect_hdmi_monitor(struct edid *edid);
 bool drm_detect_monitor_audio(struct edid *edid);
 bool drm_rgb_quant_range_selectable(struct edid *edid);
+enum hdmi_quantization_range
+drm_default_rgb_quant_range(const struct drm_display_mode *mode);
 int drm_add_modes_noedid(struct drm_connector *connector,
                         int hdisplay, int vdisplay);
 void drm_set_preferred_mode(struct drm_connector *connector,