diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dp.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 143 |
1 files changed, 125 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 5dde80f9e652..40be1fa65be1 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #define DP_LINK_CONFIGURATION_SIZE 9 | 43 | #define DP_LINK_CONFIGURATION_SIZE 9 |
44 | 44 | ||
45 | #define IS_eDP(i) ((i)->type == INTEL_OUTPUT_EDP) | 45 | #define IS_eDP(i) ((i)->type == INTEL_OUTPUT_EDP) |
46 | #define IS_PCH_eDP(dp_priv) ((dp_priv)->is_pch_edp) | ||
46 | 47 | ||
47 | struct intel_dp_priv { | 48 | struct intel_dp_priv { |
48 | uint32_t output_reg; | 49 | uint32_t output_reg; |
@@ -56,6 +57,7 @@ struct intel_dp_priv { | |||
56 | struct intel_encoder *intel_encoder; | 57 | struct intel_encoder *intel_encoder; |
57 | struct i2c_adapter adapter; | 58 | struct i2c_adapter adapter; |
58 | struct i2c_algo_dp_aux_data algo; | 59 | struct i2c_algo_dp_aux_data algo; |
60 | bool is_pch_edp; | ||
59 | }; | 61 | }; |
60 | 62 | ||
61 | static void | 63 | static void |
@@ -128,8 +130,9 @@ intel_dp_link_required(struct drm_device *dev, | |||
128 | struct intel_encoder *intel_encoder, int pixel_clock) | 130 | struct intel_encoder *intel_encoder, int pixel_clock) |
129 | { | 131 | { |
130 | struct drm_i915_private *dev_priv = dev->dev_private; | 132 | struct drm_i915_private *dev_priv = dev->dev_private; |
133 | struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; | ||
131 | 134 | ||
132 | if (IS_eDP(intel_encoder)) | 135 | if (IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) |
133 | return (pixel_clock * dev_priv->edp_bpp) / 8; | 136 | return (pixel_clock * dev_priv->edp_bpp) / 8; |
134 | else | 137 | else |
135 | return pixel_clock * 3; | 138 | return pixel_clock * 3; |
@@ -147,9 +150,21 @@ intel_dp_mode_valid(struct drm_connector *connector, | |||
147 | { | 150 | { |
148 | struct drm_encoder *encoder = intel_attached_encoder(connector); | 151 | struct drm_encoder *encoder = intel_attached_encoder(connector); |
149 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); | 152 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
153 | struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; | ||
154 | struct drm_device *dev = connector->dev; | ||
155 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
150 | int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder)); | 156 | int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder)); |
151 | int max_lanes = intel_dp_max_lane_count(intel_encoder); | 157 | int max_lanes = intel_dp_max_lane_count(intel_encoder); |
152 | 158 | ||
159 | if ((IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) && | ||
160 | dev_priv->panel_fixed_mode) { | ||
161 | if (mode->hdisplay > dev_priv->panel_fixed_mode->hdisplay) | ||
162 | return MODE_PANEL; | ||
163 | |||
164 | if (mode->vdisplay > dev_priv->panel_fixed_mode->vdisplay) | ||
165 | return MODE_PANEL; | ||
166 | } | ||
167 | |||
153 | /* only refuse the mode on non eDP since we have seen some wierd eDP panels | 168 | /* only refuse the mode on non eDP since we have seen some wierd eDP panels |
154 | which are outside spec tolerances but somehow work by magic */ | 169 | which are outside spec tolerances but somehow work by magic */ |
155 | if (!IS_eDP(intel_encoder) && | 170 | if (!IS_eDP(intel_encoder) && |
@@ -508,11 +523,37 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
508 | { | 523 | { |
509 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); | 524 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
510 | struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; | 525 | struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; |
526 | struct drm_device *dev = encoder->dev; | ||
527 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
511 | int lane_count, clock; | 528 | int lane_count, clock; |
512 | int max_lane_count = intel_dp_max_lane_count(intel_encoder); | 529 | int max_lane_count = intel_dp_max_lane_count(intel_encoder); |
513 | int max_clock = intel_dp_max_link_bw(intel_encoder) == DP_LINK_BW_2_7 ? 1 : 0; | 530 | int max_clock = intel_dp_max_link_bw(intel_encoder) == DP_LINK_BW_2_7 ? 1 : 0; |
514 | static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; | 531 | static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; |
515 | 532 | ||
533 | if ((IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) && | ||
534 | dev_priv->panel_fixed_mode) { | ||
535 | struct drm_display_mode *fixed_mode = dev_priv->panel_fixed_mode; | ||
536 | |||
537 | adjusted_mode->hdisplay = fixed_mode->hdisplay; | ||
538 | adjusted_mode->hsync_start = fixed_mode->hsync_start; | ||
539 | adjusted_mode->hsync_end = fixed_mode->hsync_end; | ||
540 | adjusted_mode->htotal = fixed_mode->htotal; | ||
541 | |||
542 | adjusted_mode->vdisplay = fixed_mode->vdisplay; | ||
543 | adjusted_mode->vsync_start = fixed_mode->vsync_start; | ||
544 | adjusted_mode->vsync_end = fixed_mode->vsync_end; | ||
545 | adjusted_mode->vtotal = fixed_mode->vtotal; | ||
546 | |||
547 | adjusted_mode->clock = fixed_mode->clock; | ||
548 | drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V); | ||
549 | |||
550 | /* | ||
551 | * the mode->clock is used to calculate the Data&Link M/N | ||
552 | * of the pipe. For the eDP the fixed clock should be used. | ||
553 | */ | ||
554 | mode->clock = dev_priv->panel_fixed_mode->clock; | ||
555 | } | ||
556 | |||
516 | for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { | 557 | for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { |
517 | for (clock = 0; clock <= max_clock; clock++) { | 558 | for (clock = 0; clock <= max_clock; clock++) { |
518 | int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count); | 559 | int link_avail = intel_dp_max_data_rate(intel_dp_link_clock(bws[clock]), lane_count); |
@@ -531,7 +572,7 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, | |||
531 | } | 572 | } |
532 | } | 573 | } |
533 | 574 | ||
534 | if (IS_eDP(intel_encoder)) { | 575 | if (IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) { |
535 | /* okay we failed just pick the highest */ | 576 | /* okay we failed just pick the highest */ |
536 | dp_priv->lane_count = max_lane_count; | 577 | dp_priv->lane_count = max_lane_count; |
537 | dp_priv->link_bw = bws[max_clock]; | 578 | dp_priv->link_bw = bws[max_clock]; |
@@ -563,14 +604,14 @@ intel_reduce_ratio(uint32_t *num, uint32_t *den) | |||
563 | } | 604 | } |
564 | 605 | ||
565 | static void | 606 | static void |
566 | intel_dp_compute_m_n(int bytes_per_pixel, | 607 | intel_dp_compute_m_n(int bpp, |
567 | int nlanes, | 608 | int nlanes, |
568 | int pixel_clock, | 609 | int pixel_clock, |
569 | int link_clock, | 610 | int link_clock, |
570 | struct intel_dp_m_n *m_n) | 611 | struct intel_dp_m_n *m_n) |
571 | { | 612 | { |
572 | m_n->tu = 64; | 613 | m_n->tu = 64; |
573 | m_n->gmch_m = pixel_clock * bytes_per_pixel; | 614 | m_n->gmch_m = (pixel_clock * bpp) >> 3; |
574 | m_n->gmch_n = link_clock * nlanes; | 615 | m_n->gmch_n = link_clock * nlanes; |
575 | intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); | 616 | intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); |
576 | m_n->link_m = pixel_clock; | 617 | m_n->link_m = pixel_clock; |
@@ -578,6 +619,28 @@ intel_dp_compute_m_n(int bytes_per_pixel, | |||
578 | intel_reduce_ratio(&m_n->link_m, &m_n->link_n); | 619 | intel_reduce_ratio(&m_n->link_m, &m_n->link_n); |
579 | } | 620 | } |
580 | 621 | ||
622 | bool intel_pch_has_edp(struct drm_crtc *crtc) | ||
623 | { | ||
624 | struct drm_device *dev = crtc->dev; | ||
625 | struct drm_mode_config *mode_config = &dev->mode_config; | ||
626 | struct drm_encoder *encoder; | ||
627 | |||
628 | list_for_each_entry(encoder, &mode_config->encoder_list, head) { | ||
629 | struct intel_encoder *intel_encoder; | ||
630 | struct intel_dp_priv *dp_priv; | ||
631 | |||
632 | if (!encoder || encoder->crtc != crtc) | ||
633 | continue; | ||
634 | |||
635 | intel_encoder = enc_to_intel_encoder(encoder); | ||
636 | dp_priv = intel_encoder->dev_priv; | ||
637 | |||
638 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) | ||
639 | return dp_priv->is_pch_edp; | ||
640 | } | ||
641 | return false; | ||
642 | } | ||
643 | |||
581 | void | 644 | void |
582 | intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, | 645 | intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, |
583 | struct drm_display_mode *adjusted_mode) | 646 | struct drm_display_mode *adjusted_mode) |
@@ -587,7 +650,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
587 | struct drm_encoder *encoder; | 650 | struct drm_encoder *encoder; |
588 | struct drm_i915_private *dev_priv = dev->dev_private; | 651 | struct drm_i915_private *dev_priv = dev->dev_private; |
589 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 652 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
590 | int lane_count = 4; | 653 | int lane_count = 4, bpp = 24; |
591 | struct intel_dp_m_n m_n; | 654 | struct intel_dp_m_n m_n; |
592 | 655 | ||
593 | /* | 656 | /* |
@@ -605,6 +668,8 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
605 | 668 | ||
606 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) { | 669 | if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) { |
607 | lane_count = dp_priv->lane_count; | 670 | lane_count = dp_priv->lane_count; |
671 | if (IS_PCH_eDP(dp_priv)) | ||
672 | bpp = dev_priv->edp_bpp; | ||
608 | break; | 673 | break; |
609 | } | 674 | } |
610 | } | 675 | } |
@@ -614,7 +679,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
614 | * the number of bytes_per_pixel post-LUT, which we always | 679 | * the number of bytes_per_pixel post-LUT, which we always |
615 | * set up for 8-bits of R/G/B, or 3 bytes total. | 680 | * set up for 8-bits of R/G/B, or 3 bytes total. |
616 | */ | 681 | */ |
617 | intel_dp_compute_m_n(3, lane_count, | 682 | intel_dp_compute_m_n(bpp, lane_count, |
618 | mode->clock, adjusted_mode->clock, &m_n); | 683 | mode->clock, adjusted_mode->clock, &m_n); |
619 | 684 | ||
620 | if (HAS_PCH_SPLIT(dev)) { | 685 | if (HAS_PCH_SPLIT(dev)) { |
@@ -796,7 +861,7 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode) | |||
796 | if (mode != DRM_MODE_DPMS_ON) { | 861 | if (mode != DRM_MODE_DPMS_ON) { |
797 | if (dp_reg & DP_PORT_EN) { | 862 | if (dp_reg & DP_PORT_EN) { |
798 | intel_dp_link_down(intel_encoder, dp_priv->DP); | 863 | intel_dp_link_down(intel_encoder, dp_priv->DP); |
799 | if (IS_eDP(intel_encoder)) { | 864 | if (IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) { |
800 | ironlake_edp_backlight_off(dev); | 865 | ironlake_edp_backlight_off(dev); |
801 | ironlake_edp_panel_off(dev); | 866 | ironlake_edp_panel_off(dev); |
802 | } | 867 | } |
@@ -804,7 +869,7 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode) | |||
804 | } else { | 869 | } else { |
805 | if (!(dp_reg & DP_PORT_EN)) { | 870 | if (!(dp_reg & DP_PORT_EN)) { |
806 | intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration); | 871 | intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration); |
807 | if (IS_eDP(intel_encoder)) { | 872 | if (IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) { |
808 | ironlake_edp_panel_on(dev); | 873 | ironlake_edp_panel_on(dev); |
809 | ironlake_edp_backlight_on(dev); | 874 | ironlake_edp_backlight_on(dev); |
810 | } | 875 | } |
@@ -1340,17 +1405,32 @@ static int intel_dp_get_modes(struct drm_connector *connector) | |||
1340 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); | 1405 | struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); |
1341 | struct drm_device *dev = intel_encoder->enc.dev; | 1406 | struct drm_device *dev = intel_encoder->enc.dev; |
1342 | struct drm_i915_private *dev_priv = dev->dev_private; | 1407 | struct drm_i915_private *dev_priv = dev->dev_private; |
1408 | struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; | ||
1343 | int ret; | 1409 | int ret; |
1344 | 1410 | ||
1345 | /* We should parse the EDID data and find out if it has an audio sink | 1411 | /* We should parse the EDID data and find out if it has an audio sink |
1346 | */ | 1412 | */ |
1347 | 1413 | ||
1348 | ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); | 1414 | ret = intel_ddc_get_modes(connector, intel_encoder->ddc_bus); |
1349 | if (ret) | 1415 | if (ret) { |
1416 | if ((IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) && | ||
1417 | !dev_priv->panel_fixed_mode) { | ||
1418 | struct drm_display_mode *newmode; | ||
1419 | list_for_each_entry(newmode, &connector->probed_modes, | ||
1420 | head) { | ||
1421 | if (newmode->type & DRM_MODE_TYPE_PREFERRED) { | ||
1422 | dev_priv->panel_fixed_mode = | ||
1423 | drm_mode_duplicate(dev, newmode); | ||
1424 | break; | ||
1425 | } | ||
1426 | } | ||
1427 | } | ||
1428 | |||
1350 | return ret; | 1429 | return ret; |
1430 | } | ||
1351 | 1431 | ||
1352 | /* if eDP has no EDID, try to use fixed panel mode from VBT */ | 1432 | /* if eDP has no EDID, try to use fixed panel mode from VBT */ |
1353 | if (IS_eDP(intel_encoder)) { | 1433 | if (IS_eDP(intel_encoder) || IS_PCH_eDP(dp_priv)) { |
1354 | if (dev_priv->panel_fixed_mode != NULL) { | 1434 | if (dev_priv->panel_fixed_mode != NULL) { |
1355 | struct drm_display_mode *mode; | 1435 | struct drm_display_mode *mode; |
1356 | mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); | 1436 | mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); |
@@ -1435,6 +1515,26 @@ intel_trans_dp_port_sel (struct drm_crtc *crtc) | |||
1435 | return -1; | 1515 | return -1; |
1436 | } | 1516 | } |
1437 | 1517 | ||
1518 | /* check the VBT to see whether the eDP is on DP-D port */ | ||
1519 | bool intel_dpd_is_edp(struct drm_device *dev) | ||
1520 | { | ||
1521 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1522 | struct child_device_config *p_child; | ||
1523 | int i; | ||
1524 | |||
1525 | if (!dev_priv->child_dev_num) | ||
1526 | return false; | ||
1527 | |||
1528 | for (i = 0; i < dev_priv->child_dev_num; i++) { | ||
1529 | p_child = dev_priv->child_dev + i; | ||
1530 | |||
1531 | if (p_child->dvo_port == PORT_IDPD && | ||
1532 | p_child->device_type == DEVICE_TYPE_eDP) | ||
1533 | return true; | ||
1534 | } | ||
1535 | return false; | ||
1536 | } | ||
1537 | |||
1438 | void | 1538 | void |
1439 | intel_dp_init(struct drm_device *dev, int output_reg) | 1539 | intel_dp_init(struct drm_device *dev, int output_reg) |
1440 | { | 1540 | { |
@@ -1444,6 +1544,7 @@ intel_dp_init(struct drm_device *dev, int output_reg) | |||
1444 | struct intel_connector *intel_connector; | 1544 | struct intel_connector *intel_connector; |
1445 | struct intel_dp_priv *dp_priv; | 1545 | struct intel_dp_priv *dp_priv; |
1446 | const char *name = NULL; | 1546 | const char *name = NULL; |
1547 | int type; | ||
1447 | 1548 | ||
1448 | intel_encoder = kcalloc(sizeof(struct intel_encoder) + | 1549 | intel_encoder = kcalloc(sizeof(struct intel_encoder) + |
1449 | sizeof(struct intel_dp_priv), 1, GFP_KERNEL); | 1550 | sizeof(struct intel_dp_priv), 1, GFP_KERNEL); |
@@ -1458,18 +1559,24 @@ intel_dp_init(struct drm_device *dev, int output_reg) | |||
1458 | 1559 | ||
1459 | dp_priv = (struct intel_dp_priv *)(intel_encoder + 1); | 1560 | dp_priv = (struct intel_dp_priv *)(intel_encoder + 1); |
1460 | 1561 | ||
1562 | if (HAS_PCH_SPLIT(dev) && (output_reg == PCH_DP_D)) | ||
1563 | if (intel_dpd_is_edp(dev)) | ||
1564 | dp_priv->is_pch_edp = true; | ||
1565 | |||
1566 | if (output_reg == DP_A || IS_PCH_eDP(dp_priv)) { | ||
1567 | type = DRM_MODE_CONNECTOR_eDP; | ||
1568 | intel_encoder->type = INTEL_OUTPUT_EDP; | ||
1569 | } else { | ||
1570 | type = DRM_MODE_CONNECTOR_DisplayPort; | ||
1571 | intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT; | ||
1572 | } | ||
1573 | |||
1461 | connector = &intel_connector->base; | 1574 | connector = &intel_connector->base; |
1462 | drm_connector_init(dev, connector, &intel_dp_connector_funcs, | 1575 | drm_connector_init(dev, connector, &intel_dp_connector_funcs, type); |
1463 | DRM_MODE_CONNECTOR_DisplayPort); | ||
1464 | drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); | 1576 | drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); |
1465 | 1577 | ||
1466 | connector->polled = DRM_CONNECTOR_POLL_HPD; | 1578 | connector->polled = DRM_CONNECTOR_POLL_HPD; |
1467 | 1579 | ||
1468 | if (output_reg == DP_A) | ||
1469 | intel_encoder->type = INTEL_OUTPUT_EDP; | ||
1470 | else | ||
1471 | intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT; | ||
1472 | |||
1473 | if (output_reg == DP_B || output_reg == PCH_DP_B) | 1580 | if (output_reg == DP_B || output_reg == PCH_DP_B) |
1474 | intel_encoder->clone_mask = (1 << INTEL_DP_B_CLONE_BIT); | 1581 | intel_encoder->clone_mask = (1 << INTEL_DP_B_CLONE_BIT); |
1475 | else if (output_reg == DP_C || output_reg == PCH_DP_C) | 1582 | else if (output_reg == DP_C || output_reg == PCH_DP_C) |
@@ -1528,7 +1635,7 @@ intel_dp_init(struct drm_device *dev, int output_reg) | |||
1528 | intel_encoder->ddc_bus = &dp_priv->adapter; | 1635 | intel_encoder->ddc_bus = &dp_priv->adapter; |
1529 | intel_encoder->hot_plug = intel_dp_hot_plug; | 1636 | intel_encoder->hot_plug = intel_dp_hot_plug; |
1530 | 1637 | ||
1531 | if (output_reg == DP_A) { | 1638 | if (output_reg == DP_A || IS_PCH_eDP(dp_priv)) { |
1532 | /* initialize panel mode from VBT if available for eDP */ | 1639 | /* initialize panel mode from VBT if available for eDP */ |
1533 | if (dev_priv->lfp_lvds_vbt_mode) { | 1640 | if (dev_priv->lfp_lvds_vbt_mode) { |
1534 | dev_priv->panel_fixed_mode = | 1641 | dev_priv->panel_fixed_mode = |