drm/radeon: setup quantization_range in AVI infoframe
authorAlex Deucher <alexander.deucher@amd.com>
Mon, 23 Feb 2015 22:14:47 +0000 (17:14 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 19 Mar 2015 16:26:26 +0000 (12:26 -0400)
If the display supports selectable range, set the range
based on what the user has selected for output csc.

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=83226

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_audio.c

index b21ef69a34ac2a2703f7adad0ee20a15f07d3509..48d49e651a30cf94212fe2b4482178e7870ed029 100644 (file)
@@ -520,16 +520,40 @@ static int radeon_audio_set_avi_packet(struct drm_encoder *encoder,
        struct radeon_device *rdev = encoder->dev->dev_private;
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
        struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+       struct drm_connector *connector;
+       struct radeon_connector *radeon_connector = NULL;
        u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
        struct hdmi_avi_infoframe frame;
        int err;
 
+       list_for_each_entry(connector,
+               &encoder->dev->mode_config.connector_list, head) {
+               if (connector->encoder == encoder) {
+                       radeon_connector = to_radeon_connector(connector);
+                       break;
+               }
+       }
+
+       if (!radeon_connector) {
+               DRM_ERROR("Couldn't find encoder's connector\n");
+               return -ENOENT;
+       }
+
        err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode);
        if (err < 0) {
                DRM_ERROR("failed to setup AVI infoframe: %d\n", err);
                return err;
        }
 
+       if (drm_rgb_quant_range_selectable(radeon_connector_edid(connector))) {
+               if (radeon_encoder->output_csc == RADEON_OUTPUT_CSC_TVRGB)
+                       frame.quantization_range = HDMI_QUANTIZATION_RANGE_LIMITED;
+               else
+                       frame.quantization_range = HDMI_QUANTIZATION_RANGE_FULL;
+       } else {
+               frame.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT;
+       }
+
        err = hdmi_avi_infoframe_pack(&frame, buffer, sizeof(buffer));
        if (err < 0) {
                DRM_ERROR("failed to pack AVI infoframe: %d\n", err);