aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_sdvo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/intel_sdvo.c')
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index e36b171c1e7d..6898145b44ce 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -41,7 +41,7 @@
41#define SDVO_TMDS_MASK (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1) 41#define SDVO_TMDS_MASK (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)
42#define SDVO_RGB_MASK (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1) 42#define SDVO_RGB_MASK (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1)
43#define SDVO_LVDS_MASK (SDVO_OUTPUT_LVDS0 | SDVO_OUTPUT_LVDS1) 43#define SDVO_LVDS_MASK (SDVO_OUTPUT_LVDS0 | SDVO_OUTPUT_LVDS1)
44#define SDVO_TV_MASK (SDVO_OUTPUT_CVBS0 | SDVO_OUTPUT_SVID0) 44#define SDVO_TV_MASK (SDVO_OUTPUT_CVBS0 | SDVO_OUTPUT_SVID0 | SDVO_OUTPUT_YPRPB0)
45 45
46#define SDVO_OUTPUT_MASK (SDVO_TMDS_MASK | SDVO_RGB_MASK | SDVO_LVDS_MASK |\ 46#define SDVO_OUTPUT_MASK (SDVO_TMDS_MASK | SDVO_RGB_MASK | SDVO_LVDS_MASK |\
47 SDVO_TV_MASK) 47 SDVO_TV_MASK)
@@ -74,7 +74,7 @@ struct intel_sdvo {
74 struct i2c_adapter ddc; 74 struct i2c_adapter ddc;
75 75
76 /* Register for the SDVO device: SDVOB or SDVOC */ 76 /* Register for the SDVO device: SDVOB or SDVOC */
77 int sdvo_reg; 77 uint32_t sdvo_reg;
78 78
79 /* Active outputs controlled by this SDVO output */ 79 /* Active outputs controlled by this SDVO output */
80 uint16_t controlled_output; 80 uint16_t controlled_output;
@@ -114,6 +114,9 @@ struct intel_sdvo {
114 */ 114 */
115 bool is_tv; 115 bool is_tv;
116 116
117 /* On different gens SDVOB is at different places. */
118 bool is_sdvob;
119
117 /* This is for current tv format name */ 120 /* This is for current tv format name */
118 int tv_format_index; 121 int tv_format_index;
119 122
@@ -403,8 +406,7 @@ static const struct _sdvo_cmd_name {
403 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA), 406 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA),
404}; 407};
405 408
406#define IS_SDVOB(reg) (reg == SDVOB || reg == PCH_SDVOB) 409#define SDVO_NAME(svdo) ((svdo)->is_sdvob ? "SDVOB" : "SDVOC")
407#define SDVO_NAME(svdo) (IS_SDVOB((svdo)->sdvo_reg) ? "SDVOB" : "SDVOC")
408 410
409static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd, 411static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd,
410 const void *args, int args_len) 412 const void *args, int args_len)
@@ -1252,7 +1254,8 @@ intel_sdvo_get_analog_edid(struct drm_connector *connector)
1252 struct drm_i915_private *dev_priv = connector->dev->dev_private; 1254 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1253 1255
1254 return drm_get_edid(connector, 1256 return drm_get_edid(connector,
1255 &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter); 1257 intel_gmbus_get_adapter(dev_priv,
1258 dev_priv->crt_ddc_pin));
1256} 1259}
1257 1260
1258enum drm_connector_status 1261enum drm_connector_status
@@ -1341,8 +1344,7 @@ intel_sdvo_detect(struct drm_connector *connector, bool force)
1341 return connector_status_unknown; 1344 return connector_status_unknown;
1342 1345
1343 /* add 30ms delay when the output type might be TV */ 1346 /* add 30ms delay when the output type might be TV */
1344 if (intel_sdvo->caps.output_flags & 1347 if (intel_sdvo->caps.output_flags & SDVO_TV_MASK)
1345 (SDVO_OUTPUT_SVID0 | SDVO_OUTPUT_CVBS0))
1346 mdelay(30); 1348 mdelay(30);
1347 1349
1348 if (!intel_sdvo_read_response(intel_sdvo, &response, 2)) 1350 if (!intel_sdvo_read_response(intel_sdvo, &response, 2))
@@ -1893,7 +1895,7 @@ intel_sdvo_select_ddc_bus(struct drm_i915_private *dev_priv,
1893{ 1895{
1894 struct sdvo_device_mapping *mapping; 1896 struct sdvo_device_mapping *mapping;
1895 1897
1896 if (IS_SDVOB(reg)) 1898 if (sdvo->is_sdvob)
1897 mapping = &(dev_priv->sdvo_mappings[0]); 1899 mapping = &(dev_priv->sdvo_mappings[0]);
1898 else 1900 else
1899 mapping = &(dev_priv->sdvo_mappings[1]); 1901 mapping = &(dev_priv->sdvo_mappings[1]);
@@ -1911,7 +1913,7 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
1911 struct sdvo_device_mapping *mapping; 1913 struct sdvo_device_mapping *mapping;
1912 u8 pin; 1914 u8 pin;
1913 1915
1914 if (IS_SDVOB(reg)) 1916 if (sdvo->is_sdvob)
1915 mapping = &dev_priv->sdvo_mappings[0]; 1917 mapping = &dev_priv->sdvo_mappings[0];
1916 else 1918 else
1917 mapping = &dev_priv->sdvo_mappings[1]; 1919 mapping = &dev_priv->sdvo_mappings[1];
@@ -1920,12 +1922,12 @@ intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
1920 if (mapping->initialized) 1922 if (mapping->initialized)
1921 pin = mapping->i2c_pin; 1923 pin = mapping->i2c_pin;
1922 1924
1923 if (pin < GMBUS_NUM_PORTS) { 1925 if (intel_gmbus_is_port_valid(pin)) {
1924 sdvo->i2c = &dev_priv->gmbus[pin].adapter; 1926 sdvo->i2c = intel_gmbus_get_adapter(dev_priv, pin);
1925 intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ); 1927 intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ);
1926 intel_gmbus_force_bit(sdvo->i2c, true); 1928 intel_gmbus_force_bit(sdvo->i2c, true);
1927 } else { 1929 } else {
1928 sdvo->i2c = &dev_priv->gmbus[GMBUS_PORT_DPB].adapter; 1930 sdvo->i2c = intel_gmbus_get_adapter(dev_priv, GMBUS_PORT_DPB);
1929 } 1931 }
1930} 1932}
1931 1933
@@ -1936,12 +1938,12 @@ intel_sdvo_is_hdmi_connector(struct intel_sdvo *intel_sdvo, int device)
1936} 1938}
1937 1939
1938static u8 1940static u8
1939intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg) 1941intel_sdvo_get_slave_addr(struct drm_device *dev, struct intel_sdvo *sdvo)
1940{ 1942{
1941 struct drm_i915_private *dev_priv = dev->dev_private; 1943 struct drm_i915_private *dev_priv = dev->dev_private;
1942 struct sdvo_device_mapping *my_mapping, *other_mapping; 1944 struct sdvo_device_mapping *my_mapping, *other_mapping;
1943 1945
1944 if (IS_SDVOB(sdvo_reg)) { 1946 if (sdvo->is_sdvob) {
1945 my_mapping = &dev_priv->sdvo_mappings[0]; 1947 my_mapping = &dev_priv->sdvo_mappings[0];
1946 other_mapping = &dev_priv->sdvo_mappings[1]; 1948 other_mapping = &dev_priv->sdvo_mappings[1];
1947 } else { 1949 } else {
@@ -1966,7 +1968,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg)
1966 /* No SDVO device info is found for another DVO port, 1968 /* No SDVO device info is found for another DVO port,
1967 * so use mapping assumption we had before BIOS parsing. 1969 * so use mapping assumption we had before BIOS parsing.
1968 */ 1970 */
1969 if (IS_SDVOB(sdvo_reg)) 1971 if (sdvo->is_sdvob)
1970 return 0x70; 1972 return 0x70;
1971 else 1973 else
1972 return 0x72; 1974 return 0x72;
@@ -2191,6 +2193,10 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags)
2191 if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_CVBS0)) 2193 if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_CVBS0))
2192 return false; 2194 return false;
2193 2195
2196 if (flags & SDVO_OUTPUT_YPRPB0)
2197 if (!intel_sdvo_tv_init(intel_sdvo, SDVO_OUTPUT_YPRPB0))
2198 return false;
2199
2194 if (flags & SDVO_OUTPUT_RGB0) 2200 if (flags & SDVO_OUTPUT_RGB0)
2195 if (!intel_sdvo_analog_init(intel_sdvo, 0)) 2201 if (!intel_sdvo_analog_init(intel_sdvo, 0))
2196 return false; 2202 return false;
@@ -2482,7 +2488,7 @@ intel_sdvo_init_ddc_proxy(struct intel_sdvo *sdvo,
2482 return i2c_add_adapter(&sdvo->ddc) == 0; 2488 return i2c_add_adapter(&sdvo->ddc) == 0;
2483} 2489}
2484 2490
2485bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg) 2491bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2486{ 2492{
2487 struct drm_i915_private *dev_priv = dev->dev_private; 2493 struct drm_i915_private *dev_priv = dev->dev_private;
2488 struct intel_encoder *intel_encoder; 2494 struct intel_encoder *intel_encoder;
@@ -2494,7 +2500,8 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
2494 return false; 2500 return false;
2495 2501
2496 intel_sdvo->sdvo_reg = sdvo_reg; 2502 intel_sdvo->sdvo_reg = sdvo_reg;
2497 intel_sdvo->slave_addr = intel_sdvo_get_slave_addr(dev, sdvo_reg) >> 1; 2503 intel_sdvo->is_sdvob = is_sdvob;
2504 intel_sdvo->slave_addr = intel_sdvo_get_slave_addr(dev, intel_sdvo) >> 1;
2498 intel_sdvo_select_i2c_bus(dev_priv, intel_sdvo, sdvo_reg); 2505 intel_sdvo_select_i2c_bus(dev_priv, intel_sdvo, sdvo_reg);
2499 if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev)) { 2506 if (!intel_sdvo_init_ddc_proxy(intel_sdvo, dev)) {
2500 kfree(intel_sdvo); 2507 kfree(intel_sdvo);
@@ -2511,13 +2518,13 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
2511 u8 byte; 2518 u8 byte;
2512 2519
2513 if (!intel_sdvo_read_byte(intel_sdvo, i, &byte)) { 2520 if (!intel_sdvo_read_byte(intel_sdvo, i, &byte)) {
2514 DRM_DEBUG_KMS("No SDVO device found on SDVO%c\n", 2521 DRM_DEBUG_KMS("No SDVO device found on %s\n",
2515 IS_SDVOB(sdvo_reg) ? 'B' : 'C'); 2522 SDVO_NAME(intel_sdvo));
2516 goto err; 2523 goto err;
2517 } 2524 }
2518 } 2525 }
2519 2526
2520 if (IS_SDVOB(sdvo_reg)) 2527 if (intel_sdvo->is_sdvob)
2521 dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS; 2528 dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS;
2522 else 2529 else
2523 dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS; 2530 dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS;
@@ -2538,8 +2545,8 @@ bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
2538 2545
2539 if (intel_sdvo_output_setup(intel_sdvo, 2546 if (intel_sdvo_output_setup(intel_sdvo,
2540 intel_sdvo->caps.output_flags) != true) { 2547 intel_sdvo->caps.output_flags) != true) {
2541 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n", 2548 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
2542 IS_SDVOB(sdvo_reg) ? 'B' : 'C'); 2549 SDVO_NAME(intel_sdvo));
2543 goto err; 2550 goto err;
2544 } 2551 }
2545 2552