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.c110
1 files changed, 75 insertions, 35 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 3093b4d4a4dd..9a00adb3a508 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -36,7 +36,7 @@
36#include "intel_sdvo_regs.h" 36#include "intel_sdvo_regs.h"
37 37
38#undef SDVO_DEBUG 38#undef SDVO_DEBUG
39 39#define I915_SDVO "i915_sdvo"
40struct intel_sdvo_priv { 40struct intel_sdvo_priv {
41 struct intel_i2c_chan *i2c_bus; 41 struct intel_i2c_chan *i2c_bus;
42 int slaveaddr; 42 int slaveaddr;
@@ -277,20 +277,21 @@ static void intel_sdvo_debug_write(struct intel_output *intel_output, u8 cmd,
277 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 277 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
278 int i; 278 int i;
279 279
280 printk(KERN_DEBUG "%s: W: %02X ", SDVO_NAME(sdvo_priv), cmd); 280 DRM_DEBUG_KMS(I915_SDVO, "%s: W: %02X ",
281 SDVO_NAME(sdvo_priv), cmd);
281 for (i = 0; i < args_len; i++) 282 for (i = 0; i < args_len; i++)
282 printk(KERN_DEBUG "%02X ", ((u8 *)args)[i]); 283 DRM_LOG_KMS("%02X ", ((u8 *)args)[i]);
283 for (; i < 8; i++) 284 for (; i < 8; i++)
284 printk(KERN_DEBUG " "); 285 DRM_LOG_KMS(" ");
285 for (i = 0; i < sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]); i++) { 286 for (i = 0; i < sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]); i++) {
286 if (cmd == sdvo_cmd_names[i].cmd) { 287 if (cmd == sdvo_cmd_names[i].cmd) {
287 printk(KERN_DEBUG "(%s)", sdvo_cmd_names[i].name); 288 DRM_LOG_KMS("(%s)", sdvo_cmd_names[i].name);
288 break; 289 break;
289 } 290 }
290 } 291 }
291 if (i == sizeof(sdvo_cmd_names)/ sizeof(sdvo_cmd_names[0])) 292 if (i == sizeof(sdvo_cmd_names)/ sizeof(sdvo_cmd_names[0]))
292 printk(KERN_DEBUG "(%02X)", cmd); 293 DRM_LOG_KMS("(%02X)", cmd);
293 printk(KERN_DEBUG "\n"); 294 DRM_LOG_KMS("\n");
294} 295}
295#else 296#else
296#define intel_sdvo_debug_write(o, c, a, l) 297#define intel_sdvo_debug_write(o, c, a, l)
@@ -329,16 +330,16 @@ static void intel_sdvo_debug_response(struct intel_output *intel_output,
329 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 330 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
330 int i; 331 int i;
331 332
332 printk(KERN_DEBUG "%s: R: ", SDVO_NAME(sdvo_priv)); 333 DRM_DEBUG_KMS(I915_SDVO, "%s: R: ", SDVO_NAME(sdvo_priv));
333 for (i = 0; i < response_len; i++) 334 for (i = 0; i < response_len; i++)
334 printk(KERN_DEBUG "%02X ", ((u8 *)response)[i]); 335 DRM_LOG_KMS("%02X ", ((u8 *)response)[i]);
335 for (; i < 8; i++) 336 for (; i < 8; i++)
336 printk(KERN_DEBUG " "); 337 DRM_LOG_KMS(" ");
337 if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP) 338 if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP)
338 printk(KERN_DEBUG "(%s)", cmd_status_names[status]); 339 DRM_LOG_KMS("(%s)", cmd_status_names[status]);
339 else 340 else
340 printk(KERN_DEBUG "(??? %d)", status); 341 DRM_LOG_KMS("(??? %d)", status);
341 printk(KERN_DEBUG "\n"); 342 DRM_LOG_KMS("\n");
342} 343}
343#else 344#else
344#define intel_sdvo_debug_response(o, r, l, s) 345#define intel_sdvo_debug_response(o, r, l, s)
@@ -1742,6 +1743,43 @@ static struct i2c_algorithm intel_sdvo_i2c_bit_algo = {
1742 .master_xfer = intel_sdvo_master_xfer, 1743 .master_xfer = intel_sdvo_master_xfer,
1743}; 1744};
1744 1745
1746static u8
1747intel_sdvo_get_slave_addr(struct drm_device *dev, int output_device)
1748{
1749 struct drm_i915_private *dev_priv = dev->dev_private;
1750 struct sdvo_device_mapping *my_mapping, *other_mapping;
1751
1752 if (output_device == SDVOB) {
1753 my_mapping = &dev_priv->sdvo_mappings[0];
1754 other_mapping = &dev_priv->sdvo_mappings[1];
1755 } else {
1756 my_mapping = &dev_priv->sdvo_mappings[1];
1757 other_mapping = &dev_priv->sdvo_mappings[0];
1758 }
1759
1760 /* If the BIOS described our SDVO device, take advantage of it. */
1761 if (my_mapping->slave_addr)
1762 return my_mapping->slave_addr;
1763
1764 /* If the BIOS only described a different SDVO device, use the
1765 * address that it isn't using.
1766 */
1767 if (other_mapping->slave_addr) {
1768 if (other_mapping->slave_addr == 0x70)
1769 return 0x72;
1770 else
1771 return 0x70;
1772 }
1773
1774 /* No SDVO device info is found for another DVO port,
1775 * so use mapping assumption we had before BIOS parsing.
1776 */
1777 if (output_device == SDVOB)
1778 return 0x70;
1779 else
1780 return 0x72;
1781}
1782
1745bool intel_sdvo_init(struct drm_device *dev, int output_device) 1783bool intel_sdvo_init(struct drm_device *dev, int output_device)
1746{ 1784{
1747 struct drm_connector *connector; 1785 struct drm_connector *connector;
@@ -1753,6 +1791,7 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1753 u8 ch[0x40]; 1791 u8 ch[0x40];
1754 int i; 1792 int i;
1755 int encoder_type, output_id; 1793 int encoder_type, output_id;
1794 u8 slave_addr;
1756 1795
1757 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); 1796 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
1758 if (!intel_output) { 1797 if (!intel_output) {
@@ -1771,16 +1810,15 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1771 if (!i2cbus) 1810 if (!i2cbus)
1772 goto err_inteloutput; 1811 goto err_inteloutput;
1773 1812
1813 slave_addr = intel_sdvo_get_slave_addr(dev, output_device);
1774 sdvo_priv->i2c_bus = i2cbus; 1814 sdvo_priv->i2c_bus = i2cbus;
1775 1815
1776 if (output_device == SDVOB) { 1816 if (output_device == SDVOB) {
1777 output_id = 1; 1817 output_id = 1;
1778 sdvo_priv->i2c_bus->slave_addr = 0x38;
1779 } else { 1818 } else {
1780 output_id = 2; 1819 output_id = 2;
1781 sdvo_priv->i2c_bus->slave_addr = 0x39;
1782 } 1820 }
1783 1821 sdvo_priv->i2c_bus->slave_addr = slave_addr >> 1;
1784 sdvo_priv->output_device = output_device; 1822 sdvo_priv->output_device = output_device;
1785 intel_output->i2c_bus = i2cbus; 1823 intel_output->i2c_bus = i2cbus;
1786 intel_output->dev_priv = sdvo_priv; 1824 intel_output->dev_priv = sdvo_priv;
@@ -1788,8 +1826,9 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1788 /* Read the regs to test if we can talk to the device */ 1826 /* Read the regs to test if we can talk to the device */
1789 for (i = 0; i < 0x40; i++) { 1827 for (i = 0; i < 0x40; i++) {
1790 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { 1828 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) {
1791 DRM_DEBUG("No SDVO device found on SDVO%c\n", 1829 DRM_DEBUG_KMS(I915_SDVO,
1792 output_device == SDVOB ? 'B' : 'C'); 1830 "No SDVO device found on SDVO%c\n",
1831 output_device == SDVOB ? 'B' : 'C');
1793 goto err_i2c; 1832 goto err_i2c;
1794 } 1833 }
1795 } 1834 }
@@ -1873,9 +1912,10 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1873 1912
1874 sdvo_priv->controlled_output = 0; 1913 sdvo_priv->controlled_output = 0;
1875 memcpy (bytes, &sdvo_priv->caps.output_flags, 2); 1914 memcpy (bytes, &sdvo_priv->caps.output_flags, 2);
1876 DRM_DEBUG("%s: Unknown SDVO output type (0x%02x%02x)\n", 1915 DRM_DEBUG_KMS(I915_SDVO,
1877 SDVO_NAME(sdvo_priv), 1916 "%s: Unknown SDVO output type (0x%02x%02x)\n",
1878 bytes[0], bytes[1]); 1917 SDVO_NAME(sdvo_priv),
1918 bytes[0], bytes[1]);
1879 encoder_type = DRM_MODE_ENCODER_NONE; 1919 encoder_type = DRM_MODE_ENCODER_NONE;
1880 connector_type = DRM_MODE_CONNECTOR_Unknown; 1920 connector_type = DRM_MODE_CONNECTOR_Unknown;
1881 goto err_i2c; 1921 goto err_i2c;
@@ -1905,21 +1945,21 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1905 &sdvo_priv->pixel_clock_max); 1945 &sdvo_priv->pixel_clock_max);
1906 1946
1907 1947
1908 DRM_DEBUG("%s device VID/DID: %02X:%02X.%02X, " 1948 DRM_DEBUG_KMS(I915_SDVO, "%s device VID/DID: %02X:%02X.%02X, "
1909 "clock range %dMHz - %dMHz, " 1949 "clock range %dMHz - %dMHz, "
1910 "input 1: %c, input 2: %c, " 1950 "input 1: %c, input 2: %c, "
1911 "output 1: %c, output 2: %c\n", 1951 "output 1: %c, output 2: %c\n",
1912 SDVO_NAME(sdvo_priv), 1952 SDVO_NAME(sdvo_priv),
1913 sdvo_priv->caps.vendor_id, sdvo_priv->caps.device_id, 1953 sdvo_priv->caps.vendor_id, sdvo_priv->caps.device_id,
1914 sdvo_priv->caps.device_rev_id, 1954 sdvo_priv->caps.device_rev_id,
1915 sdvo_priv->pixel_clock_min / 1000, 1955 sdvo_priv->pixel_clock_min / 1000,
1916 sdvo_priv->pixel_clock_max / 1000, 1956 sdvo_priv->pixel_clock_max / 1000,
1917 (sdvo_priv->caps.sdvo_inputs_mask & 0x1) ? 'Y' : 'N', 1957 (sdvo_priv->caps.sdvo_inputs_mask & 0x1) ? 'Y' : 'N',
1918 (sdvo_priv->caps.sdvo_inputs_mask & 0x2) ? 'Y' : 'N', 1958 (sdvo_priv->caps.sdvo_inputs_mask & 0x2) ? 'Y' : 'N',
1919 /* check currently supported outputs */ 1959 /* check currently supported outputs */
1920 sdvo_priv->caps.output_flags & 1960 sdvo_priv->caps.output_flags &
1921 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_RGB0) ? 'Y' : 'N', 1961 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_RGB0) ? 'Y' : 'N',
1922 sdvo_priv->caps.output_flags & 1962 sdvo_priv->caps.output_flags &
1923 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); 1963 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
1924 1964
1925 return true; 1965 return true;