drm/edid: Add display_info.rgb_quant_range_selectable
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 8 Jan 2019 17:28:28 +0000 (19:28 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 10 Jan 2019 17:01:06 +0000 (19:01 +0200)
Move the CEA-861 QS bit handling entirely into the edid code. No
need to bother the drivers with this.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Eric Anholt <eric@anholt.net> (supporter:DRM DRIVERS FOR VC4)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20190108172828.15184-4-ville.syrjala@linux.intel.com
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lspcon.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/radeon/radeon_audio.c
drivers/gpu/drm/vc4/vc4_hdmi.c
include/drm/drm_connector.h
include/drm/drm_edid.h

index cd25bd08bf53278c7a1762637661f6bdcb3683c4..990b1909f9d721f276e2a257afe8efe9de8376e0 100644 (file)
@@ -3641,6 +3641,20 @@ static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
        return oui == HDMI_FORUM_IEEE_OUI;
 }
 
+static bool cea_db_is_vcdb(const u8 *db)
+{
+       if (cea_db_tag(db) != USE_EXTENDED_TAG)
+               return false;
+
+       if (cea_db_payload_len(db) != 2)
+               return false;
+
+       if (cea_db_extended_tag(db) != EXT_VIDEO_CAPABILITY_BLOCK)
+               return false;
+
+       return true;
+}
+
 static bool cea_db_is_y420cmdb(const u8 *db)
 {
        if (cea_db_tag(db) != USE_EXTENDED_TAG)
@@ -4223,41 +4237,6 @@ end:
 }
 EXPORT_SYMBOL(drm_detect_monitor_audio);
 
-/**
- * drm_rgb_quant_range_selectable - is RGB quantization range selectable?
- * @edid: EDID block to scan
- *
- * Check whether the monitor reports the RGB quantization range selection
- * as supported. The AVI infoframe can then be used to inform the monitor
- * which quantization range (full or limited) is used.
- *
- * Return: True if the RGB quantization range is selectable, false otherwise.
- */
-bool drm_rgb_quant_range_selectable(struct edid *edid)
-{
-       u8 *edid_ext;
-       int i, start, end;
-
-       edid_ext = drm_find_cea_extension(edid);
-       if (!edid_ext)
-               return false;
-
-       if (cea_db_offsets(edid_ext, &start, &end))
-               return false;
-
-       for_each_cea_db(edid_ext, i, start, end) {
-               if (cea_db_tag(&edid_ext[i]) == USE_EXTENDED_TAG &&
-                   cea_db_payload_len(&edid_ext[i]) == 2 &&
-                   cea_db_extended_tag(&edid_ext[i]) ==
-                       EXT_VIDEO_CAPABILITY_BLOCK) {
-                       DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", edid_ext[i + 2]);
-                       return edid_ext[i + 2] & EDID_CEA_VCDB_QS;
-               }
-       }
-
-       return false;
-}
-EXPORT_SYMBOL(drm_rgb_quant_range_selectable);
 
 /**
  * drm_default_rgb_quant_range - default RGB quantization range
@@ -4278,6 +4257,16 @@ drm_default_rgb_quant_range(const struct drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_default_rgb_quant_range);
 
+static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db)
+{
+       struct drm_display_info *info = &connector->display_info;
+
+       DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", db[2]);
+
+       if (db[2] & EDID_CEA_VCDB_QS)
+               info->rgb_quant_range_selectable = true;
+}
+
 static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector,
                                               const u8 *db)
 {
@@ -4452,6 +4441,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
                        drm_parse_hdmi_forum_vsdb(connector, db);
                if (cea_db_is_y420cmdb(db))
                        drm_parse_y420cmdb_bitmap(connector, db);
+               if (cea_db_is_vcdb(db))
+                       drm_parse_vcdb(connector, db);
        }
 }
 
@@ -4472,6 +4463,7 @@ drm_reset_display_info(struct drm_connector *connector)
        info->max_tmds_clock = 0;
        info->dvi_dual = false;
        info->has_hdmi_infoframe = false;
+       info->rgb_quant_range_selectable = false;
        memset(&info->hdmi, 0, sizeof(info->hdmi));
 
        info->non_desktop = 0;
@@ -4939,15 +4931,15 @@ EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
  * @connector: the connector
  * @mode: DRM display mode
  * @rgb_quant_range: RGB quantization range (Q)
- * @rgb_quant_range_selectable: Sink support selectable RGB quantization range (QS)
  */
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
                                   struct drm_connector *connector,
                                   const struct drm_display_mode *mode,
