aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_dp.c
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyuw@linux.intel.com>2010-03-29 04:13:57 -0400
committerEric Anholt <eric@anholt.net>2010-04-12 12:23:51 -0400
commit55f78c43598dbfbce09034b463ed2abc72f1420d (patch)
tree69f6bb40dfb269034405ec0a9cf1693bd45ab3ca /drivers/gpu/drm/i915/intel_dp.c
parent674e2d0885e009c078d89f789f28f63374a4f337 (diff)
drm/i915: convert DP/eDP driver to new encoder/connector structure
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com> Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dp.c')
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 79625bd9361a..480a5eef8a48 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -138,7 +138,8 @@ static int
138intel_dp_mode_valid(struct drm_connector *connector, 138intel_dp_mode_valid(struct drm_connector *connector,
139 struct drm_display_mode *mode) 139 struct drm_display_mode *mode)
140{ 140{
141 struct intel_encoder *intel_encoder = to_intel_encoder(connector); 141 struct drm_encoder *encoder = intel_attached_encoder(connector);
142 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
142 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder)); 143 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder));
143 int max_lanes = intel_dp_max_lane_count(intel_encoder); 144 int max_lanes = intel_dp_max_lane_count(intel_encoder);
144 145
@@ -212,7 +213,7 @@ intel_dp_aux_ch(struct intel_encoder *intel_encoder,
212{ 213{
213 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 214 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
214 uint32_t output_reg = dp_priv->output_reg; 215 uint32_t output_reg = dp_priv->output_reg;
215 struct drm_device *dev = intel_encoder->base.dev; 216 struct drm_device *dev = intel_encoder->enc.dev;
216 struct drm_i915_private *dev_priv = dev->dev_private; 217 struct drm_i915_private *dev_priv = dev->dev_private;
217 uint32_t ch_ctl = output_reg + 0x10; 218 uint32_t ch_ctl = output_reg + 0x10;
218 uint32_t ch_data = ch_ctl + 4; 219 uint32_t ch_data = ch_ctl + 4;
@@ -470,7 +471,8 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
470} 471}
471 472
472static int 473static int
473intel_dp_i2c_init(struct intel_encoder *intel_encoder, const char *name) 474intel_dp_i2c_init(struct intel_encoder *intel_encoder,
475 struct intel_connector *intel_connector, const char *name)
474{ 476{
475 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 477 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
476 478
@@ -485,7 +487,7 @@ intel_dp_i2c_init(struct intel_encoder *intel_encoder, const char *name)
485 strncpy (dp_priv->adapter.name, name, sizeof(dp_priv->adapter.name) - 1); 487 strncpy (dp_priv->adapter.name, name, sizeof(dp_priv->adapter.name) - 1);
486 dp_priv->adapter.name[sizeof(dp_priv->adapter.name) - 1] = '\0'; 488 dp_priv->adapter.name[sizeof(dp_priv->adapter.name) - 1] = '\0';
487 dp_priv->adapter.algo_data = &dp_priv->algo; 489 dp_priv->adapter.algo_data = &dp_priv->algo;
488 dp_priv->adapter.dev.parent = &intel_encoder->base.kdev; 490 dp_priv->adapter.dev.parent = &intel_connector->base.kdev;
489 491
490 return i2c_dp_aux_add_bus(&dp_priv->adapter); 492 return i2c_dp_aux_add_bus(&dp_priv->adapter);
491} 493}
@@ -560,7 +562,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
560{ 562{
561 struct drm_device *dev = crtc->dev; 563 struct drm_device *dev = crtc->dev;
562 struct drm_mode_config *mode_config = &dev->mode_config; 564 struct drm_mode_config *mode_config = &dev->mode_config;
563 struct drm_connector *connector; 565 struct drm_encoder *encoder;
564 struct drm_i915_private *dev_priv = dev->dev_private; 566 struct drm_i915_private *dev_priv = dev->dev_private;
565 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 567 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
566 int lane_count = 4; 568 int lane_count = 4;
@@ -569,13 +571,16 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
569 /* 571 /*
570 * Find the lane count in the intel_encoder private 572 * Find the lane count in the intel_encoder private
571 */ 573 */
572 list_for_each_entry(connector, &mode_config->connector_list, head) { 574 list_for_each_entry(encoder, &mode_config->encoder_list, head) {
573 struct intel_encoder *intel_encoder = to_intel_encoder(connector); 575 struct intel_encoder *intel_encoder;
574 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 576 struct intel_dp_priv *dp_priv;
575 577
576 if (!connector->encoder || connector->encoder->crtc != crtc) 578 if (!encoder || encoder->crtc != crtc)
577 continue; 579 continue;
578 580
581 intel_encoder = enc_to_intel_encoder(encoder);
582 dp_priv = intel_encoder->dev_priv;
583
579 if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) { 584 if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
580 lane_count = dp_priv->lane_count; 585 lane_count = dp_priv->lane_count;
581 break; 586 break;
@@ -718,7 +723,7 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode)
718{ 723{
719 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder); 724 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
720 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 725 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
721 struct drm_device *dev = intel_encoder->base.dev; 726 struct drm_device *dev = encoder->dev;
722 struct drm_i915_private *dev_priv = dev->dev_private; 727 struct drm_i915_private *dev_priv = dev->dev_private;
723 uint32_t dp_reg = I915_READ(dp_priv->output_reg); 728 uint32_t dp_reg = I915_READ(dp_priv->output_reg);
724 729
@@ -967,7 +972,7 @@ intel_dp_set_link_train(struct intel_encoder *intel_encoder,
967 uint8_t train_set[4], 972 uint8_t train_set[4],
968 bool first) 973 bool first)
969{ 974{
970 struct drm_device *dev = intel_encoder->base.dev; 975 struct drm_device *dev = intel_encoder->enc.dev;
971 struct drm_i915_private *dev_priv = dev->dev_private; 976 struct drm_i915_private *dev_priv = dev->dev_private;
972 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 977 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
973 int ret; 978 int ret;
@@ -993,7 +998,7 @@ static void
993intel_dp_link_train(struct intel_encoder *intel_encoder, uint32_t DP, 998intel_dp_link_train(struct intel_encoder *intel_encoder, uint32_t DP,
994 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE]) 999 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE])
995{ 1000{
996 struct drm_device *dev = intel_encoder->base.dev; 1001 struct drm_device *dev = intel_encoder->enc.dev;
997 struct drm_i915_private *dev_priv = dev->dev_private; 1002 struct drm_i915_private *dev_priv = dev->dev_private;
998 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 1003 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
999 uint8_t train_set[4]; 1004 uint8_t train_set[4];
@@ -1128,7 +1133,7 @@ intel_dp_link_train(struct intel_encoder *intel_encoder, uint32_t DP,
1128static void 1133static void
1129intel_dp_link_down(struct intel_encoder *intel_encoder, uint32_t DP) 1134intel_dp_link_down(struct intel_encoder *intel_encoder, uint32_t DP)
1130{ 1135{
1131 struct drm_device *dev = intel_encoder->base.dev; 1136 struct drm_device *dev = intel_encoder->enc.dev;
1132 struct drm_i915_private *dev_priv = dev->dev_private; 1137 struct drm_i915_private *dev_priv = dev->dev_private;
1133 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 1138 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1134 1139
@@ -1189,7 +1194,8 @@ intel_dp_check_link_status(struct intel_encoder *intel_encoder)
1189static enum drm_connector_status 1194static enum drm_connector_status
1190ironlake_dp_detect(struct drm_connector *connector) 1195ironlake_dp_detect(struct drm_connector *connector)
1191{ 1196{
1192 struct intel_encoder *intel_encoder = to_intel_encoder(connector); 1197 struct drm_encoder *encoder = intel_attached_encoder(connector);
1198 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1193 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 1199 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1194 enum drm_connector_status status; 1200 enum drm_connector_status status;
1195 1201
@@ -1213,8 +1219,9 @@ ironlake_dp_detect(struct drm_connector *connector)
1213static enum drm_connector_status 1219static enum drm_connector_status
1214intel_dp_detect(struct drm_connector *connector) 1220intel_dp_detect(struct drm_connector *connector)
1215{ 1221{
1216 struct intel_encoder *intel_encoder = to_intel_encoder(connector); 1222 struct drm_encoder *encoder = intel_attached_encoder(connector);
1217 struct drm_device *dev = intel_encoder->base.dev; 1223 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1224 struct drm_device *dev = intel_encoder->enc.dev;
1218 struct drm_i915_private *dev_priv = dev->dev_private; 1225 struct drm_i915_private *dev_priv = dev->dev_private;
1219 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv; 1226 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1220 uint32_t temp, bit; 1227 uint32_t temp, bit;
@@ -1267,8 +1274,9 @@ intel_dp_detect(struct drm_connector *connector)
1267 1274
1268static int intel_dp_get_modes(struct drm_connector *connector) 1275static int intel_dp_get_modes(struct drm_connector *connector)
1269{ 1276{
1270 struct intel_encoder *intel_encoder = to_intel_encoder(connector); 1277 struct drm_encoder *encoder = intel_attached_encoder(connector);
1271 struct drm_device *dev = intel_encoder->base.dev; 1278 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1279 struct drm_device *dev = intel_encoder->enc.dev;
1272 struct drm_i915_private *dev_priv = dev->dev_private; 1280 struct drm_i915_private *dev_priv = dev->dev_private;
1273 int ret; 1281 int ret;
1274 1282
@@ -1294,13 +1302,9 @@ static int intel_dp_get_modes(struct drm_connector *connector)
1294static void 1302static void
1295intel_dp_destroy (struct drm_connector *connector) 1303intel_dp_destroy (struct drm_connector *connector)
1296{ 1304{
1297 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1298
1299 if (intel_encoder->i2c_bus)
1300 intel_i2c_destroy(intel_encoder->i2c_bus);
1301 drm_sysfs_connector_remove(connector); 1305 drm_sysfs_connector_remove(connector);
1302 drm_connector_cleanup(connector); 1306 drm_connector_cleanup(connector);
1303 kfree(intel_encoder); 1307 kfree(connector);
1304} 1308}
1305 1309
1306static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = { 1310static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
@@ -1321,12 +1325,17 @@ static const struct drm_connector_funcs intel_dp_connector_funcs = {
1321static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = { 1325static const struct drm_connector_helper_funcs intel_dp_connector_helper_funcs = {
1322 .get_modes = intel_dp_get_modes, 1326 .get_modes = intel_dp_get_modes,
1323 .mode_valid = intel_dp_mode_valid, 1327 .mode_valid = intel_dp_mode_valid,
1324 .best_encoder = intel_best_encoder, 1328 .best_encoder = intel_attached_encoder,
1325}; 1329};
1326 1330
1327static void intel_dp_enc_destroy(struct drm_encoder *encoder) 1331static void intel_dp_enc_destroy(struct drm_encoder *encoder)
1328{ 1332{
1333 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1334
1335 if (intel_encoder->i2c_bus)
1336 intel_i2c_destroy(intel_encoder->i2c_bus);
1329 drm_encoder_cleanup(encoder); 1337 drm_encoder_cleanup(encoder);
1338 kfree(intel_encoder);
1330} 1339}
1331 1340
1332static const struct drm_encoder_funcs intel_dp_enc_funcs = { 1341static const struct drm_encoder_funcs intel_dp_enc_funcs = {
@@ -1370,6 +1379,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1370 struct drm_i915_private *dev_priv = dev->dev_private; 1379 struct drm_i915_private *dev_priv = dev->dev_private;
1371 struct drm_connector *connector; 1380 struct drm_connector *connector;
1372 struct intel_encoder *intel_encoder; 1381 struct intel_encoder *intel_encoder;
1382 struct intel_connector *intel_connector;
1373 struct intel_dp_priv *dp_priv; 1383 struct intel_dp_priv *dp_priv;
1374 const char *name = NULL; 1384 const char *name = NULL;
1375 1385
@@ -1378,9 +1388,15 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1378 if (!intel_encoder) 1388 if (!intel_encoder)
1379 return; 1389 return;
1380 1390
1391 intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
1392 if (!intel_connector) {
1393 kfree(intel_encoder);
1394 return;
1395 }
1396
1381 dp_priv = (struct intel_dp_priv *)(intel_encoder + 1); 1397 dp_priv = (struct intel_dp_priv *)(intel_encoder + 1);
1382 1398
1383 connector = &intel_encoder->base; 1399 connector = &intel_connector->base;
1384 drm_connector_init(dev, connector, &intel_dp_connector_funcs, 1400 drm_connector_init(dev, connector, &intel_dp_connector_funcs,
1385 DRM_MODE_CONNECTOR_DisplayPort); 1401 DRM_MODE_CONNECTOR_DisplayPort);
1386 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); 1402 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
@@ -1414,7 +1430,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1414 DRM_MODE_ENCODER_TMDS); 1430 DRM_MODE_ENCODER_TMDS);
1415 drm_encoder_helper_add(&intel_encoder->enc, &intel_dp_helper_funcs); 1431 drm_encoder_helper_add(&intel_encoder->enc, &intel_dp_helper_funcs);
1416 1432
1417 drm_mode_connector_attach_encoder(&intel_encoder->base, 1433 drm_mode_connector_attach_encoder(&intel_connector->base,
1418 &intel_encoder->enc); 1434 &intel_encoder->enc);
1419 drm_sysfs_connector_add(connector); 1435 drm_sysfs_connector_add(connector);
1420 1436
@@ -1443,7 +1459,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1443 break; 1459 break;
1444 } 1460 }
1445 1461
1446 intel_dp_i2c_init(intel_encoder, name); 1462 intel_dp_i2c_init(intel_encoder, intel_connector, name);
1447 1463
1448 intel_encoder->ddc_bus = &dp_priv->adapter; 1464 intel_encoder->ddc_bus = &dp_priv->adapter;
1449 intel_encoder->hot_plug = intel_dp_hot_plug; 1465 intel_encoder->hot_plug = intel_dp_hot_plug;