Skip to content

Commit df5711c

Browse files
Zheng Yangrkhuangtao
authored andcommitted
drm/rockchip: dw-hdmi: set default color depth to 8 bit
If color depth is automatic, it is same as 8bit. If tmdsclk > max_tmds_clock, fall back to 8bit. Change-Id: Ia8cbf5206831ef99456ae59add94c6f8b5a33380 Signed-off-by: Zheng Yang <zhengyang@rock-chips.com>
1 parent 79d6c71 commit df5711c

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ dw_hdmi_rockchip_select_output(struct drm_connector_state *conn_state,
624624
struct hdr_static_metadata *hdr_metadata;
625625
u32 vic = drm_match_cea_mode(mode);
626626
unsigned long tmdsclock, pixclock = mode->crtc_clock;
627+
bool support_dc = false;
628+
u32 max_tmds_clock = info->max_tmds_clock;
627629

628630
*color_format = DRM_HDMI_OUTPUT_DEFAULT_RGB;
629631

@@ -664,21 +666,22 @@ dw_hdmi_rockchip_select_output(struct drm_connector_state *conn_state,
664666
break;
665667
}
666668

669+
if (*color_format == DRM_HDMI_OUTPUT_DEFAULT_RGB &&
670+
info->edid_hdmi_dc_modes & DRM_EDID_HDMI_DC_30)
671+
support_dc = true;
667672
if (*color_format == DRM_HDMI_OUTPUT_YCBCR444 &&
668-
!(info->edid_hdmi_dc_modes & DRM_EDID_HDMI_DC_Y444))
669-
*color_depth = 8;
670-
else if (!hdmi->colordepth)
671-
*color_depth = info->bpc;
672-
else
673-
*color_depth = hdmi->colordepth;
674-
675-
/* Color depth on rockchip platform is limited up to 10bit */
676-
if (*color_depth > 10) {
673+
info->edid_hdmi_dc_modes & (DRM_EDID_HDMI_DC_Y444 | DRM_EDID_HDMI_DC_30))
674+
support_dc = true;
675+
if (*color_format == DRM_HDMI_OUTPUT_YCBCR422)
676+
support_dc = true;
677+
if (*color_format == DRM_HDMI_OUTPUT_YCBCR420 &&
678+
info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30)
679+
support_dc = true;
680+
681+
if (hdmi->colordepth > 8 && support_dc)
677682
*color_depth = 10;
678-
if (*color_format == DRM_HDMI_OUTPUT_YCBCR420 &&
679-
!(info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30))
680-
*color_depth = 8;
681-
}
683+
else
684+
*color_depth = 8;
682685

683686
*eotf = TRADITIONAL_GAMMA_SDR;
684687
if (conn_state->hdr_source_metadata_blob_ptr) {
@@ -695,7 +698,7 @@ dw_hdmi_rockchip_select_output(struct drm_connector_state *conn_state,
695698
info->hdmi.colorimetry & (BIT(6) | BIT(7))))
696699
*enc_out_encoding = V4L2_YCBCR_ENC_BT2020;
697700
else if ((vic == 6) || (vic == 7) || (vic == 21) || (vic == 22) ||
698-
(vic == 2) || (vic == 3) || (vic == 17) || (vic == 18))
701+
(vic == 2) || (vic == 3) || (vic == 17) || (vic == 18))
699702
*enc_out_encoding = V4L2_YCBCR_ENC_601;
700703
else
701704
*enc_out_encoding = V4L2_YCBCR_ENC_709;
@@ -721,16 +724,15 @@ dw_hdmi_rockchip_select_output(struct drm_connector_state *conn_state,
721724

722725
if (*color_format == DRM_HDMI_OUTPUT_YCBCR420)
723726
tmdsclock /= 2;
724-
/*
725-
* For some display device, max_tmds_clock is 0, we think
726-
* max_tmds_clock is 340MHz. If tmdsclock > max_tmds_clock,
727-
* fallback to 8bit. If mode support YCBCR420, use YCBCR420.
728-
*/
729-
if ((!info->max_tmds_clock && tmdsclock > 340000) ||
730-
(info->max_tmds_clock && tmdsclock > info->max_tmds_clock) ||
731-
hdmi->dev_type == RK3368_HDMI) {
727+
728+
/* XXX: max_tmds_clock of some sink is 0, we think it is 340MHz. */
729+
if (!max_tmds_clock)
730+
max_tmds_clock = 340000;
731+
732+
if (tmdsclock > max_tmds_clock) {
732733
*color_depth = 8;
733-
if (drm_mode_is_420(info, mode))
734+
if (tmdsclock > 340000 && drm_mode_is_420(info, mode) &&
735+
(max_tmds_clock <= 340000 || hdmi->dev_type == RK3368_HDMI))
734736
*color_format = DRM_HDMI_OUTPUT_YCBCR420;
735737
}
736738
}

0 commit comments

Comments
 (0)