-                                  enum hdmi_quantization_range rgb_quant_range,
-                                  bool rgb_quant_range_selectable)
+                                  enum hdmi_quantization_range rgb_quant_range)
 {
+       const struct drm_display_info *info = &connector->display_info;
+
        /*
         * CEA-861:
         * "A Source shall not send a non-zero Q value that does not correspond
@@ -4958,7 +4950,7 @@ drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
         * HDMI 2.0 recommends sending non-zero Q when it does match the
         * default RGB quantization range for the mode, even when QS=0.
         */
-       if (rgb_quant_range_selectable ||
+       if (info->rgb_quant_range_selectable ||
            rgb_quant_range == drm_default_rgb_quant_range(mode))
                frame->quantization_range = rgb_quant_range;
        else
index a7d9ac9121259685df03273726a1ad4e70e376ca..153ee47d9c03de4dc9781277542f30cf4173388e 100644 (file)
@@ -1057,7 +1057,6 @@ struct intel_hdmi {
        } dp_dual_mode;
        bool has_hdmi_sink;
        bool has_audio;
-       bool rgb_quant_range_selectable;
        struct intel_connector *attached_connector;
        struct cec_notifier *cec_notifier;
 };
index 8a260bd6954c228a8c075f6686c26befe6385cef..4d264e577e3b25fa11ee8dc1b3a4d07087aebfc2 100644 (file)
@@ -462,7 +462,6 @@ static void intel_hdmi_set_avi_infoframe(struct intel_encoder *encoder,
                                         const struct intel_crtc_state *crtc_state,
                                         const struct drm_connector_state *conn_state)
 {
-       struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
        const struct drm_display_mode *adjusted_mode =
                &crtc_state->base.adjusted_mode;
        union hdmi_infoframe frame;
@@ -488,8 +487,7 @@ static void intel_hdmi_set_avi_infoframe(struct intel_encoder *encoder,
                                           adjusted_mode,
                                           crtc_state->limited_color_range ?
                                           HDMI_QUANTIZATION_RANGE_LIMITED :
-                                          HDMI_QUANTIZATION_RANGE_FULL,
-                                          intel_hdmi->rgb_quant_range_selectable);
+                                          HDMI_QUANTIZATION_RANGE_FULL);
 
        drm_hdmi_avi_infoframe_content_type(&frame.avi,
                                            conn_state);
@@ -1816,7 +1814,6 @@ intel_hdmi_unset_edid(struct drm_connector *connector)
 
        intel_hdmi->has_hdmi_sink = false;
        intel_hdmi->has_audio = false;
-       intel_hdmi->rgb_quant_range_selectable = false;
 
        intel_hdmi->dp_dual_mode.type = DRM_DP_DUAL_MODE_NONE;
        intel_hdmi->dp_dual_mode.max_tmds_clock = 0;
@@ -1900,9 +1897,6 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 
        to_intel_connector(connector)->detect_edid = edid;
        if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
-               intel_hdmi->rgb_quant_range_selectable =
-                       drm_rgb_quant_range_selectable(edid);
-
                intel_hdmi->has_audio = drm_detect_monitor_audio(edid);
                intel_hdmi->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
 
index c18f14d41f1d1f2391af3e9ae60a268e4a7808f8..7d15be5932e01f07f1f7a6bf42d710b760a9f8b9 100644 (file)
@@ -492,8 +492,7 @@ void lspcon_set_infoframes(struct intel_encoder *encoder,
                                           adjusted_mode,
                                           crtc_state->limited_color_range ?
                                           HDMI_QUANTIZATION_RANGE_LIMITED :
-                                          HDMI_QUANTIZATION_RANGE_FULL,
-                                          false);
+                                          HDMI_QUANTIZATION_RANGE_FULL);
 
        ret = hdmi_infoframe_pack(&frame, buf, sizeof(buf));
        if (ret < 0) {
index 9c16e273fb8d36b5fbfd3158c6d85234eea93c54..669fa9faad70e996e6257fbc18450dfab6299ab5 100644 (file)
@@ -103,7 +103,6 @@ struct intel_sdvo {
 
        bool has_hdmi_monitor;
        bool has_hdmi_audio;
-       bool rgb_quant_range_selectable;
 
        /* DDC bus used by this SDVO encoder */
        uint8_t ddc_bus;
@@ -1004,8 +1003,7 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo,
                                           adjusted_mode,
                                           pipe_config->limited_color_range ?
                                           HDMI_QUANTIZATION_RANGE_LIMITED :
-                                          HDMI_QUANTIZATION_RANGE_FULL,
-                                          intel_sdvo->rgb_quant_range_selectable);
+                                          HDMI_QUANTIZATION_RANGE_FULL);
 
        len = hdmi_infoframe_pack(&frame, sdvo_data, sizeof(sdvo_data));
        if (len < 0)
