diff options
| author | Keith Packard <keithp@keithp.com> | 2009-06-14 14:56:18 -0400 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-06-18 18:54:04 -0400 |
| commit | 308cd3a2e505b0d15f2852e8db5d648b60a6313b (patch) | |
| tree | fa78d508f93ba97c069ed47ef9578f65211e4956 | |
| parent | f9c10a9b96a31b4a82a4fa807400c04f00284068 (diff) | |
drm/i915: Clean up SDVO i2c handling
Eliminate the copy of i2c_bus in sdvo_priv.
Eliminate local copies of i2c_bus and ddcbus.
Eliminate unused settings of slave_addr.
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | drivers/gpu/drm/i915/intel_sdvo.c | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 13c39c827ebf..f03473779feb 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | #undef SDVO_DEBUG | 38 | #undef SDVO_DEBUG |
| 39 | #define I915_SDVO "i915_sdvo" | 39 | #define I915_SDVO "i915_sdvo" |
| 40 | struct intel_sdvo_priv { | 40 | struct intel_sdvo_priv { |
| 41 | struct i2c_adapter *i2c_bus; | ||
| 42 | u8 slave_addr; | 41 | u8 slave_addr; |
| 43 | 42 | ||
| 44 | /* Register for the SDVO device: SDVOB or SDVOC */ | 43 | /* Register for the SDVO device: SDVOB or SDVOC */ |
| @@ -162,7 +161,7 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr, | |||
| 162 | out_buf[0] = addr; | 161 | out_buf[0] = addr; |
| 163 | out_buf[1] = 0; | 162 | out_buf[1] = 0; |
| 164 | 163 | ||
| 165 | if ((ret = i2c_transfer(sdvo_priv->i2c_bus, msgs, 2)) == 2) | 164 | if ((ret = i2c_transfer(intel_output->i2c_bus, msgs, 2)) == 2) |
| 166 | { | 165 | { |
| 167 | *ch = buf[0]; | 166 | *ch = buf[0]; |
| 168 | return true; | 167 | return true; |
| @@ -1370,7 +1369,6 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) | |||
| 1370 | struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; | 1369 | struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; |
| 1371 | struct edid *edid = NULL; | 1370 | struct edid *edid = NULL; |
| 1372 | 1371 | ||
| 1373 | intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); | ||
| 1374 | edid = drm_get_edid(&intel_output->base, | 1372 | edid = drm_get_edid(&intel_output->base, |
| 1375 | intel_output->ddc_bus); | 1373 | intel_output->ddc_bus); |
| 1376 | if (edid != NULL) { | 1374 | if (edid != NULL) { |
| @@ -1550,7 +1548,6 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector) | |||
| 1550 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) | 1548 | static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) |
| 1551 | { | 1549 | { |
| 1552 | struct intel_output *intel_output = to_intel_output(connector); | 1550 | struct intel_output *intel_output = to_intel_output(connector); |
| 1553 | struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; | ||
| 1554 | struct drm_i915_private *dev_priv = connector->dev->dev_private; | 1551 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
| 1555 | 1552 | ||
| 1556 | /* | 1553 | /* |
| @@ -1558,8 +1555,6 @@ static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) | |||
| 1558 | * Assume that the preferred modes are | 1555 | * Assume that the preferred modes are |
| 1559 | * arranged in priority order. | 1556 | * arranged in priority order. |
| 1560 | */ | 1557 | */ |
| 1561 | /* set the bus switch and get the modes */ | ||
| 1562 | intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); | ||
| 1563 | intel_ddc_get_modes(intel_output); | 1558 | intel_ddc_get_modes(intel_output); |
| 1564 | if (list_empty(&connector->probed_modes) == false) | 1559 | if (list_empty(&connector->probed_modes) == false) |
| 1565 | return; | 1560 | return; |
| @@ -1786,14 +1781,11 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) | |||
| 1786 | struct drm_connector *connector; | 1781 | struct drm_connector *connector; |
| 1787 | struct intel_output *intel_output; | 1782 | struct intel_output *intel_output; |
| 1788 | struct intel_sdvo_priv *sdvo_priv; | 1783 | struct intel_sdvo_priv *sdvo_priv; |
| 1789 | struct i2c_adapter *i2cbus = NULL; | ||
| 1790 | struct i2c_adapter *ddcbus = NULL; | ||
| 1791 | 1784 | ||
| 1792 | int connector_type; | 1785 | int connector_type; |
| 1793 | u8 ch[0x40]; | 1786 | u8 ch[0x40]; |
| 1794 | int i; | 1787 | int i; |
| 1795 | int encoder_type; | 1788 | int encoder_type; |
| 1796 | u8 slave_addr; | ||
| 1797 | 1789 | ||
| 1798 | intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); | 1790 | intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); |
| 1799 | if (!intel_output) { | 1791 | if (!intel_output) { |
| @@ -1801,27 +1793,24 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) | |||
| 1801 | } | 1793 | } |
| 1802 | 1794 | ||
| 1803 | sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); | 1795 | sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); |
| 1796 | sdvo_priv->output_device = output_device; | ||
| 1797 | |||
| 1798 | intel_output->dev_priv = sdvo_priv; | ||
| 1804 | intel_output->type = INTEL_OUTPUT_SDVO; | 1799 | intel_output->type = INTEL_OUTPUT_SDVO; |
| 1805 | 1800 | ||
| 1806 | /* setup the DDC bus. */ | 1801 | /* setup the DDC bus. */ |
| 1807 | if (output_device == SDVOB) { | 1802 | if (output_device == SDVOB) |
| 1808 | i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); | 1803 | intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); |
| 1809 | slave_addr = 0x38; | 1804 | else |
| 1810 | } else { | 1805 | intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); |
| 1811 | i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); | 1806 | |
| 1812 | slave_addr = 0x39; | 1807 | if (!intel_output->i2c_bus) |
| 1813 | } | ||
| 1814 | |||
| 1815 | if (!i2cbus) | ||
| 1816 | goto err_inteloutput; | 1808 | goto err_inteloutput; |
| 1817 | 1809 | ||
| 1818 | slave_addr = intel_sdvo_get_slave_addr(dev, output_device); | 1810 | sdvo_priv->slave_addr = intel_sdvo_get_slave_addr(dev, output_device); |
| 1819 | sdvo_priv->i2c_bus = i2cbus; | ||
| 1820 | sdvo_priv->slave_addr = slave_addr; | ||
| 1821 | 1811 | ||
| 1822 | sdvo_priv->output_device = output_device; | 1812 | /* Save the bit-banging i2c functionality for use by the DDC wrapper */ |
| 1823 | intel_output->i2c_bus = sdvo_priv->i2c_bus; | 1813 | intel_sdvo_i2c_bit_algo.functionality = intel_output->i2c_bus->algo->functionality; |
| 1824 | intel_output->dev_priv = sdvo_priv; | ||
| 1825 | 1814 | ||
| 1826 | /* Read the regs to test if we can talk to the device */ | 1815 | /* Read the regs to test if we can talk to the device */ |
| 1827 | for (i = 0; i < 0x40; i++) { | 1816 | for (i = 0; i < 0x40; i++) { |
| @@ -1835,17 +1824,15 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) | |||
| 1835 | 1824 | ||
| 1836 | /* setup the DDC bus. */ | 1825 | /* setup the DDC bus. */ |
| 1837 | if (output_device == SDVOB) | 1826 | if (output_device == SDVOB) |
| 1838 | ddcbus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); | 1827 | intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); |
| 1839 | else | 1828 | else |
| 1840 | ddcbus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); | 1829 | intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); |
| 1841 | 1830 | ||
| 1842 | if (ddcbus == NULL) | 1831 | if (intel_output->ddc_bus == NULL) |
| 1843 | goto err_i2c; | 1832 | goto err_i2c; |
| 1844 | 1833 | ||
| 1845 | intel_sdvo_i2c_bit_algo.functionality = | 1834 | /* Wrap with our custom algo which switches to DDC mode */ |
| 1846 | intel_output->i2c_bus->algo->functionality; | 1835 | intel_output->ddc_bus->algo = &intel_sdvo_i2c_bit_algo; |
| 1847 | ddcbus->algo = &intel_sdvo_i2c_bit_algo; | ||
| 1848 | intel_output->ddc_bus = ddcbus; | ||
| 1849 | 1836 | ||
| 1850 | /* In defaut case sdvo lvds is false */ | 1837 | /* In defaut case sdvo lvds is false */ |
| 1851 | sdvo_priv->is_lvds = false; | 1838 | sdvo_priv->is_lvds = false; |
| @@ -1965,9 +1952,10 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device) | |||
| 1965 | return true; | 1952 | return true; |
| 1966 | 1953 | ||
| 1967 | err_i2c: | 1954 | err_i2c: |
| 1968 | if (ddcbus != NULL) | 1955 | if (intel_output->ddc_bus != NULL) |
| 1969 | intel_i2c_destroy(intel_output->ddc_bus); | 1956 | intel_i2c_destroy(intel_output->ddc_bus); |
| 1970 | intel_i2c_destroy(intel_output->i2c_bus); | 1957 | if (intel_output->i2c_bus != NULL) |
| 1958 | intel_i2c_destroy(intel_output->i2c_bus); | ||
| 1971 | err_inteloutput: | 1959 | err_inteloutput: |
| 1972 | kfree(intel_output); | 1960 | kfree(intel_output); |
| 1973 | 1961 | ||
