aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_sdvo.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-05-30 15:16:25 -0400
committerKeith Packard <keithp@keithp.com>2009-06-18 18:53:57 -0400
commitf9c10a9b96a31b4a82a4fa807400c04f00284068 (patch)
treed49abf9846d0177aad3b317da1ea98d9ad129ca6 /drivers/gpu/drm/i915/intel_sdvo.c
parentb99e228d354cc1e7f19fb8b5f1297d493e309186 (diff)
drm/i915: Change I2C api to pass around i2c_adapters
The existing API passed around intel_i2c_chan pointers, which are dependent on the i2c bit-banging algo. This precluded the driver from using outputs which use a different algo. Switching to the more general i2c_adpater allows the driver to support non bit-banging DDC. This also required moving the slave address into the output private structures. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_sdvo.c')
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 9a00adb3a508..13c39c827ebf 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -38,8 +38,8 @@
38#undef SDVO_DEBUG 38#undef SDVO_DEBUG
39#define I915_SDVO "i915_sdvo" 39#define I915_SDVO "i915_sdvo"
40struct intel_sdvo_priv { 40struct intel_sdvo_priv {
41 struct intel_i2c_chan *i2c_bus; 41 struct i2c_adapter *i2c_bus;
42 int slaveaddr; 42 u8 slave_addr;
43 43
44 /* Register for the SDVO device: SDVOB or SDVOC */ 44 /* Register for the SDVO device: SDVOB or SDVOC */
45 int output_device; 45 int output_device;
@@ -146,13 +146,13 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
146 146
147 struct i2c_msg msgs[] = { 147 struct i2c_msg msgs[] = {
148 { 148 {
149 .addr = sdvo_priv->i2c_bus->slave_addr, 149 .addr = sdvo_priv->slave_addr >> 1,
150 .flags = 0, 150 .flags = 0,
151 .len = 1, 151 .len = 1,
152 .buf = out_buf, 152 .buf = out_buf,
153 }, 153 },
154 { 154 {
155 .addr = sdvo_priv->i2c_bus->slave_addr, 155 .addr = sdvo_priv->slave_addr >> 1,
156 .flags = I2C_M_RD, 156 .flags = I2C_M_RD,
157 .len = 1, 157 .len = 1,
158 .buf = buf, 158 .buf = buf,
@@ -162,7 +162,7 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
162 out_buf[0] = addr; 162 out_buf[0] = addr;
163 out_buf[1] = 0; 163 out_buf[1] = 0;
164 164
165 if ((ret = i2c_transfer(&sdvo_priv->i2c_bus->adapter, msgs, 2)) == 2) 165 if ((ret = i2c_transfer(sdvo_priv->i2c_bus, msgs, 2)) == 2)
166 { 166 {
167 *ch = buf[0]; 167 *ch = buf[0];
168 return true; 168 return true;
@@ -175,10 +175,11 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
175static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr, 175static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
176 u8 ch) 176 u8 ch)
177{ 177{
178 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
178 u8 out_buf[2]; 179 u8 out_buf[2];
179 struct i2c_msg msgs[] = { 180 struct i2c_msg msgs[] = {
180 { 181 {
181 .addr = intel_output->i2c_bus->slave_addr, 182 .addr = sdvo_priv->slave_addr >> 1,
182 .flags = 0, 183 .flags = 0,
183 .len = 2, 184 .len = 2,
184 .buf = out_buf, 185 .buf = out_buf,
@@ -188,7 +189,7 @@ static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
188 out_buf[0] = addr; 189 out_buf[0] = addr;
189 out_buf[1] = ch; 190 out_buf[1] = ch;
190 191
191 if (i2c_transfer(&intel_output->i2c_bus->adapter, msgs, 1) == 1) 192 if (i2c_transfer(intel_output->i2c_bus, msgs, 1) == 1)
192 { 193 {
193 return true; 194 return true;
194 } 195 }
@@ -1371,7 +1372,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1371 1372
1372 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1373 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1373 edid = drm_get_edid(&intel_output->base, 1374 edid = drm_get_edid(&intel_output->base,
1374 &intel_output->ddc_bus->adapter); 1375 intel_output->ddc_bus);
1375 if (edid != NULL) { 1376 if (edid != NULL) {
1376 sdvo_priv->is_hdmi = drm_detect_hdmi_monitor(edid); 1377 sdvo_priv->is_hdmi = drm_detect_hdmi_monitor(edid);
1377 kfree(edid); 1378 kfree(edid);
@@ -1709,7 +1710,7 @@ intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan)
1709 1710
1710 list_for_each_entry(connector, 1711 list_for_each_entry(connector,
1711 &dev->mode_config.connector_list, head) { 1712 &dev->mode_config.connector_list, head) {
1712 if (to_intel_output(connector)->ddc_bus == chan) { 1713 if (to_intel_output(connector)->ddc_bus == &chan->adapter) {
1713 intel_output = to_intel_output(connector); 1714 intel_output = to_intel_output(connector);
1714 break; 1715 break;
1715 } 1716 }
@@ -1723,7 +1724,7 @@ static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
1723 struct intel_output *intel_output; 1724 struct intel_output *intel_output;
1724 struct intel_sdvo_priv *sdvo_priv; 1725 struct intel_sdvo_priv *sdvo_priv;
1725 struct i2c_algo_bit_data *algo_data; 1726 struct i2c_algo_bit_data *algo_data;
1726 struct i2c_algorithm *algo; 1727 const struct i2c_algorithm *algo;
1727 1728
1728 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; 1729 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data;
1729 intel_output = 1730 intel_output =
@@ -1733,7 +1734,7 @@ static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
1733 return -EINVAL; 1734 return -EINVAL;
1734 1735
1735 sdvo_priv = intel_output->dev_priv; 1736 sdvo_priv = intel_output->dev_priv;
1736 algo = (struct i2c_algorithm *)intel_output->i2c_bus->adapter.algo; 1737 algo = intel_output->i2c_bus->algo;
1737 1738
1738 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 1739 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
1739 return algo->master_xfer(i2c_adap, msgs, num); 1740 return algo->master_xfer(i2c_adap, msgs, num);
@@ -1785,12 +1786,13 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1785 struct drm_connector *connector; 1786 struct drm_connector *connector;
1786 struct intel_output *intel_output; 1787 struct intel_output *intel_output;
1787 struct intel_sdvo_priv *sdvo_priv; 1788 struct intel_sdvo_priv *sdvo_priv;
1788 struct intel_i2c_chan *i2cbus = NULL; 1789 struct i2c_adapter *i2cbus = NULL;
1789 struct intel_i2c_chan *ddcbus = NULL; 1790 struct i2c_adapter *ddcbus = NULL;
1791
1790 int connector_type; 1792 int connector_type;
1791 u8 ch[0x40]; 1793 u8 ch[0x40];
1792 int i; 1794 int i;
1793 int encoder_type, output_id; 1795 int encoder_type;
1794 u8 slave_addr; 1796 u8 slave_addr;
1795 1797
1796 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); 1798 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
@@ -1802,25 +1804,23 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1802 intel_output->type = INTEL_OUTPUT_SDVO; 1804 intel_output->type = INTEL_OUTPUT_SDVO;
1803 1805
1804 /* setup the DDC bus. */ 1806 /* setup the DDC bus. */
1805 if (output_device == SDVOB) 1807 if (output_device == SDVOB) {
1806 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); 1808 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB");
1807 else 1809 slave_addr = 0x38;
1810 } else {
1808 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); 1811 i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
1809 1812 slave_addr = 0x39;
1813 }
1814
1810 if (!i2cbus) 1815 if (!i2cbus)
1811 goto err_inteloutput; 1816 goto err_inteloutput;
1812 1817
1813 slave_addr = intel_sdvo_get_slave_addr(dev, output_device); 1818 slave_addr = intel_sdvo_get_slave_addr(dev, output_device);
1814 sdvo_priv->i2c_bus = i2cbus; 1819 sdvo_priv->i2c_bus = i2cbus;
1820 sdvo_priv->slave_addr = slave_addr;
1815 1821
1816 if (output_device == SDVOB) {
1817 output_id = 1;
1818 } else {
1819 output_id = 2;
1820 }
1821 sdvo_priv->i2c_bus->slave_addr = slave_addr >> 1;
1822 sdvo_priv->output_device = output_device; 1822 sdvo_priv->output_device = output_device;
1823 intel_output->i2c_bus = i2cbus; 1823 intel_output->i2c_bus = sdvo_priv->i2c_bus;
1824 intel_output->dev_priv = sdvo_priv; 1824 intel_output->dev_priv = sdvo_priv;
1825 1825
1826 /* 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 */
@@ -1843,8 +1843,8 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1843 goto err_i2c; 1843 goto err_i2c;
1844 1844
1845 intel_sdvo_i2c_bit_algo.functionality = 1845 intel_sdvo_i2c_bit_algo.functionality =
1846 intel_output->i2c_bus->adapter.algo->functionality; 1846 intel_output->i2c_bus->algo->functionality;
1847 ddcbus->adapter.algo = &intel_sdvo_i2c_bit_algo; 1847 ddcbus->algo = &intel_sdvo_i2c_bit_algo;
1848 intel_output->ddc_bus = ddcbus; 1848 intel_output->ddc_bus = ddcbus;
1849 1849
1850 /* In defaut case sdvo lvds is false */ 1850 /* In defaut case sdvo lvds is false */