@@ -1805,8 +1803,6 @@ intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
                        if (intel_sdvo_connector->is_hdmi) {
                                intel_sdvo->has_hdmi_monitor = drm_detect_hdmi_monitor(edid);
                                intel_sdvo->has_hdmi_audio = drm_detect_monitor_audio(edid);
-                               intel_sdvo->rgb_quant_range_selectable =
-                                       drm_rgb_quant_range_selectable(edid);
                        }
                } else
                        status = connector_status_disconnected;
@@ -1855,7 +1851,6 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
 
        intel_sdvo->has_hdmi_monitor = false;
        intel_sdvo->has_hdmi_audio = false;
-       intel_sdvo->rgb_quant_range_selectable = false;
 
        if ((intel_sdvo_connector->output_flag & response) == 0)
                ret = connector_status_disconnected;
index 708765bf9e66c7d0db362ff0b6a9ee405113c20d..96f71114237a869e7fa7d92068f3916712511ee2 100644 (file)
@@ -526,8 +526,7 @@ static int radeon_audio_set_avi_packet(struct drm_encoder *encoder,
                drm_hdmi_avi_infoframe_quant_range(&frame, connector, mode,
                                                   radeon_encoder->output_csc == RADEON_OUTPUT_CSC_TVRGB ?
                                                   HDMI_QUANTIZATION_RANGE_LIMITED :
-                                                  HDMI_QUANTIZATION_RANGE_FULL,
-                                                  drm_rgb_quant_range_selectable(radeon_connector_edid(connector)));
+                                                  HDMI_QUANTIZATION_RANGE_FULL);
        }
 
        err = hdmi_avi_infoframe_pack(&frame, buffer, sizeof(buffer));
index 4f9a80f7f2427134dbe78d883a9821ee5b8044cc..051b61b62541f1701750c5f1a01e0ffd36df4435 100644 (file)
@@ -109,7 +109,6 @@ struct vc4_hdmi_encoder {
        struct vc4_encoder base;
        bool hdmi_monitor;
        bool limited_rgb_range;
-       bool rgb_range_selectable;
 };
 
 static inline struct vc4_hdmi_encoder *
@@ -280,11 +279,6 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector)
 
        vc4_encoder->hdmi_monitor = drm_detect_hdmi_monitor(edid);
 
-       if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
-               vc4_encoder->rgb_range_selectable =
-                       drm_rgb_quant_range_selectable(edid);
-       }
-
        drm_connector_update_edid_property(connector, edid);
        ret = drm_add_edid_modes(connector, edid);
        kfree(edid);
@@ -435,8 +429,7 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
                                           hdmi->connector, mode,
                                           vc4_encoder->limited_rgb_range ?
                                           HDMI_QUANTIZATION_RANGE_LIMITED :
-                                          HDMI_QUANTIZATION_RANGE_FULL,
-                                          vc4_encoder->rgb_range_selectable);
+                                          HDMI_QUANTIZATION_RANGE_FULL);
 
        frame.avi.right_bar = cstate->tv.margins.right;
        frame.avi.left_bar = cstate->tv.margins.left;
index 594f8d33a61f7d783b4f81f39290c9e232b2eb9d..e8ad30d7561afe7948bebcd8215a0ae03576b04b 100644 (file)
@@ -365,6 +365,12 @@ struct drm_display_info {
         */
        bool has_hdmi_infoframe;
 
+       /**
+        * @rgb_quant_range_selectable: Does the sink support selecting
+        * the RGB quantization range?
+        */
+       bool rgb_quant_range_selectable;
+
        /**
         * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
         * more stuff redundant with @bus_formats.
index 9db6f130df65b30ec679216a9d2a6aaab0691eb6..8dc1a081fb36d112e950fbdb80444470b43bb391 100644 (file)
@@ -362,8 +362,7 @@ void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
                                   struct drm_connector *connector,
                                   const struct drm_display_mode *mode,
-                                  enum hdmi_quantization_range rgb_quant_range,
-                                  bool rgb_quant_range_selectable);
+                                  enum hdmi_quantization_range rgb_quant_range);
 
 /**
  * drm_eld_mnl - Get ELD monitor name length in bytes.
@@ -471,7 +470,6 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
 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,