drm/edid: Introduce drm_hdmi_avi_infoframe_quant_range()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 11 Jan 2017 12:57:23 +0000 (14:57 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 26 Jan 2017 16:37:13 +0000 (18:37 +0200)
Pull the logic to populate the quantization range information
in the AVI infoframe into a small helper. We'll be adding a bit
more logic to it, and having it in a central place seems like a
good idea since it's based on the CEA-861 spec.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170111125725.8086-4-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_hdmi.c
drivers/gpu/drm/vc4/vc4_hdmi.c
include/drm/drm_edid.h

index 9d0a506fc8ff171a074bb82d22db8475a6a6dbb9..bca73a80f156ec4b1dca7696fd00e7a2b479f3a9 100644 (file)
@@ -4292,6 +4292,32 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 }
 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
 
+/**
+ * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
+ *                                        quantization range information
+ * @frame: HDMI AVI infoframe
+ * @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,
+                                  enum hdmi_quantization_range rgb_quant_range,
+                                  bool rgb_quant_range_selectable)
+{
+       /*
+        * CEA-861:
+        * "A Source shall not send a non-zero Q value that does not correspond
+        *  to the default RGB Quantization Range for the transmitted Picture
+        *  unless the Sink indicates support for the Q bit in a Video
+        *  Capabilities Data Block."
+        */
+       if (rgb_quant_range_selectable)
+               frame->quantization_range = rgb_quant_range;
+       else
+               frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT;
+}
+EXPORT_SYMBOL(drm_hdmi_avi_infoframe_quant_range);
+
 static enum hdmi_3d_structure
 s3d_structure_from_display_mode(const struct drm_display_mode *mode)
 {
index 19bd13f53729fd3f052453933681cdb3d36390bb..351f837b09a04d23f8309503715bb21799fe82c4 100644 (file)
@@ -465,14 +465,11 @@ static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder,
                return;
        }
 
-       if (intel_hdmi->rgb_quant_range_selectable) {
-               if (crtc_state->limited_color_range)
-                       frame.avi.quantization_range =
-                               HDMI_QUANTIZATION_RANGE_LIMITED;
-               else
-                       frame.avi.quantization_range =
-                               HDMI_QUANTIZATION_RANGE_FULL;
-       }
+       drm_hdmi_avi_infoframe_quant_range(&frame.avi,
+                                          crtc_state->limited_color_range ?
+                                          HDMI_QUANTIZATION_RANGE_LIMITED :
+                                          HDMI_QUANTIZATION_RANGE_FULL,
+                                          intel_hdmi->rgb_quant_range_selectable);
 
        intel_write_infoframe(encoder, crtc_state, &frame);
 }
index 5d49bf9481624f0d62e1acf11959b9433cead5f4..87b59469b606d08fb631e5e34b5bdc9c2732d634 100644 (file)
@@ -356,15 +356,11 @@ static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
                return;
        }
 
-       if (vc4_encoder->rgb_range_selectable) {
-               if (vc4_encoder->limited_rgb_range) {
-                       frame.avi.quantization_range =
-                               HDMI_QUANTIZATION_RANGE_LIMITED;
-               } else {
-                       frame.avi.quantization_range =
-                               HDMI_QUANTIZATION_RANGE_FULL;
-               }
-       }
+       drm_hdmi_avi_infoframe_quant_range(&frame.avi,
+                                          vc4_encoder->limited_rgb_range ?
+                                          HDMI_QUANTIZATION_RANGE_LIMITED :
+                                          HDMI_QUANTIZATION_RANGE_FULL,
+                                          vc4_encoder->rgb_range_selectable);
 
        vc4_hdmi_write_infoframe(encoder, &frame);
 }
index 25cdf5f7a0d866df72c12c64ed0295f9e1331cd2..cfad4d89589f438c55818a441eb2395e1d0e76d1 100644 (file)
@@ -345,6 +345,10 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 int
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
                                            const struct drm_display_mode *mode);
+void
+drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
+                                  enum hdmi_quantization_range rgb_quant_range,
+                                  bool rgb_quant_range_selectable);
 
 /**
  * drm_eld_mnl - Get ELD monitor name length in bytes.