diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 18:08:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 18:08:47 -0400 |
commit | 5564da7e9d12ea80745f66c8d2ec7bd00f3f94eb (patch) | |
tree | 30e5327e7fac3dad5e8f74e777d1f621f0693791 /drivers/media/video | |
parent | 58617d5e59663d2edea03bd03cb74279827611bb (diff) | |
parent | d4305c68cc30b66a71ea05297e6c0663feccad65 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (95 commits)
V4L/DVB (9296): Patch to remove warning message during cx88-dvb compilation
V4L/DVB (9294): gspca: Add a stop sequence in t613.
V4L/DVB (9293): gspca: Separate and fix the sensor dependant sequences in t613.
V4L/DVB (9292): gspca: Call the control setting functions at init time in t613.
V4L/DVB (9291): gspca: Do not set the white balance temperature by default in t613.
V4L/DVB (9290): gspca: Adjust the sensor init sequences in t613.
V4L/DVB (9289): gspca: Other sensor identified as om6802 in t613.
V4L/DVB (9288): gspca: Write to the USB device and not USB interface in t613.
V4L/DVB (9287): gspca: Change the name of the multi bytes write function in t613.
V4L/DVB (9286): gspca: Compilation problem of gspca.c and the kernel version.
V4L/DVB (9283): Correct typo and enable setting the gain on the mt9m111 sensor
V4L/DVB (9282): Properly iterate the urbs when destroying them.
V4L/DVB (9281): gspca: Add hflip and vflip to the po1030 sensor
V4L/DVB (9280): gspca: Use the gspca debug macros
V4L/DVB (9279): gspca: Correct some copyright headers
V4L/DVB (9278): gspca: Remove the m5602_debug variable
V4L/DVB (9277): gspca: propagate an error in m5602_start_transfer()
V4L/DVB (9276): videobuf-dvb: two functions are now static
V4L/DVB (9275): dvb: input data pointer of cx24116_writeregN() should be const
V4L/DVB (9274): Remove spurious messages and turn into debug.
...
Diffstat (limited to 'drivers/media/video')
58 files changed, 2779 insertions, 3230 deletions
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index f794f2dbfb32..e0eb4f321442 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -29,43 +29,24 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <linux/errno.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/major.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mm.h> | ||
40 | #include <linux/signal.h> | ||
41 | #include <linux/types.h> | 32 | #include <linux/types.h> |
42 | #include <linux/i2c.h> | 33 | #include <linux/ioctl.h> |
43 | #include <asm/io.h> | ||
44 | #include <asm/pgtable.h> | ||
45 | #include <asm/page.h> | ||
46 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
47 | 35 | #include <linux/i2c.h> | |
36 | #include <linux/i2c-id.h> | ||
48 | #include <linux/videodev.h> | 37 | #include <linux/videodev.h> |
49 | #include <linux/video_encoder.h> | 38 | #include <linux/video_encoder.h> |
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-i2c-drv-legacy.h> | ||
50 | 41 | ||
51 | MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); | 42 | MODULE_DESCRIPTION("Analog Devices ADV7170 video encoder driver"); |
52 | MODULE_AUTHOR("Maxim Yevtyushkin"); | 43 | MODULE_AUTHOR("Maxim Yevtyushkin"); |
53 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
54 | 45 | ||
55 | |||
56 | #define I2C_NAME(x) (x)->name | ||
57 | |||
58 | |||
59 | static int debug; | 46 | static int debug; |
60 | module_param(debug, int, 0); | 47 | module_param(debug, int, 0); |
61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 48 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
62 | 49 | ||
63 | #define dprintk(num, format, args...) \ | ||
64 | do { \ | ||
65 | if (debug >= num) \ | ||
66 | printk(format, ##args); \ | ||
67 | } while (0) | ||
68 | |||
69 | /* ----------------------------------------------------------------------- */ | 50 | /* ----------------------------------------------------------------------- */ |
70 | 51 | ||
71 | struct adv7170 { | 52 | struct adv7170 { |
@@ -80,21 +61,12 @@ struct adv7170 { | |||
80 | int sat; | 61 | int sat; |
81 | }; | 62 | }; |
82 | 63 | ||
83 | #define I2C_ADV7170 0xd4 | ||
84 | #define I2C_ADV7171 0x54 | ||
85 | |||
86 | static char adv7170_name[] = "adv7170"; | ||
87 | static char adv7171_name[] = "adv7171"; | ||
88 | |||
89 | static char *inputs[] = { "pass_through", "play_back" }; | 64 | static char *inputs[] = { "pass_through", "play_back" }; |
90 | static char *norms[] = { "PAL", "NTSC" }; | 65 | static char *norms[] = { "PAL", "NTSC" }; |
91 | 66 | ||
92 | /* ----------------------------------------------------------------------- */ | 67 | /* ----------------------------------------------------------------------- */ |
93 | 68 | ||
94 | static inline int | 69 | static inline int adv7170_write(struct i2c_client *client, u8 reg, u8 value) |
95 | adv7170_write (struct i2c_client *client, | ||
96 | u8 reg, | ||
97 | u8 value) | ||
98 | { | 70 | { |
99 | struct adv7170 *encoder = i2c_get_clientdata(client); | 71 | struct adv7170 *encoder = i2c_get_clientdata(client); |
100 | 72 | ||
@@ -102,17 +74,13 @@ adv7170_write (struct i2c_client *client, | |||
102 | return i2c_smbus_write_byte_data(client, reg, value); | 74 | return i2c_smbus_write_byte_data(client, reg, value); |
103 | } | 75 | } |
104 | 76 | ||
105 | static inline int | 77 | static inline int adv7170_read(struct i2c_client *client, u8 reg) |
106 | adv7170_read (struct i2c_client *client, | ||
107 | u8 reg) | ||
108 | { | 78 | { |
109 | return i2c_smbus_read_byte_data(client, reg); | 79 | return i2c_smbus_read_byte_data(client, reg); |
110 | } | 80 | } |
111 | 81 | ||
112 | static int | 82 | static int adv7170_write_block(struct i2c_client *client, |
113 | adv7170_write_block (struct i2c_client *client, | 83 | const u8 *data, unsigned int len) |
114 | const u8 *data, | ||
115 | unsigned int len) | ||
116 | { | 84 | { |
117 | int ret = -1; | 85 | int ret = -1; |
118 | u8 reg; | 86 | u8 reg; |
@@ -133,33 +101,25 @@ adv7170_write_block (struct i2c_client *client, | |||
133 | encoder->reg[reg++] = data[1]; | 101 | encoder->reg[reg++] = data[1]; |
134 | len -= 2; | 102 | len -= 2; |
135 | data += 2; | 103 | data += 2; |
136 | } while (len >= 2 && data[0] == reg && | 104 | } while (len >= 2 && data[0] == reg && block_len < 32); |
137 | block_len < 32); | 105 | ret = i2c_master_send(client, block_data, block_len); |
138 | if ((ret = i2c_master_send(client, block_data, | 106 | if (ret < 0) |
139 | block_len)) < 0) | ||
140 | break; | 107 | break; |
141 | } | 108 | } |
142 | } else { | 109 | } else { |
143 | /* do some slow I2C emulation kind of thing */ | 110 | /* do some slow I2C emulation kind of thing */ |
144 | while (len >= 2) { | 111 | while (len >= 2) { |
145 | reg = *data++; | 112 | reg = *data++; |
146 | if ((ret = adv7170_write(client, reg, | 113 | ret = adv7170_write(client, reg, *data++); |
147 | *data++)) < 0) | 114 | if (ret < 0) |
148 | break; | 115 | break; |
149 | len -= 2; | 116 | len -= 2; |
150 | } | 117 | } |
151 | } | 118 | } |
152 | |||
153 | return ret; | 119 | return ret; |
154 | } | 120 | } |
155 | 121 | ||
156 | /* ----------------------------------------------------------------------- */ | 122 | /* ----------------------------------------------------------------------- */ |
157 | // Output filter: S-Video Composite | ||
158 | |||
159 | #define MR050 0x11 //0x09 | ||
160 | #define MR060 0x14 //0x0c | ||
161 | |||
162 | //--------------------------------------------------------------------------- | ||
163 | 123 | ||
164 | #define TR0MODE 0x4c | 124 | #define TR0MODE 0x4c |
165 | #define TR0RST 0x80 | 125 | #define TR0RST 0x80 |
@@ -167,7 +127,6 @@ adv7170_write_block (struct i2c_client *client, | |||
167 | #define TR1CAPT 0x00 | 127 | #define TR1CAPT 0x00 |
168 | #define TR1PLAY 0x00 | 128 | #define TR1PLAY 0x00 |
169 | 129 | ||
170 | |||
171 | static const unsigned char init_NTSC[] = { | 130 | static const unsigned char init_NTSC[] = { |
172 | 0x00, 0x10, // MR0 | 131 | 0x00, 0x10, // MR0 |
173 | 0x01, 0x20, // MR1 | 132 | 0x01, 0x20, // MR1 |
@@ -227,15 +186,11 @@ static const unsigned char init_PAL[] = { | |||
227 | }; | 186 | }; |
228 | 187 | ||
229 | 188 | ||
230 | static int | 189 | static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) |
231 | adv7170_command (struct i2c_client *client, | ||
232 | unsigned int cmd, | ||
233 | void * arg) | ||
234 | { | 190 | { |
235 | struct adv7170 *encoder = i2c_get_clientdata(client); | 191 | struct adv7170 *encoder = i2c_get_clientdata(client); |
236 | 192 | ||
237 | switch (cmd) { | 193 | switch (cmd) { |
238 | |||
239 | case 0: | 194 | case 0: |
240 | #if 0 | 195 | #if 0 |
241 | /* This is just for testing!!! */ | 196 | /* This is just for testing!!! */ |
@@ -254,18 +209,16 @@ adv7170_command (struct i2c_client *client, | |||
254 | VIDEO_ENCODER_NTSC; | 209 | VIDEO_ENCODER_NTSC; |
255 | cap->inputs = 2; | 210 | cap->inputs = 2; |
256 | cap->outputs = 1; | 211 | cap->outputs = 1; |
257 | } | ||
258 | break; | 212 | break; |
213 | } | ||
259 | 214 | ||
260 | case ENCODER_SET_NORM: | 215 | case ENCODER_SET_NORM: |
261 | { | 216 | { |
262 | int iarg = *(int *) arg; | 217 | int iarg = *(int *) arg; |
263 | 218 | ||
264 | dprintk(1, KERN_DEBUG "%s_command: set norm %d", | 219 | v4l_dbg(1, debug, client, "set norm %d\n", iarg); |
265 | I2C_NAME(client), iarg); | ||
266 | 220 | ||
267 | switch (iarg) { | 221 | switch (iarg) { |
268 | |||
269 | case VIDEO_MODE_NTSC: | 222 | case VIDEO_MODE_NTSC: |
270 | adv7170_write_block(client, init_NTSC, | 223 | adv7170_write_block(client, init_NTSC, |
271 | sizeof(init_NTSC)); | 224 | sizeof(init_NTSC)); |
@@ -285,16 +238,13 @@ adv7170_command (struct i2c_client *client, | |||
285 | break; | 238 | break; |
286 | 239 | ||
287 | default: | 240 | default: |
288 | dprintk(1, KERN_ERR "%s: illegal norm: %d\n", | 241 | v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); |
289 | I2C_NAME(client), iarg); | ||
290 | return -EINVAL; | 242 | return -EINVAL; |
291 | |||
292 | } | 243 | } |
293 | dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), | 244 | v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); |
294 | norms[iarg]); | ||
295 | encoder->norm = iarg; | 245 | encoder->norm = iarg; |
296 | } | ||
297 | break; | 246 | break; |
247 | } | ||
298 | 248 | ||
299 | case ENCODER_SET_INPUT: | 249 | case ENCODER_SET_INPUT: |
300 | { | 250 | { |
@@ -304,19 +254,17 @@ adv7170_command (struct i2c_client *client, | |||
304 | *iarg = 1: input is from ZR36060 | 254 | *iarg = 1: input is from ZR36060 |
305 | *iarg = 2: color bar */ | 255 | *iarg = 2: color bar */ |
306 | 256 | ||
307 | dprintk(1, KERN_DEBUG "%s_command: set input from %s\n", | 257 | v4l_dbg(1, debug, client, "set input from %s\n", |
308 | I2C_NAME(client), | ||
309 | iarg == 0 ? "decoder" : "ZR36060"); | 258 | iarg == 0 ? "decoder" : "ZR36060"); |
310 | 259 | ||
311 | switch (iarg) { | 260 | switch (iarg) { |
312 | |||
313 | case 0: | 261 | case 0: |
314 | adv7170_write(client, 0x01, 0x20); | 262 | adv7170_write(client, 0x01, 0x20); |
315 | adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ | 263 | adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ |
316 | adv7170_write(client, 0x02, 0x0e); // Enable genlock | 264 | adv7170_write(client, 0x02, 0x0e); // Enable genlock |
317 | adv7170_write(client, 0x07, TR0MODE | TR0RST); | 265 | adv7170_write(client, 0x07, TR0MODE | TR0RST); |
318 | adv7170_write(client, 0x07, TR0MODE); | 266 | adv7170_write(client, 0x07, TR0MODE); |
319 | //udelay(10); | 267 | /* udelay(10); */ |
320 | break; | 268 | break; |
321 | 269 | ||
322 | case 1: | 270 | case 1: |
@@ -325,20 +273,17 @@ adv7170_command (struct i2c_client *client, | |||
325 | adv7170_write(client, 0x02, 0x08); | 273 | adv7170_write(client, 0x02, 0x08); |
326 | adv7170_write(client, 0x07, TR0MODE | TR0RST); | 274 | adv7170_write(client, 0x07, TR0MODE | TR0RST); |
327 | adv7170_write(client, 0x07, TR0MODE); | 275 | adv7170_write(client, 0x07, TR0MODE); |
328 | //udelay(10); | 276 | /* udelay(10); */ |
329 | break; | 277 | break; |
330 | 278 | ||
331 | default: | 279 | default: |
332 | dprintk(1, KERN_ERR "%s: illegal input: %d\n", | 280 | v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); |
333 | I2C_NAME(client), iarg); | ||
334 | return -EINVAL; | 281 | return -EINVAL; |
335 | |||
336 | } | 282 | } |
337 | dprintk(1, KERN_DEBUG "%s: switched to %s\n", I2C_NAME(client), | 283 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); |
338 | inputs[iarg]); | ||
339 | encoder->input = iarg; | 284 | encoder->input = iarg; |
340 | } | ||
341 | break; | 285 | break; |
286 | } | ||
342 | 287 | ||
343 | case ENCODER_SET_OUTPUT: | 288 | case ENCODER_SET_OUTPUT: |
344 | { | 289 | { |
@@ -348,16 +293,16 @@ adv7170_command (struct i2c_client *client, | |||
348 | if (*iarg != 0) { | 293 | if (*iarg != 0) { |
349 | return -EINVAL; | 294 | return -EINVAL; |
350 | } | 295 | } |
351 | } | ||
352 | break; | 296 | break; |
297 | } | ||
353 | 298 | ||
354 | case ENCODER_ENABLE_OUTPUT: | 299 | case ENCODER_ENABLE_OUTPUT: |
355 | { | 300 | { |
356 | int *iarg = arg; | 301 | int *iarg = arg; |
357 | 302 | ||
358 | encoder->enable = !!*iarg; | 303 | encoder->enable = !!*iarg; |
359 | } | ||
360 | break; | 304 | break; |
305 | } | ||
361 | 306 | ||
362 | default: | 307 | default: |
363 | return -EINVAL; | 308 | return -EINVAL; |
@@ -368,149 +313,67 @@ adv7170_command (struct i2c_client *client, | |||
368 | 313 | ||
369 | /* ----------------------------------------------------------------------- */ | 314 | /* ----------------------------------------------------------------------- */ |
370 | 315 | ||
371 | /* | 316 | static unsigned short normal_i2c[] = { |
372 | * Generic i2c probe | 317 | 0xd4 >> 1, 0xd6 >> 1, /* adv7170 IDs */ |
373 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 318 | 0x54 >> 1, 0x56 >> 1, /* adv7171 IDs */ |
374 | */ | ||
375 | static unsigned short normal_i2c[] = | ||
376 | { I2C_ADV7170 >> 1, (I2C_ADV7170 >> 1) + 1, | ||
377 | I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, | ||
378 | I2C_CLIENT_END | 319 | I2C_CLIENT_END |
379 | }; | 320 | }; |
380 | 321 | ||
381 | static unsigned short ignore = I2C_CLIENT_END; | 322 | I2C_CLIENT_INSMOD; |
382 | 323 | ||
383 | static struct i2c_client_address_data addr_data = { | 324 | static int adv7170_probe(struct i2c_client *client, |
384 | .normal_i2c = normal_i2c, | 325 | const struct i2c_device_id *id) |
385 | .probe = &ignore, | ||
386 | .ignore = &ignore, | ||
387 | }; | ||
388 | |||
389 | static struct i2c_driver i2c_driver_adv7170; | ||
390 | |||
391 | static int | ||
392 | adv7170_detect_client (struct i2c_adapter *adapter, | ||
393 | int address, | ||
394 | int kind) | ||
395 | { | 326 | { |
396 | int i; | ||
397 | struct i2c_client *client; | ||
398 | struct adv7170 *encoder; | 327 | struct adv7170 *encoder; |
399 | char *dname; | 328 | int i; |
400 | |||
401 | dprintk(1, | ||
402 | KERN_INFO | ||
403 | "adv7170.c: detecting adv7170 client on address 0x%x\n", | ||
404 | address << 1); | ||
405 | 329 | ||
406 | /* Check if the adapter supports the needed features */ | 330 | /* Check if the adapter supports the needed features */ |
407 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 331 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
408 | return 0; | 332 | return -ENODEV; |
409 | 333 | ||
410 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 334 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
411 | if (!client) | 335 | client->addr << 1, client->adapter->name); |
412 | return -ENOMEM; | ||
413 | client->addr = address; | ||
414 | client->adapter = adapter; | ||
415 | client->driver = &i2c_driver_adv7170; | ||
416 | if ((client->addr == I2C_ADV7170 >> 1) || | ||
417 | (client->addr == (I2C_ADV7170 >> 1) + 1)) { | ||
418 | dname = adv7170_name; | ||
419 | } else if ((client->addr == I2C_ADV7171 >> 1) || | ||
420 | (client->addr == (I2C_ADV7171 >> 1) + 1)) { | ||
421 | dname = adv7171_name; | ||
422 | } else { | ||
423 | /* We should never get here!!! */ | ||
424 | kfree(client); | ||
425 | return 0; | ||
426 | } | ||
427 | strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); | ||
428 | 336 | ||
429 | encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); | 337 | encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); |
430 | if (encoder == NULL) { | 338 | if (encoder == NULL) |
431 | kfree(client); | ||
432 | return -ENOMEM; | 339 | return -ENOMEM; |
433 | } | ||
434 | encoder->norm = VIDEO_MODE_NTSC; | 340 | encoder->norm = VIDEO_MODE_NTSC; |
435 | encoder->input = 0; | 341 | encoder->input = 0; |
436 | encoder->enable = 1; | 342 | encoder->enable = 1; |
437 | i2c_set_clientdata(client, encoder); | 343 | i2c_set_clientdata(client, encoder); |
438 | 344 | ||
439 | i = i2c_attach_client(client); | ||
440 | if (i) { | ||
441 | kfree(client); | ||
442 | kfree(encoder); | ||
443 | return i; | ||
444 | } | ||
445 | |||
446 | i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); | 345 | i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); |
447 | if (i >= 0) { | 346 | if (i >= 0) { |
448 | i = adv7170_write(client, 0x07, TR0MODE | TR0RST); | 347 | i = adv7170_write(client, 0x07, TR0MODE | TR0RST); |
449 | i = adv7170_write(client, 0x07, TR0MODE); | 348 | i = adv7170_write(client, 0x07, TR0MODE); |
450 | i = adv7170_read(client, 0x12); | 349 | i = adv7170_read(client, 0x12); |
451 | dprintk(1, KERN_INFO "%s_attach: rev. %d at 0x%02x\n", | 350 | v4l_dbg(1, debug, client, "revision %d\n", i & 1); |
452 | I2C_NAME(client), i & 1, client->addr << 1); | ||
453 | } | ||
454 | if (i < 0) { | ||
455 | dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", | ||
456 | I2C_NAME(client), i); | ||
457 | } | 351 | } |
458 | 352 | if (i < 0) | |
353 | v4l_dbg(1, debug, client, "init error 0x%x\n", i); | ||
459 | return 0; | 354 | return 0; |
460 | } | 355 | } |
461 | 356 | ||
462 | static int | 357 | static int adv7170_remove(struct i2c_client *client) |
463 | adv7170_attach_adapter (struct i2c_adapter *adapter) | ||
464 | { | ||
465 | dprintk(1, | ||
466 | KERN_INFO | ||
467 | "adv7170.c: starting probe for adapter %s (0x%x)\n", | ||
468 | I2C_NAME(adapter), adapter->id); | ||
469 | return i2c_probe(adapter, &addr_data, &adv7170_detect_client); | ||
470 | } | ||
471 | |||
472 | static int | ||
473 | adv7170_detach_client (struct i2c_client *client) | ||
474 | { | 358 | { |
475 | struct adv7170 *encoder = i2c_get_clientdata(client); | 359 | kfree(i2c_get_clientdata(client)); |
476 | int err; | ||
477 | |||
478 | err = i2c_detach_client(client); | ||
479 | if (err) { | ||
480 | return err; | ||
481 | } | ||
482 | |||
483 | kfree(encoder); | ||
484 | kfree(client); | ||
485 | |||
486 | return 0; | 360 | return 0; |
487 | } | 361 | } |
488 | 362 | ||
489 | /* ----------------------------------------------------------------------- */ | 363 | /* ----------------------------------------------------------------------- */ |
490 | 364 | ||
491 | static struct i2c_driver i2c_driver_adv7170 = { | 365 | static const struct i2c_device_id adv7170_id[] = { |
492 | .driver = { | 366 | { "adv7170", 0 }, |
493 | .name = "adv7170", /* name */ | 367 | { "adv7171", 0 }, |
494 | }, | 368 | { } |
495 | 369 | }; | |
496 | .id = I2C_DRIVERID_ADV7170, | 370 | MODULE_DEVICE_TABLE(i2c, adv7170_id); |
497 | 371 | ||
498 | .attach_adapter = adv7170_attach_adapter, | 372 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
499 | .detach_client = adv7170_detach_client, | 373 | .name = "adv7170", |
374 | .driverid = I2C_DRIVERID_ADV7170, | ||
500 | .command = adv7170_command, | 375 | .command = adv7170_command, |
376 | .probe = adv7170_probe, | ||
377 | .remove = adv7170_remove, | ||
378 | .id_table = adv7170_id, | ||
501 | }; | 379 | }; |
502 | |||
503 | static int __init | ||
504 | adv7170_init (void) | ||
505 | { | ||
506 | return i2c_add_driver(&i2c_driver_adv7170); | ||
507 | } | ||
508 | |||
509 | static void __exit | ||
510 | adv7170_exit (void) | ||
511 | { | ||
512 | i2c_del_driver(&i2c_driver_adv7170); | ||
513 | } | ||
514 | |||
515 | module_init(adv7170_init); | ||
516 | module_exit(adv7170_exit); | ||
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 8ee07a68f702..6008e84653f1 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -25,43 +25,24 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/fs.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/major.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <linux/mm.h> | ||
36 | #include <linux/signal.h> | ||
37 | #include <linux/types.h> | 28 | #include <linux/types.h> |
38 | #include <linux/i2c.h> | 29 | #include <linux/ioctl.h> |
39 | #include <asm/io.h> | ||
40 | #include <asm/pgtable.h> | ||
41 | #include <asm/page.h> | ||
42 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
43 | 31 | #include <linux/i2c.h> | |
32 | #include <linux/i2c-id.h> | ||
44 | #include <linux/videodev.h> | 33 | #include <linux/videodev.h> |
45 | #include <linux/video_encoder.h> | 34 | #include <linux/video_encoder.h> |
35 | #include <media/v4l2-common.h> | ||
36 | #include <media/v4l2-i2c-drv-legacy.h> | ||
46 | 37 | ||
47 | MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); | 38 | MODULE_DESCRIPTION("Analog Devices ADV7175 video encoder driver"); |
48 | MODULE_AUTHOR("Dave Perks"); | 39 | MODULE_AUTHOR("Dave Perks"); |
49 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
50 | 41 | ||
51 | |||
52 | #define I2C_NAME(s) (s)->name | ||
53 | |||
54 | |||
55 | static int debug; | 42 | static int debug; |
56 | module_param(debug, int, 0); | 43 | module_param(debug, int, 0); |
57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 44 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
58 | 45 | ||
59 | #define dprintk(num, format, args...) \ | ||
60 | do { \ | ||
61 | if (debug >= num) \ | ||
62 | printk(format, ##args); \ | ||
63 | } while (0) | ||
64 | |||
65 | /* ----------------------------------------------------------------------- */ | 46 | /* ----------------------------------------------------------------------- */ |
66 | 47 | ||
67 | struct adv7175 { | 48 | struct adv7175 { |
@@ -77,33 +58,23 @@ struct adv7175 { | |||
77 | #define I2C_ADV7175 0xd4 | 58 | #define I2C_ADV7175 0xd4 |
78 | #define I2C_ADV7176 0x54 | 59 | #define I2C_ADV7176 0x54 |
79 | 60 | ||
80 | static char adv7175_name[] = "adv7175"; | ||
81 | static char adv7176_name[] = "adv7176"; | ||
82 | |||
83 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; | 61 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; |
84 | static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; | 62 | static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; |
85 | 63 | ||
86 | /* ----------------------------------------------------------------------- */ | 64 | /* ----------------------------------------------------------------------- */ |
87 | 65 | ||
88 | static inline int | 66 | static inline int adv7175_write(struct i2c_client *client, u8 reg, u8 value) |
89 | adv7175_write (struct i2c_client *client, | ||
90 | u8 reg, | ||
91 | u8 value) | ||
92 | { | 67 | { |
93 | return i2c_smbus_write_byte_data(client, reg, value); | 68 | return i2c_smbus_write_byte_data(client, reg, value); |
94 | } | 69 | } |
95 | 70 | ||
96 | static inline int | 71 | static inline int adv7175_read(struct i2c_client *client, u8 reg) |
97 | adv7175_read (struct i2c_client *client, | ||
98 | u8 reg) | ||
99 | { | 72 | { |
100 | return i2c_smbus_read_byte_data(client, reg); | 73 | return i2c_smbus_read_byte_data(client, reg); |
101 | } | 74 | } |
102 | 75 | ||
103 | static int | 76 | static int adv7175_write_block(struct i2c_client *client, |
104 | adv7175_write_block (struct i2c_client *client, | 77 | const u8 *data, unsigned int len) |
105 | const u8 *data, | ||
106 | unsigned int len) | ||
107 | { | 78 | { |
108 | int ret = -1; | 79 | int ret = -1; |
109 | u8 reg; | 80 | u8 reg; |
@@ -123,18 +94,17 @@ adv7175_write_block (struct i2c_client *client, | |||
123 | reg++; | 94 | reg++; |
124 | len -= 2; | 95 | len -= 2; |
125 | data += 2; | 96 | data += 2; |
126 | } while (len >= 2 && data[0] == reg && | 97 | } while (len >= 2 && data[0] == reg && block_len < 32); |
127 | block_len < 32); | 98 | ret = i2c_master_send(client, block_data, block_len); |
128 | if ((ret = i2c_master_send(client, block_data, | 99 | if (ret < 0) |
129 | block_len)) < 0) | ||
130 | break; | 100 | break; |
131 | } | 101 | } |
132 | } else { | 102 | } else { |
133 | /* do some slow I2C emulation kind of thing */ | 103 | /* do some slow I2C emulation kind of thing */ |
134 | while (len >= 2) { | 104 | while (len >= 2) { |
135 | reg = *data++; | 105 | reg = *data++; |
136 | if ((ret = adv7175_write(client, reg, | 106 | ret = adv7175_write(client, reg, *data++); |
137 | *data++)) < 0) | 107 | if (ret < 0) |
138 | break; | 108 | break; |
139 | len -= 2; | 109 | len -= 2; |
140 | } | 110 | } |
@@ -143,13 +113,11 @@ adv7175_write_block (struct i2c_client *client, | |||
143 | return ret; | 113 | return ret; |
144 | } | 114 | } |
145 | 115 | ||
146 | static void | 116 | static void set_subcarrier_freq(struct i2c_client *client, int pass_through) |
147 | set_subcarrier_freq (struct i2c_client *client, | ||
148 | int pass_through) | ||
149 | { | 117 | { |
150 | /* for some reason pass_through NTSC needs | 118 | /* for some reason pass_through NTSC needs |
151 | * a different sub-carrier freq to remain stable. */ | 119 | * a different sub-carrier freq to remain stable. */ |
152 | if(pass_through) | 120 | if (pass_through) |
153 | adv7175_write(client, 0x02, 0x00); | 121 | adv7175_write(client, 0x02, 0x00); |
154 | else | 122 | else |
155 | adv7175_write(client, 0x02, 0x55); | 123 | adv7175_write(client, 0x02, 0x55); |
@@ -160,12 +128,12 @@ set_subcarrier_freq (struct i2c_client *client, | |||
160 | } | 128 | } |
161 | 129 | ||
162 | /* ----------------------------------------------------------------------- */ | 130 | /* ----------------------------------------------------------------------- */ |
163 | // Output filter: S-Video Composite | 131 | /* Output filter: S-Video Composite */ |
164 | 132 | ||
165 | #define MR050 0x11 //0x09 | 133 | #define MR050 0x11 /* 0x09 */ |
166 | #define MR060 0x14 //0x0c | 134 | #define MR060 0x14 /* 0x0c */ |
167 | 135 | ||
168 | //--------------------------------------------------------------------------- | 136 | /* ----------------------------------------------------------------------- */ |
169 | 137 | ||
170 | #define TR0MODE 0x46 | 138 | #define TR0MODE 0x46 |
171 | #define TR0RST 0x80 | 139 | #define TR0RST 0x80 |
@@ -216,15 +184,11 @@ static const unsigned char init_ntsc[] = { | |||
216 | 0x06, 0x1a, /* subc. phase */ | 184 | 0x06, 0x1a, /* subc. phase */ |
217 | }; | 185 | }; |
218 | 186 | ||
219 | static int | 187 | static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) |
220 | adv7175_command (struct i2c_client *client, | ||
221 | unsigned int cmd, | ||
222 | void *arg) | ||
223 | { | 188 | { |
224 | struct adv7175 *encoder = i2c_get_clientdata(client); | 189 | struct adv7175 *encoder = i2c_get_clientdata(client); |
225 | 190 | ||
226 | switch (cmd) { | 191 | switch (cmd) { |
227 | |||
228 | case 0: | 192 | case 0: |
229 | /* This is just for testing!!! */ | 193 | /* This is just for testing!!! */ |
230 | adv7175_write_block(client, init_common, | 194 | adv7175_write_block(client, init_common, |
@@ -242,15 +206,14 @@ adv7175_command (struct i2c_client *client, | |||
242 | VIDEO_ENCODER_SECAM; /* well, hacky */ | 206 | VIDEO_ENCODER_SECAM; /* well, hacky */ |
243 | cap->inputs = 2; | 207 | cap->inputs = 2; |
244 | cap->outputs = 1; | 208 | cap->outputs = 1; |
245 | } | ||
246 | break; | 209 | break; |
210 | } | ||
247 | 211 | ||
248 | case ENCODER_SET_NORM: | 212 | case ENCODER_SET_NORM: |
249 | { | 213 | { |
250 | int iarg = *(int *) arg; | 214 | int iarg = *(int *) arg; |
251 | 215 | ||
252 | switch (iarg) { | 216 | switch (iarg) { |
253 | |||
254 | case VIDEO_MODE_NTSC: | 217 | case VIDEO_MODE_NTSC: |
255 | adv7175_write_block(client, init_ntsc, | 218 | adv7175_write_block(client, init_ntsc, |
256 | sizeof(init_ntsc)); | 219 | sizeof(init_ntsc)); |
@@ -284,16 +247,13 @@ adv7175_command (struct i2c_client *client, | |||
284 | adv7175_write(client, 0x07, TR0MODE); | 247 | adv7175_write(client, 0x07, TR0MODE); |
285 | break; | 248 | break; |
286 | default: | 249 | default: |
287 | dprintk(1, KERN_ERR "%s: illegal norm: %d\n", | 250 | v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); |
288 | I2C_NAME(client), iarg); | ||
289 | return -EINVAL; | 251 | return -EINVAL; |
290 | |||
291 | } | 252 | } |
292 | dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), | 253 | v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); |
293 | norms[iarg]); | ||
294 | encoder->norm = iarg; | 254 | encoder->norm = iarg; |
295 | } | ||
296 | break; | 255 | break; |
256 | } | ||
297 | 257 | ||
298 | case ENCODER_SET_INPUT: | 258 | case ENCODER_SET_INPUT: |
299 | { | 259 | { |
@@ -304,7 +264,6 @@ adv7175_command (struct i2c_client *client, | |||
304 | *iarg = 2: color bar */ | 264 | *iarg = 2: color bar */ |
305 | 265 | ||
306 | switch (iarg) { | 266 | switch (iarg) { |
307 | |||
308 | case 0: | 267 | case 0: |
309 | adv7175_write(client, 0x01, 0x00); | 268 | adv7175_write(client, 0x01, 0x00); |
310 | 269 | ||
@@ -331,7 +290,7 @@ adv7175_command (struct i2c_client *client, | |||
331 | adv7175_write(client, 0x0d, 0x49); | 290 | adv7175_write(client, 0x0d, 0x49); |
332 | adv7175_write(client, 0x07, TR0MODE | TR0RST); | 291 | adv7175_write(client, 0x07, TR0MODE | TR0RST); |
333 | adv7175_write(client, 0x07, TR0MODE); | 292 | adv7175_write(client, 0x07, TR0MODE); |
334 | //udelay(10); | 293 | /* udelay(10); */ |
335 | break; | 294 | break; |
336 | 295 | ||
337 | case 2: | 296 | case 2: |
@@ -343,39 +302,35 @@ adv7175_command (struct i2c_client *client, | |||
343 | adv7175_write(client, 0x0d, 0x49); | 302 | adv7175_write(client, 0x0d, 0x49); |
344 | adv7175_write(client, 0x07, TR0MODE | TR0RST); | 303 | adv7175_write(client, 0x07, TR0MODE | TR0RST); |
345 | adv7175_write(client, 0x07, TR0MODE); | 304 | adv7175_write(client, 0x07, TR0MODE); |
346 | //udelay(10); | 305 | /* udelay(10); */ |
347 | break; | 306 | break; |
348 | 307 | ||
349 | default: | 308 | default: |
350 | dprintk(1, KERN_ERR "%s: illegal input: %d\n", | 309 | v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); |
351 | I2C_NAME(client), iarg); | ||
352 | return -EINVAL; | 310 | return -EINVAL; |
353 | |||
354 | } | 311 | } |
355 | dprintk(1, KERN_INFO "%s: switched to %s\n", I2C_NAME(client), | 312 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); |
356 | inputs[iarg]); | ||
357 | encoder->input = iarg; | 313 | encoder->input = iarg; |
358 | } | ||
359 | break; | 314 | break; |
315 | } | ||
360 | 316 | ||
361 | case ENCODER_SET_OUTPUT: | 317 | case ENCODER_SET_OUTPUT: |
362 | { | 318 | { |
363 | int *iarg = arg; | 319 | int *iarg = arg; |
364 | 320 | ||
365 | /* not much choice of outputs */ | 321 | /* not much choice of outputs */ |
366 | if (*iarg != 0) { | 322 | if (*iarg != 0) |
367 | return -EINVAL; | 323 | return -EINVAL; |
368 | } | ||
369 | } | ||
370 | break; | 324 | break; |
325 | } | ||
371 | 326 | ||
372 | case ENCODER_ENABLE_OUTPUT: | 327 | case ENCODER_ENABLE_OUTPUT: |
373 | { | 328 | { |
374 | int *iarg = arg; | 329 | int *iarg = arg; |
375 | 330 | ||
376 | encoder->enable = !!*iarg; | 331 | encoder->enable = !!*iarg; |
377 | } | ||
378 | break; | 332 | break; |
333 | } | ||
379 | 334 | ||
380 | default: | 335 | default: |
381 | return -EINVAL; | 336 | return -EINVAL; |
@@ -390,145 +345,67 @@ adv7175_command (struct i2c_client *client, | |||
390 | * Generic i2c probe | 345 | * Generic i2c probe |
391 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | 346 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' |
392 | */ | 347 | */ |
393 | static unsigned short normal_i2c[] = | 348 | static unsigned short normal_i2c[] = { |
394 | { I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, | 349 | I2C_ADV7175 >> 1, (I2C_ADV7175 >> 1) + 1, |
395 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, | 350 | I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, |
396 | I2C_CLIENT_END | 351 | I2C_CLIENT_END |
397 | }; | 352 | }; |
398 | 353 | ||
399 | static unsigned short ignore = I2C_CLIENT_END; | 354 | I2C_CLIENT_INSMOD; |
400 | |||
401 | static struct i2c_client_address_data addr_data = { | ||
402 | .normal_i2c = normal_i2c, | ||
403 | .probe = &ignore, | ||
404 | .ignore = &ignore, | ||
405 | }; | ||
406 | |||
407 | static struct i2c_driver i2c_driver_adv7175; | ||
408 | 355 | ||
409 | static int | 356 | static int adv7175_probe(struct i2c_client *client, |
410 | adv7175_detect_client (struct i2c_adapter *adapter, | 357 | const struct i2c_device_id *id) |
411 | int address, | ||
412 | int kind) | ||
413 | { | 358 | { |
414 | int i; | 359 | int i; |
415 | struct i2c_client *client; | ||
416 | struct adv7175 *encoder; | 360 | struct adv7175 *encoder; |
417 | char *dname; | ||
418 | |||
419 | dprintk(1, | ||
420 | KERN_INFO | ||
421 | "adv7175.c: detecting adv7175 client on address 0x%x\n", | ||
422 | address << 1); | ||
423 | 361 | ||
424 | /* Check if the adapter supports the needed features */ | 362 | /* Check if the adapter supports the needed features */ |
425 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 363 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
426 | return 0; | 364 | return -ENODEV; |
427 | 365 | ||
428 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 366 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
429 | if (!client) | 367 | client->addr << 1, client->adapter->name); |
430 | return -ENOMEM; | ||
431 | client->addr = address; | ||
432 | client->adapter = adapter; | ||
433 | client->driver = &i2c_driver_adv7175; | ||
434 | if ((client->addr == I2C_ADV7175 >> 1) || | ||
435 | (client->addr == (I2C_ADV7175 >> 1) + 1)) { | ||
436 | dname = adv7175_name; | ||
437 | } else if ((client->addr == I2C_ADV7176 >> 1) || | ||
438 | (client->addr == (I2C_ADV7176 >> 1) + 1)) { | ||
439 | dname = adv7176_name; | ||
440 | } else { | ||
441 | /* We should never get here!!! */ | ||
442 | kfree(client); | ||
443 | return 0; | ||
444 | } | ||
445 | strlcpy(I2C_NAME(client), dname, sizeof(I2C_NAME(client))); | ||
446 | 368 | ||
447 | encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); | 369 | encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); |
448 | if (encoder == NULL) { | 370 | if (encoder == NULL) |
449 | kfree(client); | ||
450 | return -ENOMEM; | 371 | return -ENOMEM; |
451 | } | ||
452 | encoder->norm = VIDEO_MODE_PAL; | 372 | encoder->norm = VIDEO_MODE_PAL; |
453 | encoder->input = 0; | 373 | encoder->input = 0; |
454 | encoder->enable = 1; | 374 | encoder->enable = 1; |
455 | i2c_set_clientdata(client, encoder); | 375 | i2c_set_clientdata(client, encoder); |
456 | 376 | ||
457 | i = i2c_attach_client(client); | ||
458 | if (i) { | ||
459 | kfree(client); | ||
460 | kfree(encoder); | ||
461 | return i; | ||
462 | } | ||
463 | |||
464 | i = adv7175_write_block(client, init_common, sizeof(init_common)); | 377 | i = adv7175_write_block(client, init_common, sizeof(init_common)); |
465 | if (i >= 0) { | 378 | if (i >= 0) { |
466 | i = adv7175_write(client, 0x07, TR0MODE | TR0RST); | 379 | i = adv7175_write(client, 0x07, TR0MODE | TR0RST); |
467 | i = adv7175_write(client, 0x07, TR0MODE); | 380 | i = adv7175_write(client, 0x07, TR0MODE); |
468 | i = adv7175_read(client, 0x12); | 381 | i = adv7175_read(client, 0x12); |
469 | dprintk(1, KERN_INFO "%s_attach: rev. %d at 0x%x\n", | 382 | v4l_dbg(1, debug, client, "revision %d\n", i & 1); |
470 | I2C_NAME(client), i & 1, client->addr << 1); | ||
471 | } | 383 | } |
472 | if (i < 0) { | 384 | if (i < 0) |
473 | dprintk(1, KERN_ERR "%s_attach: init error 0x%x\n", | 385 | v4l_dbg(1, debug, client, "init error 0x%x\n", i); |
474 | I2C_NAME(client), i); | ||
475 | } | ||
476 | |||
477 | return 0; | 386 | return 0; |
478 | } | 387 | } |
479 | 388 | ||
480 | static int | 389 | static int adv7175_remove(struct i2c_client *client) |
481 | adv7175_attach_adapter (struct i2c_adapter *adapter) | ||
482 | { | ||
483 | dprintk(1, | ||
484 | KERN_INFO | ||
485 | "adv7175.c: starting probe for adapter %s (0x%x)\n", | ||
486 | I2C_NAME(adapter), adapter->id); | ||
487 | return i2c_probe(adapter, &addr_data, &adv7175_detect_client); | ||
488 | } | ||
489 | |||
490 | static int | ||
491 | adv7175_detach_client (struct i2c_client *client) | ||
492 | { | 390 | { |
493 | struct adv7175 *encoder = i2c_get_clientdata(client); | 391 | kfree(i2c_get_clientdata(client)); |
494 | int err; | ||
495 | |||
496 | err = i2c_detach_client(client); | ||
497 | if (err) { | ||
498 | return err; | ||
499 | } | ||
500 | |||
501 | kfree(encoder); | ||
502 | kfree(client); | ||
503 | |||
504 | return 0; | 392 | return 0; |
505 | } | 393 | } |
506 | 394 | ||
507 | /* ----------------------------------------------------------------------- */ | 395 | /* ----------------------------------------------------------------------- */ |
508 | 396 | ||
509 | static struct i2c_driver i2c_driver_adv7175 = { | 397 | static const struct i2c_device_id adv7175_id[] = { |
510 | .driver = { | 398 | { "adv7175", 0 }, |
511 | .name = "adv7175", /* name */ | 399 | { "adv7176", 0 }, |
512 | }, | 400 | { } |
513 | 401 | }; | |
514 | .id = I2C_DRIVERID_ADV7175, | 402 | MODULE_DEVICE_TABLE(i2c, adv7175_id); |
515 | 403 | ||
516 | .attach_adapter = adv7175_attach_adapter, | 404 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
517 | .detach_client = adv7175_detach_client, | 405 | .name = "adv7175", |
406 | .driverid = I2C_DRIVERID_ADV7175, | ||
518 | .command = adv7175_command, | 407 | .command = adv7175_command, |
408 | .probe = adv7175_probe, | ||
409 | .remove = adv7175_remove, | ||
410 | .id_table = adv7175_id, | ||
519 | }; | 411 | }; |
520 | |||
521 | static int __init | ||
522 | adv7175_init (void) | ||
523 | { | ||
524 | return i2c_add_driver(&i2c_driver_adv7175); | ||
525 | } | ||
526 | |||
527 | static void __exit | ||
528 | adv7175_exit (void) | ||
529 | { | ||
530 | i2c_del_driver(&i2c_driver_adv7175); | ||
531 | } | ||
532 | |||
533 | module_init(adv7175_init); | ||
534 | module_exit(adv7175_exit); | ||
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c index 5f07a8a072b6..d60123b413f5 100644 --- a/drivers/media/video/au0828/au0828-cards.c +++ b/drivers/media/video/au0828/au0828-cards.c | |||
@@ -90,6 +90,7 @@ static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) | |||
90 | case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | 90 | case 72221: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ |
91 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ | 91 | case 72231: /* WinTV-HVR950q (OEM, IR, ATSC/QAM and basic analog video */ |
92 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ | 92 | case 72241: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM and basic analog video */ |
93 | case 72251: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ | ||
93 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ | 94 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ |
94 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ | 95 | case 72500: /* WinTV-HVR950q (OEM, No IR, ATSC/QAM */ |
95 | break; | 96 | break; |
@@ -185,7 +186,7 @@ void au0828_gpio_setup(struct au0828_dev *dev) | |||
185 | } | 186 | } |
186 | 187 | ||
187 | /* table of devices that work with this driver */ | 188 | /* table of devices that work with this driver */ |
188 | struct usb_device_id au0828_usb_id_table [] = { | 189 | struct usb_device_id au0828_usb_id_table[] = { |
189 | { USB_DEVICE(0x2040, 0x7200), | 190 | { USB_DEVICE(0x2040, 0x7200), |
190 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 191 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
191 | { USB_DEVICE(0x2040, 0x7240), | 192 | { USB_DEVICE(0x2040, 0x7240), |
@@ -198,6 +199,8 @@ struct usb_device_id au0828_usb_id_table [] = { | |||
198 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 199 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
199 | { USB_DEVICE(0x2040, 0x721b), | 200 | { USB_DEVICE(0x2040, 0x721b), |
200 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 201 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
202 | { USB_DEVICE(0x2040, 0x721e), | ||
203 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
201 | { USB_DEVICE(0x2040, 0x721f), | 204 | { USB_DEVICE(0x2040, 0x721f), |
202 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | 205 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, |
203 | { USB_DEVICE(0x2040, 0x7280), | 206 | { USB_DEVICE(0x2040, 0x7280), |
diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c index d856de9f742f..5765e8656376 100644 --- a/drivers/media/video/au0828/au0828-core.c +++ b/drivers/media/video/au0828/au0828-core.c | |||
@@ -91,7 +91,8 @@ static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value, | |||
91 | status = usb_control_msg(dev->usbdev, | 91 | status = usb_control_msg(dev->usbdev, |
92 | usb_sndctrlpipe(dev->usbdev, 0), | 92 | usb_sndctrlpipe(dev->usbdev, 0), |
93 | request, | 93 | request, |
94 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 94 | USB_DIR_OUT | USB_TYPE_VENDOR | |
95 | USB_RECIP_DEVICE, | ||
95 | value, index, | 96 | value, index, |
96 | cp, size, 1000); | 97 | cp, size, 1000); |
97 | 98 | ||
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c index f0fcdb4769d7..a882cf546d0a 100644 --- a/drivers/media/video/au0828/au0828-dvb.c +++ b/drivers/media/video/au0828/au0828-dvb.c | |||
@@ -173,7 +173,8 @@ static int start_urb_transfer(struct au0828_dev *dev) | |||
173 | purb->status = -EINPROGRESS; | 173 | purb->status = -EINPROGRESS; |
174 | usb_fill_bulk_urb(purb, | 174 | usb_fill_bulk_urb(purb, |
175 | dev->usbdev, | 175 | dev->usbdev, |
176 | usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE), | 176 | usb_rcvbulkpipe(dev->usbdev, |
177 | _AU0828_BULKPIPE), | ||
177 | purb->transfer_buffer, | 178 | purb->transfer_buffer, |
178 | URB_BUFSIZE, | 179 | URB_BUFSIZE, |
179 | urb_completion, | 180 | urb_completion, |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index ddd2a7964dec..a07b7b88e5b8 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -29,44 +29,25 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
34 | #include <linux/errno.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/major.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mm.h> | ||
40 | #include <linux/signal.h> | ||
41 | #include <linux/types.h> | 33 | #include <linux/types.h> |
42 | #include <linux/i2c.h> | 34 | #include <linux/ioctl.h> |
43 | #include <asm/io.h> | ||
44 | #include <asm/pgtable.h> | ||
45 | #include <asm/page.h> | ||
46 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
47 | 36 | #include <linux/i2c.h> | |
37 | #include <linux/i2c-id.h> | ||
48 | #include <linux/videodev.h> | 38 | #include <linux/videodev.h> |
49 | #include <linux/video_decoder.h> | 39 | #include <linux/video_decoder.h> |
50 | 40 | #include <media/v4l2-common.h> | |
41 | #include <media/v4l2-i2c-drv-legacy.h> | ||
51 | 42 | ||
52 | MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); | 43 | MODULE_DESCRIPTION("Brooktree-819 video decoder driver"); |
53 | MODULE_AUTHOR("Mike Bernson & Dave Perks"); | 44 | MODULE_AUTHOR("Mike Bernson & Dave Perks"); |
54 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
55 | 46 | ||
56 | |||
57 | #define I2C_NAME(s) (s)->name | ||
58 | |||
59 | |||
60 | static int debug; | 47 | static int debug; |
61 | module_param(debug, int, 0); | 48 | module_param(debug, int, 0); |
62 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 49 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
63 | 50 | ||
64 | #define dprintk(num, format, args...) \ | ||
65 | do { \ | ||
66 | if (debug >= num) \ | ||
67 | printk(format, ##args); \ | ||
68 | } while (0) | ||
69 | |||
70 | /* ----------------------------------------------------------------------- */ | 51 | /* ----------------------------------------------------------------------- */ |
71 | 52 | ||
72 | struct bt819 { | 53 | struct bt819 { |
@@ -97,14 +78,9 @@ static struct timing timing_data[] = { | |||
97 | {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000}, | 78 | {858 - 24, 20, 525 - 2, 1, 0x00f8, 0x0000}, |
98 | }; | 79 | }; |
99 | 80 | ||
100 | #define I2C_BT819 0x8a | ||
101 | |||
102 | /* ----------------------------------------------------------------------- */ | 81 | /* ----------------------------------------------------------------------- */ |
103 | 82 | ||
104 | static inline int | 83 | static inline int bt819_write(struct i2c_client *client, u8 reg, u8 value) |
105 | bt819_write (struct i2c_client *client, | ||
106 | u8 reg, | ||
107 | u8 value) | ||
108 | { | 84 | { |
109 | struct bt819 *decoder = i2c_get_clientdata(client); | 85 | struct bt819 *decoder = i2c_get_clientdata(client); |
110 | 86 | ||
@@ -112,24 +88,15 @@ bt819_write (struct i2c_client *client, | |||
112 | return i2c_smbus_write_byte_data(client, reg, value); | 88 | return i2c_smbus_write_byte_data(client, reg, value); |
113 | } | 89 | } |
114 | 90 | ||
115 | static inline int | 91 | static inline int bt819_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) |
116 | bt819_setbit (struct i2c_client *client, | ||
117 | u8 reg, | ||
118 | u8 bit, | ||
119 | u8 value) | ||
120 | { | 92 | { |
121 | struct bt819 *decoder = i2c_get_clientdata(client); | 93 | struct bt819 *decoder = i2c_get_clientdata(client); |
122 | 94 | ||
123 | return bt819_write(client, reg, | 95 | return bt819_write(client, reg, |
124 | (decoder-> | 96 | (decoder->reg[reg] & ~(1 << bit)) | (value ? (1 << bit) : 0)); |
125 | reg[reg] & ~(1 << bit)) | | ||
126 | (value ? (1 << bit) : 0)); | ||
127 | } | 97 | } |
128 | 98 | ||
129 | static int | 99 | static int bt819_write_block(struct i2c_client *client, const u8 *data, unsigned int len) |
130 | bt819_write_block (struct i2c_client *client, | ||
131 | const u8 *data, | ||
132 | unsigned int len) | ||
133 | { | 100 | { |
134 | int ret = -1; | 101 | int ret = -1; |
135 | u8 reg; | 102 | u8 reg; |
@@ -150,10 +117,9 @@ bt819_write_block (struct i2c_client *client, | |||
150 | decoder->reg[reg++] = data[1]; | 117 | decoder->reg[reg++] = data[1]; |
151 | len -= 2; | 118 | len -= 2; |
152 | data += 2; | 119 | data += 2; |
153 | } while (len >= 2 && data[0] == reg && | 120 | } while (len >= 2 && data[0] == reg && block_len < 32); |
154 | block_len < 32); | 121 | ret = i2c_master_send(client, block_data, block_len); |
155 | if ((ret = i2c_master_send(client, block_data, | 122 | if (ret < 0) |
156 | block_len)) < 0) | ||
157 | break; | 123 | break; |
158 | } | 124 | } |
159 | } else { | 125 | } else { |
@@ -169,20 +135,17 @@ bt819_write_block (struct i2c_client *client, | |||
169 | return ret; | 135 | return ret; |
170 | } | 136 | } |
171 | 137 | ||
172 | static inline int | 138 | static inline int bt819_read(struct i2c_client *client, u8 reg) |
173 | bt819_read (struct i2c_client *client, | ||
174 | u8 reg) | ||
175 | { | 139 | { |
176 | return i2c_smbus_read_byte_data(client, reg); | 140 | return i2c_smbus_read_byte_data(client, reg); |
177 | } | 141 | } |
178 | 142 | ||
179 | static int | 143 | static int bt819_init(struct i2c_client *client) |
180 | bt819_init (struct i2c_client *client) | ||
181 | { | 144 | { |
182 | struct bt819 *decoder = i2c_get_clientdata(client); | 145 | struct bt819 *decoder = i2c_get_clientdata(client); |
183 | 146 | ||
184 | static unsigned char init[] = { | 147 | static unsigned char init[] = { |
185 | //0x1f, 0x00, /* Reset */ | 148 | /*0x1f, 0x00,*/ /* Reset */ |
186 | 0x01, 0x59, /* 0x01 input format */ | 149 | 0x01, 0x59, /* 0x01 input format */ |
187 | 0x02, 0x00, /* 0x02 temporal decimation */ | 150 | 0x02, 0x00, /* 0x02 temporal decimation */ |
188 | 0x03, 0x12, /* 0x03 Cropping msb */ | 151 | 0x03, 0x12, /* 0x03 Cropping msb */ |
@@ -218,12 +181,10 @@ bt819_init (struct i2c_client *client) | |||
218 | struct timing *timing = &timing_data[decoder->norm]; | 181 | struct timing *timing = &timing_data[decoder->norm]; |
219 | 182 | ||
220 | init[0x03 * 2 - 1] = | 183 | init[0x03 * 2 - 1] = |
221 | (((timing->vdelay >> 8) & 0x03) << 6) | (((timing-> | 184 | (((timing->vdelay >> 8) & 0x03) << 6) | |
222 | vactive >> 8) & | 185 | (((timing->vactive >> 8) & 0x03) << 4) | |
223 | 0x03) << 4) | | 186 | (((timing->hdelay >> 8) & 0x03) << 2) | |
224 | (((timing->hdelay >> 8) & 0x03) << 2) | ((timing-> | 187 | ((timing->hactive >> 8) & 0x03); |
225 | hactive >> 8) & | ||
226 | 0x03); | ||
227 | init[0x04 * 2 - 1] = timing->vdelay & 0xff; | 188 | init[0x04 * 2 - 1] = timing->vdelay & 0xff; |
228 | init[0x05 * 2 - 1] = timing->vactive & 0xff; | 189 | init[0x05 * 2 - 1] = timing->vactive & 0xff; |
229 | init[0x06 * 2 - 1] = timing->hdelay & 0xff; | 190 | init[0x06 * 2 - 1] = timing->hdelay & 0xff; |
@@ -238,27 +199,22 @@ bt819_init (struct i2c_client *client) | |||
238 | 199 | ||
239 | /* init */ | 200 | /* init */ |
240 | return bt819_write_block(client, init, sizeof(init)); | 201 | return bt819_write_block(client, init, sizeof(init)); |
241 | |||
242 | } | 202 | } |
243 | 203 | ||
244 | /* ----------------------------------------------------------------------- */ | 204 | /* ----------------------------------------------------------------------- */ |
245 | 205 | ||
246 | static int | 206 | static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) |
247 | bt819_command (struct i2c_client *client, | ||
248 | unsigned int cmd, | ||
249 | void *arg) | ||
250 | { | 207 | { |
251 | int temp; | 208 | int temp; |
252 | 209 | ||
253 | struct bt819 *decoder = i2c_get_clientdata(client); | 210 | struct bt819 *decoder = i2c_get_clientdata(client); |
254 | 211 | ||
255 | if (!decoder->initialized) { // First call to bt819_init could be | 212 | if (!decoder->initialized) { /* First call to bt819_init could be */ |
256 | bt819_init(client); // without #FRST = 0 | 213 | bt819_init(client); /* without #FRST = 0 */ |
257 | decoder->initialized = 1; | 214 | decoder->initialized = 1; |
258 | } | 215 | } |
259 | 216 | ||
260 | switch (cmd) { | 217 | switch (cmd) { |
261 | |||
262 | case 0: | 218 | case 0: |
263 | /* This is just for testing!!! */ | 219 | /* This is just for testing!!! */ |
264 | bt819_init(client); | 220 | bt819_init(client); |
@@ -274,8 +230,8 @@ bt819_command (struct i2c_client *client, | |||
274 | VIDEO_DECODER_CCIR; | 230 | VIDEO_DECODER_CCIR; |
275 | cap->inputs = 8; | 231 | cap->inputs = 8; |
276 | cap->outputs = 1; | 232 | cap->outputs = 1; |
277 | } | ||
278 | break; | 233 | break; |
234 | } | ||
279 | 235 | ||
280 | case DECODER_GET_STATUS: | 236 | case DECODER_GET_STATUS: |
281 | { | 237 | { |
@@ -285,9 +241,9 @@ bt819_command (struct i2c_client *client, | |||
285 | 241 | ||
286 | status = bt819_read(client, 0x00); | 242 | status = bt819_read(client, 0x00); |
287 | res = 0; | 243 | res = 0; |
288 | if ((status & 0x80)) { | 244 | if ((status & 0x80)) |
289 | res |= DECODER_STATUS_GOOD; | 245 | res |= DECODER_STATUS_GOOD; |
290 | } | 246 | |
291 | switch (decoder->norm) { | 247 | switch (decoder->norm) { |
292 | case VIDEO_MODE_NTSC: | 248 | case VIDEO_MODE_NTSC: |
293 | res |= DECODER_STATUS_NTSC; | 249 | res |= DECODER_STATUS_NTSC; |
@@ -297,28 +253,25 @@ bt819_command (struct i2c_client *client, | |||
297 | break; | 253 | break; |
298 | default: | 254 | default: |
299 | case VIDEO_MODE_AUTO: | 255 | case VIDEO_MODE_AUTO: |
300 | if ((status & 0x10)) { | 256 | if ((status & 0x10)) |
301 | res |= DECODER_STATUS_PAL; | 257 | res |= DECODER_STATUS_PAL; |
302 | } else { | 258 | else |
303 | res |= DECODER_STATUS_NTSC; | 259 | res |= DECODER_STATUS_NTSC; |
304 | } | ||
305 | break; | 260 | break; |
306 | } | 261 | } |
307 | res |= DECODER_STATUS_COLOR; | 262 | res |= DECODER_STATUS_COLOR; |
308 | *iarg = res; | 263 | *iarg = res; |
309 | 264 | ||
310 | dprintk(1, KERN_INFO "%s: get status %x\n", I2C_NAME(client), | 265 | v4l_dbg(1, debug, client, "get status %x\n", *iarg); |
311 | *iarg); | ||
312 | } | ||
313 | break; | 266 | break; |
267 | } | ||
314 | 268 | ||
315 | case DECODER_SET_NORM: | 269 | case DECODER_SET_NORM: |
316 | { | 270 | { |
317 | int *iarg = arg; | 271 | int *iarg = arg; |
318 | struct timing *timing = NULL; | 272 | struct timing *timing = NULL; |
319 | 273 | ||
320 | dprintk(1, KERN_INFO "%s: set norm %x\n", I2C_NAME(client), | 274 | v4l_dbg(1, debug, client, "set norm %x\n", *iarg); |
321 | *iarg); | ||
322 | 275 | ||
323 | switch (*iarg) { | 276 | switch (*iarg) { |
324 | case VIDEO_MODE_NTSC: | 277 | case VIDEO_MODE_NTSC: |
@@ -327,7 +280,7 @@ bt819_command (struct i2c_client *client, | |||
327 | bt819_setbit(client, 0x01, 5, 0); | 280 | bt819_setbit(client, 0x01, 5, 0); |
328 | bt819_write(client, 0x18, 0x68); | 281 | bt819_write(client, 0x18, 0x68); |
329 | bt819_write(client, 0x19, 0x5d); | 282 | bt819_write(client, 0x19, 0x5d); |
330 | //bt819_setbit(client, 0x1a, 5, 1); | 283 | /* bt819_setbit(client, 0x1a, 5, 1); */ |
331 | timing = &timing_data[VIDEO_MODE_NTSC]; | 284 | timing = &timing_data[VIDEO_MODE_NTSC]; |
332 | break; | 285 | break; |
333 | case VIDEO_MODE_PAL: | 286 | case VIDEO_MODE_PAL: |
@@ -336,7 +289,7 @@ bt819_command (struct i2c_client *client, | |||
336 | bt819_setbit(client, 0x01, 5, 1); | 289 | bt819_setbit(client, 0x01, 5, 1); |
337 | bt819_write(client, 0x18, 0x7f); | 290 | bt819_write(client, 0x18, 0x7f); |
338 | bt819_write(client, 0x19, 0x72); | 291 | bt819_write(client, 0x19, 0x72); |
339 | //bt819_setbit(client, 0x1a, 5, 0); | 292 | /* bt819_setbit(client, 0x1a, 5, 0); */ |
340 | timing = &timing_data[VIDEO_MODE_PAL]; | 293 | timing = &timing_data[VIDEO_MODE_PAL]; |
341 | break; | 294 | break; |
342 | case VIDEO_MODE_AUTO: | 295 | case VIDEO_MODE_AUTO: |
@@ -344,10 +297,7 @@ bt819_command (struct i2c_client *client, | |||
344 | bt819_setbit(client, 0x01, 1, 0); | 297 | bt819_setbit(client, 0x01, 1, 0); |
345 | break; | 298 | break; |
346 | default: | 299 | default: |
347 | dprintk(1, | 300 | v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg); |
348 | KERN_ERR | ||
349 | "%s: unsupported norm %d\n", | ||
350 | I2C_NAME(client), *iarg); | ||
351 | return -EINVAL; | 301 | return -EINVAL; |
352 | } | 302 | } |
353 | 303 | ||
@@ -366,19 +316,17 @@ bt819_command (struct i2c_client *client, | |||
366 | } | 316 | } |
367 | 317 | ||
368 | decoder->norm = *iarg; | 318 | decoder->norm = *iarg; |
369 | } | ||
370 | break; | 319 | break; |
320 | } | ||
371 | 321 | ||
372 | case DECODER_SET_INPUT: | 322 | case DECODER_SET_INPUT: |
373 | { | 323 | { |
374 | int *iarg = arg; | 324 | int *iarg = arg; |
375 | 325 | ||
376 | dprintk(1, KERN_INFO "%s: set input %x\n", I2C_NAME(client), | 326 | v4l_dbg(1, debug, client, "set input %x\n", *iarg); |
377 | *iarg); | ||
378 | 327 | ||
379 | if (*iarg < 0 || *iarg > 7) { | 328 | if (*iarg < 0 || *iarg > 7) |
380 | return -EINVAL; | 329 | return -EINVAL; |
381 | } | ||
382 | 330 | ||
383 | if (decoder->input != *iarg) { | 331 | if (decoder->input != *iarg) { |
384 | decoder->input = *iarg; | 332 | decoder->input = *iarg; |
@@ -391,52 +339,42 @@ bt819_command (struct i2c_client *client, | |||
391 | bt819_setbit(client, 0x1a, 1, 0); | 339 | bt819_setbit(client, 0x1a, 1, 0); |
392 | } | 340 | } |
393 | } | 341 | } |
394 | } | ||
395 | break; | 342 | break; |
343 | } | ||
396 | 344 | ||
397 | case DECODER_SET_OUTPUT: | 345 | case DECODER_SET_OUTPUT: |
398 | { | 346 | { |
399 | int *iarg = arg; | 347 | int *iarg = arg; |
400 | 348 | ||
401 | dprintk(1, KERN_INFO "%s: set output %x\n", I2C_NAME(client), | 349 | v4l_dbg(1, debug, client, "set output %x\n", *iarg); |
402 | *iarg); | ||
403 | 350 | ||
404 | /* not much choice of outputs */ | 351 | /* not much choice of outputs */ |
405 | if (*iarg != 0) { | 352 | if (*iarg != 0) |
406 | return -EINVAL; | 353 | return -EINVAL; |
407 | } | ||
408 | } | ||
409 | break; | 354 | break; |
355 | } | ||
410 | 356 | ||
411 | case DECODER_ENABLE_OUTPUT: | 357 | case DECODER_ENABLE_OUTPUT: |
412 | { | 358 | { |
413 | int *iarg = arg; | 359 | int *iarg = arg; |
414 | int enable = (*iarg != 0); | 360 | int enable = (*iarg != 0); |
415 | 361 | ||
416 | dprintk(1, KERN_INFO "%s: enable output %x\n", | 362 | v4l_dbg(1, debug, client, "enable output %x\n", *iarg); |
417 | I2C_NAME(client), *iarg); | ||
418 | 363 | ||
419 | if (decoder->enable != enable) { | 364 | if (decoder->enable != enable) { |
420 | decoder->enable = enable; | 365 | decoder->enable = enable; |
421 | 366 | bt819_setbit(client, 0x16, 7, !enable); | |
422 | if (decoder->enable) { | ||
423 | bt819_setbit(client, 0x16, 7, 0); | ||
424 | } else { | ||
425 | bt819_setbit(client, 0x16, 7, 1); | ||
426 | } | ||
427 | } | 367 | } |
428 | } | ||
429 | break; | 368 | break; |
369 | } | ||
430 | 370 | ||
431 | case DECODER_SET_PICTURE: | 371 | case DECODER_SET_PICTURE: |
432 | { | 372 | { |
433 | struct video_picture *pic = arg; | 373 | struct video_picture *pic = arg; |
434 | 374 | ||
435 | dprintk(1, | 375 | v4l_dbg(1, debug, client, |
436 | KERN_INFO | 376 | "set picture brightness %d contrast %d colour %d\n", |
437 | "%s: set picture brightness %d contrast %d colour %d\n", | 377 | pic->brightness, pic->contrast, pic->colour); |
438 | I2C_NAME(client), pic->brightness, pic->contrast, | ||
439 | pic->colour); | ||
440 | 378 | ||
441 | 379 | ||
442 | if (decoder->bright != pic->brightness) { | 380 | if (decoder->bright != pic->brightness) { |
@@ -474,8 +412,8 @@ bt819_command (struct i2c_client *client, | |||
474 | bt819_write(client, 0x0f, | 412 | bt819_write(client, 0x0f, |
475 | 128 - (decoder->hue >> 8)); | 413 | 128 - (decoder->hue >> 8)); |
476 | } | 414 | } |
477 | } | ||
478 | break; | 415 | break; |
416 | } | ||
479 | 417 | ||
480 | default: | 418 | default: |
481 | return -EINVAL; | 419 | return -EINVAL; |
@@ -486,55 +424,44 @@ bt819_command (struct i2c_client *client, | |||
486 | 424 | ||
487 | /* ----------------------------------------------------------------------- */ | 425 | /* ----------------------------------------------------------------------- */ |
488 | 426 | ||
489 | /* | 427 | static unsigned short normal_i2c[] = { 0x8a >> 1, I2C_CLIENT_END }; |
490 | * Generic i2c probe | ||
491 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
492 | */ | ||
493 | static unsigned short normal_i2c[] = { | ||
494 | I2C_BT819 >> 1, | ||
495 | I2C_CLIENT_END, | ||
496 | }; | ||
497 | |||
498 | static unsigned short ignore = I2C_CLIENT_END; | ||
499 | |||
500 | static struct i2c_client_address_data addr_data = { | ||
501 | .normal_i2c = normal_i2c, | ||
502 | .probe = &ignore, | ||
503 | .ignore = &ignore, | ||
504 | }; | ||
505 | 428 | ||
506 | static struct i2c_driver i2c_driver_bt819; | 429 | I2C_CLIENT_INSMOD; |
507 | 430 | ||
508 | static int | 431 | static int bt819_probe(struct i2c_client *client, |
509 | bt819_detect_client (struct i2c_adapter *adapter, | 432 | const struct i2c_device_id *id) |
510 | int address, | ||
511 | int kind) | ||
512 | { | 433 | { |
513 | int i, id; | 434 | int i, ver; |
514 | struct bt819 *decoder; | 435 | struct bt819 *decoder; |
515 | struct i2c_client *client; | 436 | const char *name; |
516 | |||
517 | dprintk(1, | ||
518 | KERN_INFO | ||
519 | "bt819: detecting bt819 client on address 0x%x\n", | ||
520 | address << 1); | ||
521 | 437 | ||
522 | /* Check if the adapter supports the needed features */ | 438 | /* Check if the adapter supports the needed features */ |
523 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 439 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
524 | return 0; | 440 | return -ENODEV; |
525 | 441 | ||
526 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 442 | ver = bt819_read(client, 0x17); |
527 | if (!client) | 443 | switch (ver & 0xf0) { |
528 | return -ENOMEM; | 444 | case 0x70: |
529 | client->addr = address; | 445 | name = "bt819a"; |
530 | client->adapter = adapter; | 446 | break; |
531 | client->driver = &i2c_driver_bt819; | 447 | case 0x60: |
448 | name = "bt817a"; | ||
449 | break; | ||
450 | case 0x20: | ||
451 | name = "bt815a"; | ||
452 | break; | ||
453 | default: | ||
454 | v4l_dbg(1, debug, client, | ||
455 | "unknown chip version 0x%02x\n", ver); | ||
456 | return -ENODEV; | ||
457 | } | ||
458 | |||
459 | v4l_info(client, "%s found @ 0x%x (%s)\n", name, | ||
460 | client->addr << 1, client->adapter->name); | ||
532 | 461 | ||
533 | decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); | 462 | decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); |
534 | if (decoder == NULL) { | 463 | if (decoder == NULL) |
535 | kfree(client); | ||
536 | return -ENOMEM; | 464 | return -ENOMEM; |
537 | } | ||
538 | decoder->norm = VIDEO_MODE_NTSC; | 465 | decoder->norm = VIDEO_MODE_NTSC; |
539 | decoder->input = 0; | 466 | decoder->input = 0; |
540 | decoder->enable = 1; | 467 | decoder->enable = 1; |
@@ -545,97 +472,33 @@ bt819_detect_client (struct i2c_adapter *adapter, | |||
545 | decoder->initialized = 0; | 472 | decoder->initialized = 0; |
546 | i2c_set_clientdata(client, decoder); | 473 | i2c_set_clientdata(client, decoder); |
547 | 474 | ||
548 | id = bt819_read(client, 0x17); | ||
549 | switch (id & 0xf0) { | ||
550 | case 0x70: | ||
551 | strlcpy(I2C_NAME(client), "bt819a", sizeof(I2C_NAME(client))); | ||
552 | break; | ||
553 | case 0x60: | ||
554 | strlcpy(I2C_NAME(client), "bt817a", sizeof(I2C_NAME(client))); | ||
555 | break; | ||
556 | case 0x20: | ||
557 | strlcpy(I2C_NAME(client), "bt815a", sizeof(I2C_NAME(client))); | ||
558 | break; | ||
559 | default: | ||
560 | dprintk(1, | ||
561 | KERN_ERR | ||
562 | "bt819: unknown chip version 0x%x (ver 0x%x)\n", | ||
563 | id & 0xf0, id & 0x0f); | ||
564 | kfree(decoder); | ||
565 | kfree(client); | ||
566 | return 0; | ||
567 | } | ||
568 | |||
569 | i = i2c_attach_client(client); | ||
570 | if (i) { | ||
571 | kfree(client); | ||
572 | kfree(decoder); | ||
573 | return i; | ||
574 | } | ||
575 | |||
576 | i = bt819_init(client); | 475 | i = bt819_init(client); |
577 | if (i < 0) { | 476 | if (i < 0) |
578 | dprintk(1, KERN_ERR "%s_attach: init status %d\n", | 477 | v4l_dbg(1, debug, client, "init status %d\n", i); |
579 | I2C_NAME(client), i); | ||
580 | } else { | ||
581 | dprintk(1, | ||
582 | KERN_INFO | ||
583 | "%s_attach: chip version 0x%x at address 0x%x\n", | ||
584 | I2C_NAME(client), id & 0x0f, | ||
585 | client->addr << 1); | ||
586 | } | ||
587 | |||
588 | return 0; | 478 | return 0; |
589 | } | 479 | } |
590 | 480 | ||
591 | static int | 481 | static int bt819_remove(struct i2c_client *client) |
592 | bt819_attach_adapter (struct i2c_adapter *adapter) | ||
593 | { | ||
594 | return i2c_probe(adapter, &addr_data, &bt819_detect_client); | ||
595 | } | ||
596 | |||
597 | static int | ||
598 | bt819_detach_client (struct i2c_client *client) | ||
599 | { | 482 | { |
600 | struct bt819 *decoder = i2c_get_clientdata(client); | 483 | kfree(i2c_get_clientdata(client)); |
601 | int err; | ||
602 | |||
603 | err = i2c_detach_client(client); | ||
604 | if (err) { | ||
605 | return err; | ||
606 | } | ||
607 | |||
608 | kfree(decoder); | ||
609 | kfree(client); | ||
610 | |||
611 | return 0; | 484 | return 0; |
612 | } | 485 | } |
613 | 486 | ||
614 | /* ----------------------------------------------------------------------- */ | 487 | /* ----------------------------------------------------------------------- */ |
615 | 488 | ||
616 | static struct i2c_driver i2c_driver_bt819 = { | 489 | static const struct i2c_device_id bt819_id[] = { |
617 | .driver = { | 490 | { "bt819a", 0 }, |
618 | .name = "bt819", | 491 | { "bt817a", 0 }, |
619 | }, | 492 | { "bt815a", 0 }, |
620 | 493 | { } | |
621 | .id = I2C_DRIVERID_BT819, | 494 | }; |
495 | MODULE_DEVICE_TABLE(i2c, bt819_id); | ||
622 | 496 | ||
623 | .attach_adapter = bt819_attach_adapter, | 497 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
624 | .detach_client = bt819_detach_client, | 498 | .name = "bt819", |
499 | .driverid = I2C_DRIVERID_BT819, | ||
625 | .command = bt819_command, | 500 | .command = bt819_command, |
501 | .probe = bt819_probe, | ||
502 | .remove = bt819_remove, | ||
503 | .id_table = bt819_id, | ||
626 | }; | 504 | }; |
627 | |||
628 | static int __init | ||
629 | bt819_init_module (void) | ||
630 | { | ||
631 | return i2c_add_driver(&i2c_driver_bt819); | ||
632 | } | ||
633 | |||
634 | static void __exit | ||
635 | bt819_exit (void) | ||
636 | { | ||
637 | i2c_del_driver(&i2c_driver_bt819); | ||
638 | } | ||
639 | |||
640 | module_init(bt819_init_module); | ||
641 | module_exit(bt819_exit); | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index ab2ce4d7b5de..4213867507f8 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -29,43 +29,24 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <linux/errno.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/major.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mm.h> | ||
40 | #include <linux/signal.h> | ||
41 | #include <linux/types.h> | 32 | #include <linux/types.h> |
42 | #include <linux/i2c.h> | 33 | #include <linux/ioctl.h> |
43 | #include <linux/video_encoder.h> | ||
44 | #include <asm/io.h> | ||
45 | #include <asm/pgtable.h> | ||
46 | #include <asm/page.h> | ||
47 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
48 | 35 | #include <linux/i2c.h> | |
36 | #include <linux/i2c-id.h> | ||
49 | #include <linux/videodev.h> | 37 | #include <linux/videodev.h> |
38 | #include <linux/video_encoder.h> | ||
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-i2c-drv-legacy.h> | ||
50 | 41 | ||
51 | MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); | 42 | MODULE_DESCRIPTION("Brooktree-856A video encoder driver"); |
52 | MODULE_AUTHOR("Mike Bernson & Dave Perks"); | 43 | MODULE_AUTHOR("Mike Bernson & Dave Perks"); |
53 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
54 | 45 | ||
55 | |||
56 | #define I2C_NAME(s) (s)->name | ||
57 | |||
58 | |||
59 | static int debug; | 46 | static int debug; |
60 | module_param(debug, int, 0); | 47 | module_param(debug, int, 0); |
61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 48 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
62 | 49 | ||
63 | #define dprintk(num, format, args...) \ | ||
64 | do { \ | ||
65 | if (debug >= num) \ | ||
66 | printk(format, ##args); \ | ||
67 | } while (0) | ||
68 | |||
69 | /* ----------------------------------------------------------------------- */ | 50 | /* ----------------------------------------------------------------------- */ |
70 | 51 | ||
71 | #define BT856_REG_OFFSET 0xDA | 52 | #define BT856_REG_OFFSET 0xDA |
@@ -78,14 +59,9 @@ struct bt856 { | |||
78 | int enable; | 59 | int enable; |
79 | }; | 60 | }; |
80 | 61 | ||
81 | #define I2C_BT856 0x88 | ||
82 | |||
83 | /* ----------------------------------------------------------------------- */ | 62 | /* ----------------------------------------------------------------------- */ |
84 | 63 | ||
85 | static inline int | 64 | static inline int bt856_write(struct i2c_client *client, u8 reg, u8 value) |
86 | bt856_write (struct i2c_client *client, | ||
87 | u8 reg, | ||
88 | u8 value) | ||
89 | { | 65 | { |
90 | struct bt856 *encoder = i2c_get_clientdata(client); | 66 | struct bt856 *encoder = i2c_get_clientdata(client); |
91 | 67 | ||
@@ -93,46 +69,36 @@ bt856_write (struct i2c_client *client, | |||
93 | return i2c_smbus_write_byte_data(client, reg, value); | 69 | return i2c_smbus_write_byte_data(client, reg, value); |
94 | } | 70 | } |
95 | 71 | ||
96 | static inline int | 72 | static inline int bt856_setbit(struct i2c_client *client, u8 reg, u8 bit, u8 value) |
97 | bt856_setbit (struct i2c_client *client, | ||
98 | u8 reg, | ||
99 | u8 bit, | ||
100 | u8 value) | ||
101 | { | 73 | { |
102 | struct bt856 *encoder = i2c_get_clientdata(client); | 74 | struct bt856 *encoder = i2c_get_clientdata(client); |
103 | 75 | ||
104 | return bt856_write(client, reg, | 76 | return bt856_write(client, reg, |
105 | (encoder-> | 77 | (encoder->reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | |
106 | reg[reg - BT856_REG_OFFSET] & ~(1 << bit)) | | 78 | (value ? (1 << bit) : 0)); |
107 | (value ? (1 << bit) : 0)); | ||
108 | } | 79 | } |
109 | 80 | ||
110 | static void | 81 | static void bt856_dump(struct i2c_client *client) |
111 | bt856_dump (struct i2c_client *client) | ||
112 | { | 82 | { |
113 | int i; | 83 | int i; |
114 | struct bt856 *encoder = i2c_get_clientdata(client); | 84 | struct bt856 *encoder = i2c_get_clientdata(client); |
115 | 85 | ||
116 | printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); | 86 | v4l_info(client, "register dump:\n"); |
117 | for (i = 0; i < BT856_NR_REG; i += 2) | 87 | for (i = 0; i < BT856_NR_REG; i += 2) |
118 | printk(" %02x", encoder->reg[i]); | 88 | printk(KERN_CONT " %02x", encoder->reg[i]); |
119 | printk("\n"); | 89 | printk(KERN_CONT "\n"); |
120 | } | 90 | } |
121 | 91 | ||
122 | /* ----------------------------------------------------------------------- */ | 92 | /* ----------------------------------------------------------------------- */ |
123 | 93 | ||
124 | static int | 94 | static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) |
125 | bt856_command (struct i2c_client *client, | ||
126 | unsigned int cmd, | ||
127 | void *arg) | ||
128 | { | 95 | { |
129 | struct bt856 *encoder = i2c_get_clientdata(client); | 96 | struct bt856 *encoder = i2c_get_clientdata(client); |
130 | 97 | ||
131 | switch (cmd) { | 98 | switch (cmd) { |
132 | |||
133 | case 0: | 99 | case 0: |
134 | /* This is just for testing!!! */ | 100 | /* This is just for testing!!! */ |
135 | dprintk(1, KERN_INFO "bt856: init\n"); | 101 | v4l_dbg(1, debug, client, "init\n"); |
136 | bt856_write(client, 0xdc, 0x18); | 102 | bt856_write(client, 0xdc, 0x18); |
137 | bt856_write(client, 0xda, 0); | 103 | bt856_write(client, 0xda, 0); |
138 | bt856_write(client, 0xde, 0); | 104 | bt856_write(client, 0xde, 0); |
@@ -142,7 +108,6 @@ bt856_command (struct i2c_client *client, | |||
142 | bt856_setbit(client, 0xdc, 4, 1); | 108 | bt856_setbit(client, 0xdc, 4, 1); |
143 | 109 | ||
144 | switch (encoder->norm) { | 110 | switch (encoder->norm) { |
145 | |||
146 | case VIDEO_MODE_NTSC: | 111 | case VIDEO_MODE_NTSC: |
147 | bt856_setbit(client, 0xdc, 2, 0); | 112 | bt856_setbit(client, 0xdc, 2, 0); |
148 | break; | 113 | break; |
@@ -163,26 +128,23 @@ bt856_command (struct i2c_client *client, | |||
163 | { | 128 | { |
164 | struct video_encoder_capability *cap = arg; | 129 | struct video_encoder_capability *cap = arg; |
165 | 130 | ||
166 | dprintk(1, KERN_INFO "%s: get capabilities\n", | 131 | v4l_dbg(1, debug, client, "get capabilities\n"); |
167 | I2C_NAME(client)); | ||
168 | 132 | ||
169 | cap->flags = VIDEO_ENCODER_PAL | | 133 | cap->flags = VIDEO_ENCODER_PAL | |
170 | VIDEO_ENCODER_NTSC | | 134 | VIDEO_ENCODER_NTSC | |
171 | VIDEO_ENCODER_CCIR; | 135 | VIDEO_ENCODER_CCIR; |
172 | cap->inputs = 2; | 136 | cap->inputs = 2; |
173 | cap->outputs = 1; | 137 | cap->outputs = 1; |
174 | } | ||
175 | break; | 138 | break; |
139 | } | ||
176 | 140 | ||
177 | case ENCODER_SET_NORM: | 141 | case ENCODER_SET_NORM: |
178 | { | 142 | { |
179 | int *iarg = arg; | 143 | int *iarg = arg; |
180 | 144 | ||
181 | dprintk(1, KERN_INFO "%s: set norm %d\n", I2C_NAME(client), | 145 | v4l_dbg(1, debug, client, "set norm %d\n", *iarg); |
182 | *iarg); | ||
183 | 146 | ||
184 | switch (*iarg) { | 147 | switch (*iarg) { |
185 | |||
186 | case VIDEO_MODE_NTSC: | 148 | case VIDEO_MODE_NTSC: |
187 | bt856_setbit(client, 0xdc, 2, 0); | 149 | bt856_setbit(client, 0xdc, 2, 0); |
188 | break; | 150 | break; |
@@ -195,27 +157,23 @@ bt856_command (struct i2c_client *client, | |||
195 | 157 | ||
196 | default: | 158 | default: |
197 | return -EINVAL; | 159 | return -EINVAL; |
198 | |||
199 | } | 160 | } |
200 | encoder->norm = *iarg; | 161 | encoder->norm = *iarg; |
201 | if (debug != 0) | 162 | if (debug != 0) |
202 | bt856_dump(client); | 163 | bt856_dump(client); |
203 | } | ||
204 | break; | 164 | break; |
165 | } | ||
205 | 166 | ||
206 | case ENCODER_SET_INPUT: | 167 | case ENCODER_SET_INPUT: |
207 | { | 168 | { |
208 | int *iarg = arg; | 169 | int *iarg = arg; |
209 | 170 | ||
210 | dprintk(1, KERN_INFO "%s: set input %d\n", I2C_NAME(client), | 171 | v4l_dbg(1, debug, client, "set input %d\n", *iarg); |
211 | *iarg); | ||
212 | 172 | ||
213 | /* We only have video bus. | 173 | /* We only have video bus. |
214 | * iarg = 0: input is from bt819 | 174 | * iarg = 0: input is from bt819 |
215 | * iarg = 1: input is from ZR36060 */ | 175 | * iarg = 1: input is from ZR36060 */ |
216 | |||
217 | switch (*iarg) { | 176 | switch (*iarg) { |
218 | |||
219 | case 0: | 177 | case 0: |
220 | bt856_setbit(client, 0xde, 4, 0); | 178 | bt856_setbit(client, 0xde, 4, 0); |
221 | bt856_setbit(client, 0xde, 3, 1); | 179 | bt856_setbit(client, 0xde, 3, 1); |
@@ -234,27 +192,24 @@ bt856_command (struct i2c_client *client, | |||
234 | break; | 192 | break; |
235 | default: | 193 | default: |
236 | return -EINVAL; | 194 | return -EINVAL; |
237 | |||
238 | } | 195 | } |
239 | 196 | ||
240 | if (debug != 0) | 197 | if (debug != 0) |
241 | bt856_dump(client); | 198 | bt856_dump(client); |
242 | } | ||
243 | break; | 199 | break; |
200 | } | ||
244 | 201 | ||
245 | case ENCODER_SET_OUTPUT: | 202 | case ENCODER_SET_OUTPUT: |
246 | { | 203 | { |
247 | int *iarg = arg; | 204 | int *iarg = arg; |
248 | 205 | ||
249 | dprintk(1, KERN_INFO "%s: set output %d\n", I2C_NAME(client), | 206 | v4l_dbg(1, debug, client, "set output %d\n", *iarg); |
250 | *iarg); | ||
251 | 207 | ||
252 | /* not much choice of outputs */ | 208 | /* not much choice of outputs */ |
253 | if (*iarg != 0) { | 209 | if (*iarg != 0) |
254 | return -EINVAL; | 210 | return -EINVAL; |
255 | } | ||
256 | } | ||
257 | break; | 211 | break; |
212 | } | ||
258 | 213 | ||
259 | case ENCODER_ENABLE_OUTPUT: | 214 | case ENCODER_ENABLE_OUTPUT: |
260 | { | 215 | { |
@@ -262,10 +217,9 @@ bt856_command (struct i2c_client *client, | |||
262 | 217 | ||
263 | encoder->enable = !!*iarg; | 218 | encoder->enable = !!*iarg; |
264 | 219 | ||
265 | dprintk(1, KERN_INFO "%s: enable output %d\n", | 220 | v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); |
266 | I2C_NAME(client), encoder->enable); | ||
267 | } | ||
268 | break; | 221 | break; |
222 | } | ||
269 | 223 | ||
270 | default: | 224 | default: |
271 | return -EINVAL; | 225 | return -EINVAL; |
@@ -276,64 +230,29 @@ bt856_command (struct i2c_client *client, | |||
276 | 230 | ||
277 | /* ----------------------------------------------------------------------- */ | 231 | /* ----------------------------------------------------------------------- */ |
278 | 232 | ||
279 | /* | 233 | static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; |
280 | * Generic i2c probe | ||
281 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
282 | */ | ||
283 | static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; | ||
284 | |||
285 | static unsigned short ignore = I2C_CLIENT_END; | ||
286 | |||
287 | static struct i2c_client_address_data addr_data = { | ||
288 | .normal_i2c = normal_i2c, | ||
289 | .probe = &ignore, | ||
290 | .ignore = &ignore, | ||
291 | }; | ||
292 | 234 | ||
293 | static struct i2c_driver i2c_driver_bt856; | 235 | I2C_CLIENT_INSMOD; |
294 | 236 | ||
295 | static int | 237 | static int bt856_probe(struct i2c_client *client, |
296 | bt856_detect_client (struct i2c_adapter *adapter, | 238 | const struct i2c_device_id *id) |
297 | int address, | ||
298 | int kind) | ||
299 | { | 239 | { |
300 | int i; | ||
301 | struct i2c_client *client; | ||
302 | struct bt856 *encoder; | 240 | struct bt856 *encoder; |
303 | 241 | ||
304 | dprintk(1, | ||
305 | KERN_INFO | ||
306 | "bt856.c: detecting bt856 client on address 0x%x\n", | ||
307 | address << 1); | ||
308 | |||
309 | /* Check if the adapter supports the needed features */ | 242 | /* Check if the adapter supports the needed features */ |
310 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 243 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
311 | return 0; | 244 | return -ENODEV; |
312 | 245 | ||
313 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 246 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
314 | if (!client) | 247 | client->addr << 1, client->adapter->name); |
315 | return -ENOMEM; | ||
316 | client->addr = address; | ||
317 | client->adapter = adapter; | ||
318 | client->driver = &i2c_driver_bt856; | ||
319 | strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client))); | ||
320 | 248 | ||
321 | encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); | 249 | encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); |
322 | if (encoder == NULL) { | 250 | if (encoder == NULL) |
323 | kfree(client); | ||
324 | return -ENOMEM; | 251 | return -ENOMEM; |
325 | } | ||
326 | encoder->norm = VIDEO_MODE_NTSC; | 252 | encoder->norm = VIDEO_MODE_NTSC; |
327 | encoder->enable = 1; | 253 | encoder->enable = 1; |
328 | i2c_set_clientdata(client, encoder); | 254 | i2c_set_clientdata(client, encoder); |
329 | 255 | ||
330 | i = i2c_attach_client(client); | ||
331 | if (i) { | ||
332 | kfree(client); | ||
333 | kfree(encoder); | ||
334 | return i; | ||
335 | } | ||
336 | |||
337 | bt856_write(client, 0xdc, 0x18); | 256 | bt856_write(client, 0xdc, 0x18); |
338 | bt856_write(client, 0xda, 0); | 257 | bt856_write(client, 0xda, 0); |
339 | bt856_write(client, 0xde, 0); | 258 | bt856_write(client, 0xde, 0); |
@@ -359,65 +278,26 @@ bt856_detect_client (struct i2c_adapter *adapter, | |||
359 | 278 | ||
360 | if (debug != 0) | 279 | if (debug != 0) |
361 | bt856_dump(client); | 280 | bt856_dump(client); |
362 | |||
363 | dprintk(1, KERN_INFO "%s_attach: at address 0x%x\n", I2C_NAME(client), | ||
364 | client->addr << 1); | ||
365 | |||
366 | return 0; | 281 | return 0; |
367 | } | 282 | } |
368 | 283 | ||
369 | static int | 284 | static int bt856_remove(struct i2c_client *client) |
370 | bt856_attach_adapter (struct i2c_adapter *adapter) | ||
371 | { | 285 | { |
372 | dprintk(1, | 286 | kfree(i2c_get_clientdata(client)); |
373 | KERN_INFO | ||
374 | "bt856.c: starting probe for adapter %s (0x%x)\n", | ||
375 | I2C_NAME(adapter), adapter->id); | ||
376 | return i2c_probe(adapter, &addr_data, &bt856_detect_client); | ||
377 | } | ||
378 | |||
379 | static int | ||
380 | bt856_detach_client (struct i2c_client *client) | ||
381 | { | ||
382 | struct bt856 *encoder = i2c_get_clientdata(client); | ||
383 | int err; | ||
384 | |||
385 | err = i2c_detach_client(client); | ||
386 | if (err) { | ||
387 | return err; | ||
388 | } | ||
389 | |||
390 | kfree(encoder); | ||
391 | kfree(client); | ||
392 | |||
393 | return 0; | 287 | return 0; |
394 | } | 288 | } |
395 | 289 | ||
396 | /* ----------------------------------------------------------------------- */ | 290 | static const struct i2c_device_id bt856_id[] = { |
397 | 291 | { "bt856", 0 }, | |
398 | static struct i2c_driver i2c_driver_bt856 = { | 292 | { } |
399 | .driver = { | 293 | }; |
400 | .name = "bt856", | 294 | MODULE_DEVICE_TABLE(i2c, bt856_id); |
401 | }, | ||
402 | |||
403 | .id = I2C_DRIVERID_BT856, | ||
404 | 295 | ||
405 | .attach_adapter = bt856_attach_adapter, | 296 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
406 | .detach_client = bt856_detach_client, | 297 | .name = "bt856", |
298 | .driverid = I2C_DRIVERID_BT856, | ||
407 | .command = bt856_command, | 299 | .command = bt856_command, |
300 | .probe = bt856_probe, | ||
301 | .remove = bt856_remove, | ||
302 | .id_table = bt856_id, | ||
408 | }; | 303 | }; |
409 | |||
410 | static int __init | ||
411 | bt856_init (void) | ||
412 | { | ||
413 | return i2c_add_driver(&i2c_driver_bt856); | ||
414 | } | ||
415 | |||
416 | static void __exit | ||
417 | bt856_exit (void) | ||
418 | { | ||
419 | i2c_del_driver(&i2c_driver_bt856); | ||
420 | } | ||
421 | |||
422 | module_init(bt856_init); | ||
423 | module_exit(bt856_exit); | ||
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c index 96b415576f0d..596f9e2376be 100644 --- a/drivers/media/video/bt866.c +++ b/drivers/media/video/bt866.c | |||
@@ -29,42 +29,28 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <linux/errno.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/major.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mm.h> | ||
40 | #include <linux/signal.h> | ||
41 | #include <asm/io.h> | ||
42 | #include <asm/pgtable.h> | ||
43 | #include <asm/page.h> | ||
44 | #include <linux/sched.h> | ||
45 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/ioctl.h> | ||
34 | #include <asm/uaccess.h> | ||
46 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
47 | 36 | #include <linux/i2c-id.h> | |
48 | #include <linux/videodev.h> | 37 | #include <linux/videodev.h> |
49 | #include <asm/uaccess.h> | ||
50 | |||
51 | #include <linux/video_encoder.h> | 38 | #include <linux/video_encoder.h> |
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-i2c-drv-legacy.h> | ||
52 | 41 | ||
42 | MODULE_DESCRIPTION("Brooktree-866 video encoder driver"); | ||
43 | MODULE_AUTHOR("Mike Bernson & Dave Perks"); | ||
53 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
54 | 45 | ||
55 | #define BT866_DEVNAME "bt866" | 46 | static int debug; |
56 | #define I2C_BT866 0x88 | 47 | module_param(debug, int, 0); |
57 | 48 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |
58 | MODULE_LICENSE("GPL"); | ||
59 | |||
60 | #define DEBUG(x) /* Debug driver */ | ||
61 | 49 | ||
62 | /* ----------------------------------------------------------------------- */ | 50 | /* ----------------------------------------------------------------------- */ |
63 | 51 | ||
64 | struct bt866 { | 52 | struct bt866 { |
65 | struct i2c_client *i2c; | 53 | u8 reg[256]; |
66 | int addr; | ||
67 | unsigned char reg[256]; | ||
68 | 54 | ||
69 | int norm; | 55 | int norm; |
70 | int enable; | 56 | int enable; |
@@ -74,20 +60,45 @@ struct bt866 { | |||
74 | int sat; | 60 | int sat; |
75 | }; | 61 | }; |
76 | 62 | ||
77 | static int bt866_write(struct bt866 *dev, | 63 | static int bt866_write(struct i2c_client *client, u8 subaddr, u8 data) |
78 | unsigned char subaddr, unsigned char data); | 64 | { |
65 | struct bt866 *encoder = i2c_get_clientdata(client); | ||
66 | u8 buffer[2]; | ||
67 | int err; | ||
68 | |||
69 | buffer[0] = subaddr; | ||
70 | buffer[1] = data; | ||
71 | |||
72 | encoder->reg[subaddr] = data; | ||
73 | |||
74 | v4l_dbg(1, debug, client, "write 0x%02x = 0x%02x\n", subaddr, data); | ||
75 | |||
76 | for (err = 0; err < 3;) { | ||
77 | if (i2c_master_send(client, buffer, 2) == 2) | ||
78 | break; | ||
79 | err++; | ||
80 | v4l_warn(client, "error #%d writing to 0x%02x\n", | ||
81 | err, subaddr); | ||
82 | schedule_timeout_interruptible(msecs_to_jiffies(100)); | ||
83 | } | ||
84 | if (err == 3) { | ||
85 | v4l_warn(client, "giving up\n"); | ||
86 | return -1; | ||
87 | } | ||
88 | |||
89 | return 0; | ||
90 | } | ||
79 | 91 | ||
80 | static int bt866_do_command(struct bt866 *encoder, | 92 | static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) |
81 | unsigned int cmd, void *arg) | ||
82 | { | 93 | { |
94 | struct bt866 *encoder = i2c_get_clientdata(client); | ||
95 | |||
83 | switch (cmd) { | 96 | switch (cmd) { |
84 | case ENCODER_GET_CAPABILITIES: | 97 | case ENCODER_GET_CAPABILITIES: |
85 | { | 98 | { |
86 | struct video_encoder_capability *cap = arg; | 99 | struct video_encoder_capability *cap = arg; |
87 | 100 | ||
88 | DEBUG(printk | 101 | v4l_dbg(1, debug, client, "get capabilities\n"); |
89 | (KERN_INFO "%s: get capabilities\n", | ||
90 | encoder->i2c->name)); | ||
91 | 102 | ||
92 | cap->flags | 103 | cap->flags |
93 | = VIDEO_ENCODER_PAL | 104 | = VIDEO_ENCODER_PAL |
@@ -95,18 +106,16 @@ static int bt866_do_command(struct bt866 *encoder, | |||
95 | | VIDEO_ENCODER_CCIR; | 106 | | VIDEO_ENCODER_CCIR; |
96 | cap->inputs = 2; | 107 | cap->inputs = 2; |
97 | cap->outputs = 1; | 108 | cap->outputs = 1; |
109 | break; | ||
98 | } | 110 | } |
99 | break; | ||
100 | 111 | ||
101 | case ENCODER_SET_NORM: | 112 | case ENCODER_SET_NORM: |
102 | { | 113 | { |
103 | int *iarg = arg; | 114 | int *iarg = arg; |
104 | 115 | ||
105 | DEBUG(printk(KERN_INFO "%s: set norm %d\n", | 116 | v4l_dbg(1, debug, client, "set norm %d\n", *iarg); |
106 | encoder->i2c->name, *iarg)); | ||
107 | 117 | ||
108 | switch (*iarg) { | 118 | switch (*iarg) { |
109 | |||
110 | case VIDEO_MODE_NTSC: | 119 | case VIDEO_MODE_NTSC: |
111 | break; | 120 | break; |
112 | 121 | ||
@@ -115,11 +124,10 @@ static int bt866_do_command(struct bt866 *encoder, | |||
115 | 124 | ||
116 | default: | 125 | default: |
117 | return -EINVAL; | 126 | return -EINVAL; |
118 | |||
119 | } | 127 | } |
120 | encoder->norm = *iarg; | 128 | encoder->norm = *iarg; |
129 | break; | ||
121 | } | 130 | } |
122 | break; | ||
123 | 131 | ||
124 | case ENCODER_SET_INPUT: | 132 | case ENCODER_SET_INPUT: |
125 | { | 133 | { |
@@ -155,7 +163,7 @@ static int bt866_do_command(struct bt866 *encoder, | |||
155 | u8 val; | 163 | u8 val; |
156 | 164 | ||
157 | for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2) | 165 | for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2) |
158 | bt866_write(encoder, init[i], init[i+1]); | 166 | bt866_write(client, init[i], init[i+1]); |
159 | 167 | ||
160 | val = encoder->reg[0xdc]; | 168 | val = encoder->reg[0xdc]; |
161 | 169 | ||
@@ -164,17 +172,16 @@ static int bt866_do_command(struct bt866 *encoder, | |||
164 | else | 172 | else |
165 | val &= ~0x40; /* !CBSWAP */ | 173 | val &= ~0x40; /* !CBSWAP */ |
166 | 174 | ||
167 | bt866_write(encoder, 0xdc, val); | 175 | bt866_write(client, 0xdc, val); |
168 | 176 | ||
169 | val = encoder->reg[0xcc]; | 177 | val = encoder->reg[0xcc]; |
170 | if (*iarg == 2) | 178 | if (*iarg == 2) |
171 | val |= 0x01; /* OSDBAR */ | 179 | val |= 0x01; /* OSDBAR */ |
172 | else | 180 | else |
173 | val &= ~0x01; /* !OSDBAR */ | 181 | val &= ~0x01; /* !OSDBAR */ |
174 | bt866_write(encoder, 0xcc, val); | 182 | bt866_write(client, 0xcc, val); |
175 | 183 | ||
176 | DEBUG(printk(KERN_INFO "%s: set input %d\n", | 184 | v4l_dbg(1, debug, client, "set input %d\n", *iarg); |
177 | encoder->i2c->name, *iarg)); | ||
178 | 185 | ||
179 | switch (*iarg) { | 186 | switch (*iarg) { |
180 | case 0: | 187 | case 0: |
@@ -183,48 +190,44 @@ static int bt866_do_command(struct bt866 *encoder, | |||
183 | break; | 190 | break; |
184 | default: | 191 | default: |
185 | return -EINVAL; | 192 | return -EINVAL; |
186 | |||
187 | } | 193 | } |
194 | break; | ||
188 | } | 195 | } |
189 | break; | ||
190 | 196 | ||
191 | case ENCODER_SET_OUTPUT: | 197 | case ENCODER_SET_OUTPUT: |
192 | { | 198 | { |
193 | int *iarg = arg; | 199 | int *iarg = arg; |
194 | 200 | ||
195 | DEBUG(printk(KERN_INFO "%s: set output %d\n", | 201 | v4l_dbg(1, debug, client, "set output %d\n", *iarg); |
196 | encoder->i2c->name, *iarg)); | ||
197 | 202 | ||
198 | /* not much choice of outputs */ | 203 | /* not much choice of outputs */ |
199 | if (*iarg != 0) | 204 | if (*iarg != 0) |
200 | return -EINVAL; | 205 | return -EINVAL; |
206 | break; | ||
201 | } | 207 | } |
202 | break; | ||
203 | 208 | ||
204 | case ENCODER_ENABLE_OUTPUT: | 209 | case ENCODER_ENABLE_OUTPUT: |
205 | { | 210 | { |
206 | int *iarg = arg; | 211 | int *iarg = arg; |
207 | encoder->enable = !!*iarg; | 212 | encoder->enable = !!*iarg; |
208 | 213 | ||
209 | DEBUG(printk | 214 | v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); |
210 | (KERN_INFO "%s: enable output %d\n", | 215 | break; |
211 | encoder->i2c->name, encoder->enable)); | ||
212 | } | 216 | } |
213 | break; | ||
214 | 217 | ||
215 | case 4711: | 218 | case 4711: |
216 | { | 219 | { |
217 | int *iarg = arg; | 220 | int *iarg = arg; |
218 | __u8 val; | 221 | __u8 val; |
219 | 222 | ||
220 | printk("bt866: square = %d\n", *iarg); | 223 | v4l_dbg(1, debug, client, "square %d\n", *iarg); |
221 | 224 | ||
222 | val = encoder->reg[0xdc]; | 225 | val = encoder->reg[0xdc]; |
223 | if (*iarg) | 226 | if (*iarg) |
224 | val |= 1; /* SQUARE */ | 227 | val |= 1; /* SQUARE */ |
225 | else | 228 | else |
226 | val &= ~1; /* !SQUARE */ | 229 | val &= ~1; /* !SQUARE */ |
227 | bt866_write(encoder, 0xdc, val); | 230 | bt866_write(client, 0xdc, val); |
228 | break; | 231 | break; |
229 | } | 232 | } |
230 | 233 | ||
@@ -235,141 +238,49 @@ static int bt866_do_command(struct bt866 *encoder, | |||
235 | return 0; | 238 | return 0; |
236 | } | 239 | } |
237 | 240 | ||
238 | static int bt866_write(struct bt866 *encoder, | 241 | static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; |
239 | unsigned char subaddr, unsigned char data) | ||
240 | { | ||
241 | unsigned char buffer[2]; | ||
242 | int err; | ||
243 | 242 | ||
244 | buffer[0] = subaddr; | 243 | I2C_CLIENT_INSMOD; |
245 | buffer[1] = data; | ||
246 | |||
247 | encoder->reg[subaddr] = data; | ||
248 | 244 | ||
249 | DEBUG(printk | 245 | static int bt866_probe(struct i2c_client *client, |
250 | ("%s: write 0x%02X = 0x%02X\n", | 246 | const struct i2c_device_id *id) |
251 | encoder->i2c->name, subaddr, data)); | ||
252 | |||
253 | for (err = 0; err < 3;) { | ||
254 | if (i2c_master_send(encoder->i2c, buffer, 2) == 2) | ||
255 | break; | ||
256 | err++; | ||
257 | printk(KERN_WARNING "%s: I/O error #%d " | ||
258 | "(write 0x%02x/0x%02x)\n", | ||
259 | encoder->i2c->name, err, encoder->addr, subaddr); | ||
260 | schedule_timeout_interruptible(msecs_to_jiffies(100)); | ||
261 | } | ||
262 | if (err == 3) { | ||
263 | printk(KERN_WARNING "%s: giving up\n", | ||
264 | encoder->i2c->name); | ||
265 | return -1; | ||
266 | } | ||
267 | |||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | static int bt866_attach(struct i2c_adapter *adapter); | ||
272 | static int bt866_detach(struct i2c_client *client); | ||
273 | static int bt866_command(struct i2c_client *client, | ||
274 | unsigned int cmd, void *arg); | ||
275 | |||
276 | |||
277 | /* Addresses to scan */ | ||
278 | static unsigned short normal_i2c[] = {I2C_BT866>>1, I2C_CLIENT_END}; | ||
279 | static unsigned short probe[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; | ||
280 | static unsigned short ignore[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; | ||
281 | |||
282 | static struct i2c_client_address_data addr_data = { | ||
283 | normal_i2c, | ||
284 | probe, | ||
285 | ignore, | ||
286 | }; | ||
287 | |||
288 | static struct i2c_driver i2c_driver_bt866 = { | ||
289 | .driver.name = BT866_DEVNAME, | ||
290 | .id = I2C_DRIVERID_BT866, | ||
291 | .attach_adapter = bt866_attach, | ||
292 | .detach_client = bt866_detach, | ||
293 | .command = bt866_command | ||
294 | }; | ||
295 | |||
296 | |||
297 | static struct i2c_client bt866_client_tmpl = | ||
298 | { | ||
299 | .name = "(nil)", | ||
300 | .addr = 0, | ||
301 | .adapter = NULL, | ||
302 | .driver = &i2c_driver_bt866, | ||
303 | }; | ||
304 | |||
305 | static int bt866_found_proc(struct i2c_adapter *adapter, | ||
306 | int addr, int kind) | ||
307 | { | 247 | { |
308 | struct bt866 *encoder; | 248 | struct bt866 *encoder; |
309 | struct i2c_client *client; | ||
310 | 249 | ||
311 | client = kzalloc(sizeof(*client), GFP_KERNEL); | 250 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
312 | if (client == NULL) | 251 | client->addr << 1, client->adapter->name); |
313 | return -ENOMEM; | ||
314 | memcpy(client, &bt866_client_tmpl, sizeof(*client)); | ||
315 | 252 | ||
316 | encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); | 253 | encoder = kzalloc(sizeof(*encoder), GFP_KERNEL); |
317 | if (encoder == NULL) { | 254 | if (encoder == NULL) |
318 | kfree(client); | ||
319 | return -ENOMEM; | 255 | return -ENOMEM; |
320 | } | ||
321 | 256 | ||
322 | i2c_set_clientdata(client, encoder); | 257 | i2c_set_clientdata(client, encoder); |
323 | client->adapter = adapter; | ||
324 | client->addr = addr; | ||
325 | sprintf(client->name, "%s-%02x", BT866_DEVNAME, adapter->id); | ||
326 | |||
327 | encoder->i2c = client; | ||
328 | encoder->addr = addr; | ||
329 | //encoder->encoder_type = ENCODER_TYPE_UNKNOWN; | ||
330 | |||
331 | /* initialize */ | ||
332 | |||
333 | i2c_attach_client(client); | ||
334 | |||
335 | return 0; | ||
336 | } | ||
337 | |||
338 | static int bt866_attach(struct i2c_adapter *adapter) | ||
339 | { | ||
340 | if (adapter->id == I2C_HW_B_ZR36067) | ||
341 | return i2c_probe(adapter, &addr_data, bt866_found_proc); | ||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static int bt866_detach(struct i2c_client *client) | ||
346 | { | ||
347 | struct bt866 *encoder = i2c_get_clientdata(client); | ||
348 | |||
349 | i2c_detach_client(client); | ||
350 | kfree(encoder); | ||
351 | kfree(client); | ||
352 | |||
353 | return 0; | 258 | return 0; |
354 | } | 259 | } |
355 | 260 | ||
356 | static int bt866_command(struct i2c_client *client, | 261 | static int bt866_remove(struct i2c_client *client) |
357 | unsigned int cmd, void *arg) | ||
358 | { | 262 | { |
359 | struct bt866 *encoder = i2c_get_clientdata(client); | 263 | kfree(i2c_get_clientdata(client)); |
360 | return bt866_do_command(encoder, cmd, arg); | ||
361 | } | ||
362 | |||
363 | static int __devinit bt866_init(void) | ||
364 | { | ||
365 | i2c_add_driver(&i2c_driver_bt866); | ||
366 | return 0; | 264 | return 0; |
367 | } | 265 | } |
368 | 266 | ||
369 | static void __devexit bt866_exit(void) | 267 | static int bt866_legacy_probe(struct i2c_adapter *adapter) |
370 | { | 268 | { |
371 | i2c_del_driver(&i2c_driver_bt866); | 269 | return adapter->id == I2C_HW_B_ZR36067; |
372 | } | 270 | } |
373 | 271 | ||
374 | module_init(bt866_init); | 272 | static const struct i2c_device_id bt866_id[] = { |
375 | module_exit(bt866_exit); | 273 | { "bt866", 0 }, |
274 | { } | ||
275 | }; | ||
276 | MODULE_DEVICE_TABLE(i2c, bt866_id); | ||
277 | |||
278 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | ||
279 | .name = "bt866", | ||
280 | .driverid = I2C_DRIVERID_BT866, | ||
281 | .command = bt866_command, | ||
282 | .probe = bt866_probe, | ||
283 | .remove = bt866_remove, | ||
284 | .legacy_probe = bt866_legacy_probe, | ||
285 | .id_table = bt866_id, | ||
286 | }; | ||
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c index 2cda15f829fd..dac5ccc9ba72 100644 --- a/drivers/media/video/cx23885/cx23885-cards.c +++ b/drivers/media/video/cx23885/cx23885-cards.c | |||
@@ -39,16 +39,16 @@ struct cx23885_board cx23885_boards[] = { | |||
39 | .input = {{ | 39 | .input = {{ |
40 | .type = CX23885_VMUX_COMPOSITE1, | 40 | .type = CX23885_VMUX_COMPOSITE1, |
41 | .vmux = 0, | 41 | .vmux = 0, |
42 | },{ | 42 | }, { |
43 | .type = CX23885_VMUX_COMPOSITE2, | 43 | .type = CX23885_VMUX_COMPOSITE2, |
44 | .vmux = 1, | 44 | .vmux = 1, |
45 | },{ | 45 | }, { |
46 | .type = CX23885_VMUX_COMPOSITE3, | 46 | .type = CX23885_VMUX_COMPOSITE3, |
47 | .vmux = 2, | 47 | .vmux = 2, |
48 | },{ | 48 | }, { |
49 | .type = CX23885_VMUX_COMPOSITE4, | 49 | .type = CX23885_VMUX_COMPOSITE4, |
50 | .vmux = 3, | 50 | .vmux = 3, |
51 | }}, | 51 | } }, |
52 | }, | 52 | }, |
53 | [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = { | 53 | [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = { |
54 | .name = "Hauppauge WinTV-HVR1800lp", | 54 | .name = "Hauppauge WinTV-HVR1800lp", |
@@ -57,19 +57,19 @@ struct cx23885_board cx23885_boards[] = { | |||
57 | .type = CX23885_VMUX_TELEVISION, | 57 | .type = CX23885_VMUX_TELEVISION, |
58 | .vmux = 0, | 58 | .vmux = 0, |
59 | .gpio0 = 0xff00, | 59 | .gpio0 = 0xff00, |
60 | },{ | 60 | }, { |
61 | .type = CX23885_VMUX_DEBUG, | 61 | .type = CX23885_VMUX_DEBUG, |
62 | .vmux = 0, | 62 | .vmux = 0, |
63 | .gpio0 = 0xff01, | 63 | .gpio0 = 0xff01, |
64 | },{ | 64 | }, { |
65 | .type = CX23885_VMUX_COMPOSITE1, | 65 | .type = CX23885_VMUX_COMPOSITE1, |
66 | .vmux = 1, | 66 | .vmux = 1, |
67 | .gpio0 = 0xff02, | 67 | .gpio0 = 0xff02, |
68 | },{ | 68 | }, { |
69 | .type = CX23885_VMUX_SVIDEO, | 69 | .type = CX23885_VMUX_SVIDEO, |
70 | .vmux = 2, | 70 | .vmux = 2, |
71 | .gpio0 = 0xff02, | 71 | .gpio0 = 0xff02, |
72 | }}, | 72 | } }, |
73 | }, | 73 | }, |
74 | [CX23885_BOARD_HAUPPAUGE_HVR1800] = { | 74 | [CX23885_BOARD_HAUPPAUGE_HVR1800] = { |
75 | .name = "Hauppauge WinTV-HVR1800", | 75 | .name = "Hauppauge WinTV-HVR1800", |
@@ -84,20 +84,20 @@ struct cx23885_board cx23885_boards[] = { | |||
84 | CX25840_VIN5_CH2 | | 84 | CX25840_VIN5_CH2 | |
85 | CX25840_VIN2_CH1, | 85 | CX25840_VIN2_CH1, |
86 | .gpio0 = 0, | 86 | .gpio0 = 0, |
87 | },{ | 87 | }, { |
88 | .type = CX23885_VMUX_COMPOSITE1, | 88 | .type = CX23885_VMUX_COMPOSITE1, |
89 | .vmux = CX25840_VIN7_CH3 | | 89 | .vmux = CX25840_VIN7_CH3 | |
90 | CX25840_VIN4_CH2 | | 90 | CX25840_VIN4_CH2 | |
91 | CX25840_VIN6_CH1, | 91 | CX25840_VIN6_CH1, |
92 | .gpio0 = 0, | 92 | .gpio0 = 0, |
93 | },{ | 93 | }, { |
94 | .type = CX23885_VMUX_SVIDEO, | 94 | .type = CX23885_VMUX_SVIDEO, |
95 | .vmux = CX25840_VIN7_CH3 | | 95 | .vmux = CX25840_VIN7_CH3 | |
96 | CX25840_VIN4_CH2 | | 96 | CX25840_VIN4_CH2 | |
97 | CX25840_VIN8_CH1 | | 97 | CX25840_VIN8_CH1 | |
98 | CX25840_SVIDEO_ON, | 98 | CX25840_SVIDEO_ON, |
99 | .gpio0 = 0, | 99 | .gpio0 = 0, |
100 | }}, | 100 | } }, |
101 | }, | 101 | }, |
102 | [CX23885_BOARD_HAUPPAUGE_HVR1250] = { | 102 | [CX23885_BOARD_HAUPPAUGE_HVR1250] = { |
103 | .name = "Hauppauge WinTV-HVR1250", | 103 | .name = "Hauppauge WinTV-HVR1250", |
@@ -106,19 +106,19 @@ struct cx23885_board cx23885_boards[] = { | |||
106 | .type = CX23885_VMUX_TELEVISION, | 106 | .type = CX23885_VMUX_TELEVISION, |
107 | .vmux = 0, | 107 | .vmux = 0, |
108 | .gpio0 = 0xff00, | 108 | .gpio0 = 0xff00, |
109 | },{ | 109 | }, { |
110 | .type = CX23885_VMUX_DEBUG, | 110 | .type = CX23885_VMUX_DEBUG, |
111 | .vmux = 0, | 111 | .vmux = 0, |
112 | .gpio0 = 0xff01, | 112 | .gpio0 = 0xff01, |
113 | },{ | 113 | }, { |
114 | .type = CX23885_VMUX_COMPOSITE1, | 114 | .type = CX23885_VMUX_COMPOSITE1, |
115 | .vmux = 1, | 115 | .vmux = 1, |
116 | .gpio0 = 0xff02, | 116 | .gpio0 = 0xff02, |
117 | },{ | 117 | }, { |
118 | .type = CX23885_VMUX_SVIDEO, | 118 | .type = CX23885_VMUX_SVIDEO, |
119 | .vmux = 2, | 119 | .vmux = 2, |
120 | .gpio0 = 0xff02, | 120 | .gpio0 = 0xff02, |
121 | }}, | 121 | } }, |
122 | }, | 122 | }, |
123 | [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = { | 123 | [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = { |
124 | .name = "DViCO FusionHDTV5 Express", | 124 | .name = "DViCO FusionHDTV5 Express", |
@@ -169,43 +169,43 @@ struct cx23885_subid cx23885_subids[] = { | |||
169 | .subvendor = 0x0070, | 169 | .subvendor = 0x0070, |
170 | .subdevice = 0x3400, | 170 | .subdevice = 0x3400, |
171 | .card = CX23885_BOARD_UNKNOWN, | 171 | .card = CX23885_BOARD_UNKNOWN, |
172 | },{ | 172 | }, { |
173 | .subvendor = 0x0070, | 173 | .subvendor = 0x0070, |
174 | .subdevice = 0x7600, | 174 | .subdevice = 0x7600, |
175 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp, | 175 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800lp, |
176 | },{ | 176 | }, { |
177 | .subvendor = 0x0070, | 177 | .subvendor = 0x0070, |
178 | .subdevice = 0x7800, | 178 | .subdevice = 0x7800, |
179 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, | 179 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, |
180 | },{ | 180 | }, { |
181 | .subvendor = 0x0070, | 181 | .subvendor = 0x0070, |
182 | .subdevice = 0x7801, | 182 | .subdevice = 0x7801, |
183 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, | 183 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, |
184 | },{ | 184 | }, { |
185 | .subvendor = 0x0070, | 185 | .subvendor = 0x0070, |
186 | .subdevice = 0x7809, | 186 | .subdevice = 0x7809, |
187 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, | 187 | .card = CX23885_BOARD_HAUPPAUGE_HVR1800, |
188 | },{ | 188 | }, { |
189 | .subvendor = 0x0070, | 189 | .subvendor = 0x0070, |
190 | .subdevice = 0x7911, | 190 | .subdevice = 0x7911, |
191 | .card = CX23885_BOARD_HAUPPAUGE_HVR1250, | 191 | .card = CX23885_BOARD_HAUPPAUGE_HVR1250, |
192 | },{ | 192 | }, { |
193 | .subvendor = 0x18ac, | 193 | .subvendor = 0x18ac, |
194 | .subdevice = 0xd500, | 194 | .subdevice = 0xd500, |
195 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP, | 195 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP, |
196 | },{ | 196 | }, { |
197 | .subvendor = 0x0070, | 197 | .subvendor = 0x0070, |
198 | .subdevice = 0x7790, | 198 | .subdevice = 0x7790, |
199 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, | 199 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, |
200 | },{ | 200 | }, { |
201 | .subvendor = 0x0070, | 201 | .subvendor = 0x0070, |
202 | .subdevice = 0x7797, | 202 | .subdevice = 0x7797, |
203 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, | 203 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500Q, |
204 | },{ | 204 | }, { |
205 | .subvendor = 0x0070, | 205 | .subvendor = 0x0070, |
206 | .subdevice = 0x7710, | 206 | .subdevice = 0x7710, |
207 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, | 207 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, |
208 | },{ | 208 | }, { |
209 | .subvendor = 0x0070, | 209 | .subvendor = 0x0070, |
210 | .subdevice = 0x7717, | 210 | .subdevice = 0x7717, |
211 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, | 211 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, |
@@ -225,11 +225,11 @@ struct cx23885_subid cx23885_subids[] = { | |||
225 | .subvendor = 0x0070, | 225 | .subvendor = 0x0070, |
226 | .subdevice = 0x8010, | 226 | .subdevice = 0x8010, |
227 | .card = CX23885_BOARD_HAUPPAUGE_HVR1400, | 227 | .card = CX23885_BOARD_HAUPPAUGE_HVR1400, |
228 | },{ | 228 | }, { |
229 | .subvendor = 0x18ac, | 229 | .subvendor = 0x18ac, |
230 | .subdevice = 0xd618, | 230 | .subdevice = 0xd618, |
231 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP, | 231 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP, |
232 | },{ | 232 | }, { |
233 | .subvendor = 0x18ac, | 233 | .subvendor = 0x18ac, |
234 | .subdevice = 0xdb78, | 234 | .subdevice = 0xdb78, |
235 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP, | 235 | .card = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP, |
@@ -247,23 +247,25 @@ void cx23885_card_list(struct cx23885_dev *dev) | |||
247 | 247 | ||
248 | if (0 == dev->pci->subsystem_vendor && | 248 | if (0 == dev->pci->subsystem_vendor && |
249 | 0 == dev->pci->subsystem_device) { | 249 | 0 == dev->pci->subsystem_device) { |
250 | printk("%s: Your board has no valid PCIe Subsystem ID and thus can't\n" | 250 | printk(KERN_INFO |
251 | "%s: be autodetected. Please pass card=<n> insmod option to\n" | 251 | "%s: Board has no valid PCIe Subsystem ID and can't\n" |
252 | "%s: workaround that. Redirect complaints to the vendor of\n" | 252 | "%s: be autodetected. Pass card=<n> insmod option\n" |
253 | "%s: the TV card. Best regards,\n" | 253 | "%s: to workaround that. Redirect complaints to the\n" |
254 | "%s: vendor of the TV card. Best regards,\n" | ||
254 | "%s: -- tux\n", | 255 | "%s: -- tux\n", |
255 | dev->name, dev->name, dev->name, dev->name, dev->name); | 256 | dev->name, dev->name, dev->name, dev->name, dev->name); |
256 | } else { | 257 | } else { |
257 | printk("%s: Your board isn't known (yet) to the driver. You can\n" | 258 | printk(KERN_INFO |
258 | "%s: try to pick one of the existing card configs via\n" | 259 | "%s: Your board isn't known (yet) to the driver.\n" |
260 | "%s: Try to pick one of the existing card configs via\n" | ||
259 | "%s: card=<n> insmod option. Updating to the latest\n" | 261 | "%s: card=<n> insmod option. Updating to the latest\n" |
260 | "%s: version might help as well.\n", | 262 | "%s: version might help as well.\n", |
261 | dev->name, dev->name, dev->name, dev->name); | 263 | dev->name, dev->name, dev->name, dev->name); |
262 | } | 264 | } |
263 | printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", | 265 | printk(KERN_INFO "%s: Here is a list of valid choices for the card=<n> insmod option:\n", |
264 | dev->name); | 266 | dev->name); |
265 | for (i = 0; i < cx23885_bcount; i++) | 267 | for (i = 0; i < cx23885_bcount; i++) |
266 | printk("%s: card=%d -> %s\n", | 268 | printk(KERN_INFO "%s: card=%d -> %s\n", |
267 | dev->name, i, cx23885_boards[i].name); | 269 | dev->name, i, cx23885_boards[i].name); |
268 | } | 270 | } |
269 | 271 | ||
@@ -271,11 +273,11 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
271 | { | 273 | { |
272 | struct tveeprom tv; | 274 | struct tveeprom tv; |
273 | 275 | ||
274 | tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, eeprom_data); | 276 | tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv, |
277 | eeprom_data); | ||
275 | 278 | ||
276 | /* Make sure we support the board model */ | 279 | /* Make sure we support the board model */ |
277 | switch (tv.model) | 280 | switch (tv.model) { |
278 | { | ||
279 | case 71009: | 281 | case 71009: |
280 | /* WinTV-HVR1200 (PCIe, Retail, full height) | 282 | /* WinTV-HVR1200 (PCIe, Retail, full height) |
281 | * DVB-T and basic analog */ | 283 | * DVB-T and basic analog */ |
@@ -303,21 +305,51 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
303 | case 71999: | 305 | case 71999: |
304 | /* WinTV-HVR1200 (PCIe, OEM, full height) | 306 | /* WinTV-HVR1200 (PCIe, OEM, full height) |
305 | * DVB-T and basic analog */ | 307 | * DVB-T and basic analog */ |
306 | case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ | 308 | case 76601: |
307 | case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ | 309 | /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual |
308 | case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ | 310 | channel ATSC and MPEG2 HW Encoder */ |
309 | case 77041: /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM and Basic analog */ | 311 | case 77001: |
310 | case 77051: /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM and Basic analog */ | 312 | /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC |
311 | case 78011: /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ | 313 | and Basic analog */ |
312 | case 78501: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */ | 314 | case 77011: |
313 | case 78521: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, Dual channel ATSC and MPEG2 HW Encoder */ | 315 | /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC |
314 | case 78531: /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ | 316 | and Basic analog */ |
315 | case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ | 317 | case 77041: |
316 | case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */ | 318 | /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM |
317 | case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */ | 319 | and Basic analog */ |
318 | case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ | 320 | case 77051: |
319 | case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ | 321 | /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM |
320 | case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ | 322 | and Basic analog */ |
323 | case 78011: | ||
324 | /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM, | ||
325 | Dual channel ATSC and MPEG2 HW Encoder */ | ||
326 | case 78501: | ||
327 | /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, | ||
328 | Dual channel ATSC and MPEG2 HW Encoder */ | ||
329 | case 78521: | ||
330 | /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM, | ||
331 | Dual channel ATSC and MPEG2 HW Encoder */ | ||
332 | case 78531: | ||
333 | /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM, | ||
334 | Dual channel ATSC and MPEG2 HW Encoder */ | ||
335 | case 78631: | ||
336 | /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, | ||
337 | Dual channel ATSC and MPEG2 HW Encoder */ | ||
338 | case 79001: | ||
339 | /* WinTV-HVR1250 (PCIe, Retail, IR, full height, | ||
340 | ATSC and Basic analog */ | ||
341 | case 79101: | ||
342 | /* WinTV-HVR1250 (PCIe, Retail, IR, half height, | ||
343 | ATSC and Basic analog */ | ||
344 | case 79561: | ||
345 | /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, | ||
346 | ATSC and Basic analog */ | ||
347 | case 79571: | ||
348 | /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, | ||
349 | ATSC and Basic analog */ | ||
350 | case 79671: | ||
351 | /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, | ||
352 | ATSC and Basic analog */ | ||
321 | case 80019: | 353 | case 80019: |
322 | /* WinTV-HVR1400 (Express Card, Retail, IR, | 354 | /* WinTV-HVR1400 (Express Card, Retail, IR, |
323 | * DVB-T and Basic analog */ | 355 | * DVB-T and Basic analog */ |
@@ -329,7 +361,8 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
329 | * DVB-T and MPEG2 HW Encoder */ | 361 | * DVB-T and MPEG2 HW Encoder */ |
330 | break; | 362 | break; |
331 | default: | 363 | default: |
332 | printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model); | 364 | printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n", |
365 | dev->name, tv.model); | ||
333 | break; | 366 | break; |
334 | } | 367 | } |
335 | 368 | ||
@@ -352,7 +385,7 @@ int cx23885_tuner_callback(void *priv, int component, int command, int arg) | |||
352 | return -EINVAL; | 385 | return -EINVAL; |
353 | } | 386 | } |
354 | 387 | ||
355 | switch(dev->board) { | 388 | switch (dev->board) { |
356 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | 389 | case CX23885_BOARD_HAUPPAUGE_HVR1400: |
357 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 390 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
358 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 391 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
@@ -383,7 +416,7 @@ int cx23885_tuner_callback(void *priv, int component, int command, int arg) | |||
383 | 416 | ||
384 | void cx23885_gpio_setup(struct cx23885_dev *dev) | 417 | void cx23885_gpio_setup(struct cx23885_dev *dev) |
385 | { | 418 | { |
386 | switch(dev->board) { | 419 | switch (dev->board) { |
387 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 420 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
388 | /* GPIO-0 cx24227 demodulator reset */ | 421 | /* GPIO-0 cx24227 demodulator reset */ |
389 | cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */ | 422 | cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */ |
@@ -617,10 +650,3 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
617 | } | 650 | } |
618 | 651 | ||
619 | /* ------------------------------------------------------------------ */ | 652 | /* ------------------------------------------------------------------ */ |
620 | |||
621 | /* | ||
622 | * Local variables: | ||
623 | * c-basic-offset: 8 | ||
624 | * End: | ||
625 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | ||
626 | */ | ||
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index beb3e61669a3..8f6fb2add7de 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
@@ -37,12 +37,12 @@ MODULE_AUTHOR("Steven Toth <stoth@linuxtv.org>"); | |||
37 | MODULE_LICENSE("GPL"); | 37 | MODULE_LICENSE("GPL"); |
38 | 38 | ||
39 | static unsigned int debug; | 39 | static unsigned int debug; |
40 | module_param(debug,int,0644); | 40 | module_param(debug, int, 0644); |
41 | MODULE_PARM_DESC(debug,"enable debug messages"); | 41 | MODULE_PARM_DESC(debug, "enable debug messages"); |
42 | 42 | ||
43 | static unsigned int card[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; | 43 | static unsigned int card[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET }; |
44 | module_param_array(card, int, NULL, 0444); | 44 | module_param_array(card, int, NULL, 0444); |
45 | MODULE_PARM_DESC(card,"card type"); | 45 | MODULE_PARM_DESC(card, "card type"); |
46 | 46 | ||
47 | #define dprintk(level, fmt, arg...)\ | 47 | #define dprintk(level, fmt, arg...)\ |
48 | do { if (debug >= level)\ | 48 | do { if (debug >= level)\ |
@@ -364,13 +364,12 @@ void cx23885_wakeup(struct cx23885_tsport *port, | |||
364 | list_del(&buf->vb.queue); | 364 | list_del(&buf->vb.queue); |
365 | wake_up(&buf->vb.done); | 365 | wake_up(&buf->vb.done); |
366 | } | 366 | } |
367 | if (list_empty(&q->active)) { | 367 | if (list_empty(&q->active)) |
368 | del_timer(&q->timeout); | 368 | del_timer(&q->timeout); |
369 | } else { | 369 | else |
370 | mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); | 370 | mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); |
371 | } | ||
372 | if (bc != 1) | 371 | if (bc != 1) |
373 | printk("%s: %d buffers handled (should be 1)\n", | 372 | printk(KERN_WARNING "%s: %d buffers handled (should be 1)\n", |
374 | __func__, bc); | 373 | __func__, bc); |
375 | } | 374 | } |
376 | 375 | ||
@@ -381,8 +380,7 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
381 | unsigned int i, lines; | 380 | unsigned int i, lines; |
382 | u32 cdt; | 381 | u32 cdt; |
383 | 382 | ||
384 | if (ch->cmds_start == 0) | 383 | if (ch->cmds_start == 0) { |
385 | { | ||
386 | dprintk(1, "%s() Erasing channel [%s]\n", __func__, | 384 | dprintk(1, "%s() Erasing channel [%s]\n", __func__, |
387 | ch->name); | 385 | ch->name); |
388 | cx_write(ch->ptr1_reg, 0); | 386 | cx_write(ch->ptr1_reg, 0); |
@@ -418,15 +416,15 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
418 | 416 | ||
419 | /* write CMDS */ | 417 | /* write CMDS */ |
420 | if (ch->jumponly) | 418 | if (ch->jumponly) |
421 | cx_write(ch->cmds_start + 0, 8); | 419 | cx_write(ch->cmds_start + 0, 8); |
422 | else | 420 | else |
423 | cx_write(ch->cmds_start + 0, risc); | 421 | cx_write(ch->cmds_start + 0, risc); |
424 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ | 422 | cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */ |
425 | cx_write(ch->cmds_start + 8, cdt); | 423 | cx_write(ch->cmds_start + 8, cdt); |
426 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); | 424 | cx_write(ch->cmds_start + 12, (lines*16) >> 3); |
427 | cx_write(ch->cmds_start + 16, ch->ctrl_start); | 425 | cx_write(ch->cmds_start + 16, ch->ctrl_start); |
428 | if (ch->jumponly) | 426 | if (ch->jumponly) |
429 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2) ); | 427 | cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2)); |
430 | else | 428 | else |
431 | cx_write(ch->cmds_start + 20, 64 >> 2); | 429 | cx_write(ch->cmds_start + 20, 64 >> 2); |
432 | for (i = 24; i < 80; i += 4) | 430 | for (i = 24; i < 80; i += 4) |
@@ -436,9 +434,9 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
436 | cx_write(ch->ptr1_reg, ch->fifo_start); | 434 | cx_write(ch->ptr1_reg, ch->fifo_start); |
437 | cx_write(ch->ptr2_reg, cdt); | 435 | cx_write(ch->ptr2_reg, cdt); |
438 | cx_write(ch->cnt2_reg, (lines*16) >> 3); | 436 | cx_write(ch->cnt2_reg, (lines*16) >> 3); |
439 | cx_write(ch->cnt1_reg, (bpl >> 3) -1); | 437 | cx_write(ch->cnt1_reg, (bpl >> 3) - 1); |
440 | 438 | ||
441 | dprintk(2,"[bridge %d] sram setup %s: bpl=%d lines=%d\n", | 439 | dprintk(2, "[bridge %d] sram setup %s: bpl=%d lines=%d\n", |
442 | dev->bridge, | 440 | dev->bridge, |
443 | ch->name, | 441 | ch->name, |
444 | bpl, | 442 | bpl, |
@@ -469,43 +467,43 @@ void cx23885_sram_channel_dump(struct cx23885_dev *dev, | |||
469 | u32 risc; | 467 | u32 risc; |
470 | unsigned int i, j, n; | 468 | unsigned int i, j, n; |
471 | 469 | ||
472 | printk("%s: %s - dma channel status dump\n", | 470 | printk(KERN_WARNING "%s: %s - dma channel status dump\n", |
473 | dev->name, ch->name); | 471 | dev->name, ch->name); |
474 | for (i = 0; i < ARRAY_SIZE(name); i++) | 472 | for (i = 0; i < ARRAY_SIZE(name); i++) |
475 | printk("%s: cmds: %-15s: 0x%08x\n", | 473 | printk(KERN_WARNING "%s: cmds: %-15s: 0x%08x\n", |
476 | dev->name, name[i], | 474 | dev->name, name[i], |
477 | cx_read(ch->cmds_start + 4*i)); | 475 | cx_read(ch->cmds_start + 4*i)); |
478 | 476 | ||
479 | for (i = 0; i < 4; i++) { | 477 | for (i = 0; i < 4; i++) { |
480 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); | 478 | risc = cx_read(ch->cmds_start + 4 * (i + 14)); |
481 | printk("%s: risc%d: ", dev->name, i); | 479 | printk(KERN_WARNING "%s: risc%d: ", dev->name, i); |
482 | cx23885_risc_decode(risc); | 480 | cx23885_risc_decode(risc); |
483 | } | 481 | } |
484 | for (i = 0; i < (64 >> 2); i += n) { | 482 | for (i = 0; i < (64 >> 2); i += n) { |
485 | risc = cx_read(ch->ctrl_start + 4 * i); | 483 | risc = cx_read(ch->ctrl_start + 4 * i); |
486 | /* No consideration for bits 63-32 */ | 484 | /* No consideration for bits 63-32 */ |
487 | 485 | ||
488 | printk("%s: (0x%08x) iq %x: ", dev->name, | 486 | printk(KERN_WARNING "%s: (0x%08x) iq %x: ", dev->name, |
489 | ch->ctrl_start + 4 * i, i); | 487 | ch->ctrl_start + 4 * i, i); |
490 | n = cx23885_risc_decode(risc); | 488 | n = cx23885_risc_decode(risc); |
491 | for (j = 1; j < n; j++) { | 489 | for (j = 1; j < n; j++) { |
492 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); | 490 | risc = cx_read(ch->ctrl_start + 4 * (i + j)); |
493 | printk("%s: iq %x: 0x%08x [ arg #%d ]\n", | 491 | printk(KERN_WARNING "%s: iq %x: 0x%08x [ arg #%d ]\n", |
494 | dev->name, i+j, risc, j); | 492 | dev->name, i+j, risc, j); |
495 | } | 493 | } |
496 | } | 494 | } |
497 | 495 | ||
498 | printk("%s: fifo: 0x%08x -> 0x%x\n", | 496 | printk(KERN_WARNING "%s: fifo: 0x%08x -> 0x%x\n", |
499 | dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); | 497 | dev->name, ch->fifo_start, ch->fifo_start+ch->fifo_size); |
500 | printk("%s: ctrl: 0x%08x -> 0x%x\n", | 498 | printk(KERN_WARNING "%s: ctrl: 0x%08x -> 0x%x\n", |
501 | dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); | 499 | dev->name, ch->ctrl_start, ch->ctrl_start + 6*16); |
502 | printk("%s: ptr1_reg: 0x%08x\n", | 500 | printk(KERN_WARNING "%s: ptr1_reg: 0x%08x\n", |
503 | dev->name, cx_read(ch->ptr1_reg)); | 501 | dev->name, cx_read(ch->ptr1_reg)); |
504 | printk("%s: ptr2_reg: 0x%08x\n", | 502 | printk(KERN_WARNING "%s: ptr2_reg: 0x%08x\n", |
505 | dev->name, cx_read(ch->ptr2_reg)); | 503 | dev->name, cx_read(ch->ptr2_reg)); |
506 | printk("%s: cnt1_reg: 0x%08x\n", | 504 | printk(KERN_WARNING "%s: cnt1_reg: 0x%08x\n", |
507 | dev->name, cx_read(ch->cnt1_reg)); | 505 | dev->name, cx_read(ch->cnt1_reg)); |
508 | printk("%s: cnt2_reg: 0x%08x\n", | 506 | printk(KERN_WARNING "%s: cnt2_reg: 0x%08x\n", |
509 | dev->name, cx_read(ch->cnt2_reg)); | 507 | dev->name, cx_read(ch->cnt2_reg)); |
510 | } | 508 | } |
511 | 509 | ||
@@ -515,13 +513,13 @@ static void cx23885_risc_disasm(struct cx23885_tsport *port, | |||
515 | struct cx23885_dev *dev = port->dev; | 513 | struct cx23885_dev *dev = port->dev; |
516 | unsigned int i, j, n; | 514 | unsigned int i, j, n; |
517 | 515 | ||
518 | printk("%s: risc disasm: %p [dma=0x%08lx]\n", | 516 | printk(KERN_INFO "%s: risc disasm: %p [dma=0x%08lx]\n", |
519 | dev->name, risc->cpu, (unsigned long)risc->dma); | 517 | dev->name, risc->cpu, (unsigned long)risc->dma); |
520 | for (i = 0; i < (risc->size >> 2); i += n) { | 518 | for (i = 0; i < (risc->size >> 2); i += n) { |
521 | printk("%s: %04d: ", dev->name, i); | 519 | printk(KERN_INFO "%s: %04d: ", dev->name, i); |
522 | n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); | 520 | n = cx23885_risc_decode(le32_to_cpu(risc->cpu[i])); |
523 | for (j = 1; j < n; j++) | 521 | for (j = 1; j < n; j++) |
524 | printk("%s: %04d: 0x%08x [ arg #%d ]\n", | 522 | printk(KERN_INFO "%s: %04d: 0x%08x [ arg #%d ]\n", |
525 | dev->name, i + j, risc->cpu[i + j], j); | 523 | dev->name, i + j, risc->cpu[i + j], j); |
526 | if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) | 524 | if (risc->cpu[i] == cpu_to_le32(RISC_JUMP)) |
527 | break; | 525 | break; |
@@ -600,7 +598,7 @@ static int cx23885_pci_quirks(struct cx23885_dev *dev) | |||
600 | * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not | 598 | * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not |
601 | * occur on the cx23887 bridge. | 599 | * occur on the cx23887 bridge. |
602 | */ | 600 | */ |
603 | if(dev->bridge == CX23885_BRIDGE_885) | 601 | if (dev->bridge == CX23885_BRIDGE_885) |
604 | cx_clear(RDR_TLCTL0, 1 << 4); | 602 | cx_clear(RDR_TLCTL0, 1 << 4); |
605 | 603 | ||
606 | return 0; | 604 | return 0; |
@@ -608,13 +606,13 @@ static int cx23885_pci_quirks(struct cx23885_dev *dev) | |||
608 | 606 | ||
609 | static int get_resources(struct cx23885_dev *dev) | 607 | static int get_resources(struct cx23885_dev *dev) |
610 | { | 608 | { |
611 | if (request_mem_region(pci_resource_start(dev->pci,0), | 609 | if (request_mem_region(pci_resource_start(dev->pci, 0), |
612 | pci_resource_len(dev->pci,0), | 610 | pci_resource_len(dev->pci, 0), |
613 | dev->name)) | 611 | dev->name)) |
614 | return 0; | 612 | return 0; |
615 | 613 | ||
616 | printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", | 614 | printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx\n", |
617 | dev->name, (unsigned long long)pci_resource_start(dev->pci,0)); | 615 | dev->name, (unsigned long long)pci_resource_start(dev->pci, 0)); |
618 | 616 | ||
619 | return -EBUSY; | 617 | return -EBUSY; |
620 | } | 618 | } |
@@ -623,7 +621,8 @@ static void cx23885_timeout(unsigned long data); | |||
623 | int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, | 621 | int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, |
624 | u32 reg, u32 mask, u32 value); | 622 | u32 reg, u32 mask, u32 value); |
625 | 623 | ||
626 | static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *port, int portno) | 624 | static int cx23885_init_tsport(struct cx23885_dev *dev, |
625 | struct cx23885_tsport *port, int portno) | ||
627 | { | 626 | { |
628 | dprintk(1, "%s(portno=%d)\n", __func__, portno); | 627 | dprintk(1, "%s(portno=%d)\n", __func__, portno); |
629 | 628 | ||
@@ -643,7 +642,18 @@ static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *p | |||
643 | port->mpegq.timeout.data = (unsigned long)port; | 642 | port->mpegq.timeout.data = (unsigned long)port; |
644 | init_timer(&port->mpegq.timeout); | 643 | init_timer(&port->mpegq.timeout); |
645 | 644 | ||
646 | switch(portno) { | 645 | mutex_init(&port->frontends.lock); |
646 | INIT_LIST_HEAD(&port->frontends.felist); | ||
647 | port->frontends.active_fe_id = 0; | ||
648 | |||
649 | /* This should be hardcoded allow a single frontend | ||
650 | * attachment to this tsport, keeping the -dvb.c | ||
651 | * code clean and safe. | ||
652 | */ | ||
653 | if (!port->num_frontends) | ||
654 | port->num_frontends = 1; | ||
655 | |||
656 | switch (portno) { | ||
647 | case 1: | 657 | case 1: |
648 | port->reg_gpcnt = VID_B_GPCNT; | 658 | port->reg_gpcnt = VID_B_GPCNT; |
649 | port->reg_gpcnt_ctl = VID_B_GPCNT_CTL; | 659 | port->reg_gpcnt_ctl = VID_B_GPCNT_CTL; |
@@ -744,13 +754,13 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
744 | mutex_unlock(&devlist); | 754 | mutex_unlock(&devlist); |
745 | 755 | ||
746 | /* Configure the internal memory */ | 756 | /* Configure the internal memory */ |
747 | if(dev->pci->device == 0x8880) { | 757 | if (dev->pci->device == 0x8880) { |
748 | dev->bridge = CX23885_BRIDGE_887; | 758 | dev->bridge = CX23885_BRIDGE_887; |
749 | /* Apply a sensible clock frequency for the PCIe bridge */ | 759 | /* Apply a sensible clock frequency for the PCIe bridge */ |
750 | dev->clk_freq = 25000000; | 760 | dev->clk_freq = 25000000; |
751 | dev->sram_channels = cx23887_sram_channels; | 761 | dev->sram_channels = cx23887_sram_channels; |
752 | } else | 762 | } else |
753 | if(dev->pci->device == 0x8852) { | 763 | if (dev->pci->device == 0x8852) { |
754 | dev->bridge = CX23885_BRIDGE_885; | 764 | dev->bridge = CX23885_BRIDGE_885; |
755 | /* Apply a sensible clock frequency for the PCIe bridge */ | 765 | /* Apply a sensible clock frequency for the PCIe bridge */ |
756 | dev->clk_freq = 28000000; | 766 | dev->clk_freq = 28000000; |
@@ -831,8 +841,8 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
831 | } | 841 | } |
832 | 842 | ||
833 | /* PCIe stuff */ | 843 | /* PCIe stuff */ |
834 | dev->lmmio = ioremap(pci_resource_start(dev->pci,0), | 844 | dev->lmmio = ioremap(pci_resource_start(dev->pci, 0), |
835 | pci_resource_len(dev->pci,0)); | 845 | pci_resource_len(dev->pci, 0)); |
836 | 846 | ||
837 | dev->bmmio = (u8 __iomem *)dev->lmmio; | 847 | dev->bmmio = (u8 __iomem *)dev->lmmio; |
838 | 848 | ||
@@ -862,7 +872,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
862 | cx23885_i2c_register(&dev->i2c_bus[1]); | 872 | cx23885_i2c_register(&dev->i2c_bus[1]); |
863 | cx23885_i2c_register(&dev->i2c_bus[2]); | 873 | cx23885_i2c_register(&dev->i2c_bus[2]); |
864 | cx23885_card_setup(dev); | 874 | cx23885_card_setup(dev); |
865 | cx23885_call_i2c_clients (&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); | 875 | cx23885_call_i2c_clients(&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); |
866 | cx23885_ir_init(dev); | 876 | cx23885_ir_init(dev); |
867 | 877 | ||
868 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { | 878 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { |
@@ -908,8 +918,8 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
908 | 918 | ||
909 | static void cx23885_dev_unregister(struct cx23885_dev *dev) | 919 | static void cx23885_dev_unregister(struct cx23885_dev *dev) |
910 | { | 920 | { |
911 | release_mem_region(pci_resource_start(dev->pci,0), | 921 | release_mem_region(pci_resource_start(dev->pci, 0), |
912 | pci_resource_len(dev->pci,0)); | 922 | pci_resource_len(dev->pci, 0)); |
913 | 923 | ||
914 | if (!atomic_dec_and_test(&dev->refcount)) | 924 | if (!atomic_dec_and_test(&dev->refcount)) |
915 | return; | 925 | return; |
@@ -936,7 +946,7 @@ static void cx23885_dev_unregister(struct cx23885_dev *dev) | |||
936 | iounmap(dev->lmmio); | 946 | iounmap(dev->lmmio); |
937 | } | 947 | } |
938 | 948 | ||
939 | static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, | 949 | static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, |
940 | unsigned int offset, u32 sync_line, | 950 | unsigned int offset, u32 sync_line, |
941 | unsigned int bpl, unsigned int padding, | 951 | unsigned int bpl, unsigned int padding, |
942 | unsigned int lines) | 952 | unsigned int lines) |
@@ -957,31 +967,31 @@ static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist, | |||
957 | } | 967 | } |
958 | if (bpl <= sg_dma_len(sg)-offset) { | 968 | if (bpl <= sg_dma_len(sg)-offset) { |
959 | /* fits into current chunk */ | 969 | /* fits into current chunk */ |
960 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); | 970 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL|RISC_EOL|bpl); |
961 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 971 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); |
962 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 972 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
963 | offset+=bpl; | 973 | offset += bpl; |
964 | } else { | 974 | } else { |
965 | /* scanline needs to be split */ | 975 | /* scanline needs to be split */ |
966 | todo = bpl; | 976 | todo = bpl; |
967 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_SOL| | 977 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_SOL| |
968 | (sg_dma_len(sg)-offset)); | 978 | (sg_dma_len(sg)-offset)); |
969 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | 979 | *(rp++) = cpu_to_le32(sg_dma_address(sg)+offset); |
970 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 980 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
971 | todo -= (sg_dma_len(sg)-offset); | 981 | todo -= (sg_dma_len(sg)-offset); |
972 | offset = 0; | 982 | offset = 0; |
973 | sg++; | 983 | sg++; |
974 | while (todo > sg_dma_len(sg)) { | 984 | while (todo > sg_dma_len(sg)) { |
975 | *(rp++)=cpu_to_le32(RISC_WRITE| | 985 | *(rp++) = cpu_to_le32(RISC_WRITE| |
976 | sg_dma_len(sg)); | 986 | sg_dma_len(sg)); |
977 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 987 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
978 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 988 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
979 | todo -= sg_dma_len(sg); | 989 | todo -= sg_dma_len(sg); |
980 | sg++; | 990 | sg++; |
981 | } | 991 | } |
982 | *(rp++)=cpu_to_le32(RISC_WRITE|RISC_EOL|todo); | 992 | *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); |
983 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | 993 | *(rp++) = cpu_to_le32(sg_dma_address(sg)); |
984 | *(rp++)=cpu_to_le32(0); /* bits 63-32 */ | 994 | *(rp++) = cpu_to_le32(0); /* bits 63-32 */ |
985 | offset += todo; | 995 | offset += todo; |
986 | } | 996 | } |
987 | offset += padding; | 997 | offset += padding; |
@@ -1010,9 +1020,11 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
1010 | can cause next bpl to start close to a page border. First DMA | 1020 | can cause next bpl to start close to a page border. First DMA |
1011 | region may be smaller than PAGE_SIZE */ | 1021 | region may be smaller than PAGE_SIZE */ |
1012 | /* write and jump need and extra dword */ | 1022 | /* write and jump need and extra dword */ |
1013 | instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE + lines); | 1023 | instructions = fields * (1 + ((bpl + padding) * lines) |
1024 | / PAGE_SIZE + lines); | ||
1014 | instructions += 2; | 1025 | instructions += 2; |
1015 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) | 1026 | rc = btcx_riscmem_alloc(pci, risc, instructions*12); |
1027 | if (rc < 0) | ||
1016 | return rc; | 1028 | return rc; |
1017 | 1029 | ||
1018 | /* write risc instructions */ | 1030 | /* write risc instructions */ |
@@ -1026,7 +1038,7 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
1026 | 1038 | ||
1027 | /* save pointer to jmp instruction address */ | 1039 | /* save pointer to jmp instruction address */ |
1028 | risc->jmp = rp; | 1040 | risc->jmp = rp; |
1029 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); | 1041 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); |
1030 | return 0; | 1042 | return 0; |
1031 | } | 1043 | } |
1032 | 1044 | ||
@@ -1048,7 +1060,8 @@ static int cx23885_risc_databuffer(struct pci_dev *pci, | |||
1048 | instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; | 1060 | instructions = 1 + (bpl * lines) / PAGE_SIZE + lines; |
1049 | instructions += 1; | 1061 | instructions += 1; |
1050 | 1062 | ||
1051 | if ((rc = btcx_riscmem_alloc(pci,risc,instructions*12)) < 0) | 1063 | rc = btcx_riscmem_alloc(pci, risc, instructions*12); |
1064 | if (rc < 0) | ||
1052 | return rc; | 1065 | return rc; |
1053 | 1066 | ||
1054 | /* write risc instructions */ | 1067 | /* write risc instructions */ |
@@ -1057,7 +1070,7 @@ static int cx23885_risc_databuffer(struct pci_dev *pci, | |||
1057 | 1070 | ||
1058 | /* save pointer to jmp instruction address */ | 1071 | /* save pointer to jmp instruction address */ |
1059 | risc->jmp = rp; | 1072 | risc->jmp = rp; |
1060 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof (*risc->cpu) > risc->size); | 1073 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); |
1061 | return 0; | 1074 | return 0; |
1062 | } | 1075 | } |
1063 | 1076 | ||
@@ -1067,7 +1080,8 @@ int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
1067 | __le32 *rp; | 1080 | __le32 *rp; |
1068 | int rc; | 1081 | int rc; |
1069 | 1082 | ||
1070 | if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) | 1083 | rc = btcx_riscmem_alloc(pci, risc, 4*16); |
1084 | if (rc < 0) | ||
1071 | return rc; | 1085 | return rc; |
1072 | 1086 | ||
1073 | /* write risc instructions */ | 1087 | /* write risc instructions */ |
@@ -1161,22 +1175,23 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
1161 | 1175 | ||
1162 | /* setup fifo + format */ | 1176 | /* setup fifo + format */ |
1163 | cx23885_sram_channel_setup(dev, | 1177 | cx23885_sram_channel_setup(dev, |
1164 | &dev->sram_channels[ port->sram_chno ], | 1178 | &dev->sram_channels[port->sram_chno], |
1165 | port->ts_packet_size, buf->risc.dma); | 1179 | port->ts_packet_size, buf->risc.dma); |
1166 | if(debug > 5) { | 1180 | if (debug > 5) { |
1167 | cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ] ); | 1181 | cx23885_sram_channel_dump(dev, |
1182 | &dev->sram_channels[port->sram_chno]); | ||
1168 | cx23885_risc_disasm(port, &buf->risc); | 1183 | cx23885_risc_disasm(port, &buf->risc); |
1169 | } | 1184 | } |
1170 | 1185 | ||
1171 | /* write TS length to chip */ | 1186 | /* write TS length to chip */ |
1172 | cx_write(port->reg_lngth, buf->vb.width); | 1187 | cx_write(port->reg_lngth, buf->vb.width); |
1173 | 1188 | ||
1174 | if ( (!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && | 1189 | if ((!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && |
1175 | (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB)) ) { | 1190 | (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB))) { |
1176 | printk( "%s() Failed. Unsupported value in .portb/c (0x%08x)/(0x%08x)\n", | 1191 | printk("%s() Unsupported .portb/c (0x%08x)/(0x%08x)\n", |
1177 | __func__, | 1192 | __func__, |
1178 | cx23885_boards[dev->board].portb, | 1193 | cx23885_boards[dev->board].portb, |
1179 | cx23885_boards[dev->board].portc ); | 1194 | cx23885_boards[dev->board].portc); |
1180 | return -EINVAL; | 1195 | return -EINVAL; |
1181 | } | 1196 | } |
1182 | 1197 | ||
@@ -1186,7 +1201,7 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
1186 | udelay(100); | 1201 | udelay(100); |
1187 | 1202 | ||
1188 | /* If the port supports SRC SELECT, configure it */ | 1203 | /* If the port supports SRC SELECT, configure it */ |
1189 | if(port->reg_src_sel) | 1204 | if (port->reg_src_sel) |
1190 | cx_write(port->reg_src_sel, port->src_sel_val); | 1205 | cx_write(port->reg_src_sel, port->src_sel_val); |
1191 | 1206 | ||
1192 | cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); | 1207 | cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); |
@@ -1195,7 +1210,7 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
1195 | cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); | 1210 | cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); |
1196 | udelay(100); | 1211 | udelay(100); |
1197 | 1212 | ||
1198 | // NOTE: this is 2 (reserved) for portb, does it matter? | 1213 | /* NOTE: this is 2 (reserved) for portb, does it matter? */ |
1199 | /* reset counter to zero */ | 1214 | /* reset counter to zero */ |
1200 | cx_write(port->reg_gpcnt_ctl, 3); | 1215 | cx_write(port->reg_gpcnt_ctl, 3); |
1201 | q->count = 1; | 1216 | q->count = 1; |
@@ -1229,11 +1244,11 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
1229 | cx_write(ALT_PIN_OUT_SEL, 0x10100045); | 1244 | cx_write(ALT_PIN_OUT_SEL, 0x10100045); |
1230 | } | 1245 | } |
1231 | 1246 | ||
1232 | switch(dev->bridge) { | 1247 | switch (dev->bridge) { |
1233 | case CX23885_BRIDGE_885: | 1248 | case CX23885_BRIDGE_885: |
1234 | case CX23885_BRIDGE_887: | 1249 | case CX23885_BRIDGE_887: |
1235 | /* enable irqs */ | 1250 | /* enable irqs */ |
1236 | dprintk(1, "%s() enabling TS int's and DMA\n", __func__ ); | 1251 | dprintk(1, "%s() enabling TS int's and DMA\n", __func__); |
1237 | cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); | 1252 | cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); |
1238 | cx_set(port->reg_dma_ctl, port->dma_ctl_val); | 1253 | cx_set(port->reg_dma_ctl, port->dma_ctl_val); |
1239 | cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); | 1254 | cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); |
@@ -1292,8 +1307,7 @@ int cx23885_restart_queue(struct cx23885_tsport *port, | |||
1292 | struct cx23885_buffer *buf; | 1307 | struct cx23885_buffer *buf; |
1293 | 1308 | ||
1294 | dprintk(5, "%s()\n", __func__); | 1309 | dprintk(5, "%s()\n", __func__); |
1295 | if (list_empty(&q->active)) | 1310 | if (list_empty(&q->active)) { |
1296 | { | ||
1297 | struct cx23885_buffer *prev; | 1311 | struct cx23885_buffer *prev; |
1298 | prev = NULL; | 1312 | prev = NULL; |
1299 | 1313 | ||
@@ -1311,7 +1325,7 @@ int cx23885_restart_queue(struct cx23885_tsport *port, | |||
1311 | buf->vb.state = VIDEOBUF_ACTIVE; | 1325 | buf->vb.state = VIDEOBUF_ACTIVE; |
1312 | buf->count = q->count++; | 1326 | buf->count = q->count++; |
1313 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 1327 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
1314 | dprintk(5, "[%p/%d] restart_queue - first active\n", | 1328 | dprintk(5, "[%p/%d] restart_queue - f/active\n", |
1315 | buf, buf->vb.i); | 1329 | buf, buf->vb.i); |
1316 | 1330 | ||
1317 | } else if (prev->vb.width == buf->vb.width && | 1331 | } else if (prev->vb.width == buf->vb.width && |
@@ -1322,8 +1336,9 @@ int cx23885_restart_queue(struct cx23885_tsport *port, | |||
1322 | buf->vb.state = VIDEOBUF_ACTIVE; | 1336 | buf->vb.state = VIDEOBUF_ACTIVE; |
1323 | buf->count = q->count++; | 1337 | buf->count = q->count++; |
1324 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 1338 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
1325 | prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ | 1339 | /* 64 bit bits 63-32 */ |
1326 | dprintk(5,"[%p/%d] restart_queue - move to active\n", | 1340 | prev->risc.jmp[2] = cpu_to_le32(0); |
1341 | dprintk(5, "[%p/%d] restart_queue - m/active\n", | ||
1327 | buf, buf->vb.i); | 1342 | buf, buf->vb.i); |
1328 | } else { | 1343 | } else { |
1329 | return 0; | 1344 | return 0; |
@@ -1362,7 +1377,8 @@ int cx23885_buf_prepare(struct videobuf_queue *q, struct cx23885_tsport *port, | |||
1362 | buf->vb.size = size; | 1377 | buf->vb.size = size; |
1363 | buf->vb.field = field /*V4L2_FIELD_TOP*/; | 1378 | buf->vb.field = field /*V4L2_FIELD_TOP*/; |
1364 | 1379 | ||
1365 | if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL))) | 1380 | rc = videobuf_iolock(q, &buf->vb, NULL); |
1381 | if (0 != rc) | ||
1366 | goto fail; | 1382 | goto fail; |
1367 | cx23885_risc_databuffer(dev->pci, &buf->risc, | 1383 | cx23885_risc_databuffer(dev->pci, &buf->risc, |
1368 | videobuf_to_dma(&buf->vb)->sglist, | 1384 | videobuf_to_dma(&buf->vb)->sglist, |
@@ -1388,7 +1404,7 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf) | |||
1388 | buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ | 1404 | buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ |
1389 | 1405 | ||
1390 | if (list_empty(&cx88q->active)) { | 1406 | if (list_empty(&cx88q->active)) { |
1391 | dprintk( 1, "queue is empty - first active\n" ); | 1407 | dprintk(1, "queue is empty - first active\n"); |
1392 | list_add_tail(&buf->vb.queue, &cx88q->active); | 1408 | list_add_tail(&buf->vb.queue, &cx88q->active); |
1393 | cx23885_start_dma(port, cx88q, buf); | 1409 | cx23885_start_dma(port, cx88q, buf); |
1394 | buf->vb.state = VIDEOBUF_ACTIVE; | 1410 | buf->vb.state = VIDEOBUF_ACTIVE; |
@@ -1397,7 +1413,7 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf) | |||
1397 | dprintk(1, "[%p/%d] %s - first active\n", | 1413 | dprintk(1, "[%p/%d] %s - first active\n", |
1398 | buf, buf->vb.i, __func__); | 1414 | buf, buf->vb.i, __func__); |
1399 | } else { | 1415 | } else { |
1400 | dprintk( 1, "queue is not empty - append to active\n" ); | 1416 | dprintk(1, "queue is not empty - append to active\n"); |
1401 | prev = list_entry(cx88q->active.prev, struct cx23885_buffer, | 1417 | prev = list_entry(cx88q->active.prev, struct cx23885_buffer, |
1402 | vb.queue); | 1418 | vb.queue); |
1403 | list_add_tail(&buf->vb.queue, &cx88q->active); | 1419 | list_add_tail(&buf->vb.queue, &cx88q->active); |
@@ -1405,7 +1421,7 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf) | |||
1405 | buf->count = cx88q->count++; | 1421 | buf->count = cx88q->count++; |
1406 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 1422 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
1407 | prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ | 1423 | prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ |
1408 | dprintk( 1, "[%p/%d] %s - append to active\n", | 1424 | dprintk(1, "[%p/%d] %s - append to active\n", |
1409 | buf, buf->vb.i, __func__); | 1425 | buf, buf->vb.i, __func__); |
1410 | } | 1426 | } |
1411 | } | 1427 | } |
@@ -1431,7 +1447,7 @@ static void do_cancel_buffers(struct cx23885_tsport *port, char *reason, | |||
1431 | buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); | 1447 | buf, buf->vb.i, reason, (unsigned long)buf->risc.dma); |
1432 | } | 1448 | } |
1433 | if (restart) { | 1449 | if (restart) { |
1434 | dprintk(1, "restarting queue\n" ); | 1450 | dprintk(1, "restarting queue\n"); |
1435 | cx23885_restart_queue(port, q); | 1451 | cx23885_restart_queue(port, q); |
1436 | } | 1452 | } |
1437 | spin_unlock_irqrestore(&port->slock, flags); | 1453 | spin_unlock_irqrestore(&port->slock, flags); |
@@ -1453,10 +1469,11 @@ static void cx23885_timeout(unsigned long data) | |||
1453 | struct cx23885_tsport *port = (struct cx23885_tsport *)data; | 1469 | struct cx23885_tsport *port = (struct cx23885_tsport *)data; |
1454 | struct cx23885_dev *dev = port->dev; | 1470 | struct cx23885_dev *dev = port->dev; |
1455 | 1471 | ||
1456 | dprintk(1, "%s()\n",__func__); | 1472 | dprintk(1, "%s()\n", __func__); |
1457 | 1473 | ||
1458 | if (debug > 5) | 1474 | if (debug > 5) |
1459 | cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); | 1475 | cx23885_sram_channel_dump(dev, |
1476 | &dev->sram_channels[port->sram_chno]); | ||
1460 | 1477 | ||
1461 | cx23885_stop_dma(port); | 1478 | cx23885_stop_dma(port); |
1462 | do_cancel_buffers(port, "timeout", 1); | 1479 | do_cancel_buffers(port, "timeout", 1); |
@@ -1532,16 +1549,23 @@ static int cx23885_irq_ts(struct cx23885_tsport *port, u32 status) | |||
1532 | if ((status & VID_BC_MSK_OPC_ERR) || | 1549 | if ((status & VID_BC_MSK_OPC_ERR) || |
1533 | (status & VID_BC_MSK_BAD_PKT) || | 1550 | (status & VID_BC_MSK_BAD_PKT) || |
1534 | (status & VID_BC_MSK_SYNC) || | 1551 | (status & VID_BC_MSK_SYNC) || |
1535 | (status & VID_BC_MSK_OF)) | 1552 | (status & VID_BC_MSK_OF)) { |
1536 | { | 1553 | |
1537 | if (status & VID_BC_MSK_OPC_ERR) | 1554 | if (status & VID_BC_MSK_OPC_ERR) |
1538 | dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", VID_BC_MSK_OPC_ERR); | 1555 | dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", |
1556 | VID_BC_MSK_OPC_ERR); | ||
1557 | |||
1539 | if (status & VID_BC_MSK_BAD_PKT) | 1558 | if (status & VID_BC_MSK_BAD_PKT) |
1540 | dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", VID_BC_MSK_BAD_PKT); | 1559 | dprintk(7, " (VID_BC_MSK_BAD_PKT 0x%08x)\n", |
1560 | VID_BC_MSK_BAD_PKT); | ||
1561 | |||
1541 | if (status & VID_BC_MSK_SYNC) | 1562 | if (status & VID_BC_MSK_SYNC) |
1542 | dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", VID_BC_MSK_SYNC); | 1563 | dprintk(7, " (VID_BC_MSK_SYNC 0x%08x)\n", |
1564 | VID_BC_MSK_SYNC); | ||
1565 | |||
1543 | if (status & VID_BC_MSK_OF) | 1566 | if (status & VID_BC_MSK_OF) |
1544 | dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", VID_BC_MSK_OF); | 1567 | dprintk(7, " (VID_BC_MSK_OF 0x%08x)\n", |
1568 | VID_BC_MSK_OF); | ||
1545 | 1569 | ||
1546 | printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); | 1570 | printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); |
1547 | 1571 | ||
@@ -1595,7 +1619,7 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id) | |||
1595 | ts2_status = cx_read(VID_C_INT_STAT); | 1619 | ts2_status = cx_read(VID_C_INT_STAT); |
1596 | ts2_mask = cx_read(VID_C_INT_MSK); | 1620 | ts2_mask = cx_read(VID_C_INT_MSK); |
1597 | 1621 | ||
1598 | if ( (pci_status == 0) && (ts2_status == 0) && (ts1_status == 0) ) | 1622 | if ((pci_status == 0) && (ts2_status == 0) && (ts1_status == 0)) |
1599 | goto out; | 1623 | goto out; |
1600 | 1624 | ||
1601 | vida_count = cx_read(VID_A_GPCNT); | 1625 | vida_count = cx_read(VID_A_GPCNT); |
@@ -1610,38 +1634,56 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id) | |||
1610 | dprintk(7, "ts2_status: 0x%08x ts2_mask: 0x%08x count: 0x%x\n", | 1634 | dprintk(7, "ts2_status: 0x%08x ts2_mask: 0x%08x count: 0x%x\n", |
1611 | ts2_status, ts2_mask, ts2_count); | 1635 | ts2_status, ts2_mask, ts2_count); |
1612 | 1636 | ||
1613 | if ( (pci_status & PCI_MSK_RISC_RD) || | 1637 | if ((pci_status & PCI_MSK_RISC_RD) || |
1614 | (pci_status & PCI_MSK_RISC_WR) || | 1638 | (pci_status & PCI_MSK_RISC_WR) || |
1615 | (pci_status & PCI_MSK_AL_RD) || | 1639 | (pci_status & PCI_MSK_AL_RD) || |
1616 | (pci_status & PCI_MSK_AL_WR) || | 1640 | (pci_status & PCI_MSK_AL_WR) || |
1617 | (pci_status & PCI_MSK_APB_DMA) || | 1641 | (pci_status & PCI_MSK_APB_DMA) || |
1618 | (pci_status & PCI_MSK_VID_C) || | 1642 | (pci_status & PCI_MSK_VID_C) || |
1619 | (pci_status & PCI_MSK_VID_B) || | 1643 | (pci_status & PCI_MSK_VID_B) || |
1620 | (pci_status & PCI_MSK_VID_A) || | 1644 | (pci_status & PCI_MSK_VID_A) || |
1621 | (pci_status & PCI_MSK_AUD_INT) || | 1645 | (pci_status & PCI_MSK_AUD_INT) || |
1622 | (pci_status & PCI_MSK_AUD_EXT) ) | 1646 | (pci_status & PCI_MSK_AUD_EXT)) { |
1623 | { | ||
1624 | 1647 | ||
1625 | if (pci_status & PCI_MSK_RISC_RD) | 1648 | if (pci_status & PCI_MSK_RISC_RD) |
1626 | dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", PCI_MSK_RISC_RD); | 1649 | dprintk(7, " (PCI_MSK_RISC_RD 0x%08x)\n", |
1650 | PCI_MSK_RISC_RD); | ||
1651 | |||
1627 | if (pci_status & PCI_MSK_RISC_WR) | 1652 | if (pci_status & PCI_MSK_RISC_WR) |
1628 | dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", PCI_MSK_RISC_WR); | 1653 | dprintk(7, " (PCI_MSK_RISC_WR 0x%08x)\n", |
1654 | PCI_MSK_RISC_WR); | ||
1655 | |||
1629 | if (pci_status & PCI_MSK_AL_RD) | 1656 | if (pci_status & PCI_MSK_AL_RD) |
1630 | dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", PCI_MSK_AL_RD); | 1657 | dprintk(7, " (PCI_MSK_AL_RD 0x%08x)\n", |
1658 | PCI_MSK_AL_RD); | ||
1659 | |||
1631 | if (pci_status & PCI_MSK_AL_WR) | 1660 | if (pci_status & PCI_MSK_AL_WR) |
1632 | dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", PCI_MSK_AL_WR); | 1661 | dprintk(7, " (PCI_MSK_AL_WR 0x%08x)\n", |
1662 | PCI_MSK_AL_WR); | ||
1663 | |||
1633 | if (pci_status & PCI_MSK_APB_DMA) | 1664 | if (pci_status & PCI_MSK_APB_DMA) |
1634 | dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", PCI_MSK_APB_DMA); | 1665 | dprintk(7, " (PCI_MSK_APB_DMA 0x%08x)\n", |
1666 | PCI_MSK_APB_DMA); | ||
1667 | |||
1635 | if (pci_status & PCI_MSK_VID_C) | 1668 | if (pci_status & PCI_MSK_VID_C) |
1636 | dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", PCI_MSK_VID_C); | 1669 | dprintk(7, " (PCI_MSK_VID_C 0x%08x)\n", |
1670 | PCI_MSK_VID_C); | ||
1671 | |||
1637 | if (pci_status & PCI_MSK_VID_B) | 1672 | if (pci_status & PCI_MSK_VID_B) |
1638 | dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", PCI_MSK_VID_B); | 1673 | dprintk(7, " (PCI_MSK_VID_B 0x%08x)\n", |
1674 | PCI_MSK_VID_B); | ||
1675 | |||
1639 | if (pci_status & PCI_MSK_VID_A) | 1676 | if (pci_status & PCI_MSK_VID_A) |
1640 | dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", PCI_MSK_VID_A); | 1677 | dprintk(7, " (PCI_MSK_VID_A 0x%08x)\n", |
1678 | PCI_MSK_VID_A); | ||
1679 | |||
1641 | if (pci_status & PCI_MSK_AUD_INT) | 1680 | if (pci_status & PCI_MSK_AUD_INT) |
1642 | dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", PCI_MSK_AUD_INT); | 1681 | dprintk(7, " (PCI_MSK_AUD_INT 0x%08x)\n", |
1682 | PCI_MSK_AUD_INT); | ||
1683 | |||
1643 | if (pci_status & PCI_MSK_AUD_EXT) | 1684 | if (pci_status & PCI_MSK_AUD_EXT) |
1644 | dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", PCI_MSK_AUD_EXT); | 1685 | dprintk(7, " (PCI_MSK_AUD_EXT 0x%08x)\n", |
1686 | PCI_MSK_AUD_EXT); | ||
1645 | 1687 | ||
1646 | } | 1688 | } |
1647 | 1689 | ||
@@ -1753,13 +1795,13 @@ static struct pci_device_id cx23885_pci_tbl[] = { | |||
1753 | .device = 0x8852, | 1795 | .device = 0x8852, |
1754 | .subvendor = PCI_ANY_ID, | 1796 | .subvendor = PCI_ANY_ID, |
1755 | .subdevice = PCI_ANY_ID, | 1797 | .subdevice = PCI_ANY_ID, |
1756 | },{ | 1798 | }, { |
1757 | /* CX23887 Rev 2 */ | 1799 | /* CX23887 Rev 2 */ |
1758 | .vendor = 0x14f1, | 1800 | .vendor = 0x14f1, |
1759 | .device = 0x8880, | 1801 | .device = 0x8880, |
1760 | .subvendor = PCI_ANY_ID, | 1802 | .subvendor = PCI_ANY_ID, |
1761 | .subdevice = PCI_ANY_ID, | 1803 | .subdevice = PCI_ANY_ID, |
1762 | },{ | 1804 | }, { |
1763 | /* --- end of list --- */ | 1805 | /* --- end of list --- */ |
1764 | } | 1806 | } |
1765 | }; | 1807 | }; |
@@ -1797,9 +1839,3 @@ module_init(cx23885_init); | |||
1797 | module_exit(cx23885_fini); | 1839 | module_exit(cx23885_fini); |
1798 | 1840 | ||
1799 | /* ----------------------------------------------------------- */ | 1841 | /* ----------------------------------------------------------- */ |
1800 | /* | ||
1801 | * Local variables: | ||
1802 | * c-basic-offset: 8 | ||
1803 | * End: | ||
1804 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | ||
1805 | */ | ||
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index 24bd18327aa0..e1aac07b3158 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -78,19 +78,19 @@ static int dvb_buf_prepare(struct videobuf_queue *q, | |||
78 | struct videobuf_buffer *vb, enum v4l2_field field) | 78 | struct videobuf_buffer *vb, enum v4l2_field field) |
79 | { | 79 | { |
80 | struct cx23885_tsport *port = q->priv_data; | 80 | struct cx23885_tsport *port = q->priv_data; |
81 | return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field); | 81 | return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field); |
82 | } | 82 | } |
83 | 83 | ||
84 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | 84 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) |
85 | { | 85 | { |
86 | struct cx23885_tsport *port = q->priv_data; | 86 | struct cx23885_tsport *port = q->priv_data; |
87 | cx23885_buf_queue(port, (struct cx23885_buffer*)vb); | 87 | cx23885_buf_queue(port, (struct cx23885_buffer *)vb); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void dvb_buf_release(struct videobuf_queue *q, | 90 | static void dvb_buf_release(struct videobuf_queue *q, |
91 | struct videobuf_buffer *vb) | 91 | struct videobuf_buffer *vb) |
92 | { | 92 | { |
93 | cx23885_free_buffer(q, (struct cx23885_buffer*)vb); | 93 | cx23885_free_buffer(q, (struct cx23885_buffer *)vb); |
94 | } | 94 | } |
95 | 95 | ||
96 | static struct videobuf_queue_ops dvb_qops = { | 96 | static struct videobuf_queue_ops dvb_qops = { |
@@ -312,19 +312,25 @@ static int dvb_register(struct cx23885_tsport *port) | |||
312 | { | 312 | { |
313 | struct cx23885_dev *dev = port->dev; | 313 | struct cx23885_dev *dev = port->dev; |
314 | struct cx23885_i2c *i2c_bus = NULL; | 314 | struct cx23885_i2c *i2c_bus = NULL; |
315 | struct videobuf_dvb_frontend *fe0; | ||
316 | |||
317 | /* Get the first frontend */ | ||
318 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); | ||
319 | if (!fe0) | ||
320 | return -EINVAL; | ||
315 | 321 | ||
316 | /* init struct videobuf_dvb */ | 322 | /* init struct videobuf_dvb */ |
317 | port->dvb.name = dev->name; | 323 | fe0->dvb.name = dev->name; |
318 | 324 | ||
319 | /* init frontend */ | 325 | /* init frontend */ |
320 | switch (dev->board) { | 326 | switch (dev->board) { |
321 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 327 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
322 | i2c_bus = &dev->i2c_bus[0]; | 328 | i2c_bus = &dev->i2c_bus[0]; |
323 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 329 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
324 | &hauppauge_generic_config, | 330 | &hauppauge_generic_config, |
325 | &i2c_bus->i2c_adap); | 331 | &i2c_bus->i2c_adap); |
326 | if (port->dvb.frontend != NULL) { | 332 | if (fe0->dvb.frontend != NULL) { |
327 | dvb_attach(mt2131_attach, port->dvb.frontend, | 333 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
328 | &i2c_bus->i2c_adap, | 334 | &i2c_bus->i2c_adap, |
329 | &hauppauge_generic_tunerconfig, 0); | 335 | &hauppauge_generic_tunerconfig, 0); |
330 | } | 336 | } |
@@ -333,27 +339,27 @@ static int dvb_register(struct cx23885_tsport *port) | |||
333 | i2c_bus = &dev->i2c_bus[0]; | 339 | i2c_bus = &dev->i2c_bus[0]; |
334 | switch (alt_tuner) { | 340 | switch (alt_tuner) { |
335 | case 1: | 341 | case 1: |
336 | port->dvb.frontend = | 342 | fe0->dvb.frontend = |
337 | dvb_attach(s5h1409_attach, | 343 | dvb_attach(s5h1409_attach, |
338 | &hauppauge_ezqam_config, | 344 | &hauppauge_ezqam_config, |
339 | &i2c_bus->i2c_adap); | 345 | &i2c_bus->i2c_adap); |
340 | if (port->dvb.frontend != NULL) { | 346 | if (fe0->dvb.frontend != NULL) { |
341 | dvb_attach(tda829x_attach, port->dvb.frontend, | 347 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
342 | &dev->i2c_bus[1].i2c_adap, 0x42, | 348 | &dev->i2c_bus[1].i2c_adap, 0x42, |
343 | &tda829x_no_probe); | 349 | &tda829x_no_probe); |
344 | dvb_attach(tda18271_attach, port->dvb.frontend, | 350 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
345 | 0x60, &dev->i2c_bus[1].i2c_adap, | 351 | 0x60, &dev->i2c_bus[1].i2c_adap, |
346 | &hauppauge_tda18271_config); | 352 | &hauppauge_tda18271_config); |
347 | } | 353 | } |
348 | break; | 354 | break; |
349 | case 0: | 355 | case 0: |
350 | default: | 356 | default: |
351 | port->dvb.frontend = | 357 | fe0->dvb.frontend = |
352 | dvb_attach(s5h1409_attach, | 358 | dvb_attach(s5h1409_attach, |
353 | &hauppauge_generic_config, | 359 | &hauppauge_generic_config, |
354 | &i2c_bus->i2c_adap); | 360 | &i2c_bus->i2c_adap); |
355 | if (port->dvb.frontend != NULL) | 361 | if (fe0->dvb.frontend != NULL) |
356 | dvb_attach(mt2131_attach, port->dvb.frontend, | 362 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
357 | &i2c_bus->i2c_adap, | 363 | &i2c_bus->i2c_adap, |
358 | &hauppauge_generic_tunerconfig, 0); | 364 | &hauppauge_generic_tunerconfig, 0); |
359 | break; | 365 | break; |
@@ -361,42 +367,42 @@ static int dvb_register(struct cx23885_tsport *port) | |||
361 | break; | 367 | break; |
362 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: | 368 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
363 | i2c_bus = &dev->i2c_bus[0]; | 369 | i2c_bus = &dev->i2c_bus[0]; |
364 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 370 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
365 | &hauppauge_hvr1800lp_config, | 371 | &hauppauge_hvr1800lp_config, |
366 | &i2c_bus->i2c_adap); | 372 | &i2c_bus->i2c_adap); |
367 | if (port->dvb.frontend != NULL) { | 373 | if (fe0->dvb.frontend != NULL) { |
368 | dvb_attach(mt2131_attach, port->dvb.frontend, | 374 | dvb_attach(mt2131_attach, fe0->dvb.frontend, |
369 | &i2c_bus->i2c_adap, | 375 | &i2c_bus->i2c_adap, |
370 | &hauppauge_generic_tunerconfig, 0); | 376 | &hauppauge_generic_tunerconfig, 0); |
371 | } | 377 | } |
372 | break; | 378 | break; |
373 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: | 379 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: |
374 | i2c_bus = &dev->i2c_bus[0]; | 380 | i2c_bus = &dev->i2c_bus[0]; |
375 | port->dvb.frontend = dvb_attach(lgdt330x_attach, | 381 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
376 | &fusionhdtv_5_express, | 382 | &fusionhdtv_5_express, |
377 | &i2c_bus->i2c_adap); | 383 | &i2c_bus->i2c_adap); |
378 | if (port->dvb.frontend != NULL) { | 384 | if (fe0->dvb.frontend != NULL) { |
379 | dvb_attach(simple_tuner_attach, port->dvb.frontend, | 385 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
380 | &i2c_bus->i2c_adap, 0x61, | 386 | &i2c_bus->i2c_adap, 0x61, |
381 | TUNER_LG_TDVS_H06XF); | 387 | TUNER_LG_TDVS_H06XF); |
382 | } | 388 | } |
383 | break; | 389 | break; |
384 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 390 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
385 | i2c_bus = &dev->i2c_bus[1]; | 391 | i2c_bus = &dev->i2c_bus[1]; |
386 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 392 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
387 | &hauppauge_hvr1500q_config, | 393 | &hauppauge_hvr1500q_config, |
388 | &dev->i2c_bus[0].i2c_adap); | 394 | &dev->i2c_bus[0].i2c_adap); |
389 | if (port->dvb.frontend != NULL) | 395 | if (fe0->dvb.frontend != NULL) |
390 | dvb_attach(xc5000_attach, port->dvb.frontend, | 396 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
391 | &i2c_bus->i2c_adap, | 397 | &i2c_bus->i2c_adap, |
392 | &hauppauge_hvr1500q_tunerconfig); | 398 | &hauppauge_hvr1500q_tunerconfig); |
393 | break; | 399 | break; |
394 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 400 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
395 | i2c_bus = &dev->i2c_bus[1]; | 401 | i2c_bus = &dev->i2c_bus[1]; |
396 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 402 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
397 | &hauppauge_hvr1500_config, | 403 | &hauppauge_hvr1500_config, |
398 | &dev->i2c_bus[0].i2c_adap); | 404 | &dev->i2c_bus[0].i2c_adap); |
399 | if (port->dvb.frontend != NULL) { | 405 | if (fe0->dvb.frontend != NULL) { |
400 | struct dvb_frontend *fe; | 406 | struct dvb_frontend *fe; |
401 | struct xc2028_config cfg = { | 407 | struct xc2028_config cfg = { |
402 | .i2c_adap = &i2c_bus->i2c_adap, | 408 | .i2c_adap = &i2c_bus->i2c_adap, |
@@ -409,7 +415,7 @@ static int dvb_register(struct cx23885_tsport *port) | |||
409 | }; | 415 | }; |
410 | 416 | ||
411 | fe = dvb_attach(xc2028_attach, | 417 | fe = dvb_attach(xc2028_attach, |
412 | port->dvb.frontend, &cfg); | 418 | fe0->dvb.frontend, &cfg); |
413 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | 419 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
414 | fe->ops.tuner_ops.set_config(fe, &ctl); | 420 | fe->ops.tuner_ops.set_config(fe, &ctl); |
415 | } | 421 | } |
@@ -417,24 +423,24 @@ static int dvb_register(struct cx23885_tsport *port) | |||
417 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | 423 | case CX23885_BOARD_HAUPPAUGE_HVR1200: |
418 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | 424 | case CX23885_BOARD_HAUPPAUGE_HVR1700: |
419 | i2c_bus = &dev->i2c_bus[0]; | 425 | i2c_bus = &dev->i2c_bus[0]; |
420 | port->dvb.frontend = dvb_attach(tda10048_attach, | 426 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
421 | &hauppauge_hvr1200_config, | 427 | &hauppauge_hvr1200_config, |
422 | &i2c_bus->i2c_adap); | 428 | &i2c_bus->i2c_adap); |
423 | if (port->dvb.frontend != NULL) { | 429 | if (fe0->dvb.frontend != NULL) { |
424 | dvb_attach(tda829x_attach, port->dvb.frontend, | 430 | dvb_attach(tda829x_attach, fe0->dvb.frontend, |
425 | &dev->i2c_bus[1].i2c_adap, 0x42, | 431 | &dev->i2c_bus[1].i2c_adap, 0x42, |
426 | &tda829x_no_probe); | 432 | &tda829x_no_probe); |
427 | dvb_attach(tda18271_attach, port->dvb.frontend, | 433 | dvb_attach(tda18271_attach, fe0->dvb.frontend, |
428 | 0x60, &dev->i2c_bus[1].i2c_adap, | 434 | 0x60, &dev->i2c_bus[1].i2c_adap, |
429 | &hauppauge_hvr1200_tuner_config); | 435 | &hauppauge_hvr1200_tuner_config); |
430 | } | 436 | } |
431 | break; | 437 | break; |
432 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | 438 | case CX23885_BOARD_HAUPPAUGE_HVR1400: |
433 | i2c_bus = &dev->i2c_bus[0]; | 439 | i2c_bus = &dev->i2c_bus[0]; |
434 | port->dvb.frontend = dvb_attach(dib7000p_attach, | 440 | fe0->dvb.frontend = dvb_attach(dib7000p_attach, |
435 | &i2c_bus->i2c_adap, | 441 | &i2c_bus->i2c_adap, |
436 | 0x12, &hauppauge_hvr1400_dib7000_config); | 442 | 0x12, &hauppauge_hvr1400_dib7000_config); |
437 | if (port->dvb.frontend != NULL) { | 443 | if (fe0->dvb.frontend != NULL) { |
438 | struct dvb_frontend *fe; | 444 | struct dvb_frontend *fe; |
439 | struct xc2028_config cfg = { | 445 | struct xc2028_config cfg = { |
440 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, | 446 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
@@ -444,12 +450,13 @@ static int dvb_register(struct cx23885_tsport *port) | |||
444 | .fname = XC3028L_DEFAULT_FIRMWARE, | 450 | .fname = XC3028L_DEFAULT_FIRMWARE, |
445 | .max_len = 64, | 451 | .max_len = 64, |
446 | .demod = 5000, | 452 | .demod = 5000, |
447 | /* This is true for all demods with v36 firmware? */ | 453 | /* This is true for all demods with |
454 | v36 firmware? */ | ||
448 | .type = XC2028_D2633, | 455 | .type = XC2028_D2633, |
449 | }; | 456 | }; |
450 | 457 | ||
451 | fe = dvb_attach(xc2028_attach, | 458 | fe = dvb_attach(xc2028_attach, |
452 | port->dvb.frontend, &cfg); | 459 | fe0->dvb.frontend, &cfg); |
453 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | 460 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
454 | fe->ops.tuner_ops.set_config(fe, &ctl); | 461 | fe->ops.tuner_ops.set_config(fe, &ctl); |
455 | } | 462 | } |
@@ -457,25 +464,25 @@ static int dvb_register(struct cx23885_tsport *port) | |||
457 | case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: | 464 | case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: |
458 | i2c_bus = &dev->i2c_bus[port->nr - 1]; | 465 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
459 | 466 | ||
460 | port->dvb.frontend = dvb_attach(s5h1409_attach, | 467 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
461 | &dvico_s5h1409_config, | 468 | &dvico_s5h1409_config, |
462 | &i2c_bus->i2c_adap); | 469 | &i2c_bus->i2c_adap); |
463 | if (port->dvb.frontend == NULL) | 470 | if (fe0->dvb.frontend == NULL) |
464 | port->dvb.frontend = dvb_attach(s5h1411_attach, | 471 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
465 | &dvico_s5h1411_config, | 472 | &dvico_s5h1411_config, |
466 | &i2c_bus->i2c_adap); | 473 | &i2c_bus->i2c_adap); |
467 | if (port->dvb.frontend != NULL) | 474 | if (fe0->dvb.frontend != NULL) |
468 | dvb_attach(xc5000_attach, port->dvb.frontend, | 475 | dvb_attach(xc5000_attach, fe0->dvb.frontend, |
469 | &i2c_bus->i2c_adap, | 476 | &i2c_bus->i2c_adap, |
470 | &dvico_xc5000_tunerconfig); | 477 | &dvico_xc5000_tunerconfig); |
471 | break; | 478 | break; |
472 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { | 479 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { |
473 | i2c_bus = &dev->i2c_bus[port->nr - 1]; | 480 | i2c_bus = &dev->i2c_bus[port->nr - 1]; |
474 | 481 | ||
475 | port->dvb.frontend = dvb_attach(zl10353_attach, | 482 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
476 | &dvico_fusionhdtv_xc3028, | 483 | &dvico_fusionhdtv_xc3028, |
477 | &i2c_bus->i2c_adap); | 484 | &i2c_bus->i2c_adap); |
478 | if (port->dvb.frontend != NULL) { | 485 | if (fe0->dvb.frontend != NULL) { |
479 | struct dvb_frontend *fe; | 486 | struct dvb_frontend *fe; |
480 | struct xc2028_config cfg = { | 487 | struct xc2028_config cfg = { |
481 | .i2c_adap = &i2c_bus->i2c_adap, | 488 | .i2c_adap = &i2c_bus->i2c_adap, |
@@ -487,7 +494,7 @@ static int dvb_register(struct cx23885_tsport *port) | |||
487 | .demod = XC3028_FE_ZARLINK456, | 494 | .demod = XC3028_FE_ZARLINK456, |
488 | }; | 495 | }; |
489 | 496 | ||
490 | fe = dvb_attach(xc2028_attach, port->dvb.frontend, | 497 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
491 | &cfg); | 498 | &cfg); |
492 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | 499 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
493 | fe->ops.tuner_ops.set_config(fe, &ctl); | 500 | fe->ops.tuner_ops.set_config(fe, &ctl); |
@@ -497,10 +504,10 @@ static int dvb_register(struct cx23885_tsport *port) | |||
497 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: | 504 | case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: |
498 | i2c_bus = &dev->i2c_bus[0]; | 505 | i2c_bus = &dev->i2c_bus[0]; |
499 | 506 | ||
500 | port->dvb.frontend = dvb_attach(zl10353_attach, | 507 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
501 | &dvico_fusionhdtv_xc3028, | 508 | &dvico_fusionhdtv_xc3028, |
502 | &i2c_bus->i2c_adap); | 509 | &i2c_bus->i2c_adap); |
503 | if (port->dvb.frontend != NULL) { | 510 | if (fe0->dvb.frontend != NULL) { |
504 | struct dvb_frontend *fe; | 511 | struct dvb_frontend *fe; |
505 | struct xc2028_config cfg = { | 512 | struct xc2028_config cfg = { |
506 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, | 513 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, |
@@ -512,73 +519,108 @@ static int dvb_register(struct cx23885_tsport *port) | |||
512 | .demod = XC3028_FE_ZARLINK456, | 519 | .demod = XC3028_FE_ZARLINK456, |
513 | }; | 520 | }; |
514 | 521 | ||
515 | fe = dvb_attach(xc2028_attach, port->dvb.frontend, | 522 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, |
516 | &cfg); | 523 | &cfg); |
517 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | 524 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
518 | fe->ops.tuner_ops.set_config(fe, &ctl); | 525 | fe->ops.tuner_ops.set_config(fe, &ctl); |
519 | } | 526 | } |
520 | break; | 527 | break; |
521 | default: | 528 | default: |
522 | printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", | 529 | printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " |
530 | " isn't supported yet\n", | ||
523 | dev->name); | 531 | dev->name); |
524 | break; | 532 | break; |
525 | } | 533 | } |
526 | if (NULL == port->dvb.frontend) { | 534 | if (NULL == fe0->dvb.frontend) { |
527 | printk("%s: frontend initialization failed\n", dev->name); | 535 | printk(KERN_ERR "%s: frontend initialization failed\n", |
536 | dev->name); | ||
528 | return -1; | 537 | return -1; |
529 | } | 538 | } |
530 | /* define general-purpose callback pointer */ | 539 | /* define general-purpose callback pointer */ |
531 | port->dvb.frontend->callback = cx23885_tuner_callback; | 540 | fe0->dvb.frontend->callback = cx23885_tuner_callback; |
532 | 541 | ||
533 | /* Put the analog decoder in standby to keep it quiet */ | 542 | /* Put the analog decoder in standby to keep it quiet */ |
534 | cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); | 543 | cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); |
535 | 544 | ||
536 | if (port->dvb.frontend->ops.analog_ops.standby) | 545 | if (fe0->dvb.frontend->ops.analog_ops.standby) |
537 | port->dvb.frontend->ops.analog_ops.standby(port->dvb.frontend); | 546 | fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); |
538 | 547 | ||
539 | /* register everything */ | 548 | /* register everything */ |
540 | return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, | 549 | return videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port, |
541 | &dev->pci->dev, adapter_nr); | 550 | &dev->pci->dev, adapter_nr, 0); |
551 | |||
542 | } | 552 | } |
543 | 553 | ||
544 | int cx23885_dvb_register(struct cx23885_tsport *port) | 554 | int cx23885_dvb_register(struct cx23885_tsport *port) |
545 | { | 555 | { |
556 | |||
557 | struct videobuf_dvb_frontend *fe0; | ||
546 | struct cx23885_dev *dev = port->dev; | 558 | struct cx23885_dev *dev = port->dev; |
547 | int err; | 559 | int err, i; |
560 | |||
561 | /* Here we need to allocate the correct number of frontends, | ||
562 | * as reflected in the cards struct. The reality is that currrently | ||
563 | * no cx23885 boards support this - yet. But, if we don't modify this | ||
564 | * code then the second frontend would never be allocated (later) | ||
565 | * and fail with error before the attach in dvb_register(). | ||
566 | * Without these changes we risk an OOPS later. The changes here | ||
567 | * are for safety, and should provide a good foundation for the | ||
568 | * future addition of any multi-frontend cx23885 based boards. | ||
569 | */ | ||
570 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, | ||
571 | port->num_frontends); | ||
572 | |||
573 | for (i = 1; i <= port->num_frontends; i++) { | ||
574 | if (videobuf_dvb_alloc_frontend( | ||
575 | &port->frontends, i) == NULL) { | ||
576 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | ||
577 | return -ENOMEM; | ||
578 | } | ||
548 | 579 | ||
549 | dprintk(1, "%s\n", __func__); | 580 | fe0 = videobuf_dvb_get_frontend(&port->frontends, i); |
550 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 581 | if (!fe0) |
551 | dev->board, | 582 | err = -EINVAL; |
552 | dev->name, | ||
553 | dev->pci_bus, | ||
554 | dev->pci_slot); | ||
555 | 583 | ||
556 | err = -ENODEV; | 584 | dprintk(1, "%s\n", __func__); |
585 | dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", | ||
586 | dev->board, | ||
587 | dev->name, | ||
588 | dev->pci_bus, | ||
589 | dev->pci_slot); | ||
557 | 590 | ||
558 | /* dvb stuff */ | 591 | err = -ENODEV; |
559 | printk("%s: cx23885 based dvb card\n", dev->name); | 592 | |
560 | videobuf_queue_sg_init(&port->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, | 593 | /* dvb stuff */ |
594 | /* We have to init the queue for each frontend on a port. */ | ||
595 | printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); | ||
596 | videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, | ||
597 | &dev->pci->dev, &port->slock, | ||
561 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, | 598 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, |
562 | sizeof(struct cx23885_buffer), port); | 599 | sizeof(struct cx23885_buffer), port); |
600 | } | ||
563 | err = dvb_register(port); | 601 | err = dvb_register(port); |
564 | if (err != 0) | 602 | if (err != 0) |
565 | printk("%s() dvb_register failed err = %d\n", __func__, err); | 603 | printk(KERN_ERR "%s() dvb_register failed err = %d\n", |
604 | __func__, err); | ||
566 | 605 | ||
567 | return err; | 606 | return err; |
568 | } | 607 | } |
569 | 608 | ||
570 | int cx23885_dvb_unregister(struct cx23885_tsport *port) | 609 | int cx23885_dvb_unregister(struct cx23885_tsport *port) |
571 | { | 610 | { |
572 | /* dvb */ | 611 | struct videobuf_dvb_frontend *fe0; |
573 | if(port->dvb.frontend) | 612 | |
574 | videobuf_dvb_unregister(&port->dvb); | 613 | /* FIXME: in an error condition where the we have |
614 | * an expected number of frontends (attach problem) | ||
615 | * then this might not clean up correctly, if 1 | ||
616 | * is invalid. | ||
617 | * This comment only applies to future boards IF they | ||
618 | * implement MFE support. | ||
619 | */ | ||
620 | fe0 = videobuf_dvb_get_frontend(&port->frontends, 1); | ||
621 | if (fe0->dvb.frontend) | ||
622 | videobuf_dvb_unregister_bus(&port->frontends); | ||
575 | 623 | ||
576 | return 0; | 624 | return 0; |
577 | } | 625 | } |
578 | 626 | ||
579 | /* | ||
580 | * Local variables: | ||
581 | * c-basic-offset: 8 | ||
582 | * End: | ||
583 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | ||
584 | */ | ||
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index f98e476e9617..bb7f71a1fcbe 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c | |||
@@ -131,7 +131,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
131 | printk(" >\n"); | 131 | printk(" >\n"); |
132 | } | 132 | } |
133 | 133 | ||
134 | for (cnt = 1; cnt < msg->len; cnt++ ) { | 134 | for (cnt = 1; cnt < msg->len; cnt++) { |
135 | /* following bytes */ | 135 | /* following bytes */ |
136 | wdata = msg->buf[cnt]; | 136 | wdata = msg->buf[cnt]; |
137 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); | 137 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); |
@@ -151,9 +151,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
151 | if (retval == 0) | 151 | if (retval == 0) |
152 | goto eio; | 152 | goto eio; |
153 | if (i2c_debug) { | 153 | if (i2c_debug) { |
154 | printk(" %02x", msg->buf[cnt]); | 154 | dprintk(1, " %02x", msg->buf[cnt]); |
155 | if (!(ctrl & I2C_NOSTOP)) | 155 | if (!(ctrl & I2C_NOSTOP)) |
156 | printk(" >\n"); | 156 | dprintk(1, " >\n"); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | return msg->len; | 159 | return msg->len; |
@@ -162,7 +162,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
162 | retval = -EIO; | 162 | retval = -EIO; |
163 | err: | 163 | err: |
164 | if (i2c_debug) | 164 | if (i2c_debug) |
165 | printk(" ERR: %d\n", retval); | 165 | printk(KERN_ERR " ERR: %d\n", retval); |
166 | return retval; | 166 | return retval; |
167 | } | 167 | } |
168 | 168 | ||
@@ -194,12 +194,12 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
194 | 194 | ||
195 | if (i2c_debug) { | 195 | if (i2c_debug) { |
196 | if (joined) | 196 | if (joined) |
197 | printk(" R"); | 197 | dprintk(1, " R"); |
198 | else | 198 | else |
199 | printk(" <R %02x", (msg->addr << 1) + 1); | 199 | dprintk(1, " <R %02x", (msg->addr << 1) + 1); |
200 | } | 200 | } |
201 | 201 | ||
202 | for(cnt = 0; cnt < msg->len; cnt++) { | 202 | for (cnt = 0; cnt < msg->len; cnt++) { |
203 | 203 | ||
204 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; | 204 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1; |
205 | 205 | ||
@@ -216,9 +216,9 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
216 | goto eio; | 216 | goto eio; |
217 | msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; | 217 | msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff; |
218 | if (i2c_debug) { | 218 | if (i2c_debug) { |
219 | printk(" %02x", msg->buf[cnt]); | 219 | dprintk(1, " %02x", msg->buf[cnt]); |
220 | if (!(ctrl & I2C_NOSTOP)) | 220 | if (!(ctrl & I2C_NOSTOP)) |
221 | printk(" >\n"); | 221 | dprintk(1, " >\n"); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | return msg->len; | 224 | return msg->len; |
@@ -227,7 +227,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
227 | retval = -EIO; | 227 | retval = -EIO; |
228 | err: | 228 | err: |
229 | if (i2c_debug) | 229 | if (i2c_debug) |
230 | printk(" ERR: %d\n", retval); | 230 | printk(KERN_ERR " ERR: %d\n", retval); |
231 | return retval; | 231 | return retval; |
232 | } | 232 | } |
233 | 233 | ||
@@ -353,17 +353,17 @@ static struct i2c_client cx23885_i2c_client_template = { | |||
353 | }; | 353 | }; |
354 | 354 | ||
355 | static char *i2c_devs[128] = { | 355 | static char *i2c_devs[128] = { |
356 | [0x10 >> 1] = "tda10048", | 356 | [0x10 >> 1] = "tda10048", |
357 | [0x12 >> 1] = "dib7000pc", | 357 | [0x12 >> 1] = "dib7000pc", |
358 | [ 0x1c >> 1 ] = "lgdt3303", | 358 | [0x1c >> 1] = "lgdt3303", |
359 | [ 0x86 >> 1 ] = "tda9887", | 359 | [0x86 >> 1] = "tda9887", |
360 | [ 0x32 >> 1 ] = "cx24227", | 360 | [0x32 >> 1] = "cx24227", |
361 | [ 0x88 >> 1 ] = "cx25837", | 361 | [0x88 >> 1] = "cx25837", |
362 | [ 0x84 >> 1 ] = "tda8295", | 362 | [0x84 >> 1] = "tda8295", |
363 | [ 0xa0 >> 1 ] = "eeprom", | 363 | [0xa0 >> 1] = "eeprom", |
364 | [ 0xc0 >> 1 ] = "tuner/mt2131/tda8275", | 364 | [0xc0 >> 1] = "tuner/mt2131/tda8275", |
365 | [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", | 365 | [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", |
366 | [0xc8 >> 1] = "tuner/xc3028L", | 366 | [0xc8 >> 1] = "tuner/xc3028L", |
367 | }; | 367 | }; |
368 | 368 | ||
369 | static void do_i2c_scan(char *name, struct i2c_client *c) | 369 | static void do_i2c_scan(char *name, struct i2c_client *c) |
@@ -376,7 +376,7 @@ static void do_i2c_scan(char *name, struct i2c_client *c) | |||
376 | rc = i2c_master_recv(c, &buf, 0); | 376 | rc = i2c_master_recv(c, &buf, 0); |
377 | if (rc < 0) | 377 | if (rc < 0) |
378 | continue; | 378 | continue; |
379 | printk("%s: i2c scan: found device @ 0x%x [%s]\n", | 379 | printk(KERN_INFO "%s: i2c scan: found device @ 0x%x [%s]\n", |
380 | name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); | 380 | name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); |
381 | } | 381 | } |
382 | } | 382 | } |
@@ -408,11 +408,12 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) | |||
408 | bus->i2c_client.adapter = &bus->i2c_adap; | 408 | bus->i2c_client.adapter = &bus->i2c_adap; |
409 | 409 | ||
410 | if (0 == bus->i2c_rc) { | 410 | if (0 == bus->i2c_rc) { |
411 | printk("%s: i2c bus %d registered\n", dev->name, bus->nr); | 411 | dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); |
412 | if (i2c_scan) | 412 | if (i2c_scan) |
413 | do_i2c_scan(dev->name, &bus->i2c_client); | 413 | do_i2c_scan(dev->name, &bus->i2c_client); |
414 | } else | 414 | } else |
415 | printk("%s: i2c bus %d register FAILED\n", dev->name, bus->nr); | 415 | printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", |
416 | dev->name, bus->nr); | ||
416 | 417 | ||
417 | return bus->i2c_rc; | 418 | return bus->i2c_rc; |
418 | } | 419 | } |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index f75ed1c9b71a..ab3110d6046c 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
@@ -285,11 +285,10 @@ static void cx23885_video_wakeup(struct cx23885_dev *dev, | |||
285 | list_del(&buf->vb.queue); | 285 | list_del(&buf->vb.queue); |
286 | wake_up(&buf->vb.done); | 286 | wake_up(&buf->vb.done); |
287 | } | 287 | } |
288 | if (list_empty(&q->active)) { | 288 | if (list_empty(&q->active)) |
289 | del_timer(&q->timeout); | 289 | del_timer(&q->timeout); |
290 | } else { | 290 | else |
291 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 291 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
292 | } | ||
293 | if (bc != 1) | 292 | if (bc != 1) |
294 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", | 293 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", |
295 | __func__, bc); | 294 | __func__, bc); |
@@ -379,12 +378,12 @@ static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, | |||
379 | 378 | ||
380 | static int res_check(struct cx23885_fh *fh, unsigned int bit) | 379 | static int res_check(struct cx23885_fh *fh, unsigned int bit) |
381 | { | 380 | { |
382 | return (fh->resources & bit); | 381 | return fh->resources & bit; |
383 | } | 382 | } |
384 | 383 | ||
385 | static int res_locked(struct cx23885_dev *dev, unsigned int bit) | 384 | static int res_locked(struct cx23885_dev *dev, unsigned int bit) |
386 | { | 385 | { |
387 | return (dev->resources & bit); | 386 | return dev->resources & bit; |
388 | } | 387 | } |
389 | 388 | ||
390 | static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, | 389 | static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, |
@@ -887,14 +886,16 @@ static int video_mmap(struct file *file, struct vm_area_struct *vma) | |||
887 | /* ------------------------------------------------------------------ */ | 886 | /* ------------------------------------------------------------------ */ |
888 | /* VIDEO CTRL IOCTLS */ | 887 | /* VIDEO CTRL IOCTLS */ |
889 | 888 | ||
890 | static int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) | 889 | static int cx23885_get_control(struct cx23885_dev *dev, |
890 | struct v4l2_control *ctl) | ||
891 | { | 891 | { |
892 | dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); | 892 | dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); |
893 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); | 893 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); |
894 | return 0; | 894 | return 0; |
895 | } | 895 | } |
896 | 896 | ||
897 | static int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) | 897 | static int cx23885_set_control(struct cx23885_dev *dev, |
898 | struct v4l2_control *ctl) | ||
898 | { | 899 | { |
899 | dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" | 900 | dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" |
900 | " (disabled - no action)\n", __func__); | 901 | " (disabled - no action)\n", __func__); |
@@ -1073,29 +1074,29 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
1073 | struct v4l2_requestbuffers *p) | 1074 | struct v4l2_requestbuffers *p) |
1074 | { | 1075 | { |
1075 | struct cx23885_fh *fh = priv; | 1076 | struct cx23885_fh *fh = priv; |
1076 | return (videobuf_reqbufs(get_queue(fh), p)); | 1077 | return videobuf_reqbufs(get_queue(fh), p); |
1077 | } | 1078 | } |
1078 | 1079 | ||
1079 | static int vidioc_querybuf(struct file *file, void *priv, | 1080 | static int vidioc_querybuf(struct file *file, void *priv, |
1080 | struct v4l2_buffer *p) | 1081 | struct v4l2_buffer *p) |
1081 | { | 1082 | { |
1082 | struct cx23885_fh *fh = priv; | 1083 | struct cx23885_fh *fh = priv; |
1083 | return (videobuf_querybuf(get_queue(fh), p)); | 1084 | return videobuf_querybuf(get_queue(fh), p); |
1084 | } | 1085 | } |
1085 | 1086 | ||
1086 | static int vidioc_qbuf(struct file *file, void *priv, | 1087 | static int vidioc_qbuf(struct file *file, void *priv, |
1087 | struct v4l2_buffer *p) | 1088 | struct v4l2_buffer *p) |
1088 | { | 1089 | { |
1089 | struct cx23885_fh *fh = priv; | 1090 | struct cx23885_fh *fh = priv; |
1090 | return (videobuf_qbuf(get_queue(fh), p)); | 1091 | return videobuf_qbuf(get_queue(fh), p); |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | static int vidioc_dqbuf(struct file *file, void *priv, | 1094 | static int vidioc_dqbuf(struct file *file, void *priv, |
1094 | struct v4l2_buffer *p) | 1095 | struct v4l2_buffer *p) |
1095 | { | 1096 | { |
1096 | struct cx23885_fh *fh = priv; | 1097 | struct cx23885_fh *fh = priv; |
1097 | return (videobuf_dqbuf(get_queue(fh), p, | 1098 | return videobuf_dqbuf(get_queue(fh), p, |
1098 | file->f_flags & O_NONBLOCK)); | 1099 | file->f_flags & O_NONBLOCK); |
1099 | } | 1100 | } |
1100 | 1101 | ||
1101 | static int vidioc_streamon(struct file *file, void *priv, | 1102 | static int vidioc_streamon(struct file *file, void *priv, |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index ba4e0aaed463..1d53f54cd943 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/version.h> | 37 | #include <linux/version.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | 39 | ||
40 | #define CX23885_VERSION_CODE KERNEL_VERSION(0,0,1) | 40 | #define CX23885_VERSION_CODE KERNEL_VERSION(0, 0, 1) |
41 | 41 | ||
42 | #define UNSET (-1U) | 42 | #define UNSET (-1U) |
43 | 43 | ||
@@ -225,7 +225,7 @@ struct cx23885_tsport { | |||
225 | int nr; | 225 | int nr; |
226 | int sram_chno; | 226 | int sram_chno; |
227 | 227 | ||
228 | struct videobuf_dvb dvb; | 228 | struct videobuf_dvb_frontends frontends; |
229 | 229 | ||
230 | /* dma queues */ | 230 | /* dma queues */ |
231 | struct cx23885_dmaqueue mpegq; | 231 | struct cx23885_dmaqueue mpegq; |
@@ -262,6 +262,9 @@ struct cx23885_tsport { | |||
262 | u32 src_sel_val; | 262 | u32 src_sel_val; |
263 | u32 vld_misc_val; | 263 | u32 vld_misc_val; |
264 | u32 hw_sop_ctrl_val; | 264 | u32 hw_sop_ctrl_val; |
265 | |||
266 | /* Allow a single tsport to have multiple frontends */ | ||
267 | u32 num_frontends; | ||
265 | }; | 268 | }; |
266 | 269 | ||
267 | struct cx23885_dev { | 270 | struct cx23885_dev { |
@@ -367,14 +370,14 @@ struct sram_channel { | |||
367 | /* ----------------------------------------------------------- */ | 370 | /* ----------------------------------------------------------- */ |
368 | 371 | ||
369 | #define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) | 372 | #define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) |
370 | #define cx_write(reg,value) writel((value), dev->lmmio + ((reg)>>2)) | 373 | #define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) |
371 | 374 | ||
372 | #define cx_andor(reg,mask,value) \ | 375 | #define cx_andor(reg, mask, value) \ |
373 | writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ | 376 | writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\ |
374 | ((value) & (mask)), dev->lmmio+((reg)>>2)) | 377 | ((value) & (mask)), dev->lmmio+((reg)>>2)) |
375 | 378 | ||
376 | #define cx_set(reg,bit) cx_andor((reg),(bit),(bit)) | 379 | #define cx_set(reg, bit) cx_andor((reg), (bit), (bit)) |
377 | #define cx_clear(reg,bit) cx_andor((reg),(bit),0) | 380 | #define cx_clear(reg, bit) cx_andor((reg), (bit), 0) |
378 | 381 | ||
379 | /* ----------------------------------------------------------- */ | 382 | /* ----------------------------------------------------------- */ |
380 | /* cx23885-core.c */ | 383 | /* cx23885-core.c */ |
@@ -411,7 +414,8 @@ extern const unsigned int cx23885_bcount; | |||
411 | extern struct cx23885_subid cx23885_subids[]; | 414 | extern struct cx23885_subid cx23885_subids[]; |
412 | extern const unsigned int cx23885_idcount; | 415 | extern const unsigned int cx23885_idcount; |
413 | 416 | ||
414 | extern int cx23885_tuner_callback(void *priv, int component, int command, int arg); | 417 | extern int cx23885_tuner_callback(void *priv, int component, |
418 | int command, int arg); | ||
415 | extern void cx23885_card_list(struct cx23885_dev *dev); | 419 | extern void cx23885_card_list(struct cx23885_dev *dev); |
416 | extern int cx23885_ir_init(struct cx23885_dev *dev); | 420 | extern int cx23885_ir_init(struct cx23885_dev *dev); |
417 | extern void cx23885_gpio_setup(struct cx23885_dev *dev); | 421 | extern void cx23885_gpio_setup(struct cx23885_dev *dev); |
@@ -479,11 +483,3 @@ static inline unsigned int norm_swidth(v4l2_std_id norm) | |||
479 | { | 483 | { |
480 | return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; | 484 | return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922; |
481 | } | 485 | } |
482 | |||
483 | |||
484 | /* | ||
485 | * Local variables: | ||
486 | * c-basic-offset: 8 | ||
487 | * End: | ||
488 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | ||
489 | */ | ||
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 5da04e811ca2..fbc224f46e0e 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
@@ -1270,27 +1270,40 @@ static const struct cx88_board cx88_boards[] = { | |||
1270 | .mpeg = CX88_MPEG_DVB, | 1270 | .mpeg = CX88_MPEG_DVB, |
1271 | }, | 1271 | }, |
1272 | [CX88_BOARD_HAUPPAUGE_HVR3000] = { | 1272 | [CX88_BOARD_HAUPPAUGE_HVR3000] = { |
1273 | /* FIXME: Add dvb & radio support */ | ||
1274 | .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T", | 1273 | .name = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T", |
1275 | .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, | 1274 | .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, |
1276 | .radio_type = UNSET, | 1275 | .radio_type = UNSET, |
1277 | .tuner_addr = ADDR_UNSET, | 1276 | .tuner_addr = ADDR_UNSET, |
1278 | .radio_addr = ADDR_UNSET, | 1277 | .radio_addr = ADDR_UNSET, |
1279 | .tda9887_conf = TDA9887_PRESENT, | 1278 | .tda9887_conf = TDA9887_PRESENT, |
1279 | .audio_chip = V4L2_IDENT_WM8775, | ||
1280 | .input = {{ | 1280 | .input = {{ |
1281 | .type = CX88_VMUX_TELEVISION, | 1281 | .type = CX88_VMUX_TELEVISION, |
1282 | .vmux = 0, | 1282 | .vmux = 0, |
1283 | .gpio0 = 0x84bf, | 1283 | .gpio0 = 0x84bf, |
1284 | /* 1: TV Audio / FM Mono */ | ||
1285 | .audioroute = 1, | ||
1284 | },{ | 1286 | },{ |
1285 | .type = CX88_VMUX_COMPOSITE1, | 1287 | .type = CX88_VMUX_COMPOSITE1, |
1286 | .vmux = 1, | 1288 | .vmux = 1, |
1287 | .gpio0 = 0x84bf, | 1289 | .gpio0 = 0x84bf, |
1290 | /* 2: Line-In */ | ||
1291 | .audioroute = 2, | ||
1288 | },{ | 1292 | },{ |
1289 | .type = CX88_VMUX_SVIDEO, | 1293 | .type = CX88_VMUX_SVIDEO, |
1290 | .vmux = 2, | 1294 | .vmux = 2, |
1291 | .gpio0 = 0x84bf, | 1295 | .gpio0 = 0x84bf, |
1296 | /* 2: Line-In */ | ||
1297 | .audioroute = 2, | ||
1292 | }}, | 1298 | }}, |
1299 | .radio = { | ||
1300 | .type = CX88_RADIO, | ||
1301 | .gpio0 = 0x84bf, | ||
1302 | /* 4: FM Stereo (untested) */ | ||
1303 | .audioroute = 8, | ||
1304 | }, | ||
1293 | .mpeg = CX88_MPEG_DVB, | 1305 | .mpeg = CX88_MPEG_DVB, |
1306 | .num_frontends = 2, | ||
1294 | }, | 1307 | }, |
1295 | [CX88_BOARD_NORWOOD_MICRO] = { | 1308 | [CX88_BOARD_NORWOOD_MICRO] = { |
1296 | .name = "Norwood Micro TV Tuner", | 1309 | .name = "Norwood Micro TV Tuner", |
@@ -1356,23 +1369,27 @@ static const struct cx88_board cx88_boards[] = { | |||
1356 | .type = CX88_VMUX_TELEVISION, | 1369 | .type = CX88_VMUX_TELEVISION, |
1357 | .vmux = 0, | 1370 | .vmux = 0, |
1358 | .gpio0 = 0xef88, | 1371 | .gpio0 = 0xef88, |
1372 | /* 1: TV Audio / FM Mono */ | ||
1359 | .audioroute = 1, | 1373 | .audioroute = 1, |
1360 | },{ | 1374 | },{ |
1361 | .type = CX88_VMUX_COMPOSITE1, | 1375 | .type = CX88_VMUX_COMPOSITE1, |
1362 | .vmux = 1, | 1376 | .vmux = 1, |
1363 | .gpio0 = 0xef88, | 1377 | .gpio0 = 0xef88, |
1378 | /* 2: Line-In */ | ||
1364 | .audioroute = 2, | 1379 | .audioroute = 2, |
1365 | },{ | 1380 | },{ |
1366 | .type = CX88_VMUX_SVIDEO, | 1381 | .type = CX88_VMUX_SVIDEO, |
1367 | .vmux = 2, | 1382 | .vmux = 2, |
1368 | .gpio0 = 0xef88, | 1383 | .gpio0 = 0xef88, |
1384 | /* 2: Line-In */ | ||
1369 | .audioroute = 2, | 1385 | .audioroute = 2, |
1370 | }}, | 1386 | }}, |
1371 | /* fixme: Add radio support */ | ||
1372 | .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, | 1387 | .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, |
1373 | .radio = { | 1388 | .radio = { |
1374 | .type = CX88_RADIO, | 1389 | .type = CX88_RADIO, |
1375 | .gpio0 = 0xef88, | 1390 | .gpio0 = 0xef88, |
1391 | /* 4: FM Stereo (untested) */ | ||
1392 | .audioroute = 8, | ||
1376 | }, | 1393 | }, |
1377 | }, | 1394 | }, |
1378 | [CX88_BOARD_ADSTECH_PTV_390] = { | 1395 | [CX88_BOARD_ADSTECH_PTV_390] = { |
@@ -1716,6 +1733,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1716 | .tuner_addr = ADDR_UNSET, | 1733 | .tuner_addr = ADDR_UNSET, |
1717 | .radio_addr = ADDR_UNSET, | 1734 | .radio_addr = ADDR_UNSET, |
1718 | .tda9887_conf = TDA9887_PRESENT, | 1735 | .tda9887_conf = TDA9887_PRESENT, |
1736 | .audio_chip = V4L2_IDENT_WM8775, | ||
1719 | /* | 1737 | /* |
1720 | * GPIO0 (WINTV2000) | 1738 | * GPIO0 (WINTV2000) |
1721 | * | 1739 | * |
@@ -1729,7 +1747,7 @@ static const struct cx88_board cx88_boards[] = { | |||
1729 | * BIT VALUE FUNCTION GP{x}_IO | 1747 | * BIT VALUE FUNCTION GP{x}_IO |
1730 | * 0 1 I:? | 1748 | * 0 1 I:? |
1731 | * 1 1 I:? | 1749 | * 1 1 I:? |
1732 | * 2 1 O:DVB-T DEMOD ENABLE LOW/ANALOG DEMOD ENABLE HIGH | 1750 | * 2 1 O:MPEG PORT 0=DVB-T 1=DVB-S |
1733 | * 3 1 I:? | 1751 | * 3 1 I:? |
1734 | * 4 1 I:? | 1752 | * 4 1 I:? |
1735 | * 5 1 I:? | 1753 | * 5 1 I:? |
@@ -1745,22 +1763,41 @@ static const struct cx88_board cx88_boards[] = { | |||
1745 | * d 0 I | 1763 | * d 0 I |
1746 | * e 1 O | 1764 | * e 1 O |
1747 | * f 1 O | 1765 | * f 1 O |
1766 | * | ||
1767 | * WM8775 ADC | ||
1768 | * | ||
1769 | * 1: TV Audio / FM Mono | ||
1770 | * 2: Line-In | ||
1771 | * 3: Line-In Expansion | ||
1772 | * 4: FM Stereo | ||
1748 | */ | 1773 | */ |
1749 | .input = {{ | 1774 | .input = {{ |
1750 | .type = CX88_VMUX_TELEVISION, | 1775 | .type = CX88_VMUX_TELEVISION, |
1751 | .vmux = 0, | 1776 | .vmux = 0, |
1752 | .gpio0 = 0xc4bf, | 1777 | .gpio0 = 0xc4bf, |
1778 | /* 1: TV Audio / FM Mono */ | ||
1779 | .audioroute = 1, | ||
1753 | }, { | 1780 | }, { |
1754 | .type = CX88_VMUX_COMPOSITE1, | 1781 | .type = CX88_VMUX_COMPOSITE1, |
1755 | .vmux = 1, | 1782 | .vmux = 1, |
1756 | .gpio0 = 0xc4bf, | 1783 | .gpio0 = 0xc4bf, |
1784 | /* 2: Line-In */ | ||
1785 | .audioroute = 2, | ||
1757 | }, { | 1786 | }, { |
1758 | .type = CX88_VMUX_SVIDEO, | 1787 | .type = CX88_VMUX_SVIDEO, |
1759 | .vmux = 2, | 1788 | .vmux = 2, |
1760 | .gpio0 = 0xc4bf, | 1789 | .gpio0 = 0xc4bf, |
1790 | /* 2: Line-In */ | ||
1791 | .audioroute = 2, | ||
1761 | } }, | 1792 | } }, |
1762 | /* fixme: Add radio support */ | 1793 | .radio = { |
1794 | .type = CX88_RADIO, | ||
1795 | .gpio0 = 0xc4bf, | ||
1796 | /* 4: FM Stereo */ | ||
1797 | .audioroute = 8, | ||
1798 | }, | ||
1763 | .mpeg = CX88_MPEG_DVB, | 1799 | .mpeg = CX88_MPEG_DVB, |
1800 | .num_frontends = 2, | ||
1764 | }, | 1801 | }, |
1765 | [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = { | 1802 | [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = { |
1766 | .name = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2", | 1803 | .name = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2", |
@@ -2662,10 +2699,13 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) | |||
2662 | 2699 | ||
2663 | case CX88_BOARD_HAUPPAUGE_HVR3000: | 2700 | case CX88_BOARD_HAUPPAUGE_HVR3000: |
2664 | case CX88_BOARD_HAUPPAUGE_HVR4000: | 2701 | case CX88_BOARD_HAUPPAUGE_HVR4000: |
2665 | case CX88_BOARD_HAUPPAUGE_HVR4000LITE: | ||
2666 | /* Init GPIO */ | 2702 | /* Init GPIO */ |
2667 | cx_write(MO_GP0_IO, core->board.input[0].gpio0); | 2703 | cx_write(MO_GP0_IO, core->board.input[0].gpio0); |
2668 | udelay(1000); | 2704 | udelay(1000); |
2705 | cx_clear(MO_GP0_IO, 0x00000080); | ||
2706 | udelay(50); | ||
2707 | cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */ | ||
2708 | udelay(1000); | ||
2669 | break; | 2709 | break; |
2670 | } | 2710 | } |
2671 | } | 2711 | } |
@@ -3004,10 +3044,14 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3004 | 3044 | ||
3005 | memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); | 3045 | memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); |
3006 | 3046 | ||
3007 | info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s]\n", | 3047 | if (!core->board.num_frontends) |
3048 | core->board.num_frontends=1; | ||
3049 | |||
3050 | info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n", | ||
3008 | pci->subsystem_vendor, pci->subsystem_device, core->board.name, | 3051 | pci->subsystem_vendor, pci->subsystem_device, core->board.name, |
3009 | core->boardnr, card[core->nr] == core->boardnr ? | 3052 | core->boardnr, card[core->nr] == core->boardnr ? |
3010 | "insmod option" : "autodetected"); | 3053 | "insmod option" : "autodetected", |
3054 | core->board.num_frontends); | ||
3011 | 3055 | ||
3012 | if (tuner[core->nr] != UNSET) | 3056 | if (tuner[core->nr] != UNSET) |
3013 | core->board.tuner_type = tuner[core->nr]; | 3057 | core->board.tuner_type = tuner[core->nr]; |
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index d656fec59010..60705b08bfe8 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
@@ -549,7 +549,8 @@ void cx88_wakeup(struct cx88_core *core, | |||
549 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 549 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
550 | } | 550 | } |
551 | if (bc != 1) | 551 | if (bc != 1) |
552 | printk("%s: %d buffers handled (should be 1)\n",__func__,bc); | 552 | dprintk(2, "%s: %d buffers handled (should be 1)\n", |
553 | __func__, bc); | ||
553 | } | 554 | } |
554 | 555 | ||
555 | void cx88_shutdown(struct cx88_core *core) | 556 | void cx88_shutdown(struct cx88_core *core) |
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index 344ed2626e59..6968ab0181aa 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
@@ -116,13 +116,23 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire) | |||
116 | struct cx8802_dev *dev= fe->dvb->priv; | 116 | struct cx8802_dev *dev= fe->dvb->priv; |
117 | struct cx8802_driver *drv = NULL; | 117 | struct cx8802_driver *drv = NULL; |
118 | int ret = 0; | 118 | int ret = 0; |
119 | int fe_id; | ||
120 | |||
121 | fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe); | ||
122 | if (!fe_id) { | ||
123 | printk(KERN_ERR "%s() No frontend found\n", __func__); | ||
124 | return -EINVAL; | ||
125 | } | ||
119 | 126 | ||
120 | drv = cx8802_get_driver(dev, CX88_MPEG_DVB); | 127 | drv = cx8802_get_driver(dev, CX88_MPEG_DVB); |
121 | if (drv) { | 128 | if (drv) { |
122 | if (acquire) | 129 | if (acquire){ |
130 | dev->frontends.active_fe_id = fe_id; | ||
123 | ret = drv->request_acquire(drv); | 131 | ret = drv->request_acquire(drv); |
124 | else | 132 | } else { |
125 | ret = drv->request_release(drv); | 133 | ret = drv->request_release(drv); |
134 | dev->frontends.active_fe_id = 0; | ||
135 | } | ||
126 | } | 136 | } |
127 | 137 | ||
128 | return ret; | 138 | return ret; |
@@ -396,7 +406,7 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe, | |||
396 | cx_write(MO_GP0_IO, 0x00006060); | 406 | cx_write(MO_GP0_IO, 0x00006060); |
397 | break; | 407 | break; |
398 | case SEC_VOLTAGE_OFF: | 408 | case SEC_VOLTAGE_OFF: |
399 | printk("LNB Voltage SEC_VOLTAGE_off\n"); | 409 | printk("LNB Voltage SEC_VOLTAGE_off\n"); |
400 | break; | 410 | break; |
401 | } | 411 | } |
402 | 412 | ||
@@ -483,6 +493,7 @@ static struct xc5000_config dvico_fusionhdtv7_tuner_config = { | |||
483 | static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | 493 | static int attach_xc3028(u8 addr, struct cx8802_dev *dev) |
484 | { | 494 | { |
485 | struct dvb_frontend *fe; | 495 | struct dvb_frontend *fe; |
496 | struct videobuf_dvb_frontend *fe0 = NULL; | ||
486 | struct xc2028_ctrl ctl; | 497 | struct xc2028_ctrl ctl; |
487 | struct xc2028_config cfg = { | 498 | struct xc2028_config cfg = { |
488 | .i2c_adap = &dev->core->i2c_adap, | 499 | .i2c_adap = &dev->core->i2c_adap, |
@@ -490,7 +501,12 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
490 | .ctrl = &ctl, | 501 | .ctrl = &ctl, |
491 | }; | 502 | }; |
492 | 503 | ||
493 | if (!dev->dvb.frontend) { | 504 | /* Get the first frontend */ |
505 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | ||
506 | if (!fe0) | ||
507 | return -EINVAL; | ||
508 | |||
509 | if (!fe0->dvb.frontend) { | ||
494 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | 510 | printk(KERN_ERR "%s/2: dvb frontend not attached. " |
495 | "Can't attach xc3028\n", | 511 | "Can't attach xc3028\n", |
496 | dev->core->name); | 512 | dev->core->name); |
@@ -504,10 +520,13 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | |||
504 | */ | 520 | */ |
505 | cx88_setup_xc3028(dev->core, &ctl); | 521 | cx88_setup_xc3028(dev->core, &ctl); |
506 | 522 | ||
507 | fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | 523 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); |
508 | if (!fe) { | 524 | if (!fe) { |
509 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 525 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
510 | dev->core->name); | 526 | dev->core->name); |
527 | dvb_frontend_detach(fe0->dvb.frontend); | ||
528 | dvb_unregister_frontend(fe0->dvb.frontend); | ||
529 | fe0->dvb.frontend = NULL; | ||
511 | return -EINVAL; | 530 | return -EINVAL; |
512 | } | 531 | } |
513 | 532 | ||
@@ -532,8 +551,10 @@ static int cx24116_reset_device(struct dvb_frontend *fe) | |||
532 | struct cx88_core *core = dev->core; | 551 | struct cx88_core *core = dev->core; |
533 | 552 | ||
534 | /* Reset the part */ | 553 | /* Reset the part */ |
554 | /* Put the cx24116 into reset */ | ||
535 | cx_write(MO_SRST_IO, 0); | 555 | cx_write(MO_SRST_IO, 0); |
536 | msleep(10); | 556 | msleep(10); |
557 | /* Take the cx24116 out of reset */ | ||
537 | cx_write(MO_SRST_IO, 1); | 558 | cx_write(MO_SRST_IO, 1); |
538 | msleep(10); | 559 | msleep(10); |
539 | 560 | ||
@@ -554,14 +575,14 @@ static struct cx24116_config tevii_s460_config = { | |||
554 | 575 | ||
555 | static struct stv0299_config tevii_tuner_sharp_config = { | 576 | static struct stv0299_config tevii_tuner_sharp_config = { |
556 | .demod_address = 0x68, | 577 | .demod_address = 0x68, |
557 | .inittab = sharp_z0194a__inittab, | 578 | .inittab = sharp_z0194a_inittab, |
558 | .mclk = 88000000UL, | 579 | .mclk = 88000000UL, |
559 | .invert = 1, | 580 | .invert = 1, |
560 | .skip_reinit = 0, | 581 | .skip_reinit = 0, |
561 | .lock_output = 1, | 582 | .lock_output = 1, |
562 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 583 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
563 | .min_delay_ms = 100, | 584 | .min_delay_ms = 100, |
564 | .set_symbol_rate = sharp_z0194a__set_symbol_rate, | 585 | .set_symbol_rate = sharp_z0194a_set_symbol_rate, |
565 | .set_ts_params = cx24116_set_ts_param, | 586 | .set_ts_params = cx24116_set_ts_param, |
566 | }; | 587 | }; |
567 | 588 | ||
@@ -574,19 +595,25 @@ static struct stv0288_config tevii_tuner_earda_config = { | |||
574 | static int dvb_register(struct cx8802_dev *dev) | 595 | static int dvb_register(struct cx8802_dev *dev) |
575 | { | 596 | { |
576 | struct cx88_core *core = dev->core; | 597 | struct cx88_core *core = dev->core; |
598 | struct videobuf_dvb_frontend *fe0, *fe1 = NULL; | ||
599 | int mfe_shared = 0; /* bus not shared by default */ | ||
577 | 600 | ||
578 | /* init struct videobuf_dvb */ | 601 | /* Get the first frontend */ |
579 | dev->dvb.name = core->name; | 602 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); |
580 | dev->ts_gen_cntrl = 0x0c; | 603 | if (!fe0) |
604 | return -EINVAL; | ||
581 | 605 | ||
582 | /* init frontend */ | 606 | /* multi-frontend gate control is undefined or defaults to fe0 */ |
607 | dev->frontends.gate = 0; | ||
608 | |||
609 | /* init frontend(s) */ | ||
583 | switch (core->boardnr) { | 610 | switch (core->boardnr) { |
584 | case CX88_BOARD_HAUPPAUGE_DVB_T1: | 611 | case CX88_BOARD_HAUPPAUGE_DVB_T1: |
585 | dev->dvb.frontend = dvb_attach(cx22702_attach, | 612 | fe0->dvb.frontend = dvb_attach(cx22702_attach, |
586 | &connexant_refboard_config, | 613 | &connexant_refboard_config, |
587 | &core->i2c_adap); | 614 | &core->i2c_adap); |
588 | if (dev->dvb.frontend != NULL) { | 615 | if (fe0->dvb.frontend != NULL) { |
589 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 616 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
590 | 0x61, &core->i2c_adap, | 617 | 0x61, &core->i2c_adap, |
591 | DVB_PLL_THOMSON_DTT759X)) | 618 | DVB_PLL_THOMSON_DTT759X)) |
592 | goto frontend_detach; | 619 | goto frontend_detach; |
@@ -596,11 +623,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
596 | case CX88_BOARD_CONEXANT_DVB_T1: | 623 | case CX88_BOARD_CONEXANT_DVB_T1: |
597 | case CX88_BOARD_KWORLD_DVB_T_CX22702: | 624 | case CX88_BOARD_KWORLD_DVB_T_CX22702: |
598 | case CX88_BOARD_WINFAST_DTV1000: | 625 | case CX88_BOARD_WINFAST_DTV1000: |
599 | dev->dvb.frontend = dvb_attach(cx22702_attach, | 626 | fe0->dvb.frontend = dvb_attach(cx22702_attach, |
600 | &connexant_refboard_config, | 627 | &connexant_refboard_config, |
601 | &core->i2c_adap); | 628 | &core->i2c_adap); |
602 | if (dev->dvb.frontend != NULL) { | 629 | if (fe0->dvb.frontend != NULL) { |
603 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 630 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
604 | 0x60, &core->i2c_adap, | 631 | 0x60, &core->i2c_adap, |
605 | DVB_PLL_THOMSON_DTT7579)) | 632 | DVB_PLL_THOMSON_DTT7579)) |
606 | goto frontend_detach; | 633 | goto frontend_detach; |
@@ -610,33 +637,67 @@ static int dvb_register(struct cx8802_dev *dev) | |||
610 | case CX88_BOARD_HAUPPAUGE_HVR1100: | 637 | case CX88_BOARD_HAUPPAUGE_HVR1100: |
611 | case CX88_BOARD_HAUPPAUGE_HVR1100LP: | 638 | case CX88_BOARD_HAUPPAUGE_HVR1100LP: |
612 | case CX88_BOARD_HAUPPAUGE_HVR1300: | 639 | case CX88_BOARD_HAUPPAUGE_HVR1300: |
613 | case CX88_BOARD_HAUPPAUGE_HVR3000: | 640 | fe0->dvb.frontend = dvb_attach(cx22702_attach, |
614 | dev->dvb.frontend = dvb_attach(cx22702_attach, | ||
615 | &hauppauge_hvr_config, | 641 | &hauppauge_hvr_config, |
616 | &core->i2c_adap); | 642 | &core->i2c_adap); |
617 | if (dev->dvb.frontend != NULL) { | 643 | if (fe0->dvb.frontend != NULL) { |
618 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 644 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
619 | &core->i2c_adap, 0x61, | 645 | &core->i2c_adap, 0x61, |
620 | TUNER_PHILIPS_FMD1216ME_MK3)) | 646 | TUNER_PHILIPS_FMD1216ME_MK3)) |
621 | goto frontend_detach; | 647 | goto frontend_detach; |
622 | } | 648 | } |
623 | break; | 649 | break; |
650 | case CX88_BOARD_HAUPPAUGE_HVR3000: | ||
651 | /* DVB-S init */ | ||
652 | fe0->dvb.frontend = dvb_attach(cx24123_attach, | ||
653 | &hauppauge_novas_config, | ||
654 | &dev->core->i2c_adap); | ||
655 | if (fe0->dvb.frontend) { | ||
656 | if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, | ||
657 | &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { | ||
658 | dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __func__); | ||
659 | } | ||
660 | } else { | ||
661 | dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __func__); | ||
662 | } | ||
663 | /* DVB-T init */ | ||
664 | fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); | ||
665 | if (fe1) { | ||
666 | dev->frontends.gate = 2; | ||
667 | mfe_shared = 1; | ||
668 | fe1->dvb.frontend = dvb_attach(cx22702_attach, | ||
669 | &hauppauge_hvr_config, | ||
670 | &dev->core->i2c_adap); | ||
671 | if (fe1->dvb.frontend) { | ||
672 | fe1->dvb.frontend->id = 1; | ||
673 | if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, | ||
674 | &dev->core->i2c_adap, 0x61, | ||
675 | TUNER_PHILIPS_FMD1216ME_MK3)) { | ||
676 | dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __func__); | ||
677 | } | ||
678 | } else { | ||
679 | dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __func__); | ||
680 | } | ||
681 | } else { | ||
682 | dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __func__); | ||
683 | } | ||
684 | break; | ||
624 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: | 685 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: |
625 | dev->dvb.frontend = dvb_attach(mt352_attach, | 686 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
626 | &dvico_fusionhdtv, | 687 | &dvico_fusionhdtv, |
627 | &core->i2c_adap); | 688 | &core->i2c_adap); |
628 | if (dev->dvb.frontend != NULL) { | 689 | if (fe0->dvb.frontend != NULL) { |
629 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 690 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
630 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) | 691 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) |
631 | goto frontend_detach; | 692 | goto frontend_detach; |
632 | break; | 693 | break; |
633 | } | 694 | } |
634 | /* ZL10353 replaces MT352 on later cards */ | 695 | /* ZL10353 replaces MT352 on later cards */ |
635 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 696 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
636 | &dvico_fusionhdtv_plus_v1_1, | 697 | &dvico_fusionhdtv_plus_v1_1, |
637 | &core->i2c_adap); | 698 | &core->i2c_adap); |
638 | if (dev->dvb.frontend != NULL) { | 699 | if (fe0->dvb.frontend != NULL) { |
639 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 700 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
640 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) | 701 | 0x60, NULL, DVB_PLL_THOMSON_DTT7579)) |
641 | goto frontend_detach; | 702 | goto frontend_detach; |
642 | } | 703 | } |
@@ -644,31 +705,31 @@ static int dvb_register(struct cx8802_dev *dev) | |||
644 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: | 705 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: |
645 | /* The tin box says DEE1601, but it seems to be DTT7579 | 706 | /* The tin box says DEE1601, but it seems to be DTT7579 |
646 | * compatible, with a slightly different MT352 AGC gain. */ | 707 | * compatible, with a slightly different MT352 AGC gain. */ |
647 | dev->dvb.frontend = dvb_attach(mt352_attach, | 708 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
648 | &dvico_fusionhdtv_dual, | 709 | &dvico_fusionhdtv_dual, |
649 | &core->i2c_adap); | 710 | &core->i2c_adap); |
650 | if (dev->dvb.frontend != NULL) { | 711 | if (fe0->dvb.frontend != NULL) { |
651 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 712 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
652 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) | 713 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) |
653 | goto frontend_detach; | 714 | goto frontend_detach; |
654 | break; | 715 | break; |
655 | } | 716 | } |
656 | /* ZL10353 replaces MT352 on later cards */ | 717 | /* ZL10353 replaces MT352 on later cards */ |
657 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 718 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
658 | &dvico_fusionhdtv_plus_v1_1, | 719 | &dvico_fusionhdtv_plus_v1_1, |
659 | &core->i2c_adap); | 720 | &core->i2c_adap); |
660 | if (dev->dvb.frontend != NULL) { | 721 | if (fe0->dvb.frontend != NULL) { |
661 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 722 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
662 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) | 723 | 0x61, NULL, DVB_PLL_THOMSON_DTT7579)) |
663 | goto frontend_detach; | 724 | goto frontend_detach; |
664 | } | 725 | } |
665 | break; | 726 | break; |
666 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: | 727 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: |
667 | dev->dvb.frontend = dvb_attach(mt352_attach, | 728 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
668 | &dvico_fusionhdtv, | 729 | &dvico_fusionhdtv, |
669 | &core->i2c_adap); | 730 | &core->i2c_adap); |
670 | if (dev->dvb.frontend != NULL) { | 731 | if (fe0->dvb.frontend != NULL) { |
671 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 732 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
672 | 0x61, NULL, DVB_PLL_LG_Z201)) | 733 | 0x61, NULL, DVB_PLL_LG_Z201)) |
673 | goto frontend_detach; | 734 | goto frontend_detach; |
674 | } | 735 | } |
@@ -676,11 +737,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
676 | case CX88_BOARD_KWORLD_DVB_T: | 737 | case CX88_BOARD_KWORLD_DVB_T: |
677 | case CX88_BOARD_DNTV_LIVE_DVB_T: | 738 | case CX88_BOARD_DNTV_LIVE_DVB_T: |
678 | case CX88_BOARD_ADSTECH_DVB_T_PCI: | 739 | case CX88_BOARD_ADSTECH_DVB_T_PCI: |
679 | dev->dvb.frontend = dvb_attach(mt352_attach, | 740 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
680 | &dntv_live_dvbt_config, | 741 | &dntv_live_dvbt_config, |
681 | &core->i2c_adap); | 742 | &core->i2c_adap); |
682 | if (dev->dvb.frontend != NULL) { | 743 | if (fe0->dvb.frontend != NULL) { |
683 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, | 744 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, |
684 | 0x61, NULL, DVB_PLL_UNKNOWN_1)) | 745 | 0x61, NULL, DVB_PLL_UNKNOWN_1)) |
685 | goto frontend_detach; | 746 | goto frontend_detach; |
686 | } | 747 | } |
@@ -688,10 +749,10 @@ static int dvb_register(struct cx8802_dev *dev) | |||
688 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: | 749 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
689 | #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) | 750 | #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) |
690 | /* MT352 is on a secondary I2C bus made from some GPIO lines */ | 751 | /* MT352 is on a secondary I2C bus made from some GPIO lines */ |
691 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, | 752 | fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, |
692 | &dev->vp3054->adap); | 753 | &dev->vp3054->adap); |
693 | if (dev->dvb.frontend != NULL) { | 754 | if (fe0->dvb.frontend != NULL) { |
694 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 755 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
695 | &core->i2c_adap, 0x61, | 756 | &core->i2c_adap, 0x61, |
696 | TUNER_PHILIPS_FMD1216ME_MK3)) | 757 | TUNER_PHILIPS_FMD1216ME_MK3)) |
697 | goto frontend_detach; | 758 | goto frontend_detach; |
@@ -702,22 +763,22 @@ static int dvb_register(struct cx8802_dev *dev) | |||
702 | #endif | 763 | #endif |
703 | break; | 764 | break; |
704 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: | 765 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: |
705 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 766 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
706 | &dvico_fusionhdtv_hybrid, | 767 | &dvico_fusionhdtv_hybrid, |
707 | &core->i2c_adap); | 768 | &core->i2c_adap); |
708 | if (dev->dvb.frontend != NULL) { | 769 | if (fe0->dvb.frontend != NULL) { |
709 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 770 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
710 | &core->i2c_adap, 0x61, | 771 | &core->i2c_adap, 0x61, |
711 | TUNER_THOMSON_FE6600)) | 772 | TUNER_THOMSON_FE6600)) |
712 | goto frontend_detach; | 773 | goto frontend_detach; |
713 | } | 774 | } |
714 | break; | 775 | break; |
715 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | 776 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: |
716 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 777 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
717 | &dvico_fusionhdtv_xc3028, | 778 | &dvico_fusionhdtv_xc3028, |
718 | &core->i2c_adap); | 779 | &core->i2c_adap); |
719 | if (dev->dvb.frontend == NULL) | 780 | if (fe0->dvb.frontend == NULL) |
720 | dev->dvb.frontend = dvb_attach(mt352_attach, | 781 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
721 | &dvico_fusionhdtv_mt352_xc3028, | 782 | &dvico_fusionhdtv_mt352_xc3028, |
722 | &core->i2c_adap); | 783 | &core->i2c_adap); |
723 | /* | 784 | /* |
@@ -725,16 +786,16 @@ static int dvb_register(struct cx8802_dev *dev) | |||
725 | * We must not permit gate_ctrl to be performed, or | 786 | * We must not permit gate_ctrl to be performed, or |
726 | * the xc3028 cannot communicate on the bus. | 787 | * the xc3028 cannot communicate on the bus. |
727 | */ | 788 | */ |
728 | if (dev->dvb.frontend) | 789 | if (fe0->dvb.frontend) |
729 | dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; | 790 | fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; |
730 | if (attach_xc3028(0x61, dev) < 0) | 791 | if (attach_xc3028(0x61, dev) < 0) |
731 | return -EINVAL; | 792 | return -EINVAL; |
732 | break; | 793 | break; |
733 | case CX88_BOARD_PCHDTV_HD3000: | 794 | case CX88_BOARD_PCHDTV_HD3000: |
734 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, | 795 | fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, |
735 | &core->i2c_adap); | 796 | &core->i2c_adap); |
736 | if (dev->dvb.frontend != NULL) { | 797 | if (fe0->dvb.frontend != NULL) { |
737 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 798 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
738 | &core->i2c_adap, 0x61, | 799 | &core->i2c_adap, 0x61, |
739 | TUNER_THOMSON_DTT761X)) | 800 | TUNER_THOMSON_DTT761X)) |
740 | goto frontend_detach; | 801 | goto frontend_detach; |
@@ -751,11 +812,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
751 | 812 | ||
752 | /* Select RF connector callback */ | 813 | /* Select RF connector callback */ |
753 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; | 814 | fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; |
754 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 815 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
755 | &fusionhdtv_3_gold, | 816 | &fusionhdtv_3_gold, |
756 | &core->i2c_adap); | 817 | &core->i2c_adap); |
757 | if (dev->dvb.frontend != NULL) { | 818 | if (fe0->dvb.frontend != NULL) { |
758 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 819 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
759 | &core->i2c_adap, 0x61, | 820 | &core->i2c_adap, 0x61, |
760 | TUNER_MICROTUNE_4042FI5)) | 821 | TUNER_MICROTUNE_4042FI5)) |
761 | goto frontend_detach; | 822 | goto frontend_detach; |
@@ -769,11 +830,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
769 | mdelay(100); | 830 | mdelay(100); |
770 | cx_set(MO_GP0_IO, 9); | 831 | cx_set(MO_GP0_IO, 9); |
771 | mdelay(200); | 832 | mdelay(200); |
772 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 833 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
773 | &fusionhdtv_3_gold, | 834 | &fusionhdtv_3_gold, |
774 | &core->i2c_adap); | 835 | &core->i2c_adap); |
775 | if (dev->dvb.frontend != NULL) { | 836 | if (fe0->dvb.frontend != NULL) { |
776 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 837 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
777 | &core->i2c_adap, 0x61, | 838 | &core->i2c_adap, 0x61, |
778 | TUNER_THOMSON_DTT761X)) | 839 | TUNER_THOMSON_DTT761X)) |
779 | goto frontend_detach; | 840 | goto frontend_detach; |
@@ -787,15 +848,15 @@ static int dvb_register(struct cx8802_dev *dev) | |||
787 | mdelay(100); | 848 | mdelay(100); |
788 | cx_set(MO_GP0_IO, 1); | 849 | cx_set(MO_GP0_IO, 1); |
789 | mdelay(200); | 850 | mdelay(200); |
790 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 851 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
791 | &fusionhdtv_5_gold, | 852 | &fusionhdtv_5_gold, |
792 | &core->i2c_adap); | 853 | &core->i2c_adap); |
793 | if (dev->dvb.frontend != NULL) { | 854 | if (fe0->dvb.frontend != NULL) { |
794 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 855 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
795 | &core->i2c_adap, 0x61, | 856 | &core->i2c_adap, 0x61, |
796 | TUNER_LG_TDVS_H06XF)) | 857 | TUNER_LG_TDVS_H06XF)) |
797 | goto frontend_detach; | 858 | goto frontend_detach; |
798 | if (!dvb_attach(tda9887_attach, dev->dvb.frontend, | 859 | if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, |
799 | &core->i2c_adap, 0x43)) | 860 | &core->i2c_adap, 0x43)) |
800 | goto frontend_detach; | 861 | goto frontend_detach; |
801 | } | 862 | } |
@@ -808,25 +869,25 @@ static int dvb_register(struct cx8802_dev *dev) | |||
808 | mdelay(100); | 869 | mdelay(100); |
809 | cx_set(MO_GP0_IO, 1); | 870 | cx_set(MO_GP0_IO, 1); |
810 | mdelay(200); | 871 | mdelay(200); |
811 | dev->dvb.frontend = dvb_attach(lgdt330x_attach, | 872 | fe0->dvb.frontend = dvb_attach(lgdt330x_attach, |
812 | &pchdtv_hd5500, | 873 | &pchdtv_hd5500, |
813 | &core->i2c_adap); | 874 | &core->i2c_adap); |
814 | if (dev->dvb.frontend != NULL) { | 875 | if (fe0->dvb.frontend != NULL) { |
815 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 876 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
816 | &core->i2c_adap, 0x61, | 877 | &core->i2c_adap, 0x61, |
817 | TUNER_LG_TDVS_H06XF)) | 878 | TUNER_LG_TDVS_H06XF)) |
818 | goto frontend_detach; | 879 | goto frontend_detach; |
819 | if (!dvb_attach(tda9887_attach, dev->dvb.frontend, | 880 | if (!dvb_attach(tda9887_attach, fe0->dvb.frontend, |
820 | &core->i2c_adap, 0x43)) | 881 | &core->i2c_adap, 0x43)) |
821 | goto frontend_detach; | 882 | goto frontend_detach; |
822 | } | 883 | } |
823 | break; | 884 | break; |
824 | case CX88_BOARD_ATI_HDTVWONDER: | 885 | case CX88_BOARD_ATI_HDTVWONDER: |
825 | dev->dvb.frontend = dvb_attach(nxt200x_attach, | 886 | fe0->dvb.frontend = dvb_attach(nxt200x_attach, |
826 | &ati_hdtvwonder, | 887 | &ati_hdtvwonder, |
827 | &core->i2c_adap); | 888 | &core->i2c_adap); |
828 | if (dev->dvb.frontend != NULL) { | 889 | if (fe0->dvb.frontend != NULL) { |
829 | if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 890 | if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
830 | &core->i2c_adap, 0x61, | 891 | &core->i2c_adap, 0x61, |
831 | TUNER_PHILIPS_TUV1236D)) | 892 | TUNER_PHILIPS_TUV1236D)) |
832 | goto frontend_detach; | 893 | goto frontend_detach; |
@@ -834,49 +895,49 @@ static int dvb_register(struct cx8802_dev *dev) | |||
834 | break; | 895 | break; |
835 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: | 896 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
836 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: | 897 | case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: |
837 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 898 | fe0->dvb.frontend = dvb_attach(cx24123_attach, |
838 | &hauppauge_novas_config, | 899 | &hauppauge_novas_config, |
839 | &core->i2c_adap); | 900 | &core->i2c_adap); |
840 | if (dev->dvb.frontend) { | 901 | if (fe0->dvb.frontend) { |
841 | if (!dvb_attach(isl6421_attach, dev->dvb.frontend, | 902 | if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, |
842 | &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) | 903 | &core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) |
843 | goto frontend_detach; | 904 | goto frontend_detach; |
844 | } | 905 | } |
845 | break; | 906 | break; |
846 | case CX88_BOARD_KWORLD_DVBS_100: | 907 | case CX88_BOARD_KWORLD_DVBS_100: |
847 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 908 | fe0->dvb.frontend = dvb_attach(cx24123_attach, |
848 | &kworld_dvbs_100_config, | 909 | &kworld_dvbs_100_config, |
849 | &core->i2c_adap); | 910 | &core->i2c_adap); |
850 | if (dev->dvb.frontend) { | 911 | if (fe0->dvb.frontend) { |
851 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 912 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
852 | dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; | 913 | fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; |
853 | } | 914 | } |
854 | break; | 915 | break; |
855 | case CX88_BOARD_GENIATECH_DVBS: | 916 | case CX88_BOARD_GENIATECH_DVBS: |
856 | dev->dvb.frontend = dvb_attach(cx24123_attach, | 917 | fe0->dvb.frontend = dvb_attach(cx24123_attach, |
857 | &geniatech_dvbs_config, | 918 | &geniatech_dvbs_config, |
858 | &core->i2c_adap); | 919 | &core->i2c_adap); |
859 | if (dev->dvb.frontend) { | 920 | if (fe0->dvb.frontend) { |
860 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 921 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
861 | dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; | 922 | fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; |
862 | } | 923 | } |
863 | break; | 924 | break; |
864 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | 925 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: |
865 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 926 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
866 | &pinnacle_pctv_hd_800i_config, | 927 | &pinnacle_pctv_hd_800i_config, |
867 | &core->i2c_adap); | 928 | &core->i2c_adap); |
868 | if (dev->dvb.frontend != NULL) { | 929 | if (fe0->dvb.frontend != NULL) { |
869 | if (!dvb_attach(xc5000_attach, dev->dvb.frontend, | 930 | if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, |
870 | &core->i2c_adap, | 931 | &core->i2c_adap, |
871 | &pinnacle_pctv_hd_800i_tuner_config)) | 932 | &pinnacle_pctv_hd_800i_tuner_config)) |
872 | goto frontend_detach; | 933 | goto frontend_detach; |
873 | } | 934 | } |
874 | break; | 935 | break; |
875 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | 936 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: |
876 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 937 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
877 | &dvico_hdtv5_pci_nano_config, | 938 | &dvico_hdtv5_pci_nano_config, |
878 | &core->i2c_adap); | 939 | &core->i2c_adap); |
879 | if (dev->dvb.frontend != NULL) { | 940 | if (fe0->dvb.frontend != NULL) { |
880 | struct dvb_frontend *fe; | 941 | struct dvb_frontend *fe; |
881 | struct xc2028_config cfg = { | 942 | struct xc2028_config cfg = { |
882 | .i2c_adap = &core->i2c_adap, | 943 | .i2c_adap = &core->i2c_adap, |
@@ -889,17 +950,17 @@ static int dvb_register(struct cx8802_dev *dev) | |||
889 | }; | 950 | }; |
890 | 951 | ||
891 | fe = dvb_attach(xc2028_attach, | 952 | fe = dvb_attach(xc2028_attach, |
892 | dev->dvb.frontend, &cfg); | 953 | fe0->dvb.frontend, &cfg); |
893 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | 954 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) |
894 | fe->ops.tuner_ops.set_config(fe, &ctl); | 955 | fe->ops.tuner_ops.set_config(fe, &ctl); |
895 | } | 956 | } |
896 | break; | 957 | break; |
897 | case CX88_BOARD_PINNACLE_HYBRID_PCTV: | 958 | case CX88_BOARD_PINNACLE_HYBRID_PCTV: |
898 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 959 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
899 | &cx88_pinnacle_hybrid_pctv, | 960 | &cx88_pinnacle_hybrid_pctv, |
900 | &core->i2c_adap); | 961 | &core->i2c_adap); |
901 | if (dev->dvb.frontend) { | 962 | if (fe0->dvb.frontend) { |
902 | dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; | 963 | fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; |
903 | if (attach_xc3028(0x61, dev) < 0) | 964 | if (attach_xc3028(0x61, dev) < 0) |
904 | goto frontend_detach; | 965 | goto frontend_detach; |
905 | } | 966 | } |
@@ -907,85 +968,118 @@ static int dvb_register(struct cx8802_dev *dev) | |||
907 | case CX88_BOARD_GENIATECH_X8000_MT: | 968 | case CX88_BOARD_GENIATECH_X8000_MT: |
908 | dev->ts_gen_cntrl = 0x00; | 969 | dev->ts_gen_cntrl = 0x00; |
909 | 970 | ||
910 | dev->dvb.frontend = dvb_attach(zl10353_attach, | 971 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
911 | &cx88_geniatech_x8000_mt, | 972 | &cx88_geniatech_x8000_mt, |
912 | &core->i2c_adap); | 973 | &core->i2c_adap); |
913 | if (attach_xc3028(0x61, dev) < 0) | 974 | if (attach_xc3028(0x61, dev) < 0) |
914 | goto frontend_detach; | 975 | goto frontend_detach; |
915 | break; | 976 | break; |
916 | case CX88_BOARD_KWORLD_ATSC_120: | 977 | case CX88_BOARD_KWORLD_ATSC_120: |
917 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | 978 | fe0->dvb.frontend = dvb_attach(s5h1409_attach, |
918 | &kworld_atsc_120_config, | 979 | &kworld_atsc_120_config, |
919 | &core->i2c_adap); | 980 | &core->i2c_adap); |
920 | if (attach_xc3028(0x61, dev) < 0) | 981 | if (attach_xc3028(0x61, dev) < 0) |
921 | goto frontend_detach; | 982 | goto frontend_detach; |
922 | break; | 983 | break; |
923 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: | 984 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: |
924 | dev->dvb.frontend = dvb_attach(s5h1411_attach, | 985 | fe0->dvb.frontend = dvb_attach(s5h1411_attach, |
925 | &dvico_fusionhdtv7_config, | 986 | &dvico_fusionhdtv7_config, |
926 | &core->i2c_adap); | 987 | &core->i2c_adap); |
927 | if (dev->dvb.frontend != NULL) { | 988 | if (fe0->dvb.frontend != NULL) { |
928 | if (!dvb_attach(xc5000_attach, dev->dvb.frontend, | 989 | if (!dvb_attach(xc5000_attach, fe0->dvb.frontend, |
929 | &core->i2c_adap, | 990 | &core->i2c_adap, |
930 | &dvico_fusionhdtv7_tuner_config)) | 991 | &dvico_fusionhdtv7_tuner_config)) |
931 | goto frontend_detach; | 992 | goto frontend_detach; |
932 | } | 993 | } |
933 | break; | 994 | break; |
934 | case CX88_BOARD_HAUPPAUGE_HVR4000: | 995 | case CX88_BOARD_HAUPPAUGE_HVR4000: |
996 | /* DVB-S/S2 Init */ | ||
997 | fe0->dvb.frontend = dvb_attach(cx24116_attach, | ||
998 | &hauppauge_hvr4000_config, | ||
999 | &dev->core->i2c_adap); | ||
1000 | if (fe0->dvb.frontend) { | ||
1001 | if(!dvb_attach(isl6421_attach, fe0->dvb.frontend, | ||
1002 | &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { | ||
1003 | dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __func__); | ||
1004 | } | ||
1005 | } else { | ||
1006 | dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __func__); | ||
1007 | } | ||
1008 | /* DVB-T Init */ | ||
1009 | fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); | ||
1010 | if (fe1) { | ||
1011 | dev->frontends.gate = 2; | ||
1012 | mfe_shared = 1; | ||
1013 | fe1->dvb.frontend = dvb_attach(cx22702_attach, | ||
1014 | &hauppauge_hvr_config, | ||
1015 | &dev->core->i2c_adap); | ||
1016 | if (fe1->dvb.frontend) { | ||
1017 | fe1->dvb.frontend->id = 1; | ||
1018 | if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, | ||
1019 | &dev->core->i2c_adap, 0x61, | ||
1020 | TUNER_PHILIPS_FMD1216ME_MK3)) { | ||
1021 | dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __func__); | ||
1022 | } | ||
1023 | } else { | ||
1024 | dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __func__); | ||
1025 | } | ||
1026 | } else { | ||
1027 | dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __func__); | ||
1028 | } | ||
1029 | break; | ||
935 | case CX88_BOARD_HAUPPAUGE_HVR4000LITE: | 1030 | case CX88_BOARD_HAUPPAUGE_HVR4000LITE: |
936 | /* Support for DVB-S only, not DVB-T support */ | 1031 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
937 | dev->dvb.frontend = dvb_attach(cx24116_attach, | ||
938 | &hauppauge_hvr4000_config, | 1032 | &hauppauge_hvr4000_config, |
939 | &dev->core->i2c_adap); | 1033 | &dev->core->i2c_adap); |
940 | if (dev->dvb.frontend) { | 1034 | if (fe0->dvb.frontend) { |
941 | dvb_attach(isl6421_attach, dev->dvb.frontend, | 1035 | dvb_attach(isl6421_attach, fe0->dvb.frontend, |
942 | &dev->core->i2c_adap, | 1036 | &dev->core->i2c_adap, |
943 | 0x08, ISL6421_DCL, 0x00); | 1037 | 0x08, ISL6421_DCL, 0x00); |
944 | } | 1038 | } |
945 | break; | 1039 | break; |
946 | case CX88_BOARD_TEVII_S420: | 1040 | case CX88_BOARD_TEVII_S420: |
947 | dev->dvb.frontend = dvb_attach(stv0299_attach, | 1041 | fe0->dvb.frontend = dvb_attach(stv0299_attach, |
948 | &tevii_tuner_sharp_config, | 1042 | &tevii_tuner_sharp_config, |
949 | &core->i2c_adap); | 1043 | &core->i2c_adap); |
950 | if (dev->dvb.frontend != NULL) { | 1044 | if (fe0->dvb.frontend != NULL) { |
951 | if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 1045 | if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, |
952 | &core->i2c_adap, DVB_PLL_OPERA1)) | 1046 | &core->i2c_adap, DVB_PLL_OPERA1)) |
953 | goto frontend_detach; | 1047 | goto frontend_detach; |
954 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 1048 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
955 | dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; | 1049 | fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; |
956 | 1050 | ||
957 | } else { | 1051 | } else { |
958 | dev->dvb.frontend = dvb_attach(stv0288_attach, | 1052 | fe0->dvb.frontend = dvb_attach(stv0288_attach, |
959 | &tevii_tuner_earda_config, | 1053 | &tevii_tuner_earda_config, |
960 | &core->i2c_adap); | 1054 | &core->i2c_adap); |
961 | if (dev->dvb.frontend != NULL) { | 1055 | if (fe0->dvb.frontend != NULL) { |
962 | if (!dvb_attach(stb6000_attach, dev->dvb.frontend, 0x61, | 1056 | if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61, |
963 | &core->i2c_adap)) | 1057 | &core->i2c_adap)) |
964 | goto frontend_detach; | 1058 | goto frontend_detach; |
965 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 1059 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
966 | dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; | 1060 | fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; |
967 | 1061 | ||
968 | } | 1062 | } |
969 | } | 1063 | } |
970 | break; | 1064 | break; |
971 | case CX88_BOARD_TEVII_S460: | 1065 | case CX88_BOARD_TEVII_S460: |
972 | dev->dvb.frontend = dvb_attach(cx24116_attach, | 1066 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
973 | &tevii_s460_config, | 1067 | &tevii_s460_config, |
974 | &core->i2c_adap); | 1068 | &core->i2c_adap); |
975 | if (dev->dvb.frontend != NULL) { | 1069 | if (fe0->dvb.frontend != NULL) { |
976 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 1070 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
977 | dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; | 1071 | fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; |
978 | } | 1072 | } |
979 | break; | 1073 | break; |
980 | case CX88_BOARD_OMICOM_SS4_PCI: | 1074 | case CX88_BOARD_OMICOM_SS4_PCI: |
981 | case CX88_BOARD_TBS_8920: | 1075 | case CX88_BOARD_TBS_8920: |
982 | case CX88_BOARD_PROF_7300: | 1076 | case CX88_BOARD_PROF_7300: |
983 | dev->dvb.frontend = dvb_attach(cx24116_attach, | 1077 | fe0->dvb.frontend = dvb_attach(cx24116_attach, |
984 | &hauppauge_hvr4000_config, | 1078 | &hauppauge_hvr4000_config, |
985 | &core->i2c_adap); | 1079 | &core->i2c_adap); |
986 | if (dev->dvb.frontend != NULL) { | 1080 | if (fe0->dvb.frontend != NULL) { |
987 | core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; | 1081 | core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage; |
988 | dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; | 1082 | fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; |
989 | } | 1083 | } |
990 | break; | 1084 | break; |
991 | default: | 1085 | default: |
@@ -993,29 +1087,32 @@ static int dvb_register(struct cx8802_dev *dev) | |||
993 | core->name); | 1087 | core->name); |
994 | break; | 1088 | break; |
995 | } | 1089 | } |
996 | if (NULL == dev->dvb.frontend) { | 1090 | |
1091 | if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { | ||
997 | printk(KERN_ERR | 1092 | printk(KERN_ERR |
998 | "%s/2: frontend initialization failed\n", | 1093 | "%s/2: frontend initialization failed\n", |
999 | core->name); | 1094 | core->name); |
1000 | return -EINVAL; | 1095 | return -EINVAL; |
1001 | } | 1096 | } |
1002 | /* define general-purpose callback pointer */ | 1097 | /* define general-purpose callback pointer */ |
1003 | dev->dvb.frontend->callback = cx88_tuner_callback; | 1098 | fe0->dvb.frontend->callback = cx88_tuner_callback; |
1004 | 1099 | ||
1005 | /* Ensure all frontends negotiate bus access */ | 1100 | /* Ensure all frontends negotiate bus access */ |
1006 | dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; | 1101 | fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; |
1102 | if (fe1) | ||
1103 | fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; | ||
1007 | 1104 | ||
1008 | /* Put the analog decoder in standby to keep it quiet */ | 1105 | /* Put the analog decoder in standby to keep it quiet */ |
1009 | cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); | 1106 | cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL); |
1010 | 1107 | ||
1011 | /* register everything */ | 1108 | /* register everything */ |
1012 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, | 1109 | return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, |
1013 | &dev->pci->dev, adapter_nr); | 1110 | &dev->pci->dev, adapter_nr, mfe_shared); |
1014 | 1111 | ||
1015 | frontend_detach: | 1112 | frontend_detach: |
1016 | if (dev->dvb.frontend) { | 1113 | if (fe0->dvb.frontend) { |
1017 | dvb_frontend_detach(dev->dvb.frontend); | 1114 | dvb_frontend_detach(fe0->dvb.frontend); |
1018 | dev->dvb.frontend = NULL; | 1115 | fe0->dvb.frontend = NULL; |
1019 | } | 1116 | } |
1020 | return -EINVAL; | 1117 | return -EINVAL; |
1021 | } | 1118 | } |
@@ -1039,6 +1136,38 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv) | |||
1039 | cx_clear(MO_GP0_IO, 0x00000004); | 1136 | cx_clear(MO_GP0_IO, 0x00000004); |
1040 | udelay(1000); | 1137 | udelay(1000); |
1041 | break; | 1138 | break; |
1139 | |||
1140 | case CX88_BOARD_HAUPPAUGE_HVR3000: | ||
1141 | case CX88_BOARD_HAUPPAUGE_HVR4000: | ||
1142 | if(core->dvbdev->frontends.active_fe_id == 1) { | ||
1143 | /* DVB-S/S2 Enabled */ | ||
1144 | |||
1145 | /* Toggle reset on cx22702 leaving i2c active */ | ||
1146 | cx_write(MO_GP0_IO, (core->board.input[0].gpio0 & 0x0000ff00) | 0x00000080); | ||
1147 | udelay(1000); | ||
1148 | cx_clear(MO_GP0_IO, 0x00000080); | ||
1149 | udelay(50); | ||
1150 | cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */ | ||
1151 | cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */ | ||
1152 | udelay(1000); | ||
1153 | |||
1154 | cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */ | ||
1155 | core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */ | ||
1156 | } else | ||
1157 | if (core->dvbdev->frontends.active_fe_id == 2) { | ||
1158 | /* DVB-T Enabled */ | ||
1159 | |||
1160 | /* Put the cx24116/cx24123 into reset */ | ||
1161 | cx_write(MO_SRST_IO, 0); | ||
1162 | |||
1163 | /* cx22702 out of reset and enable it */ | ||
1164 | cx_set(MO_GP0_IO, 0x00000080); | ||
1165 | cx_clear(MO_GP0_IO, 0x00000004); | ||
1166 | core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */ | ||
1167 | udelay(1000); | ||
1168 | } | ||
1169 | break; | ||
1170 | |||
1042 | default: | 1171 | default: |
1043 | err = -ENODEV; | 1172 | err = -ENODEV; |
1044 | } | 1173 | } |
@@ -1056,6 +1185,9 @@ static int cx8802_dvb_advise_release(struct cx8802_driver *drv) | |||
1056 | case CX88_BOARD_HAUPPAUGE_HVR1300: | 1185 | case CX88_BOARD_HAUPPAUGE_HVR1300: |
1057 | /* Do Nothing, leave the cx22702 on the bus. */ | 1186 | /* Do Nothing, leave the cx22702 on the bus. */ |
1058 | break; | 1187 | break; |
1188 | case CX88_BOARD_HAUPPAUGE_HVR3000: | ||
1189 | case CX88_BOARD_HAUPPAUGE_HVR4000: | ||
1190 | break; | ||
1059 | default: | 1191 | default: |
1060 | err = -ENODEV; | 1192 | err = -ENODEV; |
1061 | } | 1193 | } |
@@ -1066,7 +1198,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1066 | { | 1198 | { |
1067 | struct cx88_core *core = drv->core; | 1199 | struct cx88_core *core = drv->core; |
1068 | struct cx8802_dev *dev = drv->core->dvbdev; | 1200 | struct cx8802_dev *dev = drv->core->dvbdev; |
1069 | int err; | 1201 | int err, i; |
1202 | struct videobuf_dvb_frontend *fe; | ||
1070 | 1203 | ||
1071 | dprintk( 1, "%s\n", __func__); | 1204 | dprintk( 1, "%s\n", __func__); |
1072 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 1205 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
@@ -1086,18 +1219,28 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
1086 | 1219 | ||
1087 | /* dvb stuff */ | 1220 | /* dvb stuff */ |
1088 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); | 1221 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); |
1089 | videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops, | 1222 | dev->ts_gen_cntrl = 0x0c; |
1223 | |||
1224 | for (i = 1; i <= core->board.num_frontends; i++) { | ||
1225 | fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); | ||
1226 | if (!fe) { | ||
1227 | printk(KERN_ERR "%s() failed to get frontend(%d)\n", __func__, i); | ||
1228 | continue; | ||
1229 | } | ||
1230 | videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, | ||
1090 | &dev->pci->dev, &dev->slock, | 1231 | &dev->pci->dev, &dev->slock, |
1091 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1232 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1092 | V4L2_FIELD_TOP, | 1233 | V4L2_FIELD_TOP, |
1093 | sizeof(struct cx88_buffer), | 1234 | sizeof(struct cx88_buffer), |
1094 | dev); | 1235 | dev); |
1236 | /* init struct videobuf_dvb */ | ||
1237 | fe->dvb.name = dev->core->name; | ||
1238 | } | ||
1095 | err = dvb_register(dev); | 1239 | err = dvb_register(dev); |
1096 | if (err != 0) | 1240 | if (err != 0) |
1097 | printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", | 1241 | printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", |
1098 | core->name, err); | 1242 | core->name, err); |
1099 | 1243 | fail_core: | |
1100 | fail_core: | ||
1101 | return err; | 1244 | return err; |
1102 | } | 1245 | } |
1103 | 1246 | ||
@@ -1105,9 +1248,7 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv) | |||
1105 | { | 1248 | { |
1106 | struct cx8802_dev *dev = drv->core->dvbdev; | 1249 | struct cx8802_dev *dev = drv->core->dvbdev; |
1107 | 1250 | ||
1108 | /* dvb */ | 1251 | videobuf_dvb_unregister_bus(&dev->frontends); |
1109 | if (dev->dvb.frontend) | ||
1110 | videobuf_dvb_unregister(&dev->dvb); | ||
1111 | 1252 | ||
1112 | vp3054_i2c_remove(dev); | 1253 | vp3054_i2c_remove(dev); |
1113 | 1254 | ||
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 8e74d64fdcd2..01de23007095 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c | |||
@@ -116,18 +116,25 @@ static int detach_inform(struct i2c_client *client) | |||
116 | 116 | ||
117 | void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) | 117 | void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) |
118 | { | 118 | { |
119 | struct videobuf_dvb_frontends *f = &core->dvbdev->frontends; | ||
120 | struct videobuf_dvb_frontend *fe = NULL; | ||
119 | if (0 != core->i2c_rc) | 121 | if (0 != core->i2c_rc) |
120 | return; | 122 | return; |
121 | 123 | ||
122 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) | 124 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) |
123 | if ( (core->dvbdev) && (core->dvbdev->dvb.frontend) ) { | 125 | if (core->dvbdev && f) { |
124 | if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) | 126 | if(f->gate <= 1) /* undefined or fe0 */ |
125 | core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1); | 127 | fe = videobuf_dvb_get_frontend(f, 1); |
128 | else | ||
129 | fe = videobuf_dvb_get_frontend(f, f->gate); | ||
130 | |||
131 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) | ||
132 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 1); | ||
126 | 133 | ||
127 | i2c_clients_command(&core->i2c_adap, cmd, arg); | 134 | i2c_clients_command(&core->i2c_adap, cmd, arg); |
128 | 135 | ||
129 | if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) | 136 | if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) |
130 | core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0); | 137 | fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 0); |
131 | } else | 138 | } else |
132 | #endif | 139 | #endif |
133 | i2c_clients_command(&core->i2c_adap, cmd, arg); | 140 | i2c_clients_command(&core->i2c_adap, cmd, arg); |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index a6b061c2644a..6df5cf314186 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -768,7 +768,8 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev, | |||
768 | { | 768 | { |
769 | struct cx8802_dev *dev; | 769 | struct cx8802_dev *dev; |
770 | struct cx88_core *core; | 770 | struct cx88_core *core; |
771 | int err; | 771 | struct videobuf_dvb_frontend *demod; |
772 | int err,i; | ||
772 | 773 | ||
773 | /* general setup */ | 774 | /* general setup */ |
774 | core = cx88_core_get(pci_dev); | 775 | core = cx88_core_get(pci_dev); |
@@ -781,6 +782,11 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev, | |||
781 | if (!core->board.mpeg) | 782 | if (!core->board.mpeg) |
782 | goto fail_core; | 783 | goto fail_core; |
783 | 784 | ||
785 | if (!core->board.num_frontends) { | ||
786 | printk(KERN_ERR "%s() .num_frontends should be non-zero, err = %d\n", __func__, err); | ||
787 | goto fail_core; | ||
788 | } | ||
789 | |||
784 | err = -ENOMEM; | 790 | err = -ENOMEM; |
785 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); | 791 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); |
786 | if (NULL == dev) | 792 | if (NULL == dev) |
@@ -795,6 +801,20 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev, | |||
795 | INIT_LIST_HEAD(&dev->drvlist); | 801 | INIT_LIST_HEAD(&dev->drvlist); |
796 | list_add_tail(&dev->devlist,&cx8802_devlist); | 802 | list_add_tail(&dev->devlist,&cx8802_devlist); |
797 | 803 | ||
804 | mutex_init(&dev->frontends.lock); | ||
805 | INIT_LIST_HEAD(&dev->frontends.felist); | ||
806 | |||
807 | printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, core->board.num_frontends); | ||
808 | |||
809 | for (i = 1; i <= core->board.num_frontends; i++) { | ||
810 | demod = videobuf_dvb_alloc_frontend(&dev->frontends, i); | ||
811 | if(demod == NULL) { | ||
812 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | ||
813 | err = -ENOMEM; | ||
814 | goto fail_free; | ||
815 | } | ||
816 | } | ||
817 | |||
798 | /* Maintain a reference so cx88-video can query the 8802 device. */ | 818 | /* Maintain a reference so cx88-video can query the 8802 device. */ |
799 | core->dvbdev = dev; | 819 | core->dvbdev = dev; |
800 | 820 | ||
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 3a1977f41e27..7dd506b987fe 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c | |||
@@ -767,6 +767,14 @@ void cx88_set_tvaudio(struct cx88_core *core) | |||
767 | case WW_FM: | 767 | case WW_FM: |
768 | set_audio_standard_FM(core, radio_deemphasis); | 768 | set_audio_standard_FM(core, radio_deemphasis); |
769 | break; | 769 | break; |
770 | case WW_I2SADC: | ||
771 | set_audio_start(core, 0x01); | ||
772 | /* Slave/Philips/Autobaud */ | ||
773 | cx_write(AUD_I2SINPUTCNTL, 0); | ||
774 | /* Switch to "I2S ADC mode" */ | ||
775 | cx_write(AUD_I2SCNTL, 0x1); | ||
776 | set_audio_finish(core, EN_I2SIN_ENABLE); | ||
777 | break; | ||
770 | case WW_NONE: | 778 | case WW_NONE: |
771 | default: | 779 | default: |
772 | printk("%s/0: unknown tv audio mode [%d]\n", | 780 | printk("%s/0: unknown tv audio mode [%d]\n", |
@@ -895,6 +903,9 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual) | |||
895 | break; | 903 | break; |
896 | } | 904 | } |
897 | break; | 905 | break; |
906 | case WW_I2SADC: | ||
907 | /* DO NOTHING */ | ||
908 | break; | ||
898 | } | 909 | } |
899 | 910 | ||
900 | if (UNSET != ctl) { | 911 | if (UNSET != ctl) { |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index be45955dff68..3904b73f52ee 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -426,24 +426,7 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input) | |||
426 | 426 | ||
427 | /* if there are audioroutes defined, we have an external | 427 | /* if there are audioroutes defined, we have an external |
428 | ADC to deal with audio */ | 428 | ADC to deal with audio */ |
429 | |||
430 | if (INPUT(input).audioroute) { | 429 | if (INPUT(input).audioroute) { |
431 | |||
432 | /* cx2388's C-ADC is connected to the tuner only. | ||
433 | When used with S-Video, that ADC is busy dealing with | ||
434 | chroma, so an external must be used for baseband audio */ | ||
435 | |||
436 | if (INPUT(input).type != CX88_VMUX_TELEVISION && | ||
437 | INPUT(input).type != CX88_RADIO) { | ||
438 | /* "ADC mode" */ | ||
439 | cx_write(AUD_I2SCNTL, 0x1); | ||
440 | cx_set(AUD_CTL, EN_I2SIN_ENABLE); | ||
441 | } else { | ||
442 | /* Normal mode */ | ||
443 | cx_write(AUD_I2SCNTL, 0x0); | ||
444 | cx_clear(AUD_CTL, EN_I2SIN_ENABLE); | ||
445 | } | ||
446 | |||
447 | /* The wm8775 module has the "2" route hardwired into | 430 | /* The wm8775 module has the "2" route hardwired into |
448 | the initialization. Some boards may use different | 431 | the initialization. Some boards may use different |
449 | routes for different inputs. HVR-1300 surely does */ | 432 | routes for different inputs. HVR-1300 surely does */ |
@@ -454,9 +437,19 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input) | |||
454 | route.input = INPUT(input).audioroute; | 437 | route.input = INPUT(input).audioroute; |
455 | cx88_call_i2c_clients(core, | 438 | cx88_call_i2c_clients(core, |
456 | VIDIOC_INT_S_AUDIO_ROUTING, &route); | 439 | VIDIOC_INT_S_AUDIO_ROUTING, &route); |
457 | |||
458 | } | 440 | } |
459 | 441 | /* cx2388's C-ADC is connected to the tuner only. | |
442 | When used with S-Video, that ADC is busy dealing with | ||
443 | chroma, so an external must be used for baseband audio */ | ||
444 | if (INPUT(input).type != CX88_VMUX_TELEVISION ) { | ||
445 | /* "I2S ADC mode" */ | ||
446 | core->tvaudio = WW_I2SADC; | ||
447 | cx88_set_tvaudio(core); | ||
448 | } else { | ||
449 | /* Normal mode */ | ||
450 | cx_write(AUD_I2SCNTL, 0x0); | ||
451 | cx_clear(AUD_CTL, EN_I2SIN_ENABLE); | ||
452 | } | ||
460 | } | 453 | } |
461 | 454 | ||
462 | return 0; | 455 | return 0; |
@@ -832,9 +825,24 @@ static int video_open(struct inode *inode, struct file *file) | |||
832 | cx_write(MO_GP0_IO, core->board.radio.gpio0); | 825 | cx_write(MO_GP0_IO, core->board.radio.gpio0); |
833 | cx_write(MO_GP1_IO, core->board.radio.gpio1); | 826 | cx_write(MO_GP1_IO, core->board.radio.gpio1); |
834 | cx_write(MO_GP2_IO, core->board.radio.gpio2); | 827 | cx_write(MO_GP2_IO, core->board.radio.gpio2); |
835 | core->tvaudio = WW_FM; | 828 | if (core->board.radio.audioroute) { |
836 | cx88_set_tvaudio(core); | 829 | if(core->board.audio_chip && |
837 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); | 830 | core->board.audio_chip == V4L2_IDENT_WM8775) { |
831 | struct v4l2_routing route; | ||
832 | |||
833 | route.input = core->board.radio.audioroute; | ||
834 | cx88_call_i2c_clients(core, | ||
835 | VIDIOC_INT_S_AUDIO_ROUTING, &route); | ||
836 | } | ||
837 | /* "I2S ADC mode" */ | ||
838 | core->tvaudio = WW_I2SADC; | ||
839 | cx88_set_tvaudio(core); | ||
840 | } else { | ||
841 | /* FM Mode */ | ||
842 | core->tvaudio = WW_FM; | ||
843 | cx88_set_tvaudio(core); | ||
844 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); | ||
845 | } | ||
838 | cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); | 846 | cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); |
839 | } | 847 | } |
840 | unlock_kernel(); | 848 | unlock_kernel(); |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index dbf01b8b57a5..76207c2856b7 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -247,7 +247,7 @@ struct cx88_input { | |||
247 | enum cx88_itype type; | 247 | enum cx88_itype type; |
248 | u32 gpio0, gpio1, gpio2, gpio3; | 248 | u32 gpio0, gpio1, gpio2, gpio3; |
249 | unsigned int vmux:2; | 249 | unsigned int vmux:2; |
250 | unsigned int audioroute:2; | 250 | unsigned int audioroute:4; |
251 | }; | 251 | }; |
252 | 252 | ||
253 | struct cx88_board { | 253 | struct cx88_board { |
@@ -261,6 +261,7 @@ struct cx88_board { | |||
261 | struct cx88_input radio; | 261 | struct cx88_input radio; |
262 | enum cx88_board_type mpeg; | 262 | enum cx88_board_type mpeg; |
263 | unsigned int audio_chip; | 263 | unsigned int audio_chip; |
264 | int num_frontends; | ||
264 | }; | 265 | }; |
265 | 266 | ||
266 | struct cx88_subid { | 267 | struct cx88_subid { |
@@ -356,6 +357,7 @@ struct cx88_core { | |||
356 | struct cx8802_dev *dvbdev; | 357 | struct cx8802_dev *dvbdev; |
357 | enum cx88_board_type active_type_id; | 358 | enum cx88_board_type active_type_id; |
358 | int active_ref; | 359 | int active_ref; |
360 | int active_fe_id; | ||
359 | }; | 361 | }; |
360 | 362 | ||
361 | struct cx8800_dev; | 363 | struct cx8800_dev; |
@@ -490,7 +492,7 @@ struct cx8802_dev { | |||
490 | 492 | ||
491 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) | 493 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) |
492 | /* for dvb only */ | 494 | /* for dvb only */ |
493 | struct videobuf_dvb dvb; | 495 | struct videobuf_dvb_frontends frontends; |
494 | #endif | 496 | #endif |
495 | 497 | ||
496 | #if defined(CONFIG_VIDEO_CX88_VP3054) || \ | 498 | #if defined(CONFIG_VIDEO_CX88_VP3054) || \ |
@@ -628,6 +630,7 @@ extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl); | |||
628 | #define WW_EIAJ 7 | 630 | #define WW_EIAJ 7 |
629 | #define WW_I2SPT 8 | 631 | #define WW_I2SPT 8 |
630 | #define WW_FM 9 | 632 | #define WW_FM 9 |
633 | #define WW_I2SADC 10 | ||
631 | 634 | ||
632 | void cx88_set_tvaudio(struct cx88_core *core); | 635 | void cx88_set_tvaudio(struct cx88_core *core); |
633 | void cx88_newstation(struct cx88_core *core); | 636 | void cx88_newstation(struct cx88_core *core); |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index c21af312ee7c..e48fbfc8ad05 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #define MODULE_NAME "gspca" | 21 | #define MODULE_NAME "gspca" |
22 | 22 | ||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/version.h> | ||
24 | #include <linux/fs.h> | 25 | #include <linux/fs.h> |
25 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
26 | #include <linux/sched.h> | 27 | #include <linux/sched.h> |
@@ -403,7 +404,7 @@ static void destroy_urbs(struct gspca_dev *gspca_dev) | |||
403 | unsigned int i; | 404 | unsigned int i; |
404 | 405 | ||
405 | PDEBUG(D_STREAM, "kill transfer"); | 406 | PDEBUG(D_STREAM, "kill transfer"); |
406 | for (i = 0; i < MAX_NURBS; ++i) { | 407 | for (i = 0; i < MAX_NURBS; i++) { |
407 | urb = gspca_dev->urb[i]; | 408 | urb = gspca_dev->urb[i]; |
408 | if (urb == NULL) | 409 | if (urb == NULL) |
409 | break; | 410 | break; |
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index 4779dd0b06da..1d9dc90b4791 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define GSPCAV2_H | 2 | #define GSPCAV2_H |
3 | 3 | ||
4 | #include <linux/module.h> | 4 | #include <linux/module.h> |
5 | #include <linux/version.h> | ||
6 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
7 | #include <linux/usb.h> | 6 | #include <linux/usb.h> |
8 | #include <linux/videodev2.h> | 7 | #include <linux/videodev2.h> |
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h index c786d7d3d44a..1a37ae4bc82d 100644 --- a/drivers/media/video/gspca/m5602/m5602_bridge.h +++ b/drivers/media/video/gspca/m5602/m5602_bridge.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * USB Driver for ALi m5602 based webcams | 2 | * USB Driver for ALi m5602 based webcams |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -25,33 +25,6 @@ | |||
25 | 25 | ||
26 | /*****************************************************************************/ | 26 | /*****************************************************************************/ |
27 | 27 | ||
28 | #undef PDEBUG | ||
29 | #undef info | ||
30 | #undef err | ||
31 | |||
32 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | ||
33 | format "\n" , ## arg) | ||
34 | #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ | ||
35 | format "\n" , ## arg) | ||
36 | |||
37 | /* Debug parameters */ | ||
38 | #define DBG_INIT 0x1 | ||
39 | #define DBG_PROBE 0x2 | ||
40 | #define DBG_V4L2 0x4 | ||
41 | #define DBG_TRACE 0x8 | ||
42 | #define DBG_DATA 0x10 | ||
43 | #define DBG_V4L2_CID 0x20 | ||
44 | #define DBG_GSPCA 0x40 | ||
45 | |||
46 | #define PDEBUG(level, fmt, args...) \ | ||
47 | do { \ | ||
48 | if (m5602_debug & level) \ | ||
49 | info("[%s:%d] " fmt, __func__, __LINE__ , \ | ||
50 | ## args); \ | ||
51 | } while (0) | ||
52 | |||
53 | /*****************************************************************************/ | ||
54 | |||
55 | #define M5602_XB_SENSOR_TYPE 0x00 | 28 | #define M5602_XB_SENSOR_TYPE 0x00 |
56 | #define M5602_XB_SENSOR_CTRL 0x01 | 29 | #define M5602_XB_SENSOR_CTRL 0x01 |
57 | #define M5602_XB_LINE_OF_FRAME_H 0x02 | 30 | #define M5602_XB_LINE_OF_FRAME_H 0x02 |
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c index 19d5e351ccc1..fd6ce384b487 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * USB Driver for ALi m5602 based webcams | 2 | * USB Driver for ALi m5602 based webcams |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -26,7 +26,6 @@ | |||
26 | int force_sensor; | 26 | int force_sensor; |
27 | int dump_bridge; | 27 | int dump_bridge; |
28 | int dump_sensor; | 28 | int dump_sensor; |
29 | unsigned int m5602_debug; | ||
30 | 29 | ||
31 | static const __devinitdata struct usb_device_id m5602_table[] = { | 30 | static const __devinitdata struct usb_device_id m5602_table[] = { |
32 | {USB_DEVICE(0x0402, 0x5602)}, | 31 | {USB_DEVICE(0x0402, 0x5602)}, |
@@ -48,7 +47,7 @@ int m5602_read_bridge(struct sd *sd, u8 address, u8 *i2c_data) | |||
48 | 1, M5602_URB_MSG_TIMEOUT); | 47 | 1, M5602_URB_MSG_TIMEOUT); |
49 | *i2c_data = buf[0]; | 48 | *i2c_data = buf[0]; |
50 | 49 | ||
51 | PDEBUG(DBG_TRACE, "Reading bridge register 0x%x containing 0x%x", | 50 | PDEBUG(D_CONF, "Reading bridge register 0x%x containing 0x%x", |
52 | address, *i2c_data); | 51 | address, *i2c_data); |
53 | 52 | ||
54 | /* usb_control_msg(...) returns the number of bytes sent upon success, | 53 | /* usb_control_msg(...) returns the number of bytes sent upon success, |
@@ -63,7 +62,7 @@ int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data) | |||
63 | struct usb_device *udev = sd->gspca_dev.dev; | 62 | struct usb_device *udev = sd->gspca_dev.dev; |
64 | __u8 *buf = sd->gspca_dev.usb_buf; | 63 | __u8 *buf = sd->gspca_dev.usb_buf; |
65 | 64 | ||
66 | PDEBUG(DBG_TRACE, "Writing bridge register 0x%x with 0x%x", | 65 | PDEBUG(D_CONF, "Writing bridge register 0x%x with 0x%x", |
67 | address, i2c_data); | 66 | address, i2c_data); |
68 | 67 | ||
69 | memcpy(buf, bridge_urb_skeleton, | 68 | memcpy(buf, bridge_urb_skeleton, |
@@ -91,7 +90,8 @@ static void m5602_dump_bridge(struct sd *sd) | |||
91 | m5602_read_bridge(sd, i, &val); | 90 | m5602_read_bridge(sd, i, &val); |
92 | info("ALi m5602 address 0x%x contains 0x%x", i, val); | 91 | info("ALi m5602 address 0x%x contains 0x%x", i, val); |
93 | } | 92 | } |
94 | info("Warning: The camera probably won't work until it's power cycled"); | 93 | info("Warning: The ALi m5602 webcam probably won't work " |
94 | "until it's power cycled"); | ||
95 | } | 95 | } |
96 | 96 | ||
97 | static int m5602_probe_sensor(struct sd *sd) | 97 | static int m5602_probe_sensor(struct sd *sd) |
@@ -135,7 +135,7 @@ static int m5602_init(struct gspca_dev *gspca_dev) | |||
135 | struct sd *sd = (struct sd *) gspca_dev; | 135 | struct sd *sd = (struct sd *) gspca_dev; |
136 | int err; | 136 | int err; |
137 | 137 | ||
138 | PDEBUG(DBG_TRACE, "Initializing ALi m5602 webcam"); | 138 | PDEBUG(D_CONF, "Initializing ALi m5602 webcam"); |
139 | /* Run the init sequence */ | 139 | /* Run the init sequence */ |
140 | err = sd->sensor->init(sd); | 140 | err = sd->sensor->init(sd); |
141 | 141 | ||
@@ -146,16 +146,18 @@ static int m5602_start_transfer(struct gspca_dev *gspca_dev) | |||
146 | { | 146 | { |
147 | struct sd *sd = (struct sd *) gspca_dev; | 147 | struct sd *sd = (struct sd *) gspca_dev; |
148 | __u8 *buf = sd->gspca_dev.usb_buf; | 148 | __u8 *buf = sd->gspca_dev.usb_buf; |
149 | int err; | ||
149 | 150 | ||
150 | /* Send start command to the camera */ | 151 | /* Send start command to the camera */ |
151 | const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; | 152 | const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; |
152 | memcpy(buf, buffer, sizeof(buffer)); | 153 | memcpy(buf, buffer, sizeof(buffer)); |
153 | usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), | 154 | err = usb_control_msg(gspca_dev->dev, |
154 | 0x04, 0x40, 0x19, 0x0000, buf, | 155 | usb_sndctrlpipe(gspca_dev->dev, 0), |
155 | 4, M5602_URB_MSG_TIMEOUT); | 156 | 0x04, 0x40, 0x19, 0x0000, buf, |
157 | 4, M5602_URB_MSG_TIMEOUT); | ||
156 | 158 | ||
157 | PDEBUG(DBG_V4L2, "Transfer started"); | 159 | PDEBUG(D_STREAM, "Transfer started"); |
158 | return 0; | 160 | return (err < 0) ? err : 0; |
159 | } | 161 | } |
160 | 162 | ||
161 | static void m5602_urb_complete(struct gspca_dev *gspca_dev, | 163 | static void m5602_urb_complete(struct gspca_dev *gspca_dev, |
@@ -165,14 +167,14 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, | |||
165 | struct sd *sd = (struct sd *) gspca_dev; | 167 | struct sd *sd = (struct sd *) gspca_dev; |
166 | 168 | ||
167 | if (len < 6) { | 169 | if (len < 6) { |
168 | PDEBUG(DBG_DATA, "Packet is less than 6 bytes"); | 170 | PDEBUG(D_PACK, "Packet is less than 6 bytes"); |
169 | return; | 171 | return; |
170 | } | 172 | } |
171 | 173 | ||
172 | /* Frame delimiter: ff xx xx xx ff ff */ | 174 | /* Frame delimiter: ff xx xx xx ff ff */ |
173 | if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && | 175 | if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && |
174 | data[2] != sd->frame_id) { | 176 | data[2] != sd->frame_id) { |
175 | PDEBUG(DBG_DATA, "Frame delimiter detected"); | 177 | PDEBUG(D_FRAM, "Frame delimiter detected"); |
176 | sd->frame_id = data[2]; | 178 | sd->frame_id = data[2]; |
177 | 179 | ||
178 | /* Remove the extra fluff appended on each header */ | 180 | /* Remove the extra fluff appended on each header */ |
@@ -187,7 +189,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, | |||
187 | /* Create a new frame */ | 189 | /* Create a new frame */ |
188 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); | 190 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); |
189 | 191 | ||
190 | PDEBUG(DBG_V4L2, "Starting new frame %d", | 192 | PDEBUG(D_FRAM, "Starting new frame %d", |
191 | sd->frame_count); | 193 | sd->frame_count); |
192 | 194 | ||
193 | } else { | 195 | } else { |
@@ -198,7 +200,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev, | |||
198 | len -= 4; | 200 | len -= 4; |
199 | 201 | ||
200 | if (cur_frame_len + len <= frame->v4l2_buf.length) { | 202 | if (cur_frame_len + len <= frame->v4l2_buf.length) { |
201 | PDEBUG(DBG_DATA, "Continuing frame %d copying %d bytes", | 203 | PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes", |
202 | sd->frame_count, len); | 204 | sd->frame_count, len); |
203 | 205 | ||
204 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | 206 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
@@ -234,8 +236,6 @@ static int m5602_configure(struct gspca_dev *gspca_dev, | |||
234 | struct cam *cam; | 236 | struct cam *cam; |
235 | int err; | 237 | int err; |
236 | 238 | ||
237 | PDEBUG(DBG_GSPCA, "m5602_configure start"); | ||
238 | |||
239 | cam = &gspca_dev->cam; | 239 | cam = &gspca_dev->cam; |
240 | cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; | 240 | cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; |
241 | sd->desc = &sd_desc; | 241 | sd->desc = &sd_desc; |
@@ -248,11 +248,10 @@ static int m5602_configure(struct gspca_dev *gspca_dev, | |||
248 | if (err) | 248 | if (err) |
249 | goto fail; | 249 | goto fail; |
250 | 250 | ||
251 | PDEBUG(DBG_GSPCA, "m5602_configure end"); | ||
252 | return 0; | 251 | return 0; |
253 | 252 | ||
254 | fail: | 253 | fail: |
255 | PDEBUG(DBG_GSPCA, "m5602_configure failed"); | 254 | PDEBUG(D_ERR, "ALi m5602 webcam failed"); |
256 | cam->cam_mode = NULL; | 255 | cam->cam_mode = NULL; |
257 | cam->nmodes = 0; | 256 | cam->nmodes = 0; |
258 | 257 | ||
@@ -282,13 +281,13 @@ static int __init mod_m5602_init(void) | |||
282 | { | 281 | { |
283 | if (usb_register(&sd_driver) < 0) | 282 | if (usb_register(&sd_driver) < 0) |
284 | return -1; | 283 | return -1; |
285 | PDEBUG(D_PROBE, "m5602 module registered"); | 284 | PDEBUG(D_PROBE, "registered"); |
286 | return 0; | 285 | return 0; |
287 | } | 286 | } |
288 | static void __exit mod_m5602_exit(void) | 287 | static void __exit mod_m5602_exit(void) |
289 | { | 288 | { |
290 | usb_deregister(&sd_driver); | 289 | usb_deregister(&sd_driver); |
291 | PDEBUG(D_PROBE, "m5602 module deregistered"); | 290 | PDEBUG(D_PROBE, "deregistered"); |
292 | } | 291 | } |
293 | 292 | ||
294 | module_init(mod_m5602_init); | 293 | module_init(mod_m5602_init); |
@@ -297,9 +296,6 @@ module_exit(mod_m5602_exit); | |||
297 | MODULE_AUTHOR(DRIVER_AUTHOR); | 296 | MODULE_AUTHOR(DRIVER_AUTHOR); |
298 | MODULE_DESCRIPTION(DRIVER_DESC); | 297 | MODULE_DESCRIPTION(DRIVER_DESC); |
299 | MODULE_LICENSE("GPL"); | 298 | MODULE_LICENSE("GPL"); |
300 | module_param_named(debug, m5602_debug, int, S_IRUGO | S_IWUSR); | ||
301 | MODULE_PARM_DESC(debug, "toggles debug on/off"); | ||
302 | |||
303 | module_param(force_sensor, int, S_IRUGO | S_IWUSR); | 299 | module_param(force_sensor, int, S_IRUGO | S_IWUSR); |
304 | MODULE_PARM_DESC(force_sensor, | 300 | MODULE_PARM_DESC(force_sensor, |
305 | "force detection of sensor, " | 301 | "force detection of sensor, " |
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c index 566d4925a0e8..fb700c2d055a 100644 --- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c +++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the mt9m111 sensor | 2 | * Driver for the mt9m111 sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -107,7 +107,7 @@ int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
107 | err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, | 107 | err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, |
108 | data, 2); | 108 | data, 2); |
109 | *val = data[0] & MT9M111_RMB_MIRROR_ROWS; | 109 | *val = data[0] & MT9M111_RMB_MIRROR_ROWS; |
110 | PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); | 110 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
111 | 111 | ||
112 | return (err < 0) ? err : 0; | 112 | return (err < 0) ? err : 0; |
113 | } | 113 | } |
@@ -118,7 +118,7 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
118 | u8 data[2] = {0x00, 0x00}; | 118 | u8 data[2] = {0x00, 0x00}; |
119 | struct sd *sd = (struct sd *) gspca_dev; | 119 | struct sd *sd = (struct sd *) gspca_dev; |
120 | 120 | ||
121 | PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); | 121 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
122 | 122 | ||
123 | /* Set the correct page map */ | 123 | /* Set the correct page map */ |
124 | err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); | 124 | err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); |
@@ -145,7 +145,7 @@ int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
145 | err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, | 145 | err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, |
146 | data, 2); | 146 | data, 2); |
147 | *val = data[0] & MT9M111_RMB_MIRROR_COLS; | 147 | *val = data[0] & MT9M111_RMB_MIRROR_COLS; |
148 | PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); | 148 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
149 | 149 | ||
150 | return (err < 0) ? err : 0; | 150 | return (err < 0) ? err : 0; |
151 | } | 151 | } |
@@ -156,7 +156,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
156 | u8 data[2] = {0x00, 0x00}; | 156 | u8 data[2] = {0x00, 0x00}; |
157 | struct sd *sd = (struct sd *) gspca_dev; | 157 | struct sd *sd = (struct sd *) gspca_dev; |
158 | 158 | ||
159 | PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); | 159 | PDEBUG(D_V4L2, "Set horizontal flip to %d", val); |
160 | 160 | ||
161 | /* Set the correct page map */ | 161 | /* Set the correct page map */ |
162 | err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); | 162 | err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); |
@@ -188,7 +188,7 @@ int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
188 | ((tmp & (1 << 8)) * 2) | | 188 | ((tmp & (1 << 8)) * 2) | |
189 | (tmp & 0x7f); | 189 | (tmp & 0x7f); |
190 | 190 | ||
191 | PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); | 191 | PDEBUG(D_V4L2, "Read gain %d", *val); |
192 | 192 | ||
193 | return (err < 0) ? err : 0; | 193 | return (err < 0) ? err : 0; |
194 | } | 194 | } |
@@ -222,7 +222,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
222 | 222 | ||
223 | data[1] = (tmp & 0xff00) >> 8; | 223 | data[1] = (tmp & 0xff00) >> 8; |
224 | data[0] = (tmp & 0xff); | 224 | data[0] = (tmp & 0xff); |
225 | PDEBUG(DBG_V4L2_CID, "tmp=%d, data[1]=%d, data[0]=%d", tmp, | 225 | PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp, |
226 | data[1], data[0]); | 226 | data[1], data[0]); |
227 | 227 | ||
228 | err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, | 228 | err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, |
@@ -257,7 +257,7 @@ int mt9m111_read_sensor(struct sd *sd, const u8 address, | |||
257 | for (i = 0; i < len && !err; i++) { | 257 | for (i = 0; i < len && !err; i++) { |
258 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | 258 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); |
259 | 259 | ||
260 | PDEBUG(DBG_TRACE, "Reading sensor register " | 260 | PDEBUG(D_CONF, "Reading sensor register " |
261 | "0x%x contains 0x%x ", address, *i2c_data); | 261 | "0x%x contains 0x%x ", address, *i2c_data); |
262 | } | 262 | } |
263 | out: | 263 | out: |
@@ -290,7 +290,7 @@ int mt9m111_write_sensor(struct sd *sd, const u8 address, | |||
290 | memcpy(p, sensor_urb_skeleton + 16, 4); | 290 | memcpy(p, sensor_urb_skeleton + 16, 4); |
291 | p[3] = i2c_data[i]; | 291 | p[3] = i2c_data[i]; |
292 | p += 4; | 292 | p += 4; |
293 | PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", | 293 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", |
294 | address, i2c_data[i]); | 294 | address, i2c_data[i]); |
295 | } | 295 | } |
296 | 296 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h index 79a5d8878190..315209d5aeef 100644 --- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h +++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the mt9m111 sensor | 2 | * Driver for the mt9m111 sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -82,7 +82,6 @@ | |||
82 | /* Kernel module parameters */ | 82 | /* Kernel module parameters */ |
83 | extern int force_sensor; | 83 | extern int force_sensor; |
84 | extern int dump_sensor; | 84 | extern int dump_sensor; |
85 | extern unsigned int m5602_debug; | ||
86 | 85 | ||
87 | int mt9m111_probe(struct sd *sd); | 86 | int mt9m111_probe(struct sd *sd); |
88 | int mt9m111_init(struct sd *sd); | 87 | int mt9m111_init(struct sd *sd); |
@@ -152,8 +151,8 @@ static struct m5602_sensor mt9m111 = { | |||
152 | .default_value = DEFAULT_GAIN, | 151 | .default_value = DEFAULT_GAIN, |
153 | .flags = V4L2_CTRL_FLAG_SLIDER | 152 | .flags = V4L2_CTRL_FLAG_SLIDER |
154 | }, | 153 | }, |
155 | .set = mt9m111_set_hflip, | 154 | .set = mt9m111_set_gain, |
156 | .get = mt9m111_get_hflip | 155 | .get = mt9m111_get_gain |
157 | } | 156 | } |
158 | }, | 157 | }, |
159 | 158 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c index 31c5896250e7..837c7e47661c 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov9650.c +++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the ov9650 sensor | 2 | * Driver for the ov9650 sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -40,7 +40,7 @@ int ov9650_read_sensor(struct sd *sd, const u8 address, | |||
40 | for (i = 0; i < len; i++) { | 40 | for (i = 0; i < len; i++) { |
41 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | 41 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); |
42 | 42 | ||
43 | PDEBUG(DBG_TRACE, "Reading sensor register " | 43 | PDEBUG(D_CONF, "Reading sensor register " |
44 | "0x%x containing 0x%x ", address, *i2c_data); | 44 | "0x%x containing 0x%x ", address, *i2c_data); |
45 | } | 45 | } |
46 | return (err < 0) ? err : 0; | 46 | return (err < 0) ? err : 0; |
@@ -72,7 +72,7 @@ int ov9650_write_sensor(struct sd *sd, const u8 address, | |||
72 | memcpy(p, sensor_urb_skeleton + 16, 4); | 72 | memcpy(p, sensor_urb_skeleton + 16, 4); |
73 | p[3] = i2c_data[i]; | 73 | p[3] = i2c_data[i]; |
74 | p += 4; | 74 | p += 4; |
75 | PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", | 75 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", |
76 | address, i2c_data[i]); | 76 | address, i2c_data[i]); |
77 | } | 77 | } |
78 | 78 | ||
@@ -199,7 +199,7 @@ int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
199 | goto out; | 199 | goto out; |
200 | *val |= (i2c_data & 0x3f) << 10; | 200 | *val |= (i2c_data & 0x3f) << 10; |
201 | 201 | ||
202 | PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); | 202 | PDEBUG(D_V4L2, "Read exposure %d", *val); |
203 | out: | 203 | out: |
204 | return (err < 0) ? err : 0; | 204 | return (err < 0) ? err : 0; |
205 | } | 205 | } |
@@ -210,7 +210,7 @@ int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
210 | u8 i2c_data; | 210 | u8 i2c_data; |
211 | int err; | 211 | int err; |
212 | 212 | ||
213 | PDEBUG(DBG_V4L2_CID, "Set exposure to %d", | 213 | PDEBUG(D_V4L2, "Set exposure to %d", |
214 | val & 0xffff); | 214 | val & 0xffff); |
215 | 215 | ||
216 | /* The 6 MSBs */ | 216 | /* The 6 MSBs */ |
@@ -246,7 +246,7 @@ int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
246 | 246 | ||
247 | err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); | 247 | err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); |
248 | *val |= i2c_data; | 248 | *val |= i2c_data; |
249 | PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); | 249 | PDEBUG(D_V4L2, "Read gain %d", *val); |
250 | return (err < 0) ? err : 0; | 250 | return (err < 0) ? err : 0; |
251 | } | 251 | } |
252 | 252 | ||
@@ -280,7 +280,7 @@ int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
280 | err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); | 280 | err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); |
281 | *val = i2c_data; | 281 | *val = i2c_data; |
282 | 282 | ||
283 | PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); | 283 | PDEBUG(D_V4L2, "Read red gain %d", *val); |
284 | 284 | ||
285 | return (err < 0) ? err : 0; | 285 | return (err < 0) ? err : 0; |
286 | } | 286 | } |
@@ -291,7 +291,7 @@ int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
291 | u8 i2c_data; | 291 | u8 i2c_data; |
292 | struct sd *sd = (struct sd *) gspca_dev; | 292 | struct sd *sd = (struct sd *) gspca_dev; |
293 | 293 | ||
294 | PDEBUG(DBG_V4L2_CID, "Set red gain to %d", | 294 | PDEBUG(D_V4L2, "Set red gain to %d", |
295 | val & 0xff); | 295 | val & 0xff); |
296 | 296 | ||
297 | i2c_data = val & 0xff; | 297 | i2c_data = val & 0xff; |
@@ -309,7 +309,7 @@ int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
309 | err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); | 309 | err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); |
310 | *val = i2c_data; | 310 | *val = i2c_data; |
311 | 311 | ||
312 | PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); | 312 | PDEBUG(D_V4L2, "Read blue gain %d", *val); |
313 | 313 | ||
314 | return (err < 0) ? err : 0; | 314 | return (err < 0) ? err : 0; |
315 | } | 315 | } |
@@ -320,7 +320,7 @@ int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
320 | u8 i2c_data; | 320 | u8 i2c_data; |
321 | struct sd *sd = (struct sd *) gspca_dev; | 321 | struct sd *sd = (struct sd *) gspca_dev; |
322 | 322 | ||
323 | PDEBUG(DBG_V4L2_CID, "Set blue gain to %d", | 323 | PDEBUG(D_V4L2, "Set blue gain to %d", |
324 | val & 0xff); | 324 | val & 0xff); |
325 | 325 | ||
326 | i2c_data = val & 0xff; | 326 | i2c_data = val & 0xff; |
@@ -340,7 +340,7 @@ int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
340 | *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; | 340 | *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; |
341 | else | 341 | else |
342 | *val = (i2c_data & OV9650_HFLIP) >> 5; | 342 | *val = (i2c_data & OV9650_HFLIP) >> 5; |
343 | PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); | 343 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
344 | 344 | ||
345 | return (err < 0) ? err : 0; | 345 | return (err < 0) ? err : 0; |
346 | } | 346 | } |
@@ -351,7 +351,7 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
351 | u8 i2c_data; | 351 | u8 i2c_data; |
352 | struct sd *sd = (struct sd *) gspca_dev; | 352 | struct sd *sd = (struct sd *) gspca_dev; |
353 | 353 | ||
354 | PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); | 354 | PDEBUG(D_V4L2, "Set horizontal flip to %d", val); |
355 | err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 355 | err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); |
356 | if (err < 0) | 356 | if (err < 0) |
357 | goto out; | 357 | goto out; |
@@ -379,7 +379,7 @@ int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
379 | *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; | 379 | *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; |
380 | else | 380 | else |
381 | *val = (i2c_data & 0x10) >> 4; | 381 | *val = (i2c_data & 0x10) >> 4; |
382 | PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); | 382 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
383 | 383 | ||
384 | return (err < 0) ? err : 0; | 384 | return (err < 0) ? err : 0; |
385 | } | 385 | } |
@@ -390,7 +390,7 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
390 | u8 i2c_data; | 390 | u8 i2c_data; |
391 | struct sd *sd = (struct sd *) gspca_dev; | 391 | struct sd *sd = (struct sd *) gspca_dev; |
392 | 392 | ||
393 | PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); | 393 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
394 | err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); | 394 | err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); |
395 | if (err < 0) | 395 | if (err < 0) |
396 | goto out; | 396 | goto out; |
@@ -420,7 +420,7 @@ int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
420 | 420 | ||
421 | err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); | 421 | err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); |
422 | *val |= i2c_data; | 422 | *val |= i2c_data; |
423 | PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); | 423 | PDEBUG(D_V4L2, "Read gain %d", *val); |
424 | out: | 424 | out: |
425 | return (err < 0) ? err : 0; | 425 | return (err < 0) ? err : 0; |
426 | } | 426 | } |
@@ -431,7 +431,7 @@ int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | |||
431 | u8 i2c_data; | 431 | u8 i2c_data; |
432 | struct sd *sd = (struct sd *) gspca_dev; | 432 | struct sd *sd = (struct sd *) gspca_dev; |
433 | 433 | ||
434 | PDEBUG(DBG_V4L2_CID, "Set gain to %d", val & 0x3ff); | 434 | PDEBUG(D_V4L2, "Set gain to %d", val & 0x3ff); |
435 | 435 | ||
436 | /* Read the OV9650_VREF register first to avoid | 436 | /* Read the OV9650_VREF register first to avoid |
437 | corrupting the VREF high and low bits */ | 437 | corrupting the VREF high and low bits */ |
@@ -461,7 +461,7 @@ int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
461 | 461 | ||
462 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 462 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
463 | *val = (i2c_data & OV9650_AWB_EN) >> 1; | 463 | *val = (i2c_data & OV9650_AWB_EN) >> 1; |
464 | PDEBUG(DBG_V4L2_CID, "Read auto white balance %d", *val); | 464 | PDEBUG(D_V4L2, "Read auto white balance %d", *val); |
465 | 465 | ||
466 | return (err < 0) ? err : 0; | 466 | return (err < 0) ? err : 0; |
467 | } | 467 | } |
@@ -472,7 +472,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
472 | u8 i2c_data; | 472 | u8 i2c_data; |
473 | struct sd *sd = (struct sd *) gspca_dev; | 473 | struct sd *sd = (struct sd *) gspca_dev; |
474 | 474 | ||
475 | PDEBUG(DBG_V4L2_CID, "Set auto white balance to %d", val); | 475 | PDEBUG(D_V4L2, "Set auto white balance to %d", val); |
476 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 476 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
477 | if (err < 0) | 477 | if (err < 0) |
478 | goto out; | 478 | goto out; |
@@ -491,7 +491,7 @@ int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
491 | 491 | ||
492 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 492 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
493 | *val = (i2c_data & OV9650_AGC_EN) >> 2; | 493 | *val = (i2c_data & OV9650_AGC_EN) >> 2; |
494 | PDEBUG(DBG_V4L2_CID, "Read auto gain control %d", *val); | 494 | PDEBUG(D_V4L2, "Read auto gain control %d", *val); |
495 | 495 | ||
496 | return (err < 0) ? err : 0; | 496 | return (err < 0) ? err : 0; |
497 | } | 497 | } |
@@ -502,7 +502,7 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
502 | u8 i2c_data; | 502 | u8 i2c_data; |
503 | struct sd *sd = (struct sd *) gspca_dev; | 503 | struct sd *sd = (struct sd *) gspca_dev; |
504 | 504 | ||
505 | PDEBUG(DBG_V4L2_CID, "Set auto gain control to %d", val); | 505 | PDEBUG(D_V4L2, "Set auto gain control to %d", val); |
506 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); | 506 | err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); |
507 | if (err < 0) | 507 | if (err < 0) |
508 | goto out; | 508 | goto out; |
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h index 2f29cb056f30..065632f0378e 100644 --- a/drivers/media/video/gspca/m5602/m5602_ov9650.h +++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the ov9650 sensor | 2 | * Driver for the ov9650 sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -121,7 +121,6 @@ | |||
121 | /* Kernel module parameters */ | 121 | /* Kernel module parameters */ |
122 | extern int force_sensor; | 122 | extern int force_sensor; |
123 | extern int dump_sensor; | 123 | extern int dump_sensor; |
124 | extern unsigned int m5602_debug; | ||
125 | 124 | ||
126 | int ov9650_probe(struct sd *sd); | 125 | int ov9650_probe(struct sd *sd); |
127 | int ov9650_init(struct sd *sd); | 126 | int ov9650_init(struct sd *sd); |
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c index 08c015bde115..d17ac52566e6 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.c +++ b/drivers/media/video/gspca/m5602/m5602_po1030.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the po1030 sensor | 2 | * Driver for the po1030 sensor |
3 | * | 3 | * |
4 | * Copyright (c) 2008 Erik Andren | 4 | * Copyright (c) 2008 Erik Andrén |
5 | * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -82,7 +82,7 @@ int po1030_read_sensor(struct sd *sd, const u8 address, | |||
82 | for (i = 0; i < len; i++) { | 82 | for (i = 0; i < len; i++) { |
83 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | 83 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); |
84 | 84 | ||
85 | PDEBUG(DBG_TRACE, "Reading sensor register " | 85 | PDEBUG(D_CONF, "Reading sensor register " |
86 | "0x%x containing 0x%x ", address, *i2c_data); | 86 | "0x%x containing 0x%x ", address, *i2c_data); |
87 | } | 87 | } |
88 | return (err < 0) ? err : 0; | 88 | return (err < 0) ? err : 0; |
@@ -112,7 +112,7 @@ int po1030_write_sensor(struct sd *sd, const u8 address, | |||
112 | memcpy(p, sensor_urb_skeleton + 16, 4); | 112 | memcpy(p, sensor_urb_skeleton + 16, 4); |
113 | p[3] = i2c_data[i]; | 113 | p[3] = i2c_data[i]; |
114 | p += 4; | 114 | p += 4; |
115 | PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", | 115 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", |
116 | address, i2c_data[i]); | 116 | address, i2c_data[i]); |
117 | } | 117 | } |
118 | 118 | ||
@@ -185,7 +185,7 @@ int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
185 | &i2c_data, 1); | 185 | &i2c_data, 1); |
186 | *val |= i2c_data; | 186 | *val |= i2c_data; |
187 | 187 | ||
188 | PDEBUG(DBG_V4L2_CID, "Exposure read as %d", *val); | 188 | PDEBUG(D_V4L2, "Exposure read as %d", *val); |
189 | out: | 189 | out: |
190 | return (err < 0) ? err : 0; | 190 | return (err < 0) ? err : 0; |
191 | } | 191 | } |
@@ -196,10 +196,10 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
196 | u8 i2c_data; | 196 | u8 i2c_data; |
197 | int err; | 197 | int err; |
198 | 198 | ||
199 | PDEBUG(DBG_V4L2, "Set exposure to %d", val & 0xffff); | 199 | PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff); |
200 | 200 | ||
201 | i2c_data = ((val & 0xff00) >> 8); | 201 | i2c_data = ((val & 0xff00) >> 8); |
202 | PDEBUG(DBG_V4L2, "Set exposure to high byte to 0x%x", | 202 | PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", |
203 | i2c_data); | 203 | i2c_data); |
204 | 204 | ||
205 | err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, | 205 | err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, |
@@ -208,7 +208,7 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
208 | goto out; | 208 | goto out; |
209 | 209 | ||
210 | i2c_data = (val & 0xff); | 210 | i2c_data = (val & 0xff); |
211 | PDEBUG(DBG_V4L2, "Set exposure to low byte to 0x%x", | 211 | PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", |
212 | i2c_data); | 212 | i2c_data); |
213 | err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, | 213 | err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, |
214 | &i2c_data, 1); | 214 | &i2c_data, 1); |
@@ -226,7 +226,71 @@ int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
226 | err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, | 226 | err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, |
227 | &i2c_data, 1); | 227 | &i2c_data, 1); |
228 | *val = i2c_data; | 228 | *val = i2c_data; |
229 | PDEBUG(DBG_V4L2_CID, "Read global gain %d", *val); | 229 | PDEBUG(D_V4L2, "Read global gain %d", *val); |
230 | |||
231 | return (err < 0) ? err : 0; | ||
232 | } | ||
233 | |||
234 | int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
235 | { | ||
236 | struct sd *sd = (struct sd *) gspca_dev; | ||
237 | u8 i2c_data; | ||
238 | int err; | ||
239 | |||
240 | err = po1030_read_sensor(sd, PO1030_REG_CONTROL2, | ||
241 | &i2c_data, 1); | ||
242 | |||
243 | *val = (i2c_data >> 7) & 0x01 ; | ||
244 | |||
245 | PDEBUG(D_V4L2, "Read hflip %d", *val); | ||
246 | |||
247 | return (err < 0) ? err : 0; | ||
248 | } | ||
249 | |||
250 | int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | ||
251 | { | ||
252 | struct sd *sd = (struct sd *) gspca_dev; | ||
253 | u8 i2c_data; | ||
254 | int err; | ||
255 | |||
256 | PDEBUG(D_V4L2, "Set hflip %d", val); | ||
257 | |||
258 | i2c_data = (val & 0x01) << 7; | ||
259 | |||
260 | err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, | ||
261 | &i2c_data, 1); | ||
262 | |||
263 | return (err < 0) ? err : 0; | ||
264 | } | ||
265 | |||
266 | int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
267 | { | ||
268 | struct sd *sd = (struct sd *) gspca_dev; | ||
269 | u8 i2c_data; | ||
270 | int err; | ||
271 | |||
272 | err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, | ||
273 | &i2c_data, 1); | ||
274 | |||
275 | *val = (i2c_data >> 6) & 0x01; | ||
276 | |||
277 | PDEBUG(D_V4L2, "Read vflip %d", *val); | ||
278 | |||
279 | return (err < 0) ? err : 0; | ||
280 | } | ||
281 | |||
282 | int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | ||
283 | { | ||
284 | struct sd *sd = (struct sd *) gspca_dev; | ||
285 | u8 i2c_data; | ||
286 | int err; | ||
287 | |||
288 | PDEBUG(D_V4L2, "Set vflip %d", val); | ||
289 | |||
290 | i2c_data = (val & 0x01) << 6; | ||
291 | |||
292 | err = po1030_write_sensor(sd, PO1030_REG_CONTROL2, | ||
293 | &i2c_data, 1); | ||
230 | 294 | ||
231 | return (err < 0) ? err : 0; | 295 | return (err < 0) ? err : 0; |
232 | } | 296 | } |
@@ -238,7 +302,7 @@ int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
238 | int err; | 302 | int err; |
239 | 303 | ||
240 | i2c_data = val & 0xff; | 304 | i2c_data = val & 0xff; |
241 | PDEBUG(DBG_V4L2, "Set global gain to %d", i2c_data); | 305 | PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); |
242 | err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, | 306 | err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, |
243 | &i2c_data, 1); | 307 | &i2c_data, 1); |
244 | return (err < 0) ? err : 0; | 308 | return (err < 0) ? err : 0; |
@@ -253,7 +317,7 @@ int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
253 | err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, | 317 | err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, |
254 | &i2c_data, 1); | 318 | &i2c_data, 1); |
255 | *val = i2c_data; | 319 | *val = i2c_data; |
256 | PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); | 320 | PDEBUG(D_V4L2, "Read red gain %d", *val); |
257 | return (err < 0) ? err : 0; | 321 | return (err < 0) ? err : 0; |
258 | } | 322 | } |
259 | 323 | ||
@@ -264,7 +328,7 @@ int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
264 | int err; | 328 | int err; |
265 | 329 | ||
266 | i2c_data = val & 0xff; | 330 | i2c_data = val & 0xff; |
267 | PDEBUG(DBG_V4L2, "Set red gain to %d", i2c_data); | 331 | PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); |
268 | err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, | 332 | err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, |
269 | &i2c_data, 1); | 333 | &i2c_data, 1); |
270 | return (err < 0) ? err : 0; | 334 | return (err < 0) ? err : 0; |
@@ -279,7 +343,7 @@ int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
279 | err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, | 343 | err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, |
280 | &i2c_data, 1); | 344 | &i2c_data, 1); |
281 | *val = i2c_data; | 345 | *val = i2c_data; |
282 | PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); | 346 | PDEBUG(D_V4L2, "Read blue gain %d", *val); |
283 | 347 | ||
284 | return (err < 0) ? err : 0; | 348 | return (err < 0) ? err : 0; |
285 | } | 349 | } |
@@ -290,7 +354,7 @@ int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
290 | u8 i2c_data; | 354 | u8 i2c_data; |
291 | int err; | 355 | int err; |
292 | i2c_data = val & 0xff; | 356 | i2c_data = val & 0xff; |
293 | PDEBUG(DBG_V4L2, "Set blue gain to %d", i2c_data); | 357 | PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); |
294 | err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, | 358 | err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, |
295 | &i2c_data, 1); | 359 | &i2c_data, 1); |
296 | 360 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h index 68f34c97bf44..a0b75ff61d79 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.h +++ b/drivers/media/video/gspca/m5602/m5602_po1030.h | |||
@@ -1,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the po1030 sensor. | 2 | * Driver for the po1030 sensor. |
3 | * This is probably a pixel plus sensor but we haven't identified it yet | ||
4 | * | 3 | * |
5 | * Copyright (c) 2008 Erik Andren | 4 | * Copyright (c) 2008 Erik Andrén |
6 | * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
7 | * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
8 | * | 7 | * |
@@ -109,10 +108,13 @@ | |||
109 | #define PO1030_REG_YCONTRAST 0x74 | 108 | #define PO1030_REG_YCONTRAST 0x74 |
110 | #define PO1030_REG_YSATURATION 0x75 | 109 | #define PO1030_REG_YSATURATION 0x75 |
111 | 110 | ||
111 | #define PO1030_HFLIP (1 << 7) | ||
112 | #define PO1030_VFLIP (1 << 6) | ||
113 | |||
112 | /*****************************************************************************/ | 114 | /*****************************************************************************/ |
113 | 115 | ||
114 | #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 | 116 | #define PO1030_GLOBAL_GAIN_DEFAULT 0x12 |
115 | #define PO1030_EXPOSURE_DEFAULT 0xf0ff | 117 | #define PO1030_EXPOSURE_DEFAULT 0x0085 |
116 | #define PO1030_BLUE_GAIN_DEFAULT 0x40 | 118 | #define PO1030_BLUE_GAIN_DEFAULT 0x40 |
117 | #define PO1030_RED_GAIN_DEFAULT 0x40 | 119 | #define PO1030_RED_GAIN_DEFAULT 0x40 |
118 | 120 | ||
@@ -121,7 +123,6 @@ | |||
121 | /* Kernel module parameters */ | 123 | /* Kernel module parameters */ |
122 | extern int force_sensor; | 124 | extern int force_sensor; |
123 | extern int dump_sensor; | 125 | extern int dump_sensor; |
124 | extern unsigned int m5602_debug; | ||
125 | 126 | ||
126 | int po1030_probe(struct sd *sd); | 127 | int po1030_probe(struct sd *sd); |
127 | int po1030_init(struct sd *sd); | 128 | int po1030_init(struct sd *sd); |
@@ -142,6 +143,10 @@ int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val); | |||
142 | int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); | 143 | int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); |
143 | int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); | 144 | int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); |
144 | int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); | 145 | int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); |
146 | int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
147 | int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | ||
148 | int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
149 | int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); | ||
145 | 150 | ||
146 | static struct m5602_sensor po1030 = { | 151 | static struct m5602_sensor po1030 = { |
147 | .name = "PO1030", | 152 | .name = "PO1030", |
@@ -152,7 +157,7 @@ static struct m5602_sensor po1030 = { | |||
152 | .init = po1030_init, | 157 | .init = po1030_init, |
153 | .power_down = po1030_power_down, | 158 | .power_down = po1030_power_down, |
154 | 159 | ||
155 | .nctrls = 4, | 160 | .nctrls = 6, |
156 | .ctrls = { | 161 | .ctrls = { |
157 | { | 162 | { |
158 | { | 163 | { |
@@ -160,7 +165,7 @@ static struct m5602_sensor po1030 = { | |||
160 | .type = V4L2_CTRL_TYPE_INTEGER, | 165 | .type = V4L2_CTRL_TYPE_INTEGER, |
161 | .name = "gain", | 166 | .name = "gain", |
162 | .minimum = 0x00, | 167 | .minimum = 0x00, |
163 | .maximum = 0xff, | 168 | .maximum = 0x4f, |
164 | .step = 0x1, | 169 | .step = 0x1, |
165 | .default_value = PO1030_GLOBAL_GAIN_DEFAULT, | 170 | .default_value = PO1030_GLOBAL_GAIN_DEFAULT, |
166 | .flags = V4L2_CTRL_FLAG_SLIDER | 171 | .flags = V4L2_CTRL_FLAG_SLIDER |
@@ -173,7 +178,7 @@ static struct m5602_sensor po1030 = { | |||
173 | .type = V4L2_CTRL_TYPE_INTEGER, | 178 | .type = V4L2_CTRL_TYPE_INTEGER, |
174 | .name = "exposure", | 179 | .name = "exposure", |
175 | .minimum = 0x00, | 180 | .minimum = 0x00, |
176 | .maximum = 0xffff, | 181 | .maximum = 0x02ff, |
177 | .step = 0x1, | 182 | .step = 0x1, |
178 | .default_value = PO1030_EXPOSURE_DEFAULT, | 183 | .default_value = PO1030_EXPOSURE_DEFAULT, |
179 | .flags = V4L2_CTRL_FLAG_SLIDER | 184 | .flags = V4L2_CTRL_FLAG_SLIDER |
@@ -206,8 +211,33 @@ static struct m5602_sensor po1030 = { | |||
206 | }, | 211 | }, |
207 | .set = po1030_set_blue_balance, | 212 | .set = po1030_set_blue_balance, |
208 | .get = po1030_get_blue_balance | 213 | .get = po1030_get_blue_balance |
214 | }, { | ||
215 | { | ||
216 | .id = V4L2_CID_HFLIP, | ||
217 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
218 | .name = "horizontal flip", | ||
219 | .minimum = 0, | ||
220 | .maximum = 1, | ||
221 | .step = 1, | ||
222 | .default_value = 0, | ||
223 | }, | ||
224 | .set = po1030_set_hflip, | ||
225 | .get = po1030_get_hflip | ||
226 | }, { | ||
227 | { | ||
228 | .id = V4L2_CID_VFLIP, | ||
229 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
230 | .name = "vertical flip", | ||
231 | .minimum = 0, | ||
232 | .maximum = 1, | ||
233 | .step = 1, | ||
234 | .default_value = 0, | ||
235 | }, | ||
236 | .set = po1030_set_vflip, | ||
237 | .get = po1030_get_vflip | ||
209 | } | 238 | } |
210 | }, | 239 | }, |
240 | |||
211 | .nmodes = 1, | 241 | .nmodes = 1, |
212 | .modes = { | 242 | .modes = { |
213 | { | 243 | { |
@@ -381,7 +411,7 @@ static const unsigned char init_po1030[][4] = | |||
381 | 411 | ||
382 | /* Set the y window to 1 */ | 412 | /* Set the y window to 1 */ |
383 | {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, | 413 | {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, |
384 | {SENSOR, PO1030_REG_WINDOWX_L, 0x01}, | 414 | {SENSOR, PO1030_REG_WINDOWY_L, 0x01}, |
385 | 415 | ||
386 | {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, | 416 | {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, |
387 | {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87}, | 417 | {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87}, |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c index 68202565325d..14b1eac5b812 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the s5k4aa sensor | 2 | * Driver for the s5k4aa sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -117,7 +117,7 @@ int s5k4aa_read_sensor(struct sd *sd, const u8 address, | |||
117 | for (i = 0; (i < len) & !err; i++) { | 117 | for (i = 0; (i < len) & !err; i++) { |
118 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | 118 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); |
119 | 119 | ||
120 | PDEBUG(DBG_TRACE, "Reading sensor register " | 120 | PDEBUG(D_CONF, "Reading sensor register " |
121 | "0x%x containing 0x%x ", address, *i2c_data); | 121 | "0x%x containing 0x%x ", address, *i2c_data); |
122 | } | 122 | } |
123 | out: | 123 | out: |
@@ -150,7 +150,7 @@ int s5k4aa_write_sensor(struct sd *sd, const u8 address, | |||
150 | memcpy(p, sensor_urb_skeleton + 16, 4); | 150 | memcpy(p, sensor_urb_skeleton + 16, 4); |
151 | p[3] = i2c_data[i]; | 151 | p[3] = i2c_data[i]; |
152 | p += 4; | 152 | p += 4; |
153 | PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", | 153 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", |
154 | address, i2c_data[i]); | 154 | address, i2c_data[i]); |
155 | } | 155 | } |
156 | 156 | ||
@@ -248,7 +248,7 @@ int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | |||
248 | *val = data << 8; | 248 | *val = data << 8; |
249 | err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); | 249 | err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); |
250 | *val |= data; | 250 | *val |= data; |
251 | PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); | 251 | PDEBUG(D_V4L2, "Read exposure %d", *val); |
252 | out: | 252 | out: |
253 | return (err < 0) ? err : 0; | 253 | return (err < 0) ? err : 0; |
254 | } | 254 | } |
@@ -259,7 +259,7 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | |||
259 | u8 data = S5K4AA_PAGE_MAP_2; | 259 | u8 data = S5K4AA_PAGE_MAP_2; |
260 | int err; | 260 | int err; |
261 | 261 | ||
262 | PDEBUG(DBG_V4L2_CID, "Set exposure to %d", val); | 262 | PDEBUG(D_V4L2, "Set exposure to %d", val); |
263 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 263 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
264 | if (err < 0) | 264 | if (err < 0) |
265 | goto out; | 265 | goto out; |
@@ -285,7 +285,7 @@ int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
285 | 285 | ||
286 | err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 286 | err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
287 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; | 287 | *val = (data & S5K4AA_RM_V_FLIP) >> 7; |
288 | PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); | 288 | PDEBUG(D_V4L2, "Read vertical flip %d", *val); |
289 | 289 | ||
290 | out: | 290 | out: |
291 | return (err < 0) ? err : 0; | 291 | return (err < 0) ? err : 0; |
@@ -297,7 +297,7 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
297 | u8 data = S5K4AA_PAGE_MAP_2; | 297 | u8 data = S5K4AA_PAGE_MAP_2; |
298 | int err; | 298 | int err; |
299 | 299 | ||
300 | PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); | 300 | PDEBUG(D_V4L2, "Set vertical flip to %d", val); |
301 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 301 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
302 | if (err < 0) | 302 | if (err < 0) |
303 | goto out; | 303 | goto out; |
@@ -341,7 +341,7 @@ int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
341 | 341 | ||
342 | err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 342 | err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
343 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; | 343 | *val = (data & S5K4AA_RM_H_FLIP) >> 6; |
344 | PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); | 344 | PDEBUG(D_V4L2, "Read horizontal flip %d", *val); |
345 | out: | 345 | out: |
346 | return (err < 0) ? err : 0; | 346 | return (err < 0) ? err : 0; |
347 | } | 347 | } |
@@ -352,7 +352,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
352 | u8 data = S5K4AA_PAGE_MAP_2; | 352 | u8 data = S5K4AA_PAGE_MAP_2; |
353 | int err; | 353 | int err; |
354 | 354 | ||
355 | PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", | 355 | PDEBUG(D_V4L2, "Set horizontal flip to %d", |
356 | val); | 356 | val); |
357 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 357 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
358 | if (err < 0) | 358 | if (err < 0) |
@@ -397,7 +397,7 @@ int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
397 | 397 | ||
398 | err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 398 | err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); |
399 | *val = data; | 399 | *val = data; |
400 | PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); | 400 | PDEBUG(D_V4L2, "Read gain %d", *val); |
401 | 401 | ||
402 | out: | 402 | out: |
403 | return (err < 0) ? err : 0; | 403 | return (err < 0) ? err : 0; |
@@ -409,7 +409,7 @@ int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
409 | u8 data = S5K4AA_PAGE_MAP_2; | 409 | u8 data = S5K4AA_PAGE_MAP_2; |
410 | int err; | 410 | int err; |
411 | 411 | ||
412 | PDEBUG(DBG_V4L2_CID, "Set gain to %d", val); | 412 | PDEBUG(D_V4L2, "Set gain to %d", val); |
413 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | 413 | err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); |
414 | if (err < 0) | 414 | if (err < 0) |
415 | goto out; | 415 | goto out; |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h index bb7f7e3e90af..eaef67655afa 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the s5k4aa sensor | 2 | * Driver for the s5k4aa sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -63,7 +63,6 @@ | |||
63 | /* Kernel module parameters */ | 63 | /* Kernel module parameters */ |
64 | extern int force_sensor; | 64 | extern int force_sensor; |
65 | extern int dump_sensor; | 65 | extern int dump_sensor; |
66 | extern unsigned int m5602_debug; | ||
67 | 66 | ||
68 | int s5k4aa_probe(struct sd *sd); | 67 | int s5k4aa_probe(struct sd *sd); |
69 | int s5k4aa_init(struct sd *sd); | 68 | int s5k4aa_init(struct sd *sd); |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c index b4b33c2d0499..8988a728e0b4 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the s5k83a sensor | 2 | * Driver for the s5k83a sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -101,7 +101,7 @@ int s5k83a_read_sensor(struct sd *sd, const u8 address, | |||
101 | for (i = 0; i < len && !len; i++) { | 101 | for (i = 0; i < len && !len; i++) { |
102 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); | 102 | err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); |
103 | 103 | ||
104 | PDEBUG(DBG_TRACE, "Reading sensor register " | 104 | PDEBUG(D_CONF, "Reading sensor register " |
105 | "0x%x containing 0x%x ", address, *i2c_data); | 105 | "0x%x containing 0x%x ", address, *i2c_data); |
106 | } | 106 | } |
107 | 107 | ||
@@ -135,7 +135,7 @@ int s5k83a_write_sensor(struct sd *sd, const u8 address, | |||
135 | memcpy(p, sensor_urb_skeleton + 16, 4); | 135 | memcpy(p, sensor_urb_skeleton + 16, 4); |
136 | p[3] = i2c_data[i]; | 136 | p[3] = i2c_data[i]; |
137 | p += 4; | 137 | p += 4; |
138 | PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", | 138 | PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x", |
139 | address, i2c_data[i]); | 139 | address, i2c_data[i]); |
140 | } | 140 | } |
141 | 141 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h index 833708eb5a42..ee3ee9cfca1d 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the s5k83a sensor | 2 | * Driver for the s5k83a sensor |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
@@ -41,8 +41,6 @@ | |||
41 | /* Kernel module parameters */ | 41 | /* Kernel module parameters */ |
42 | extern int force_sensor; | 42 | extern int force_sensor; |
43 | extern int dump_sensor; | 43 | extern int dump_sensor; |
44 | extern unsigned int m5602_debug; | ||
45 | |||
46 | 44 | ||
47 | int s5k83a_probe(struct sd *sd); | 45 | int s5k83a_probe(struct sd *sd); |
48 | int s5k83a_init(struct sd *sd); | 46 | int s5k83a_init(struct sd *sd); |
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h index 930fcaab4416..60c9a48e0c02 100644 --- a/drivers/media/video/gspca/m5602/m5602_sensor.h +++ b/drivers/media/video/gspca/m5602/m5602_sensor.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * USB Driver for ALi m5602 based webcams | 2 | * USB Driver for ALi m5602 based webcams |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Erik Andren | 4 | * Copyright (C) 2008 Erik Andrén |
5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. | 5 | * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. |
6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> | 6 | * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> |
7 | * | 7 | * |
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index b561f7c4f066..eac245d7a756 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c | |||
@@ -50,7 +50,7 @@ struct sd { | |||
50 | 50 | ||
51 | __u8 sensor; | 51 | __u8 sensor; |
52 | #define SENSOR_TAS5130A 0 | 52 | #define SENSOR_TAS5130A 0 |
53 | #define SENSOR_OTHER 1 | 53 | #define SENSOR_OM6802 1 |
54 | }; | 54 | }; |
55 | 55 | ||
56 | /* V4L2 controls supported by the driver */ | 56 | /* V4L2 controls supported by the driver */ |
@@ -188,7 +188,7 @@ static struct ctrl sd_ctrls[] = { | |||
188 | .minimum = 0, | 188 | .minimum = 0, |
189 | .maximum = 1, | 189 | .maximum = 1, |
190 | .step = 1, | 190 | .step = 1, |
191 | .default_value = 1, | 191 | .default_value = 0, |
192 | }, | 192 | }, |
193 | .set = sd_setwhitebalance, | 193 | .set = sd_setwhitebalance, |
194 | .get = sd_getwhitebalance | 194 | .get = sd_getwhitebalance |
@@ -261,6 +261,59 @@ static struct v4l2_pix_format vga_mode_t16[] = { | |||
261 | .priv = 0}, | 261 | .priv = 0}, |
262 | }; | 262 | }; |
263 | 263 | ||
264 | /* sensor specific data */ | ||
265 | struct additional_sensor_data { | ||
266 | const __u8 data1[20]; | ||
267 | const __u8 data2[18]; | ||
268 | const __u8 data3[18]; | ||
269 | const __u8 data4[4]; | ||
270 | const __u8 data5[6]; | ||
271 | const __u8 stream[4]; | ||
272 | }; | ||
273 | |||
274 | const static struct additional_sensor_data sensor_data[] = { | ||
275 | { /* TAS5130A */ | ||
276 | .data1 = | ||
277 | {0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, | ||
278 | 0xd4, 0xbb, 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, | ||
279 | 0xd8, 0xc8, 0xd9, 0xfc}, | ||
280 | .data2 = | ||
281 | {0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, | ||
282 | 0xe4, 0xa8, 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, | ||
283 | 0xe8, 0xe0}, | ||
284 | .data3 = | ||
285 | {0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, | ||
286 | 0xcb, 0xa8, 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, | ||
287 | 0xcf, 0xe0}, | ||
288 | .data4 = /* Freq (50/60Hz). Splitted for test purpose */ | ||
289 | {0x66, 0x00, 0xa8, 0xe8}, | ||
290 | .data5 = | ||
291 | {0x0c, 0x03, 0xab, 0x10, 0x81, 0x20}, | ||
292 | .stream = | ||
293 | {0x0b, 0x04, 0x0a, 0x40}, | ||
294 | }, | ||
295 | { /* OM6802 */ | ||
296 | .data1 = | ||
297 | {0xd0, 0xc2, 0xd1, 0x28, 0xd2, 0x0f, 0xd3, 0x22, | ||
298 | 0xd4, 0xcd, 0xd5, 0x27, 0xd6, 0x2c, 0xd7, 0x06, | ||
299 | 0xd8, 0xb3, 0xd9, 0xfc}, | ||
300 | .data2 = | ||
301 | {0xe0, 0x80, 0xe1, 0xff, 0xe2, 0xff, 0xe3, 0x80, | ||
302 | 0xe4, 0xff, 0xe5, 0xff, 0xe6, 0x80, 0xe7, 0xff, | ||
303 | 0xe8, 0xff}, | ||
304 | .data3 = | ||
305 | {0xc7, 0x80, 0xc8, 0xff, 0xc9, 0xff, 0xca, 0x80, | ||
306 | 0xcb, 0xff, 0xcc, 0xff, 0xcd, 0x80, 0xce, 0xff, | ||
307 | 0xcf, 0xff}, | ||
308 | .data4 = /*Freq (50/60Hz). Splitted for test purpose */ | ||
309 | {0x66, 0xca, 0xa8, 0xf0 }, | ||
310 | .data5 = /* this could be removed later */ | ||
311 | {0x0c, 0x03, 0xab, 0x13, 0x81, 0x23}, | ||
312 | .stream = | ||
313 | {0x0b, 0x04, 0x0a, 0x78}, | ||
314 | } | ||
315 | }; | ||
316 | |||
264 | #define MAX_EFFECTS 7 | 317 | #define MAX_EFFECTS 7 |
265 | /* easily done by soft, this table could be removed, | 318 | /* easily done by soft, this table could be removed, |
266 | * i keep it here just in case */ | 319 | * i keep it here just in case */ |
@@ -365,6 +418,8 @@ static const __u8 tas5130a_sensor_init[][8] = { | |||
365 | {}, | 418 | {}, |
366 | }; | 419 | }; |
367 | 420 | ||
421 | static __u8 sensor_reset[] = {0x61, 0x68, 0x62, 0xff, 0x60, 0x07}; | ||
422 | |||
368 | /* read 1 byte */ | 423 | /* read 1 byte */ |
369 | static int reg_r(struct gspca_dev *gspca_dev, | 424 | static int reg_r(struct gspca_dev *gspca_dev, |
370 | __u16 index) | 425 | __u16 index) |
@@ -385,12 +440,12 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
385 | usb_control_msg(gspca_dev->dev, | 440 | usb_control_msg(gspca_dev->dev, |
386 | usb_sndctrlpipe(gspca_dev->dev, 0), | 441 | usb_sndctrlpipe(gspca_dev->dev, 0), |
387 | 0, | 442 | 0, |
388 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 443 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
389 | 0, index, | 444 | 0, index, |
390 | NULL, 0, 500); | 445 | NULL, 0, 500); |
391 | } | 446 | } |
392 | 447 | ||
393 | static void i2c_w(struct gspca_dev *gspca_dev, | 448 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
394 | const __u8 *buffer, __u16 len) | 449 | const __u8 *buffer, __u16 len) |
395 | { | 450 | { |
396 | if (len <= USB_BUF_SZ) { | 451 | if (len <= USB_BUF_SZ) { |
@@ -398,7 +453,7 @@ static void i2c_w(struct gspca_dev *gspca_dev, | |||
398 | usb_control_msg(gspca_dev->dev, | 453 | usb_control_msg(gspca_dev->dev, |
399 | usb_sndctrlpipe(gspca_dev->dev, 0), | 454 | usb_sndctrlpipe(gspca_dev->dev, 0), |
400 | 0, | 455 | 0, |
401 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 456 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
402 | 0x01, 0, | 457 | 0x01, 0, |
403 | gspca_dev->usb_buf, len, 500); | 458 | gspca_dev->usb_buf, len, 500); |
404 | } else { | 459 | } else { |
@@ -409,14 +464,15 @@ static void i2c_w(struct gspca_dev *gspca_dev, | |||
409 | usb_control_msg(gspca_dev->dev, | 464 | usb_control_msg(gspca_dev->dev, |
410 | usb_sndctrlpipe(gspca_dev->dev, 0), | 465 | usb_sndctrlpipe(gspca_dev->dev, 0), |
411 | 0, | 466 | 0, |
412 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 467 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
413 | 0x01, 0, | 468 | 0x01, 0, |
414 | tmpbuf, len, 500); | 469 | tmpbuf, len, 500); |
415 | kfree(tmpbuf); | 470 | kfree(tmpbuf); |
416 | } | 471 | } |
417 | } | 472 | } |
418 | 473 | ||
419 | static void other_sensor_init(struct gspca_dev *gspca_dev) | 474 | /* Reported as OM6802*/ |
475 | static void om6802_sensor_init(struct gspca_dev *gspca_dev) | ||
420 | { | 476 | { |
421 | int i; | 477 | int i; |
422 | const __u8 *p; | 478 | const __u8 *p; |
@@ -436,19 +492,32 @@ static void other_sensor_init(struct gspca_dev *gspca_dev) | |||
436 | 0x90, 0x24, | 492 | 0x90, 0x24, |
437 | 0x91, 0xb2, | 493 | 0x91, 0xb2, |
438 | 0x82, 0x32, | 494 | 0x82, 0x32, |
439 | 0xfd, 0x00, | ||
440 | 0xfd, 0x01, | ||
441 | 0xfd, 0x41, | 495 | 0xfd, 0x41, |
442 | 0x00 /* table end */ | 496 | 0x00 /* table end */ |
443 | }; | 497 | }; |
444 | 498 | ||
499 | reg_w_buf(gspca_dev, sensor_reset, sizeof sensor_reset); | ||
500 | msleep(5); | ||
501 | i = 4; | ||
502 | while (--i < 0) { | ||
503 | byte = reg_r(gspca_dev, 0x0060); | ||
504 | if (!(byte & 0x01)) | ||
505 | break; | ||
506 | msleep(100); | ||
507 | } | ||
508 | byte = reg_r(gspca_dev, 0x0063); | ||
509 | if (byte != 0x17) { | ||
510 | err("Bad sensor reset %02x", byte); | ||
511 | /* continue? */ | ||
512 | } | ||
513 | |||
445 | p = sensor_init; | 514 | p = sensor_init; |
446 | while (*p != 0) { | 515 | while (*p != 0) { |
447 | val[1] = *p++; | 516 | val[1] = *p++; |
448 | val[3] = *p++; | 517 | val[3] = *p++; |
449 | if (*p == 0) | 518 | if (*p == 0) |
450 | reg_w(gspca_dev, 0x3c80); | 519 | reg_w(gspca_dev, 0x3c80); |
451 | i2c_w(gspca_dev, val, sizeof val); | 520 | reg_w_buf(gspca_dev, val, sizeof val); |
452 | i = 4; | 521 | i = 4; |
453 | while (--i >= 0) { | 522 | while (--i >= 0) { |
454 | msleep(15); | 523 | msleep(15); |
@@ -457,7 +526,8 @@ static void other_sensor_init(struct gspca_dev *gspca_dev) | |||
457 | break; | 526 | break; |
458 | } | 527 | } |
459 | } | 528 | } |
460 | reg_w(gspca_dev, 0x3c80); | 529 | msleep(15); |
530 | reg_w(gspca_dev, 0x3c80); | ||
461 | } | 531 | } |
462 | 532 | ||
463 | /* this function is called at probe time */ | 533 | /* this function is called at probe time */ |
@@ -485,12 +555,75 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
485 | return 0; | 555 | return 0; |
486 | } | 556 | } |
487 | 557 | ||
558 | static void setbrightness(struct gspca_dev *gspca_dev) | ||
559 | { | ||
560 | struct sd *sd = (struct sd *) gspca_dev; | ||
561 | unsigned int brightness; | ||
562 | __u8 set6[4] = { 0x8f, 0x24, 0xc3, 0x00 }; | ||
563 | |||
564 | brightness = sd->brightness; | ||
565 | if (brightness < 7) { | ||
566 | set6[1] = 0x26; | ||
567 | set6[3] = 0x70 - brightness * 0x10; | ||
568 | } else { | ||
569 | set6[3] = 0x00 + ((brightness - 7) * 0x10); | ||
570 | } | ||
571 | |||
572 | reg_w_buf(gspca_dev, set6, sizeof set6); | ||
573 | } | ||
574 | |||
575 | static void setcontrast(struct gspca_dev *gspca_dev) | ||
576 | { | ||
577 | struct sd *sd = (struct sd *) gspca_dev; | ||
578 | unsigned int contrast = sd->contrast; | ||
579 | __u16 reg_to_write; | ||
580 | |||
581 | if (contrast < 7) | ||
582 | reg_to_write = 0x8ea9 - contrast * 0x200; | ||
583 | else | ||
584 | reg_to_write = 0x00a9 + (contrast - 7) * 0x200; | ||
585 | |||
586 | reg_w(gspca_dev, reg_to_write); | ||
587 | } | ||
588 | |||
589 | static void setcolors(struct gspca_dev *gspca_dev) | ||
590 | { | ||
591 | struct sd *sd = (struct sd *) gspca_dev; | ||
592 | __u16 reg_to_write; | ||
593 | |||
594 | reg_to_write = 0x80bb + sd->colors * 0x100; /* was 0xc0 */ | ||
595 | reg_w(gspca_dev, reg_to_write); | ||
596 | } | ||
597 | |||
488 | static void setgamma(struct gspca_dev *gspca_dev) | 598 | static void setgamma(struct gspca_dev *gspca_dev) |
489 | { | 599 | { |
490 | struct sd *sd = (struct sd *) gspca_dev; | 600 | struct sd *sd = (struct sd *) gspca_dev; |
491 | 601 | ||
492 | PDEBUG(D_CONF, "Gamma: %d", sd->gamma); | 602 | PDEBUG(D_CONF, "Gamma: %d", sd->gamma); |
493 | i2c_w(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); | 603 | reg_w_buf(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); |
604 | } | ||
605 | |||
606 | static void setwhitebalance(struct gspca_dev *gspca_dev) | ||
607 | { | ||
608 | struct sd *sd = (struct sd *) gspca_dev; | ||
609 | |||
610 | __u8 white_balance[8] = | ||
611 | {0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38}; | ||
612 | |||
613 | if (sd->whitebalance) | ||
614 | white_balance[7] = 0x3c; | ||
615 | |||
616 | reg_w_buf(gspca_dev, white_balance, sizeof white_balance); | ||
617 | } | ||
618 | |||
619 | static void setsharpness(struct gspca_dev *gspca_dev) | ||
620 | { | ||
621 | struct sd *sd = (struct sd *) gspca_dev; | ||
622 | __u16 reg_to_write; | ||
623 | |||
624 | reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; | ||
625 | |||
626 | reg_w(gspca_dev, reg_to_write); | ||
494 | } | 627 | } |
495 | 628 | ||
496 | /* this function is called at probe and resume time */ | 629 | /* this function is called at probe and resume time */ |
@@ -511,8 +644,6 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
511 | {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; | 644 | {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; |
512 | static const __u8 n2[] = | 645 | static const __u8 n2[] = |
513 | {0x08, 0x00}; | 646 | {0x08, 0x00}; |
514 | static const __u8 nset[] = | ||
515 | { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 }; | ||
516 | static const __u8 n3[] = | 647 | static const __u8 n3[] = |
517 | {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; | 648 | {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; |
518 | static const __u8 n4[] = | 649 | static const __u8 n4[] = |
@@ -525,51 +656,29 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
525 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, | 656 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, |
526 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, | 657 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, |
527 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; | 658 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; |
528 | static const __u8 nset4[] = { | ||
529 | 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8, | ||
530 | 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, | ||
531 | 0xe8, 0xe0 | ||
532 | }; | ||
533 | /* ojo puede ser 0xe6 en vez de 0xe9 */ | ||
534 | static const __u8 nset2[] = { | ||
535 | 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb, | ||
536 | 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, | ||
537 | 0xd8, 0xc8, 0xd9, 0xfc | ||
538 | }; | ||
539 | static const __u8 missing[] = | ||
540 | { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; | ||
541 | static const __u8 nset3[] = { | ||
542 | 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8, | ||
543 | 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, | ||
544 | 0xcf, 0xe0 | ||
545 | }; | ||
546 | static const __u8 nset5[] = | ||
547 | { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */ | ||
548 | static const __u8 nset7[4] = | ||
549 | { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */ | ||
550 | static const __u8 nset9[4] = | 659 | static const __u8 nset9[4] = |
551 | { 0x0b, 0x04, 0x0a, 0x78 }; | 660 | { 0x0b, 0x04, 0x0a, 0x78 }; |
552 | static const __u8 nset8[6] = | 661 | static const __u8 nset8[6] = |
553 | { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; | 662 | { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 }; |
554 | static const __u8 nset10[6] = | ||
555 | { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; | ||
556 | 663 | ||
557 | byte = reg_r(gspca_dev, 0x06); | 664 | byte = reg_r(gspca_dev, 0x06); |
558 | test_byte = reg_r(gspca_dev, 0x07); | 665 | test_byte = reg_r(gspca_dev, 0x07); |
559 | if (byte == 0x08 && test_byte == 0x07) { | 666 | if (byte == 0x08 && test_byte == 0x07) { |
560 | PDEBUG(D_CONF, "other sensor"); | 667 | PDEBUG(D_CONF, "sensor om6802"); |
561 | sd->sensor = SENSOR_OTHER; | 668 | sd->sensor = SENSOR_OM6802; |
669 | } else if (byte == 0x08 && test_byte == 0x01) { | ||
670 | PDEBUG(D_CONF, "sensor tas5130a"); | ||
671 | sd->sensor = SENSOR_TAS5130A; | ||
562 | } else { | 672 | } else { |
563 | PDEBUG(D_CONF, "sensor %02x %02x", byte, test_byte); | 673 | PDEBUG(D_CONF, "unknown sensor %02x %02x", byte, test_byte); |
564 | sd->sensor = SENSOR_TAS5130A; | 674 | sd->sensor = SENSOR_TAS5130A; |
565 | } | 675 | } |
566 | 676 | ||
567 | i2c_w(gspca_dev, n1, sizeof n1); | 677 | reg_w_buf(gspca_dev, n1, sizeof n1); |
568 | test_byte = 0; | 678 | test_byte = 0; |
569 | i = 5; | 679 | i = 5; |
570 | while (--i >= 0) { | 680 | while (--i >= 0) { |
571 | i2c_w(gspca_dev, nset, sizeof nset); | 681 | reg_w_buf(gspca_dev, sensor_reset, sizeof sensor_reset); |
572 | msleep(5); | ||
573 | test_byte = reg_r(gspca_dev, 0x0063); | 682 | test_byte = reg_r(gspca_dev, 0x0063); |
574 | msleep(100); | 683 | msleep(100); |
575 | if (test_byte == 0x17) | 684 | if (test_byte == 0x17) |
@@ -580,7 +689,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
580 | /* return -EIO; */ | 689 | /* return -EIO; */ |
581 | /*fixme: test - continue */ | 690 | /*fixme: test - continue */ |
582 | } | 691 | } |
583 | i2c_w(gspca_dev, n2, sizeof n2); | 692 | reg_w_buf(gspca_dev, n2, sizeof n2); |
584 | 693 | ||
585 | i = 0; | 694 | i = 0; |
586 | while (read_indexs[i] != 0x00) { | 695 | while (read_indexs[i] != 0x00) { |
@@ -590,56 +699,50 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
590 | i++; | 699 | i++; |
591 | } | 700 | } |
592 | 701 | ||
593 | i2c_w(gspca_dev, n3, sizeof n3); | 702 | reg_w_buf(gspca_dev, n3, sizeof n3); |
594 | i2c_w(gspca_dev, n4, sizeof n4); | 703 | reg_w_buf(gspca_dev, n4, sizeof n4); |
595 | reg_r(gspca_dev, 0x0080); | 704 | reg_r(gspca_dev, 0x0080); |
596 | reg_w(gspca_dev, 0x2c80); | 705 | reg_w(gspca_dev, 0x2c80); |
597 | i2c_w(gspca_dev, nset2, sizeof nset2); | 706 | |
598 | i2c_w(gspca_dev, nset3, sizeof nset3); | 707 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, |
599 | i2c_w(gspca_dev, nset4, sizeof nset4); | 708 | sizeof sensor_data[sd->sensor].data1); |
709 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, | ||
710 | sizeof sensor_data[sd->sensor].data3); | ||
711 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, | ||
712 | sizeof sensor_data[sd->sensor].data2); | ||
713 | |||
600 | reg_w(gspca_dev, 0x3880); | 714 | reg_w(gspca_dev, 0x3880); |
601 | reg_w(gspca_dev, 0x3880); | 715 | reg_w(gspca_dev, 0x3880); |
602 | reg_w(gspca_dev, 0x338e); | 716 | reg_w(gspca_dev, 0x338e); |
603 | i2c_w(gspca_dev, nset5, sizeof nset5); | ||
604 | reg_w(gspca_dev, 0x00a9); | ||
605 | setgamma(gspca_dev); | ||
606 | reg_w(gspca_dev, 0x86bb); | ||
607 | reg_w(gspca_dev, 0x4aa6); | ||
608 | 717 | ||
609 | i2c_w(gspca_dev, missing, sizeof missing); | 718 | setbrightness(gspca_dev); |
719 | setcontrast(gspca_dev); | ||
720 | setgamma(gspca_dev); | ||
721 | setcolors(gspca_dev); | ||
722 | setsharpness(gspca_dev); | ||
723 | setwhitebalance(gspca_dev); | ||
610 | 724 | ||
611 | reg_w(gspca_dev, 0x2087); | 725 | reg_w(gspca_dev, 0x2087); /* tied to white balance? */ |
612 | reg_w(gspca_dev, 0x2088); | 726 | reg_w(gspca_dev, 0x2088); |
613 | reg_w(gspca_dev, 0x2089); | 727 | reg_w(gspca_dev, 0x2089); |
614 | 728 | ||
615 | i2c_w(gspca_dev, nset7, sizeof nset7); | 729 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, |
616 | i2c_w(gspca_dev, nset10, sizeof nset10); | 730 | sizeof sensor_data[sd->sensor].data4); |
617 | i2c_w(gspca_dev, nset8, sizeof nset8); | 731 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data5, |
618 | i2c_w(gspca_dev, nset9, sizeof nset9); | 732 | sizeof sensor_data[sd->sensor].data5); |
733 | reg_w_buf(gspca_dev, nset8, sizeof nset8); | ||
734 | reg_w_buf(gspca_dev, nset9, sizeof nset9); | ||
619 | 735 | ||
620 | reg_w(gspca_dev, 0x2880); | 736 | reg_w(gspca_dev, 0x2880); |
621 | i2c_w(gspca_dev, nset2, sizeof nset2); | ||
622 | i2c_w(gspca_dev, nset3, sizeof nset3); | ||
623 | i2c_w(gspca_dev, nset4, sizeof nset4); | ||
624 | |||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | static void setbrightness(struct gspca_dev *gspca_dev) | ||
629 | { | ||
630 | struct sd *sd = (struct sd *) gspca_dev; | ||
631 | unsigned int brightness; | ||
632 | __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x00 }; | ||
633 | 737 | ||
634 | brightness = sd->brightness; | 738 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data1, |
635 | if (brightness < 7) { | 739 | sizeof sensor_data[sd->sensor].data1); |
636 | set6[3] = 0x70 - brightness * 0x10; | 740 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data3, |
637 | } else { | 741 | sizeof sensor_data[sd->sensor].data3); |
638 | set6[1] = 0x24; | 742 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data2, |
639 | set6[3] = 0x00 + ((brightness - 7) * 0x10); | 743 | sizeof sensor_data[sd->sensor].data2); |
640 | } | ||
641 | 744 | ||
642 | i2c_w(gspca_dev, set6, sizeof set6); | 745 | return 0; |
643 | } | 746 | } |
644 | 747 | ||
645 | static void setflip(struct gspca_dev *gspca_dev) | 748 | static void setflip(struct gspca_dev *gspca_dev) |
@@ -651,14 +754,15 @@ static void setflip(struct gspca_dev *gspca_dev) | |||
651 | if (sd->mirror) | 754 | if (sd->mirror) |
652 | flipcmd[3] = 0x01; | 755 | flipcmd[3] = 0x01; |
653 | 756 | ||
654 | i2c_w(gspca_dev, flipcmd, sizeof flipcmd); | 757 | reg_w_buf(gspca_dev, flipcmd, sizeof flipcmd); |
655 | } | 758 | } |
656 | 759 | ||
657 | static void seteffect(struct gspca_dev *gspca_dev) | 760 | static void seteffect(struct gspca_dev *gspca_dev) |
658 | { | 761 | { |
659 | struct sd *sd = (struct sd *) gspca_dev; | 762 | struct sd *sd = (struct sd *) gspca_dev; |
660 | 763 | ||
661 | i2c_w(gspca_dev, effects_table[sd->effect], sizeof effects_table[0]); | 764 | reg_w_buf(gspca_dev, effects_table[sd->effect], |
765 | sizeof effects_table[0]); | ||
662 | if (sd->effect == 1 || sd->effect == 5) { | 766 | if (sd->effect == 1 || sd->effect == 5) { |
663 | PDEBUG(D_CONF, | 767 | PDEBUG(D_CONF, |
664 | "This effect have been disabled for webcam \"safety\""); | 768 | "This effect have been disabled for webcam \"safety\""); |
@@ -671,19 +775,6 @@ static void seteffect(struct gspca_dev *gspca_dev) | |||
671 | reg_w(gspca_dev, 0xfaa6); | 775 | reg_w(gspca_dev, 0xfaa6); |
672 | } | 776 | } |
673 | 777 | ||
674 | static void setwhitebalance(struct gspca_dev *gspca_dev) | ||
675 | { | ||
676 | struct sd *sd = (struct sd *) gspca_dev; | ||
677 | |||
678 | __u8 white_balance[8] = | ||
679 | { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; | ||
680 | |||
681 | if (sd->whitebalance == 1) | ||
682 | white_balance[7] = 0x3c; | ||
683 | |||
684 | i2c_w(gspca_dev, white_balance, sizeof white_balance); | ||
685 | } | ||
686 | |||
687 | static void setlightfreq(struct gspca_dev *gspca_dev) | 778 | static void setlightfreq(struct gspca_dev *gspca_dev) |
688 | { | 779 | { |
689 | struct sd *sd = (struct sd *) gspca_dev; | 780 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -692,52 +783,46 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
692 | if (sd->freq == 2) /* 60hz */ | 783 | if (sd->freq == 2) /* 60hz */ |
693 | freq[1] = 0x00; | 784 | freq[1] = 0x00; |
694 | 785 | ||
695 | i2c_w(gspca_dev, freq, sizeof freq); | 786 | reg_w_buf(gspca_dev, freq, sizeof freq); |
696 | } | 787 | } |
697 | 788 | ||
698 | static void setcontrast(struct gspca_dev *gspca_dev) | 789 | /* Is this really needed? |
790 | * i added some module parameters for test with some users */ | ||
791 | static void poll_sensor(struct gspca_dev *gspca_dev) | ||
699 | { | 792 | { |
700 | struct sd *sd = (struct sd *) gspca_dev; | 793 | struct sd *sd = (struct sd *) gspca_dev; |
701 | unsigned int contrast = sd->contrast; | 794 | static const __u8 poll1[] = |
702 | __u16 reg_to_write; | 795 | {0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82, |
703 | 796 | 0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34, | |
704 | if (contrast < 7) | 797 | 0x74, 0x32, 0x75, 0x92, 0x76, 0x00, 0x09, 0x01, |
705 | reg_to_write = 0x8ea9 - (0x200 * contrast); | 798 | 0x60, 0x14}; |
706 | else | 799 | static const __u8 poll2[] = |
707 | reg_to_write = (0x00a9 + ((contrast - 7) * 0x200)); | 800 | {0x67, 0x02, 0x68, 0x71, 0x69, 0x72, 0x72, 0xa9, |
708 | 801 | 0x73, 0x02, 0x73, 0x02, 0x60, 0x14}; | |
709 | reg_w(gspca_dev, reg_to_write); | 802 | static const __u8 poll3[] = |
710 | } | 803 | {0x87, 0x3f, 0x88, 0x20, 0x89, 0x2d}; |
711 | 804 | static const __u8 poll4[] = | |
712 | static void setcolors(struct gspca_dev *gspca_dev) | 805 | {0xa6, 0x0a, 0xea, 0xcf, 0xbe, 0x26, 0xb1, 0x5f, |
713 | { | 806 | 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c, |
714 | struct sd *sd = (struct sd *) gspca_dev; | 807 | 0xc2, 0x80, 0xc3, 0x10}; |
715 | __u16 reg_to_write; | 808 | |
716 | 809 | if (sd->sensor != SENSOR_TAS5130A) { | |
717 | reg_to_write = 0xc0bb + sd->colors * 0x100; | 810 | PDEBUG(D_STREAM, "[Sensor requires polling]"); |
718 | reg_w(gspca_dev, reg_to_write); | 811 | reg_w_buf(gspca_dev, poll1, sizeof poll1); |
719 | } | 812 | reg_w_buf(gspca_dev, poll2, sizeof poll2); |
720 | 813 | reg_w_buf(gspca_dev, poll3, sizeof poll3); | |
721 | static void setsharpness(struct gspca_dev *gspca_dev) | 814 | reg_w_buf(gspca_dev, poll4, sizeof poll4); |
722 | { | 815 | } |
723 | struct sd *sd = (struct sd *) gspca_dev; | ||
724 | __u16 reg_to_write; | ||
725 | |||
726 | reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; | ||
727 | |||
728 | reg_w(gspca_dev, reg_to_write); | ||
729 | } | 816 | } |
730 | 817 | ||
731 | static int sd_start(struct gspca_dev *gspca_dev) | 818 | static int sd_start(struct gspca_dev *gspca_dev) |
732 | { | 819 | { |
733 | struct sd *sd = (struct sd *) gspca_dev; | 820 | struct sd *sd = (struct sd *) gspca_dev; |
734 | int i, mode; | 821 | int i, mode; |
735 | static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; | ||
736 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; | 822 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; |
737 | static const __u8 t3[] = | 823 | static const __u8 t3[] = |
738 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, | 824 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, |
739 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; | 825 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; |
740 | static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; | ||
741 | 826 | ||
742 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; | 827 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; |
743 | switch (mode) { | 828 | switch (mode) { |
@@ -760,25 +845,29 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
760 | if (sd->sensor == SENSOR_TAS5130A) { | 845 | if (sd->sensor == SENSOR_TAS5130A) { |
761 | i = 0; | 846 | i = 0; |
762 | while (tas5130a_sensor_init[i][0] != 0) { | 847 | while (tas5130a_sensor_init[i][0] != 0) { |
763 | i2c_w(gspca_dev, tas5130a_sensor_init[i], | 848 | reg_w_buf(gspca_dev, tas5130a_sensor_init[i], |
764 | sizeof tas5130a_sensor_init[0]); | 849 | sizeof tas5130a_sensor_init[0]); |
765 | i++; | 850 | i++; |
766 | } | 851 | } |
767 | reg_w(gspca_dev, 0x3c80); | 852 | reg_w(gspca_dev, 0x3c80); |
768 | /* just in case and to keep sync with logs (for mine) */ | 853 | /* just in case and to keep sync with logs (for mine) */ |
769 | i2c_w(gspca_dev, tas5130a_sensor_init[3], | 854 | reg_w_buf(gspca_dev, tas5130a_sensor_init[3], |
770 | sizeof tas5130a_sensor_init[0]); | 855 | sizeof tas5130a_sensor_init[0]); |
771 | reg_w(gspca_dev, 0x3c80); | 856 | reg_w(gspca_dev, 0x3c80); |
772 | } else { | 857 | } else { |
773 | other_sensor_init(gspca_dev); | 858 | om6802_sensor_init(gspca_dev); |
774 | } | 859 | } |
775 | /* just in case and to keep sync with logs (for mine) */ | 860 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, |
776 | i2c_w(gspca_dev, t1, sizeof t1); | 861 | sizeof sensor_data[sd->sensor].data4); |
777 | i2c_w(gspca_dev, t2, sizeof t2); | ||
778 | reg_r(gspca_dev, 0x0012); | 862 | reg_r(gspca_dev, 0x0012); |
779 | i2c_w(gspca_dev, t3, sizeof t3); | 863 | reg_w_buf(gspca_dev, t2, sizeof t2); |
864 | reg_w_buf(gspca_dev, t3, sizeof t3); | ||
780 | reg_w(gspca_dev, 0x0013); | 865 | reg_w(gspca_dev, 0x0013); |
781 | i2c_w(gspca_dev, t4, sizeof t4); | 866 | msleep(15); |
867 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, | ||
868 | sizeof sensor_data[sd->sensor].stream); | ||
869 | poll_sensor(gspca_dev); | ||
870 | |||
782 | /* restart on each start, just in case, sometimes regs goes wrong | 871 | /* restart on each start, just in case, sometimes regs goes wrong |
783 | * when using controls from app */ | 872 | * when using controls from app */ |
784 | setbrightness(gspca_dev); | 873 | setbrightness(gspca_dev); |
@@ -787,6 +876,19 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
787 | return 0; | 876 | return 0; |
788 | } | 877 | } |
789 | 878 | ||
879 | static void sd_stopN(struct gspca_dev *gspca_dev) | ||
880 | { | ||
881 | struct sd *sd = (struct sd *) gspca_dev; | ||
882 | |||
883 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, | ||
884 | sizeof sensor_data[sd->sensor].stream); | ||
885 | msleep(20); | ||
886 | reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, | ||
887 | sizeof sensor_data[sd->sensor].stream); | ||
888 | msleep(20); | ||
889 | reg_w(gspca_dev, 0x0309); | ||
890 | } | ||
891 | |||
790 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 892 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
791 | struct gspca_frame *frame, /* target */ | 893 | struct gspca_frame *frame, /* target */ |
792 | __u8 *data, /* isoc packet */ | 894 | __u8 *data, /* isoc packet */ |
@@ -1036,6 +1138,7 @@ static const struct sd_desc sd_desc = { | |||
1036 | .config = sd_config, | 1138 | .config = sd_config, |
1037 | .init = sd_init, | 1139 | .init = sd_init, |
1038 | .start = sd_start, | 1140 | .start = sd_start, |
1141 | .stopN = sd_stopN, | ||
1039 | .pkt_scan = sd_pkt_scan, | 1142 | .pkt_scan = sd_pkt_scan, |
1040 | .querymenu = sd_querymenu, | 1143 | .querymenu = sd_querymenu, |
1041 | }; | 1144 | }; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index b7457fc60ba5..1c404e454a36 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -600,13 +600,14 @@ retry: | |||
600 | since we may get here before the stream has been fully set-up */ | 600 | since we may get here before the stream has been fully set-up */ |
601 | if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { | 601 | if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { |
602 | while (count >= itv->dma_data_req_size) { | 602 | while (count >= itv->dma_data_req_size) { |
603 | if (!ivtv_yuv_udma_stream_frame (itv, (void __user *)user_buf)) { | 603 | rc = ivtv_yuv_udma_stream_frame(itv, (void __user *)user_buf); |
604 | bytes_written += itv->dma_data_req_size; | 604 | |
605 | user_buf += itv->dma_data_req_size; | 605 | if (rc < 0) |
606 | count -= itv->dma_data_req_size; | 606 | return rc; |
607 | } else { | 607 | |
608 | break; | 608 | bytes_written += itv->dma_data_req_size; |
609 | } | 609 | user_buf += itv->dma_data_req_size; |
610 | count -= itv->dma_data_req_size; | ||
610 | } | 611 | } |
611 | if (count == 0) { | 612 | if (count == 0) { |
612 | IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused); | 613 | IVTV_DEBUG_HI_FILE("Wrote %d bytes to %s (%d)\n", bytes_written, s->name, s->q_full.bytesused); |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 8696527ab134..208fb54842f2 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -509,7 +509,6 @@ static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_ | |||
509 | static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) | 509 | static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt) |
510 | { | 510 | { |
511 | struct ivtv_open_id *id = fh; | 511 | struct ivtv_open_id *id = fh; |
512 | struct ivtv *itv = id->itv; | ||
513 | s32 w = fmt->fmt.pix.width; | 512 | s32 w = fmt->fmt.pix.width; |
514 | s32 h = fmt->fmt.pix.height; | 513 | s32 h = fmt->fmt.pix.height; |
515 | int field = fmt->fmt.pix.field; | 514 | int field = fmt->fmt.pix.field; |
@@ -517,7 +516,22 @@ static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format | |||
517 | 516 | ||
518 | w = min(w, 720); | 517 | w = min(w, 720); |
519 | w = max(w, 2); | 518 | w = max(w, 2); |
520 | h = min(h, itv->is_out_50hz ? 576 : 480); | 519 | /* Why can the height be 576 even when the output is NTSC? |
520 | |||
521 | Internally the buffers of the PVR350 are always set to 720x576. The | ||
522 | decoded video frame will always be placed in the top left corner of | ||
523 | this buffer. For any video which is not 720x576, the buffer will | ||
524 | then be cropped to remove the unused right and lower areas, with | ||
525 | the remaining image being scaled by the hardware to fit the display | ||
526 | area. The video can be scaled both up and down, so a 720x480 video | ||
527 | can be displayed full-screen on PAL and a 720x576 video can be | ||
528 | displayed without cropping on NTSC. | ||
529 | |||
530 | Note that the scaling only occurs on the video stream, the osd | ||
531 | resolution is locked to the broadcast standard and not scaled. | ||
532 | |||
533 | Thanks to Ian Armstrong for this explanation. */ | ||
534 | h = min(h, 576); | ||
521 | h = max(h, 2); | 535 | h = max(h, 2); |
522 | if (id->type == IVTV_DEC_STREAM_TYPE_YUV) | 536 | if (id->type == IVTV_DEC_STREAM_TYPE_YUV) |
523 | fmt->fmt.pix.field = field; | 537 | fmt->fmt.pix.field = field; |
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c index 2fd4b4a44aa9..bae2d2beb709 100644 --- a/drivers/media/video/ks0127.c +++ b/drivers/media/video/ks0127.c | |||
@@ -33,27 +33,20 @@ | |||
33 | * V1.1 Gerard v.d. Horst Added some debugoutput, reset the video-standard | 33 | * V1.1 Gerard v.d. Horst Added some debugoutput, reset the video-standard |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #ifndef __KERNEL__ | ||
37 | #define __KERNEL__ | ||
38 | #endif | ||
39 | |||
40 | #include <linux/init.h> | 36 | #include <linux/init.h> |
41 | #include <linux/module.h> | 37 | #include <linux/module.h> |
42 | #include <linux/delay.h> | 38 | #include <linux/delay.h> |
43 | #include <linux/errno.h> | 39 | #include <linux/errno.h> |
44 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
45 | #include <linux/slab.h> | ||
46 | #include <linux/proc_fs.h> | ||
47 | #include "ks0127.h" | ||
48 | |||
49 | #include <linux/i2c.h> | 41 | #include <linux/i2c.h> |
50 | #include <linux/video_decoder.h> | 42 | #include <linux/video_decoder.h> |
43 | #include <media/v4l2-common.h> | ||
44 | #include <media/v4l2-i2c-drv-legacy.h> | ||
45 | #include "ks0127.h" | ||
51 | 46 | ||
52 | #define dprintk if (debug) printk | 47 | MODULE_DESCRIPTION("KS0127 video decoder driver"); |
53 | 48 | MODULE_AUTHOR("Ryan Drake"); | |
54 | /* i2c identification */ | 49 | MODULE_LICENSE("GPL"); |
55 | #define I2C_KS0127_ADDON 0xD8 | ||
56 | #define I2C_KS0127_ONBOARD 0xDA | ||
57 | 50 | ||
58 | #define KS_TYPE_UNKNOWN 0 | 51 | #define KS_TYPE_UNKNOWN 0 |
59 | #define KS_TYPE_0122S 1 | 52 | #define KS_TYPE_0122S 1 |
@@ -204,8 +197,6 @@ struct adjust { | |||
204 | }; | 197 | }; |
205 | 198 | ||
206 | struct ks0127 { | 199 | struct ks0127 { |
207 | struct i2c_client *client; | ||
208 | unsigned char addr; | ||
209 | int format_width; | 200 | int format_width; |
210 | int format_height; | 201 | int format_height; |
211 | int cap_width; | 202 | int cap_width; |
@@ -220,16 +211,18 @@ static int debug; /* insmod parameter */ | |||
220 | 211 | ||
221 | module_param(debug, int, 0); | 212 | module_param(debug, int, 0); |
222 | MODULE_PARM_DESC(debug, "Debug output"); | 213 | MODULE_PARM_DESC(debug, "Debug output"); |
223 | MODULE_LICENSE("GPL"); | ||
224 | 214 | ||
225 | static u8 reg_defaults[64]; | 215 | static u8 reg_defaults[64]; |
226 | 216 | ||
227 | |||
228 | |||
229 | static void init_reg_defaults(void) | 217 | static void init_reg_defaults(void) |
230 | { | 218 | { |
219 | static int initialized; | ||
231 | u8 *table = reg_defaults; | 220 | u8 *table = reg_defaults; |
232 | 221 | ||
222 | if (initialized) | ||
223 | return; | ||
224 | initialized = 1; | ||
225 | |||
233 | table[KS_CMDA] = 0x2c; /* VSE=0, CCIR 601, autodetect standard */ | 226 | table[KS_CMDA] = 0x2c; /* VSE=0, CCIR 601, autodetect standard */ |
234 | table[KS_CMDB] = 0x12; /* VALIGN=0, AGC control and input */ | 227 | table[KS_CMDB] = 0x12; /* VALIGN=0, AGC control and input */ |
235 | table[KS_CMDC] = 0x00; /* Test options */ | 228 | table[KS_CMDC] = 0x00; /* Test options */ |
@@ -308,50 +301,53 @@ static void init_reg_defaults(void) | |||
308 | * An explanation from kayork@mail.utexas.edu: | 301 | * An explanation from kayork@mail.utexas.edu: |
309 | * | 302 | * |
310 | * During I2C reads, the KS0127 only samples for a stop condition | 303 | * During I2C reads, the KS0127 only samples for a stop condition |
311 | * during the place where the acknoledge bit should be. Any standard | 304 | * during the place where the acknowledge bit should be. Any standard |
312 | * I2C implementation (correctly) throws in another clock transition | 305 | * I2C implementation (correctly) throws in another clock transition |
313 | * at the 9th bit, and the KS0127 will not recognize the stop condition | 306 | * at the 9th bit, and the KS0127 will not recognize the stop condition |
314 | * and will continue to clock out data. | 307 | * and will continue to clock out data. |
315 | * | 308 | * |
316 | * So we have to do the read ourself. Big deal. | 309 | * So we have to do the read ourself. Big deal. |
317 | workaround in i2c-algo-bit | 310 | * workaround in i2c-algo-bit |
318 | */ | 311 | */ |
319 | 312 | ||
320 | 313 | ||
321 | static u8 ks0127_read(struct ks0127 *ks, u8 reg) | 314 | static u8 ks0127_read(struct i2c_client *c, u8 reg) |
322 | { | 315 | { |
323 | struct i2c_client *c = ks->client; | ||
324 | char val = 0; | 316 | char val = 0; |
325 | struct i2c_msg msgs[] = { | 317 | struct i2c_msg msgs[] = { |
326 | {c->addr, 0, sizeof(reg), ®}, | 318 | { c->addr, 0, sizeof(reg), ® }, |
327 | {c->addr, I2C_M_RD | I2C_M_NO_RD_ACK, sizeof(val), &val}}; | 319 | { c->addr, I2C_M_RD | I2C_M_NO_RD_ACK, sizeof(val), &val } |
320 | }; | ||
328 | int ret; | 321 | int ret; |
329 | 322 | ||
330 | ret = i2c_transfer(c->adapter, msgs, ARRAY_SIZE(msgs)); | 323 | ret = i2c_transfer(c->adapter, msgs, ARRAY_SIZE(msgs)); |
331 | if (ret != ARRAY_SIZE(msgs)) | 324 | if (ret != ARRAY_SIZE(msgs)) |
332 | dprintk("ks0127_write error\n"); | 325 | v4l_dbg(1, debug, c, "read error\n"); |
333 | 326 | ||
334 | return val; | 327 | return val; |
335 | } | 328 | } |
336 | 329 | ||
337 | 330 | ||
338 | static void ks0127_write(struct ks0127 *ks, u8 reg, u8 val) | 331 | static void ks0127_write(struct i2c_client *c, u8 reg, u8 val) |
339 | { | 332 | { |
340 | char msg[] = {reg, val}; | 333 | struct ks0127 *ks = i2c_get_clientdata(c); |
334 | char msg[] = { reg, val }; | ||
341 | 335 | ||
342 | if (i2c_master_send(ks->client, msg, sizeof(msg)) != sizeof(msg)) | 336 | if (i2c_master_send(c, msg, sizeof(msg)) != sizeof(msg)) |
343 | dprintk("ks0127_write error\n"); | 337 | v4l_dbg(1, debug, c, "write error\n"); |
344 | 338 | ||
345 | ks->regs[reg] = val; | 339 | ks->regs[reg] = val; |
346 | } | 340 | } |
347 | 341 | ||
348 | 342 | ||
349 | /* generic bit-twiddling */ | 343 | /* generic bit-twiddling */ |
350 | static void ks0127_and_or(struct ks0127 *ks, u8 reg, u8 and_v, u8 or_v) | 344 | static void ks0127_and_or(struct i2c_client *client, u8 reg, u8 and_v, u8 or_v) |
351 | { | 345 | { |
346 | struct ks0127 *ks = i2c_get_clientdata(client); | ||
347 | |||
352 | u8 val = ks->regs[reg]; | 348 | u8 val = ks->regs[reg]; |
353 | val = (val & and_v) | or_v; | 349 | val = (val & and_v) | or_v; |
354 | ks0127_write(ks, reg, val); | 350 | ks0127_write(client, reg, val); |
355 | } | 351 | } |
356 | 352 | ||
357 | 353 | ||
@@ -359,73 +355,69 @@ static void ks0127_and_or(struct ks0127 *ks, u8 reg, u8 and_v, u8 or_v) | |||
359 | /**************************************************************************** | 355 | /**************************************************************************** |
360 | * ks0127 private api | 356 | * ks0127 private api |
361 | ****************************************************************************/ | 357 | ****************************************************************************/ |
362 | static void ks0127_reset(struct ks0127* ks) | 358 | static void ks0127_reset(struct i2c_client *c) |
363 | { | 359 | { |
364 | int i; | 360 | struct ks0127 *ks = i2c_get_clientdata(c); |
365 | u8 *table = reg_defaults; | 361 | u8 *table = reg_defaults; |
362 | int i; | ||
366 | 363 | ||
367 | ks->ks_type = KS_TYPE_UNKNOWN; | 364 | ks->ks_type = KS_TYPE_UNKNOWN; |
368 | 365 | ||
369 | dprintk("ks0127: reset\n"); | 366 | v4l_dbg(1, debug, c, "reset\n"); |
370 | msleep(1); | 367 | msleep(1); |
371 | 368 | ||
372 | /* initialize all registers to known values */ | 369 | /* initialize all registers to known values */ |
373 | /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ | 370 | /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ |
374 | 371 | ||
375 | for(i = 1; i < 33; i++) | 372 | for (i = 1; i < 33; i++) |
376 | ks0127_write(ks, i, table[i]); | 373 | ks0127_write(c, i, table[i]); |
377 | 374 | ||
378 | for(i = 35; i < 40; i++) | 375 | for (i = 35; i < 40; i++) |
379 | ks0127_write(ks, i, table[i]); | 376 | ks0127_write(c, i, table[i]); |
380 | 377 | ||
381 | for(i = 41; i < 56; i++) | 378 | for (i = 41; i < 56; i++) |
382 | ks0127_write(ks, i, table[i]); | 379 | ks0127_write(c, i, table[i]); |
383 | 380 | ||
384 | for(i = 58; i < 64; i++) | 381 | for (i = 58; i < 64; i++) |
385 | ks0127_write(ks, i, table[i]); | 382 | ks0127_write(c, i, table[i]); |
386 | 383 | ||
387 | 384 | ||
388 | if ((ks0127_read(ks, KS_STAT) & 0x80) == 0) { | 385 | if ((ks0127_read(c, KS_STAT) & 0x80) == 0) { |
389 | ks->ks_type = KS_TYPE_0122S; | 386 | ks->ks_type = KS_TYPE_0122S; |
390 | dprintk("ks0127: ks0122s Found\n"); | 387 | v4l_dbg(1, debug, c, "ks0122s found\n"); |
391 | return; | 388 | return; |
392 | } | 389 | } |
393 | 390 | ||
394 | switch(ks0127_read(ks, KS_CMDE) & 0x0f) { | 391 | switch (ks0127_read(c, KS_CMDE) & 0x0f) { |
395 | |||
396 | case 0: | 392 | case 0: |
397 | ks->ks_type = KS_TYPE_0127; | 393 | ks->ks_type = KS_TYPE_0127; |
398 | dprintk("ks0127: ks0127 found\n"); | 394 | v4l_dbg(1, debug, c, "ks0127 found\n"); |
399 | break; | 395 | break; |
400 | 396 | ||
401 | case 9: | 397 | case 9: |
402 | ks->ks_type = KS_TYPE_0127B; | 398 | ks->ks_type = KS_TYPE_0127B; |
403 | dprintk("ks0127: ks0127B Revision A found\n"); | 399 | v4l_dbg(1, debug, c, "ks0127B Revision A found\n"); |
404 | break; | 400 | break; |
405 | 401 | ||
406 | default: | 402 | default: |
407 | dprintk("ks0127: unknown revision\n"); | 403 | v4l_dbg(1, debug, c, "unknown revision\n"); |
408 | break; | 404 | break; |
409 | } | 405 | } |
410 | } | 406 | } |
411 | 407 | ||
412 | static int ks0127_command(struct i2c_client *client, | 408 | static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) |
413 | unsigned int cmd, void *arg) | ||
414 | { | 409 | { |
415 | struct ks0127 *ks = i2c_get_clientdata(client); | 410 | struct ks0127 *ks = i2c_get_clientdata(c); |
416 | 411 | int *iarg = (int *)arg; | |
417 | int *iarg = (int*)arg; | ||
418 | |||
419 | int status; | 412 | int status; |
420 | 413 | ||
421 | if (!ks) | 414 | if (!ks) |
422 | return -ENODEV; | 415 | return -ENODEV; |
423 | 416 | ||
424 | switch (cmd) { | 417 | switch (cmd) { |
425 | |||
426 | case DECODER_INIT: | 418 | case DECODER_INIT: |
427 | dprintk("ks0127: command DECODER_INIT\n"); | 419 | v4l_dbg(1, debug, c, "DECODER_INIT\n"); |
428 | ks0127_reset(ks); | 420 | ks0127_reset(c); |
429 | break; | 421 | break; |
430 | 422 | ||
431 | case DECODER_SET_INPUT: | 423 | case DECODER_SET_INPUT: |
@@ -436,161 +428,160 @@ static int ks0127_command(struct i2c_client *client, | |||
436 | case KS_INPUT_COMPOSITE_4: | 428 | case KS_INPUT_COMPOSITE_4: |
437 | case KS_INPUT_COMPOSITE_5: | 429 | case KS_INPUT_COMPOSITE_5: |
438 | case KS_INPUT_COMPOSITE_6: | 430 | case KS_INPUT_COMPOSITE_6: |
439 | dprintk("ks0127: command DECODER_SET_INPUT %d: " | 431 | v4l_dbg(1, debug, c, |
440 | "Composite\n", *iarg); | 432 | "DECODER_SET_INPUT %d: Composite\n", *iarg); |
441 | /* autodetect 50/60 Hz */ | 433 | /* autodetect 50/60 Hz */ |
442 | ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); | 434 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); |
443 | /* VSE=0 */ | 435 | /* VSE=0 */ |
444 | ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); | 436 | ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); |
445 | /* set input line */ | 437 | /* set input line */ |
446 | ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); | 438 | ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); |
447 | /* non-freerunning mode */ | 439 | /* non-freerunning mode */ |
448 | ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); | 440 | ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); |
449 | /* analog input */ | 441 | /* analog input */ |
450 | ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); | 442 | ks0127_and_or(c, KS_CMDD, 0x03, 0x00); |
451 | /* enable chroma demodulation */ | 443 | /* enable chroma demodulation */ |
452 | ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); | 444 | ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); |
453 | /* chroma trap, HYBWR=1 */ | 445 | /* chroma trap, HYBWR=1 */ |
454 | ks0127_and_or(ks, KS_LUMA, 0x00, | 446 | ks0127_and_or(c, KS_LUMA, 0x00, |
455 | (reg_defaults[KS_LUMA])|0x0c); | 447 | (reg_defaults[KS_LUMA])|0x0c); |
456 | /* scaler fullbw, luma comb off */ | 448 | /* scaler fullbw, luma comb off */ |
457 | ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); | 449 | ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); |
458 | /* manual chroma comb .25 .5 .25 */ | 450 | /* manual chroma comb .25 .5 .25 */ |
459 | ks0127_and_or(ks, KS_VERTIC, 0x0f, 0x90); | 451 | ks0127_and_or(c, KS_VERTIC, 0x0f, 0x90); |
460 | 452 | ||
461 | /* chroma path delay */ | 453 | /* chroma path delay */ |
462 | ks0127_and_or(ks, KS_CHROMB, 0x0f, 0x90); | 454 | ks0127_and_or(c, KS_CHROMB, 0x0f, 0x90); |
463 | 455 | ||
464 | ks0127_write(ks, KS_UGAIN, reg_defaults[KS_UGAIN]); | 456 | ks0127_write(c, KS_UGAIN, reg_defaults[KS_UGAIN]); |
465 | ks0127_write(ks, KS_VGAIN, reg_defaults[KS_VGAIN]); | 457 | ks0127_write(c, KS_VGAIN, reg_defaults[KS_VGAIN]); |
466 | ks0127_write(ks, KS_UVOFFH, reg_defaults[KS_UVOFFH]); | 458 | ks0127_write(c, KS_UVOFFH, reg_defaults[KS_UVOFFH]); |
467 | ks0127_write(ks, KS_UVOFFL, reg_defaults[KS_UVOFFL]); | 459 | ks0127_write(c, KS_UVOFFL, reg_defaults[KS_UVOFFL]); |
468 | break; | 460 | break; |
469 | 461 | ||
470 | case KS_INPUT_SVIDEO_1: | 462 | case KS_INPUT_SVIDEO_1: |
471 | case KS_INPUT_SVIDEO_2: | 463 | case KS_INPUT_SVIDEO_2: |
472 | case KS_INPUT_SVIDEO_3: | 464 | case KS_INPUT_SVIDEO_3: |
473 | dprintk("ks0127: command DECODER_SET_INPUT %d: " | 465 | v4l_dbg(1, debug, c, |
474 | "S-Video\n", *iarg); | 466 | "DECODER_SET_INPUT %d: S-Video\n", *iarg); |
475 | /* autodetect 50/60 Hz */ | 467 | /* autodetect 50/60 Hz */ |
476 | ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); | 468 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); |
477 | /* VSE=0 */ | 469 | /* VSE=0 */ |
478 | ks0127_and_or(ks, KS_CMDA, ~0x40, 0x00); | 470 | ks0127_and_or(c, KS_CMDA, ~0x40, 0x00); |
479 | /* set input line */ | 471 | /* set input line */ |
480 | ks0127_and_or(ks, KS_CMDB, 0xb0, *iarg); | 472 | ks0127_and_or(c, KS_CMDB, 0xb0, *iarg); |
481 | /* non-freerunning mode */ | 473 | /* non-freerunning mode */ |
482 | ks0127_and_or(ks, KS_CMDC, 0x70, 0x0a); | 474 | ks0127_and_or(c, KS_CMDC, 0x70, 0x0a); |
483 | /* analog input */ | 475 | /* analog input */ |
484 | ks0127_and_or(ks, KS_CMDD, 0x03, 0x00); | 476 | ks0127_and_or(c, KS_CMDD, 0x03, 0x00); |
485 | /* enable chroma demodulation */ | 477 | /* enable chroma demodulation */ |
486 | ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x00); | 478 | ks0127_and_or(c, KS_CTRACK, 0xcf, 0x00); |
487 | ks0127_and_or(ks, KS_LUMA, 0x00, | 479 | ks0127_and_or(c, KS_LUMA, 0x00, |
488 | reg_defaults[KS_LUMA]); | 480 | reg_defaults[KS_LUMA]); |
489 | /* disable luma comb */ | 481 | /* disable luma comb */ |
490 | ks0127_and_or(ks, KS_VERTIA, 0x08, | 482 | ks0127_and_or(c, KS_VERTIA, 0x08, |
491 | (reg_defaults[KS_VERTIA]&0xf0)|0x01); | 483 | (reg_defaults[KS_VERTIA]&0xf0)|0x01); |
492 | ks0127_and_or(ks, KS_VERTIC, 0x0f, | 484 | ks0127_and_or(c, KS_VERTIC, 0x0f, |
493 | reg_defaults[KS_VERTIC]&0xf0); | 485 | reg_defaults[KS_VERTIC]&0xf0); |
494 | 486 | ||
495 | ks0127_and_or(ks, KS_CHROMB, 0x0f, | 487 | ks0127_and_or(c, KS_CHROMB, 0x0f, |
496 | reg_defaults[KS_CHROMB]&0xf0); | 488 | reg_defaults[KS_CHROMB]&0xf0); |
497 | 489 | ||
498 | ks0127_write(ks, KS_UGAIN, reg_defaults[KS_UGAIN]); | 490 | ks0127_write(c, KS_UGAIN, reg_defaults[KS_UGAIN]); |
499 | ks0127_write(ks, KS_VGAIN, reg_defaults[KS_VGAIN]); | 491 | ks0127_write(c, KS_VGAIN, reg_defaults[KS_VGAIN]); |
500 | ks0127_write(ks, KS_UVOFFH, reg_defaults[KS_UVOFFH]); | 492 | ks0127_write(c, KS_UVOFFH, reg_defaults[KS_UVOFFH]); |
501 | ks0127_write(ks, KS_UVOFFL, reg_defaults[KS_UVOFFL]); | 493 | ks0127_write(c, KS_UVOFFL, reg_defaults[KS_UVOFFL]); |
502 | break; | 494 | break; |
503 | 495 | ||
504 | case KS_INPUT_YUV656: | 496 | case KS_INPUT_YUV656: |
505 | dprintk("ks0127: command DECODER_SET_INPUT 15: " | 497 | v4l_dbg(1, debug, c, |
506 | "YUV656\n"); | 498 | "DECODER_SET_INPUT 15: YUV656\n"); |
507 | if (ks->norm == VIDEO_MODE_NTSC || | 499 | if (ks->norm == VIDEO_MODE_NTSC || |
508 | ks->norm == KS_STD_PAL_M) | 500 | ks->norm == KS_STD_PAL_M) |
509 | /* force 60 Hz */ | 501 | /* force 60 Hz */ |
510 | ks0127_and_or(ks, KS_CMDA, 0xfc, 0x03); | 502 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); |
511 | else | 503 | else |
512 | /* force 50 Hz */ | 504 | /* force 50 Hz */ |
513 | ks0127_and_or(ks, KS_CMDA, 0xfc, 0x02); | 505 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x02); |
514 | 506 | ||
515 | ks0127_and_or(ks, KS_CMDA, 0xff, 0x40); /* VSE=1 */ | 507 | ks0127_and_or(c, KS_CMDA, 0xff, 0x40); /* VSE=1 */ |
516 | /* set input line and VALIGN */ | 508 | /* set input line and VALIGN */ |
517 | ks0127_and_or(ks, KS_CMDB, 0xb0, (*iarg | 0x40)); | 509 | ks0127_and_or(c, KS_CMDB, 0xb0, (*iarg | 0x40)); |
518 | /* freerunning mode, */ | 510 | /* freerunning mode, */ |
519 | /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ | 511 | /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ |
520 | ks0127_and_or(ks, KS_CMDC, 0x70, 0x87); | 512 | ks0127_and_or(c, KS_CMDC, 0x70, 0x87); |
521 | /* digital input, SYNDIR = 0 INPSL=01 CLKDIR=0 EAV=0 */ | 513 | /* digital input, SYNDIR = 0 INPSL=01 CLKDIR=0 EAV=0 */ |
522 | ks0127_and_or(ks, KS_CMDD, 0x03, 0x08); | 514 | ks0127_and_or(c, KS_CMDD, 0x03, 0x08); |
523 | /* disable chroma demodulation */ | 515 | /* disable chroma demodulation */ |
524 | ks0127_and_or(ks, KS_CTRACK, 0xcf, 0x30); | 516 | ks0127_and_or(c, KS_CTRACK, 0xcf, 0x30); |
525 | /* HYPK =01 CTRAP = 0 HYBWR=0 PED=1 RGBH=1 UNIT=1 */ | 517 | /* HYPK =01 CTRAP = 0 HYBWR=0 PED=1 RGBH=1 UNIT=1 */ |
526 | ks0127_and_or(ks, KS_LUMA, 0x00, 0x71); | 518 | ks0127_and_or(c, KS_LUMA, 0x00, 0x71); |
527 | ks0127_and_or(ks, KS_VERTIC, 0x0f, | 519 | ks0127_and_or(c, KS_VERTIC, 0x0f, |
528 | reg_defaults[KS_VERTIC]&0xf0); | 520 | reg_defaults[KS_VERTIC]&0xf0); |
529 | 521 | ||
530 | /* scaler fullbw, luma comb off */ | 522 | /* scaler fullbw, luma comb off */ |
531 | ks0127_and_or(ks, KS_VERTIA, 0x08, 0x81); | 523 | ks0127_and_or(c, KS_VERTIA, 0x08, 0x81); |
532 | 524 | ||
533 | ks0127_and_or(ks, KS_CHROMB, 0x0f, | 525 | ks0127_and_or(c, KS_CHROMB, 0x0f, |
534 | reg_defaults[KS_CHROMB]&0xf0); | 526 | reg_defaults[KS_CHROMB]&0xf0); |
535 | 527 | ||
536 | ks0127_and_or(ks, KS_CON, 0x00, 0x00); | 528 | ks0127_and_or(c, KS_CON, 0x00, 0x00); |
537 | ks0127_and_or(ks, KS_BRT, 0x00, 32); /* spec: 34 */ | 529 | ks0127_and_or(c, KS_BRT, 0x00, 32); /* spec: 34 */ |
538 | /* spec: 229 (e5) */ | 530 | /* spec: 229 (e5) */ |
539 | ks0127_and_or(ks, KS_SAT, 0x00, 0xe8); | 531 | ks0127_and_or(c, KS_SAT, 0x00, 0xe8); |
540 | ks0127_and_or(ks, KS_HUE, 0x00, 0); | 532 | ks0127_and_or(c, KS_HUE, 0x00, 0); |
541 | 533 | ||
542 | ks0127_and_or(ks, KS_UGAIN, 0x00, 238); | 534 | ks0127_and_or(c, KS_UGAIN, 0x00, 238); |
543 | ks0127_and_or(ks, KS_VGAIN, 0x00, 0x00); | 535 | ks0127_and_or(c, KS_VGAIN, 0x00, 0x00); |
544 | 536 | ||
545 | /*UOFF:0x30, VOFF:0x30, TSTCGN=1 */ | 537 | /*UOFF:0x30, VOFF:0x30, TSTCGN=1 */ |
546 | ks0127_and_or(ks, KS_UVOFFH, 0x00, 0x4f); | 538 | ks0127_and_or(c, KS_UVOFFH, 0x00, 0x4f); |
547 | ks0127_and_or(ks, KS_UVOFFL, 0x00, 0x00); | 539 | ks0127_and_or(c, KS_UVOFFL, 0x00, 0x00); |
548 | break; | 540 | break; |
549 | 541 | ||
550 | default: | 542 | default: |
551 | dprintk("ks0127: command DECODER_SET_INPUT: " | 543 | v4l_dbg(1, debug, c, |
552 | "Unknown input %d\n", *iarg); | 544 | "DECODER_SET_INPUT: Unknown input %d\n", *iarg); |
553 | break; | 545 | break; |
554 | } | 546 | } |
555 | 547 | ||
556 | /* hack: CDMLPF sometimes spontaneously switches on; */ | 548 | /* hack: CDMLPF sometimes spontaneously switches on; */ |
557 | /* force back off */ | 549 | /* force back off */ |
558 | ks0127_write(ks, KS_DEMOD, reg_defaults[KS_DEMOD]); | 550 | ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); |
559 | break; | 551 | break; |
560 | 552 | ||
561 | case DECODER_SET_OUTPUT: | 553 | case DECODER_SET_OUTPUT: |
562 | switch(*iarg) { | 554 | switch(*iarg) { |
563 | case KS_OUTPUT_YUV656E: | 555 | case KS_OUTPUT_YUV656E: |
564 | dprintk("ks0127: command DECODER_SET_OUTPUT: " | 556 | v4l_dbg(1, debug, c, |
565 | "OUTPUT_YUV656E (Missing)\n"); | 557 | "DECODER_SET_OUTPUT: OUTPUT_YUV656E (Missing)\n"); |
566 | return -EINVAL; | 558 | return -EINVAL; |
567 | break; | ||
568 | 559 | ||
569 | case KS_OUTPUT_EXV: | 560 | case KS_OUTPUT_EXV: |
570 | dprintk("ks0127: command DECODER_SET_OUTPUT: " | 561 | v4l_dbg(1, debug, c, |
571 | "OUTPUT_EXV\n"); | 562 | "DECODER_SET_OUTPUT: OUTPUT_EXV\n"); |
572 | ks0127_and_or(ks, KS_OFMTA, 0xf0, 0x09); | 563 | ks0127_and_or(c, KS_OFMTA, 0xf0, 0x09); |
573 | break; | 564 | break; |
574 | } | 565 | } |
575 | break; | 566 | break; |
576 | 567 | ||
577 | case DECODER_SET_NORM: //sam This block mixes old and new norm names... | 568 | case DECODER_SET_NORM: /* sam This block mixes old and new norm names... */ |
578 | /* Set to automatic SECAM/Fsc mode */ | 569 | /* Set to automatic SECAM/Fsc mode */ |
579 | ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); | 570 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); |
580 | 571 | ||
581 | ks->norm = *iarg; | 572 | ks->norm = *iarg; |
582 | switch(*iarg) | 573 | switch (*iarg) { |
583 | { | ||
584 | /* this is untested !! */ | 574 | /* this is untested !! */ |
585 | /* It just detects PAL_N/NTSC_M (no special frequencies) */ | 575 | /* It just detects PAL_N/NTSC_M (no special frequencies) */ |
586 | /* And you have to set the standard a second time afterwards */ | 576 | /* And you have to set the standard a second time afterwards */ |
587 | case VIDEO_MODE_AUTO: | 577 | case VIDEO_MODE_AUTO: |
588 | dprintk("ks0127: command DECODER_SET_NORM: AUTO\n"); | 578 | v4l_dbg(1, debug, c, |
579 | "DECODER_SET_NORM: AUTO\n"); | ||
589 | 580 | ||
590 | /* The chip determines the format */ | 581 | /* The chip determines the format */ |
591 | /* based on the current field rate */ | 582 | /* based on the current field rate */ |
592 | ks0127_and_or(ks, KS_CMDA, 0xfc, 0x00); | 583 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); |
593 | ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); | 584 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); |
594 | /* This is wrong for PAL ! As I said, */ | 585 | /* This is wrong for PAL ! As I said, */ |
595 | /* you need to set the standard once again !! */ | 586 | /* you need to set the standard once again !! */ |
596 | ks->format_height = 240; | 587 | ks->format_height = 240; |
@@ -598,84 +589,86 @@ static int ks0127_command(struct i2c_client *client, | |||
598 | break; | 589 | break; |
599 | 590 | ||
600 | case VIDEO_MODE_NTSC: | 591 | case VIDEO_MODE_NTSC: |
601 | dprintk("ks0127: command DECODER_SET_NORM: NTSC_M\n"); | 592 | v4l_dbg(1, debug, c, |
602 | ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); | 593 | "DECODER_SET_NORM: NTSC_M\n"); |
594 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); | ||
603 | ks->format_height = 240; | 595 | ks->format_height = 240; |
604 | ks->format_width = 704; | 596 | ks->format_width = 704; |
605 | break; | 597 | break; |
606 | 598 | ||
607 | case KS_STD_NTSC_N: | 599 | case KS_STD_NTSC_N: |
608 | dprintk("ks0127: command KS0127_SET_STANDARD: " | 600 | v4l_dbg(1, debug, c, |
609 | "NTSC_N (fixme)\n"); | 601 | "KS0127_SET_NORM: NTSC_N (fixme)\n"); |
610 | ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x40); | 602 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); |
611 | ks->format_height = 240; | 603 | ks->format_height = 240; |
612 | ks->format_width = 704; | 604 | ks->format_width = 704; |
613 | break; | 605 | break; |
614 | 606 | ||
615 | case VIDEO_MODE_PAL: | 607 | case VIDEO_MODE_PAL: |
616 | dprintk("ks0127: command DECODER_SET_NORM: PAL_N\n"); | 608 | v4l_dbg(1, debug, c, |
617 | ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x20); | 609 | "DECODER_SET_NORM: PAL_N\n"); |
610 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); | ||
618 | ks->format_height = 290; | 611 | ks->format_height = 290; |
619 | ks->format_width = 704; | 612 | ks->format_width = 704; |
620 | break; | 613 | break; |
621 | 614 | ||
622 | case KS_STD_PAL_M: | 615 | case KS_STD_PAL_M: |
623 | dprintk("ks0127: command KS0127_SET_STANDARD: " | 616 | v4l_dbg(1, debug, c, |
624 | "PAL_M (fixme)\n"); | 617 | "KS0127_SET_NORM: PAL_M (fixme)\n"); |
625 | ks0127_and_or(ks, KS_CHROMA, 0x9f, 0x40); | 618 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); |
626 | ks->format_height = 290; | 619 | ks->format_height = 290; |
627 | ks->format_width = 704; | 620 | ks->format_width = 704; |
628 | break; | 621 | break; |
629 | 622 | ||
630 | case VIDEO_MODE_SECAM: | 623 | case VIDEO_MODE_SECAM: |
631 | dprintk("ks0127: command KS0127_SET_STANDARD: " | 624 | v4l_dbg(1, debug, c, |
632 | "SECAM\n"); | 625 | "KS0127_SET_NORM: SECAM\n"); |
633 | ks->format_height = 290; | 626 | ks->format_height = 290; |
634 | ks->format_width = 704; | 627 | ks->format_width = 704; |
635 | 628 | ||
636 | /* set to secam autodetection */ | 629 | /* set to secam autodetection */ |
637 | ks0127_and_or(ks, KS_CHROMA, 0xdf, 0x20); | 630 | ks0127_and_or(c, KS_CHROMA, 0xdf, 0x20); |
638 | ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x00); | 631 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); |
639 | schedule_timeout_interruptible(HZ/10+1); | 632 | schedule_timeout_interruptible(HZ/10+1); |
640 | 633 | ||
641 | /* did it autodetect? */ | 634 | /* did it autodetect? */ |
642 | if (ks0127_read(ks, KS_DEMOD) & 0x40) | 635 | if (ks0127_read(c, KS_DEMOD) & 0x40) |
643 | break; | 636 | break; |
644 | 637 | ||
645 | /* force to secam mode */ | 638 | /* force to secam mode */ |
646 | ks0127_and_or(ks, KS_DEMOD, 0xf0, 0x0f); | 639 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); |
647 | break; | 640 | break; |
648 | 641 | ||
649 | default: | 642 | default: |
650 | dprintk("ks0127: command DECODER_SET_NORM: " | 643 | v4l_dbg(1, debug, c, |
651 | "Unknown norm %d\n", *iarg); | 644 | "DECODER_SET_NORM: Unknown norm %d\n", *iarg); |
652 | break; | 645 | break; |
653 | } | 646 | } |
654 | break; | 647 | break; |
655 | 648 | ||
656 | case DECODER_SET_PICTURE: | 649 | case DECODER_SET_PICTURE: |
657 | dprintk("ks0127: command DECODER_SET_PICTURE " | 650 | v4l_dbg(1, debug, c, |
658 | "not yet supported (fixme)\n"); | 651 | "DECODER_SET_PICTURE: not yet supported\n"); |
659 | return -EINVAL; | 652 | return -EINVAL; |
660 | 653 | ||
661 | //sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE | 654 | /* sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE */ |
662 | //sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE | 655 | /* sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE */ |
663 | //sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? | 656 | /* sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? */ |
664 | //sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE | 657 | /* sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE */ |
665 | //sam todo: KS0127_SET_AGC_MODE: | 658 | /* sam todo: KS0127_SET_AGC_MODE: */ |
666 | //sam todo: KS0127_SET_AGC: | 659 | /* sam todo: KS0127_SET_AGC: */ |
667 | //sam todo: KS0127_SET_CHROMA_MODE: | 660 | /* sam todo: KS0127_SET_CHROMA_MODE: */ |
668 | //sam todo: KS0127_SET_PIXCLK_MODE: | 661 | /* sam todo: KS0127_SET_PIXCLK_MODE: */ |
669 | //sam todo: KS0127_SET_GAMMA_MODE: | 662 | /* sam todo: KS0127_SET_GAMMA_MODE: */ |
670 | //sam todo: KS0127_SET_UGAIN: | 663 | /* sam todo: KS0127_SET_UGAIN: */ |
671 | //sam todo: KS0127_SET_VGAIN: | 664 | /* sam todo: KS0127_SET_VGAIN: */ |
672 | //sam todo: KS0127_SET_INVALY: | 665 | /* sam todo: KS0127_SET_INVALY: */ |
673 | //sam todo: KS0127_SET_INVALU: | 666 | /* sam todo: KS0127_SET_INVALU: */ |
674 | //sam todo: KS0127_SET_INVALV: | 667 | /* sam todo: KS0127_SET_INVALV: */ |
675 | //sam todo: KS0127_SET_UNUSEY: | 668 | /* sam todo: KS0127_SET_UNUSEY: */ |
676 | //sam todo: KS0127_SET_UNUSEU: | 669 | /* sam todo: KS0127_SET_UNUSEU: */ |
677 | //sam todo: KS0127_SET_UNUSEV: | 670 | /* sam todo: KS0127_SET_UNUSEV: */ |
678 | //sam todo: KS0127_SET_VSALIGN_MODE: | 671 | /* sam todo: KS0127_SET_VSALIGN_MODE: */ |
679 | 672 | ||
680 | case DECODER_ENABLE_OUTPUT: | 673 | case DECODER_ENABLE_OUTPUT: |
681 | { | 674 | { |
@@ -684,34 +677,32 @@ static int ks0127_command(struct i2c_client *client, | |||
684 | iarg = arg; | 677 | iarg = arg; |
685 | enable = (*iarg != 0); | 678 | enable = (*iarg != 0); |
686 | if (enable) { | 679 | if (enable) { |
687 | dprintk("ks0127: command " | 680 | v4l_dbg(1, debug, c, |
688 | "DECODER_ENABLE_OUTPUT on " | 681 | "DECODER_ENABLE_OUTPUT on\n"); |
689 | "(%d)\n", enable); | ||
690 | /* All output pins on */ | 682 | /* All output pins on */ |
691 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x30); | 683 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); |
692 | /* Obey the OEN pin */ | 684 | /* Obey the OEN pin */ |
693 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x00); | 685 | ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); |
694 | } else { | 686 | } else { |
695 | dprintk("ks0127: command " | 687 | v4l_dbg(1, debug, c, |
696 | "DECODER_ENABLE_OUTPUT off " | 688 | "DECODER_ENABLE_OUTPUT off\n"); |
697 | "(%d)\n", enable); | ||
698 | /* Video output pins off */ | 689 | /* Video output pins off */ |
699 | ks0127_and_or(ks, KS_OFMTA, 0xcf, 0x00); | 690 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); |
700 | /* Ignore the OEN pin */ | 691 | /* Ignore the OEN pin */ |
701 | ks0127_and_or(ks, KS_CDEM, 0x7f, 0x80); | 692 | ks0127_and_or(c, KS_CDEM, 0x7f, 0x80); |
702 | } | 693 | } |
703 | } | ||
704 | break; | 694 | break; |
695 | } | ||
705 | 696 | ||
706 | //sam todo: KS0127_SET_OUTPUT_MODE: | 697 | /* sam todo: KS0127_SET_OUTPUT_MODE: */ |
707 | //sam todo: KS0127_SET_WIDTH: | 698 | /* sam todo: KS0127_SET_WIDTH: */ |
708 | //sam todo: KS0127_SET_HEIGHT: | 699 | /* sam todo: KS0127_SET_HEIGHT: */ |
709 | //sam todo: KS0127_SET_HSCALE: | 700 | /* sam todo: KS0127_SET_HSCALE: */ |
710 | 701 | ||
711 | case DECODER_GET_STATUS: | 702 | case DECODER_GET_STATUS: |
712 | dprintk("ks0127: command DECODER_GET_STATUS\n"); | 703 | v4l_dbg(1, debug, c, "DECODER_GET_STATUS\n"); |
713 | *iarg = 0; | 704 | *iarg = 0; |
714 | status = ks0127_read(ks, KS_STAT); | 705 | status = ks0127_read(c, KS_STAT); |
715 | if (!(status & 0x20)) /* NOVID not set */ | 706 | if (!(status & 0x20)) /* NOVID not set */ |
716 | *iarg = (*iarg | DECODER_STATUS_GOOD); | 707 | *iarg = (*iarg | DECODER_STATUS_GOOD); |
717 | if ((status & 0x01)) /* CLOCK set */ | 708 | if ((status & 0x01)) /* CLOCK set */ |
@@ -722,124 +713,81 @@ static int ks0127_command(struct i2c_client *client, | |||
722 | *iarg = (*iarg | DECODER_STATUS_NTSC); | 713 | *iarg = (*iarg | DECODER_STATUS_NTSC); |
723 | break; | 714 | break; |
724 | 715 | ||
725 | //Catch any unknown command | 716 | /* Catch any unknown command */ |
726 | default: | 717 | default: |
727 | dprintk("ks0127: command unknown: %04X\n", cmd); | 718 | v4l_dbg(1, debug, c, "unknown: 0x%08x\n", cmd); |
728 | return -EINVAL; | 719 | return -EINVAL; |
729 | } | 720 | } |
730 | return 0; | 721 | return 0; |
731 | } | 722 | } |
732 | 723 | ||
733 | 724 | ||
734 | |||
735 | |||
736 | static int ks0127_probe(struct i2c_adapter *adapter); | ||
737 | static int ks0127_detach(struct i2c_client *client); | ||
738 | static int ks0127_command(struct i2c_client *client, | ||
739 | unsigned int cmd, void *arg); | ||
740 | |||
741 | |||
742 | |||
743 | /* Addresses to scan */ | 725 | /* Addresses to scan */ |
744 | static unsigned short normal_i2c[] = {I2C_KS0127_ADDON>>1, | 726 | #define I2C_KS0127_ADDON 0xD8 |
745 | I2C_KS0127_ONBOARD>>1, I2C_CLIENT_END}; | 727 | #define I2C_KS0127_ONBOARD 0xDA |
746 | static unsigned short probe[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; | ||
747 | static unsigned short ignore[2] = {I2C_CLIENT_END, I2C_CLIENT_END}; | ||
748 | static struct i2c_client_address_data addr_data = { | ||
749 | normal_i2c, | ||
750 | probe, | ||
751 | ignore, | ||
752 | }; | ||
753 | 728 | ||
754 | static struct i2c_driver i2c_driver_ks0127 = { | 729 | static unsigned short normal_i2c[] = { |
755 | .driver.name = "ks0127", | 730 | I2C_KS0127_ADDON >> 1, |
756 | .id = I2C_DRIVERID_KS0127, | 731 | I2C_KS0127_ONBOARD >> 1, |
757 | .attach_adapter = ks0127_probe, | 732 | I2C_CLIENT_END |
758 | .detach_client = ks0127_detach, | ||
759 | .command = ks0127_command | ||
760 | }; | 733 | }; |
761 | 734 | ||
762 | static struct i2c_client ks0127_client_tmpl = | 735 | I2C_CLIENT_INSMOD; |
763 | { | ||
764 | .name = "(ks0127 unset)", | ||
765 | .addr = 0, | ||
766 | .adapter = NULL, | ||
767 | .driver = &i2c_driver_ks0127, | ||
768 | }; | ||
769 | 736 | ||
770 | static int ks0127_found_proc(struct i2c_adapter *adapter, int addr, int kind) | 737 | static int ks0127_probe(struct i2c_client *c, const struct i2c_device_id *id) |
771 | { | 738 | { |
772 | struct ks0127 *ks; | 739 | struct ks0127 *ks; |
773 | struct i2c_client *client; | ||
774 | 740 | ||
775 | client = kzalloc(sizeof(*client), GFP_KERNEL); | 741 | v4l_info(c, "%s chip found @ 0x%x (%s)\n", |
776 | if (client == NULL) | 742 | c->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board", |
777 | return -ENOMEM; | 743 | c->addr << 1, c->adapter->name); |
778 | memcpy(client, &ks0127_client_tmpl, sizeof(*client)); | ||
779 | 744 | ||
780 | ks = kzalloc(sizeof(*ks), GFP_KERNEL); | 745 | ks = kzalloc(sizeof(*ks), GFP_KERNEL); |
781 | if (ks == NULL) { | 746 | if (ks == NULL) |
782 | kfree(client); | ||
783 | return -ENOMEM; | 747 | return -ENOMEM; |
784 | } | ||
785 | 748 | ||
786 | i2c_set_clientdata(client, ks); | 749 | i2c_set_clientdata(c, ks); |
787 | client->adapter = adapter; | ||
788 | client->addr = addr; | ||
789 | sprintf(client->name, "ks0127-%02x", adapter->id); | ||
790 | 750 | ||
791 | ks->client = client; | ||
792 | ks->addr = addr; | ||
793 | ks->ks_type = KS_TYPE_UNKNOWN; | 751 | ks->ks_type = KS_TYPE_UNKNOWN; |
794 | 752 | ||
795 | /* power up */ | 753 | /* power up */ |
796 | ks0127_write(ks, KS_CMDA, 0x2c); | 754 | init_reg_defaults(); |
755 | ks0127_write(c, KS_CMDA, 0x2c); | ||
797 | mdelay(10); | 756 | mdelay(10); |
798 | 757 | ||
799 | /* reset the device */ | 758 | /* reset the device */ |
800 | ks0127_reset(ks); | 759 | ks0127_reset(c); |
801 | printk(KERN_INFO "ks0127: attach: %s video decoder\n", | ||
802 | ks->addr==(I2C_KS0127_ADDON>>1) ? "addon" : "on-board"); | ||
803 | |||
804 | i2c_attach_client(client); | ||
805 | return 0; | 760 | return 0; |
806 | } | 761 | } |
807 | 762 | ||
808 | 763 | static int ks0127_remove(struct i2c_client *c) | |
809 | static int ks0127_probe(struct i2c_adapter *adapter) | ||
810 | { | 764 | { |
811 | if (adapter->id == I2C_HW_B_ZR36067) | 765 | struct ks0127 *ks = i2c_get_clientdata(c); |
812 | return i2c_probe(adapter, &addr_data, ks0127_found_proc); | ||
813 | return 0; | ||
814 | } | ||
815 | |||
816 | static int ks0127_detach(struct i2c_client *client) | ||
817 | { | ||
818 | struct ks0127 *ks = i2c_get_clientdata(client); | ||
819 | 766 | ||
820 | ks0127_write(ks, KS_OFMTA, 0x20); /*tristate*/ | 767 | ks0127_write(c, KS_OFMTA, 0x20); /* tristate */ |
821 | ks0127_write(ks, KS_CMDA, 0x2c | 0x80); /* power down */ | 768 | ks0127_write(c, KS_CMDA, 0x2c | 0x80); /* power down */ |
822 | 769 | ||
823 | i2c_detach_client(client); | ||
824 | kfree(ks); | 770 | kfree(ks); |
825 | kfree(client); | ||
826 | |||
827 | dprintk("ks0127: detach\n"); | ||
828 | return 0; | 771 | return 0; |
829 | } | 772 | } |
830 | 773 | ||
831 | 774 | static int ks0127_legacy_probe(struct i2c_adapter *adapter) | |
832 | static int __devinit ks0127_init_module(void) | ||
833 | { | 775 | { |
834 | init_reg_defaults(); | 776 | return adapter->id == I2C_HW_B_ZR36067; |
835 | return i2c_add_driver(&i2c_driver_ks0127); | ||
836 | } | 777 | } |
837 | 778 | ||
838 | static void __devexit ks0127_cleanup_module(void) | 779 | static const struct i2c_device_id ks0127_id[] = { |
839 | { | 780 | { "ks0127", 0 }, |
840 | i2c_del_driver(&i2c_driver_ks0127); | 781 | { } |
841 | } | 782 | }; |
842 | 783 | MODULE_DEVICE_TABLE(i2c, ks0127_id); | |
843 | 784 | ||
844 | module_init(ks0127_init_module); | 785 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
845 | module_exit(ks0127_cleanup_module); | 786 | .name = "ks0127", |
787 | .driverid = I2C_DRIVERID_KS0127, | ||
788 | .command = ks0127_command, | ||
789 | .probe = ks0127_probe, | ||
790 | .remove = ks0127_remove, | ||
791 | .legacy_probe = ks0127_legacy_probe, | ||
792 | .id_table = ks0127_id, | ||
793 | }; | ||
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); | ||
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 96c3d4357722..a4738a2fb4d3 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -28,43 +28,24 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | ||
32 | #include <linux/delay.h> | ||
33 | #include <linux/errno.h> | ||
34 | #include <linux/fs.h> | ||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/major.h> | ||
37 | #include <linux/slab.h> | ||
38 | #include <linux/mm.h> | ||
39 | #include <linux/signal.h> | ||
40 | #include <linux/types.h> | 31 | #include <linux/types.h> |
41 | #include <linux/i2c.h> | 32 | #include <linux/ioctl.h> |
42 | #include <asm/io.h> | ||
43 | #include <asm/pgtable.h> | ||
44 | #include <asm/page.h> | ||
45 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
46 | 34 | #include <linux/i2c.h> | |
35 | #include <linux/i2c-id.h> | ||
47 | #include <linux/videodev.h> | 36 | #include <linux/videodev.h> |
48 | #include <linux/video_decoder.h> | 37 | #include <linux/video_decoder.h> |
38 | #include <media/v4l2-common.h> | ||
39 | #include <media/v4l2-i2c-drv-legacy.h> | ||
49 | 40 | ||
50 | MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); | 41 | MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); |
51 | MODULE_AUTHOR("Dave Perks"); | 42 | MODULE_AUTHOR("Dave Perks"); |
52 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
53 | 44 | ||
54 | |||
55 | #define I2C_NAME(s) (s)->name | ||
56 | |||
57 | |||
58 | static int debug; | 45 | static int debug; |
59 | module_param(debug, int, 0644); | 46 | module_param(debug, int, 0644); |
60 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 47 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
61 | 48 | ||
62 | #define dprintk(num, format, args...) \ | ||
63 | do { \ | ||
64 | if (debug >= num) \ | ||
65 | printk(format, ##args); \ | ||
66 | } while (0) | ||
67 | |||
68 | /* ----------------------------------------------------------------------- */ | 49 | /* ----------------------------------------------------------------------- */ |
69 | 50 | ||
70 | #define SAA7111_NR_REG 0x18 | 51 | #define SAA7111_NR_REG 0x18 |
@@ -77,14 +58,9 @@ struct saa7111 { | |||
77 | int enable; | 58 | int enable; |
78 | }; | 59 | }; |
79 | 60 | ||
80 | #define I2C_SAA7111 0x48 | ||
81 | |||
82 | /* ----------------------------------------------------------------------- */ | 61 | /* ----------------------------------------------------------------------- */ |
83 | 62 | ||
84 | static inline int | 63 | static inline int saa7111_write(struct i2c_client *client, u8 reg, u8 value) |
85 | saa7111_write (struct i2c_client *client, | ||
86 | u8 reg, | ||
87 | u8 value) | ||
88 | { | 64 | { |
89 | struct saa7111 *decoder = i2c_get_clientdata(client); | 65 | struct saa7111 *decoder = i2c_get_clientdata(client); |
90 | 66 | ||
@@ -92,8 +68,7 @@ saa7111_write (struct i2c_client *client, | |||
92 | return i2c_smbus_write_byte_data(client, reg, value); | 68 | return i2c_smbus_write_byte_data(client, reg, value); |
93 | } | 69 | } |
94 | 70 | ||
95 | static inline void | 71 | static inline void saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) |
96 | saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) | ||
97 | { | 72 | { |
98 | struct saa7111 *decoder = i2c_get_clientdata(client); | 73 | struct saa7111 *decoder = i2c_get_clientdata(client); |
99 | 74 | ||
@@ -103,10 +78,7 @@ saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) | |||
103 | } | 78 | } |
104 | } | 79 | } |
105 | 80 | ||
106 | static int | 81 | static int saa7111_write_block(struct i2c_client *client, const u8 *data, unsigned int len) |
107 | saa7111_write_block (struct i2c_client *client, | ||
108 | const u8 *data, | ||
109 | unsigned int len) | ||
110 | { | 82 | { |
111 | int ret = -1; | 83 | int ret = -1; |
112 | u8 reg; | 84 | u8 reg; |
@@ -127,18 +99,17 @@ saa7111_write_block (struct i2c_client *client, | |||
127 | decoder->reg[reg++] = data[1]; | 99 | decoder->reg[reg++] = data[1]; |
128 | len -= 2; | 100 | len -= 2; |
129 | data += 2; | 101 | data += 2; |
130 | } while (len >= 2 && data[0] == reg && | 102 | } while (len >= 2 && data[0] == reg && block_len < 32); |
131 | block_len < 32); | 103 | ret = i2c_master_send(client, block_data, block_len); |
132 | if ((ret = i2c_master_send(client, block_data, | 104 | if (ret < 0) |
133 | block_len)) < 0) | ||
134 | break; | 105 | break; |
135 | } | 106 | } |
136 | } else { | 107 | } else { |
137 | /* do some slow I2C emulation kind of thing */ | 108 | /* do some slow I2C emulation kind of thing */ |
138 | while (len >= 2) { | 109 | while (len >= 2) { |
139 | reg = *data++; | 110 | reg = *data++; |
140 | if ((ret = saa7111_write(client, reg, | 111 | ret = saa7111_write(client, reg, *data++); |
141 | *data++)) < 0) | 112 | if (ret < 0) |
142 | break; | 113 | break; |
143 | len -= 2; | 114 | len -= 2; |
144 | } | 115 | } |
@@ -147,16 +118,13 @@ saa7111_write_block (struct i2c_client *client, | |||
147 | return ret; | 118 | return ret; |
148 | } | 119 | } |
149 | 120 | ||
150 | static int | 121 | static int saa7111_init_decoder(struct i2c_client *client, |
151 | saa7111_init_decoder (struct i2c_client *client, | 122 | struct video_decoder_init *init) |
152 | struct video_decoder_init *init) | ||
153 | { | 123 | { |
154 | return saa7111_write_block(client, init->data, init->len); | 124 | return saa7111_write_block(client, init->data, init->len); |
155 | } | 125 | } |
156 | 126 | ||
157 | static inline int | 127 | static inline int saa7111_read(struct i2c_client *client, u8 reg) |
158 | saa7111_read (struct i2c_client *client, | ||
159 | u8 reg) | ||
160 | { | 128 | { |
161 | return i2c_smbus_read_byte_data(client, reg); | 129 | return i2c_smbus_read_byte_data(client, reg); |
162 | } | 130 | } |
@@ -203,28 +171,23 @@ static const unsigned char saa7111_i2c_init[] = { | |||
203 | 0x17, 0x00, /* 17 - VBI */ | 171 | 0x17, 0x00, /* 17 - VBI */ |
204 | }; | 172 | }; |
205 | 173 | ||
206 | static int | 174 | static int saa7111_command(struct i2c_client *client, unsigned cmd, void *arg) |
207 | saa7111_command (struct i2c_client *client, | ||
208 | unsigned int cmd, | ||
209 | void *arg) | ||
210 | { | 175 | { |
211 | struct saa7111 *decoder = i2c_get_clientdata(client); | 176 | struct saa7111 *decoder = i2c_get_clientdata(client); |
212 | 177 | ||
213 | switch (cmd) { | 178 | switch (cmd) { |
214 | |||
215 | case 0: | 179 | case 0: |
216 | break; | 180 | break; |
217 | case DECODER_INIT: | 181 | case DECODER_INIT: |
218 | { | 182 | { |
219 | struct video_decoder_init *init = arg; | 183 | struct video_decoder_init *init = arg; |
184 | struct video_decoder_init vdi; | ||
185 | |||
220 | if (NULL != init) | 186 | if (NULL != init) |
221 | return saa7111_init_decoder(client, init); | 187 | return saa7111_init_decoder(client, init); |
222 | else { | 188 | vdi.data = saa7111_i2c_init; |
223 | struct video_decoder_init vdi; | 189 | vdi.len = sizeof(saa7111_i2c_init); |
224 | vdi.data = saa7111_i2c_init; | 190 | return saa7111_init_decoder(client, &vdi); |
225 | vdi.len = sizeof(saa7111_i2c_init); | ||
226 | return saa7111_init_decoder(client, &vdi); | ||
227 | } | ||
228 | } | 191 | } |
229 | 192 | ||
230 | case DECODER_DUMP: | 193 | case DECODER_DUMP: |
@@ -234,15 +197,15 @@ saa7111_command (struct i2c_client *client, | |||
234 | for (i = 0; i < SAA7111_NR_REG; i += 16) { | 197 | for (i = 0; i < SAA7111_NR_REG; i += 16) { |
235 | int j; | 198 | int j; |
236 | 199 | ||
237 | printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); | 200 | v4l_info(client, "%03x", i); |
238 | for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { | 201 | for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { |
239 | printk(" %02x", | 202 | printk(KERN_CONT " %02x", |
240 | saa7111_read(client, i + j)); | 203 | saa7111_read(client, i + j)); |
241 | } | 204 | } |
242 | printk("\n"); | 205 | printk(KERN_CONT "\n"); |
243 | } | 206 | } |
244 | } | ||
245 | break; | 207 | break; |
208 | } | ||
246 | 209 | ||
247 | case DECODER_GET_CAPABILITIES: | 210 | case DECODER_GET_CAPABILITIES: |
248 | { | 211 | { |
@@ -255,8 +218,8 @@ saa7111_command (struct i2c_client *client, | |||
255 | VIDEO_DECODER_CCIR; | 218 | VIDEO_DECODER_CCIR; |
256 | cap->inputs = 8; | 219 | cap->inputs = 8; |
257 | cap->outputs = 1; | 220 | cap->outputs = 1; |
258 | } | ||
259 | break; | 221 | break; |
222 | } | ||
260 | 223 | ||
261 | case DECODER_GET_STATUS: | 224 | case DECODER_GET_STATUS: |
262 | { | 225 | { |
@@ -265,8 +228,7 @@ saa7111_command (struct i2c_client *client, | |||
265 | int res; | 228 | int res; |
266 | 229 | ||
267 | status = saa7111_read(client, 0x1f); | 230 | status = saa7111_read(client, 0x1f); |
268 | dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), | 231 | v4l_dbg(1, debug, client, "status: 0x%02x\n", status); |
269 | status); | ||
270 | res = 0; | 232 | res = 0; |
271 | if ((status & (1 << 6)) == 0) { | 233 | if ((status & (1 << 6)) == 0) { |
272 | res |= DECODER_STATUS_GOOD; | 234 | res |= DECODER_STATUS_GOOD; |
@@ -294,8 +256,8 @@ saa7111_command (struct i2c_client *client, | |||
294 | res |= DECODER_STATUS_COLOR; | 256 | res |= DECODER_STATUS_COLOR; |
295 | } | 257 | } |
296 | *iarg = res; | 258 | *iarg = res; |
297 | } | ||
298 | break; | 259 | break; |
260 | } | ||
299 | 261 | ||
300 | case DECODER_SET_GPIO: | 262 | case DECODER_SET_GPIO: |
301 | { | 263 | { |
@@ -362,8 +324,8 @@ saa7111_command (struct i2c_client *client, | |||
362 | 324 | ||
363 | } | 325 | } |
364 | decoder->norm = *iarg; | 326 | decoder->norm = *iarg; |
365 | } | ||
366 | break; | 327 | break; |
328 | } | ||
367 | 329 | ||
368 | case DECODER_SET_INPUT: | 330 | case DECODER_SET_INPUT: |
369 | { | 331 | { |
@@ -387,8 +349,8 @@ saa7111_command (struct i2c_client *client, | |||
387 | 3) ? 0x80 : | 349 | 3) ? 0x80 : |
388 | 0)); | 350 | 0)); |
389 | } | 351 | } |
390 | } | ||
391 | break; | 352 | break; |
353 | } | ||
392 | 354 | ||
393 | case DECODER_SET_OUTPUT: | 355 | case DECODER_SET_OUTPUT: |
394 | { | 356 | { |
@@ -398,8 +360,8 @@ saa7111_command (struct i2c_client *client, | |||
398 | if (*iarg != 0) { | 360 | if (*iarg != 0) { |
399 | return -EINVAL; | 361 | return -EINVAL; |
400 | } | 362 | } |
401 | } | ||
402 | break; | 363 | break; |
364 | } | ||
403 | 365 | ||
404 | case DECODER_ENABLE_OUTPUT: | 366 | case DECODER_ENABLE_OUTPUT: |
405 | { | 367 | { |
@@ -439,8 +401,8 @@ saa7111_command (struct i2c_client *client, | |||
439 | (decoder->reg[0x11] & 0xf3)); | 401 | (decoder->reg[0x11] & 0xf3)); |
440 | } | 402 | } |
441 | } | 403 | } |
442 | } | ||
443 | break; | 404 | break; |
405 | } | ||
444 | 406 | ||
445 | case DECODER_SET_PICTURE: | 407 | case DECODER_SET_PICTURE: |
446 | { | 408 | { |
@@ -454,8 +416,8 @@ saa7111_command (struct i2c_client *client, | |||
454 | saa7111_write(client, 0x0c, pic->colour >> 9); | 416 | saa7111_write(client, 0x0c, pic->colour >> 9); |
455 | /* We want -128 to 127 we get 0-65535 */ | 417 | /* We want -128 to 127 we get 0-65535 */ |
456 | saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); | 418 | saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); |
457 | } | ||
458 | break; | 419 | break; |
420 | } | ||
459 | 421 | ||
460 | default: | 422 | default: |
461 | return -EINVAL; | 423 | return -EINVAL; |
@@ -466,48 +428,23 @@ saa7111_command (struct i2c_client *client, | |||
466 | 428 | ||
467 | /* ----------------------------------------------------------------------- */ | 429 | /* ----------------------------------------------------------------------- */ |
468 | 430 | ||
469 | /* | 431 | static unsigned short normal_i2c[] = { 0x48 >> 1, I2C_CLIENT_END }; |
470 | * Generic i2c probe | ||
471 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
472 | */ | ||
473 | static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; | ||
474 | |||
475 | static unsigned short ignore = I2C_CLIENT_END; | ||
476 | |||
477 | static struct i2c_client_address_data addr_data = { | ||
478 | .normal_i2c = normal_i2c, | ||
479 | .probe = &ignore, | ||
480 | .ignore = &ignore, | ||
481 | }; | ||
482 | 432 | ||
483 | static struct i2c_driver i2c_driver_saa7111; | 433 | I2C_CLIENT_INSMOD; |
484 | 434 | ||
485 | static int | 435 | static int saa7111_probe(struct i2c_client *client, |
486 | saa7111_detect_client (struct i2c_adapter *adapter, | 436 | const struct i2c_device_id *id) |
487 | int address, | ||
488 | int kind) | ||
489 | { | 437 | { |
490 | int i; | 438 | int i; |
491 | struct i2c_client *client; | ||
492 | struct saa7111 *decoder; | 439 | struct saa7111 *decoder; |
493 | struct video_decoder_init vdi; | 440 | struct video_decoder_init vdi; |
494 | 441 | ||
495 | dprintk(1, | ||
496 | KERN_INFO | ||
497 | "saa7111.c: detecting saa7111 client on address 0x%x\n", | ||
498 | address << 1); | ||
499 | |||
500 | /* Check if the adapter supports the needed features */ | 442 | /* Check if the adapter supports the needed features */ |
501 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 443 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
502 | return 0; | 444 | return -ENODEV; |
503 | 445 | ||
504 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 446 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
505 | if (!client) | 447 | client->addr << 1, client->adapter->name); |
506 | return -ENOMEM; | ||
507 | client->addr = address; | ||
508 | client->adapter = adapter; | ||
509 | client->driver = &i2c_driver_saa7111; | ||
510 | strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client))); | ||
511 | 448 | ||
512 | decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); | 449 | decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); |
513 | if (decoder == NULL) { | 450 | if (decoder == NULL) { |
@@ -519,82 +456,37 @@ saa7111_detect_client (struct i2c_adapter *adapter, | |||
519 | decoder->enable = 1; | 456 | decoder->enable = 1; |
520 | i2c_set_clientdata(client, decoder); | 457 | i2c_set_clientdata(client, decoder); |
521 | 458 | ||
522 | i = i2c_attach_client(client); | ||
523 | if (i) { | ||
524 | kfree(client); | ||
525 | kfree(decoder); | ||
526 | return i; | ||
527 | } | ||
528 | |||
529 | vdi.data = saa7111_i2c_init; | 459 | vdi.data = saa7111_i2c_init; |
530 | vdi.len = sizeof(saa7111_i2c_init); | 460 | vdi.len = sizeof(saa7111_i2c_init); |
531 | i = saa7111_init_decoder(client, &vdi); | 461 | i = saa7111_init_decoder(client, &vdi); |
532 | if (i < 0) { | 462 | if (i < 0) { |
533 | dprintk(1, KERN_ERR "%s_attach error: init status %d\n", | 463 | v4l_dbg(1, debug, client, "init status %d\n", i); |
534 | I2C_NAME(client), i); | ||
535 | } else { | 464 | } else { |
536 | dprintk(1, | 465 | v4l_dbg(1, debug, client, "revision %x\n", |
537 | KERN_INFO | 466 | saa7111_read(client, 0x00) >> 4); |
538 | "%s_attach: chip version %x at address 0x%x\n", | ||
539 | I2C_NAME(client), saa7111_read(client, 0x00) >> 4, | ||
540 | client->addr << 1); | ||
541 | } | 467 | } |
542 | |||
543 | return 0; | 468 | return 0; |
544 | } | 469 | } |
545 | 470 | ||
546 | static int | 471 | static int saa7111_remove(struct i2c_client *client) |
547 | saa7111_attach_adapter (struct i2c_adapter *adapter) | ||
548 | { | 472 | { |
549 | dprintk(1, | 473 | kfree(i2c_get_clientdata(client)); |
550 | KERN_INFO | ||
551 | "saa7111.c: starting probe for adapter %s (0x%x)\n", | ||
552 | I2C_NAME(adapter), adapter->id); | ||
553 | return i2c_probe(adapter, &addr_data, &saa7111_detect_client); | ||
554 | } | ||
555 | |||
556 | static int | ||
557 | saa7111_detach_client (struct i2c_client *client) | ||
558 | { | ||
559 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
560 | int err; | ||
561 | |||
562 | err = i2c_detach_client(client); | ||
563 | if (err) { | ||
564 | return err; | ||
565 | } | ||
566 | |||
567 | kfree(decoder); | ||
568 | kfree(client); | ||
569 | |||
570 | return 0; | 474 | return 0; |
571 | } | 475 | } |
572 | 476 | ||
573 | /* ----------------------------------------------------------------------- */ | 477 | /* ----------------------------------------------------------------------- */ |
574 | 478 | ||
575 | static struct i2c_driver i2c_driver_saa7111 = { | 479 | static const struct i2c_device_id saa7111_id[] = { |
576 | .driver = { | 480 | { "saa7111_old", 0 }, /* "saa7111" maps to the saa7115 driver */ |
577 | .name = "saa7111", | 481 | { } |
578 | }, | 482 | }; |
579 | 483 | MODULE_DEVICE_TABLE(i2c, saa7111_id); | |
580 | .id = I2C_DRIVERID_SAA7111A, | ||
581 | 484 | ||
582 | .attach_adapter = saa7111_attach_adapter, | 485 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
583 | .detach_client = saa7111_detach_client, | 486 | .name = "saa7111", |
487 | .driverid = I2C_DRIVERID_SAA7111A, | ||
584 | .command = saa7111_command, | 488 | .command = saa7111_command, |
489 | .probe = saa7111_probe, | ||
490 | .remove = saa7111_remove, | ||
491 | .id_table = saa7111_id, | ||
585 | }; | 492 | }; |
586 | |||
587 | static int __init | ||
588 | saa7111_init (void) | ||
589 | { | ||
590 | return i2c_add_driver(&i2c_driver_saa7111); | ||
591 | } | ||
592 | |||
593 | static void __exit | ||
594 | saa7111_exit (void) | ||
595 | { | ||
596 | i2c_del_driver(&i2c_driver_saa7111); | ||
597 | } | ||
598 | |||
599 | module_init(saa7111_init); | ||
600 | module_exit(saa7111_exit); | ||
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index e79075533beb..7ca709fda5f4 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
@@ -29,43 +29,24 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <linux/errno.h> | ||
35 | #include <linux/fs.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/major.h> | ||
38 | #include <linux/slab.h> | ||
39 | #include <linux/mm.h> | ||
40 | #include <linux/signal.h> | ||
41 | #include <linux/types.h> | 32 | #include <linux/types.h> |
42 | #include <linux/i2c.h> | 33 | #include <linux/ioctl.h> |
43 | #include <asm/io.h> | ||
44 | #include <asm/pgtable.h> | ||
45 | #include <asm/page.h> | ||
46 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
47 | 35 | #include <linux/i2c.h> | |
36 | #include <linux/i2c-id.h> | ||
48 | #include <linux/videodev.h> | 37 | #include <linux/videodev.h> |
49 | #include <linux/video_decoder.h> | 38 | #include <linux/video_decoder.h> |
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-i2c-drv-legacy.h> | ||
50 | 41 | ||
51 | MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); | 42 | MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); |
52 | MODULE_AUTHOR("Maxim Yevtyushkin"); | 43 | MODULE_AUTHOR("Maxim Yevtyushkin"); |
53 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
54 | 45 | ||
55 | |||
56 | #define I2C_NAME(x) (x)->name | ||
57 | |||
58 | |||
59 | static int debug; | 46 | static int debug; |
60 | module_param(debug, int, 0); | 47 | module_param(debug, int, 0); |
61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 48 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
62 | 49 | ||
63 | #define dprintk(num, format, args...) \ | ||
64 | do { \ | ||
65 | if (debug >= num) \ | ||
66 | printk(format, ##args); \ | ||
67 | } while (0) | ||
68 | |||
69 | /* ----------------------------------------------------------------------- */ | 50 | /* ----------------------------------------------------------------------- */ |
70 | 51 | ||
71 | struct saa7114 { | 52 | struct saa7114 { |
@@ -81,9 +62,6 @@ struct saa7114 { | |||
81 | int playback; | 62 | int playback; |
82 | }; | 63 | }; |
83 | 64 | ||
84 | #define I2C_SAA7114 0x42 | ||
85 | #define I2C_SAA7114A 0x40 | ||
86 | |||
87 | #define I2C_DELAY 10 | 65 | #define I2C_DELAY 10 |
88 | 66 | ||
89 | 67 | ||
@@ -129,18 +107,12 @@ struct saa7114 { | |||
129 | 107 | ||
130 | /* ----------------------------------------------------------------------- */ | 108 | /* ----------------------------------------------------------------------- */ |
131 | 109 | ||
132 | static inline int | 110 | static inline int saa7114_write(struct i2c_client *client, u8 reg, u8 value) |
133 | saa7114_write (struct i2c_client *client, | ||
134 | u8 reg, | ||
135 | u8 value) | ||
136 | { | 111 | { |
137 | return i2c_smbus_write_byte_data(client, reg, value); | 112 | return i2c_smbus_write_byte_data(client, reg, value); |
138 | } | 113 | } |
139 | 114 | ||
140 | static int | 115 | static int saa7114_write_block(struct i2c_client *client, const u8 *data, unsigned int len) |
141 | saa7114_write_block (struct i2c_client *client, | ||
142 | const u8 *data, | ||
143 | unsigned int len) | ||
144 | { | 116 | { |
145 | int ret = -1; | 117 | int ret = -1; |
146 | u8 reg; | 118 | u8 reg; |
@@ -160,18 +132,17 @@ saa7114_write_block (struct i2c_client *client, | |||
160 | reg++; | 132 | reg++; |
161 | len -= 2; | 133 | len -= 2; |
162 | data += 2; | 134 | data += 2; |
163 | } while (len >= 2 && data[0] == reg && | 135 | } while (len >= 2 && data[0] == reg && block_len < 32); |
164 | block_len < 32); | 136 | ret = i2c_master_send(client, block_data, block_len); |
165 | if ((ret = i2c_master_send(client, block_data, | 137 | if (ret < 0) |
166 | block_len)) < 0) | ||
167 | break; | 138 | break; |
168 | } | 139 | } |
169 | } else { | 140 | } else { |
170 | /* do some slow I2C emulation kind of thing */ | 141 | /* do some slow I2C emulation kind of thing */ |
171 | while (len >= 2) { | 142 | while (len >= 2) { |
172 | reg = *data++; | 143 | reg = *data++; |
173 | if ((ret = saa7114_write(client, reg, | 144 | ret = saa7114_write(client, reg, *data++); |
174 | *data++)) < 0) | 145 | if (ret < 0) |
175 | break; | 146 | break; |
176 | len -= 2; | 147 | len -= 2; |
177 | } | 148 | } |
@@ -180,9 +151,7 @@ saa7114_write_block (struct i2c_client *client, | |||
180 | return ret; | 151 | return ret; |
181 | } | 152 | } |
182 | 153 | ||
183 | static inline int | 154 | static inline int saa7114_read(struct i2c_client *client, u8 reg) |
184 | saa7114_read (struct i2c_client *client, | ||
185 | u8 reg) | ||
186 | { | 155 | { |
187 | return i2c_smbus_read_byte_data(client, reg); | 156 | return i2c_smbus_read_byte_data(client, reg); |
188 | } | 157 | } |
@@ -452,15 +421,11 @@ static const unsigned char init[] = { | |||
452 | 0xef, 0x00 | 421 | 0xef, 0x00 |
453 | }; | 422 | }; |
454 | 423 | ||
455 | static int | 424 | static int saa7114_command(struct i2c_client *client, unsigned cmd, void *arg) |
456 | saa7114_command (struct i2c_client *client, | ||
457 | unsigned int cmd, | ||
458 | void *arg) | ||
459 | { | 425 | { |
460 | struct saa7114 *decoder = i2c_get_clientdata(client); | 426 | struct saa7114 *decoder = i2c_get_clientdata(client); |
461 | 427 | ||
462 | switch (cmd) { | 428 | switch (cmd) { |
463 | |||
464 | case 0: | 429 | case 0: |
465 | //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); | 430 | //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); |
466 | //saa7114_write_block(client, init, sizeof(init)); | 431 | //saa7114_write_block(client, init, sizeof(init)); |
@@ -470,27 +435,28 @@ saa7114_command (struct i2c_client *client, | |||
470 | { | 435 | { |
471 | int i; | 436 | int i; |
472 | 437 | ||
473 | dprintk(1, KERN_INFO "%s: decoder dump\n", I2C_NAME(client)); | 438 | if (!debug) |
439 | break; | ||
440 | v4l_info(client, "decoder dump\n"); | ||
474 | 441 | ||
475 | for (i = 0; i < 32; i += 16) { | 442 | for (i = 0; i < 32; i += 16) { |
476 | int j; | 443 | int j; |
477 | 444 | ||
478 | printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); | 445 | v4l_info(client, "%03x", i); |
479 | for (j = 0; j < 16; ++j) { | 446 | for (j = 0; j < 16; ++j) { |
480 | printk(" %02x", | 447 | printk(KERN_CONT " %02x", |
481 | saa7114_read(client, i + j)); | 448 | saa7114_read(client, i + j)); |
482 | } | 449 | } |
483 | printk("\n"); | 450 | printk(KERN_CONT "\n"); |
484 | } | 451 | } |
485 | } | ||
486 | break; | 452 | break; |
453 | } | ||
487 | 454 | ||
488 | case DECODER_GET_CAPABILITIES: | 455 | case DECODER_GET_CAPABILITIES: |
489 | { | 456 | { |
490 | struct video_decoder_capability *cap = arg; | 457 | struct video_decoder_capability *cap = arg; |
491 | 458 | ||
492 | dprintk(1, KERN_DEBUG "%s: decoder get capabilities\n", | 459 | v4l_dbg(1, debug, client, "get capabilities\n"); |
493 | I2C_NAME(client)); | ||
494 | 460 | ||
495 | cap->flags = VIDEO_DECODER_PAL | | 461 | cap->flags = VIDEO_DECODER_PAL | |
496 | VIDEO_DECODER_NTSC | | 462 | VIDEO_DECODER_NTSC | |
@@ -498,8 +464,8 @@ saa7114_command (struct i2c_client *client, | |||
498 | VIDEO_DECODER_CCIR; | 464 | VIDEO_DECODER_CCIR; |
499 | cap->inputs = 8; | 465 | cap->inputs = 8; |
500 | cap->outputs = 1; | 466 | cap->outputs = 1; |
501 | } | ||
502 | break; | 467 | break; |
468 | } | ||
503 | 469 | ||
504 | case DECODER_GET_STATUS: | 470 | case DECODER_GET_STATUS: |
505 | { | 471 | { |
@@ -509,8 +475,7 @@ saa7114_command (struct i2c_client *client, | |||
509 | 475 | ||
510 | status = saa7114_read(client, 0x1f); | 476 | status = saa7114_read(client, 0x1f); |
511 | 477 | ||
512 | dprintk(1, KERN_DEBUG "%s status: 0x%02x\n", I2C_NAME(client), | 478 | v4l_dbg(1, debug, client, "status: 0x%02x\n", status); |
513 | status); | ||
514 | res = 0; | 479 | res = 0; |
515 | if ((status & (1 << 6)) == 0) { | 480 | if ((status & (1 << 6)) == 0) { |
516 | res |= DECODER_STATUS_GOOD; | 481 | res |= DECODER_STATUS_GOOD; |
@@ -538,8 +503,8 @@ saa7114_command (struct i2c_client *client, | |||
538 | res |= DECODER_STATUS_COLOR; | 503 | res |= DECODER_STATUS_COLOR; |
539 | } | 504 | } |
540 | *iarg = res; | 505 | *iarg = res; |
541 | } | ||
542 | break; | 506 | break; |
507 | } | ||
543 | 508 | ||
544 | case DECODER_SET_NORM: | 509 | case DECODER_SET_NORM: |
545 | { | 510 | { |
@@ -547,12 +512,11 @@ saa7114_command (struct i2c_client *client, | |||
547 | 512 | ||
548 | short int hoff = 0, voff = 0, w = 0, h = 0; | 513 | short int hoff = 0, voff = 0, w = 0, h = 0; |
549 | 514 | ||
550 | dprintk(1, KERN_DEBUG "%s: decoder set norm ", | 515 | v4l_dbg(1, debug, client, "set norm\n"); |
551 | I2C_NAME(client)); | ||
552 | switch (*iarg) { | ||
553 | 516 | ||
517 | switch (*iarg) { | ||
554 | case VIDEO_MODE_NTSC: | 518 | case VIDEO_MODE_NTSC: |
555 | dprintk(1, "NTSC\n"); | 519 | v4l_dbg(1, debug, client, "NTSC\n"); |
556 | decoder->reg[REG_ADDR(0x06)] = | 520 | decoder->reg[REG_ADDR(0x06)] = |
557 | SAA_7114_NTSC_HSYNC_START; | 521 | SAA_7114_NTSC_HSYNC_START; |
558 | decoder->reg[REG_ADDR(0x07)] = | 522 | decoder->reg[REG_ADDR(0x07)] = |
@@ -571,7 +535,7 @@ saa7114_command (struct i2c_client *client, | |||
571 | break; | 535 | break; |
572 | 536 | ||
573 | case VIDEO_MODE_PAL: | 537 | case VIDEO_MODE_PAL: |
574 | dprintk(1, "PAL\n"); | 538 | v4l_dbg(1, debug, client, "PAL\n"); |
575 | decoder->reg[REG_ADDR(0x06)] = | 539 | decoder->reg[REG_ADDR(0x06)] = |
576 | SAA_7114_PAL_HSYNC_START; | 540 | SAA_7114_PAL_HSYNC_START; |
577 | decoder->reg[REG_ADDR(0x07)] = | 541 | decoder->reg[REG_ADDR(0x07)] = |
@@ -590,9 +554,8 @@ saa7114_command (struct i2c_client *client, | |||
590 | break; | 554 | break; |
591 | 555 | ||
592 | default: | 556 | default: |
593 | dprintk(1, " Unknown video mode!!!\n"); | 557 | v4l_dbg(1, debug, client, "Unknown video mode\n"); |
594 | return -EINVAL; | 558 | return -EINVAL; |
595 | |||
596 | } | 559 | } |
597 | 560 | ||
598 | 561 | ||
@@ -644,22 +607,20 @@ saa7114_command (struct i2c_client *client, | |||
644 | saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection | 607 | saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection |
645 | 608 | ||
646 | decoder->norm = *iarg; | 609 | decoder->norm = *iarg; |
647 | } | ||
648 | break; | 610 | break; |
611 | } | ||
649 | 612 | ||
650 | case DECODER_SET_INPUT: | 613 | case DECODER_SET_INPUT: |
651 | { | 614 | { |
652 | int *iarg = arg; | 615 | int *iarg = arg; |
653 | 616 | ||
654 | dprintk(1, KERN_DEBUG "%s: decoder set input (%d)\n", | 617 | v4l_dbg(1, debug, client, "set input (%d)\n", *iarg); |
655 | I2C_NAME(client), *iarg); | ||
656 | if (*iarg < 0 || *iarg > 7) { | 618 | if (*iarg < 0 || *iarg > 7) { |
657 | return -EINVAL; | 619 | return -EINVAL; |
658 | } | 620 | } |
659 | 621 | ||
660 | if (decoder->input != *iarg) { | 622 | if (decoder->input != *iarg) { |
661 | dprintk(1, KERN_DEBUG "%s: now setting %s input\n", | 623 | v4l_dbg(1, debug, client, "now setting %s input\n", |
662 | I2C_NAME(client), | ||
663 | *iarg >= 6 ? "S-Video" : "Composite"); | 624 | *iarg >= 6 ? "S-Video" : "Composite"); |
664 | decoder->input = *iarg; | 625 | decoder->input = *iarg; |
665 | 626 | ||
@@ -690,30 +651,29 @@ saa7114_command (struct i2c_client *client, | |||
690 | saa7114_write(client, 0x0e, | 651 | saa7114_write(client, 0x0e, |
691 | decoder->reg[REG_ADDR(0x0e)]); | 652 | decoder->reg[REG_ADDR(0x0e)]); |
692 | } | 653 | } |
693 | } | ||
694 | break; | 654 | break; |
655 | } | ||
695 | 656 | ||
696 | case DECODER_SET_OUTPUT: | 657 | case DECODER_SET_OUTPUT: |
697 | { | 658 | { |
698 | int *iarg = arg; | 659 | int *iarg = arg; |
699 | 660 | ||
700 | dprintk(1, KERN_DEBUG "%s: decoder set output\n", | 661 | v4l_dbg(1, debug, client, "set output\n"); |
701 | I2C_NAME(client)); | ||
702 | 662 | ||
703 | /* not much choice of outputs */ | 663 | /* not much choice of outputs */ |
704 | if (*iarg != 0) { | 664 | if (*iarg != 0) { |
705 | return -EINVAL; | 665 | return -EINVAL; |
706 | } | 666 | } |
707 | } | ||
708 | break; | 667 | break; |
668 | } | ||
709 | 669 | ||
710 | case DECODER_ENABLE_OUTPUT: | 670 | case DECODER_ENABLE_OUTPUT: |
711 | { | 671 | { |
712 | int *iarg = arg; | 672 | int *iarg = arg; |
713 | int enable = (*iarg != 0); | 673 | int enable = (*iarg != 0); |
714 | 674 | ||
715 | dprintk(1, KERN_DEBUG "%s: decoder %s output\n", | 675 | v4l_dbg(1, debug, client, "%s output\n", |
716 | I2C_NAME(client), enable ? "enable" : "disable"); | 676 | enable ? "enable" : "disable"); |
717 | 677 | ||
718 | decoder->playback = !enable; | 678 | decoder->playback = !enable; |
719 | 679 | ||
@@ -754,18 +714,16 @@ saa7114_command (struct i2c_client *client, | |||
754 | saa7114_write(client, 0x80, 0x36); | 714 | saa7114_write(client, 0x80, 0x36); |
755 | 715 | ||
756 | } | 716 | } |
757 | } | ||
758 | break; | 717 | break; |
718 | } | ||
759 | 719 | ||
760 | case DECODER_SET_PICTURE: | 720 | case DECODER_SET_PICTURE: |
761 | { | 721 | { |
762 | struct video_picture *pic = arg; | 722 | struct video_picture *pic = arg; |
763 | 723 | ||
764 | dprintk(1, | 724 | v4l_dbg(1, debug, client, |
765 | KERN_DEBUG | 725 | "decoder set picture bright=%d contrast=%d saturation=%d hue=%d\n", |
766 | "%s: decoder set picture bright=%d contrast=%d saturation=%d hue=%d\n", | 726 | pic->brightness, pic->contrast, pic->colour, pic->hue); |
767 | I2C_NAME(client), pic->brightness, pic->contrast, | ||
768 | pic->colour, pic->hue); | ||
769 | 727 | ||
770 | if (decoder->bright != pic->brightness) { | 728 | if (decoder->bright != pic->brightness) { |
771 | /* We want 0 to 255 we get 0-65535 */ | 729 | /* We want 0 to 255 we get 0-65535 */ |
@@ -789,8 +747,8 @@ saa7114_command (struct i2c_client *client, | |||
789 | saa7114_write(client, 0x0d, | 747 | saa7114_write(client, 0x0d, |
790 | (decoder->hue - 32768) >> 8); | 748 | (decoder->hue - 32768) >> 8); |
791 | } | 749 | } |
792 | } | ||
793 | break; | 750 | break; |
751 | } | ||
794 | 752 | ||
795 | default: | 753 | default: |
796 | return -EINVAL; | 754 | return -EINVAL; |
@@ -801,58 +759,30 @@ saa7114_command (struct i2c_client *client, | |||
801 | 759 | ||
802 | /* ----------------------------------------------------------------------- */ | 760 | /* ----------------------------------------------------------------------- */ |
803 | 761 | ||
804 | /* | 762 | static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; |
805 | * Generic i2c probe | ||
806 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
807 | */ | ||
808 | static unsigned short normal_i2c[] = | ||
809 | { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; | ||
810 | |||
811 | static unsigned short ignore = I2C_CLIENT_END; | ||
812 | |||
813 | static struct i2c_client_address_data addr_data = { | ||
814 | .normal_i2c = normal_i2c, | ||
815 | .probe = &ignore, | ||
816 | .ignore = &ignore, | ||
817 | }; | ||
818 | 763 | ||
819 | static struct i2c_driver i2c_driver_saa7114; | 764 | I2C_CLIENT_INSMOD; |
820 | 765 | ||
821 | static int | 766 | static int saa7114_probe(struct i2c_client *client, |
822 | saa7114_detect_client (struct i2c_adapter *adapter, | 767 | const struct i2c_device_id *id) |
823 | int address, | ||
824 | int kind) | ||
825 | { | 768 | { |
826 | int i, err[30]; | 769 | int i, err[30]; |
827 | short int hoff = SAA_7114_NTSC_HOFFSET; | 770 | short int hoff = SAA_7114_NTSC_HOFFSET; |
828 | short int voff = SAA_7114_NTSC_VOFFSET; | 771 | short int voff = SAA_7114_NTSC_VOFFSET; |
829 | short int w = SAA_7114_NTSC_WIDTH; | 772 | short int w = SAA_7114_NTSC_WIDTH; |
830 | short int h = SAA_7114_NTSC_HEIGHT; | 773 | short int h = SAA_7114_NTSC_HEIGHT; |
831 | struct i2c_client *client; | ||
832 | struct saa7114 *decoder; | 774 | struct saa7114 *decoder; |
833 | 775 | ||
834 | dprintk(1, | ||
835 | KERN_INFO | ||
836 | "saa7114.c: detecting saa7114 client on address 0x%x\n", | ||
837 | address << 1); | ||
838 | |||
839 | /* Check if the adapter supports the needed features */ | 776 | /* Check if the adapter supports the needed features */ |
840 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 777 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
841 | return 0; | 778 | return -ENODEV; |
842 | 779 | ||
843 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 780 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
844 | if (!client) | 781 | client->addr << 1, client->adapter->name); |
845 | return -ENOMEM; | ||
846 | client->addr = address; | ||
847 | client->adapter = adapter; | ||
848 | client->driver = &i2c_driver_saa7114; | ||
849 | strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client))); | ||
850 | 782 | ||
851 | decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); | 783 | decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); |
852 | if (decoder == NULL) { | 784 | if (decoder == NULL) |
853 | kfree(client); | ||
854 | return -ENOMEM; | 785 | return -ENOMEM; |
855 | } | ||
856 | decoder->norm = VIDEO_MODE_NTSC; | 786 | decoder->norm = VIDEO_MODE_NTSC; |
857 | decoder->input = -1; | 787 | decoder->input = -1; |
858 | decoder->enable = 1; | 788 | decoder->enable = 1; |
@@ -937,8 +867,7 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
937 | decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on | 867 | decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on |
938 | 868 | ||
939 | 869 | ||
940 | dprintk(1, KERN_DEBUG "%s_attach: starting decoder init\n", | 870 | v4l_dbg(1, debug, client, "starting init\n"); |
941 | I2C_NAME(client)); | ||
942 | 871 | ||
943 | err[0] = | 872 | err[0] = |
944 | saa7114_write_block(client, decoder->reg + (0x20 << 1), | 873 | saa7114_write_block(client, decoder->reg + (0x20 << 1), |
@@ -962,28 +891,23 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
962 | 891 | ||
963 | for (i = 0; i <= 5; i++) { | 892 | for (i = 0; i <= 5; i++) { |
964 | if (err[i] < 0) { | 893 | if (err[i] < 0) { |
965 | dprintk(1, | 894 | v4l_dbg(1, debug, client, |
966 | KERN_ERR | 895 | "init error %d at stage %d, leaving attach.\n", |
967 | "%s_attach: init error %d at stage %d, leaving attach.\n", | 896 | i, err[i]); |
968 | I2C_NAME(client), i, err[i]); | ||
969 | kfree(decoder); | 897 | kfree(decoder); |
970 | kfree(client); | 898 | return -EIO; |
971 | return 0; | ||
972 | } | 899 | } |
973 | } | 900 | } |
974 | 901 | ||
975 | for (i = 6; i < 8; i++) { | 902 | for (i = 6; i < 8; i++) { |
976 | dprintk(1, | 903 | v4l_dbg(1, debug, client, |
977 | KERN_DEBUG | 904 | "reg[0x%02x] = 0x%02x (0x%02x)\n", |
978 | "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", | 905 | i, saa7114_read(client, i), |
979 | I2C_NAME(client), i, saa7114_read(client, i), | ||
980 | decoder->reg[REG_ADDR(i)]); | 906 | decoder->reg[REG_ADDR(i)]); |
981 | } | 907 | } |
982 | 908 | ||
983 | dprintk(1, | 909 | v4l_dbg(1, debug, client, |
984 | KERN_DEBUG | 910 | "performing decoder reset sequence\n"); |
985 | "%s_attach: performing decoder reset sequence\n", | ||
986 | I2C_NAME(client)); | ||
987 | 911 | ||
988 | err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off | 912 | err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off |
989 | err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler | 913 | err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler |
@@ -991,19 +915,15 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
991 | 915 | ||
992 | for (i = 6; i <= 8; i++) { | 916 | for (i = 6; i <= 8; i++) { |
993 | if (err[i] < 0) { | 917 | if (err[i] < 0) { |
994 | dprintk(1, | 918 | v4l_dbg(1, debug, client, |
995 | KERN_ERR | 919 | "init error %d at stage %d, leaving attach.\n", |
996 | "%s_attach: init error %d at stage %d, leaving attach.\n", | 920 | i, err[i]); |
997 | I2C_NAME(client), i, err[i]); | ||
998 | kfree(decoder); | 921 | kfree(decoder); |
999 | kfree(client); | 922 | return -EIO; |
1000 | return 0; | ||
1001 | } | 923 | } |
1002 | } | 924 | } |
1003 | 925 | ||
1004 | dprintk(1, KERN_INFO "%s_attach: performing the rest of init\n", | 926 | v4l_dbg(1, debug, client, "performing the rest of init\n"); |
1005 | I2C_NAME(client)); | ||
1006 | |||
1007 | 927 | ||
1008 | err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); | 928 | err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); |
1009 | err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq | 929 | err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq |
@@ -1039,37 +959,32 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
1039 | 959 | ||
1040 | for (i = 9; i <= 18; i++) { | 960 | for (i = 9; i <= 18; i++) { |
1041 | if (err[i] < 0) { | 961 | if (err[i] < 0) { |
1042 | dprintk(1, | 962 | v4l_dbg(1, debug, client, |
1043 | KERN_ERR | 963 | "init error %d at stage %d, leaving attach.\n", |
1044 | "%s_attach: init error %d at stage %d, leaving attach.\n", | 964 | i, err[i]); |
1045 | I2C_NAME(client), i, err[i]); | ||
1046 | kfree(decoder); | 965 | kfree(decoder); |
1047 | kfree(client); | 966 | return -EIO; |
1048 | return 0; | ||
1049 | } | 967 | } |
1050 | } | 968 | } |
1051 | 969 | ||
1052 | 970 | ||
1053 | for (i = 6; i < 8; i++) { | 971 | for (i = 6; i < 8; i++) { |
1054 | dprintk(1, | 972 | v4l_dbg(1, debug, client, |
1055 | KERN_DEBUG | 973 | "reg[0x%02x] = 0x%02x (0x%02x)\n", |
1056 | "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", | 974 | i, saa7114_read(client, i), |
1057 | I2C_NAME(client), i, saa7114_read(client, i), | ||
1058 | decoder->reg[REG_ADDR(i)]); | 975 | decoder->reg[REG_ADDR(i)]); |
1059 | } | 976 | } |
1060 | 977 | ||
1061 | 978 | ||
1062 | for (i = 0x11; i <= 0x13; i++) { | 979 | for (i = 0x11; i <= 0x13; i++) { |
1063 | dprintk(1, | 980 | v4l_dbg(1, debug, client, |
1064 | KERN_DEBUG | 981 | "reg[0x%02x] = 0x%02x (0x%02x)\n", |
1065 | "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", | 982 | i, saa7114_read(client, i), |
1066 | I2C_NAME(client), i, saa7114_read(client, i), | ||
1067 | decoder->reg[REG_ADDR(i)]); | 983 | decoder->reg[REG_ADDR(i)]); |
1068 | } | 984 | } |
1069 | 985 | ||
1070 | 986 | ||
1071 | dprintk(1, KERN_DEBUG "%s_attach: setting video input\n", | 987 | v4l_dbg(1, debug, client, "setting video input\n"); |
1072 | I2C_NAME(client)); | ||
1073 | 988 | ||
1074 | err[19] = | 989 | err[19] = |
1075 | saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); | 990 | saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); |
@@ -1080,20 +995,15 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
1080 | 995 | ||
1081 | for (i = 19; i <= 21; i++) { | 996 | for (i = 19; i <= 21; i++) { |
1082 | if (err[i] < 0) { | 997 | if (err[i] < 0) { |
1083 | dprintk(1, | 998 | v4l_dbg(1, debug, client, |
1084 | KERN_ERR | 999 | "init error %d at stage %d, leaving attach.\n", |
1085 | "%s_attach: init error %d at stage %d, leaving attach.\n", | 1000 | i, err[i]); |
1086 | I2C_NAME(client), i, err[i]); | ||
1087 | kfree(decoder); | 1001 | kfree(decoder); |
1088 | kfree(client); | 1002 | return -EIO; |
1089 | return 0; | ||
1090 | } | 1003 | } |
1091 | } | 1004 | } |
1092 | 1005 | ||
1093 | dprintk(1, | 1006 | v4l_dbg(1, debug, client, "performing decoder reset sequence\n"); |
1094 | KERN_DEBUG | ||
1095 | "%s_attach: performing decoder reset sequence\n", | ||
1096 | I2C_NAME(client)); | ||
1097 | 1007 | ||
1098 | err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler | 1008 | err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler |
1099 | err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | 1009 | err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release |
@@ -1102,13 +1012,11 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
1102 | 1012 | ||
1103 | for (i = 22; i <= 24; i++) { | 1013 | for (i = 22; i <= 24; i++) { |
1104 | if (err[i] < 0) { | 1014 | if (err[i] < 0) { |
1105 | dprintk(1, | 1015 | v4l_dbg(1, debug, client, |
1106 | KERN_ERR | 1016 | "init error %d at stage %d, leaving attach.\n", |
1107 | "%s_attach: init error %d at stage %d, leaving attach.\n", | 1017 | i, err[i]); |
1108 | I2C_NAME(client), i, err[i]); | ||
1109 | kfree(decoder); | 1018 | kfree(decoder); |
1110 | kfree(client); | 1019 | return -EIO; |
1111 | return 0; | ||
1112 | } | 1020 | } |
1113 | } | 1021 | } |
1114 | 1022 | ||
@@ -1116,101 +1024,45 @@ saa7114_detect_client (struct i2c_adapter *adapter, | |||
1116 | err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); | 1024 | err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); |
1117 | err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); | 1025 | err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); |
1118 | 1026 | ||
1119 | dprintk(1, | 1027 | v4l_dbg(1, debug, client, "chip version %x, decoder status 0x%02x\n", |
1120 | KERN_INFO | 1028 | saa7114_read(client, 0x00) >> 4, |
1121 | "%s_attach: chip version %x, decoder status 0x%02x\n", | ||
1122 | I2C_NAME(client), saa7114_read(client, 0x00) >> 4, | ||
1123 | saa7114_read(client, 0x1f)); | 1029 | saa7114_read(client, 0x1f)); |
1124 | dprintk(1, | 1030 | v4l_dbg(1, debug, client, |
1125 | KERN_DEBUG | 1031 | "power save control: 0x%02x, scaler status: 0x%02x\n", |
1126 | "%s_attach: power save control: 0x%02x, scaler status: 0x%02x\n", | 1032 | saa7114_read(client, 0x88), |
1127 | I2C_NAME(client), saa7114_read(client, 0x88), | ||
1128 | saa7114_read(client, 0x8f)); | 1033 | saa7114_read(client, 0x8f)); |
1129 | 1034 | ||
1130 | 1035 | ||
1131 | for (i = 0x94; i < 0x96; i++) { | 1036 | for (i = 0x94; i < 0x96; i++) { |
1132 | dprintk(1, | 1037 | v4l_dbg(1, debug, client, |
1133 | KERN_DEBUG | 1038 | "reg[0x%02x] = 0x%02x (0x%02x)\n", |
1134 | "%s_attach: reg[0x%02x] = 0x%02x (0x%02x)\n", | 1039 | i, saa7114_read(client, i), |
1135 | I2C_NAME(client), i, saa7114_read(client, i), | ||
1136 | decoder->reg[REG_ADDR(i)]); | 1040 | decoder->reg[REG_ADDR(i)]); |
1137 | } | 1041 | } |
1138 | 1042 | ||
1139 | i = i2c_attach_client(client); | ||
1140 | if (i) { | ||
1141 | kfree(client); | ||
1142 | kfree(decoder); | ||
1143 | return i; | ||
1144 | } | ||
1145 | |||
1146 | //i = saa7114_write_block(client, init, sizeof(init)); | 1043 | //i = saa7114_write_block(client, init, sizeof(init)); |
1147 | i = 0; | ||
1148 | if (i < 0) { | ||
1149 | dprintk(1, KERN_ERR "%s_attach error: init status %d\n", | ||
1150 | I2C_NAME(client), i); | ||
1151 | } else { | ||
1152 | dprintk(1, | ||
1153 | KERN_INFO | ||
1154 | "%s_attach: chip version %x at address 0x%x\n", | ||
1155 | I2C_NAME(client), saa7114_read(client, 0x00) >> 4, | ||
1156 | client->addr << 1); | ||
1157 | } | ||
1158 | |||
1159 | return 0; | 1044 | return 0; |
1160 | } | 1045 | } |
1161 | 1046 | ||
1162 | static int | 1047 | static int saa7114_remove(struct i2c_client *client) |
1163 | saa7114_attach_adapter (struct i2c_adapter *adapter) | ||
1164 | { | ||
1165 | dprintk(1, | ||
1166 | KERN_INFO | ||
1167 | "saa7114.c: starting probe for adapter %s (0x%x)\n", | ||
1168 | I2C_NAME(adapter), adapter->id); | ||
1169 | return i2c_probe(adapter, &addr_data, &saa7114_detect_client); | ||
1170 | } | ||
1171 | |||
1172 | static int | ||
1173 | saa7114_detach_client (struct i2c_client *client) | ||
1174 | { | 1048 | { |
1175 | struct saa7114 *decoder = i2c_get_clientdata(client); | 1049 | kfree(i2c_get_clientdata(client)); |
1176 | int err; | ||
1177 | |||
1178 | err = i2c_detach_client(client); | ||
1179 | if (err) { | ||
1180 | return err; | ||
1181 | } | ||
1182 | |||
1183 | kfree(decoder); | ||
1184 | kfree(client); | ||
1185 | |||
1186 | return 0; | 1050 | return 0; |
1187 | } | 1051 | } |
1188 | 1052 | ||
1189 | /* ----------------------------------------------------------------------- */ | 1053 | /* ----------------------------------------------------------------------- */ |
1190 | 1054 | ||
1191 | static struct i2c_driver i2c_driver_saa7114 = { | 1055 | static const struct i2c_device_id saa7114_id[] = { |
1192 | .driver = { | 1056 | { "saa7114_old", 0 }, /* "saa7114" maps to the saa7115 driver */ |
1193 | .name = "saa7114", | 1057 | { } |
1194 | }, | 1058 | }; |
1195 | 1059 | MODULE_DEVICE_TABLE(i2c, saa7114_id); | |
1196 | .id = I2C_DRIVERID_SAA7114, | ||
1197 | 1060 | ||
1198 | .attach_adapter = saa7114_attach_adapter, | 1061 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
1199 | .detach_client = saa7114_detach_client, | 1062 | .name = "saa7114", |
1063 | .driverid = I2C_DRIVERID_SAA7114, | ||
1200 | .command = saa7114_command, | 1064 | .command = saa7114_command, |
1065 | .probe = saa7114_probe, | ||
1066 | .remove = saa7114_remove, | ||
1067 | .id_table = saa7114_id, | ||
1201 | }; | 1068 | }; |
1202 | |||
1203 | static int __init | ||
1204 | saa7114_init (void) | ||
1205 | { | ||
1206 | return i2c_add_driver(&i2c_driver_saa7114); | ||
1207 | } | ||
1208 | |||
1209 | static void __exit | ||
1210 | saa7114_exit (void) | ||
1211 | { | ||
1212 | i2c_del_driver(&i2c_driver_saa7114); | ||
1213 | } | ||
1214 | |||
1215 | module_init(saa7114_init); | ||
1216 | module_exit(saa7114_exit); | ||
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index d0e83fe0ff51..cc02fb18efa7 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c | |||
@@ -29,7 +29,7 @@ | |||
29 | * Note: the saa7126 is identical to the saa7127, and the saa7128 is | 29 | * Note: the saa7126 is identical to the saa7127, and the saa7128 is |
30 | * identical to the saa7129, except that the saa7126 and saa7128 have | 30 | * identical to the saa7129, except that the saa7126 and saa7128 have |
31 | * macrovision anti-taping support. This driver will almost certainly | 31 | * macrovision anti-taping support. This driver will almost certainly |
32 | * work find for those chips, except of course for the missing anti-taping | 32 | * work fine for those chips, except of course for the missing anti-taping |
33 | * support. | 33 | * support. |
34 | * | 34 | * |
35 | * This program is free software; you can redistribute it and/or modify | 35 | * This program is free software; you can redistribute it and/or modify |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 87c10983266f..8c46115d4c79 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -535,11 +535,16 @@ static int configure_tda827x_fe(struct saa7134_dev *dev, | |||
535 | struct tda1004x_config *cdec_conf, | 535 | struct tda1004x_config *cdec_conf, |
536 | struct tda827x_config *tuner_conf) | 536 | struct tda827x_config *tuner_conf) |
537 | { | 537 | { |
538 | dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); | 538 | struct videobuf_dvb_frontend *fe0; |
539 | if (dev->dvb.frontend) { | 539 | |
540 | /* Get the first frontend */ | ||
541 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | ||
542 | |||
543 | fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); | ||
544 | if (fe0->dvb.frontend) { | ||
540 | if (cdec_conf->i2c_gate) | 545 | if (cdec_conf->i2c_gate) |
541 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; | 546 | fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; |
542 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, | 547 | if (dvb_attach(tda827x_attach, fe0->dvb.frontend, |
543 | cdec_conf->tuner_address, | 548 | cdec_conf->tuner_address, |
544 | &dev->i2c_adap, tuner_conf)) | 549 | &dev->i2c_adap, tuner_conf)) |
545 | return 0; | 550 | return 0; |
@@ -944,12 +949,30 @@ static int dvb_init(struct saa7134_dev *dev) | |||
944 | { | 949 | { |
945 | int ret; | 950 | int ret; |
946 | int attach_xc3028 = 0; | 951 | int attach_xc3028 = 0; |
952 | struct videobuf_dvb_frontend *fe0; | ||
953 | |||
954 | /* FIXME: add support for multi-frontend */ | ||
955 | mutex_init(&dev->frontends.lock); | ||
956 | INIT_LIST_HEAD(&dev->frontends.felist); | ||
957 | dev->frontends.active_fe_id = 0; | ||
958 | |||
959 | printk(KERN_INFO "%s() allocating 1 frontend\n", __func__); | ||
960 | |||
961 | if (videobuf_dvb_alloc_frontend(&dev->frontends, 1) == NULL) { | ||
962 | printk(KERN_ERR "%s() failed to alloc\n", __func__); | ||
963 | return -ENOMEM; | ||
964 | } | ||
965 | |||
966 | /* Get the first frontend */ | ||
967 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | ||
968 | if (!fe0) | ||
969 | return -EINVAL; | ||
947 | 970 | ||
948 | /* init struct videobuf_dvb */ | 971 | /* init struct videobuf_dvb */ |
949 | dev->ts.nr_bufs = 32; | 972 | dev->ts.nr_bufs = 32; |
950 | dev->ts.nr_packets = 32*4; | 973 | dev->ts.nr_packets = 32*4; |
951 | dev->dvb.name = dev->name; | 974 | fe0->dvb.name = dev->name; |
952 | videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops, | 975 | videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops, |
953 | &dev->pci->dev, &dev->slock, | 976 | &dev->pci->dev, &dev->slock, |
954 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 977 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
955 | V4L2_FIELD_ALTERNATE, | 978 | V4L2_FIELD_ALTERNATE, |
@@ -959,47 +982,47 @@ static int dvb_init(struct saa7134_dev *dev) | |||
959 | switch (dev->board) { | 982 | switch (dev->board) { |
960 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: | 983 | case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: |
961 | dprintk("pinnacle 300i dvb setup\n"); | 984 | dprintk("pinnacle 300i dvb setup\n"); |
962 | dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, | 985 | fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i, |
963 | &dev->i2c_adap); | 986 | &dev->i2c_adap); |
964 | if (dev->dvb.frontend) { | 987 | if (fe0->dvb.frontend) { |
965 | dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; | 988 | fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; |
966 | } | 989 | } |
967 | break; | 990 | break; |
968 | case SAA7134_BOARD_AVERMEDIA_777: | 991 | case SAA7134_BOARD_AVERMEDIA_777: |
969 | case SAA7134_BOARD_AVERMEDIA_A16AR: | 992 | case SAA7134_BOARD_AVERMEDIA_A16AR: |
970 | dprintk("avertv 777 dvb setup\n"); | 993 | dprintk("avertv 777 dvb setup\n"); |
971 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, | 994 | fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, |
972 | &dev->i2c_adap); | 995 | &dev->i2c_adap); |
973 | if (dev->dvb.frontend) { | 996 | if (fe0->dvb.frontend) { |
974 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 997 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
975 | &dev->i2c_adap, 0x61, | 998 | &dev->i2c_adap, 0x61, |
976 | TUNER_PHILIPS_TD1316); | 999 | TUNER_PHILIPS_TD1316); |
977 | } | 1000 | } |
978 | break; | 1001 | break; |
979 | case SAA7134_BOARD_AVERMEDIA_A16D: | 1002 | case SAA7134_BOARD_AVERMEDIA_A16D: |
980 | dprintk("AverMedia A16D dvb setup\n"); | 1003 | dprintk("AverMedia A16D dvb setup\n"); |
981 | dev->dvb.frontend = dvb_attach(mt352_attach, | 1004 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
982 | &avermedia_xc3028_mt352_dev, | 1005 | &avermedia_xc3028_mt352_dev, |
983 | &dev->i2c_adap); | 1006 | &dev->i2c_adap); |
984 | attach_xc3028 = 1; | 1007 | attach_xc3028 = 1; |
985 | break; | 1008 | break; |
986 | case SAA7134_BOARD_MD7134: | 1009 | case SAA7134_BOARD_MD7134: |
987 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1010 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
988 | &medion_cardbus, | 1011 | &medion_cardbus, |
989 | &dev->i2c_adap); | 1012 | &dev->i2c_adap); |
990 | if (dev->dvb.frontend) { | 1013 | if (fe0->dvb.frontend) { |
991 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 1014 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
992 | &dev->i2c_adap, medion_cardbus.tuner_address, | 1015 | &dev->i2c_adap, medion_cardbus.tuner_address, |
993 | TUNER_PHILIPS_FMD1216ME_MK3); | 1016 | TUNER_PHILIPS_FMD1216ME_MK3); |
994 | } | 1017 | } |
995 | break; | 1018 | break; |
996 | case SAA7134_BOARD_PHILIPS_TOUGH: | 1019 | case SAA7134_BOARD_PHILIPS_TOUGH: |
997 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1020 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
998 | &philips_tu1216_60_config, | 1021 | &philips_tu1216_60_config, |
999 | &dev->i2c_adap); | 1022 | &dev->i2c_adap); |
1000 | if (dev->dvb.frontend) { | 1023 | if (fe0->dvb.frontend) { |
1001 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; | 1024 | fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; |
1002 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; | 1025 | fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
1003 | } | 1026 | } |
1004 | break; | 1027 | break; |
1005 | case SAA7134_BOARD_FLYDVBTDUO: | 1028 | case SAA7134_BOARD_FLYDVBTDUO: |
@@ -1010,24 +1033,24 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1010 | break; | 1033 | break; |
1011 | case SAA7134_BOARD_PHILIPS_EUROPA: | 1034 | case SAA7134_BOARD_PHILIPS_EUROPA: |
1012 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 1035 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
1013 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1036 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
1014 | &philips_europa_config, | 1037 | &philips_europa_config, |
1015 | &dev->i2c_adap); | 1038 | &dev->i2c_adap); |
1016 | if (dev->dvb.frontend) { | 1039 | if (fe0->dvb.frontend) { |
1017 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; | 1040 | dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep; |
1018 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; | 1041 | fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
1019 | dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; | 1042 | fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; |
1020 | dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; | 1043 | fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep; |
1021 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; | 1044 | fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; |
1022 | } | 1045 | } |
1023 | break; | 1046 | break; |
1024 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: | 1047 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
1025 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1048 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
1026 | &philips_tu1216_61_config, | 1049 | &philips_tu1216_61_config, |
1027 | &dev->i2c_adap); | 1050 | &dev->i2c_adap); |
1028 | if (dev->dvb.frontend) { | 1051 | if (fe0->dvb.frontend) { |
1029 | dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; | 1052 | fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init; |
1030 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; | 1053 | fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; |
1031 | } | 1054 | } |
1032 | break; | 1055 | break; |
1033 | case SAA7134_BOARD_KWORLD_DVBT_210: | 1056 | case SAA7134_BOARD_KWORLD_DVBT_210: |
@@ -1066,14 +1089,14 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1066 | &tda827x_cfg_0) < 0) | 1089 | &tda827x_cfg_0) < 0) |
1067 | goto dettach_frontend; | 1090 | goto dettach_frontend; |
1068 | } else { /* satellite */ | 1091 | } else { /* satellite */ |
1069 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); | 1092 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
1070 | if (dev->dvb.frontend) { | 1093 | if (fe0->dvb.frontend) { |
1071 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, | 1094 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63, |
1072 | &dev->i2c_adap, 0) == NULL) { | 1095 | &dev->i2c_adap, 0) == NULL) { |
1073 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); | 1096 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); |
1074 | goto dettach_frontend; | 1097 | goto dettach_frontend; |
1075 | } | 1098 | } |
1076 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, | 1099 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap, |
1077 | 0x08, 0, 0) == NULL) { | 1100 | 0x08, 0, 0) == NULL) { |
1078 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); | 1101 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); |
1079 | goto dettach_frontend; | 1102 | goto dettach_frontend; |
@@ -1083,11 +1106,11 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1083 | break; | 1106 | break; |
1084 | case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: | 1107 | case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: |
1085 | case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: | 1108 | case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: |
1086 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1109 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
1087 | &ads_tech_duo_config, | 1110 | &ads_tech_duo_config, |
1088 | &dev->i2c_adap); | 1111 | &dev->i2c_adap); |
1089 | if (dev->dvb.frontend) { | 1112 | if (fe0->dvb.frontend) { |
1090 | if (dvb_attach(tda827x_attach,dev->dvb.frontend, | 1113 | if (dvb_attach(tda827x_attach,fe0->dvb.frontend, |
1091 | ads_tech_duo_config.tuner_address, &dev->i2c_adap, | 1114 | ads_tech_duo_config.tuner_address, &dev->i2c_adap, |
1092 | &ads_duo_cfg) == NULL) { | 1115 | &ads_duo_cfg) == NULL) { |
1093 | wprintk("no tda827x tuner found at addr: %02x\n", | 1116 | wprintk("no tda827x tuner found at addr: %02x\n", |
@@ -1108,15 +1131,15 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1108 | &tda827x_cfg_0) < 0) | 1131 | &tda827x_cfg_0) < 0) |
1109 | goto dettach_frontend; | 1132 | goto dettach_frontend; |
1110 | } else { /* satellite */ | 1133 | } else { /* satellite */ |
1111 | dev->dvb.frontend = dvb_attach(tda10086_attach, | 1134 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1112 | &flydvbs, &dev->i2c_adap); | 1135 | &flydvbs, &dev->i2c_adap); |
1113 | if (dev->dvb.frontend) { | 1136 | if (fe0->dvb.frontend) { |
1114 | struct dvb_frontend *fe = dev->dvb.frontend; | 1137 | struct dvb_frontend *fe = fe0->dvb.frontend; |
1115 | u8 dev_id = dev->eedata[2]; | 1138 | u8 dev_id = dev->eedata[2]; |
1116 | u8 data = 0xc4; | 1139 | u8 data = 0xc4; |
1117 | struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; | 1140 | struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; |
1118 | 1141 | ||
1119 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, | 1142 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, |
1120 | 0x60, &dev->i2c_adap, 0) == NULL) { | 1143 | 0x60, &dev->i2c_adap, 0) == NULL) { |
1121 | wprintk("%s: Medion Quadro, no tda826x " | 1144 | wprintk("%s: Medion Quadro, no tda826x " |
1122 | "found !\n", __func__); | 1145 | "found !\n", __func__); |
@@ -1150,31 +1173,31 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1150 | } | 1173 | } |
1151 | break; | 1174 | break; |
1152 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: | 1175 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: |
1153 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, | 1176 | fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, |
1154 | &dev->i2c_adap); | 1177 | &dev->i2c_adap); |
1155 | if (dev->dvb.frontend) | 1178 | if (fe0->dvb.frontend) |
1156 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 1179 | dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61, |
1157 | NULL, DVB_PLL_TDHU2); | 1180 | NULL, DVB_PLL_TDHU2); |
1158 | break; | 1181 | break; |
1159 | case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI: | 1182 | case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI: |
1160 | case SAA7134_BOARD_KWORLD_ATSC110: | 1183 | case SAA7134_BOARD_KWORLD_ATSC110: |
1161 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, | 1184 | fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, |
1162 | &dev->i2c_adap); | 1185 | &dev->i2c_adap); |
1163 | if (dev->dvb.frontend) | 1186 | if (fe0->dvb.frontend) |
1164 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 1187 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
1165 | &dev->i2c_adap, 0x61, | 1188 | &dev->i2c_adap, 0x61, |
1166 | TUNER_PHILIPS_TUV1236D); | 1189 | TUNER_PHILIPS_TUV1236D); |
1167 | break; | 1190 | break; |
1168 | case SAA7134_BOARD_FLYDVBS_LR300: | 1191 | case SAA7134_BOARD_FLYDVBS_LR300: |
1169 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | 1192 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
1170 | &dev->i2c_adap); | 1193 | &dev->i2c_adap); |
1171 | if (dev->dvb.frontend) { | 1194 | if (fe0->dvb.frontend) { |
1172 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | 1195 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, |
1173 | &dev->i2c_adap, 0) == NULL) { | 1196 | &dev->i2c_adap, 0) == NULL) { |
1174 | wprintk("%s: No tda826x found!\n", __func__); | 1197 | wprintk("%s: No tda826x found!\n", __func__); |
1175 | goto dettach_frontend; | 1198 | goto dettach_frontend; |
1176 | } | 1199 | } |
1177 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, | 1200 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, |
1178 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1201 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1179 | wprintk("%s: No ISL6421 found!\n", __func__); | 1202 | wprintk("%s: No ISL6421 found!\n", __func__); |
1180 | goto dettach_frontend; | 1203 | goto dettach_frontend; |
@@ -1182,25 +1205,25 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1182 | } | 1205 | } |
1183 | break; | 1206 | break; |
1184 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: | 1207 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: |
1185 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1208 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
1186 | &medion_cardbus, | 1209 | &medion_cardbus, |
1187 | &dev->i2c_adap); | 1210 | &dev->i2c_adap); |
1188 | if (dev->dvb.frontend) { | 1211 | if (fe0->dvb.frontend) { |
1189 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; | 1212 | dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep; |
1190 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; | 1213 | fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
1191 | 1214 | ||
1192 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, | 1215 | dvb_attach(simple_tuner_attach, fe0->dvb.frontend, |
1193 | &dev->i2c_adap, medion_cardbus.tuner_address, | 1216 | &dev->i2c_adap, medion_cardbus.tuner_address, |
1194 | TUNER_PHILIPS_FMD1216ME_MK3); | 1217 | TUNER_PHILIPS_FMD1216ME_MK3); |
1195 | } | 1218 | } |
1196 | break; | 1219 | break; |
1197 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: | 1220 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: |
1198 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 1221 | fe0->dvb.frontend = dvb_attach(tda10046_attach, |
1199 | &philips_europa_config, | 1222 | &philips_europa_config, |
1200 | &dev->i2c_adap); | 1223 | &dev->i2c_adap); |
1201 | if (dev->dvb.frontend) { | 1224 | if (fe0->dvb.frontend) { |
1202 | dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; | 1225 | fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init; |
1203 | dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; | 1226 | fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params; |
1204 | } | 1227 | } |
1205 | break; | 1228 | break; |
1206 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: | 1229 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: |
@@ -1239,15 +1262,15 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1239 | goto dettach_frontend; | 1262 | goto dettach_frontend; |
1240 | break; | 1263 | break; |
1241 | case SAA7134_BOARD_PHILIPS_SNAKE: | 1264 | case SAA7134_BOARD_PHILIPS_SNAKE: |
1242 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | 1265 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
1243 | &dev->i2c_adap); | 1266 | &dev->i2c_adap); |
1244 | if (dev->dvb.frontend) { | 1267 | if (fe0->dvb.frontend) { |
1245 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | 1268 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, |
1246 | &dev->i2c_adap, 0) == NULL) { | 1269 | &dev->i2c_adap, 0) == NULL) { |
1247 | wprintk("%s: No tda826x found!\n", __func__); | 1270 | wprintk("%s: No tda826x found!\n", __func__); |
1248 | goto dettach_frontend; | 1271 | goto dettach_frontend; |
1249 | } | 1272 | } |
1250 | if (dvb_attach(lnbp21_attach, dev->dvb.frontend, | 1273 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, |
1251 | &dev->i2c_adap, 0, 0) == NULL) { | 1274 | &dev->i2c_adap, 0, 0) == NULL) { |
1252 | wprintk("%s: No lnbp21 found!\n", __func__); | 1275 | wprintk("%s: No lnbp21 found!\n", __func__); |
1253 | goto dettach_frontend; | 1276 | goto dettach_frontend; |
@@ -1269,24 +1292,24 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1269 | saa7134_set_gpio(dev, 25, 0); | 1292 | saa7134_set_gpio(dev, 25, 0); |
1270 | msleep(10); | 1293 | msleep(10); |
1271 | saa7134_set_gpio(dev, 25, 1); | 1294 | saa7134_set_gpio(dev, 25, 1); |
1272 | dev->dvb.frontend = dvb_attach(mt352_attach, | 1295 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
1273 | &avermedia_xc3028_mt352_dev, | 1296 | &avermedia_xc3028_mt352_dev, |
1274 | &dev->i2c_adap); | 1297 | &dev->i2c_adap); |
1275 | attach_xc3028 = 1; | 1298 | attach_xc3028 = 1; |
1276 | break; | 1299 | break; |
1277 | case SAA7134_BOARD_MD7134_BRIDGE_2: | 1300 | case SAA7134_BOARD_MD7134_BRIDGE_2: |
1278 | dev->dvb.frontend = dvb_attach(tda10086_attach, | 1301 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1279 | &sd1878_4m, &dev->i2c_adap); | 1302 | &sd1878_4m, &dev->i2c_adap); |
1280 | if (dev->dvb.frontend) { | 1303 | if (fe0->dvb.frontend) { |
1281 | struct dvb_frontend *fe; | 1304 | struct dvb_frontend *fe; |
1282 | if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | 1305 | if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60, |
1283 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { | 1306 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { |
1284 | wprintk("%s: MD7134 DVB-S, no SD1878 " | 1307 | wprintk("%s: MD7134 DVB-S, no SD1878 " |
1285 | "found !\n", __func__); | 1308 | "found !\n", __func__); |
1286 | goto dettach_frontend; | 1309 | goto dettach_frontend; |
1287 | } | 1310 | } |
1288 | /* we need to open the i2c gate (we know it exists) */ | 1311 | /* we need to open the i2c gate (we know it exists) */ |
1289 | fe = dev->dvb.frontend; | 1312 | fe = fe0->dvb.frontend; |
1290 | fe->ops.i2c_gate_ctrl(fe, 1); | 1313 | fe->ops.i2c_gate_ctrl(fe, 1); |
1291 | if (dvb_attach(isl6405_attach, fe, | 1314 | if (dvb_attach(isl6405_attach, fe, |
1292 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1315 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
@@ -1305,7 +1328,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1305 | saa7134_set_gpio(dev, 25, 0); | 1328 | saa7134_set_gpio(dev, 25, 0); |
1306 | msleep(10); | 1329 | msleep(10); |
1307 | saa7134_set_gpio(dev, 25, 1); | 1330 | saa7134_set_gpio(dev, 25, 1); |
1308 | dev->dvb.frontend = dvb_attach(mt352_attach, | 1331 | fe0->dvb.frontend = dvb_attach(mt352_attach, |
1309 | &avermedia_xc3028_mt352_dev, | 1332 | &avermedia_xc3028_mt352_dev, |
1310 | &dev->i2c_adap); | 1333 | &dev->i2c_adap); |
1311 | attach_xc3028 = 1; | 1334 | attach_xc3028 = 1; |
@@ -1316,17 +1339,17 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1316 | &tda827x_cfg_2) < 0) | 1339 | &tda827x_cfg_2) < 0) |
1317 | goto dettach_frontend; | 1340 | goto dettach_frontend; |
1318 | } else { /* satellite */ | 1341 | } else { /* satellite */ |
1319 | dev->dvb.frontend = dvb_attach(tda10086_attach, | 1342 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1320 | &flydvbs, &dev->i2c_adap); | 1343 | &flydvbs, &dev->i2c_adap); |
1321 | if (dev->dvb.frontend) { | 1344 | if (fe0->dvb.frontend) { |
1322 | if (dvb_attach(tda826x_attach, | 1345 | if (dvb_attach(tda826x_attach, |
1323 | dev->dvb.frontend, 0x60, | 1346 | fe0->dvb.frontend, 0x60, |
1324 | &dev->i2c_adap, 0) == NULL) { | 1347 | &dev->i2c_adap, 0) == NULL) { |
1325 | wprintk("%s: Asus Tiger 3in1, no " | 1348 | wprintk("%s: Asus Tiger 3in1, no " |
1326 | "tda826x found!\n", __func__); | 1349 | "tda826x found!\n", __func__); |
1327 | goto dettach_frontend; | 1350 | goto dettach_frontend; |
1328 | } | 1351 | } |
1329 | if (dvb_attach(lnbp21_attach, dev->dvb.frontend, | 1352 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, |
1330 | &dev->i2c_adap, 0, 0) == NULL) { | 1353 | &dev->i2c_adap, 0, 0) == NULL) { |
1331 | wprintk("%s: Asus Tiger 3in1, no lnbp21" | 1354 | wprintk("%s: Asus Tiger 3in1, no lnbp21" |
1332 | " found!\n", __func__); | 1355 | " found!\n", __func__); |
@@ -1352,10 +1375,10 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1352 | .i2c_addr = 0x61, | 1375 | .i2c_addr = 0x61, |
1353 | }; | 1376 | }; |
1354 | 1377 | ||
1355 | if (!dev->dvb.frontend) | 1378 | if (!fe0->dvb.frontend) |
1356 | return -1; | 1379 | return -1; |
1357 | 1380 | ||
1358 | fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | 1381 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); |
1359 | if (!fe) { | 1382 | if (!fe) { |
1360 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 1383 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
1361 | dev->name); | 1384 | dev->name); |
@@ -1363,40 +1386,47 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1363 | } | 1386 | } |
1364 | } | 1387 | } |
1365 | 1388 | ||
1366 | if (NULL == dev->dvb.frontend) { | 1389 | if (NULL == fe0->dvb.frontend) { |
1367 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); | 1390 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); |
1368 | return -1; | 1391 | return -1; |
1369 | } | 1392 | } |
1370 | /* define general-purpose callback pointer */ | 1393 | /* define general-purpose callback pointer */ |
1371 | dev->dvb.frontend->callback = saa7134_tuner_callback; | 1394 | fe0->dvb.frontend->callback = saa7134_tuner_callback; |
1372 | 1395 | ||
1373 | /* register everything else */ | 1396 | /* register everything else */ |
1374 | ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev, | 1397 | ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev, |
1375 | adapter_nr); | 1398 | &dev->pci->dev, adapter_nr, 0); |
1376 | 1399 | ||
1377 | /* this sequence is necessary to make the tda1004x load its firmware | 1400 | /* this sequence is necessary to make the tda1004x load its firmware |
1378 | * and to enter analog mode of hybrid boards | 1401 | * and to enter analog mode of hybrid boards |
1379 | */ | 1402 | */ |
1380 | if (!ret) { | 1403 | if (!ret) { |
1381 | if (dev->dvb.frontend->ops.init) | 1404 | if (fe0->dvb.frontend->ops.init) |
1382 | dev->dvb.frontend->ops.init(dev->dvb.frontend); | 1405 | fe0->dvb.frontend->ops.init(fe0->dvb.frontend); |
1383 | if (dev->dvb.frontend->ops.sleep) | 1406 | if (fe0->dvb.frontend->ops.sleep) |
1384 | dev->dvb.frontend->ops.sleep(dev->dvb.frontend); | 1407 | fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend); |
1385 | if (dev->dvb.frontend->ops.tuner_ops.sleep) | 1408 | if (fe0->dvb.frontend->ops.tuner_ops.sleep) |
1386 | dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); | 1409 | fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend); |
1387 | } | 1410 | } |
1388 | return ret; | 1411 | return ret; |
1389 | 1412 | ||
1390 | dettach_frontend: | 1413 | dettach_frontend: |
1391 | if (dev->dvb.frontend) | 1414 | if (fe0->dvb.frontend) |
1392 | dvb_frontend_detach(dev->dvb.frontend); | 1415 | dvb_frontend_detach(fe0->dvb.frontend); |
1393 | dev->dvb.frontend = NULL; | 1416 | fe0->dvb.frontend = NULL; |
1394 | 1417 | ||
1395 | return -1; | 1418 | return -1; |
1396 | } | 1419 | } |
1397 | 1420 | ||
1398 | static int dvb_fini(struct saa7134_dev *dev) | 1421 | static int dvb_fini(struct saa7134_dev *dev) |
1399 | { | 1422 | { |
1423 | struct videobuf_dvb_frontend *fe0; | ||
1424 | |||
1425 | /* Get the first frontend */ | ||
1426 | fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); | ||
1427 | if (!fe0) | ||
1428 | return -EINVAL; | ||
1429 | |||
1400 | /* FIXME: I suspect that this code is bogus, since the entry for | 1430 | /* FIXME: I suspect that this code is bogus, since the entry for |
1401 | Pinnacle 300I DVB-T PAL already defines the proper init to allow | 1431 | Pinnacle 300I DVB-T PAL already defines the proper init to allow |
1402 | the detection of mt2032 (TDA9887_PORT2_INACTIVE) | 1432 | the detection of mt2032 (TDA9887_PORT2_INACTIVE) |
@@ -1416,7 +1446,7 @@ static int dvb_fini(struct saa7134_dev *dev) | |||
1416 | u8 data = 0x80; | 1446 | u8 data = 0x80; |
1417 | struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; | 1447 | struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; |
1418 | struct dvb_frontend *fe; | 1448 | struct dvb_frontend *fe; |
1419 | fe = dev->dvb.frontend; | 1449 | fe = fe0->dvb.frontend; |
1420 | if (fe->ops.i2c_gate_ctrl) { | 1450 | if (fe->ops.i2c_gate_ctrl) { |
1421 | fe->ops.i2c_gate_ctrl(fe, 1); | 1451 | fe->ops.i2c_gate_ctrl(fe, 1); |
1422 | i2c_transfer(&dev->i2c_adap, &msg, 1); | 1452 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
@@ -1424,8 +1454,8 @@ static int dvb_fini(struct saa7134_dev *dev) | |||
1424 | } | 1454 | } |
1425 | } | 1455 | } |
1426 | } | 1456 | } |
1427 | if (dev->dvb.frontend) | 1457 | if (fe0->dvb.frontend) |
1428 | videobuf_dvb_unregister(&dev->dvb); | 1458 | videobuf_dvb_unregister_bus(&dev->frontends); |
1429 | return 0; | 1459 | return 0; |
1430 | } | 1460 | } |
1431 | 1461 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 491ab1f8fdd3..24096d6e1ef8 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -581,7 +581,7 @@ struct saa7134_dev { | |||
581 | 581 | ||
582 | #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) | 582 | #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) |
583 | /* SAA7134_MPEG_DVB only */ | 583 | /* SAA7134_MPEG_DVB only */ |
584 | struct videobuf_dvb dvb; | 584 | struct videobuf_dvb_frontends frontends; |
585 | int (*original_demod_sleep)(struct dvb_frontend *fe); | 585 | int (*original_demod_sleep)(struct dvb_frontend *fe); |
586 | int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); | 586 | int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); |
587 | int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg); | 587 | int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg); |
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 02fda4eecea3..6debb65152ee 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -25,43 +25,25 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/init.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/fs.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/major.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <linux/mm.h> | ||
36 | #include <linux/signal.h> | ||
37 | #include <linux/types.h> | 28 | #include <linux/types.h> |
38 | #include <linux/i2c.h> | 29 | #include <linux/ioctl.h> |
39 | #include <asm/io.h> | ||
40 | #include <asm/pgtable.h> | ||
41 | #include <asm/page.h> | ||
42 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
43 | 31 | #include <linux/i2c.h> | |
32 | #include <linux/i2c-id.h> | ||
44 | #include <linux/videodev.h> | 33 | #include <linux/videodev.h> |
45 | #include <linux/video_encoder.h> | 34 | #include <linux/video_encoder.h> |
35 | #include <media/v4l2-common.h> | ||
36 | #include <media/v4l2-i2c-drv-legacy.h> | ||
46 | 37 | ||
47 | MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); | 38 | MODULE_DESCRIPTION("Philips SAA7185 video encoder driver"); |
48 | MODULE_AUTHOR("Dave Perks"); | 39 | MODULE_AUTHOR("Dave Perks"); |
49 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
50 | 41 | ||
51 | 42 | ||
52 | #define I2C_NAME(s) (s)->name | ||
53 | |||
54 | |||
55 | static int debug; | 43 | static int debug; |
56 | module_param(debug, int, 0); | 44 | module_param(debug, int, 0); |
57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 45 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
58 | 46 | ||
59 | #define dprintk(num, format, args...) \ | ||
60 | do { \ | ||
61 | if (debug >= num) \ | ||
62 | printk(format, ##args); \ | ||
63 | } while (0) | ||
64 | |||
65 | /* ----------------------------------------------------------------------- */ | 47 | /* ----------------------------------------------------------------------- */ |
66 | 48 | ||
67 | struct saa7185 { | 49 | struct saa7185 { |
@@ -75,32 +57,24 @@ struct saa7185 { | |||
75 | int sat; | 57 | int sat; |
76 | }; | 58 | }; |
77 | 59 | ||
78 | #define I2C_SAA7185 0x88 | ||
79 | |||
80 | /* ----------------------------------------------------------------------- */ | 60 | /* ----------------------------------------------------------------------- */ |
81 | 61 | ||
82 | static inline int | 62 | static inline int saa7185_read(struct i2c_client *client) |
83 | saa7185_read (struct i2c_client *client) | ||
84 | { | 63 | { |
85 | return i2c_smbus_read_byte(client); | 64 | return i2c_smbus_read_byte(client); |
86 | } | 65 | } |
87 | 66 | ||
88 | static int | 67 | static int saa7185_write(struct i2c_client *client, u8 reg, u8 value) |
89 | saa7185_write (struct i2c_client *client, | ||
90 | u8 reg, | ||
91 | u8 value) | ||
92 | { | 68 | { |
93 | struct saa7185 *encoder = i2c_get_clientdata(client); | 69 | struct saa7185 *encoder = i2c_get_clientdata(client); |
94 | 70 | ||
95 | dprintk(1, KERN_DEBUG "SAA7185: %02x set to %02x\n", reg, value); | 71 | v4l_dbg(1, debug, client, "%02x set to %02x\n", reg, value); |
96 | encoder->reg[reg] = value; | 72 | encoder->reg[reg] = value; |
97 | return i2c_smbus_write_byte_data(client, reg, value); | 73 | return i2c_smbus_write_byte_data(client, reg, value); |
98 | } | 74 | } |
99 | 75 | ||
100 | static int | 76 | static int saa7185_write_block(struct i2c_client *client, |
101 | saa7185_write_block (struct i2c_client *client, | 77 | const u8 *data, unsigned int len) |
102 | const u8 *data, | ||
103 | unsigned int len) | ||
104 | { | 78 | { |
105 | int ret = -1; | 79 | int ret = -1; |
106 | u8 reg; | 80 | u8 reg; |
@@ -121,18 +95,17 @@ saa7185_write_block (struct i2c_client *client, | |||
121 | encoder->reg[reg++] = data[1]; | 95 | encoder->reg[reg++] = data[1]; |
122 | len -= 2; | 96 | len -= 2; |
123 | data += 2; | 97 | data += 2; |
124 | } while (len >= 2 && data[0] == reg && | 98 | } while (len >= 2 && data[0] == reg && block_len < 32); |
125 | block_len < 32); | 99 | ret = i2c_master_send(client, block_data, block_len); |
126 | if ((ret = i2c_master_send(client, block_data, | 100 | if (ret < 0) |
127 | block_len)) < 0) | ||
128 | break; | 101 | break; |
129 | } | 102 | } |
130 | } else { | 103 | } else { |
131 | /* do some slow I2C emulation kind of thing */ | 104 | /* do some slow I2C emulation kind of thing */ |
132 | while (len >= 2) { | 105 | while (len >= 2) { |
133 | reg = *data++; | 106 | reg = *data++; |
134 | if ((ret = saa7185_write(client, reg, | 107 | ret = saa7185_write(client, reg, *data++); |
135 | *data++)) < 0) | 108 | if (ret < 0) |
136 | break; | 109 | break; |
137 | len -= 2; | 110 | len -= 2; |
138 | } | 111 | } |
@@ -240,15 +213,11 @@ static const unsigned char init_ntsc[] = { | |||
240 | 0x66, 0x21, /* FSC3 */ | 213 | 0x66, 0x21, /* FSC3 */ |
241 | }; | 214 | }; |
242 | 215 | ||
243 | static int | 216 | static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) |
244 | saa7185_command (struct i2c_client *client, | ||
245 | unsigned int cmd, | ||
246 | void *arg) | ||
247 | { | 217 | { |
248 | struct saa7185 *encoder = i2c_get_clientdata(client); | 218 | struct saa7185 *encoder = i2c_get_clientdata(client); |
249 | 219 | ||
250 | switch (cmd) { | 220 | switch (cmd) { |
251 | |||
252 | case 0: | 221 | case 0: |
253 | saa7185_write_block(client, init_common, | 222 | saa7185_write_block(client, init_common, |
254 | sizeof(init_common)); | 223 | sizeof(init_common)); |
@@ -264,7 +233,6 @@ saa7185_command (struct i2c_client *client, | |||
264 | sizeof(init_pal)); | 233 | sizeof(init_pal)); |
265 | break; | 234 | break; |
266 | } | 235 | } |
267 | |||
268 | break; | 236 | break; |
269 | 237 | ||
270 | case ENCODER_GET_CAPABILITIES: | 238 | case ENCODER_GET_CAPABILITIES: |
@@ -276,8 +244,8 @@ saa7185_command (struct i2c_client *client, | |||
276 | VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; | 244 | VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; |
277 | cap->inputs = 1; | 245 | cap->inputs = 1; |
278 | cap->outputs = 1; | 246 | cap->outputs = 1; |
279 | } | ||
280 | break; | 247 | break; |
248 | } | ||
281 | 249 | ||
282 | case ENCODER_SET_NORM: | 250 | case ENCODER_SET_NORM: |
283 | { | 251 | { |
@@ -286,7 +254,6 @@ saa7185_command (struct i2c_client *client, | |||
286 | //saa7185_write_block(client, init_common, sizeof(init_common)); | 254 | //saa7185_write_block(client, init_common, sizeof(init_common)); |
287 | 255 | ||
288 | switch (*iarg) { | 256 | switch (*iarg) { |
289 | |||
290 | case VIDEO_MODE_NTSC: | 257 | case VIDEO_MODE_NTSC: |
291 | saa7185_write_block(client, init_ntsc, | 258 | saa7185_write_block(client, init_ntsc, |
292 | sizeof(init_ntsc)); | 259 | sizeof(init_ntsc)); |
@@ -300,11 +267,10 @@ saa7185_command (struct i2c_client *client, | |||
300 | case VIDEO_MODE_SECAM: | 267 | case VIDEO_MODE_SECAM: |
301 | default: | 268 | default: |
302 | return -EINVAL; | 269 | return -EINVAL; |
303 | |||
304 | } | 270 | } |
305 | encoder->norm = *iarg; | 271 | encoder->norm = *iarg; |
306 | } | ||
307 | break; | 272 | break; |
273 | } | ||
308 | 274 | ||
309 | case ENCODER_SET_INPUT: | 275 | case ENCODER_SET_INPUT: |
310 | { | 276 | { |
@@ -314,7 +280,6 @@ saa7185_command (struct i2c_client *client, | |||
314 | *iarg = 1: input is from ZR36060 */ | 280 | *iarg = 1: input is from ZR36060 */ |
315 | 281 | ||
316 | switch (*iarg) { | 282 | switch (*iarg) { |
317 | |||
318 | case 0: | 283 | case 0: |
319 | /* Switch RTCE to 1 */ | 284 | /* Switch RTCE to 1 */ |
320 | saa7185_write(client, 0x61, | 285 | saa7185_write(client, 0x61, |
@@ -332,21 +297,19 @@ saa7185_command (struct i2c_client *client, | |||
332 | 297 | ||
333 | default: | 298 | default: |
334 | return -EINVAL; | 299 | return -EINVAL; |
335 | |||
336 | } | 300 | } |
337 | } | ||
338 | break; | 301 | break; |
302 | } | ||
339 | 303 | ||
340 | case ENCODER_SET_OUTPUT: | 304 | case ENCODER_SET_OUTPUT: |
341 | { | 305 | { |
342 | int *iarg = arg; | 306 | int *iarg = arg; |
343 | 307 | ||
344 | /* not much choice of outputs */ | 308 | /* not much choice of outputs */ |
345 | if (*iarg != 0) { | 309 | if (*iarg != 0) |
346 | return -EINVAL; | 310 | return -EINVAL; |
347 | } | ||
348 | } | ||
349 | break; | 311 | break; |
312 | } | ||
350 | 313 | ||
351 | case ENCODER_ENABLE_OUTPUT: | 314 | case ENCODER_ENABLE_OUTPUT: |
352 | { | 315 | { |
@@ -356,8 +319,8 @@ saa7185_command (struct i2c_client *client, | |||
356 | saa7185_write(client, 0x61, | 319 | saa7185_write(client, 0x61, |
357 | (encoder->reg[0x61] & 0xbf) | | 320 | (encoder->reg[0x61] & 0xbf) | |
358 | (encoder->enable ? 0x00 : 0x40)); | 321 | (encoder->enable ? 0x00 : 0x40)); |
359 | } | ||
360 | break; | 322 | break; |
323 | } | ||
361 | 324 | ||
362 | default: | 325 | default: |
363 | return -EINVAL; | 326 | return -EINVAL; |
@@ -368,138 +331,65 @@ saa7185_command (struct i2c_client *client, | |||
368 | 331 | ||
369 | /* ----------------------------------------------------------------------- */ | 332 | /* ----------------------------------------------------------------------- */ |
370 | 333 | ||
371 | /* | 334 | static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; |
372 | * Generic i2c probe | ||
373 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
374 | */ | ||
375 | static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; | ||
376 | 335 | ||
377 | static unsigned short ignore = I2C_CLIENT_END; | 336 | I2C_CLIENT_INSMOD; |
378 | 337 | ||
379 | static struct i2c_client_address_data addr_data = { | 338 | static int saa7185_probe(struct i2c_client *client, |
380 | .normal_i2c = normal_i2c, | 339 | const struct i2c_device_id *id) |
381 | .probe = &ignore, | ||
382 | .ignore = &ignore, | ||
383 | }; | ||
384 | |||
385 | static struct i2c_driver i2c_driver_saa7185; | ||
386 | |||
387 | static int | ||
388 | saa7185_detect_client (struct i2c_adapter *adapter, | ||
389 | int address, | ||
390 | int kind) | ||
391 | { | 340 | { |
392 | int i; | 341 | int i; |
393 | struct i2c_client *client; | ||
394 | struct saa7185 *encoder; | 342 | struct saa7185 *encoder; |
395 | 343 | ||
396 | dprintk(1, | ||
397 | KERN_INFO | ||
398 | "saa7185.c: detecting saa7185 client on address 0x%x\n", | ||
399 | address << 1); | ||
400 | |||
401 | /* Check if the adapter supports the needed features */ | 344 | /* Check if the adapter supports the needed features */ |
402 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 345 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
403 | return 0; | 346 | return -ENODEV; |
404 | 347 | ||
405 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | 348 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
406 | if (!client) | 349 | client->addr << 1, client->adapter->name); |
407 | return -ENOMEM; | ||
408 | client->addr = address; | ||
409 | client->adapter = adapter; | ||
410 | client->driver = &i2c_driver_saa7185; | ||
411 | strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client))); | ||
412 | 350 | ||
413 | encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); | 351 | encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); |
414 | if (encoder == NULL) { | 352 | if (encoder == NULL) |
415 | kfree(client); | ||
416 | return -ENOMEM; | 353 | return -ENOMEM; |
417 | } | ||
418 | encoder->norm = VIDEO_MODE_NTSC; | 354 | encoder->norm = VIDEO_MODE_NTSC; |
419 | encoder->enable = 1; | 355 | encoder->enable = 1; |
420 | i2c_set_clientdata(client, encoder); | 356 | i2c_set_clientdata(client, encoder); |
421 | 357 | ||
422 | i = i2c_attach_client(client); | ||
423 | if (i) { | ||
424 | kfree(client); | ||
425 | kfree(encoder); | ||
426 | return i; | ||
427 | } | ||
428 | |||
429 | i = saa7185_write_block(client, init_common, sizeof(init_common)); | 358 | i = saa7185_write_block(client, init_common, sizeof(init_common)); |
430 | if (i >= 0) { | 359 | if (i >= 0) |
431 | i = saa7185_write_block(client, init_ntsc, | 360 | i = saa7185_write_block(client, init_ntsc, sizeof(init_ntsc)); |
432 | sizeof(init_ntsc)); | 361 | if (i < 0) |
433 | } | 362 | v4l_dbg(1, debug, client, "init error %d\n", i); |
434 | if (i < 0) { | 363 | else |
435 | dprintk(1, KERN_ERR "%s_attach: init error %d\n", | 364 | v4l_dbg(1, debug, client, "revision 0x%x\n", |
436 | I2C_NAME(client), i); | 365 | saa7185_read(client) >> 5); |
437 | } else { | ||
438 | dprintk(1, | ||
439 | KERN_INFO | ||
440 | "%s_attach: chip version %d at address 0x%x\n", | ||
441 | I2C_NAME(client), saa7185_read(client) >> 5, | ||
442 | client->addr << 1); | ||
443 | } | ||
444 | |||
445 | return 0; | 366 | return 0; |
446 | } | 367 | } |
447 | 368 | ||
448 | static int | 369 | static int saa7185_remove(struct i2c_client *client) |
449 | saa7185_attach_adapter (struct i2c_adapter *adapter) | ||
450 | { | ||
451 | dprintk(1, | ||
452 | KERN_INFO | ||
453 | "saa7185.c: starting probe for adapter %s (0x%x)\n", | ||
454 | I2C_NAME(adapter), adapter->id); | ||
455 | return i2c_probe(adapter, &addr_data, &saa7185_detect_client); | ||
456 | } | ||
457 | |||
458 | static int | ||
459 | saa7185_detach_client (struct i2c_client *client) | ||
460 | { | 370 | { |
461 | struct saa7185 *encoder = i2c_get_clientdata(client); | 371 | struct saa7185 *encoder = i2c_get_clientdata(client); |
462 | int err; | ||
463 | |||
464 | err = i2c_detach_client(client); | ||
465 | if (err) { | ||
466 | return err; | ||
467 | } | ||
468 | 372 | ||
469 | saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ | 373 | saa7185_write(client, 0x61, (encoder->reg[0x61]) | 0x40); /* SW: output off is active */ |
470 | //saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ | 374 | //saa7185_write(client, 0x3a, (encoder->reg[0x3a]) | 0x80); /* SW: color bar */ |
471 | 375 | ||
472 | kfree(encoder); | 376 | kfree(encoder); |
473 | kfree(client); | ||
474 | |||
475 | return 0; | 377 | return 0; |
476 | } | 378 | } |
477 | 379 | ||
478 | /* ----------------------------------------------------------------------- */ | 380 | /* ----------------------------------------------------------------------- */ |
479 | 381 | ||
480 | static struct i2c_driver i2c_driver_saa7185 = { | 382 | static const struct i2c_device_id saa7185_id[] = { |
481 | .driver = { | 383 | { "saa7185", 0 }, |
482 | .name = "saa7185", /* name */ | 384 | { } |
483 | }, | 385 | }; |
484 | 386 | MODULE_DEVICE_TABLE(i2c, saa7185_id); | |
485 | .id = I2C_DRIVERID_SAA7185B, | ||
486 | 387 | ||
487 | .attach_adapter = saa7185_attach_adapter, | 388 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
488 | .detach_client = saa7185_detach_client, | 389 | .name = "saa7185", |
390 | .driverid = I2C_DRIVERID_SAA7185B, | ||
489 | .command = saa7185_command, | 391 | .command = saa7185_command, |
392 | .probe = saa7185_probe, | ||
393 | .remove = saa7185_remove, | ||
394 | .id_table = saa7185_id, | ||
490 | }; | 395 | }; |
491 | |||
492 | static int __init | ||
493 | saa7185_init (void) | ||
494 | { | ||
495 | return i2c_add_driver(&i2c_driver_saa7185); | ||
496 | } | ||
497 | |||
498 | static void __exit | ||
499 | saa7185_exit (void) | ||
500 | { | ||
501 | i2c_del_driver(&i2c_driver_saa7185); | ||
502 | } | ||
503 | |||
504 | module_init(saa7185_init); | ||
505 | module_exit(saa7185_exit); | ||
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 76838091dc66..2407607f2eff 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -40,39 +40,39 @@ | |||
40 | 40 | ||
41 | /* register offsets for sh7722 / sh7723 */ | 41 | /* register offsets for sh7722 / sh7723 */ |
42 | 42 | ||
43 | #define CAPSR 0x00 | 43 | #define CAPSR 0x00 /* Capture start register */ |
44 | #define CAPCR 0x04 | 44 | #define CAPCR 0x04 /* Capture control register */ |
45 | #define CAMCR 0x08 | 45 | #define CAMCR 0x08 /* Capture interface control register */ |
46 | #define CMCYR 0x0c | 46 | #define CMCYR 0x0c /* Capture interface cycle register */ |
47 | #define CAMOR 0x10 | 47 | #define CAMOR 0x10 /* Capture interface offset register */ |
48 | #define CAPWR 0x14 | 48 | #define CAPWR 0x14 /* Capture interface width register */ |
49 | #define CAIFR 0x18 | 49 | #define CAIFR 0x18 /* Capture interface input format register */ |
50 | #define CSTCR 0x20 /* not on sh7723 */ | 50 | #define CSTCR 0x20 /* Camera strobe control register (<= sh7722) */ |
51 | #define CSECR 0x24 /* not on sh7723 */ | 51 | #define CSECR 0x24 /* Camera strobe emission count register (<= sh7722) */ |
52 | #define CRCNTR 0x28 | 52 | #define CRCNTR 0x28 /* CEU register control register */ |
53 | #define CRCMPR 0x2c | 53 | #define CRCMPR 0x2c /* CEU register forcible control register */ |
54 | #define CFLCR 0x30 | 54 | #define CFLCR 0x30 /* Capture filter control register */ |
55 | #define CFSZR 0x34 | 55 | #define CFSZR 0x34 /* Capture filter size clip register */ |
56 | #define CDWDR 0x38 | 56 | #define CDWDR 0x38 /* Capture destination width register */ |
57 | #define CDAYR 0x3c | 57 | #define CDAYR 0x3c /* Capture data address Y register */ |
58 | #define CDACR 0x40 | 58 | #define CDACR 0x40 /* Capture data address C register */ |
59 | #define CDBYR 0x44 | 59 | #define CDBYR 0x44 /* Capture data bottom-field address Y register */ |
60 | #define CDBCR 0x48 | 60 | #define CDBCR 0x48 /* Capture data bottom-field address C register */ |
61 | #define CBDSR 0x4c | 61 | #define CBDSR 0x4c /* Capture bundle destination size register */ |
62 | #define CFWCR 0x5c | 62 | #define CFWCR 0x5c /* Firewall operation control register */ |
63 | #define CLFCR 0x60 | 63 | #define CLFCR 0x60 /* Capture low-pass filter control register */ |
64 | #define CDOCR 0x64 | 64 | #define CDOCR 0x64 /* Capture data output control register */ |
65 | #define CDDCR 0x68 | 65 | #define CDDCR 0x68 /* Capture data complexity level register */ |
66 | #define CDDAR 0x6c | 66 | #define CDDAR 0x6c /* Capture data complexity level address register */ |
67 | #define CEIER 0x70 | 67 | #define CEIER 0x70 /* Capture event interrupt enable register */ |
68 | #define CETCR 0x74 | 68 | #define CETCR 0x74 /* Capture event flag clear register */ |
69 | #define CSTSR 0x7c | 69 | #define CSTSR 0x7c /* Capture status register */ |
70 | #define CSRTR 0x80 | 70 | #define CSRTR 0x80 /* Capture software reset register */ |
71 | #define CDSSR 0x84 | 71 | #define CDSSR 0x84 /* Capture data size register */ |
72 | #define CDAYR2 0x90 | 72 | #define CDAYR2 0x90 /* Capture data address Y register 2 */ |
73 | #define CDACR2 0x94 | 73 | #define CDACR2 0x94 /* Capture data address C register 2 */ |
74 | #define CDBYR2 0x98 | 74 | #define CDBYR2 0x98 /* Capture data bottom-field address Y register 2 */ |
75 | #define CDBCR2 0x9c | 75 | #define CDBCR2 0x9c /* Capture data bottom-field address C register 2 */ |
76 | 76 | ||
77 | static DEFINE_MUTEX(camera_lock); | 77 | static DEFINE_MUTEX(camera_lock); |
78 | 78 | ||
@@ -165,6 +165,7 @@ static void sh_mobile_ceu_capture(struct sh_mobile_ceu_dev *pcdev) | |||
165 | ceu_write(pcdev, CETCR, 0x0317f313 ^ 0x10); | 165 | ceu_write(pcdev, CETCR, 0x0317f313 ^ 0x10); |
166 | 166 | ||
167 | if (pcdev->active) { | 167 | if (pcdev->active) { |
168 | pcdev->active->state = VIDEOBUF_ACTIVE; | ||
168 | ceu_write(pcdev, CDAYR, videobuf_to_dma_contig(pcdev->active)); | 169 | ceu_write(pcdev, CDAYR, videobuf_to_dma_contig(pcdev->active)); |
169 | ceu_write(pcdev, CAPSR, 0x1); /* start capture */ | 170 | ceu_write(pcdev, CAPSR, 0x1); /* start capture */ |
170 | } | 171 | } |
@@ -236,7 +237,7 @@ static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue *vq, | |||
236 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, | 237 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, |
237 | vb, vb->baddr, vb->bsize); | 238 | vb, vb->baddr, vb->bsize); |
238 | 239 | ||
239 | vb->state = VIDEOBUF_ACTIVE; | 240 | vb->state = VIDEOBUF_QUEUED; |
240 | spin_lock_irqsave(&pcdev->lock, flags); | 241 | spin_lock_irqsave(&pcdev->lock, flags); |
241 | list_add_tail(&vb->queue, &pcdev->capture); | 242 | list_add_tail(&vb->queue, &pcdev->capture); |
242 | 243 | ||
@@ -323,12 +324,24 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd) | |||
323 | { | 324 | { |
324 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 325 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
325 | struct sh_mobile_ceu_dev *pcdev = ici->priv; | 326 | struct sh_mobile_ceu_dev *pcdev = ici->priv; |
327 | unsigned long flags; | ||
326 | 328 | ||
327 | BUG_ON(icd != pcdev->icd); | 329 | BUG_ON(icd != pcdev->icd); |
328 | 330 | ||
329 | /* disable capture, disable interrupts */ | 331 | /* disable capture, disable interrupts */ |
330 | ceu_write(pcdev, CEIER, 0); | 332 | ceu_write(pcdev, CEIER, 0); |
331 | ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ | 333 | ceu_write(pcdev, CAPSR, 1 << 16); /* reset */ |
334 | |||
335 | /* make sure active buffer is canceled */ | ||
336 | spin_lock_irqsave(&pcdev->lock, flags); | ||
337 | if (pcdev->active) { | ||
338 | list_del(&pcdev->active->queue); | ||
339 | pcdev->active->state = VIDEOBUF_ERROR; | ||
340 | wake_up_all(&pcdev->active->done); | ||
341 | pcdev->active = NULL; | ||
342 | } | ||
343 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
344 | |||
332 | icd->ops->release(icd); | 345 | icd->ops->release(icd); |
333 | 346 | ||
334 | dev_info(&icd->dev, | 347 | dev_info(&icd->dev, |
@@ -391,7 +404,20 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd, | |||
391 | ceu_write(pcdev, CFLCR, 0); /* data fetch mode - no scaling */ | 404 | ceu_write(pcdev, CFLCR, 0); /* data fetch mode - no scaling */ |
392 | ceu_write(pcdev, CFSZR, (icd->height << 16) | cfszr_width); | 405 | ceu_write(pcdev, CFSZR, (icd->height << 16) | cfszr_width); |
393 | ceu_write(pcdev, CLFCR, 0); /* data fetch mode - no lowpass filter */ | 406 | ceu_write(pcdev, CLFCR, 0); /* data fetch mode - no lowpass filter */ |
394 | ceu_write(pcdev, CDOCR, 0x00000016); | 407 | |
408 | /* A few words about byte order (observed in Big Endian mode) | ||
409 | * | ||
410 | * In data fetch mode bytes are received in chunks of 8 bytes. | ||
411 | * D0, D1, D2, D3, D4, D5, D6, D7 (D0 received first) | ||
412 | * | ||
413 | * The data is however by default written to memory in reverse order: | ||
414 | * D7, D6, D5, D4, D3, D2, D1, D0 (D7 written to lowest byte) | ||
415 | * | ||
416 | * The lowest three bits of CDOCR allows us to do swapping, | ||
417 | * using 7 we swap the data bytes to match the incoming order: | ||
418 | * D0, D1, D2, D3, D4, D5, D6, D7 | ||
419 | */ | ||
420 | ceu_write(pcdev, CDOCR, 0x00000017); | ||
395 | 421 | ||
396 | ceu_write(pcdev, CDWDR, cdwdr_width); | 422 | ceu_write(pcdev, CDWDR, cdwdr_width); |
397 | ceu_write(pcdev, CFWCR, 0); /* keep "datafetch firewall" disabled */ | 423 | ceu_write(pcdev, CFWCR, 0); /* keep "datafetch firewall" disabled */ |
diff --git a/drivers/media/video/soc_camera_platform.c b/drivers/media/video/soc_camera_platform.c index 1adc257ebdb9..bb7a9d480e8f 100644 --- a/drivers/media/video/soc_camera_platform.c +++ b/drivers/media/video/soc_camera_platform.c | |||
@@ -18,15 +18,7 @@ | |||
18 | #include <linux/videodev2.h> | 18 | #include <linux/videodev2.h> |
19 | #include <media/v4l2-common.h> | 19 | #include <media/v4l2-common.h> |
20 | #include <media/soc_camera.h> | 20 | #include <media/soc_camera.h> |
21 | 21 | #include <media/soc_camera_platform.h> | |
22 | struct soc_camera_platform_info { | ||
23 | int iface; | ||
24 | char *format_name; | ||
25 | unsigned long format_depth; | ||
26 | struct v4l2_pix_format format; | ||
27 | unsigned long bus_param; | ||
28 | int (*set_capture)(struct soc_camera_platform_info *info, int enable); | ||
29 | }; | ||
30 | 22 | ||
31 | struct soc_camera_platform_priv { | 23 | struct soc_camera_platform_priv { |
32 | struct soc_camera_platform_info *info; | 24 | struct soc_camera_platform_info *info; |
@@ -44,11 +36,21 @@ soc_camera_platform_get_info(struct soc_camera_device *icd) | |||
44 | 36 | ||
45 | static int soc_camera_platform_init(struct soc_camera_device *icd) | 37 | static int soc_camera_platform_init(struct soc_camera_device *icd) |
46 | { | 38 | { |
39 | struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); | ||
40 | |||
41 | if (p->power) | ||
42 | p->power(1); | ||
43 | |||
47 | return 0; | 44 | return 0; |
48 | } | 45 | } |
49 | 46 | ||
50 | static int soc_camera_platform_release(struct soc_camera_device *icd) | 47 | static int soc_camera_platform_release(struct soc_camera_device *icd) |
51 | { | 48 | { |
49 | struct soc_camera_platform_info *p = soc_camera_platform_get_info(icd); | ||
50 | |||
51 | if (p->power) | ||
52 | p->power(0); | ||
53 | |||
52 | return 0; | 54 | return 0; |
53 | } | 55 | } |
54 | 56 | ||
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index db69bc5556d6..edaea4964513 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/kref.h> | ||
31 | 30 | ||
32 | #include <linux/usb.h> | 31 | #include <linux/usb.h> |
33 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
@@ -560,7 +559,7 @@ static void stk_clean_iso(struct stk_camera *dev) | |||
560 | 559 | ||
561 | urb = dev->isobufs[i].urb; | 560 | urb = dev->isobufs[i].urb; |
562 | if (urb) { | 561 | if (urb) { |
563 | if (atomic_read(&dev->urbs_used)) | 562 | if (atomic_read(&dev->urbs_used) && is_present(dev)) |
564 | usb_kill_urb(urb); | 563 | usb_kill_urb(urb); |
565 | usb_free_urb(urb); | 564 | usb_free_urb(urb); |
566 | } | 565 | } |
@@ -689,18 +688,14 @@ static int v4l_stk_release(struct inode *inode, struct file *fp) | |||
689 | { | 688 | { |
690 | struct stk_camera *dev = fp->private_data; | 689 | struct stk_camera *dev = fp->private_data; |
691 | 690 | ||
692 | if (dev->owner != fp) { | 691 | if (dev->owner == fp) { |
693 | usb_autopm_put_interface(dev->interface); | 692 | stk_stop_stream(dev); |
694 | return 0; | 693 | stk_free_buffers(dev); |
694 | dev->owner = NULL; | ||
695 | } | 695 | } |
696 | 696 | ||
697 | stk_stop_stream(dev); | 697 | if(is_present(dev)) |
698 | 698 | usb_autopm_put_interface(dev->interface); | |
699 | stk_free_buffers(dev); | ||
700 | |||
701 | dev->owner = NULL; | ||
702 | |||
703 | usb_autopm_put_interface(dev->interface); | ||
704 | 699 | ||
705 | return 0; | 700 | return 0; |
706 | } | 701 | } |
@@ -714,9 +709,6 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf, | |||
714 | struct stk_sio_buffer *sbuf; | 709 | struct stk_sio_buffer *sbuf; |
715 | struct stk_camera *dev = fp->private_data; | 710 | struct stk_camera *dev = fp->private_data; |
716 | 711 | ||
717 | if (dev == NULL) | ||
718 | return -EIO; | ||
719 | |||
720 | if (!is_present(dev)) | 712 | if (!is_present(dev)) |
721 | return -EIO; | 713 | return -EIO; |
722 | if (dev->owner && dev->owner != fp) | 714 | if (dev->owner && dev->owner != fp) |
@@ -773,9 +765,6 @@ static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) | |||
773 | { | 765 | { |
774 | struct stk_camera *dev = fp->private_data; | 766 | struct stk_camera *dev = fp->private_data; |
775 | 767 | ||
776 | if (dev == NULL) | ||
777 | return -ENODEV; | ||
778 | |||
779 | poll_wait(fp, &dev->wait_frame, wait); | 768 | poll_wait(fp, &dev->wait_frame, wait); |
780 | 769 | ||
781 | if (!is_present(dev)) | 770 | if (!is_present(dev)) |
@@ -1436,7 +1425,7 @@ static void stk_camera_disconnect(struct usb_interface *interface) | |||
1436 | wake_up_interruptible(&dev->wait_frame); | 1425 | wake_up_interruptible(&dev->wait_frame); |
1437 | stk_remove_sysfs_files(&dev->vdev); | 1426 | stk_remove_sysfs_files(&dev->vdev); |
1438 | 1427 | ||
1439 | STK_INFO("Syntek USB2.0 Camera release resources" | 1428 | STK_INFO("Syntek USB2.0 Camera release resources " |
1440 | "video device /dev/video%d\n", dev->vdev.minor); | 1429 | "video device /dev/video%d\n", dev->vdev.minor); |
1441 | 1430 | ||
1442 | video_unregister_device(&dev->vdev); | 1431 | video_unregister_device(&dev->vdev); |
diff --git a/drivers/media/video/stk-webcam.h b/drivers/media/video/stk-webcam.h index 084a85bdd16e..9f6736637571 100644 --- a/drivers/media/video/stk-webcam.h +++ b/drivers/media/video/stk-webcam.h | |||
@@ -122,7 +122,6 @@ struct stk_camera { | |||
122 | 122 | ||
123 | #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) | 123 | #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) |
124 | 124 | ||
125 | void stk_camera_delete(struct kref *); | ||
126 | int stk_camera_write_reg(struct stk_camera *, u16, u8); | 125 | int stk_camera_write_reg(struct stk_camera *, u16, u8); |
127 | int stk_camera_read_reg(struct stk_camera *, u16, int *); | 126 | int stk_camera_read_reg(struct stk_camera *, u16, int *); |
128 | 127 | ||
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index bcc32fa92a81..3b0b84c2e451 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
@@ -242,7 +242,7 @@ hauppauge_tuner[] = | |||
242 | { TUNER_ABSENT, "TCL M2523_3DBH_E"}, | 242 | { TUNER_ABSENT, "TCL M2523_3DBH_E"}, |
243 | { TUNER_ABSENT, "TCL M2523_3DIH_E"}, | 243 | { TUNER_ABSENT, "TCL M2523_3DIH_E"}, |
244 | { TUNER_ABSENT, "TCL MFPE05_2_U"}, | 244 | { TUNER_ABSENT, "TCL MFPE05_2_U"}, |
245 | { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216MEX"}, | 245 | { TUNER_PHILIPS_FMD1216MEX_MK3, "Philips FMD1216MEX"}, |
246 | { TUNER_ABSENT, "Philips FRH2036B"}, | 246 | { TUNER_ABSENT, "Philips FRH2036B"}, |
247 | { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, | 247 | { TUNER_ABSENT, "Panasonic ENGF75_01GF"}, |
248 | { TUNER_ABSENT, "MaxLinear MXL5005"}, | 248 | { TUNER_ABSENT, "MaxLinear MXL5005"}, |
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c index b56cffcbfd45..917277d36605 100644 --- a/drivers/media/video/videobuf-dvb.c +++ b/drivers/media/video/videobuf-dvb.c | |||
@@ -126,7 +126,6 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed) | |||
126 | mutex_lock(&dvb->lock); | 126 | mutex_lock(&dvb->lock); |
127 | dvb->nfeeds--; | 127 | dvb->nfeeds--; |
128 | if (0 == dvb->nfeeds && NULL != dvb->thread) { | 128 | if (0 == dvb->nfeeds && NULL != dvb->thread) { |
129 | // FIXME: cx8802_cancel_buffers(dev); | ||
130 | err = kthread_stop(dvb->thread); | 129 | err = kthread_stop(dvb->thread); |
131 | dvb->thread = NULL; | 130 | dvb->thread = NULL; |
132 | } | 131 | } |
@@ -134,30 +133,38 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed) | |||
134 | return err; | 133 | return err; |
135 | } | 134 | } |
136 | 135 | ||
137 | /* ------------------------------------------------------------------ */ | 136 | static int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe, |
138 | |||
139 | int videobuf_dvb_register(struct videobuf_dvb *dvb, | ||
140 | struct module *module, | 137 | struct module *module, |
141 | void *adapter_priv, | 138 | void *adapter_priv, |
142 | struct device *device, | 139 | struct device *device, |
143 | short *adapter_nr) | 140 | char *adapter_name, |
141 | short *adapter_nr, | ||
142 | int mfe_shared) | ||
144 | { | 143 | { |
145 | int result; | 144 | int result; |
146 | 145 | ||
147 | mutex_init(&dvb->lock); | 146 | mutex_init(&fe->lock); |
148 | 147 | ||
149 | /* register adapter */ | 148 | /* register adapter */ |
150 | result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device, | 149 | result = dvb_register_adapter(&fe->adapter, adapter_name, module, |
151 | adapter_nr); | 150 | device, adapter_nr); |
152 | if (result < 0) { | 151 | if (result < 0) { |
153 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", | 152 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", |
154 | dvb->name, result); | 153 | adapter_name, result); |
155 | goto fail_adapter; | ||
156 | } | 154 | } |
157 | dvb->adapter.priv = adapter_priv; | 155 | fe->adapter.priv = adapter_priv; |
156 | fe->adapter.mfe_shared = mfe_shared; | ||
157 | |||
158 | return result; | ||
159 | } | ||
160 | |||
161 | static int videobuf_dvb_register_frontend(struct dvb_adapter *adapter, | ||
162 | struct videobuf_dvb *dvb) | ||
163 | { | ||
164 | int result; | ||
158 | 165 | ||
159 | /* register frontend */ | 166 | /* register frontend */ |
160 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | 167 | result = dvb_register_frontend(adapter, dvb->frontend); |
161 | if (result < 0) { | 168 | if (result < 0) { |
162 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", | 169 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", |
163 | dvb->name, result); | 170 | dvb->name, result); |
@@ -183,7 +190,8 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb, | |||
183 | dvb->dmxdev.filternum = 256; | 190 | dvb->dmxdev.filternum = 256; |
184 | dvb->dmxdev.demux = &dvb->demux.dmx; | 191 | dvb->dmxdev.demux = &dvb->demux.dmx; |
185 | dvb->dmxdev.capabilities = 0; | 192 | dvb->dmxdev.capabilities = 0; |
186 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | 193 | result = dvb_dmxdev_init(&dvb->dmxdev, adapter); |
194 | |||
187 | if (result < 0) { | 195 | if (result < 0) { |
188 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | 196 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", |
189 | dvb->name, result); | 197 | dvb->name, result); |
@@ -214,7 +222,11 @@ int videobuf_dvb_register(struct videobuf_dvb *dvb, | |||
214 | } | 222 | } |
215 | 223 | ||
216 | /* register network adapter */ | 224 | /* register network adapter */ |
217 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | 225 | dvb_net_init(adapter, &dvb->net, &dvb->demux.dmx); |
226 | if (dvb->net.dvbdev == NULL) { | ||
227 | result = -ENOMEM; | ||
228 | goto fail_fe_conn; | ||
229 | } | ||
218 | return 0; | 230 | return 0; |
219 | 231 | ||
220 | fail_fe_conn: | 232 | fail_fe_conn: |
@@ -229,30 +241,151 @@ fail_dmx: | |||
229 | dvb_unregister_frontend(dvb->frontend); | 241 | dvb_unregister_frontend(dvb->frontend); |
230 | fail_frontend: | 242 | fail_frontend: |
231 | dvb_frontend_detach(dvb->frontend); | 243 | dvb_frontend_detach(dvb->frontend); |
232 | dvb_unregister_adapter(&dvb->adapter); | 244 | dvb->frontend = NULL; |
233 | fail_adapter: | 245 | |
234 | return result; | 246 | return result; |
235 | } | 247 | } |
236 | 248 | ||
237 | void videobuf_dvb_unregister(struct videobuf_dvb *dvb) | 249 | /* ------------------------------------------------------------------ */ |
250 | /* Register a single adapter and one or more frontends */ | ||
251 | int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f, | ||
252 | struct module *module, | ||
253 | void *adapter_priv, | ||
254 | struct device *device, | ||
255 | short *adapter_nr, | ||
256 | int mfe_shared) | ||
238 | { | 257 | { |
239 | dvb_net_release(&dvb->net); | 258 | struct list_head *list, *q; |
240 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | 259 | struct videobuf_dvb_frontend *fe; |
241 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | 260 | int res; |
242 | dvb_dmxdev_release(&dvb->dmxdev); | 261 | |
243 | dvb_dmx_release(&dvb->demux); | 262 | fe = videobuf_dvb_get_frontend(f, 1); |
244 | dvb_unregister_frontend(dvb->frontend); | 263 | if (!fe) { |
245 | dvb_frontend_detach(dvb->frontend); | 264 | printk(KERN_WARNING "Unable to register the adapter which has no frontends\n"); |
246 | dvb_unregister_adapter(&dvb->adapter); | 265 | return -EINVAL; |
266 | } | ||
267 | |||
268 | /* Bring up the adapter */ | ||
269 | res = videobuf_dvb_register_adapter(f, module, adapter_priv, device, | ||
270 | fe->dvb.name, adapter_nr, mfe_shared); | ||
271 | if (res < 0) { | ||
272 | printk(KERN_WARNING "videobuf_dvb_register_adapter failed (errno = %d)\n", res); | ||
273 | return res; | ||
274 | } | ||
275 | |||
276 | /* Attach all of the frontends to the adapter */ | ||
277 | mutex_lock(&f->lock); | ||
278 | list_for_each_safe(list, q, &f->felist) { | ||
279 | fe = list_entry(list, struct videobuf_dvb_frontend, felist); | ||
280 | res = videobuf_dvb_register_frontend(&f->adapter, &fe->dvb); | ||
281 | if (res < 0) { | ||
282 | printk(KERN_WARNING "%s: videobuf_dvb_register_frontend failed (errno = %d)\n", | ||
283 | fe->dvb.name, res); | ||
284 | goto err; | ||
285 | } | ||
286 | } | ||
287 | mutex_unlock(&f->lock); | ||
288 | return 0; | ||
289 | |||
290 | err: | ||
291 | mutex_unlock(&f->lock); | ||
292 | videobuf_dvb_unregister_bus(f); | ||
293 | return res; | ||
247 | } | 294 | } |
295 | EXPORT_SYMBOL(videobuf_dvb_register_bus); | ||
248 | 296 | ||
249 | EXPORT_SYMBOL(videobuf_dvb_register); | 297 | void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f) |
250 | EXPORT_SYMBOL(videobuf_dvb_unregister); | 298 | { |
299 | struct list_head *list, *q; | ||
300 | struct videobuf_dvb_frontend *fe; | ||
301 | |||
302 | mutex_lock(&f->lock); | ||
303 | list_for_each_safe(list, q, &f->felist) { | ||
304 | fe = list_entry(list, struct videobuf_dvb_frontend, felist); | ||
305 | if (fe->dvb.net.dvbdev) { | ||
306 | dvb_net_release(&fe->dvb.net); | ||
307 | fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, | ||
308 | &fe->dvb.fe_mem); | ||
309 | fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, | ||
310 | &fe->dvb.fe_hw); | ||
311 | dvb_dmxdev_release(&fe->dvb.dmxdev); | ||
312 | dvb_dmx_release(&fe->dvb.demux); | ||
313 | dvb_unregister_frontend(fe->dvb.frontend); | ||
314 | } | ||
315 | if (fe->dvb.frontend) | ||
316 | /* always allocated, may have been reset */ | ||
317 | dvb_frontend_detach(fe->dvb.frontend); | ||
318 | list_del(list); | ||
319 | kfree(fe); | ||
320 | } | ||
321 | mutex_unlock(&f->lock); | ||
251 | 322 | ||
252 | /* ------------------------------------------------------------------ */ | 323 | dvb_unregister_adapter(&f->adapter); |
253 | /* | 324 | } |
254 | * Local variables: | 325 | EXPORT_SYMBOL(videobuf_dvb_unregister_bus); |
255 | * c-basic-offset: 8 | 326 | |
256 | * compile-command: "make DVB=1" | 327 | struct videobuf_dvb_frontend *videobuf_dvb_get_frontend( |
257 | * End: | 328 | struct videobuf_dvb_frontends *f, int id) |
258 | */ | 329 | { |
330 | struct list_head *list, *q; | ||
331 | struct videobuf_dvb_frontend *fe, *ret = NULL; | ||
332 | |||
333 | mutex_lock(&f->lock); | ||
334 | |||
335 | list_for_each_safe(list, q, &f->felist) { | ||
336 | fe = list_entry(list, struct videobuf_dvb_frontend, felist); | ||
337 | if (fe->id == id) { | ||
338 | ret = fe; | ||
339 | break; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | mutex_unlock(&f->lock); | ||
344 | |||
345 | return ret; | ||
346 | } | ||
347 | EXPORT_SYMBOL(videobuf_dvb_get_frontend); | ||
348 | |||
349 | int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, | ||
350 | struct dvb_frontend *p) | ||
351 | { | ||
352 | struct list_head *list, *q; | ||
353 | struct videobuf_dvb_frontend *fe = NULL; | ||
354 | int ret = 0; | ||
355 | |||
356 | mutex_lock(&f->lock); | ||
357 | |||
358 | list_for_each_safe(list, q, &f->felist) { | ||
359 | fe = list_entry(list, struct videobuf_dvb_frontend, felist); | ||
360 | if (fe->dvb.frontend == p) { | ||
361 | ret = fe->id; | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | |||
366 | mutex_unlock(&f->lock); | ||
367 | |||
368 | return ret; | ||
369 | } | ||
370 | EXPORT_SYMBOL(videobuf_dvb_find_frontend); | ||
371 | |||
372 | struct videobuf_dvb_frontend *videobuf_dvb_alloc_frontend( | ||
373 | struct videobuf_dvb_frontends *f, int id) | ||
374 | { | ||
375 | struct videobuf_dvb_frontend *fe; | ||
376 | |||
377 | fe = kzalloc(sizeof(struct videobuf_dvb_frontend), GFP_KERNEL); | ||
378 | if (fe == NULL) | ||
379 | goto fail_alloc; | ||
380 | |||
381 | fe->id = id; | ||
382 | mutex_init(&fe->dvb.lock); | ||
383 | |||
384 | mutex_lock(&f->lock); | ||
385 | list_add_tail(&fe->felist, &f->felist); | ||
386 | mutex_unlock(&f->lock); | ||
387 | |||
388 | fail_alloc: | ||
389 | return fe; | ||
390 | } | ||
391 | EXPORT_SYMBOL(videobuf_dvb_alloc_frontend); | ||
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 65c8af18e767..7d7e51def461 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -128,12 +128,56 @@ struct vivi_fmt { | |||
128 | int depth; | 128 | int depth; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static struct vivi_fmt format = { | 131 | static struct vivi_fmt formats[] = { |
132 | .name = "4:2:2, packed, YUYV", | 132 | { |
133 | .fourcc = V4L2_PIX_FMT_YUYV, | 133 | .name = "4:2:2, packed, YUYV", |
134 | .depth = 16, | 134 | .fourcc = V4L2_PIX_FMT_YUYV, |
135 | .depth = 16, | ||
136 | }, | ||
137 | { | ||
138 | .name = "4:2:2, packed, UYVY", | ||
139 | .fourcc = V4L2_PIX_FMT_UYVY, | ||
140 | .depth = 16, | ||
141 | }, | ||
142 | { | ||
143 | .name = "RGB565 (LE)", | ||
144 | .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ | ||
145 | .depth = 16, | ||
146 | }, | ||
147 | { | ||
148 | .name = "RGB565 (BE)", | ||
149 | .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ | ||
150 | .depth = 16, | ||
151 | }, | ||
152 | { | ||
153 | .name = "RGB555 (LE)", | ||
154 | .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */ | ||
155 | .depth = 16, | ||
156 | }, | ||
157 | { | ||
158 | .name = "RGB555 (BE)", | ||
159 | .fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */ | ||
160 | .depth = 16, | ||
161 | }, | ||
135 | }; | 162 | }; |
136 | 163 | ||
164 | static struct vivi_fmt *get_format(struct v4l2_format *f) | ||
165 | { | ||
166 | struct vivi_fmt *fmt; | ||
167 | unsigned int k; | ||
168 | |||
169 | for (k = 0; k < ARRAY_SIZE(formats); k++) { | ||
170 | fmt = &formats[k]; | ||
171 | if (fmt->fourcc == f->fmt.pix.pixelformat) | ||
172 | break; | ||
173 | } | ||
174 | |||
175 | if (k == ARRAY_SIZE(formats)) | ||
176 | return NULL; | ||
177 | |||
178 | return &formats[k]; | ||
179 | } | ||
180 | |||
137 | struct sg_to_addr { | 181 | struct sg_to_addr { |
138 | int pos; | 182 | int pos; |
139 | struct scatterlist *sg; | 183 | struct scatterlist *sg; |
@@ -190,6 +234,7 @@ struct vivi_fh { | |||
190 | struct videobuf_queue vb_vidq; | 234 | struct videobuf_queue vb_vidq; |
191 | 235 | ||
192 | enum v4l2_buf_type type; | 236 | enum v4l2_buf_type type; |
237 | unsigned char bars[8][3]; | ||
193 | }; | 238 | }; |
194 | 239 | ||
195 | /* ------------------------------------------------------------------ | 240 | /* ------------------------------------------------------------------ |
@@ -234,42 +279,118 @@ static u8 bars[8][3] = { | |||
234 | #define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 | 279 | #define TSTAMP_MAX_Y TSTAMP_MIN_Y+15 |
235 | #define TSTAMP_MIN_X 64 | 280 | #define TSTAMP_MIN_X 64 |
236 | 281 | ||
237 | static void gen_line(char *basep, int inipos, int wmax, | 282 | static void gen_twopix(struct vivi_fh *fh, unsigned char *buf, int colorpos) |
238 | int hmax, int line, int count, char *timestr) | ||
239 | { | 283 | { |
240 | int w, i, j, y; | 284 | unsigned char r_y, g_u, b_v; |
241 | int pos = inipos; | 285 | unsigned char *p; |
242 | char *p, *s; | 286 | int color; |
243 | u8 chr, r, g, b, color; | ||
244 | 287 | ||
245 | /* We will just duplicate the second pixel at the packet */ | 288 | r_y = fh->bars[colorpos][0]; /* R or precalculated Y */ |
246 | wmax /= 2; | 289 | g_u = fh->bars[colorpos][1]; /* G or precalculated U */ |
290 | b_v = fh->bars[colorpos][2]; /* B or precalculated V */ | ||
247 | 291 | ||
248 | /* Generate a standard color bar pattern */ | 292 | for (color = 0; color < 4; color++) { |
249 | for (w = 0; w < wmax; w++) { | 293 | p = buf + color; |
250 | int colorpos = ((w + count) * 8/(wmax + 1)) % 8; | ||
251 | r = bars[colorpos][0]; | ||
252 | g = bars[colorpos][1]; | ||
253 | b = bars[colorpos][2]; | ||
254 | |||
255 | for (color = 0; color < 4; color++) { | ||
256 | p = basep + pos; | ||
257 | 294 | ||
295 | switch (fh->fmt->fourcc) { | ||
296 | case V4L2_PIX_FMT_YUYV: | ||
258 | switch (color) { | 297 | switch (color) { |
259 | case 0: | 298 | case 0: |
260 | case 2: | 299 | case 2: |
261 | *p = TO_Y(r, g, b); /* Luma */ | 300 | *p = r_y; |
262 | break; | 301 | break; |
263 | case 1: | 302 | case 1: |
264 | *p = TO_U(r, g, b); /* Cb */ | 303 | *p = g_u; |
265 | break; | 304 | break; |
266 | case 3: | 305 | case 3: |
267 | *p = TO_V(r, g, b); /* Cr */ | 306 | *p = b_v; |
307 | break; | ||
308 | } | ||
309 | break; | ||
310 | case V4L2_PIX_FMT_UYVY: | ||
311 | switch (color) { | ||
312 | case 1: | ||
313 | case 3: | ||
314 | *p = r_y; | ||
315 | break; | ||
316 | case 0: | ||
317 | *p = g_u; | ||
318 | break; | ||
319 | case 2: | ||
320 | *p = b_v; | ||
321 | break; | ||
322 | } | ||
323 | break; | ||
324 | case V4L2_PIX_FMT_RGB565: | ||
325 | switch (color) { | ||
326 | case 0: | ||
327 | case 2: | ||
328 | *p = (g_u << 5) | b_v; | ||
329 | break; | ||
330 | case 1: | ||
331 | case 3: | ||
332 | *p = (r_y << 3) | (g_u >> 3); | ||
333 | break; | ||
334 | } | ||
335 | break; | ||
336 | case V4L2_PIX_FMT_RGB565X: | ||
337 | switch (color) { | ||
338 | case 0: | ||
339 | case 2: | ||
340 | *p = (r_y << 3) | (g_u >> 3); | ||
341 | break; | ||
342 | case 1: | ||
343 | case 3: | ||
344 | *p = (g_u << 5) | b_v; | ||
268 | break; | 345 | break; |
269 | } | 346 | } |
270 | pos++; | 347 | break; |
348 | case V4L2_PIX_FMT_RGB555: | ||
349 | switch (color) { | ||
350 | case 0: | ||
351 | case 2: | ||
352 | *p = (g_u << 5) | b_v; | ||
353 | break; | ||
354 | case 1: | ||
355 | case 3: | ||
356 | *p = (r_y << 2) | (g_u >> 3); | ||
357 | break; | ||
358 | } | ||
359 | break; | ||
360 | case V4L2_PIX_FMT_RGB555X: | ||
361 | switch (color) { | ||
362 | case 0: | ||
363 | case 2: | ||
364 | *p = (r_y << 2) | (g_u >> 3); | ||
365 | break; | ||
366 | case 1: | ||
367 | case 3: | ||
368 | *p = (g_u << 5) | b_v; | ||
369 | break; | ||
370 | } | ||
371 | break; | ||
271 | } | 372 | } |
272 | } | 373 | } |
374 | } | ||
375 | |||
376 | static void gen_line(struct vivi_fh *fh, char *basep, int inipos, int wmax, | ||
377 | int hmax, int line, int count, char *timestr) | ||
378 | { | ||
379 | int w, i, j; | ||
380 | int pos = inipos; | ||
381 | char *s; | ||
382 | u8 chr; | ||
383 | |||
384 | /* We will just duplicate the second pixel at the packet */ | ||
385 | wmax /= 2; | ||
386 | |||
387 | /* Generate a standard color bar pattern */ | ||
388 | for (w = 0; w < wmax; w++) { | ||
389 | int colorpos = ((w + count) * 8/(wmax + 1)) % 8; | ||
390 | |||
391 | gen_twopix(fh, basep + pos, colorpos); | ||
392 | pos += 4; /* only 16 bpp supported for now */ | ||
393 | } | ||
273 | 394 | ||
274 | /* Checks if it is possible to show timestamp */ | 395 | /* Checks if it is possible to show timestamp */ |
275 | if (TSTAMP_MAX_Y >= hmax) | 396 | if (TSTAMP_MAX_Y >= hmax) |
@@ -283,38 +404,12 @@ static void gen_line(char *basep, int inipos, int wmax, | |||
283 | for (s = timestr; *s; s++) { | 404 | for (s = timestr; *s; s++) { |
284 | chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y]; | 405 | chr = rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y]; |
285 | for (i = 0; i < 7; i++) { | 406 | for (i = 0; i < 7; i++) { |
286 | if (chr & 1 << (7 - i)) { | ||
287 | /* Font color*/ | ||
288 | r = 0; | ||
289 | g = 198; | ||
290 | b = 0; | ||
291 | } else { | ||
292 | /* Background color */ | ||
293 | r = bars[BLACK][0]; | ||
294 | g = bars[BLACK][1]; | ||
295 | b = bars[BLACK][2]; | ||
296 | } | ||
297 | |||
298 | pos = inipos + j * 2; | 407 | pos = inipos + j * 2; |
299 | for (color = 0; color < 4; color++) { | 408 | /* Draw white font on black background */ |
300 | p = basep + pos; | 409 | if (chr & 1 << (7 - i)) |
301 | 410 | gen_twopix(fh, basep + pos, WHITE); | |
302 | y = TO_Y(r, g, b); | 411 | else |
303 | 412 | gen_twopix(fh, basep + pos, BLACK); | |
304 | switch (color) { | ||
305 | case 0: | ||
306 | case 2: | ||
307 | *p = TO_Y(r, g, b); /* Luma */ | ||
308 | break; | ||
309 | case 1: | ||
310 | *p = TO_U(r, g, b); /* Cb */ | ||
311 | break; | ||
312 | case 3: | ||
313 | *p = TO_V(r, g, b); /* Cr */ | ||
314 | break; | ||
315 | } | ||
316 | pos++; | ||
317 | } | ||
318 | j++; | 413 | j++; |
319 | } | 414 | } |
320 | } | 415 | } |
@@ -324,8 +419,9 @@ end: | |||
324 | return; | 419 | return; |
325 | } | 420 | } |
326 | 421 | ||
327 | static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | 422 | static void vivi_fillbuff(struct vivi_fh *fh, struct vivi_buffer *buf) |
328 | { | 423 | { |
424 | struct vivi_dev *dev = fh->dev; | ||
329 | int h , pos = 0; | 425 | int h , pos = 0; |
330 | int hmax = buf->vb.height; | 426 | int hmax = buf->vb.height; |
331 | int wmax = buf->vb.width; | 427 | int wmax = buf->vb.width; |
@@ -341,7 +437,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
341 | return; | 437 | return; |
342 | 438 | ||
343 | for (h = 0; h < hmax; h++) { | 439 | for (h = 0; h < hmax; h++) { |
344 | gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count, | 440 | gen_line(fh, tmpbuf, 0, wmax, hmax, h, dev->mv_count, |
345 | dev->timestr); | 441 | dev->timestr); |
346 | memcpy(vbuf + pos, tmpbuf, wmax * 2); | 442 | memcpy(vbuf + pos, tmpbuf, wmax * 2); |
347 | pos += wmax*2; | 443 | pos += wmax*2; |
@@ -410,7 +506,7 @@ static void vivi_thread_tick(struct vivi_fh *fh) | |||
410 | do_gettimeofday(&buf->vb.ts); | 506 | do_gettimeofday(&buf->vb.ts); |
411 | 507 | ||
412 | /* Fill buffer */ | 508 | /* Fill buffer */ |
413 | vivi_fillbuff(dev, buf); | 509 | vivi_fillbuff(fh, buf); |
414 | dprintk(dev, 1, "filled buffer %p\n", buf); | 510 | dprintk(dev, 1, "filled buffer %p\n", buf); |
415 | 511 | ||
416 | wake_up(&buf->vb.done); | 512 | wake_up(&buf->vb.done); |
@@ -636,11 +732,15 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
636 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | 732 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
637 | struct v4l2_fmtdesc *f) | 733 | struct v4l2_fmtdesc *f) |
638 | { | 734 | { |
639 | if (f->index > 0) | 735 | struct vivi_fmt *fmt; |
736 | |||
737 | if (f->index >= ARRAY_SIZE(formats)) | ||
640 | return -EINVAL; | 738 | return -EINVAL; |
641 | 739 | ||
642 | strlcpy(f->description, format.name, sizeof(f->description)); | 740 | fmt = &formats[f->index]; |
643 | f->pixelformat = format.fourcc; | 741 | |
742 | strlcpy(f->description, fmt->name, sizeof(f->description)); | ||
743 | f->pixelformat = fmt->fourcc; | ||
644 | return 0; | 744 | return 0; |
645 | } | 745 | } |
646 | 746 | ||
@@ -670,13 +770,12 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
670 | enum v4l2_field field; | 770 | enum v4l2_field field; |
671 | unsigned int maxw, maxh; | 771 | unsigned int maxw, maxh; |
672 | 772 | ||
673 | if (format.fourcc != f->fmt.pix.pixelformat) { | 773 | fmt = get_format(f); |
674 | dprintk(dev, 1, "Fourcc format (0x%08x) invalid. " | 774 | if (!fmt) { |
675 | "Driver accepts only 0x%08x\n", | 775 | dprintk(dev, 1, "Fourcc format (0x%08x) invalid.\n", |
676 | f->fmt.pix.pixelformat, format.fourcc); | 776 | f->fmt.pix.pixelformat); |
677 | return -EINVAL; | 777 | return -EINVAL; |
678 | } | 778 | } |
679 | fmt = &format; | ||
680 | 779 | ||
681 | field = f->fmt.pix.field; | 780 | field = f->fmt.pix.field; |
682 | 781 | ||
@@ -714,6 +813,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
714 | { | 813 | { |
715 | struct vivi_fh *fh = priv; | 814 | struct vivi_fh *fh = priv; |
716 | struct videobuf_queue *q = &fh->vb_vidq; | 815 | struct videobuf_queue *q = &fh->vb_vidq; |
816 | unsigned char r, g, b; | ||
817 | int k, is_yuv; | ||
717 | 818 | ||
718 | int ret = vidioc_try_fmt_vid_cap(file, fh, f); | 819 | int ret = vidioc_try_fmt_vid_cap(file, fh, f); |
719 | if (ret < 0) | 820 | if (ret < 0) |
@@ -727,12 +828,49 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
727 | goto out; | 828 | goto out; |
728 | } | 829 | } |
729 | 830 | ||
730 | fh->fmt = &format; | 831 | fh->fmt = get_format(f); |
731 | fh->width = f->fmt.pix.width; | 832 | fh->width = f->fmt.pix.width; |
732 | fh->height = f->fmt.pix.height; | 833 | fh->height = f->fmt.pix.height; |
733 | fh->vb_vidq.field = f->fmt.pix.field; | 834 | fh->vb_vidq.field = f->fmt.pix.field; |
734 | fh->type = f->type; | 835 | fh->type = f->type; |
735 | 836 | ||
837 | /* precalculate color bar values to speed up rendering */ | ||
838 | for (k = 0; k < 8; k++) { | ||
839 | r = bars[k][0]; | ||
840 | g = bars[k][1]; | ||
841 | b = bars[k][2]; | ||
842 | is_yuv = 0; | ||
843 | |||
844 | switch (fh->fmt->fourcc) { | ||
845 | case V4L2_PIX_FMT_YUYV: | ||
846 | case V4L2_PIX_FMT_UYVY: | ||
847 | is_yuv = 1; | ||
848 | break; | ||
849 | case V4L2_PIX_FMT_RGB565: | ||
850 | case V4L2_PIX_FMT_RGB565X: | ||
851 | r >>= 3; | ||
852 | g >>= 2; | ||
853 | b >>= 3; | ||
854 | break; | ||
855 | case V4L2_PIX_FMT_RGB555: | ||
856 | case V4L2_PIX_FMT_RGB555X: | ||
857 | r >>= 3; | ||
858 | g >>= 3; | ||
859 | b >>= 3; | ||
860 | break; | ||
861 | } | ||
862 | |||
863 | if (is_yuv) { | ||
864 | fh->bars[k][0] = TO_Y(r, g, b); /* Luma */ | ||
865 | fh->bars[k][1] = TO_U(r, g, b); /* Cb */ | ||
866 | fh->bars[k][2] = TO_V(r, g, b); /* Cr */ | ||
867 | } else { | ||
868 | fh->bars[k][0] = r; | ||
869 | fh->bars[k][1] = g; | ||
870 | fh->bars[k][2] = b; | ||
871 | } | ||
872 | } | ||
873 | |||
736 | ret = 0; | 874 | ret = 0; |
737 | out: | 875 | out: |
738 | mutex_unlock(&q->vb_lock); | 876 | mutex_unlock(&q->vb_lock); |
@@ -886,8 +1024,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
886 | File operations for the device | 1024 | File operations for the device |
887 | ------------------------------------------------------------------*/ | 1025 | ------------------------------------------------------------------*/ |
888 | 1026 | ||
889 | #define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8) | ||
890 | |||
891 | static int vivi_open(struct inode *inode, struct file *file) | 1027 | static int vivi_open(struct inode *inode, struct file *file) |
892 | { | 1028 | { |
893 | int minor = iminor(inode); | 1029 | int minor = iminor(inode); |
@@ -936,7 +1072,7 @@ unlock: | |||
936 | fh->dev = dev; | 1072 | fh->dev = dev; |
937 | 1073 | ||
938 | fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1074 | fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
939 | fh->fmt = &format; | 1075 | fh->fmt = &formats[0]; |
940 | fh->width = 640; | 1076 | fh->width = 640; |
941 | fh->height = 480; | 1077 | fh->height = 480; |
942 | 1078 | ||
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 45be9ec8edc4..67aa0db4b81a 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -22,32 +22,21 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/slab.h> | ||
26 | |||
27 | #include <asm/io.h> | ||
28 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
29 | |||
30 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
31 | |||
32 | #define I2C_NAME(x) (x)->name | ||
33 | |||
34 | #include <linux/videodev.h> | ||
35 | #include <media/v4l2-common.h> | 27 | #include <media/v4l2-common.h> |
28 | #include <media/v4l2-i2c-drv-legacy.h> | ||
29 | #include <linux/videodev.h> | ||
36 | #include <linux/video_decoder.h> | 30 | #include <linux/video_decoder.h> |
37 | 31 | ||
38 | #define I2C_VPX3220 0x86 | 32 | MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); |
39 | #define VPX3220_DEBUG KERN_DEBUG "vpx3220: " | 33 | MODULE_AUTHOR("Laurent Pinchart"); |
34 | MODULE_LICENSE("GPL"); | ||
40 | 35 | ||
41 | static int debug; | 36 | static int debug; |
42 | module_param(debug, int, 0); | 37 | module_param(debug, int, 0); |
43 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 38 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
44 | 39 | ||
45 | #define dprintk(num, format, args...) \ | ||
46 | do { \ | ||
47 | if (debug >= num) \ | ||
48 | printk(format, ##args); \ | ||
49 | } while (0) | ||
50 | |||
51 | #define VPX_TIMEOUT_COUNT 10 | 40 | #define VPX_TIMEOUT_COUNT 10 |
52 | 41 | ||
53 | /* ----------------------------------------------------------------------- */ | 42 | /* ----------------------------------------------------------------------- */ |
@@ -67,10 +56,8 @@ struct vpx3220 { | |||
67 | static char *inputs[] = { "internal", "composite", "svideo" }; | 56 | static char *inputs[] = { "internal", "composite", "svideo" }; |
68 | 57 | ||
69 | /* ----------------------------------------------------------------------- */ | 58 | /* ----------------------------------------------------------------------- */ |
70 | static inline int | 59 | |
71 | vpx3220_write (struct i2c_client *client, | 60 | static inline int vpx3220_write(struct i2c_client *client, u8 reg, u8 value) |
72 | u8 reg, | ||
73 | u8 value) | ||
74 | { | 61 | { |
75 | struct vpx3220 *decoder = i2c_get_clientdata(client); | 62 | struct vpx3220 *decoder = i2c_get_clientdata(client); |
76 | 63 | ||
@@ -78,15 +65,12 @@ vpx3220_write (struct i2c_client *client, | |||
78 | return i2c_smbus_write_byte_data(client, reg, value); | 65 | return i2c_smbus_write_byte_data(client, reg, value); |
79 | } | 66 | } |
80 | 67 | ||
81 | static inline int | 68 | static inline int vpx3220_read(struct i2c_client *client, u8 reg) |
82 | vpx3220_read (struct i2c_client *client, | ||
83 | u8 reg) | ||
84 | { | 69 | { |
85 | return i2c_smbus_read_byte_data(client, reg); | 70 | return i2c_smbus_read_byte_data(client, reg); |
86 | } | 71 | } |
87 | 72 | ||
88 | static int | 73 | static int vpx3220_fp_status(struct i2c_client *client) |
89 | vpx3220_fp_status (struct i2c_client *client) | ||
90 | { | 74 | { |
91 | unsigned char status; | 75 | unsigned char status; |
92 | unsigned int i; | 76 | unsigned int i; |
@@ -106,14 +90,11 @@ vpx3220_fp_status (struct i2c_client *client) | |||
106 | return -1; | 90 | return -1; |
107 | } | 91 | } |
108 | 92 | ||
109 | static int | 93 | static int vpx3220_fp_write(struct i2c_client *client, u8 fpaddr, u16 data) |
110 | vpx3220_fp_write (struct i2c_client *client, | ||
111 | u8 fpaddr, | ||
112 | u16 data) | ||
113 | { | 94 | { |
114 | /* Write the 16-bit address to the FPWR register */ | 95 | /* Write the 16-bit address to the FPWR register */ |
115 | if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) { | 96 | if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) { |
116 | dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); | 97 | v4l_dbg(1, debug, client, "%s: failed\n", __func__); |
117 | return -1; | 98 | return -1; |
118 | } | 99 | } |
119 | 100 | ||
@@ -122,22 +103,20 @@ vpx3220_fp_write (struct i2c_client *client, | |||
122 | 103 | ||
123 | /* Write the 16-bit data to the FPDAT register */ | 104 | /* Write the 16-bit data to the FPDAT register */ |
124 | if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) { | 105 | if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) { |
125 | dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); | 106 | v4l_dbg(1, debug, client, "%s: failed\n", __func__); |
126 | return -1; | 107 | return -1; |
127 | } | 108 | } |
128 | 109 | ||
129 | return 0; | 110 | return 0; |
130 | } | 111 | } |
131 | 112 | ||
132 | static u16 | 113 | static u16 vpx3220_fp_read(struct i2c_client *client, u16 fpaddr) |
133 | vpx3220_fp_read (struct i2c_client *client, | ||
134 | u16 fpaddr) | ||
135 | { | 114 | { |
136 | s16 data; | 115 | s16 data; |
137 | 116 | ||
138 | /* Write the 16-bit address to the FPRD register */ | 117 | /* Write the 16-bit address to the FPRD register */ |
139 | if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) { | 118 | if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) { |
140 | dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); | 119 | v4l_dbg(1, debug, client, "%s: failed\n", __func__); |
141 | return -1; | 120 | return -1; |
142 | } | 121 | } |
143 | 122 | ||
@@ -147,25 +126,22 @@ vpx3220_fp_read (struct i2c_client *client, | |||
147 | /* Read the 16-bit data from the FPDAT register */ | 126 | /* Read the 16-bit data from the FPDAT register */ |
148 | data = i2c_smbus_read_word_data(client, 0x28); | 127 | data = i2c_smbus_read_word_data(client, 0x28); |
149 | if (data == -1) { | 128 | if (data == -1) { |
150 | dprintk(1, VPX3220_DEBUG "%s: failed\n", __func__); | 129 | v4l_dbg(1, debug, client, "%s: failed\n", __func__); |
151 | return -1; | 130 | return -1; |
152 | } | 131 | } |
153 | 132 | ||
154 | return swab16(data); | 133 | return swab16(data); |
155 | } | 134 | } |
156 | 135 | ||
157 | static int | 136 | static int vpx3220_write_block(struct i2c_client *client, const u8 *data, unsigned int len) |
158 | vpx3220_write_block (struct i2c_client *client, | ||
159 | const u8 *data, | ||
160 | unsigned int len) | ||
161 | { | 137 | { |
162 | u8 reg; | 138 | u8 reg; |
163 | int ret = -1; | 139 | int ret = -1; |
164 | 140 | ||
165 | while (len >= 2) { | 141 | while (len >= 2) { |
166 | reg = *data++; | 142 | reg = *data++; |
167 | if ((ret = | 143 | ret = vpx3220_write(client, reg, *data++); |
168 | vpx3220_write(client, reg, *data++)) < 0) | 144 | if (ret < 0) |
169 | break; | 145 | break; |
170 | len -= 2; | 146 | len -= 2; |
171 | } | 147 | } |
@@ -173,10 +149,8 @@ vpx3220_write_block (struct i2c_client *client, | |||
173 | return ret; | 149 | return ret; |
174 | } | 150 | } |
175 | 151 | ||
176 | static int | 152 | static int vpx3220_write_fp_block(struct i2c_client *client, |
177 | vpx3220_write_fp_block (struct i2c_client *client, | 153 | const u16 *data, unsigned int len) |
178 | const u16 *data, | ||
179 | unsigned int len) | ||
180 | { | 154 | { |
181 | u8 reg; | 155 | u8 reg; |
182 | int ret = 0; | 156 | int ret = 0; |
@@ -285,25 +259,20 @@ static const unsigned short init_fp[] = { | |||
285 | 0x4b, 0x298, /* PLL gain */ | 259 | 0x4b, 0x298, /* PLL gain */ |
286 | }; | 260 | }; |
287 | 261 | ||
288 | static void | 262 | static void vpx3220_dump_i2c(struct i2c_client *client) |
289 | vpx3220_dump_i2c (struct i2c_client *client) | ||
290 | { | 263 | { |
291 | int len = sizeof(init_common); | 264 | int len = sizeof(init_common); |
292 | const unsigned char *data = init_common; | 265 | const unsigned char *data = init_common; |
293 | 266 | ||
294 | while (len > 1) { | 267 | while (len > 1) { |
295 | dprintk(1, | 268 | v4l_dbg(1, debug, client, "i2c reg 0x%02x data 0x%02x\n", |
296 | KERN_DEBUG "vpx3216b i2c reg 0x%02x data 0x%02x\n", | ||
297 | *data, vpx3220_read(client, *data)); | 269 | *data, vpx3220_read(client, *data)); |
298 | data += 2; | 270 | data += 2; |
299 | len -= 2; | 271 | len -= 2; |
300 | } | 272 | } |
301 | } | 273 | } |
302 | 274 | ||
303 | static int | 275 | static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) |
304 | vpx3220_command (struct i2c_client *client, | ||
305 | unsigned int cmd, | ||
306 | void *arg) | ||
307 | { | 276 | { |
308 | struct vpx3220 *decoder = i2c_get_clientdata(client); | 277 | struct vpx3220 *decoder = i2c_get_clientdata(client); |
309 | 278 | ||
@@ -315,7 +284,6 @@ vpx3220_command (struct i2c_client *client, | |||
315 | vpx3220_write_fp_block(client, init_fp, | 284 | vpx3220_write_fp_block(client, init_fp, |
316 | sizeof(init_fp) >> 1); | 285 | sizeof(init_fp) >> 1); |
317 | switch (decoder->norm) { | 286 | switch (decoder->norm) { |
318 | |||
319 | case VIDEO_MODE_NTSC: | 287 | case VIDEO_MODE_NTSC: |
320 | vpx3220_write_fp_block(client, init_ntsc, | 288 | vpx3220_write_fp_block(client, init_ntsc, |
321 | sizeof(init_ntsc) >> 1); | 289 | sizeof(init_ntsc) >> 1); |
@@ -334,21 +302,20 @@ vpx3220_command (struct i2c_client *client, | |||
334 | sizeof(init_pal) >> 1); | 302 | sizeof(init_pal) >> 1); |
335 | break; | 303 | break; |
336 | } | 304 | } |
337 | } | ||
338 | break; | 305 | break; |
306 | } | ||
339 | 307 | ||
340 | case DECODER_DUMP: | 308 | case DECODER_DUMP: |
341 | { | 309 | { |
342 | vpx3220_dump_i2c(client); | 310 | vpx3220_dump_i2c(client); |
343 | } | ||
344 | break; | 311 | break; |
312 | } | ||
345 | 313 | ||
346 | case DECODER_GET_CAPABILITIES: | 314 | case DECODER_GET_CAPABILITIES: |
347 | { | 315 | { |
348 | struct video_decoder_capability *cap = arg; | 316 | struct video_decoder_capability *cap = arg; |
349 | 317 | ||
350 | dprintk(1, KERN_DEBUG "%s: DECODER_GET_CAPABILITIES\n", | 318 | v4l_dbg(1, debug, client, "DECODER_GET_CAPABILITIES\n"); |
351 | I2C_NAME(client)); | ||
352 | 319 | ||
353 | cap->flags = VIDEO_DECODER_PAL | | 320 | cap->flags = VIDEO_DECODER_PAL | |
354 | VIDEO_DECODER_NTSC | | 321 | VIDEO_DECODER_NTSC | |
@@ -357,20 +324,18 @@ vpx3220_command (struct i2c_client *client, | |||
357 | VIDEO_DECODER_CCIR; | 324 | VIDEO_DECODER_CCIR; |
358 | cap->inputs = 3; | 325 | cap->inputs = 3; |
359 | cap->outputs = 1; | 326 | cap->outputs = 1; |
360 | } | ||
361 | break; | 327 | break; |
328 | } | ||
362 | 329 | ||
363 | case DECODER_GET_STATUS: | 330 | case DECODER_GET_STATUS: |
364 | { | 331 | { |
365 | int res = 0, status; | 332 | int res = 0, status; |
366 | 333 | ||
367 | dprintk(1, KERN_INFO "%s: DECODER_GET_STATUS\n", | 334 | v4l_dbg(1, debug, client, "DECODER_GET_STATUS\n"); |
368 | I2C_NAME(client)); | ||
369 | 335 | ||
370 | status = vpx3220_fp_read(client, 0x0f3); | 336 | status = vpx3220_fp_read(client, 0x0f3); |
371 | 337 | ||
372 | dprintk(1, KERN_INFO "%s: status: 0x%04x\n", I2C_NAME(client), | 338 | v4l_dbg(1, debug, client, "status: 0x%04x\n", status); |
373 | status); | ||
374 | 339 | ||
375 | if (status < 0) | 340 | if (status < 0) |
376 | return status; | 341 | return status; |
@@ -379,7 +344,6 @@ vpx3220_command (struct i2c_client *client, | |||
379 | res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; | 344 | res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; |
380 | 345 | ||
381 | switch (status & 0x18) { | 346 | switch (status & 0x18) { |
382 | |||
383 | case 0x00: | 347 | case 0x00: |
384 | case 0x10: | 348 | case 0x10: |
385 | case 0x14: | 349 | case 0x14: |
@@ -400,8 +364,8 @@ vpx3220_command (struct i2c_client *client, | |||
400 | } | 364 | } |
401 | 365 | ||
402 | *(int *) arg = res; | 366 | *(int *) arg = res; |
403 | } | ||
404 | break; | 367 | break; |
368 | } | ||
405 | 369 | ||
406 | case DECODER_SET_NORM: | 370 | case DECODER_SET_NORM: |
407 | { | 371 | { |
@@ -413,50 +377,43 @@ vpx3220_command (struct i2c_client *client, | |||
413 | choosen video norm */ | 377 | choosen video norm */ |
414 | temp_input = vpx3220_fp_read(client, 0xf2); | 378 | temp_input = vpx3220_fp_read(client, 0xf2); |
415 | 379 | ||
416 | dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n", | 380 | v4l_dbg(1, debug, client, "DECODER_SET_NORM %d\n", *iarg); |
417 | I2C_NAME(client), *iarg); | ||
418 | switch (*iarg) { | 381 | switch (*iarg) { |
419 | |||
420 | case VIDEO_MODE_NTSC: | 382 | case VIDEO_MODE_NTSC: |
421 | vpx3220_write_fp_block(client, init_ntsc, | 383 | vpx3220_write_fp_block(client, init_ntsc, |
422 | sizeof(init_ntsc) >> 1); | 384 | sizeof(init_ntsc) >> 1); |
423 | dprintk(1, KERN_INFO "%s: norm switched to NTSC\n", | 385 | v4l_dbg(1, debug, client, "norm switched to NTSC\n"); |
424 | I2C_NAME(client)); | ||
425 | break; | 386 | break; |
426 | 387 | ||
427 | case VIDEO_MODE_PAL: | 388 | case VIDEO_MODE_PAL: |
428 | vpx3220_write_fp_block(client, init_pal, | 389 | vpx3220_write_fp_block(client, init_pal, |
429 | sizeof(init_pal) >> 1); | 390 | sizeof(init_pal) >> 1); |
430 | dprintk(1, KERN_INFO "%s: norm switched to PAL\n", | 391 | v4l_dbg(1, debug, client, "norm switched to PAL\n"); |
431 | I2C_NAME(client)); | ||
432 | break; | 392 | break; |
433 | 393 | ||
434 | case VIDEO_MODE_SECAM: | 394 | case VIDEO_MODE_SECAM: |
435 | vpx3220_write_fp_block(client, init_secam, | 395 | vpx3220_write_fp_block(client, init_secam, |
436 | sizeof(init_secam) >> 1); | 396 | sizeof(init_secam) >> 1); |
437 | dprintk(1, KERN_INFO "%s: norm switched to SECAM\n", | 397 | v4l_dbg(1, debug, client, "norm switched to SECAM\n"); |
438 | I2C_NAME(client)); | ||
439 | break; | 398 | break; |
440 | 399 | ||
441 | case VIDEO_MODE_AUTO: | 400 | case VIDEO_MODE_AUTO: |
442 | /* FIXME This is only preliminary support */ | 401 | /* FIXME This is only preliminary support */ |
443 | data = vpx3220_fp_read(client, 0xf2) & 0x20; | 402 | data = vpx3220_fp_read(client, 0xf2) & 0x20; |
444 | vpx3220_fp_write(client, 0xf2, 0x00c0 | data); | 403 | vpx3220_fp_write(client, 0xf2, 0x00c0 | data); |
445 | dprintk(1, KERN_INFO "%s: norm switched to Auto\n", | 404 | v4l_dbg(1, debug, client, "norm switched to AUTO\n"); |
446 | I2C_NAME(client)); | ||
447 | break; | 405 | break; |
448 | 406 | ||
449 | default: | 407 | default: |
450 | return -EINVAL; | 408 | return -EINVAL; |
451 | |||
452 | } | 409 | } |
453 | decoder->norm = *iarg; | 410 | decoder->norm = *iarg; |
454 | 411 | ||
455 | /* And here we set the backed up video input again */ | 412 | /* And here we set the backed up video input again */ |
456 | vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); | 413 | vpx3220_fp_write(client, 0xf2, temp_input | 0x0010); |
457 | udelay(10); | 414 | udelay(10); |
458 | } | ||
459 | break; | 415 | break; |
416 | } | ||
460 | 417 | ||
461 | case DECODER_SET_INPUT: | 418 | case DECODER_SET_INPUT: |
462 | { | 419 | { |
@@ -475,8 +432,7 @@ vpx3220_command (struct i2c_client *client, | |||
475 | if (*iarg < 0 || *iarg > 2) | 432 | if (*iarg < 0 || *iarg > 2) |
476 | return -EINVAL; | 433 | return -EINVAL; |
477 | 434 | ||
478 | dprintk(1, KERN_INFO "%s: input switched to %s\n", | 435 | v4l_dbg(1, debug, client, "input switched to %s\n", inputs[*iarg]); |
479 | I2C_NAME(client), inputs[*iarg]); | ||
480 | 436 | ||
481 | vpx3220_write(client, 0x33, input[*iarg][0]); | 437 | vpx3220_write(client, 0x33, input[*iarg][0]); |
482 | 438 | ||
@@ -488,8 +444,8 @@ vpx3220_command (struct i2c_client *client, | |||
488 | data | (input[*iarg][1] << 5) | 0x0010); | 444 | data | (input[*iarg][1] << 5) | 0x0010); |
489 | 445 | ||
490 | udelay(10); | 446 | udelay(10); |
491 | } | ||
492 | break; | 447 | break; |
448 | } | ||
493 | 449 | ||
494 | case DECODER_SET_OUTPUT: | 450 | case DECODER_SET_OUTPUT: |
495 | { | 451 | { |
@@ -499,19 +455,18 @@ vpx3220_command (struct i2c_client *client, | |||
499 | if (*iarg != 0) { | 455 | if (*iarg != 0) { |
500 | return -EINVAL; | 456 | return -EINVAL; |
501 | } | 457 | } |
502 | } | ||
503 | break; | 458 | break; |
459 | } | ||
504 | 460 | ||
505 | case DECODER_ENABLE_OUTPUT: | 461 | case DECODER_ENABLE_OUTPUT: |
506 | { | 462 | { |
507 | int *iarg = arg; | 463 | int *iarg = arg; |
508 | 464 | ||
509 | dprintk(1, KERN_DEBUG "%s: DECODER_ENABLE_OUTPUT %d\n", | 465 | v4l_dbg(1, debug, client, "DECODER_ENABLE_OUTPUT %d\n", *iarg); |
510 | I2C_NAME(client), *iarg); | ||
511 | 466 | ||
512 | vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); | 467 | vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); |
513 | } | ||
514 | break; | 468 | break; |
469 | } | ||
515 | 470 | ||
516 | case DECODER_SET_PICTURE: | 471 | case DECODER_SET_PICTURE: |
517 | { | 472 | { |
@@ -542,8 +497,8 @@ vpx3220_command (struct i2c_client *client, | |||
542 | vpx3220_fp_write(client, 0x1c, | 497 | vpx3220_fp_write(client, 0x1c, |
543 | ((decoder->hue - 32768) >> 6) & 0xFFF); | 498 | ((decoder->hue - 32768) >> 6) & 0xFFF); |
544 | } | 499 | } |
545 | } | ||
546 | break; | 500 | break; |
501 | } | ||
547 | 502 | ||
548 | default: | 503 | default: |
549 | return -EINVAL; | 504 | return -EINVAL; |
@@ -552,8 +507,7 @@ vpx3220_command (struct i2c_client *client, | |||
552 | return 0; | 507 | return 0; |
553 | } | 508 | } |
554 | 509 | ||
555 | static int | 510 | static int vpx3220_init_client(struct i2c_client *client) |
556 | vpx3220_init_client (struct i2c_client *client) | ||
557 | { | 511 | { |
558 | vpx3220_write_block(client, init_common, sizeof(init_common)); | 512 | vpx3220_write_block(client, init_common, sizeof(init_common)); |
559 | vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1); | 513 | vpx3220_write_fp_block(client, init_fp, sizeof(init_fp) >> 1); |
@@ -567,115 +521,26 @@ vpx3220_init_client (struct i2c_client *client) | |||
567 | * Client management code | 521 | * Client management code |
568 | */ | 522 | */ |
569 | 523 | ||
570 | /* | 524 | static unsigned short normal_i2c[] = { 0x86 >> 1, 0x8e >> 1, I2C_CLIENT_END }; |
571 | * Generic i2c probe | ||
572 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
573 | */ | ||
574 | static unsigned short normal_i2c[] = | ||
575 | { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, | ||
576 | I2C_CLIENT_END | ||
577 | }; | ||
578 | |||
579 | static unsigned short ignore = I2C_CLIENT_END; | ||
580 | 525 | ||
581 | static struct i2c_client_address_data addr_data = { | 526 | I2C_CLIENT_INSMOD; |
582 | .normal_i2c = normal_i2c, | ||
583 | .probe = &ignore, | ||
584 | .ignore = &ignore, | ||
585 | }; | ||
586 | |||
587 | static struct i2c_driver vpx3220_i2c_driver; | ||
588 | |||
589 | static int | ||
590 | vpx3220_detach_client (struct i2c_client *client) | ||
591 | { | ||
592 | struct vpx3220 *decoder = i2c_get_clientdata(client); | ||
593 | int err; | ||
594 | |||
595 | err = i2c_detach_client(client); | ||
596 | if (err) { | ||
597 | return err; | ||
598 | } | ||
599 | |||
600 | kfree(decoder); | ||
601 | kfree(client); | ||
602 | |||
603 | return 0; | ||
604 | } | ||
605 | 527 | ||
606 | static int | 528 | static int vpx3220_probe(struct i2c_client *client, |
607 | vpx3220_detect_client (struct i2c_adapter *adapter, | 529 | const struct i2c_device_id *id) |
608 | int address, | ||
609 | int kind) | ||
610 | { | 530 | { |
611 | int err; | ||
612 | struct i2c_client *client; | ||
613 | struct vpx3220 *decoder; | 531 | struct vpx3220 *decoder; |
614 | 532 | const char *name = NULL; | |
615 | dprintk(1, VPX3220_DEBUG "%s\n", __func__); | 533 | u8 ver; |
534 | u16 pn; | ||
616 | 535 | ||
617 | /* Check if the adapter supports the needed features */ | 536 | /* Check if the adapter supports the needed features */ |
618 | if (!i2c_check_functionality | 537 | if (!i2c_check_functionality(client->adapter, |
619 | (adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) | 538 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) |
620 | return 0; | 539 | return -ENODEV; |
621 | |||
622 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
623 | if (client == NULL) { | ||
624 | return -ENOMEM; | ||
625 | } | ||
626 | |||
627 | client->addr = address; | ||
628 | client->adapter = adapter; | ||
629 | client->driver = &vpx3220_i2c_driver; | ||
630 | |||
631 | /* Check for manufacture ID and part number */ | ||
632 | if (kind < 0) { | ||
633 | u8 id; | ||
634 | u16 pn; | ||
635 | |||
636 | id = vpx3220_read(client, 0x00); | ||
637 | if (id != 0xec) { | ||
638 | dprintk(1, | ||
639 | KERN_INFO | ||
640 | "vpx3220_attach: Wrong manufacturer ID (0x%02x)\n", | ||
641 | id); | ||
642 | kfree(client); | ||
643 | return 0; | ||
644 | } | ||
645 | |||
646 | pn = (vpx3220_read(client, 0x02) << 8) + | ||
647 | vpx3220_read(client, 0x01); | ||
648 | switch (pn) { | ||
649 | case 0x4680: | ||
650 | strlcpy(I2C_NAME(client), "vpx3220a", | ||
651 | sizeof(I2C_NAME(client))); | ||
652 | break; | ||
653 | case 0x4260: | ||
654 | strlcpy(I2C_NAME(client), "vpx3216b", | ||
655 | sizeof(I2C_NAME(client))); | ||
656 | break; | ||
657 | case 0x4280: | ||
658 | strlcpy(I2C_NAME(client), "vpx3214c", | ||
659 | sizeof(I2C_NAME(client))); | ||
660 | break; | ||
661 | default: | ||
662 | dprintk(1, | ||
663 | KERN_INFO | ||
664 | "%s: Wrong part number (0x%04x)\n", | ||
665 | __func__, pn); | ||
666 | kfree(client); | ||
667 | return 0; | ||
668 | } | ||
669 | } else { | ||
670 | strlcpy(I2C_NAME(client), "forced vpx32xx", | ||
671 | sizeof(I2C_NAME(client))); | ||
672 | } | ||
673 | 540 | ||
674 | decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); | 541 | decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); |
675 | if (decoder == NULL) { | 542 | if (decoder == NULL) |
676 | kfree(client); | ||
677 | return -ENOMEM; | 543 | return -ENOMEM; |
678 | } | ||
679 | decoder->norm = VIDEO_MODE_PAL; | 544 | decoder->norm = VIDEO_MODE_PAL; |
680 | decoder->input = 0; | 545 | decoder->input = 0; |
681 | decoder->enable = 1; | 546 | decoder->enable = 1; |
@@ -685,63 +550,52 @@ vpx3220_detect_client (struct i2c_adapter *adapter, | |||
685 | decoder->sat = 32768; | 550 | decoder->sat = 32768; |
686 | i2c_set_clientdata(client, decoder); | 551 | i2c_set_clientdata(client, decoder); |
687 | 552 | ||
688 | err = i2c_attach_client(client); | 553 | ver = i2c_smbus_read_byte_data(client, 0x00); |
689 | if (err) { | 554 | pn = (i2c_smbus_read_byte_data(client, 0x02) << 8) + |
690 | kfree(client); | 555 | i2c_smbus_read_byte_data(client, 0x01); |
691 | kfree(decoder); | 556 | if (ver == 0xec) { |
692 | return err; | 557 | switch (pn) { |
558 | case 0x4680: | ||
559 | name = "vpx3220a"; | ||
560 | break; | ||
561 | case 0x4260: | ||
562 | name = "vpx3216b"; | ||
563 | break; | ||
564 | case 0x4280: | ||
565 | name = "vpx3214c"; | ||
566 | break; | ||
567 | } | ||
693 | } | 568 | } |
694 | 569 | if (name) | |
695 | dprintk(1, KERN_INFO "%s: vpx32xx client found at address 0x%02x\n", | 570 | v4l_info(client, "%s found @ 0x%x (%s)\n", name, |
696 | I2C_NAME(client), client->addr << 1); | 571 | client->addr << 1, client->adapter->name); |
572 | else | ||
573 | v4l_info(client, "chip (%02x:%04x) found @ 0x%x (%s)\n", | ||
574 | ver, pn, client->addr << 1, client->adapter->name); | ||
697 | 575 | ||
698 | vpx3220_init_client(client); | 576 | vpx3220_init_client(client); |
699 | |||
700 | return 0; | 577 | return 0; |
701 | } | 578 | } |
702 | 579 | ||
703 | static int | 580 | static int vpx3220_remove(struct i2c_client *client) |
704 | vpx3220_attach_adapter (struct i2c_adapter *adapter) | ||
705 | { | 581 | { |
706 | int ret; | 582 | kfree(i2c_get_clientdata(client)); |
707 | 583 | return 0; | |
708 | ret = i2c_probe(adapter, &addr_data, &vpx3220_detect_client); | ||
709 | dprintk(1, VPX3220_DEBUG "%s: i2c_probe returned %d\n", | ||
710 | __func__, ret); | ||
711 | return ret; | ||
712 | } | 584 | } |
713 | 585 | ||
714 | /* ----------------------------------------------------------------------- | 586 | static const struct i2c_device_id vpx3220_id[] = { |
715 | * Driver initialization and cleanup code | 587 | { "vpx3220a", 0 }, |
716 | */ | 588 | { "vpx3216b", 0 }, |
717 | 589 | { "vpx3214c", 0 }, | |
718 | static struct i2c_driver vpx3220_i2c_driver = { | 590 | { } |
719 | .driver = { | 591 | }; |
720 | .name = "vpx3220", | 592 | MODULE_DEVICE_TABLE(i2c, vpx3220_id); |
721 | }, | ||
722 | |||
723 | .id = I2C_DRIVERID_VPX3220, | ||
724 | 593 | ||
725 | .attach_adapter = vpx3220_attach_adapter, | 594 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
726 | .detach_client = vpx3220_detach_client, | 595 | .name = "vpx3220", |
596 | .driverid = I2C_DRIVERID_VPX3220, | ||
727 | .command = vpx3220_command, | 597 | .command = vpx3220_command, |
598 | .probe = vpx3220_probe, | ||
599 | .remove = vpx3220_remove, | ||
600 | .id_table = vpx3220_id, | ||
728 | }; | 601 | }; |
729 | |||
730 | static int __init | ||
731 | vpx3220_init (void) | ||
732 | { | ||
733 | return i2c_add_driver(&vpx3220_i2c_driver); | ||
734 | } | ||
735 | |||
736 | static void __exit | ||
737 | vpx3220_cleanup (void) | ||
738 | { | ||
739 | i2c_del_driver(&vpx3220_i2c_driver); | ||
740 | } | ||
741 | |||
742 | module_init(vpx3220_init); | ||
743 | module_exit(vpx3220_cleanup); | ||
744 | |||
745 | MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); | ||
746 | MODULE_AUTHOR("Laurent Pinchart"); | ||
747 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index 3282be730298..fa5f2f8f518a 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -817,6 +817,7 @@ zoran_register_i2c (struct zoran *zr) | |||
817 | memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, | 817 | memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, |
818 | sizeof(struct i2c_algo_bit_data)); | 818 | sizeof(struct i2c_algo_bit_data)); |
819 | zr->i2c_algo.data = zr; | 819 | zr->i2c_algo.data = zr; |
820 | zr->i2c_adapter.class = I2C_CLASS_TV_ANALOG; | ||
820 | zr->i2c_adapter.id = I2C_HW_B_ZR36067; | 821 | zr->i2c_adapter.id = I2C_HW_B_ZR36067; |
821 | zr->i2c_adapter.client_register = zoran_i2c_client_register; | 822 | zr->i2c_adapter.client_register = zoran_i2c_client_register; |
822 | zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister; | 823 | zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister; |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index 25de7631443e..db11ab9e60da 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -2996,7 +2996,6 @@ zoran_do_ioctl (struct inode *inode, | |||
2996 | break; | 2996 | break; |
2997 | 2997 | ||
2998 | default: | 2998 | default: |
2999 | dprintk(3, "unsupported\n"); | ||
3000 | dprintk(1, | 2999 | dprintk(1, |
3001 | KERN_ERR | 3000 | KERN_ERR |
3002 | "%s: VIDIOC_S_FMT - unsupported type %d\n", | 3001 | "%s: VIDIOC_S_FMT - unsupported type %d\n", |