aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_sdvo.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-09-09 11:20:55 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-09 12:00:43 -0400
commitdf0e924883d029a8651a2a0c7b8da67a07611ed2 (patch)
tree7482d6c4942c709f2c6812f397c3239326ade3b8 /drivers/gpu/drm/i915/intel_sdvo.c
parentf875c15a4fbf37534dda30771d8bde8604fbbf09 (diff)
drm/i915: Make the connector->encoder relationship explicit
Currently we have a exact mapping of a connector onto an encoder for its whole lifetime. Make this an explicit property of the structure and so simplify the code. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_sdvo.c')
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 3d8f4f4cf326..96952d20cd21 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -189,6 +189,12 @@ static struct intel_sdvo *enc_to_intel_sdvo(struct drm_encoder *encoder)
189 return container_of(encoder, struct intel_sdvo, base.base); 189 return container_of(encoder, struct intel_sdvo, base.base);
190} 190}
191 191
192static struct intel_sdvo *intel_attached_sdvo(struct drm_connector *connector)
193{
194 return container_of(intel_attached_encoder(connector),
195 struct intel_sdvo, base);
196}
197
192static struct intel_sdvo_connector *to_intel_sdvo_connector(struct drm_connector *connector) 198static struct intel_sdvo_connector *to_intel_sdvo_connector(struct drm_connector *connector)
193{ 199{
194 return container_of(to_intel_connector(connector), struct intel_sdvo_connector, base); 200 return container_of(to_intel_connector(connector), struct intel_sdvo_connector, base);
@@ -1239,8 +1245,7 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
1239static int intel_sdvo_mode_valid(struct drm_connector *connector, 1245static int intel_sdvo_mode_valid(struct drm_connector *connector,
1240 struct drm_display_mode *mode) 1246 struct drm_display_mode *mode)
1241{ 1247{
1242 struct drm_encoder *encoder = intel_attached_encoder(connector); 1248 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1243 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1244 1249
1245 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 1250 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1246 return MODE_NO_DBLESCAN; 1251 return MODE_NO_DBLESCAN;
@@ -1372,18 +1377,22 @@ static struct drm_connector *
1372intel_find_analog_connector(struct drm_device *dev) 1377intel_find_analog_connector(struct drm_device *dev)
1373{ 1378{
1374 struct drm_connector *connector; 1379 struct drm_connector *connector;
1375 struct drm_encoder *encoder; 1380 struct intel_sdvo *encoder;
1376 struct intel_sdvo *intel_sdvo; 1381
1377 1382 list_for_each_entry(encoder,
1378 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { 1383 &dev->mode_config.encoder_list,
1379 intel_sdvo = enc_to_intel_sdvo(encoder); 1384 base.base.head) {
1380 if (intel_sdvo->base.type == INTEL_OUTPUT_ANALOG) { 1385 if (encoder->base.type == INTEL_OUTPUT_ANALOG) {
1381 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1386 list_for_each_entry(connector,
1382 if (encoder == intel_attached_encoder(connector)) 1387 &dev->mode_config.connector_list,
1388 head) {
1389 if (&encoder->base ==
1390 intel_attached_encoder(connector))
1383 return connector; 1391 return connector;
1384 } 1392 }
1385 } 1393 }
1386 } 1394 }
1395
1387 return NULL; 1396 return NULL;
1388} 1397}
1389 1398
@@ -1406,8 +1415,7 @@ intel_analog_is_connected(struct drm_device *dev)
1406enum drm_connector_status 1415enum drm_connector_status
1407intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) 1416intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1408{ 1417{
1409 struct drm_encoder *encoder = intel_attached_encoder(connector); 1418 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1410 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1411 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); 1419 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1412 enum drm_connector_status status = connector_status_connected; 1420 enum drm_connector_status status = connector_status_connected;
1413 struct edid *edid = NULL; 1421 struct edid *edid = NULL;
@@ -1468,8 +1476,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1468static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) 1476static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector)
1469{ 1477{
1470 uint16_t response; 1478 uint16_t response;
1471 struct drm_encoder *encoder = intel_attached_encoder(connector); 1479 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1472 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1473 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); 1480 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1474 enum drm_connector_status ret; 1481 enum drm_connector_status ret;
1475 1482
@@ -1516,8 +1523,7 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1516 1523
1517static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) 1524static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
1518{ 1525{
1519 struct drm_encoder *encoder = intel_attached_encoder(connector); 1526 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1520 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1521 int num_modes; 1527 int num_modes;
1522 1528
1523 /* set the bus switch and get the modes */ 1529 /* set the bus switch and get the modes */
@@ -1605,8 +1611,7 @@ struct drm_display_mode sdvo_tv_modes[] = {
1605 1611
1606static void intel_sdvo_get_tv_modes(struct drm_connector *connector) 1612static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1607{ 1613{
1608 struct drm_encoder *encoder = intel_attached_encoder(connector); 1614 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1609 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1610 struct intel_sdvo_sdtv_resolution_request tv_res; 1615 struct intel_sdvo_sdtv_resolution_request tv_res;
1611 uint32_t reply = 0, format_map = 0; 1616 uint32_t reply = 0, format_map = 0;
1612 int i; 1617 int i;
@@ -1640,8 +1645,7 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1640 1645
1641static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) 1646static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1642{ 1647{
1643 struct drm_encoder *encoder = intel_attached_encoder(connector); 1648 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1644 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1645 struct drm_i915_private *dev_priv = connector->dev->dev_private; 1649 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1646 struct drm_display_mode *newmode; 1650 struct drm_display_mode *newmode;
1647 1651
@@ -1757,8 +1761,7 @@ intel_sdvo_set_property(struct drm_connector *connector,
1757 struct drm_property *property, 1761 struct drm_property *property,
1758 uint64_t val) 1762 uint64_t val)
1759{ 1763{
1760 struct drm_encoder *encoder = intel_attached_encoder(connector); 1764 struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1761 struct intel_sdvo *intel_sdvo = enc_to_intel_sdvo(encoder);
1762 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector); 1765 struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
1763 uint16_t temp_value; 1766 uint16_t temp_value;
1764 uint8_t cmd; 1767 uint8_t cmd;
@@ -1861,9 +1864,8 @@ set_value:
1861 1864
1862 1865
1863done: 1866done:
1864 if (encoder->crtc) { 1867 if (intel_sdvo->base.base.crtc) {
1865 struct drm_crtc *crtc = encoder->crtc; 1868 struct drm_crtc *crtc = intel_sdvo->base.base.crtc;
1866
1867 drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x, 1869 drm_crtc_helper_set_mode(crtc, &crtc->mode, crtc->x,
1868 crtc->y, crtc->fb); 1870 crtc->y, crtc->fb);
1869 } 1871 }
@@ -1891,7 +1893,7 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = {
1891static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = { 1893static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {
1892 .get_modes = intel_sdvo_get_modes, 1894 .get_modes = intel_sdvo_get_modes,
1893 .mode_valid = intel_sdvo_mode_valid, 1895 .mode_valid = intel_sdvo_mode_valid,
1894 .best_encoder = intel_attached_encoder, 1896 .best_encoder = intel_best_encoder,
1895}; 1897};
1896 1898
1897static void intel_sdvo_enc_destroy(struct drm_encoder *encoder) 1899static void intel_sdvo_enc_destroy(struct drm_encoder *encoder)
@@ -2058,20 +2060,23 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg)
2058} 2060}
2059 2061
2060static void 2062static void
2061intel_sdvo_connector_init(struct drm_encoder *encoder, 2063intel_sdvo_connector_init(struct intel_sdvo_connector *connector,
2062 struct drm_connector *connector) 2064 struct intel_sdvo *encoder)
2063{ 2065{
2064 drm_connector_init(encoder->dev, connector, &intel_sdvo_connector_funcs, 2066 drm_connector_init(encoder->base.base.dev,
2065 connector->connector_type); 2067 &connector->base.base,
2068 &intel_sdvo_connector_funcs,
2069 connector->base.base.connector_type);
2066 2070
2067 drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); 2071 drm_connector_helper_add(&connector->base.base,
2072 &intel_sdvo_connector_helper_funcs);
2068 2073
2069 connector->interlace_allowed = 0; 2074 connector->base.base.interlace_allowed = 0;
2070 connector->doublescan_allowed = 0; 2075 connector->base.base.doublescan_allowed = 0;
2071 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 2076 connector->base.base.display_info.subpixel_order = SubPixelHorizontalRGB;
2072 2077
2073 drm_mode_connector_attach_encoder(connector, encoder); 2078 intel_connector_attach_encoder(&connector->base, &encoder->base);
2074 drm_sysfs_connector_add(connector); 2079 drm_sysfs_connector_add(&connector->base.base);
2075} 2080}
2076 2081
2077static bool 2082static bool
@@ -2112,7 +2117,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2112 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2117 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
2113 (1 << INTEL_ANALOG_CLONE_BIT)); 2118 (1 << INTEL_ANALOG_CLONE_BIT));
2114 2119
2115 intel_sdvo_connector_init(encoder, connector); 2120 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2116 2121
2117 return true; 2122 return true;
2118} 2123}
@@ -2141,7 +2146,7 @@ intel_sdvo_tv_init(struct intel_sdvo *intel_sdvo, int type)
2141 intel_sdvo->base.needs_tv_clock = true; 2146 intel_sdvo->base.needs_tv_clock = true;
2142 intel_sdvo->base.clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; 2147 intel_sdvo->base.clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT;
2143 2148
2144 intel_sdvo_connector_init(encoder, connector); 2149 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2145 2150
2146 if (!intel_sdvo_tv_create_property(intel_sdvo, intel_sdvo_connector, type)) 2151 if (!intel_sdvo_tv_create_property(intel_sdvo, intel_sdvo_connector, type))
2147 goto err; 2152 goto err;
@@ -2186,7 +2191,8 @@ intel_sdvo_analog_init(struct intel_sdvo *intel_sdvo, int device)
2186 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2191 intel_sdvo->base.clone_mask = ((1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
2187 (1 << INTEL_ANALOG_CLONE_BIT)); 2192 (1 << INTEL_ANALOG_CLONE_BIT));
2188 2193
2189 intel_sdvo_connector_init(encoder, connector); 2194 intel_sdvo_connector_init(intel_sdvo_connector,
2195 intel_sdvo);
2190 return true; 2196 return true;
2191} 2197}
2192 2198
@@ -2218,7 +2224,7 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
2218 intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) | 2224 intel_sdvo->base.clone_mask = ((1 << INTEL_ANALOG_CLONE_BIT) |
2219 (1 << INTEL_SDVO_LVDS_CLONE_BIT)); 2225 (1 << INTEL_SDVO_LVDS_CLONE_BIT));
2220 2226
2221 intel_sdvo_connector_init(encoder, connector); 2227 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2222 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) 2228 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector))
2223 goto err; 2229 goto err;
2224 2230