diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/gpu/drm/i915/dvo_ch7017.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/gpu/drm/i915/dvo_ch7017.c')
-rw-r--r-- | drivers/gpu/drm/i915/dvo_ch7017.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/drivers/gpu/drm/i915/dvo_ch7017.c b/drivers/gpu/drm/i915/dvo_ch7017.c index 14d59804acd7..d3e8c540f778 100644 --- a/drivers/gpu/drm/i915/dvo_ch7017.c +++ b/drivers/gpu/drm/i915/dvo_ch7017.c | |||
@@ -165,67 +165,44 @@ struct ch7017_priv { | |||
165 | static void ch7017_dump_regs(struct intel_dvo_device *dvo); | 165 | static void ch7017_dump_regs(struct intel_dvo_device *dvo); |
166 | static void ch7017_dpms(struct intel_dvo_device *dvo, int mode); | 166 | static void ch7017_dpms(struct intel_dvo_device *dvo, int mode); |
167 | 167 | ||
168 | static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val) | 168 | static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val) |
169 | { | 169 | { |
170 | struct i2c_adapter *adapter = dvo->i2c_bus; | ||
171 | struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter); | ||
172 | u8 out_buf[2]; | ||
173 | u8 in_buf[2]; | ||
174 | |||
175 | struct i2c_msg msgs[] = { | 170 | struct i2c_msg msgs[] = { |
176 | { | 171 | { |
177 | .addr = dvo->slave_addr, | 172 | .addr = dvo->slave_addr, |
178 | .flags = 0, | 173 | .flags = 0, |
179 | .len = 1, | 174 | .len = 1, |
180 | .buf = out_buf, | 175 | .buf = &addr, |
181 | }, | 176 | }, |
182 | { | 177 | { |
183 | .addr = dvo->slave_addr, | 178 | .addr = dvo->slave_addr, |
184 | .flags = I2C_M_RD, | 179 | .flags = I2C_M_RD, |
185 | .len = 1, | 180 | .len = 1, |
186 | .buf = in_buf, | 181 | .buf = val, |
187 | } | 182 | } |
188 | }; | 183 | }; |
189 | 184 | return i2c_transfer(dvo->i2c_bus, msgs, 2) == 2; | |
190 | out_buf[0] = addr; | ||
191 | out_buf[1] = 0; | ||
192 | |||
193 | if (i2c_transfer(&i2cbus->adapter, msgs, 2) == 2) { | ||
194 | *val= in_buf[0]; | ||
195 | return true; | ||
196 | }; | ||
197 | |||
198 | return false; | ||
199 | } | 185 | } |
200 | 186 | ||
201 | static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val) | 187 | static bool ch7017_write(struct intel_dvo_device *dvo, u8 addr, u8 val) |
202 | { | 188 | { |
203 | struct i2c_adapter *adapter = dvo->i2c_bus; | 189 | uint8_t buf[2] = { addr, val }; |
204 | struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter); | ||
205 | uint8_t out_buf[2]; | ||
206 | struct i2c_msg msg = { | 190 | struct i2c_msg msg = { |
207 | .addr = dvo->slave_addr, | 191 | .addr = dvo->slave_addr, |
208 | .flags = 0, | 192 | .flags = 0, |
209 | .len = 2, | 193 | .len = 2, |
210 | .buf = out_buf, | 194 | .buf = buf, |
211 | }; | 195 | }; |
212 | 196 | return i2c_transfer(dvo->i2c_bus, &msg, 1) == 1; | |
213 | out_buf[0] = addr; | ||
214 | out_buf[1] = val; | ||
215 | |||
216 | if (i2c_transfer(&i2cbus->adapter, &msg, 1) == 1) | ||
217 | return true; | ||
218 | |||
219 | return false; | ||
220 | } | 197 | } |
221 | 198 | ||
222 | /** Probes for a CH7017 on the given bus and slave address. */ | 199 | /** Probes for a CH7017 on the given bus and slave address. */ |
223 | static bool ch7017_init(struct intel_dvo_device *dvo, | 200 | static bool ch7017_init(struct intel_dvo_device *dvo, |
224 | struct i2c_adapter *adapter) | 201 | struct i2c_adapter *adapter) |
225 | { | 202 | { |
226 | struct intel_i2c_chan *i2cbus = container_of(adapter, struct intel_i2c_chan, adapter); | ||
227 | struct ch7017_priv *priv; | 203 | struct ch7017_priv *priv; |
228 | uint8_t val; | 204 | const char *str; |
205 | u8 val; | ||
229 | 206 | ||
230 | priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL); | 207 | priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL); |
231 | if (priv == NULL) | 208 | if (priv == NULL) |
@@ -237,16 +214,27 @@ static bool ch7017_init(struct intel_dvo_device *dvo, | |||
237 | if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val)) | 214 | if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val)) |
238 | goto fail; | 215 | goto fail; |
239 | 216 | ||
240 | if (val != CH7017_DEVICE_ID_VALUE && | 217 | switch (val) { |
241 | val != CH7018_DEVICE_ID_VALUE && | 218 | case CH7017_DEVICE_ID_VALUE: |
242 | val != CH7019_DEVICE_ID_VALUE) { | 219 | str = "ch7017"; |
220 | break; | ||
221 | case CH7018_DEVICE_ID_VALUE: | ||
222 | str = "ch7018"; | ||
223 | break; | ||
224 | case CH7019_DEVICE_ID_VALUE: | ||
225 | str = "ch7019"; | ||
226 | break; | ||
227 | default: | ||
243 | DRM_DEBUG_KMS("ch701x not detected, got %d: from %s " | 228 | DRM_DEBUG_KMS("ch701x not detected, got %d: from %s " |
244 | "Slave %d.\n", | 229 | "slave %d.\n", |
245 | val, i2cbus->adapter.name,dvo->slave_addr); | 230 | val, adapter->name,dvo->slave_addr); |
246 | goto fail; | 231 | goto fail; |
247 | } | 232 | } |
248 | 233 | ||
234 | DRM_DEBUG_KMS("%s detected on %s, addr %d\n", | ||
235 | str, adapter->name, dvo->slave_addr); | ||
249 | return true; | 236 | return true; |
237 | |||
250 | fail: | 238 | fail: |
251 | kfree(priv); | 239 | kfree(priv); |
252 | return false; | 240 | return false; |
@@ -254,7 +242,7 @@ fail: | |||
254 | 242 | ||
255 | static enum drm_connector_status ch7017_detect(struct intel_dvo_device *dvo) | 243 | static enum drm_connector_status ch7017_detect(struct intel_dvo_device *dvo) |
256 | { | 244 | { |
257 | return connector_status_unknown; | 245 | return connector_status_connected; |
258 | } | 246 | } |
259 | 247 | ||
260 | static enum drm_mode_status ch7017_mode_valid(struct intel_dvo_device *dvo, | 248 | static enum drm_mode_status ch7017_mode_valid(struct intel_dvo_device *dvo, |
@@ -368,7 +356,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode) | |||
368 | } | 356 | } |
369 | 357 | ||
370 | /* XXX: Should actually wait for update power status somehow */ | 358 | /* XXX: Should actually wait for update power status somehow */ |
371 | udelay(20000); | 359 | msleep(20); |
372 | } | 360 | } |
373 | 361 | ||
374 | static void ch7017_dump_regs(struct intel_dvo_device *dvo) | 362 | static void ch7017_dump_regs(struct intel_dvo_device *dvo) |