aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_sdvo.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2009-06-12 11:02:03 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2009-06-12 11:02:03 -0400
commit82681a318f9f028ea64e61f24bbd9ac535531921 (patch)
tree529b6a5b4fd040fb54b7672b1a224ebd47445876 /drivers/gpu/drm/i915/intel_sdvo.c
parent3860c97bd60a4525bb62eb90e3e7d2f02662ac59 (diff)
parent8ebf975608aaebd7feb33d77f07ba21a6380e086 (diff)
[SCSI] Merge branch 'linus'
Conflicts: drivers/message/fusion/mptsas.c fixed up conflict between req->data_len accessors and mptsas driver updates. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_sdvo.c')
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c138
1 files changed, 115 insertions, 23 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 9913651c1e17..3093b4d4a4dd 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -69,6 +69,10 @@ struct intel_sdvo_priv {
69 * This is set if we treat the device as HDMI, instead of DVI. 69 * This is set if we treat the device as HDMI, instead of DVI.
70 */ 70 */
71 bool is_hdmi; 71 bool is_hdmi;
72 /**
73 * This is set if we detect output of sdvo device as LVDS.
74 */
75 bool is_lvds;
72 76
73 /** 77 /**
74 * Returned SDTV resolutions allowed for the current format, if the 78 * Returned SDTV resolutions allowed for the current format, if the
@@ -1398,10 +1402,8 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1398static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) 1402static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
1399{ 1403{
1400 struct intel_output *intel_output = to_intel_output(connector); 1404 struct intel_output *intel_output = to_intel_output(connector);
1401 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1402 1405
1403 /* set the bus switch and get the modes */ 1406 /* set the bus switch and get the modes */
1404 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1405 intel_ddc_get_modes(intel_output); 1407 intel_ddc_get_modes(intel_output);
1406 1408
1407#if 0 1409#if 0
@@ -1543,6 +1545,37 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1543 } 1545 }
1544} 1546}
1545 1547
1548static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1549{
1550 struct intel_output *intel_output = to_intel_output(connector);
1551 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1552 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1553
1554 /*
1555 * Attempt to get the mode list from DDC.
1556 * Assume that the preferred modes are
1557 * arranged in priority order.
1558 */
1559 /* set the bus switch and get the modes */
1560 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1561 intel_ddc_get_modes(intel_output);
1562 if (list_empty(&connector->probed_modes) == false)
1563 return;
1564
1565 /* Fetch modes from VBT */
1566 if (dev_priv->sdvo_lvds_vbt_mode != NULL) {
1567 struct drm_display_mode *newmode;
1568 newmode = drm_mode_duplicate(connector->dev,
1569 dev_priv->sdvo_lvds_vbt_mode);
1570 if (newmode != NULL) {
1571 /* Guarantee the mode is preferred */
1572 newmode->type = (DRM_MODE_TYPE_PREFERRED |
1573 DRM_MODE_TYPE_DRIVER);
1574 drm_mode_probed_add(connector, newmode);
1575 }
1576 }
1577}
1578
1546static int intel_sdvo_get_modes(struct drm_connector *connector) 1579static int intel_sdvo_get_modes(struct drm_connector *connector)
1547{ 1580{
1548 struct intel_output *output = to_intel_output(connector); 1581 struct intel_output *output = to_intel_output(connector);
@@ -1550,6 +1583,8 @@ static int intel_sdvo_get_modes(struct drm_connector *connector)
1550 1583
1551 if (sdvo_priv->is_tv) 1584 if (sdvo_priv->is_tv)
1552 intel_sdvo_get_tv_modes(connector); 1585 intel_sdvo_get_tv_modes(connector);
1586 else if (sdvo_priv->is_lvds == true)
1587 intel_sdvo_get_lvds_modes(connector);
1553 else 1588 else
1554 intel_sdvo_get_ddc_modes(connector); 1589 intel_sdvo_get_ddc_modes(connector);
1555 1590
@@ -1564,6 +1599,9 @@ static void intel_sdvo_destroy(struct drm_connector *connector)
1564 1599
1565 if (intel_output->i2c_bus) 1600 if (intel_output->i2c_bus)
1566 intel_i2c_destroy(intel_output->i2c_bus); 1601 intel_i2c_destroy(intel_output->i2c_bus);
1602 if (intel_output->ddc_bus)
1603 intel_i2c_destroy(intel_output->ddc_bus);
1604
1567 drm_sysfs_connector_remove(connector); 1605 drm_sysfs_connector_remove(connector);
1568 drm_connector_cleanup(connector); 1606 drm_connector_cleanup(connector);
1569 kfree(intel_output); 1607 kfree(intel_output);
@@ -1578,6 +1616,7 @@ static const struct drm_encoder_helper_funcs intel_sdvo_helper_funcs = {
1578}; 1616};
1579 1617
1580static const struct drm_connector_funcs intel_sdvo_connector_funcs = { 1618static const struct drm_connector_funcs intel_sdvo_connector_funcs = {
1619 .dpms = drm_helper_connector_dpms,
1581 .save = intel_sdvo_save, 1620 .save = intel_sdvo_save,
1582 .restore = intel_sdvo_restore, 1621 .restore = intel_sdvo_restore,
1583 .detect = intel_sdvo_detect, 1622 .detect = intel_sdvo_detect,
@@ -1660,12 +1699,56 @@ intel_sdvo_get_digital_encoding_mode(struct intel_output *output)
1660 return true; 1699 return true;
1661} 1700}
1662 1701
1702static struct intel_output *
1703intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan)
1704{
1705 struct drm_device *dev = chan->drm_dev;
1706 struct drm_connector *connector;
1707 struct intel_output *intel_output = NULL;
1708
1709 list_for_each_entry(connector,
1710 &dev->mode_config.connector_list, head) {
1711 if (to_intel_output(connector)->ddc_bus == chan) {
1712 intel_output = to_intel_output(connector);
1713 break;
1714 }
1715 }
1716 return intel_output;
1717}
1718
1719static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
1720 struct i2c_msg msgs[], int num)
1721{
1722 struct intel_output *intel_output;
1723 struct intel_sdvo_priv *sdvo_priv;
1724 struct i2c_algo_bit_data *algo_data;
1725 struct i2c_algorithm *algo;
1726
1727 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data;
1728 intel_output =
1729 intel_sdvo_chan_to_intel_output(
1730 (struct intel_i2c_chan *)(algo_data->data));
1731 if (intel_output == NULL)
1732 return -EINVAL;
1733
1734 sdvo_priv = intel_output->dev_priv;
1735 algo = (struct i2c_algorithm *)intel_output->i2c_bus->adapter.algo;
1736
1737 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1738 return algo->master_xfer(i2c_adap, msgs, num);
1739}
1740
1741static struct i2c_algorithm intel_sdvo_i2c_bit_algo = {
1742 .master_xfer = intel_sdvo_master_xfer,
1743};
1744
1663bool intel_sdvo_init(struct drm_device *dev, int output_device) 1745bool intel_sdvo_init(struct drm_device *dev, int output_device)
1664{ 1746{
1665 struct drm_connector *connector; 1747 struct drm_connector *connector;
1666 struct intel_output *intel_output; 1748 struct intel_output *intel_output;
1667 struct intel_sdvo_priv *sdvo_priv; 1749 struct intel_sdvo_priv *sdvo_priv;
1668 struct intel_i2c_chan *i2cbus = NULL; 1750 struct intel_i2c_chan *i2cbus = NULL;
1751 struct intel_i2c_chan *ddcbus = NULL;
1669 int connector_type; 1752 int connector_type;
1670 u8 ch[0x40]; 1753 u8 ch[0x40];
1671 int i; 1754 int i;
@@ -1676,17 +1759,9 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1676 return false; 1759 return false;
1677 } 1760 }
1678 1761
1679 connector = &intel_output->base;
1680
1681 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
1682 DRM_MODE_CONNECTOR_Unknown);
1683 drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs);
1684 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); 1762 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1);
1685 intel_output->type = INTEL_OUTPUT_SDVO; 1763 intel_output->type = INTEL_OUTPUT_SDVO;
1686 1764
1687 connector->interlace_allowed = 0;
1688 connector->doublescan_allowed = 0;
1689
1690 /* setup the DDC bus. */ 1765 /* setup the DDC bus. */
1691 if (output_device == SDVOB) 1766 if (output_device == SDVOB)
1692 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); 1767 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB");
@@ -1694,7 +1769,7 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1694 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); 1769 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
1695 1770
1696 if (!i2cbus) 1771 if (!i2cbus)
1697 goto err_connector; 1772 goto err_inteloutput;
1698 1773
1699 sdvo_priv->i2c_bus = i2cbus; 1774 sdvo_priv->i2c_bus = i2cbus;
1700 1775
@@ -1710,7 +1785,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1710 intel_output->i2c_bus = i2cbus; 1785 intel_output->i2c_bus = i2cbus;
1711 intel_output->dev_priv = sdvo_priv; 1786 intel_output->dev_priv = sdvo_priv;
1712 1787
1713
1714 /* Read the regs to test if we can talk to the device */ 1788 /* Read the regs to test if we can talk to the device */
1715 for (i = 0; i < 0x40; i++) { 1789 for (i = 0; i < 0x40; i++) {
1716 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { 1790 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) {
@@ -1720,6 +1794,22 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1720 } 1794 }
1721 } 1795 }
1722 1796
1797 /* setup the DDC bus. */
1798 if (output_device == SDVOB)
1799 ddcbus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS");
1800 else
1801 ddcbus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS");
1802
1803 if (ddcbus == NULL)
1804 goto err_i2c;
1805
1806 intel_sdvo_i2c_bit_algo.functionality =
1807 intel_output->i2c_bus->adapter.algo->functionality;
1808 ddcbus->adapter.algo = &intel_sdvo_i2c_bit_algo;
1809 intel_output->ddc_bus = ddcbus;
1810
1811 /* In defaut case sdvo lvds is false */
1812 sdvo_priv->is_lvds = false;
1723 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 1813 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps);
1724 1814
1725 if (sdvo_priv->caps.output_flags & 1815 if (sdvo_priv->caps.output_flags &
@@ -1729,7 +1819,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1729 else 1819 else
1730 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1; 1820 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
1731 1821
1732 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1733 encoder_type = DRM_MODE_ENCODER_TMDS; 1822 encoder_type = DRM_MODE_ENCODER_TMDS;
1734 connector_type = DRM_MODE_CONNECTOR_DVID; 1823 connector_type = DRM_MODE_CONNECTOR_DVID;
1735 1824
@@ -1747,7 +1836,6 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1747 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0) 1836 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0)
1748 { 1837 {
1749 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0; 1838 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1750 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1751 encoder_type = DRM_MODE_ENCODER_TVDAC; 1839 encoder_type = DRM_MODE_ENCODER_TVDAC;
1752 connector_type = DRM_MODE_CONNECTOR_SVIDEO; 1840 connector_type = DRM_MODE_CONNECTOR_SVIDEO;
1753 sdvo_priv->is_tv = true; 1841 sdvo_priv->is_tv = true;
@@ -1756,30 +1844,28 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1756 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) 1844 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0)
1757 { 1845 {
1758 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0; 1846 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
1759 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1760 encoder_type = DRM_MODE_ENCODER_DAC; 1847 encoder_type = DRM_MODE_ENCODER_DAC;
1761 connector_type = DRM_MODE_CONNECTOR_VGA; 1848 connector_type = DRM_MODE_CONNECTOR_VGA;
1762 } 1849 }
1763 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) 1850 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
1764 { 1851 {
1765 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1; 1852 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
1766 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1767 encoder_type = DRM_MODE_ENCODER_DAC; 1853 encoder_type = DRM_MODE_ENCODER_DAC;
1768 connector_type = DRM_MODE_CONNECTOR_VGA; 1854 connector_type = DRM_MODE_CONNECTOR_VGA;
1769 } 1855 }
1770 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0) 1856 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0)
1771 { 1857 {
1772 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0; 1858 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
1773 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1774 encoder_type = DRM_MODE_ENCODER_LVDS; 1859 encoder_type = DRM_MODE_ENCODER_LVDS;
1775 connector_type = DRM_MODE_CONNECTOR_LVDS; 1860 connector_type = DRM_MODE_CONNECTOR_LVDS;
1861 sdvo_priv->is_lvds = true;
1776 } 1862 }
1777 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1) 1863 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1)
1778 { 1864 {
1779 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1; 1865 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
1780 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1781 encoder_type = DRM_MODE_ENCODER_LVDS; 1866 encoder_type = DRM_MODE_ENCODER_LVDS;
1782 connector_type = DRM_MODE_CONNECTOR_LVDS; 1867 connector_type = DRM_MODE_CONNECTOR_LVDS;
1868 sdvo_priv->is_lvds = true;
1783 } 1869 }
1784 else 1870 else
1785 { 1871 {
@@ -1795,9 +1881,16 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1795 goto err_i2c; 1881 goto err_i2c;
1796 } 1882 }
1797 1883
1884 connector = &intel_output->base;
1885 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
1886 connector_type);
1887 drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs);
1888 connector->interlace_allowed = 0;
1889 connector->doublescan_allowed = 0;
1890 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1891
1798 drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type); 1892 drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type);
1799 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs); 1893 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs);
1800 connector->connector_type = connector_type;
1801 1894
1802 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1895 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
1803 drm_sysfs_connector_add(connector); 1896 drm_sysfs_connector_add(connector);
@@ -1829,14 +1922,13 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1829 sdvo_priv->caps.output_flags & 1922 sdvo_priv->caps.output_flags &
1830 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); 1923 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
1831 1924
1832 intel_output->ddc_bus = i2cbus;
1833
1834 return true; 1925 return true;
1835 1926
1836err_i2c: 1927err_i2c:
1928 if (ddcbus != NULL)
1929 intel_i2c_destroy(intel_output->ddc_bus);
1837 intel_i2c_destroy(intel_output->i2c_bus); 1930 intel_i2c_destroy(intel_output->i2c_bus);
1838err_connector: 1931err_inteloutput:
1839 drm_connector_cleanup(connector);
1840 kfree(intel_output); 1932 kfree(intel_output);
1841 1933
1842 return false; 1934 return false;