aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-09-28 18:33:17 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-28 18:33:17 -0400
commita8ed0b16a924a59b56906e83d6c033a04a9818f6 (patch)
tree125d98b944c25394683a66523f99a918c9139a95
parentb8232e906381dcba2bb26f0d849d4c25cc9b1368 (diff)
drm/i915: Tidy dvo_ch7017 and print out which chip we detect
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--drivers/gpu/drm/i915/dvo_ch7017.c63
1 files changed, 27 insertions, 36 deletions
diff --git a/drivers/gpu/drm/i915/dvo_ch7017.c b/drivers/gpu/drm/i915/dvo_ch7017.c
index 0bc8ce1ad9aa..af70337567ce 100644
--- a/drivers/gpu/drm/i915/dvo_ch7017.c
+++ b/drivers/gpu/drm/i915/dvo_ch7017.c
@@ -165,56 +165,35 @@ struct ch7017_priv {
165static void ch7017_dump_regs(struct intel_dvo_device *dvo); 165static void ch7017_dump_regs(struct intel_dvo_device *dvo);
166static void ch7017_dpms(struct intel_dvo_device *dvo, int mode); 166static void ch7017_dpms(struct intel_dvo_device *dvo, int mode);
167 167
168static bool ch7017_read(struct intel_dvo_device *dvo, int addr, uint8_t *val) 168static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val)
169{ 169{
170 struct i2c_adapter *adapter = dvo->i2c_bus;
171 u8 out_buf[2];
172 u8 in_buf[2];
173
174 struct i2c_msg msgs[] = { 170 struct i2c_msg msgs[] = {
175 { 171 {
176 .addr = dvo->slave_addr, 172 .addr = dvo->slave_addr,
177 .flags = 0, 173 .flags = 0,
178 .len = 1, 174 .len = 1,
179 .buf = out_buf, 175 .buf = &addr,
180 }, 176 },
181 { 177 {
182 .addr = dvo->slave_addr, 178 .addr = dvo->slave_addr,
183 .flags = I2C_M_RD, 179 .flags = I2C_M_RD,
184 .len = 1, 180 .len = 1,
185 .buf = in_buf, 181 .buf = val,
186 } 182 }
187 }; 183 };
188 184 return i2c_transfer(dvo->i2c_bus, msgs, 2) == 2;
189 out_buf[0] = addr;
190 out_buf[1] = 0;
191
192 if (i2c_transfer(adapter, msgs, 2) == 2) {
193 *val= in_buf[0];
194 return true;
195 };
196
197 return false;
198} 185}
199 186
200static bool ch7017_write(struct intel_dvo_device *dvo, int addr, uint8_t val) 187static bool ch7017_write(struct intel_dvo_device *dvo, u8 addr, u8 val)
201{ 188{
202 struct i2c_adapter *adapter = dvo->i2c_bus; 189 uint8_t buf[2] = { addr, val };
203 uint8_t out_buf[2];
204 struct i2c_msg msg = { 190 struct i2c_msg msg = {
205 .addr = dvo->slave_addr, 191 .addr = dvo->slave_addr,
206 .flags = 0, 192 .flags = 0,
207 .len = 2, 193 .len = 2,
208 .buf = out_buf, 194 .buf = buf,
209 }; 195 };
210 196 return i2c_transfer(dvo->i2c_bus, &msg, 1) == 1;
211 out_buf[0] = addr;
212 out_buf[1] = val;
213
214 if (i2c_transfer(adapter, &msg, 1) == 1)
215 return true;
216
217 return false;
218} 197}
219 198
220/** Probes for a CH7017 on the given bus and slave address. */ 199/** Probes for a CH7017 on the given bus and slave address. */
@@ -222,7 +201,8 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
222 struct i2c_adapter *adapter) 201 struct i2c_adapter *adapter)
223{ 202{
224 struct ch7017_priv *priv; 203 struct ch7017_priv *priv;
225 uint8_t val; 204 const char *str;
205 u8 val;
226 206
227 priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL); 207 priv = kzalloc(sizeof(struct ch7017_priv), GFP_KERNEL);
228 if (priv == NULL) 208 if (priv == NULL)
@@ -234,16 +214,27 @@ static bool ch7017_init(struct intel_dvo_device *dvo,
234 if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val)) 214 if (!ch7017_read(dvo, CH7017_DEVICE_ID, &val))
235 goto fail; 215 goto fail;
236 216
237 if (val != CH7017_DEVICE_ID_VALUE && 217 switch (val) {
238 val != CH7018_DEVICE_ID_VALUE && 218 case CH7017_DEVICE_ID_VALUE:
239 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:
240 DRM_DEBUG_KMS("ch701x not detected, got %d: from %s " 228 DRM_DEBUG_KMS("ch701x not detected, got %d: from %s "
241 "Slave %d.\n", 229 "slave %d.\n",
242 val, adapter->name,dvo->slave_addr); 230 val, adapter->name,dvo->slave_addr);
243 goto fail; 231 goto fail;
244 } 232 }
245 233
234 DRM_DEBUG_KMS("%s detected on %s, addr %d\n",
235 str, adapter->name, dvo->slave_addr);
246 return true; 236 return true;
237
247fail: 238fail:
248 kfree(priv); 239 kfree(priv);
249 return false; 240 return false;
@@ -365,7 +356,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode)
365 } 356 }
366 357
367 /* XXX: Should actually wait for update power status somehow */ 358 /* XXX: Should actually wait for update power status somehow */
368 udelay(20000); 359 msleep(20);
369} 360}
370 361
371static void ch7017_dump_regs(struct intel_dvo_device *dvo) 362static void ch7017_dump_regs(struct intel_dvo_device *dvo)