提交 5df3196b 编写于 作者: A Alex Deucher

drm/radeon: store the encoder in the radeon_crtc

This saves lots of lookups later.
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 19eca43e
...@@ -83,25 +83,19 @@ static void atombios_scaler_setup(struct drm_crtc *crtc) ...@@ -83,25 +83,19 @@ static void atombios_scaler_setup(struct drm_crtc *crtc)
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
ENABLE_SCALER_PS_ALLOCATION args; ENABLE_SCALER_PS_ALLOCATION args;
int index = GetIndexIntoMasterTable(COMMAND, EnableScaler); int index = GetIndexIntoMasterTable(COMMAND, EnableScaler);
struct radeon_encoder *radeon_encoder =
to_radeon_encoder(radeon_crtc->encoder);
/* fixme - fill in enc_priv for atom dac */ /* fixme - fill in enc_priv for atom dac */
enum radeon_tv_std tv_std = TV_STD_NTSC; enum radeon_tv_std tv_std = TV_STD_NTSC;
bool is_tv = false, is_cv = false; bool is_tv = false, is_cv = false;
struct drm_encoder *encoder;
if (!ASIC_IS_AVIVO(rdev) && radeon_crtc->crtc_id) if (!ASIC_IS_AVIVO(rdev) && radeon_crtc->crtc_id)
return; return;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { if (radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT) {
/* find tv std */ struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv;
if (encoder->crtc == crtc) { tv_std = tv_dac->tv_std;
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); is_tv = true;
if (radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT) {
struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv;
tv_std = tv_dac->tv_std;
is_tv = true;
}
}
} }
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
...@@ -538,14 +532,14 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc, ...@@ -538,14 +532,14 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder = NULL; struct drm_encoder *encoder = radeon_crtc->encoder;
struct radeon_encoder *radeon_encoder = NULL; struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
struct drm_connector *connector = NULL; struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
u32 adjusted_clock = mode->clock; u32 adjusted_clock = mode->clock;
int encoder_mode = 0; int encoder_mode = atombios_get_encoder_mode(encoder);
u32 dp_clock = mode->clock; u32 dp_clock = mode->clock;
int bpc = 8; int bpc = radeon_get_monitor_bpc(connector);
bool is_duallink = false; bool is_duallink = radeon_dig_monitor_is_duallink(encoder, mode->clock);
/* reset the pll flags */ /* reset the pll flags */
radeon_crtc->pll_flags = 0; radeon_crtc->pll_flags = 0;
...@@ -576,54 +570,44 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc, ...@@ -576,54 +570,44 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
radeon_crtc->pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV; radeon_crtc->pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
} }
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
if (encoder->crtc == crtc) { (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
radeon_encoder = to_radeon_encoder(encoder); if (connector) {
connector = radeon_get_connector_for_encoder(encoder); struct radeon_connector *radeon_connector = to_radeon_connector(connector);
bpc = radeon_get_monitor_bpc(connector); struct radeon_connector_atom_dig *dig_connector =
encoder_mode = atombios_get_encoder_mode(encoder); radeon_connector->con_priv;
is_duallink = radeon_dig_monitor_is_duallink(encoder, mode->clock);
if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
(radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) {
if (connector) {
struct radeon_connector *radeon_connector = to_radeon_connector(connector);
struct radeon_connector_atom_dig *dig_connector =
radeon_connector->con_priv;
dp_clock = dig_connector->dp_clock;
}
}
/* use recommended ref_div for ss */ dp_clock = dig_connector->dp_clock;
if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { }
if (radeon_crtc->ss_enabled) { }
if (radeon_crtc->ss.refdiv) {
radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV;
radeon_crtc->pll_reference_div = radeon_crtc->ss.refdiv;
if (ASIC_IS_AVIVO(rdev))
radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
}
}
}
if (ASIC_IS_AVIVO(rdev)) { /* use recommended ref_div for ss */
/* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */ if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1) if (radeon_crtc->ss_enabled) {
adjusted_clock = mode->clock * 2; if (radeon_crtc->ss.refdiv) {
if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV;
radeon_crtc->pll_flags |= RADEON_PLL_PREFER_CLOSEST_LOWER; radeon_crtc->pll_reference_div = radeon_crtc->ss.refdiv;
if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) if (ASIC_IS_AVIVO(rdev))
radeon_crtc->pll_flags |= RADEON_PLL_IS_LCD; radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
} else {
if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
radeon_crtc->pll_flags |= RADEON_PLL_NO_ODD_POST_DIV;
if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS)
radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV;
} }
break;
} }
} }
if (ASIC_IS_AVIVO(rdev)) {
/* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */
if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1)
adjusted_clock = mode->clock * 2;
if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT))
radeon_crtc->pll_flags |= RADEON_PLL_PREFER_CLOSEST_LOWER;
if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT))
radeon_crtc->pll_flags |= RADEON_PLL_IS_LCD;
} else {
if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
radeon_crtc->pll_flags |= RADEON_PLL_NO_ODD_POST_DIV;
if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS)
radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV;
}
/* DCE3+ has an AdjustDisplayPll that will adjust the pixel clock /* DCE3+ has an AdjustDisplayPll that will adjust the pixel clock
* accordingly based on the encoder/transmitter to work around * accordingly based on the encoder/transmitter to work around
* special hw requirements. * special hw requirements.
...@@ -913,29 +897,18 @@ static bool atombios_crtc_prepare_pll(struct drm_crtc *crtc, struct drm_display_ ...@@ -913,29 +897,18 @@ static bool atombios_crtc_prepare_pll(struct drm_crtc *crtc, struct drm_display_
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder = NULL; struct radeon_encoder *radeon_encoder =
struct radeon_encoder *radeon_encoder = NULL; to_radeon_encoder(radeon_crtc->encoder);
int encoder_mode = 0; int encoder_mode = atombios_get_encoder_mode(radeon_crtc->encoder);
radeon_crtc->bpc = 8; radeon_crtc->bpc = 8;
radeon_crtc->ss_enabled = false; radeon_crtc->ss_enabled = false;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder);
encoder_mode = atombios_get_encoder_mode(encoder);
break;
}
}
if (!radeon_encoder)
return false;
if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) || if ((radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT | ATOM_DEVICE_DFP_SUPPORT)) ||
(radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE)) { (radeon_encoder_get_dp_bridge_encoder_id(radeon_crtc->encoder) != ENCODER_OBJECT_ID_NONE)) {
struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
struct drm_connector *connector = struct drm_connector *connector =
radeon_get_connector_for_encoder(encoder); radeon_get_connector_for_encoder(radeon_crtc->encoder);
struct radeon_connector *radeon_connector = struct radeon_connector *radeon_connector =
to_radeon_connector(connector); to_radeon_connector(connector);
struct radeon_connector_atom_dig *dig_connector = struct radeon_connector_atom_dig *dig_connector =
...@@ -1016,23 +989,12 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode ...@@ -1016,23 +989,12 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder = NULL; struct radeon_encoder *radeon_encoder =
struct radeon_encoder *radeon_encoder = NULL; to_radeon_encoder(radeon_crtc->encoder);
u32 pll_clock = mode->clock; u32 pll_clock = mode->clock;
u32 ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0; u32 ref_div = 0, fb_div = 0, frac_fb_div = 0, post_div = 0;
struct radeon_pll *pll; struct radeon_pll *pll;
int encoder_mode = 0; int encoder_mode = atombios_get_encoder_mode(radeon_crtc->encoder);
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder);
encoder_mode = atombios_get_encoder_mode(encoder);
break;
}
}
if (!radeon_encoder)
return;
switch (radeon_crtc->pll_id) { switch (radeon_crtc->pll_id) {
case ATOM_PPLL1: case ATOM_PPLL1:
...@@ -1557,15 +1519,15 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc) ...@@ -1557,15 +1519,15 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_encoder *test_encoder; struct drm_encoder *test_encoder;
struct radeon_crtc *radeon_test_crtc; struct radeon_crtc *test_radeon_crtc;
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
if (test_encoder->crtc && (test_encoder->crtc != crtc)) { if (test_encoder->crtc && (test_encoder->crtc != crtc)) {
if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) {
/* for DP use the same PLL for all */ /* for DP use the same PLL for all */
radeon_test_crtc = to_radeon_crtc(test_encoder->crtc); test_radeon_crtc = to_radeon_crtc(test_encoder->crtc);
if (radeon_test_crtc->pll_id != ATOM_PPLL_INVALID) if (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID)
return radeon_test_crtc->pll_id; return test_radeon_crtc->pll_id;
} }
} }
} }
...@@ -1581,13 +1543,14 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc) ...@@ -1581,13 +1543,14 @@ static int radeon_get_shared_dp_ppll(struct drm_crtc *crtc)
* Returns the PPLL (Pixel PLL) used by another non-DP crtc/encoder which can * Returns the PPLL (Pixel PLL) used by another non-DP crtc/encoder which can
* be shared (i.e., same clock). * be shared (i.e., same clock).
*/ */
static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc, static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc)
struct drm_encoder *encoder)
{ {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); struct radeon_encoder *radeon_encoder =
to_radeon_encoder(radeon_crtc->encoder);
struct drm_encoder *test_encoder; struct drm_encoder *test_encoder;
struct radeon_crtc *radeon_test_crtc; struct radeon_crtc *test_radeon_crtc;
struct radeon_encoder *test_radeon_encoder; struct radeon_encoder *test_radeon_encoder;
u32 target_clock, test_clock; u32 target_clock, test_clock;
...@@ -1600,15 +1563,15 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc, ...@@ -1600,15 +1563,15 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc,
if (test_encoder->crtc && (test_encoder->crtc != crtc)) { if (test_encoder->crtc && (test_encoder->crtc != crtc)) {
if (!ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { if (!ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) {
test_radeon_encoder = to_radeon_encoder(test_encoder); test_radeon_encoder = to_radeon_encoder(test_encoder);
radeon_test_crtc = to_radeon_crtc(test_encoder->crtc); test_radeon_crtc = to_radeon_crtc(test_encoder->crtc);
/* for non-DP check the clock */ /* for non-DP check the clock */
if (test_radeon_encoder->native_mode.clock) if (test_radeon_encoder->native_mode.clock)
test_clock = test_radeon_encoder->native_mode.clock; test_clock = test_radeon_encoder->native_mode.clock;
else else
test_clock = test_encoder->crtc->mode.clock; test_clock = test_encoder->crtc->mode.clock;
if ((target_clock == test_clock) && if ((target_clock == test_clock) &&
(radeon_test_crtc->pll_id != ATOM_PPLL_INVALID)) (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID))
return radeon_test_crtc->pll_id; return test_radeon_crtc->pll_id;
} }
} }
} }
...@@ -1648,44 +1611,38 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc, ...@@ -1648,44 +1611,38 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc,
*/ */
static int radeon_atom_pick_pll(struct drm_crtc *crtc) static int radeon_atom_pick_pll(struct drm_crtc *crtc)
{ {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *test_encoder; struct radeon_encoder *radeon_encoder =
to_radeon_encoder(radeon_crtc->encoder);
u32 pll_in_use; u32 pll_in_use;
int pll; int pll;
if (ASIC_IS_DCE61(rdev)) { if (ASIC_IS_DCE61(rdev)) {
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { struct radeon_encoder_atom_dig *dig =
if (test_encoder->crtc && (test_encoder->crtc == crtc)) { radeon_encoder->enc_priv;
struct radeon_encoder *test_radeon_encoder =
to_radeon_encoder(test_encoder); if ((radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY) &&
struct radeon_encoder_atom_dig *dig = (dig->linkb == false))
test_radeon_encoder->enc_priv; /* UNIPHY A uses PPLL2 */
return ATOM_PPLL2;
if ((test_radeon_encoder->encoder_id == else if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
ENCODER_OBJECT_ID_INTERNAL_UNIPHY) && /* UNIPHY B/C/D/E/F */
(dig->linkb == false)) if (rdev->clock.dp_extclk)
/* UNIPHY A uses PPLL2 */ /* skip PPLL programming if using ext clock */
return ATOM_PPLL2; return ATOM_PPLL_INVALID;
else if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { else {
/* UNIPHY B/C/D/E/F */ /* use the same PPLL for all DP monitors */
if (rdev->clock.dp_extclk) pll = radeon_get_shared_dp_ppll(crtc);
/* skip PPLL programming if using ext clock */ if (pll != ATOM_PPLL_INVALID)
return ATOM_PPLL_INVALID; return pll;
else {
/* use the same PPLL for all DP monitors */
pll = radeon_get_shared_dp_ppll(crtc);
if (pll != ATOM_PPLL_INVALID)
return pll;
}
} else {
/* use the same PPLL for all monitors with the same clock */
pll = radeon_get_shared_nondp_ppll(crtc, test_encoder);
if (pll != ATOM_PPLL_INVALID)
return pll;
}
break;
} }
} else {
/* use the same PPLL for all monitors with the same clock */
pll = radeon_get_shared_nondp_ppll(crtc);
if (pll != ATOM_PPLL_INVALID)
return pll;
} }
/* UNIPHY B/C/D/E/F */ /* UNIPHY B/C/D/E/F */
pll_in_use = radeon_get_pll_use_mask(crtc); pll_in_use = radeon_get_pll_use_mask(crtc);
...@@ -1696,42 +1653,37 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc) ...@@ -1696,42 +1653,37 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
DRM_ERROR("unable to allocate a PPLL\n"); DRM_ERROR("unable to allocate a PPLL\n");
return ATOM_PPLL_INVALID; return ATOM_PPLL_INVALID;
} else if (ASIC_IS_DCE4(rdev)) { } else if (ASIC_IS_DCE4(rdev)) {
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock,
if (test_encoder->crtc && (test_encoder->crtc == crtc)) { * depending on the asic:
/* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock, * DCE4: PPLL or ext clock
* depending on the asic: * DCE5: PPLL, DCPLL, or ext clock
* DCE4: PPLL or ext clock * DCE6: PPLL, PPLL0, or ext clock
* DCE5: PPLL, DCPLL, or ext clock *
* DCE6: PPLL, PPLL0, or ext clock * Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip
* * PPLL/DCPLL programming and only program the DP DTO for the
* Setting ATOM_PPLL_INVALID will cause SetPixelClock to skip * crtc virtual pixel clock.
* PPLL/DCPLL programming and only program the DP DTO for the */
* crtc virtual pixel clock. if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
*/ if (rdev->clock.dp_extclk)
if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { /* skip PPLL programming if using ext clock */
if (rdev->clock.dp_extclk) return ATOM_PPLL_INVALID;
/* skip PPLL programming if using ext clock */ else if (ASIC_IS_DCE6(rdev))
return ATOM_PPLL_INVALID; /* use PPLL0 for all DP */
else if (ASIC_IS_DCE6(rdev)) return ATOM_PPLL0;
/* use PPLL0 for all DP */ else if (ASIC_IS_DCE5(rdev))
return ATOM_PPLL0; /* use DCPLL for all DP */
else if (ASIC_IS_DCE5(rdev)) return ATOM_DCPLL;
/* use DCPLL for all DP */ else {
return ATOM_DCPLL; /* use the same PPLL for all DP monitors */
else { pll = radeon_get_shared_dp_ppll(crtc);
/* use the same PPLL for all DP monitors */ if (pll != ATOM_PPLL_INVALID)
pll = radeon_get_shared_dp_ppll(crtc); return pll;
if (pll != ATOM_PPLL_INVALID)
return pll;
}
} else {
/* use the same PPLL for all monitors with the same clock */
pll = radeon_get_shared_nondp_ppll(crtc, test_encoder);
if (pll != ATOM_PPLL_INVALID)
return pll;
}
break;
} }
} else {
/* use the same PPLL for all monitors with the same clock */
pll = radeon_get_shared_nondp_ppll(crtc);
if (pll != ATOM_PPLL_INVALID)
return pll;
} }
/* all other cases */ /* all other cases */
pll_in_use = radeon_get_pll_use_mask(crtc); pll_in_use = radeon_get_pll_use_mask(crtc);
...@@ -1742,39 +1694,34 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc) ...@@ -1742,39 +1694,34 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
DRM_ERROR("unable to allocate a PPLL\n"); DRM_ERROR("unable to allocate a PPLL\n");
return ATOM_PPLL_INVALID; return ATOM_PPLL_INVALID;
} else { } else {
/* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ if (ASIC_IS_AVIVO(rdev)) {
if (!ASIC_IS_AVIVO(rdev)) { /* in DP mode, the DP ref clock can come from either PPLL
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); * depending on the asic:
return radeon_crtc->crtc_id; * DCE3: PPLL1 or PPLL2
} */
list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
if (test_encoder->crtc && (test_encoder->crtc == crtc)) { /* use the same PPLL for all DP monitors */
/* in DP mode, the DP ref clock can come from either PPLL pll = radeon_get_shared_dp_ppll(crtc);
* depending on the asic: if (pll != ATOM_PPLL_INVALID)
* DCE3: PPLL1 or PPLL2 return pll;
*/ } else {
if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(test_encoder))) { /* use the same PPLL for all monitors with the same clock */
/* use the same PPLL for all DP monitors */ pll = radeon_get_shared_nondp_ppll(crtc);
pll = radeon_get_shared_dp_ppll(crtc); if (pll != ATOM_PPLL_INVALID)
if (pll != ATOM_PPLL_INVALID) return pll;
return pll;
} else {
/* use the same PPLL for all monitors with the same clock */
pll = radeon_get_shared_nondp_ppll(crtc, test_encoder);
if (pll != ATOM_PPLL_INVALID)
return pll;
}
break;
} }
/* all other cases */
pll_in_use = radeon_get_pll_use_mask(crtc);
if (!(pll_in_use & (1 << ATOM_PPLL2)))
return ATOM_PPLL2;
if (!(pll_in_use & (1 << ATOM_PPLL1)))
return ATOM_PPLL1;
DRM_ERROR("unable to allocate a PPLL\n");
return ATOM_PPLL_INVALID;
} else {
/* on pre-R5xx asics, the crtc to pll mapping is hardcoded */
return radeon_crtc->crtc_id;
} }
/* all other cases */
pll_in_use = radeon_get_pll_use_mask(crtc);
if (!(pll_in_use & (1 << ATOM_PPLL2)))
return ATOM_PPLL2;
if (!(pll_in_use & (1 << ATOM_PPLL1)))
return ATOM_PPLL1;
DRM_ERROR("unable to allocate a PPLL\n");
return ATOM_PPLL_INVALID;
} }
} }
...@@ -1806,18 +1753,13 @@ int atombios_crtc_mode_set(struct drm_crtc *crtc, ...@@ -1806,18 +1753,13 @@ int atombios_crtc_mode_set(struct drm_crtc *crtc,
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct radeon_device *rdev = dev->dev_private; struct radeon_device *rdev = dev->dev_private;
struct drm_encoder *encoder; struct radeon_encoder *radeon_encoder =
to_radeon_encoder(radeon_crtc->encoder);
bool is_tvcv = false; bool is_tvcv = false;
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { if (radeon_encoder->active_device &
/* find tv std */ (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
if (encoder->crtc == crtc) { is_tvcv = true;
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
if (radeon_encoder->active_device &
(ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
is_tvcv = true;
}
}
atombios_crtc_set_pll(crtc, adjusted_mode); atombios_crtc_set_pll(crtc, adjusted_mode);
...@@ -1844,6 +1786,19 @@ static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc, ...@@ -1844,6 +1786,19 @@ static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
{ {
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
struct drm_device *dev = crtc->dev;
struct drm_encoder *encoder;
/* assign the encoder to the radeon crtc to avoid repeated lookups later */
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) {
radeon_crtc->encoder = encoder;
break;
}
}
if (radeon_crtc->encoder == NULL)
return false;
if (!radeon_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode)) if (!radeon_crtc_scaling_mode_fixup(crtc, mode, adjusted_mode))
return false; return false;
if (!atombios_crtc_prepare_pll(crtc, adjusted_mode)) if (!atombios_crtc_prepare_pll(crtc, adjusted_mode))
...@@ -1918,6 +1873,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc) ...@@ -1918,6 +1873,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
} }
done: done:
radeon_crtc->pll_id = ATOM_PPLL_INVALID; radeon_crtc->pll_id = ATOM_PPLL_INVALID;
radeon_crtc->encoder = NULL;
} }
static const struct drm_crtc_helper_funcs atombios_helper_funcs = { static const struct drm_crtc_helper_funcs atombios_helper_funcs = {
...@@ -1967,5 +1923,6 @@ void radeon_atombios_init_crtc(struct drm_device *dev, ...@@ -1967,5 +1923,6 @@ void radeon_atombios_init_crtc(struct drm_device *dev,
radeon_crtc->crtc_offset = 0; radeon_crtc->crtc_offset = 0;
} }
radeon_crtc->pll_id = ATOM_PPLL_INVALID; radeon_crtc->pll_id = ATOM_PPLL_INVALID;
radeon_crtc->encoder = NULL;
drm_crtc_helper_add(&radeon_crtc->base, &atombios_helper_funcs); drm_crtc_helper_add(&radeon_crtc->base, &atombios_helper_funcs);
} }
...@@ -326,6 +326,7 @@ struct radeon_crtc { ...@@ -326,6 +326,7 @@ struct radeon_crtc {
u32 pll_reference_div; u32 pll_reference_div;
u32 pll_post_div; u32 pll_post_div;
u32 pll_flags; u32 pll_flags;
struct drm_encoder *encoder;
}; };
struct radeon_encoder_primary_dac { struct radeon_encoder_primary_dac {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册