diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-09-07 07:00:32 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-17 16:17:47 -0400 |
commit | 85ede69fec2d26789f5782a364fb3a93ebf0b546 (patch) | |
tree | ca18c5c3711ae7ac15aa23bca61387770dbabd32 /drivers/media/video | |
parent | 9875c0fb32246f97a9f40bdfe027544b8827f156 (diff) |
V4L/DVB (9204): saa7110: convert i2c driver for new i2c API
- Convert to use v4l2-i2c-drv-legacy.h to be able to handle the new i2c API
- Cleanups
- Use v4l_dbg/v4l_info to have uniform kernel messages
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/saa7110.c | 242 |
1 files changed, 64 insertions, 178 deletions
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 4aa82b310708..adf2ba79496a 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -31,36 +31,24 @@ | |||
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/wait.h> | 33 | #include <linux/wait.h> |
34 | #include <asm/io.h> | ||
35 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
35 | #include <linux/i2c.h> | ||
36 | #include <linux/videodev.h> | ||
37 | #include <linux/video_decoder.h> | ||
38 | #include <media/v4l2-common.h> | ||
39 | #include <media/v4l2-i2c-drv-legacy.h> | ||
36 | 40 | ||
37 | MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); | 41 | MODULE_DESCRIPTION("Philips SAA7110 video decoder driver"); |
38 | MODULE_AUTHOR("Pauline Middelink"); | 42 | MODULE_AUTHOR("Pauline Middelink"); |
39 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
40 | 44 | ||
41 | #include <linux/i2c.h> | ||
42 | |||
43 | #define I2C_NAME(s) (s)->name | ||
44 | |||
45 | #include <linux/videodev.h> | ||
46 | #include <media/v4l2-common.h> | ||
47 | #include <linux/video_decoder.h> | ||
48 | |||
49 | static int debug; | 45 | static int debug; |
50 | module_param(debug, int, 0); | 46 | module_param(debug, int, 0); |
51 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 47 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
52 | 48 | ||
53 | #define dprintk(num, format, args...) \ | ||
54 | do { \ | ||
55 | if (debug >= num) \ | ||
56 | printk(format, ##args); \ | ||
57 | } while (0) | ||
58 | |||
59 | #define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ | 49 | #define SAA7110_MAX_INPUT 9 /* 6 CVBS, 3 SVHS */ |
60 | #define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ | 50 | #define SAA7110_MAX_OUTPUT 0 /* its a decoder only */ |
61 | 51 | ||
62 | #define I2C_SAA7110 0x9C /* or 0x9E */ | ||
63 | |||
64 | #define SAA7110_NR_REG 0x35 | 52 | #define SAA7110_NR_REG 0x35 |
65 | 53 | ||
66 | struct saa7110 { | 54 | struct saa7110 { |
@@ -81,10 +69,7 @@ struct saa7110 { | |||
81 | /* I2C support functions */ | 69 | /* I2C support functions */ |
82 | /* ----------------------------------------------------------------------- */ | 70 | /* ----------------------------------------------------------------------- */ |
83 | 71 | ||
84 | static int | 72 | static int saa7110_write(struct i2c_client *client, u8 reg, u8 value) |
85 | saa7110_write (struct i2c_client *client, | ||
86 | u8 reg, | ||
87 | u8 value) | ||
88 | { | 73 | { |
89 | struct saa7110 *decoder = i2c_get_clientdata(client); | 74 | struct saa7110 *decoder = i2c_get_clientdata(client); |
90 | 75 | ||
@@ -92,10 +77,7 @@ saa7110_write (struct i2c_client *client, | |||
92 | return i2c_smbus_write_byte_data(client, reg, value); | 77 | return i2c_smbus_write_byte_data(client, reg, value); |
93 | } | 78 | } |
94 | 79 | ||
95 | static int | 80 | static int saa7110_write_block(struct i2c_client *client, const u8 *data, unsigned int len) |
96 | saa7110_write_block (struct i2c_client *client, | ||
97 | const u8 *data, | ||
98 | unsigned int len) | ||
99 | { | 81 | { |
100 | int ret = -1; | 82 | int ret = -1; |
101 | u8 reg = *data; /* first register to write to */ | 83 | u8 reg = *data; /* first register to write to */ |
@@ -115,8 +97,8 @@ saa7110_write_block (struct i2c_client *client, | |||
115 | memcpy(decoder->reg + reg, data + 1, len - 1); | 97 | memcpy(decoder->reg + reg, data + 1, len - 1); |
116 | } else { | 98 | } else { |
117 | for (++data, --len; len; len--) { | 99 | for (++data, --len; len; len--) { |
118 | if ((ret = saa7110_write(client, reg++, | 100 | ret = saa7110_write(client, reg++, *data++); |
119 | *data++)) < 0) | 101 | if (ret < 0) |
120 | break; | 102 | break; |
121 | } | 103 | } |
122 | } | 104 | } |
@@ -124,8 +106,7 @@ saa7110_write_block (struct i2c_client *client, | |||
124 | return ret; | 106 | return ret; |
125 | } | 107 | } |
126 | 108 | ||
127 | static inline int | 109 | static inline int saa7110_read(struct i2c_client *client) |
128 | saa7110_read (struct i2c_client *client) | ||
129 | { | 110 | { |
130 | return i2c_smbus_read_byte(client); | 111 | return i2c_smbus_read_byte(client); |
131 | } | 112 | } |
@@ -138,9 +119,7 @@ saa7110_read (struct i2c_client *client) | |||
138 | #define FRESP_06H_SVIDEO 0x83 //0xC0 | 119 | #define FRESP_06H_SVIDEO 0x83 //0xC0 |
139 | 120 | ||
140 | 121 | ||
141 | static int | 122 | static int saa7110_selmux(struct i2c_client *client, int chan) |
142 | saa7110_selmux (struct i2c_client *client, | ||
143 | int chan) | ||
144 | { | 123 | { |
145 | static const unsigned char modes[9][8] = { | 124 | static const unsigned char modes[9][8] = { |
146 | /* mode 0 */ | 125 | /* mode 0 */ |
@@ -197,8 +176,7 @@ static const unsigned char initseq[1 + SAA7110_NR_REG] = { | |||
197 | /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 | 176 | /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 |
198 | }; | 177 | }; |
199 | 178 | ||
200 | static int | 179 | static int determine_norm(struct i2c_client *client) |
201 | determine_norm (struct i2c_client *client) | ||
202 | { | 180 | { |
203 | DEFINE_WAIT(wait); | 181 | DEFINE_WAIT(wait); |
204 | struct saa7110 *decoder = i2c_get_clientdata(client); | 182 | struct saa7110 *decoder = i2c_get_clientdata(client); |
@@ -212,29 +190,23 @@ determine_norm (struct i2c_client *client) | |||
212 | finish_wait(&decoder->wq, &wait); | 190 | finish_wait(&decoder->wq, &wait); |
213 | status = saa7110_read(client); | 191 | status = saa7110_read(client); |
214 | if (status & 0x40) { | 192 | if (status & 0x40) { |
215 | dprintk(1, KERN_INFO "%s: status=0x%02x (no signal)\n", | 193 | v4l_dbg(1, debug, client, "status=0x%02x (no signal)\n", status); |
216 | I2C_NAME(client), status); | ||
217 | return decoder->norm; // no change | 194 | return decoder->norm; // no change |
218 | } | 195 | } |
219 | if ((status & 3) == 0) { | 196 | if ((status & 3) == 0) { |
220 | saa7110_write(client, 0x06, 0x83); | 197 | saa7110_write(client, 0x06, 0x83); |
221 | if (status & 0x20) { | 198 | if (status & 0x20) { |
222 | dprintk(1, | 199 | v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); |
223 | KERN_INFO | ||
224 | "%s: status=0x%02x (NTSC/no color)\n", | ||
225 | I2C_NAME(client), status); | ||
226 | //saa7110_write(client,0x2E,0x81); | 200 | //saa7110_write(client,0x2E,0x81); |
227 | return VIDEO_MODE_NTSC; | 201 | return VIDEO_MODE_NTSC; |
228 | } | 202 | } |
229 | dprintk(1, KERN_INFO "%s: status=0x%02x (PAL/no color)\n", | 203 | v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); |
230 | I2C_NAME(client), status); | ||
231 | //saa7110_write(client,0x2E,0x9A); | 204 | //saa7110_write(client,0x2E,0x9A); |
232 | return VIDEO_MODE_PAL; | 205 | return VIDEO_MODE_PAL; |
233 | } | 206 | } |
234 | //saa7110_write(client,0x06,0x03); | 207 | //saa7110_write(client,0x06,0x03); |
235 | if (status & 0x20) { /* 60Hz */ | 208 | if (status & 0x20) { /* 60Hz */ |
236 | dprintk(1, KERN_INFO "%s: status=0x%02x (NTSC)\n", | 209 | v4l_dbg(1, debug, client, "status=0x%02x (NTSC)\n", status); |
237 | I2C_NAME(client), status); | ||
238 | saa7110_write(client, 0x0D, 0x86); | 210 | saa7110_write(client, 0x0D, 0x86); |
239 | saa7110_write(client, 0x0F, 0x50); | 211 | saa7110_write(client, 0x0F, 0x50); |
240 | saa7110_write(client, 0x11, 0x2C); | 212 | saa7110_write(client, 0x11, 0x2C); |
@@ -254,13 +226,11 @@ determine_norm (struct i2c_client *client) | |||
254 | 226 | ||
255 | status = saa7110_read(client); | 227 | status = saa7110_read(client); |
256 | if ((status & 0x03) == 0x01) { | 228 | if ((status & 0x03) == 0x01) { |
257 | dprintk(1, KERN_INFO "%s: status=0x%02x (SECAM)\n", | 229 | v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); |
258 | I2C_NAME(client), status); | ||
259 | saa7110_write(client, 0x0D, 0x87); | 230 | saa7110_write(client, 0x0D, 0x87); |
260 | return VIDEO_MODE_SECAM; | 231 | return VIDEO_MODE_SECAM; |
261 | } | 232 | } |
262 | dprintk(1, KERN_INFO "%s: status=0x%02x (PAL)\n", I2C_NAME(client), | 233 | v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); |
263 | status); | ||
264 | return VIDEO_MODE_PAL; | 234 | return VIDEO_MODE_PAL; |
265 | } | 235 | } |
266 | 236 | ||
@@ -286,8 +256,8 @@ saa7110_command (struct i2c_client *client, | |||
286 | VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; | 256 | VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; |
287 | dc->inputs = SAA7110_MAX_INPUT; | 257 | dc->inputs = SAA7110_MAX_INPUT; |
288 | dc->outputs = SAA7110_MAX_OUTPUT; | 258 | dc->outputs = SAA7110_MAX_OUTPUT; |
289 | } | ||
290 | break; | 259 | break; |
260 | } | ||
291 | 261 | ||
292 | case DECODER_GET_STATUS: | 262 | case DECODER_GET_STATUS: |
293 | { | 263 | { |
@@ -295,8 +265,8 @@ saa7110_command (struct i2c_client *client, | |||
295 | int res = 0; | 265 | int res = 0; |
296 | 266 | ||
297 | status = saa7110_read(client); | 267 | status = saa7110_read(client); |
298 | dprintk(1, KERN_INFO "%s: status=0x%02x norm=%d\n", | 268 | v4l_dbg(1, debug, client, "status=0x%02x norm=%d\n", |
299 | I2C_NAME(client), status, decoder->norm); | 269 | status, decoder->norm); |
300 | if (!(status & 0x40)) | 270 | if (!(status & 0x40)) |
301 | res |= DECODER_STATUS_GOOD; | 271 | res |= DECODER_STATUS_GOOD; |
302 | if (status & 0x03) | 272 | if (status & 0x03) |
@@ -314,8 +284,8 @@ saa7110_command (struct i2c_client *client, | |||
314 | break; | 284 | break; |
315 | } | 285 | } |
316 | *(int *) arg = res; | 286 | *(int *) arg = res; |
317 | } | ||
318 | break; | 287 | break; |
288 | } | ||
319 | 289 | ||
320 | case DECODER_SET_NORM: | 290 | case DECODER_SET_NORM: |
321 | v = *(int *) arg; | 291 | v = *(int *) arg; |
@@ -328,34 +298,24 @@ saa7110_command (struct i2c_client *client, | |||
328 | saa7110_write(client, 0x0F, 0x50); | 298 | saa7110_write(client, 0x0F, 0x50); |
329 | saa7110_write(client, 0x11, 0x2C); | 299 | saa7110_write(client, 0x11, 0x2C); |
330 | //saa7110_write(client, 0x2E, 0x81); | 300 | //saa7110_write(client, 0x2E, 0x81); |
331 | dprintk(1, | 301 | v4l_dbg(1, debug, client, "switched to NTSC\n"); |
332 | KERN_INFO "%s: switched to NTSC\n", | ||
333 | I2C_NAME(client)); | ||
334 | break; | 302 | break; |
335 | case VIDEO_MODE_PAL: | 303 | case VIDEO_MODE_PAL: |
336 | saa7110_write(client, 0x0D, 0x86); | 304 | saa7110_write(client, 0x0D, 0x86); |
337 | saa7110_write(client, 0x0F, 0x10); | 305 | saa7110_write(client, 0x0F, 0x10); |
338 | saa7110_write(client, 0x11, 0x59); | 306 | saa7110_write(client, 0x11, 0x59); |
339 | //saa7110_write(client, 0x2E, 0x9A); | 307 | //saa7110_write(client, 0x2E, 0x9A); |
340 | dprintk(1, | 308 | v4l_dbg(1, debug, client, "switched to PAL\n"); |
341 | KERN_INFO "%s: switched to PAL\n", | ||
342 | I2C_NAME(client)); | ||
343 | break; | 309 | break; |
344 | case VIDEO_MODE_SECAM: | 310 | case VIDEO_MODE_SECAM: |
345 | saa7110_write(client, 0x0D, 0x87); | 311 | saa7110_write(client, 0x0D, 0x87); |
346 | saa7110_write(client, 0x0F, 0x10); | 312 | saa7110_write(client, 0x0F, 0x10); |
347 | saa7110_write(client, 0x11, 0x59); | 313 | saa7110_write(client, 0x11, 0x59); |
348 | //saa7110_write(client, 0x2E, 0x9A); | 314 | //saa7110_write(client, 0x2E, 0x9A); |
349 | dprintk(1, | 315 | v4l_dbg(1, debug, client, "switched to SECAM\n"); |
350 | KERN_INFO | ||
351 | "%s: switched to SECAM\n", | ||
352 | I2C_NAME(client)); | ||
353 | break; | 316 | break; |
354 | case VIDEO_MODE_AUTO: | 317 | case VIDEO_MODE_AUTO: |
355 | dprintk(1, | 318 | v4l_dbg(1, debug, client, "switched to AUTO\n"); |
356 | KERN_INFO | ||
357 | "%s: TV standard detection...\n", | ||
358 | I2C_NAME(client)); | ||
359 | decoder->norm = determine_norm(client); | 319 | decoder->norm = determine_norm(client); |
360 | *(int *) arg = decoder->norm; | 320 | *(int *) arg = decoder->norm; |
361 | break; | 321 | break; |
@@ -368,15 +328,12 @@ saa7110_command (struct i2c_client *client, | |||
368 | case DECODER_SET_INPUT: | 328 | case DECODER_SET_INPUT: |
369 | v = *(int *) arg; | 329 | v = *(int *) arg; |
370 | if (v < 0 || v > SAA7110_MAX_INPUT) { | 330 | if (v < 0 || v > SAA7110_MAX_INPUT) { |
371 | dprintk(1, | 331 | v4l_dbg(1, debug, client, "input=%d not available\n", v); |
372 | KERN_INFO "%s: input=%d not available\n", | ||
373 | I2C_NAME(client), v); | ||
374 | return -EINVAL; | 332 | return -EINVAL; |
375 | } | 333 | } |
376 | if (decoder->input != v) { | 334 | if (decoder->input != v) { |
377 | saa7110_selmux(client, v); | 335 | saa7110_selmux(client, v); |
378 | dprintk(1, KERN_INFO "%s: switched to input=%d\n", | 336 | v4l_dbg(1, debug, client, "switched to input=%d\n", v); |
379 | I2C_NAME(client), v); | ||
380 | } | 337 | } |
381 | break; | 338 | break; |
382 | 339 | ||
@@ -392,8 +349,7 @@ saa7110_command (struct i2c_client *client, | |||
392 | if (decoder->enable != v) { | 349 | if (decoder->enable != v) { |
393 | decoder->enable = v; | 350 | decoder->enable = v; |
394 | saa7110_write(client, 0x0E, v ? 0x18 : 0x80); | 351 | saa7110_write(client, 0x0E, v ? 0x18 : 0x80); |
395 | dprintk(1, KERN_INFO "%s: YUV %s\n", I2C_NAME(client), | 352 | v4l_dbg(1, debug, client, "YUV %s\n", v ? "on" : "off"); |
396 | v ? "on" : "off"); | ||
397 | } | 353 | } |
398 | break; | 354 | break; |
399 | 355 | ||
@@ -423,23 +379,23 @@ saa7110_command (struct i2c_client *client, | |||
423 | saa7110_write(client, 0x07, | 379 | saa7110_write(client, 0x07, |
424 | (decoder->hue >> 8) - 128); | 380 | (decoder->hue >> 8) - 128); |
425 | } | 381 | } |
426 | } | ||
427 | break; | 382 | break; |
383 | } | ||
428 | 384 | ||
429 | case DECODER_DUMP: | 385 | case DECODER_DUMP: |
386 | if (!debug) | ||
387 | break; | ||
430 | for (v = 0; v < SAA7110_NR_REG; v += 16) { | 388 | for (v = 0; v < SAA7110_NR_REG; v += 16) { |
431 | int j; | 389 | int j; |
432 | dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client), | 390 | v4l_dbg(1, debug, client, "%02x:", v); |
433 | v); | ||
434 | for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) | 391 | for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) |
435 | dprintk(1, " %02x", decoder->reg[v + j]); | 392 | printk(KERN_CONT " %02x", decoder->reg[v + j]); |
436 | dprintk(1, "\n"); | 393 | printk(KERN_CONT "\n"); |
437 | } | 394 | } |
438 | break; | 395 | break; |
439 | 396 | ||
440 | default: | 397 | default: |
441 | dprintk(1, KERN_INFO "unknown saa7110_command??(%d)\n", | 398 | v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); |
442 | cmd); | ||
443 | return -EINVAL; | 399 | return -EINVAL; |
444 | } | 400 | } |
445 | return 0; | 401 | return 0; |
@@ -451,55 +407,28 @@ saa7110_command (struct i2c_client *client, | |||
451 | * Generic i2c probe | 407 | * Generic i2c probe |
452 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 408 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
453 | */ | 409 | */ |
454 | static unsigned short normal_i2c[] = { | ||
455 | I2C_SAA7110 >> 1, | ||
456 | (I2C_SAA7110 >> 1) + 1, | ||
457 | I2C_CLIENT_END | ||
458 | }; | ||
459 | |||
460 | static unsigned short ignore = I2C_CLIENT_END; | ||
461 | 410 | ||
462 | static struct i2c_client_address_data addr_data = { | 411 | static unsigned short normal_i2c[] = { 0x9c >> 1, 0x9e >> 1, I2C_CLIENT_END }; |
463 | .normal_i2c = normal_i2c, | ||
464 | .probe = &ignore, | ||
465 | .ignore = &ignore, | ||
466 | }; | ||
467 | 412 | ||
468 | static struct i2c_driver i2c_driver_saa7110; | 413 | I2C_CLIENT_INSMOD; |
469 | 414 | ||
470 | static int | 415 | static int saa7110_probe(struct i2c_client *client, |
471 | saa7110_detect_client (struct i2c_adapter *adapter, | 416 | const struct i2c_device_id *id) |
472 | int address, | ||
473 | int kind) | ||
474 | { | 417 | { |
475 | struct i2c_client *client; | ||
476 | struct saa7110 *decoder; | 418 | struct saa7110 *decoder; |
477 | int rv; | 419 | int rv; |
478 | 420 | ||
479 | dprintk(1, | ||
480 | KERN_INFO | ||
481 | "saa7110.c: detecting saa7110 client on address 0x%x\n", | ||
482 | address << 1); | ||
483 | |||
484 | /* Check if the adapter supports the needed features */ | 421 | /* Check if the adapter supports the needed features */ |
485 | if (!i2c_check_functionality | 422 | if (!i2c_check_functionality(client->adapter, |
486 | (adapter, | 423 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) |
487 | I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) | 424 | return -ENODEV; |
488 | return 0; | ||
489 | 425 | ||
490 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 426 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
491 | if (!client) | 427 | client->addr << 1, client->adapter->name); |
492 | return -ENOMEM; | ||
493 | client->addr = address; | ||
494 | client->adapter = adapter; | ||
495 | client->driver = &i2c_driver_saa7110; | ||
496 | strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); | ||
497 | 428 | ||
498 | decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); | 429 | decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); |
499 | if (!decoder) { | 430 | if (!decoder) |
500 | kfree(client); | ||
501 | return -ENOMEM; | 431 | return -ENOMEM; |
502 | } | ||
503 | decoder->norm = VIDEO_MODE_PAL; | 432 | decoder->norm = VIDEO_MODE_PAL; |
504 | decoder->input = 0; | 433 | decoder->input = 0; |
505 | decoder->enable = 1; | 434 | decoder->enable = 1; |
@@ -510,18 +439,10 @@ saa7110_detect_client (struct i2c_adapter *adapter, | |||
510 | init_waitqueue_head(&decoder->wq); | 439 | init_waitqueue_head(&decoder->wq); |
511 | i2c_set_clientdata(client, decoder); | 440 | i2c_set_clientdata(client, decoder); |
512 | 441 | ||
513 | rv = i2c_attach_client(client); | ||
514 | if (rv) { | ||
515 | kfree(client); | ||
516 | kfree(decoder); | ||
517 | return rv; | ||
518 | } | ||
519 | |||
520 | rv = saa7110_write_block(client, initseq, sizeof(initseq)); | 442 | rv = saa7110_write_block(client, initseq, sizeof(initseq)); |
521 | if (rv < 0) | 443 | if (rv < 0) { |
522 | dprintk(1, KERN_ERR "%s_attach: init status %d\n", | 444 | v4l_dbg(1, debug, client, "init status %d\n", rv); |
523 | I2C_NAME(client), rv); | 445 | } else { |
524 | else { | ||
525 | int ver, status; | 446 | int ver, status; |
526 | saa7110_write(client, 0x21, 0x10); | 447 | saa7110_write(client, 0x21, 0x10); |
527 | saa7110_write(client, 0x0e, 0x18); | 448 | saa7110_write(client, 0x0e, 0x18); |
@@ -530,10 +451,8 @@ saa7110_detect_client (struct i2c_adapter *adapter, | |||
530 | saa7110_write(client, 0x0D, 0x06); | 451 | saa7110_write(client, 0x0D, 0x06); |
531 | //mdelay(150); | 452 | //mdelay(150); |
532 | status = saa7110_read(client); | 453 | status = saa7110_read(client); |
533 | dprintk(1, | 454 | v4l_dbg(1, debug, client, "version %x, status=0x%02x\n", |
534 | KERN_INFO | 455 | ver, status); |
535 | "%s_attach: SAA7110A version %x at 0x%02x, status=0x%02x\n", | ||
536 | I2C_NAME(client), ver, client->addr << 1, status); | ||
537 | saa7110_write(client, 0x0D, 0x86); | 456 | saa7110_write(client, 0x0D, 0x86); |
538 | saa7110_write(client, 0x0F, 0x10); | 457 | saa7110_write(client, 0x0F, 0x10); |
539 | saa7110_write(client, 0x11, 0x59); | 458 | saa7110_write(client, 0x11, 0x59); |
@@ -547,58 +466,25 @@ saa7110_detect_client (struct i2c_adapter *adapter, | |||
547 | return 0; | 466 | return 0; |
548 | } | 467 | } |
549 | 468 | ||
550 | static int | 469 | static int saa7110_remove(struct i2c_client *client) |
551 | saa7110_attach_adapter (struct i2c_adapter *adapter) | ||
552 | { | ||
553 | dprintk(1, | ||
554 | KERN_INFO | ||
555 | "saa7110.c: starting probe for adapter %s (0x%x)\n", | ||
556 | I2C_NAME(adapter), adapter->id); | ||
557 | return i2c_probe(adapter, &addr_data, &saa7110_detect_client); | ||
558 | } | ||
559 | |||
560 | static int | ||
561 | saa7110_detach_client (struct i2c_client *client) | ||
562 | { | 470 | { |
563 | struct saa7110 *decoder = i2c_get_clientdata(client); | 471 | kfree(i2c_get_clientdata(client)); |
564 | int err; | ||
565 | |||
566 | err = i2c_detach_client(client); | ||
567 | if (err) { | ||
568 | return err; | ||
569 | } | ||
570 | |||
571 | kfree(decoder); | ||
572 | kfree(client); | ||
573 | |||
574 | return 0; | 472 | return 0; |
575 | } | 473 | } |
576 | 474 | ||
577 | /* ----------------------------------------------------------------------- */ | 475 | /* ----------------------------------------------------------------------- */ |
578 | 476 | ||
579 | static struct i2c_driver i2c_driver_saa7110 = { | 477 | static const struct i2c_device_id saa7110_id[] = { |
580 | .driver = { | 478 | { "saa7110", 0 }, |
581 | .name = "saa7110", | 479 | { } |
582 | }, | 480 | }; |
583 | 481 | MODULE_DEVICE_TABLE(i2c, saa7110_id); | |
584 | .id = I2C_DRIVERID_SAA7110, | ||
585 | 482 | ||
586 | .attach_adapter = saa7110_attach_adapter, | 483 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
587 | .detach_client = saa7110_detach_client, | 484 | .name = "saa7110", |
485 | .driverid = I2C_DRIVERID_SAA7110, | ||
588 | .command = saa7110_command, | 486 | .command = saa7110_command, |
487 | .probe = saa7110_probe, | ||
488 | .remove = saa7110_remove, | ||
489 | .id_table = saa7110_id, | ||
589 | }; | 490 | }; |
590 | |||
591 | static int __init | ||
592 | saa7110_init (void) | ||
593 | { | ||
594 | return i2c_add_driver(&i2c_driver_saa7110); | ||
595 | } | ||
596 | |||
597 | static void __exit | ||
598 | saa7110_exit (void) | ||
599 | { | ||
600 | i2c_del_driver(&i2c_driver_saa7110); | ||
601 | } | ||
602 | |||
603 | module_init(saa7110_init); | ||
604 | module_exit(saa7110_exit); | ||