aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:38:27 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:27 -0500
commit3acf28095009509c9ca1e283de821b5be9ddede6 (patch)
tree824f31e6942ac09d977103f4a010e0a349b3afa2 /drivers/media/video/em28xx/em28xx-video.c
parente0ec29b7e5aa1f4f1ff73ebd3003336dbe83e174 (diff)
[PATCH] v4l: 886: renamed common structures to em28xx
- Renamed common structures to em28xx Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c601
1 files changed, 301 insertions, 300 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 5ae896a1dcf6..f6acce820791 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -28,6 +28,7 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/video_decoder.h> 30#include <linux/video_decoder.h>
31#include <linux/utsname.h>
31 32
32#include "em28xx.h" 33#include "em28xx.h"
33#include <media/tuner.h> 34#include <media/tuner.h>
@@ -39,9 +40,9 @@
39 40
40#define DRIVER_NAME "em28xx" 41#define DRIVER_NAME "em28xx"
41#define DRIVER_DESC "Empia em28xx based USB video device driver" 42#define DRIVER_DESC "Empia em28xx based USB video device driver"
42#define EM2820_VERSION_CODE KERNEL_VERSION(0, 0, 1) 43#define EM28XX_VERSION_CODE KERNEL_VERSION(0, 0, 1)
43 44
44#define em2820_videodbg(fmt, arg...) do {\ 45#define em28xx_videodbg(fmt, arg...) do {\
45 if (video_debug) \ 46 if (video_debug) \
46 printk(KERN_INFO "%s %s :"fmt, \ 47 printk(KERN_INFO "%s %s :"fmt, \
47 dev->name, __FUNCTION__ , ##arg); } while (0) 48 dev->name, __FUNCTION__ , ##arg); } while (0)
@@ -50,9 +51,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
50MODULE_DESCRIPTION(DRIVER_DESC); 51MODULE_DESCRIPTION(DRIVER_DESC);
51MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
52 53
53static LIST_HEAD(em2820_devlist); 54static LIST_HEAD(em28xx_devlist);
54 55
55static unsigned int card[] = {[0 ... (EM2820_MAXBOARDS - 1)] = UNSET }; 56static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
56 57
57module_param_array(card, int, NULL, 0444); 58module_param_array(card, int, NULL, 0444);
58MODULE_PARM_DESC(card,"card type"); 59MODULE_PARM_DESC(card,"card type");
@@ -66,7 +67,7 @@ module_param(video_debug,int,0644);
66MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 67MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
67 68
68/* supported tv norms */ 69/* supported tv norms */
69static struct em2820_tvnorm tvnorms[] = { 70static struct em28xx_tvnorm tvnorms[] = {
70 { 71 {
71 .name = "PAL", 72 .name = "PAL",
72 .id = V4L2_STD_PAL, 73 .id = V4L2_STD_PAL,
@@ -106,7 +107,7 @@ static const unsigned char saa7114_i2c_init[] = {
106#define TVNORMS ARRAY_SIZE(tvnorms) 107#define TVNORMS ARRAY_SIZE(tvnorms)
107 108
108/* supported controls */ 109/* supported controls */
109static struct v4l2_queryctrl em2820_qctrl[] = { 110static struct v4l2_queryctrl em28xx_qctrl[] = {
110 { 111 {
111 .id = V4L2_CID_BRIGHTNESS, 112 .id = V4L2_CID_BRIGHTNESS,
112 .type = V4L2_CTRL_TYPE_INTEGER, 113 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -182,10 +183,10 @@ static struct v4l2_queryctrl em2820_qctrl[] = {
182 } 183 }
183}; 184};
184 185
185static struct usb_driver em2820_usb_driver; 186static struct usb_driver em28xx_usb_driver;
186 187
187static DECLARE_MUTEX(em2820_sysfs_lock); 188static DECLARE_MUTEX(em28xx_sysfs_lock);
188static DECLARE_RWSEM(em2820_disconnect); 189static DECLARE_RWSEM(em28xx_disconnect);
189 190
190/********************* v4l2 interface ******************************************/ 191/********************* v4l2 interface ******************************************/
191 192
@@ -200,95 +201,95 @@ static inline unsigned long kvirt_to_pa(unsigned long adr)
200} 201}
201 202
202/* 203/*
203 * em2820_config() 204 * em28xx_config()
204 * inits registers with sane defaults 205 * inits registers with sane defaults
205 */ 206 */
206static int em2820_config(struct em2820 *dev) 207static int em28xx_config(struct em28xx *dev)
207{ 208{
208 209
209 /* Sets I2C speed to 100 KHz */ 210 /* Sets I2C speed to 100 KHz */
210 em2820_write_regs_req(dev, 0x00, 0x06, "\x40", 1); 211 em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
211 212
212 /* enable vbi capturing */ 213 /* enable vbi capturing */
213 em2820_audio_usb_mute(dev, 1); 214 em28xx_audio_usb_mute(dev, 1);
214 dev->mute = 1; /* maybe not the right place... */ 215 dev->mute = 1; /* maybe not the right place... */
215 dev->volume = 0x1f; 216 dev->volume = 0x1f;
216 em2820_audio_analog_set(dev); 217 em28xx_audio_analog_set(dev);
217 em2820_audio_analog_setup(dev); 218 em28xx_audio_analog_setup(dev);
218 em2820_outfmt_set_yuv422(dev); 219 em28xx_outfmt_set_yuv422(dev);
219 em2820_colorlevels_set_default(dev); 220 em28xx_colorlevels_set_default(dev);
220 em2820_compression_disable(dev); 221 em28xx_compression_disable(dev);
221 222
222 return 0; 223 return 0;
223} 224}
224 225
225/* 226/*
226 * em2820_config_i2c() 227 * em28xx_config_i2c()
227 * configure i2c attached devices 228 * configure i2c attached devices
228 */ 229 */
229void em2820_config_i2c(struct em2820 *dev) 230void em28xx_config_i2c(struct em28xx *dev)
230{ 231{
231 struct v4l2_frequency f; 232 struct v4l2_frequency f;
232 struct video_decoder_init em2820_vdi = {.data = NULL }; 233 struct video_decoder_init em28xx_vdi = {.data = NULL };
233 234
234 235
235 /* configure decoder */ 236 /* configure decoder */
236 if(dev->model == EM2820_BOARD_MSI_VOX_USB_2){ 237 if(dev->model == EM2820_BOARD_MSI_VOX_USB_2){
237 em2820_vdi.data=saa7114_i2c_init; 238 em28xx_vdi.data=saa7114_i2c_init;
238 em2820_vdi.len=sizeof(saa7114_i2c_init); 239 em28xx_vdi.len=sizeof(saa7114_i2c_init);
239 } 240 }
240 241
241 242
242 em2820_i2c_call_clients(dev, DECODER_INIT, &em2820_vdi); 243 em28xx_i2c_call_clients(dev, DECODER_INIT, &em28xx_vdi);
243 em2820_i2c_call_clients(dev, DECODER_SET_INPUT, &dev->ctl_input); 244 em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &dev->ctl_input);
244/* em2820_i2c_call_clients(dev,DECODER_SET_PICTURE, &dev->vpic); */ 245/* em28xx_i2c_call_clients(dev,DECODER_SET_PICTURE, &dev->vpic); */
245/* em2820_i2c_call_clients(dev,DECODER_SET_NORM,&dev->tvnorm->id); */ 246/* em28xx_i2c_call_clients(dev,DECODER_SET_NORM,&dev->tvnorm->id); */
246/* em2820_i2c_call_clients(dev,DECODER_ENABLE_OUTPUT,&output); */ 247/* em28xx_i2c_call_clients(dev,DECODER_ENABLE_OUTPUT,&output); */
247/* em2820_i2c_call_clients(dev,DECODER_DUMP, NULL); */ 248/* em28xx_i2c_call_clients(dev,DECODER_DUMP, NULL); */
248 249
249 /* configure tuner */ 250 /* configure tuner */
250 f.tuner = 0; 251 f.tuner = 0;
251 f.type = V4L2_TUNER_ANALOG_TV; 252 f.type = V4L2_TUNER_ANALOG_TV;
252 f.frequency = 9076; /* FIXME:remove magic number */ 253 f.frequency = 9076; /* FIXME:remove magic number */
253 dev->ctl_freq = f.frequency; 254 dev->ctl_freq = f.frequency;
254 em2820_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 255 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
255 256
256 /* configure tda9887 */ 257 /* configure tda9887 */
257 258
258 259
259/* em2820_i2c_call_clients(dev,VIDIOC_S_STD,&dev->tvnorm->id); */ 260/* em28xx_i2c_call_clients(dev,VIDIOC_S_STD,&dev->tvnorm->id); */
260} 261}
261 262
262/* 263/*
263 * em2820_empty_framequeues() 264 * em28xx_empty_framequeues()
264 * prepare queues for incoming and outgoing frames 265 * prepare queues for incoming and outgoing frames
265 */ 266 */
266static void em2820_empty_framequeues(struct em2820 *dev) 267static void em28xx_empty_framequeues(struct em28xx *dev)
267{ 268{
268 u32 i; 269 u32 i;
269 270
270 INIT_LIST_HEAD(&dev->inqueue); 271 INIT_LIST_HEAD(&dev->inqueue);
271 INIT_LIST_HEAD(&dev->outqueue); 272 INIT_LIST_HEAD(&dev->outqueue);
272 273
273 for (i = 0; i < EM2820_NUM_FRAMES; i++) { 274 for (i = 0; i < EM28XX_NUM_FRAMES; i++) {
274 dev->frame[i].state = F_UNUSED; 275 dev->frame[i].state = F_UNUSED;
275 dev->frame[i].buf.bytesused = 0; 276 dev->frame[i].buf.bytesused = 0;
276 } 277 }
277} 278}
278 279
279/* 280/*
280 * em2820_v4l2_open() 281 * em28xx_v4l2_open()
281 * inits the device and starts isoc transfer 282 * inits the device and starts isoc transfer
282 */ 283 */
283static int em2820_v4l2_open(struct inode *inode, struct file *filp) 284static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
284{ 285{
285 int minor = iminor(inode); 286 int minor = iminor(inode);
286 int errCode = 0; 287 int errCode = 0;
287 struct em2820 *h,*dev = NULL; 288 struct em28xx *h,*dev = NULL;
288 struct list_head *list; 289 struct list_head *list;
289 290
290 list_for_each(list,&em2820_devlist) { 291 list_for_each(list,&em28xx_devlist) {
291 h = list_entry(list, struct em2820, devlist); 292 h = list_entry(list, struct em28xx, devlist);
292 if (h->vdev->minor == minor) { 293 if (h->vdev->minor == minor) {
293 dev = h; 294 dev = h;
294 } 295 }
@@ -297,14 +298,14 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
297 filp->private_data=dev; 298 filp->private_data=dev;
298 299
299 300
300 em2820_videodbg("users=%d", dev->users); 301 em28xx_videodbg("users=%d", dev->users);
301 302
302 if (!down_read_trylock(&em2820_disconnect)) 303 if (!down_read_trylock(&em28xx_disconnect))
303 return -ERESTARTSYS; 304 return -ERESTARTSYS;
304 305
305 if (dev->users) { 306 if (dev->users) {
306 em2820_warn("this driver can be opened only once\n"); 307 em28xx_warn("this driver can be opened only once\n");
307 up_read(&em2820_disconnect); 308 up_read(&em28xx_disconnect);
308 return -EBUSY; 309 return -EBUSY;
309 } 310 }
310 311
@@ -322,7 +323,7 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
322 323
323 down(&dev->lock); 324 down(&dev->lock);
324 325
325 em2820_set_alternate(dev); 326 em28xx_set_alternate(dev);
326 327
327 dev->width = norm_maxw(dev); 328 dev->width = norm_maxw(dev);
328 dev->height = norm_maxh(dev); 329 dev->height = norm_maxh(dev);
@@ -332,11 +333,11 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
332 dev->hscale = 0; 333 dev->hscale = 0;
333 dev->vscale = 0; 334 dev->vscale = 0;
334 335
335 em2820_capture_start(dev, 1); 336 em28xx_capture_start(dev, 1);
336 em2820_resolution_set(dev); 337 em28xx_resolution_set(dev);
337 338
338 /* start the transfer */ 339 /* start the transfer */
339 errCode = em2820_init_isoc(dev); 340 errCode = em28xx_init_isoc(dev);
340 if (errCode) 341 if (errCode)
341 goto err; 342 goto err;
342 343
@@ -347,55 +348,55 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
347 dev->num_frames = 0; 348 dev->num_frames = 0;
348 349
349 /* prepare queues */ 350 /* prepare queues */
350 em2820_empty_framequeues(dev); 351 em28xx_empty_framequeues(dev);
351 352
352 dev->state |= DEV_INITIALIZED; 353 dev->state |= DEV_INITIALIZED;
353 354
354 err: 355 err:
355 up(&dev->lock); 356 up(&dev->lock);
356 up_read(&em2820_disconnect); 357 up_read(&em28xx_disconnect);
357 return errCode; 358 return errCode;
358} 359}
359 360
360/* 361/*
361 * em2820_realease_resources() 362 * em28xx_realease_resources()
362 * unregisters the v4l2,i2c and usb devices 363 * unregisters the v4l2,i2c and usb devices
363 * called when the device gets disconected or at module unload 364 * called when the device gets disconected or at module unload
364*/ 365*/
365static void em2820_release_resources(struct em2820 *dev) 366static void em28xx_release_resources(struct em28xx *dev)
366{ 367{
367 down(&em2820_sysfs_lock); 368 down(&em28xx_sysfs_lock);
368 369
369 em2820_info("V4L2 device /dev/video%d deregistered\n", 370 em28xx_info("V4L2 device /dev/video%d deregistered\n",
370 dev->vdev->minor); 371 dev->vdev->minor);
371 list_del(&dev->devlist); 372 list_del(&dev->devlist);
372 video_unregister_device(dev->vdev); 373 video_unregister_device(dev->vdev);
373/* video_unregister_device(dev->vbi_dev); */ 374/* video_unregister_device(dev->vbi_dev); */
374 em2820_i2c_unregister(dev); 375 em28xx_i2c_unregister(dev);
375 usb_put_dev(dev->udev); 376 usb_put_dev(dev->udev);
376 up(&em2820_sysfs_lock); 377 up(&em28xx_sysfs_lock);
377} 378}
378 379
379/* 380/*
380 * em2820_v4l2_close() 381 * em28xx_v4l2_close()
381 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls 382 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls
382 */ 383 */
383static int em2820_v4l2_close(struct inode *inode, struct file *filp) 384static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
384{ 385{
385 int errCode; 386 int errCode;
386 struct em2820 *dev=filp->private_data; 387 struct em28xx *dev=filp->private_data;
387 388
388 em2820_videodbg("users=%d", dev->users); 389 em28xx_videodbg("users=%d", dev->users);
389 390
390 down(&dev->lock); 391 down(&dev->lock);
391 392
392 em2820_uninit_isoc(dev); 393 em28xx_uninit_isoc(dev);
393 394
394 em2820_release_buffers(dev); 395 em28xx_release_buffers(dev);
395 396
396 /* the device is already disconnect, free the remaining resources */ 397 /* the device is already disconnect, free the remaining resources */
397 if (dev->state & DEV_DISCONNECTED) { 398 if (dev->state & DEV_DISCONNECTED) {
398 em2820_release_resources(dev); 399 em28xx_release_resources(dev);
399 up(&dev->lock); 400 up(&dev->lock);
400 kfree(dev); 401 kfree(dev);
401 return 0; 402 return 0;
@@ -403,10 +404,10 @@ static int em2820_v4l2_close(struct inode *inode, struct file *filp)
403 404
404 /* set alternate 0 */ 405 /* set alternate 0 */
405 dev->alt = 0; 406 dev->alt = 0;
406 em2820_videodbg("setting alternate 0"); 407 em28xx_videodbg("setting alternate 0");
407 errCode = usb_set_interface(dev->udev, 0, 0); 408 errCode = usb_set_interface(dev->udev, 0, 0);
408 if (errCode < 0) { 409 if (errCode < 0) {
409 em2820_errdev ("cannot change alternate number to 0 (error=%i)\n", 410 em28xx_errdev ("cannot change alternate number to 0 (error=%i)\n",
410 errCode); 411 errCode);
411 } 412 }
412 413
@@ -417,49 +418,49 @@ static int em2820_v4l2_close(struct inode *inode, struct file *filp)
417} 418}
418 419
419/* 420/*
420 * em2820_v4l2_read() 421 * em28xx_v4l2_read()
421 * will allocate buffers when called for the first time 422 * will allocate buffers when called for the first time
422 */ 423 */
423static ssize_t 424static ssize_t
424em2820_v4l2_read(struct file *filp, char __user * buf, size_t count, 425em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
425 loff_t * f_pos) 426 loff_t * f_pos)
426{ 427{
427 struct em2820_frame_t *f, *i; 428 struct em28xx_frame_t *f, *i;
428 unsigned long lock_flags; 429 unsigned long lock_flags;
429 int ret = 0; 430 int ret = 0;
430 struct em2820 *dev = filp->private_data; 431 struct em28xx *dev = filp->private_data;
431 432
432 if (down_interruptible(&dev->fileop_lock)) 433 if (down_interruptible(&dev->fileop_lock))
433 return -ERESTARTSYS; 434 return -ERESTARTSYS;
434 435
435 if (dev->state & DEV_DISCONNECTED) { 436 if (dev->state & DEV_DISCONNECTED) {
436 em2820_videodbg("device not present"); 437 em28xx_videodbg("device not present");
437 up(&dev->fileop_lock); 438 up(&dev->fileop_lock);
438 return -ENODEV; 439 return -ENODEV;
439 } 440 }
440 441
441 if (dev->state & DEV_MISCONFIGURED) { 442 if (dev->state & DEV_MISCONFIGURED) {
442 em2820_videodbg("device misconfigured; close and open it again"); 443 em28xx_videodbg("device misconfigured; close and open it again");
443 up(&dev->fileop_lock); 444 up(&dev->fileop_lock);
444 return -EIO; 445 return -EIO;
445 } 446 }
446 447
447 if (dev->io == IO_MMAP) { 448 if (dev->io == IO_MMAP) {
448 em2820_videodbg ("IO method is set to mmap; close and open" 449 em28xx_videodbg ("IO method is set to mmap; close and open"
449 " the device again to choose the read method"); 450 " the device again to choose the read method");
450 up(&dev->fileop_lock); 451 up(&dev->fileop_lock);
451 return -EINVAL; 452 return -EINVAL;
452 } 453 }
453 454
454 if (dev->io == IO_NONE) { 455 if (dev->io == IO_NONE) {
455 if (!em2820_request_buffers(dev, EM2820_NUM_READ_FRAMES)) { 456 if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) {
456 em2820_errdev("read failed, not enough memory\n"); 457 em28xx_errdev("read failed, not enough memory\n");
457 up(&dev->fileop_lock); 458 up(&dev->fileop_lock);
458 return -ENOMEM; 459 return -ENOMEM;
459 } 460 }
460 dev->io = IO_READ; 461 dev->io = IO_READ;
461 dev->stream = STREAM_ON; 462 dev->stream = STREAM_ON;
462 em2820_queue_unusedframes(dev); 463 em28xx_queue_unusedframes(dev);
463 } 464 }
464 465
465 if (!count) { 466 if (!count) {
@@ -486,7 +487,7 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
486 } 487 }
487 } 488 }
488 489
489 f = list_entry(dev->outqueue.prev, struct em2820_frame_t, frame); 490 f = list_entry(dev->outqueue.prev, struct em28xx_frame_t, frame);
490 491
491 spin_lock_irqsave(&dev->queue_lock, lock_flags); 492 spin_lock_irqsave(&dev->queue_lock, lock_flags);
492 list_for_each_entry(i, &dev->outqueue, frame) 493 list_for_each_entry(i, &dev->outqueue, frame)
@@ -494,7 +495,7 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
494 INIT_LIST_HEAD(&dev->outqueue); 495 INIT_LIST_HEAD(&dev->outqueue);
495 spin_unlock_irqrestore(&dev->queue_lock, lock_flags); 496 spin_unlock_irqrestore(&dev->queue_lock, lock_flags);
496 497
497 em2820_queue_unusedframes(dev); 498 em28xx_queue_unusedframes(dev);
498 499
499 if (count > f->buf.length) 500 if (count > f->buf.length)
500 count = f->buf.length; 501 count = f->buf.length;
@@ -511,26 +512,26 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
511} 512}
512 513
513/* 514/*
514 * em2820_v4l2_poll() 515 * em28xx_v4l2_poll()
515 * will allocate buffers when called for the first time 516 * will allocate buffers when called for the first time
516 */ 517 */
517static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait) 518static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
518{ 519{
519 unsigned int mask = 0; 520 unsigned int mask = 0;
520 struct em2820 *dev = filp->private_data; 521 struct em28xx *dev = filp->private_data;
521 522
522 if (down_interruptible(&dev->fileop_lock)) 523 if (down_interruptible(&dev->fileop_lock))
523 return POLLERR; 524 return POLLERR;
524 525
525 if (dev->state & DEV_DISCONNECTED) { 526 if (dev->state & DEV_DISCONNECTED) {
526 em2820_videodbg("device not present"); 527 em28xx_videodbg("device not present");
527 } else if (dev->state & DEV_MISCONFIGURED) { 528 } else if (dev->state & DEV_MISCONFIGURED) {
528 em2820_videodbg("device is misconfigured; close and open it again"); 529 em28xx_videodbg("device is misconfigured; close and open it again");
529 } else { 530 } else {
530 if (dev->io == IO_NONE) { 531 if (dev->io == IO_NONE) {
531 if (!em2820_request_buffers 532 if (!em28xx_request_buffers
532 (dev, EM2820_NUM_READ_FRAMES)) { 533 (dev, EM28XX_NUM_READ_FRAMES)) {
533 em2820_warn 534 em28xx_warn
534 ("poll() failed, not enough memory\n"); 535 ("poll() failed, not enough memory\n");
535 } else { 536 } else {
536 dev->io = IO_READ; 537 dev->io = IO_READ;
@@ -539,7 +540,7 @@ static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait)
539 } 540 }
540 541
541 if (dev->io == IO_READ) { 542 if (dev->io == IO_READ) {
542 em2820_queue_unusedframes(dev); 543 em28xx_queue_unusedframes(dev);
543 poll_wait(filp, &dev->wait_frame, wait); 544 poll_wait(filp, &dev->wait_frame, wait);
544 545
545 if (!list_empty(&dev->outqueue)) 546 if (!list_empty(&dev->outqueue))
@@ -556,51 +557,51 @@ static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait)
556} 557}
557 558
558/* 559/*
559 * em2820_vm_open() 560 * em28xx_vm_open()
560 */ 561 */
561static void em2820_vm_open(struct vm_area_struct *vma) 562static void em28xx_vm_open(struct vm_area_struct *vma)
562{ 563{
563 struct em2820_frame_t *f = vma->vm_private_data; 564 struct em28xx_frame_t *f = vma->vm_private_data;
564 f->vma_use_count++; 565 f->vma_use_count++;
565} 566}
566 567
567/* 568/*
568 * em2820_vm_close() 569 * em28xx_vm_close()
569 */ 570 */
570static void em2820_vm_close(struct vm_area_struct *vma) 571static void em28xx_vm_close(struct vm_area_struct *vma)
571{ 572{
572 /* NOTE: buffers are not freed here */ 573 /* NOTE: buffers are not freed here */
573 struct em2820_frame_t *f = vma->vm_private_data; 574 struct em28xx_frame_t *f = vma->vm_private_data;
574 f->vma_use_count--; 575 f->vma_use_count--;
575} 576}
576 577
577static struct vm_operations_struct em2820_vm_ops = { 578static struct vm_operations_struct em28xx_vm_ops = {
578 .open = em2820_vm_open, 579 .open = em28xx_vm_open,
579 .close = em2820_vm_close, 580 .close = em28xx_vm_close,
580}; 581};
581 582
582/* 583/*
583 * em2820_v4l2_mmap() 584 * em28xx_v4l2_mmap()
584 */ 585 */
585static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) 586static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
586{ 587{
587 unsigned long size = vma->vm_end - vma->vm_start, 588 unsigned long size = vma->vm_end - vma->vm_start,
588 start = vma->vm_start, pos, page; 589 start = vma->vm_start, pos, page;
589 u32 i; 590 u32 i;
590 591
591 struct em2820 *dev = filp->private_data; 592 struct em28xx *dev = filp->private_data;
592 593
593 if (down_interruptible(&dev->fileop_lock)) 594 if (down_interruptible(&dev->fileop_lock))
594 return -ERESTARTSYS; 595 return -ERESTARTSYS;
595 596
596 if (dev->state & DEV_DISCONNECTED) { 597 if (dev->state & DEV_DISCONNECTED) {
597 em2820_videodbg("mmap: device not present"); 598 em28xx_videodbg("mmap: device not present");
598 up(&dev->fileop_lock); 599 up(&dev->fileop_lock);
599 return -ENODEV; 600 return -ENODEV;
600 } 601 }
601 602
602 if (dev->state & DEV_MISCONFIGURED) { 603 if (dev->state & DEV_MISCONFIGURED) {
603 em2820_videodbg ("mmap: Device is misconfigured; close and " 604 em28xx_videodbg ("mmap: Device is misconfigured; close and "
604 "open it again"); 605 "open it again");
605 up(&dev->fileop_lock); 606 up(&dev->fileop_lock);
606 return -EIO; 607 return -EIO;
@@ -617,7 +618,7 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
617 break; 618 break;
618 } 619 }
619 if (i == dev->num_frames) { 620 if (i == dev->num_frames) {
620 em2820_videodbg("mmap: user supplied mapping address is out of range"); 621 em28xx_videodbg("mmap: user supplied mapping address is out of range");
621 up(&dev->fileop_lock); 622 up(&dev->fileop_lock);
622 return -EINVAL; 623 return -EINVAL;
623 } 624 }
@@ -631,7 +632,7 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
631 page = vmalloc_to_pfn((void *)pos); 632 page = vmalloc_to_pfn((void *)pos);
632 if (remap_pfn_range(vma, start, page, PAGE_SIZE, 633 if (remap_pfn_range(vma, start, page, PAGE_SIZE,
633 vma->vm_page_prot)) { 634 vma->vm_page_prot)) {
634 em2820_videodbg("mmap: rename page map failed"); 635 em28xx_videodbg("mmap: rename page map failed");
635 up(&dev->fileop_lock); 636 up(&dev->fileop_lock);
636 return -EAGAIN; 637 return -EAGAIN;
637 } 638 }
@@ -640,19 +641,19 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
640 size -= PAGE_SIZE; 641 size -= PAGE_SIZE;
641 } 642 }
642 643
643 vma->vm_ops = &em2820_vm_ops; 644 vma->vm_ops = &em28xx_vm_ops;
644 vma->vm_private_data = &dev->frame[i]; 645 vma->vm_private_data = &dev->frame[i];
645 646
646 em2820_vm_open(vma); 647 em28xx_vm_open(vma);
647 up(&dev->fileop_lock); 648 up(&dev->fileop_lock);
648 return 0; 649 return 0;
649} 650}
650 651
651/* 652/*
652 * em2820_get_ctrl() 653 * em28xx_get_ctrl()
653 * return the current saturation, brightness or contrast, mute state 654 * return the current saturation, brightness or contrast, mute state
654 */ 655 */
655static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl) 656static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
656{ 657{
657 s32 tmp; 658 s32 tmp;
658 switch (ctrl->id) { 659 switch (ctrl->id) {
@@ -663,30 +664,30 @@ static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl)
663 ctrl->value = dev->volume; 664 ctrl->value = dev->volume;
664 return 0; 665 return 0;
665 case V4L2_CID_BRIGHTNESS: 666 case V4L2_CID_BRIGHTNESS:
666 if ((tmp = em2820_brightness_get(dev)) < 0) 667 if ((tmp = em28xx_brightness_get(dev)) < 0)
667 return -EIO; 668 return -EIO;
668 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 669 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
669 return 0; 670 return 0;
670 case V4L2_CID_CONTRAST: 671 case V4L2_CID_CONTRAST:
671 if ((ctrl->value = em2820_contrast_get(dev)) < 0) 672 if ((ctrl->value = em28xx_contrast_get(dev)) < 0)
672 return -EIO; 673 return -EIO;
673 return 0; 674 return 0;
674 case V4L2_CID_SATURATION: 675 case V4L2_CID_SATURATION:
675 if ((ctrl->value = em2820_saturation_get(dev)) < 0) 676 if ((ctrl->value = em28xx_saturation_get(dev)) < 0)
676 return -EIO; 677 return -EIO;
677 return 0; 678 return 0;
678 case V4L2_CID_RED_BALANCE: 679 case V4L2_CID_RED_BALANCE:
679 if ((tmp = em2820_v_balance_get(dev)) < 0) 680 if ((tmp = em28xx_v_balance_get(dev)) < 0)
680 return -EIO; 681 return -EIO;
681 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 682 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
682 return 0; 683 return 0;
683 case V4L2_CID_BLUE_BALANCE: 684 case V4L2_CID_BLUE_BALANCE:
684 if ((tmp = em2820_u_balance_get(dev)) < 0) 685 if ((tmp = em28xx_u_balance_get(dev)) < 0)
685 return -EIO; 686 return -EIO;
686 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 687 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
687 return 0; 688 return 0;
688 case V4L2_CID_GAMMA: 689 case V4L2_CID_GAMMA:
689 if ((ctrl->value = em2820_gamma_get(dev)) < 0) 690 if ((ctrl->value = em28xx_gamma_get(dev)) < 0)
690 return -EIO; 691 return -EIO;
691 return 0; 692 return 0;
692 default: 693 default:
@@ -695,44 +696,44 @@ static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl)
695} 696}
696 697
697/* 698/*
698 * em2820_set_ctrl() 699 * em28xx_set_ctrl()
699 * mute or set new saturation, brightness or contrast 700 * mute or set new saturation, brightness or contrast
700 */ 701 */
701static int em2820_set_ctrl(struct em2820 *dev, const struct v4l2_control *ctrl) 702static int em28xx_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)
702{ 703{
703 switch (ctrl->id) { 704 switch (ctrl->id) {
704 case V4L2_CID_AUDIO_MUTE: 705 case V4L2_CID_AUDIO_MUTE:
705 if (ctrl->value != dev->mute) { 706 if (ctrl->value != dev->mute) {
706 dev->mute = ctrl->value; 707 dev->mute = ctrl->value;
707 em2820_audio_usb_mute(dev, ctrl->value); 708 em28xx_audio_usb_mute(dev, ctrl->value);
708 return em2820_audio_analog_set(dev); 709 return em28xx_audio_analog_set(dev);
709 } 710 }
710 return 0; 711 return 0;
711 case V4L2_CID_AUDIO_VOLUME: 712 case V4L2_CID_AUDIO_VOLUME:
712 dev->volume = ctrl->value; 713 dev->volume = ctrl->value;
713 return em2820_audio_analog_set(dev); 714 return em28xx_audio_analog_set(dev);
714 case V4L2_CID_BRIGHTNESS: 715 case V4L2_CID_BRIGHTNESS:
715 return em2820_brightness_set(dev, ctrl->value); 716 return em28xx_brightness_set(dev, ctrl->value);
716 case V4L2_CID_CONTRAST: 717 case V4L2_CID_CONTRAST:
717 return em2820_contrast_set(dev, ctrl->value); 718 return em28xx_contrast_set(dev, ctrl->value);
718 case V4L2_CID_SATURATION: 719 case V4L2_CID_SATURATION:
719 return em2820_saturation_set(dev, ctrl->value); 720 return em28xx_saturation_set(dev, ctrl->value);
720 case V4L2_CID_RED_BALANCE: 721 case V4L2_CID_RED_BALANCE:
721 return em2820_v_balance_set(dev, ctrl->value); 722 return em28xx_v_balance_set(dev, ctrl->value);
722 case V4L2_CID_BLUE_BALANCE: 723 case V4L2_CID_BLUE_BALANCE:
723 return em2820_u_balance_set(dev, ctrl->value); 724 return em28xx_u_balance_set(dev, ctrl->value);
724 case V4L2_CID_GAMMA: 725 case V4L2_CID_GAMMA:
725 return em2820_gamma_set(dev, ctrl->value); 726 return em28xx_gamma_set(dev, ctrl->value);
726 default: 727 default:
727 return -EINVAL; 728 return -EINVAL;
728 } 729 }
729} 730}
730 731
731/* 732/*
732 * em2820_stream_interrupt() 733 * em28xx_stream_interrupt()
733 * stops streaming 734 * stops streaming
734 */ 735 */
735static int em2820_stream_interrupt(struct em2820 *dev) 736static int em28xx_stream_interrupt(struct em28xx *dev)
736{ 737{
737 int ret = 0; 738 int ret = 0;
738 739
@@ -742,12 +743,12 @@ static int em2820_stream_interrupt(struct em2820 *dev)
742 ret = wait_event_timeout(dev->wait_stream, 743 ret = wait_event_timeout(dev->wait_stream,
743 (dev->stream == STREAM_OFF) || 744 (dev->stream == STREAM_OFF) ||
744 (dev->state & DEV_DISCONNECTED), 745 (dev->state & DEV_DISCONNECTED),
745 EM2820_URB_TIMEOUT); 746 EM28XX_URB_TIMEOUT);
746 if (dev->state & DEV_DISCONNECTED) 747 if (dev->state & DEV_DISCONNECTED)
747 return -ENODEV; 748 return -ENODEV;
748 else if (ret) { 749 else if (ret) {
749 dev->state |= DEV_MISCONFIGURED; 750 dev->state |= DEV_MISCONFIGURED;
750 em2820_videodbg("device is misconfigured; close and " 751 em28xx_videodbg("device is misconfigured; close and "
751 "open /dev/video%d again", dev->vdev->minor); 752 "open /dev/video%d again", dev->vdev->minor);
752 return ret; 753 return ret;
753 } 754 }
@@ -755,7 +756,7 @@ static int em2820_stream_interrupt(struct em2820 *dev)
755 return 0; 756 return 0;
756} 757}
757 758
758static int em2820_set_norm(struct em2820 *dev, int width, int height) 759static int em28xx_set_norm(struct em28xx *dev, int width, int height)
759{ 760{
760 unsigned int hscale, vscale; 761 unsigned int hscale, vscale;
761 unsigned int maxh, maxw; 762 unsigned int maxh, maxw;
@@ -794,41 +795,41 @@ static int em2820_set_norm(struct em2820 *dev, int width, int height)
794 dev->hscale = hscale; 795 dev->hscale = hscale;
795 dev->vscale = vscale; 796 dev->vscale = vscale;
796 797
797 em2820_resolution_set(dev); 798 em28xx_resolution_set(dev);
798 799
799 return 0; 800 return 0;
800} 801}
801 802
802static void video_mux(struct em2820 *dev, int index) 803static void video_mux(struct em28xx *dev, int index)
803{ 804{
804 int input, ainput; 805 int input, ainput;
805 806
806 input = INPUT(index)->vmux; 807 input = INPUT(index)->vmux;
807 dev->ctl_input = index; 808 dev->ctl_input = index;
808 809
809 em2820_i2c_call_clients(dev, DECODER_SET_INPUT, &input); 810 em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &input);
810 811
811 dev->ctl_ainput = INPUT(index)->amux; 812 dev->ctl_ainput = INPUT(index)->amux;
812 813
813 switch (dev->ctl_ainput) { 814 switch (dev->ctl_ainput) {
814 case 0: 815 case 0:
815 ainput = EM2820_AUDIO_SRC_TUNER; 816 ainput = EM28XX_AUDIO_SRC_TUNER;
816 break; 817 break;
817 default: 818 default:
818 ainput = EM2820_AUDIO_SRC_LINE; 819 ainput = EM28XX_AUDIO_SRC_LINE;
819 } 820 }
820 821
821 em2820_audio_source(dev, ainput); 822 em28xx_audio_source(dev, ainput);
822} 823}
823 824
824/* 825/*
825 * em2820_v4l2_do_ioctl() 826 * em28xx_v4l2_do_ioctl()
826 * This function is _not_ called directly, but from 827 * This function is _not_ called directly, but from
827 * em2820_v4l2_ioctl. Userspace 828 * em28xx_v4l2_ioctl. Userspace
828 * copying is done already, arg is a kernel pointer. 829 * copying is done already, arg is a kernel pointer.
829 */ 830 */
830static int em2820_do_ioctl(struct inode *inode, struct file *filp, 831static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
831 struct em2820 *dev, unsigned int cmd, void *arg, 832 struct em28xx *dev, unsigned int cmd, void *arg,
832 v4l2_kioctl driver_ioctl) 833 v4l2_kioctl driver_ioctl)
833{ 834{
834 int ret; 835 int ret;
@@ -875,7 +876,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
875 down(&dev->lock); 876 down(&dev->lock);
876 dev->tvnorm = &tvnorms[i]; 877 dev->tvnorm = &tvnorms[i];
877 878
878 em2820_set_norm(dev, dev->width, dev->height); 879 em28xx_set_norm(dev, dev->width, dev->height);
879 880
880/* 881/*
881 dev->width=norm_maxw(dev); 882 dev->width=norm_maxw(dev);
@@ -886,18 +887,18 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
886 dev->hscale=0; 887 dev->hscale=0;
887 dev->vscale=0; 888 dev->vscale=0;
888 889
889 em2820_resolution_set(dev); 890 em28xx_resolution_set(dev);
890*/ 891*/
891/* 892/*
892 em2820_uninit_isoc(dev); 893 em28xx_uninit_isoc(dev);
893 em2820_set_alternate(dev); 894 em28xx_set_alternate(dev);
894 em2820_capture_start(dev, 1); 895 em28xx_capture_start(dev, 1);
895 em2820_resolution_set(dev); 896 em28xx_resolution_set(dev);
896 em2820_init_isoc(dev); 897 em28xx_init_isoc(dev);
897*/ 898*/
898 em2820_i2c_call_clients(dev, DECODER_SET_NORM, 899 em28xx_i2c_call_clients(dev, DECODER_SET_NORM,
899 &tvnorms[i].mode); 900 &tvnorms[i].mode);
900 em2820_i2c_call_clients(dev, VIDIOC_S_STD, 901 em28xx_i2c_call_clients(dev, VIDIOC_S_STD,
901 &dev->tvnorm->id); 902 &dev->tvnorm->id);
902 903
903 up(&dev->lock); 904 up(&dev->lock);
@@ -911,19 +912,19 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
911 struct v4l2_input *i = arg; 912 struct v4l2_input *i = arg;
912 unsigned int n; 913 unsigned int n;
913 static const char *iname[] = { 914 static const char *iname[] = {
914 [EM2820_VMUX_COMPOSITE1] = "Composite1", 915 [EM28XX_VMUX_COMPOSITE1] = "Composite1",
915 [EM2820_VMUX_COMPOSITE2] = "Composite2", 916 [EM28XX_VMUX_COMPOSITE2] = "Composite2",
916 [EM2820_VMUX_COMPOSITE3] = "Composite3", 917 [EM28XX_VMUX_COMPOSITE3] = "Composite3",
917 [EM2820_VMUX_COMPOSITE4] = "Composite4", 918 [EM28XX_VMUX_COMPOSITE4] = "Composite4",
918 [EM2820_VMUX_SVIDEO] = "S-Video", 919 [EM28XX_VMUX_SVIDEO] = "S-Video",
919 [EM2820_VMUX_TELEVISION] = "Television", 920 [EM28XX_VMUX_TELEVISION] = "Television",
920 [EM2820_VMUX_CABLE] = "Cable TV", 921 [EM28XX_VMUX_CABLE] = "Cable TV",
921 [EM2820_VMUX_DVB] = "DVB", 922 [EM28XX_VMUX_DVB] = "DVB",
922 [EM2820_VMUX_DEBUG] = "for debug only", 923 [EM28XX_VMUX_DEBUG] = "for debug only",
923 }; 924 };
924 925
925 n = i->index; 926 n = i->index;
926 if (n >= MAX_EM2820_INPUT) 927 if (n >= MAX_EM28XX_INPUT)
927 return -EINVAL; 928 return -EINVAL;
928 if (0 == INPUT(n)->type) 929 if (0 == INPUT(n)->type)
929 return -EINVAL; 930 return -EINVAL;
@@ -931,8 +932,8 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
931 i->index = n; 932 i->index = n;
932 i->type = V4L2_INPUT_TYPE_CAMERA; 933 i->type = V4L2_INPUT_TYPE_CAMERA;
933 strcpy(i->name, iname[INPUT(n)->type]); 934 strcpy(i->name, iname[INPUT(n)->type]);
934 if ((EM2820_VMUX_TELEVISION == INPUT(n)->type) || 935 if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) ||
935 (EM2820_VMUX_CABLE == INPUT(n)->type)) 936 (EM28XX_VMUX_CABLE == INPUT(n)->type))
936 i->type = V4L2_INPUT_TYPE_TUNER; 937 i->type = V4L2_INPUT_TYPE_TUNER;
937 for (n = 0; n < ARRAY_SIZE(tvnorms); n++) 938 for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
938 i->std |= tvnorms[n].id; 939 i->std |= tvnorms[n].id;
@@ -951,7 +952,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
951 { 952 {
952 int *index = arg; 953 int *index = arg;
953 954
954 if (*index >= MAX_EM2820_INPUT) 955 if (*index >= MAX_EM28XX_INPUT)
955 return -EINVAL; 956 return -EINVAL;
956 if (0 == INPUT(*index)->type) 957 if (0 == INPUT(*index)->type)
957 return -EINVAL; 958 return -EINVAL;
@@ -997,10 +998,10 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
997 { 998 {
998 struct v4l2_queryctrl *qc = arg; 999 struct v4l2_queryctrl *qc = arg;
999 u8 i, n; 1000 u8 i, n;
1000 n = sizeof(em2820_qctrl) / sizeof(em2820_qctrl[0]); 1001 n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);
1001 for (i = 0; i < n; i++) 1002 for (i = 0; i < n; i++)
1002 if (qc->id && qc->id == em2820_qctrl[i].id) { 1003 if (qc->id && qc->id == em28xx_qctrl[i].id) {
1003 memcpy(qc, &(em2820_qctrl[i]), 1004 memcpy(qc, &(em28xx_qctrl[i]),
1004 sizeof(*qc)); 1005 sizeof(*qc));
1005 return 0; 1006 return 0;
1006 } 1007 }
@@ -1013,7 +1014,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1013 struct v4l2_control *ctrl = arg; 1014 struct v4l2_control *ctrl = arg;
1014 1015
1015 1016
1016 return em2820_get_ctrl(dev, ctrl); 1017 return em28xx_get_ctrl(dev, ctrl);
1017 } 1018 }
1018 1019
1019 case VIDIOC_S_CTRL_OLD: /* ??? */ 1020 case VIDIOC_S_CTRL_OLD: /* ??? */
@@ -1023,16 +1024,16 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1023 u8 i, n; 1024 u8 i, n;
1024 1025
1025 1026
1026 n = sizeof(em2820_qctrl) / sizeof(em2820_qctrl[0]); 1027 n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);
1027 for (i = 0; i < n; i++) 1028 for (i = 0; i < n; i++)
1028 if (ctrl->id == em2820_qctrl[i].id) { 1029 if (ctrl->id == em28xx_qctrl[i].id) {
1029 if (ctrl->value < 1030 if (ctrl->value <
1030 em2820_qctrl[i].minimum 1031 em28xx_qctrl[i].minimum
1031 || ctrl->value > 1032 || ctrl->value >
1032 em2820_qctrl[i].maximum) 1033 em28xx_qctrl[i].maximum)
1033 return -ERANGE; 1034 return -ERANGE;
1034 1035
1035 return em2820_set_ctrl(dev, ctrl); 1036 return em28xx_set_ctrl(dev, ctrl);
1036 } 1037 }
1037 return -EINVAL; 1038 return -EINVAL;
1038 } 1039 }
@@ -1052,16 +1053,16 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1052 t->capability = V4L2_TUNER_CAP_NORM; 1053 t->capability = V4L2_TUNER_CAP_NORM;
1053 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ 1054 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */
1054/* t->signal = 0xffff;*/ 1055/* t->signal = 0xffff;*/
1055/* em2820_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ 1056/* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/
1056 /* No way to get signal strength? */ 1057 /* No way to get signal strength? */
1057 down(&dev->lock); 1058 down(&dev->lock);
1058 em2820_i2c_call_clients(dev, DECODER_GET_STATUS, 1059 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1059 &status); 1060 &status);
1060 up(&dev->lock); 1061 up(&dev->lock);
1061 t->signal = 1062 t->signal =
1062 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1063 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1063 1064
1064 em2820_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x", t->signal, 1065 em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x", t->signal,
1065 t->afc); 1066 t->afc);
1066 return 0; 1067 return 0;
1067 } 1068 }
@@ -1080,13 +1081,13 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1080/* t->signal = 0xffff; */ 1081/* t->signal = 0xffff; */
1081 /* No way to get signal strength? */ 1082 /* No way to get signal strength? */
1082 down(&dev->lock); 1083 down(&dev->lock);
1083 em2820_i2c_call_clients(dev, DECODER_GET_STATUS, 1084 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1084 &status); 1085 &status);
1085 up(&dev->lock); 1086 up(&dev->lock);
1086 t->signal = 1087 t->signal =
1087 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1088 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1088 1089
1089 em2820_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n", 1090 em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n",
1090 t->signal, t->afc); 1091 t->signal, t->afc);
1091 return 0; 1092 return 0;
1092 } 1093 }
@@ -1112,7 +1113,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1112 1113
1113 down(&dev->lock); 1114 down(&dev->lock);
1114 dev->ctl_freq = f->frequency; 1115 dev->ctl_freq = f->frequency;
1115 em2820_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); 1116 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f);
1116 up(&dev->lock); 1117 up(&dev->lock);
1117 return 0; 1118 return 0;
1118 } 1119 }
@@ -1145,7 +1146,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1145 1146
1146 dev->stream = STREAM_ON; /* FIXME: Start video capture here? */ 1147 dev->stream = STREAM_ON; /* FIXME: Start video capture here? */
1147 1148
1148 em2820_videodbg("VIDIOC_STREAMON: starting stream"); 1149 em28xx_videodbg("VIDIOC_STREAMON: starting stream");
1149 1150
1150 return 0; 1151 return 0;
1151 } 1152 }
@@ -1159,11 +1160,11 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1159 return -EINVAL; 1160 return -EINVAL;
1160 1161
1161 if (dev->stream == STREAM_ON) { 1162 if (dev->stream == STREAM_ON) {
1162 em2820_videodbg ("VIDIOC_STREAMOFF: interrupting stream"); 1163 em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream");
1163 if ((ret = em2820_stream_interrupt(dev))) 1164 if ((ret = em28xx_stream_interrupt(dev)))
1164 return ret; 1165 return ret;
1165 } 1166 }
1166 em2820_empty_framequeues(dev); 1167 em28xx_empty_framequeues(dev);
1167 1168
1168 return 0; 1169 return 0;
1169 } 1170 }
@@ -1175,21 +1176,21 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1175} 1176}
1176 1177
1177/* 1178/*
1178 * em2820_v4l2_do_ioctl() 1179 * em28xx_v4l2_do_ioctl()
1179 * This function is _not_ called directly, but from 1180 * This function is _not_ called directly, but from
1180 * em2820_v4l2_ioctl. Userspace 1181 * em28xx_v4l2_ioctl. Userspace
1181 * copying is done already, arg is a kernel pointer. 1182 * copying is done already, arg is a kernel pointer.
1182 */ 1183 */
1183static int em2820_video_do_ioctl(struct inode *inode, struct file *filp, 1184static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
1184 unsigned int cmd, void *arg) 1185 unsigned int cmd, void *arg)
1185{ 1186{
1186 struct em2820 *dev = filp->private_data; 1187 struct em28xx *dev = filp->private_data;
1187 1188
1188 if (!dev) 1189 if (!dev)
1189 return -ENODEV; 1190 return -ENODEV;
1190 1191
1191 if (video_debug > 1) 1192 if (video_debug > 1)
1192 em2820_print_ioctl(dev->name,cmd); 1193 em28xx_print_ioctl(dev->name,cmd);
1193 1194
1194 switch (cmd) { 1195 switch (cmd) {
1195 1196
@@ -1199,12 +1200,12 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1199 struct v4l2_capability *cap = arg; 1200 struct v4l2_capability *cap = arg;
1200 1201
1201 memset(cap, 0, sizeof(*cap)); 1202 memset(cap, 0, sizeof(*cap));
1202 strlcpy(cap->driver, "em2820", sizeof(cap->driver)); 1203 strlcpy(cap->driver, "em28xx", sizeof(cap->driver));
1203 strlcpy(cap->card, em2820_boards[dev->model].name, 1204 strlcpy(cap->card, em28xx_boards[dev->model].name,
1204 sizeof(cap->card)); 1205 sizeof(cap->card));
1205 strlcpy(cap->bus_info, dev->udev->dev.bus_id, 1206 strlcpy(cap->bus_info, dev->udev->dev.bus_id,
1206 sizeof(cap->bus_info)); 1207 sizeof(cap->bus_info));
1207 cap->version = EM2820_VERSION_CODE; 1208 cap->version = EM28XX_VERSION_CODE;
1208 cap->capabilities = 1209 cap->capabilities =
1209 V4L2_CAP_VIDEO_CAPTURE | 1210 V4L2_CAP_VIDEO_CAPTURE |
1210 V4L2_CAP_AUDIO | 1211 V4L2_CAP_AUDIO |
@@ -1233,7 +1234,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1233 { 1234 {
1234 struct v4l2_format *format = arg; 1235 struct v4l2_format *format = arg;
1235 1236
1236 em2820_videodbg("VIDIOC_G_FMT: type=%s", 1237 em28xx_videodbg("VIDIOC_G_FMT: type=%s",
1237 format->type == 1238 format->type ==
1238 V4L2_BUF_TYPE_VIDEO_CAPTURE ? 1239 V4L2_BUF_TYPE_VIDEO_CAPTURE ?
1239 "V4L2_BUF_TYPE_VIDEO_CAPTURE" : format->type == 1240 "V4L2_BUF_TYPE_VIDEO_CAPTURE" : format->type ==
@@ -1252,7 +1253,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1252 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1253 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1253 format->fmt.pix.field = dev->interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ 1254 format->fmt.pix.field = dev->interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
1254 1255
1255 em2820_videodbg("VIDIOC_G_FMT: %dx%d", dev->width, 1256 em28xx_videodbg("VIDIOC_G_FMT: %dx%d", dev->width,
1256 dev->height); 1257 dev->height);
1257 return 0; 1258 return 0;
1258 } 1259 }
@@ -1273,7 +1274,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1273 1274
1274/* int both_fields; */ 1275/* int both_fields; */
1275 1276
1276 em2820_videodbg("%s: type=%s", 1277 em28xx_videodbg("%s: type=%s",
1277 cmd == 1278 cmd ==
1278 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1279 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1279 "VIDIOC_S_FMT", 1280 "VIDIOC_S_FMT",
@@ -1287,7 +1288,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1287 if (format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1288 if (format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1288 return -EINVAL; 1289 return -EINVAL;
1289 1290
1290 em2820_videodbg("%s: requested %dx%d", 1291 em28xx_videodbg("%s: requested %dx%d",
1291 cmd == 1292 cmd ==
1292 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1293 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1293 "VIDIOC_S_FMT", format->fmt.pix.width, 1294 "VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1346,7 +1347,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1346 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1347 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1347 format->fmt.pix.field = V4L2_FIELD_INTERLACED; 1348 format->fmt.pix.field = V4L2_FIELD_INTERLACED;
1348 1349
1349 em2820_videodbg("%s: returned %dx%d (%d, %d)", 1350 em28xx_videodbg("%s: returned %dx%d (%d, %d)",
1350 cmd == 1351 cmd ==
1351 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1352 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1352 "VIDIOC_S_FMT", format->fmt.pix.width, 1353 "VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1357,19 +1358,19 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1357 1358
1358 for (i = 0; i < dev->num_frames; i++) 1359 for (i = 0; i < dev->num_frames; i++)
1359 if (dev->frame[i].vma_use_count) { 1360 if (dev->frame[i].vma_use_count) {
1360 em2820_videodbg("VIDIOC_S_FMT failed. " 1361 em28xx_videodbg("VIDIOC_S_FMT failed. "
1361 "Unmap the buffers first."); 1362 "Unmap the buffers first.");
1362 return -EINVAL; 1363 return -EINVAL;
1363 } 1364 }
1364 1365
1365 /* stop io in case it is already in progress */ 1366 /* stop io in case it is already in progress */
1366 if (dev->stream == STREAM_ON) { 1367 if (dev->stream == STREAM_ON) {
1367 em2820_videodbg("VIDIOC_SET_FMT: interupting stream"); 1368 em28xx_videodbg("VIDIOC_SET_FMT: interupting stream");
1368 if ((ret = em2820_stream_interrupt(dev))) 1369 if ((ret = em28xx_stream_interrupt(dev)))
1369 return ret; 1370 return ret;
1370 } 1371 }
1371 1372
1372 em2820_release_buffers(dev); 1373 em28xx_release_buffers(dev);
1373 dev->io = IO_NONE; 1374 dev->io = IO_NONE;
1374 1375
1375 /* set new image size */ 1376 /* set new image size */
@@ -1381,11 +1382,11 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1381 dev->hscale = hscale; 1382 dev->hscale = hscale;
1382 dev->vscale = vscale; 1383 dev->vscale = vscale;
1383/* dev->both_fileds = both_fileds; */ 1384/* dev->both_fileds = both_fileds; */
1384 em2820_uninit_isoc(dev); 1385 em28xx_uninit_isoc(dev);
1385 em2820_set_alternate(dev); 1386 em28xx_set_alternate(dev);
1386 em2820_capture_start(dev, 1); 1387 em28xx_capture_start(dev, 1);
1387 em2820_resolution_set(dev); 1388 em28xx_resolution_set(dev);
1388 em2820_init_isoc(dev); 1389 em28xx_init_isoc(dev);
1389 1390
1390 return 0; 1391 return 0;
1391 } 1392 }
@@ -1402,7 +1403,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1402 return -EINVAL; 1403 return -EINVAL;
1403 1404
1404 if (dev->io == IO_READ) { 1405 if (dev->io == IO_READ) {
1405 em2820_videodbg ("method is set to read;" 1406 em28xx_videodbg ("method is set to read;"
1406 " close and open the device again to" 1407 " close and open the device again to"
1407 " choose the mmap I/O method"); 1408 " choose the mmap I/O method");
1408 return -EINVAL; 1409 return -EINVAL;
@@ -1410,26 +1411,26 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1410 1411
1411 for (i = 0; i < dev->num_frames; i++) 1412 for (i = 0; i < dev->num_frames; i++)
1412 if (dev->frame[i].vma_use_count) { 1413 if (dev->frame[i].vma_use_count) {
1413 em2820_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped"); 1414 em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped");
1414 return -EINVAL; 1415 return -EINVAL;
1415 } 1416 }
1416 1417
1417 if (dev->stream == STREAM_ON) { 1418 if (dev->stream == STREAM_ON) {
1418 em2820_videodbg("VIDIOC_REQBUFS: interrupting stream"); 1419 em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream");
1419 if ((ret = em2820_stream_interrupt(dev))) 1420 if ((ret = em28xx_stream_interrupt(dev)))
1420 return ret; 1421 return ret;
1421 } 1422 }
1422 1423
1423 em2820_empty_framequeues(dev); 1424 em28xx_empty_framequeues(dev);
1424 1425
1425 em2820_release_buffers(dev); 1426 em28xx_release_buffers(dev);
1426 if (rb->count) 1427 if (rb->count)
1427 rb->count = 1428 rb->count =
1428 em2820_request_buffers(dev, rb->count); 1429 em28xx_request_buffers(dev, rb->count);
1429 1430
1430 dev->frame_current = NULL; 1431 dev->frame_current = NULL;
1431 1432
1432 em2820_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i", 1433 em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i",
1433 rb->count); 1434 rb->count);
1434 dev->io = rb->count ? IO_MMAP : IO_NONE; 1435 dev->io = rb->count ? IO_MMAP : IO_NONE;
1435 return 0; 1436 return 0;
@@ -1480,7 +1481,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1480 case VIDIOC_DQBUF: 1481 case VIDIOC_DQBUF:
1481 { 1482 {
1482 struct v4l2_buffer *b = arg; 1483 struct v4l2_buffer *b = arg;
1483 struct em2820_frame_t *f; 1484 struct em28xx_frame_t *f;
1484 unsigned long lock_flags; 1485 unsigned long lock_flags;
1485 int ret = 0; 1486 int ret = 0;
1486 1487
@@ -1505,7 +1506,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1505 1506
1506 spin_lock_irqsave(&dev->queue_lock, lock_flags); 1507 spin_lock_irqsave(&dev->queue_lock, lock_flags);
1507 f = list_entry(dev->outqueue.next, 1508 f = list_entry(dev->outqueue.next,
1508 struct em2820_frame_t, frame); 1509 struct em28xx_frame_t, frame);
1509 list_del(dev->outqueue.next); 1510 list_del(dev->outqueue.next);
1510 spin_unlock_irqrestore(&dev->queue_lock, lock_flags); 1511 spin_unlock_irqrestore(&dev->queue_lock, lock_flags);
1511 1512
@@ -1518,66 +1519,66 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1518 return 0; 1519 return 0;
1519 } 1520 }
1520 default: 1521 default:
1521 return em2820_do_ioctl(inode, filp, dev, cmd, arg, 1522 return em28xx_do_ioctl(inode, filp, dev, cmd, arg,
1522 em2820_video_do_ioctl); 1523 em28xx_video_do_ioctl);
1523 } 1524 }
1524 return 0; 1525 return 0;
1525} 1526}
1526 1527
1527/* 1528/*
1528 * em2820_v4l2_ioctl() 1529 * em28xx_v4l2_ioctl()
1529 * handle v4l2 ioctl the main action happens in em2820_v4l2_do_ioctl() 1530 * handle v4l2 ioctl the main action happens in em28xx_v4l2_do_ioctl()
1530 */ 1531 */
1531static int em2820_v4l2_ioctl(struct inode *inode, struct file *filp, 1532static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp,
1532 unsigned int cmd, unsigned long arg) 1533 unsigned int cmd, unsigned long arg)
1533{ 1534{
1534 int ret = 0; 1535 int ret = 0;
1535 struct em2820 *dev = filp->private_data; 1536 struct em28xx *dev = filp->private_data;
1536 1537
1537 if (down_interruptible(&dev->fileop_lock)) 1538 if (down_interruptible(&dev->fileop_lock))
1538 return -ERESTARTSYS; 1539 return -ERESTARTSYS;
1539 1540
1540 if (dev->state & DEV_DISCONNECTED) { 1541 if (dev->state & DEV_DISCONNECTED) {
1541 em2820_errdev("v4l2 ioctl: device not present\n"); 1542 em28xx_errdev("v4l2 ioctl: device not present\n");
1542 up(&dev->fileop_lock); 1543 up(&dev->fileop_lock);
1543 return -ENODEV; 1544 return -ENODEV;
1544 } 1545 }
1545 1546
1546 if (dev->state & DEV_MISCONFIGURED) { 1547 if (dev->state & DEV_MISCONFIGURED) {
1547 em2820_errdev 1548 em28xx_errdev
1548 ("v4l2 ioctl: device is misconfigured; close and open it again\n"); 1549 ("v4l2 ioctl: device is misconfigured; close and open it again\n");
1549 up(&dev->fileop_lock); 1550 up(&dev->fileop_lock);
1550 return -EIO; 1551 return -EIO;
1551 } 1552 }
1552 1553
1553 ret = video_usercopy(inode, filp, cmd, arg, em2820_video_do_ioctl); 1554 ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl);
1554 1555
1555 up(&dev->fileop_lock); 1556 up(&dev->fileop_lock);
1556 1557
1557 return ret; 1558 return ret;
1558} 1559}
1559 1560
1560static struct file_operations em2820_v4l_fops = { 1561static struct file_operations em28xx_v4l_fops = {
1561 .owner = THIS_MODULE, 1562 .owner = THIS_MODULE,
1562 .open = em2820_v4l2_open, 1563 .open = em28xx_v4l2_open,
1563 .release = em2820_v4l2_close, 1564 .release = em28xx_v4l2_close,
1564 .ioctl = em2820_v4l2_ioctl, 1565 .ioctl = em28xx_v4l2_ioctl,
1565 .read = em2820_v4l2_read, 1566 .read = em28xx_v4l2_read,
1566 .poll = em2820_v4l2_poll, 1567 .poll = em28xx_v4l2_poll,
1567 .mmap = em2820_v4l2_mmap, 1568 .mmap = em28xx_v4l2_mmap,
1568 .llseek = no_llseek, 1569 .llseek = no_llseek,
1569}; 1570};
1570 1571
1571/******************************** usb interface *****************************************/ 1572/******************************** usb interface *****************************************/
1572 1573
1573/* 1574/*
1574 * em2820_init_dev() 1575 * em28xx_init_dev()
1575 * allocates and inits the device structs, registers i2c bus and v4l device 1576 * allocates and inits the device structs, registers i2c bus and v4l device
1576 */ 1577 */
1577static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, 1578static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1578 int minor, int model) 1579 int minor, int model)
1579{ 1580{
1580 struct em2820 *dev = *devhandle; 1581 struct em28xx *dev = *devhandle;
1581 int retval = -ENOMEM; 1582 int retval = -ENOMEM;
1582 int errCode, i; 1583 int errCode, i;
1583 unsigned int maxh, maxw; 1584 unsigned int maxh, maxw;
@@ -1588,33 +1589,33 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1588 init_MUTEX(&dev->lock); 1589 init_MUTEX(&dev->lock);
1589 init_waitqueue_head(&dev->open); 1590 init_waitqueue_head(&dev->open);
1590 1591
1591 dev->em2820_write_regs = em2820_write_regs; 1592 dev->em28xx_write_regs = em28xx_write_regs;
1592 dev->em2820_read_reg = em2820_read_reg; 1593 dev->em28xx_read_reg = em28xx_read_reg;
1593 dev->em2820_read_reg_req_len = em2820_read_reg_req_len; 1594 dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
1594 dev->em2820_write_regs_req = em2820_write_regs_req; 1595 dev->em28xx_write_regs_req = em28xx_write_regs_req;
1595 dev->em2820_read_reg_req = em2820_read_reg_req; 1596 dev->em28xx_read_reg_req = em28xx_read_reg_req;
1596 dev->is_em2800 = em2820_boards[model].is_em2800; 1597 dev->is_em2800 = em28xx_boards[model].is_em2800;
1597 dev->has_tuner = em2820_boards[model].has_tuner; 1598 dev->has_tuner = em28xx_boards[model].has_tuner;
1598 dev->has_msp34xx = em2820_boards[model].has_msp34xx; 1599 dev->has_msp34xx = em28xx_boards[model].has_msp34xx;
1599 dev->tda9887_conf = em2820_boards[model].tda9887_conf; 1600 dev->tda9887_conf = em28xx_boards[model].tda9887_conf;
1600 dev->decoder = em2820_boards[model].decoder; 1601 dev->decoder = em28xx_boards[model].decoder;
1601 1602
1602 if (tuner >= 0) 1603 if (tuner >= 0)
1603 dev->tuner_type = tuner; 1604 dev->tuner_type = tuner;
1604 else 1605 else
1605 dev->tuner_type = em2820_boards[model].tuner_type; 1606 dev->tuner_type = em28xx_boards[model].tuner_type;
1606 1607
1607 dev->video_inputs = em2820_boards[model].vchannels; 1608 dev->video_inputs = em28xx_boards[model].vchannels;
1608 1609
1609 for (i = 0; i < TVNORMS; i++) 1610 for (i = 0; i < TVNORMS; i++)
1610 if (em2820_boards[model].norm == tvnorms[i].mode) 1611 if (em28xx_boards[model].norm == tvnorms[i].mode)
1611 break; 1612 break;
1612 if (i == TVNORMS) 1613 if (i == TVNORMS)
1613 i = 0; 1614 i = 0;
1614 1615
1615 dev->tvnorm = &tvnorms[i]; /* set default norm */ 1616 dev->tvnorm = &tvnorms[i]; /* set default norm */
1616 1617
1617 em2820_videodbg("tvnorm=%s\n", dev->tvnorm->name); 1618 em28xx_videodbg("tvnorm=%s\n", dev->tvnorm->name);
1618 1619
1619 maxw = norm_maxw(dev); 1620 maxw = norm_maxw(dev);
1620 maxh = norm_maxh(dev); 1621 maxh = norm_maxh(dev);
@@ -1622,7 +1623,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1622 /* set default image size */ 1623 /* set default image size */
1623 dev->width = maxw; 1624 dev->width = maxw;
1624 dev->height = maxh; 1625 dev->height = maxh;
1625 dev->interlaced = EM2820_INTERLACED_DEFAULT; 1626 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
1626 dev->field_size = dev->width * dev->height; 1627 dev->field_size = dev->width * dev->height;
1627 dev->frame_size = 1628 dev->frame_size =
1628 dev->interlaced ? dev->field_size << 1 : dev->field_size; 1629 dev->interlaced ? dev->field_size << 1 : dev->field_size;
@@ -1644,7 +1645,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1644 /* compute alternate max packet sizes */ 1645 /* compute alternate max packet sizes */
1645 uif = dev->udev->actconfig->interface[0]; 1646 uif = dev->udev->actconfig->interface[0];
1646 dev->alt_max_pkt_size[0] = 0; 1647 dev->alt_max_pkt_size[0] = 0;
1647 for (i = 1; i <= EM2820_MAX_ALT && i < uif->num_altsetting ; i++) { 1648 for (i = 1; i <= EM28XX_MAX_ALT && i < uif->num_altsetting ; i++) {
1648 u16 tmp = 1649 u16 tmp =
1649 le16_to_cpu(uif->altsetting[i].endpoint[1].desc. 1650 le16_to_cpu(uif->altsetting[i].endpoint[1].desc.
1650 wMaxPacketSize); 1651 wMaxPacketSize);
@@ -1654,35 +1655,35 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1654 1655
1655#ifdef CONFIG_MODULES 1656#ifdef CONFIG_MODULES
1656 /* request some modules */ 1657 /* request some modules */
1657 if (dev->decoder == EM2820_SAA7113 || dev->decoder == EM2820_SAA7114) 1658 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
1658 request_module("saa711x"); 1659 request_module("saa711x");
1659 if (dev->decoder == EM2820_TVP5150) 1660 if (dev->decoder == EM28XX_TVP5150)
1660 request_module("tvp5150"); 1661 request_module("tvp5150");
1661 if (dev->has_tuner) 1662 if (dev->has_tuner)
1662 request_module("tuner"); 1663 request_module("tuner");
1663 if (dev->tda9887_conf) 1664 if (dev->tda9887_conf)
1664 request_module("tda9887"); 1665 request_module("tda9887");
1665#endif 1666#endif
1666 errCode = em2820_config(dev); 1667 errCode = em28xx_config(dev);
1667 if (errCode) { 1668 if (errCode) {
1668 em2820_errdev("error configuring device\n"); 1669 em28xx_errdev("error configuring device\n");
1669 kfree(dev); 1670 kfree(dev);
1670 return -ENOMEM; 1671 return -ENOMEM;
1671 } 1672 }
1672 1673
1673 down(&dev->lock); 1674 down(&dev->lock);
1674 /* register i2c bus */ 1675 /* register i2c bus */
1675 em2820_i2c_register(dev); 1676 em28xx_i2c_register(dev);
1676 1677
1677 /* Do board specific init and eeprom reading */ 1678 /* Do board specific init and eeprom reading */
1678 em2820_card_setup(dev); 1679 em28xx_card_setup(dev);
1679 1680
1680 /* configure the device */ 1681 /* configure the device */
1681 em2820_config_i2c(dev); 1682 em28xx_config_i2c(dev);
1682 1683
1683 up(&dev->lock); 1684 up(&dev->lock);
1684 1685
1685 errCode = em2820_config(dev); 1686 errCode = em28xx_config(dev);
1686 1687
1687#ifdef CONFIG_MODULES 1688#ifdef CONFIG_MODULES
1688 if (dev->has_msp34xx) 1689 if (dev->has_msp34xx)
@@ -1691,7 +1692,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1691 /* allocate and fill v4l2 device struct */ 1692 /* allocate and fill v4l2 device struct */
1692 dev->vdev = video_device_alloc(); 1693 dev->vdev = video_device_alloc();
1693 if (NULL == dev->vdev) { 1694 if (NULL == dev->vdev) {
1694 em2820_errdev("cannot allocate video_device.\n"); 1695 em28xx_errdev("cannot allocate video_device.\n");
1695 kfree(dev); 1696 kfree(dev);
1696 return -ENOMEM; 1697 return -ENOMEM;
1697 } 1698 }
@@ -1700,18 +1701,18 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1700 if (dev->has_tuner) 1701 if (dev->has_tuner)
1701 dev->vdev->type |= VID_TYPE_TUNER; 1702 dev->vdev->type |= VID_TYPE_TUNER;
1702 dev->vdev->hardware = 0; 1703 dev->vdev->hardware = 0;
1703 dev->vdev->fops = &em2820_v4l_fops; 1704 dev->vdev->fops = &em28xx_v4l_fops;
1704 dev->vdev->minor = -1; 1705 dev->vdev->minor = -1;
1705 dev->vdev->dev = &dev->udev->dev; 1706 dev->vdev->dev = &dev->udev->dev;
1706 dev->vdev->release = video_device_release; 1707 dev->vdev->release = video_device_release;
1707 snprintf(dev->vdev->name, sizeof(dev->vdev->name), "%s", 1708 snprintf(dev->vdev->name, sizeof(dev->vdev->name), "%s",
1708 "em2820 video"); 1709 "em28xx video");
1709 list_add_tail(&dev->devlist,&em2820_devlist); 1710 list_add_tail(&dev->devlist,&em28xx_devlist);
1710 1711
1711 /* register v4l2 device */ 1712 /* register v4l2 device */
1712 down(&dev->lock); 1713 down(&dev->lock);
1713 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1))) { 1714 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1))) {
1714 em2820_errdev("unable to register video device (error=%i).\n", 1715 em28xx_errdev("unable to register video device (error=%i).\n",
1715 retval); 1716 retval);
1716 up(&dev->lock); 1717 up(&dev->lock);
1717 list_del(&dev->devlist); 1718 list_del(&dev->devlist);
@@ -1721,9 +1722,9 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1721 } 1722 }
1722 if (dev->has_msp34xx) { 1723 if (dev->has_msp34xx) {
1723 /* Send a reset to other chips via gpio */ 1724 /* Send a reset to other chips via gpio */
1724 em2820_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); 1725 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
1725 udelay(2500); 1726 udelay(2500);
1726 em2820_write_regs_req(dev, 0x00, 0x08, "\xff", 1); 1727 em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
1727 udelay(2500); 1728 udelay(2500);
1728 1729
1729 } 1730 }
@@ -1731,22 +1732,22 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1731 1732
1732 up(&dev->lock); 1733 up(&dev->lock);
1733 1734
1734 em2820_info("V4L2 device registered as /dev/video%d\n", 1735 em28xx_info("V4L2 device registered as /dev/video%d\n",
1735 dev->vdev->minor); 1736 dev->vdev->minor);
1736 1737
1737 return 0; 1738 return 0;
1738} 1739}
1739 1740
1740/* 1741/*
1741 * em2820_usb_probe() 1742 * em28xx_usb_probe()
1742 * checks for supported devices 1743 * checks for supported devices
1743 */ 1744 */
1744static int em2820_usb_probe(struct usb_interface *interface, 1745static int em28xx_usb_probe(struct usb_interface *interface,
1745 const struct usb_device_id *id) 1746 const struct usb_device_id *id)
1746{ 1747{
1747 const struct usb_endpoint_descriptor *endpoint; 1748 const struct usb_endpoint_descriptor *endpoint;
1748 struct usb_device *udev; 1749 struct usb_device *udev;
1749 struct em2820 *dev = NULL; 1750 struct em28xx *dev = NULL;
1750 int retval = -ENODEV; 1751 int retval = -ENODEV;
1751 int model,i,nr,ifnum; 1752 int model,i,nr,ifnum;
1752 1753
@@ -1756,14 +1757,14 @@ static int em2820_usb_probe(struct usb_interface *interface,
1756 1757
1757 /* Don't register audio interfaces */ 1758 /* Don't register audio interfaces */
1758 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 1759 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
1759 em2820_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", 1760 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n",
1760 udev->descriptor.idVendor,udev->descriptor.idProduct, 1761 udev->descriptor.idVendor,udev->descriptor.idProduct,
1761 ifnum, 1762 ifnum,
1762 interface->altsetting[0].desc.bInterfaceClass); 1763 interface->altsetting[0].desc.bInterfaceClass);
1763 return -ENODEV; 1764 return -ENODEV;
1764 } 1765 }
1765 1766
1766 em2820_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", 1767 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n",
1767 udev->descriptor.idVendor,udev->descriptor.idProduct, 1768 udev->descriptor.idVendor,udev->descriptor.idProduct,
1768 ifnum, 1769 ifnum,
1769 interface->altsetting[0].desc.bInterfaceClass); 1770 interface->altsetting[0].desc.bInterfaceClass);
@@ -1773,33 +1774,33 @@ static int em2820_usb_probe(struct usb_interface *interface,
1773 /* check if the the device has the iso in endpoint at the correct place */ 1774 /* check if the the device has the iso in endpoint at the correct place */
1774 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 1775 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
1775 USB_ENDPOINT_XFER_ISOC) { 1776 USB_ENDPOINT_XFER_ISOC) {
1776 em2820_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); 1777 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n");
1777 return -ENODEV; 1778 return -ENODEV;
1778 } 1779 }
1779 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 1780 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
1780 em2820_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); 1781 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n");
1781 return -ENODEV; 1782 return -ENODEV;
1782 } 1783 }
1783 1784
1784 model=id->driver_info; 1785 model=id->driver_info;
1785 nr=interface->minor; 1786 nr=interface->minor;
1786 1787
1787 if (nr>EM2820_MAXBOARDS) { 1788 if (nr>EM28XX_MAXBOARDS) {
1788 printk ("em2820: Supports only %i em28xx boards.\n",EM2820_MAXBOARDS); 1789 printk ("em28xx: Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS);
1789 return -ENOMEM; 1790 return -ENOMEM;
1790 } 1791 }
1791 1792
1792 /* allocate memory for our device state and initialize it */ 1793 /* allocate memory for our device state and initialize it */
1793 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 1794 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
1794 if (dev == NULL) { 1795 if (dev == NULL) {
1795 em2820_err(DRIVER_NAME ": out of memory!\n"); 1796 em28xx_err(DRIVER_NAME ": out of memory!\n");
1796 return -ENOMEM; 1797 return -ENOMEM;
1797 } 1798 }
1798 memset(dev, 0, sizeof(*dev)); 1799 memset(dev, 0, sizeof(*dev));
1799 1800
1800 snprintf(dev->name, 29, "em2820 #%d", nr); 1801 snprintf(dev->name, 29, "em28xx #%d", nr);
1801 1802
1802 if ((card[nr]>=0)&&(card[nr]<em2820_bcount)) 1803 if ((card[nr]>=0)&&(card[nr]<em28xx_bcount))
1803 model=card[nr]; 1804 model=card[nr];
1804 1805
1805 if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) { 1806 if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) {
@@ -1811,18 +1812,18 @@ static int em2820_usb_probe(struct usb_interface *interface,
1811 dev->name,dev->name,dev->name,dev->name,dev->name); 1812 dev->name,dev->name,dev->name,dev->name,dev->name);
1812 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", 1813 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
1813 dev->name); 1814 dev->name);
1814 for (i = 0; i < em2820_bcount; i++) { 1815 for (i = 0; i < em28xx_bcount; i++) {
1815 printk("%s: card=%d -> %s\n", 1816 printk("%s: card=%d -> %s\n",
1816 dev->name, i, em2820_boards[i].name); 1817 dev->name, i, em28xx_boards[i].name);
1817 } 1818 }
1818 } 1819 }
1819 1820
1820 /* allocate device struct */ 1821 /* allocate device struct */
1821 retval = em2820_init_dev(&dev, udev, nr, model); 1822 retval = em28xx_init_dev(&dev, udev, nr, model);
1822 if (retval) 1823 if (retval)
1823 return retval; 1824 return retval;
1824 1825
1825 em2820_info("Found %s\n", em2820_boards[model].name); 1826 em28xx_info("Found %s\n", em28xx_boards[model].name);
1826 1827
1827 /* save our data pointer in this interface device */ 1828 /* save our data pointer in this interface device */
1828 usb_set_intfdata(interface, dev); 1829 usb_set_intfdata(interface, dev);
@@ -1830,38 +1831,38 @@ static int em2820_usb_probe(struct usb_interface *interface,
1830} 1831}
1831 1832
1832/* 1833/*
1833 * em2820_usb_disconnect() 1834 * em28xx_usb_disconnect()
1834 * called when the device gets diconencted 1835 * called when the device gets diconencted
1835 * video device will be unregistered on v4l2_close in case it is still open 1836 * video device will be unregistered on v4l2_close in case it is still open
1836 */ 1837 */
1837static void em2820_usb_disconnect(struct usb_interface *interface) 1838static void em28xx_usb_disconnect(struct usb_interface *interface)
1838{ 1839{
1839 struct em2820 *dev = usb_get_intfdata(interface); 1840 struct em28xx *dev = usb_get_intfdata(interface);
1840 usb_set_intfdata(interface, NULL); 1841 usb_set_intfdata(interface, NULL);
1841 1842
1842 if (!dev) 1843 if (!dev)
1843 return; 1844 return;
1844 1845
1845 down_write(&em2820_disconnect); 1846 down_write(&em28xx_disconnect);
1846 1847
1847 down(&dev->lock); 1848 down(&dev->lock);
1848 1849
1849 em2820_info("disconnecting %s\n", dev->vdev->name); 1850 em28xx_info("disconnecting %s\n", dev->vdev->name);
1850 1851
1851 wake_up_interruptible_all(&dev->open); 1852 wake_up_interruptible_all(&dev->open);
1852 1853
1853 if (dev->users) { 1854 if (dev->users) {
1854 em2820_warn 1855 em28xx_warn
1855 ("device /dev/video%d is open! Deregistration and memory " 1856 ("device /dev/video%d is open! Deregistration and memory "
1856 "deallocation are deferred on close.\n", dev->vdev->minor); 1857 "deallocation are deferred on close.\n", dev->vdev->minor);
1857 dev->state |= DEV_MISCONFIGURED; 1858 dev->state |= DEV_MISCONFIGURED;
1858 em2820_uninit_isoc(dev); 1859 em28xx_uninit_isoc(dev);
1859 dev->state |= DEV_DISCONNECTED; 1860 dev->state |= DEV_DISCONNECTED;
1860 wake_up_interruptible(&dev->wait_frame); 1861 wake_up_interruptible(&dev->wait_frame);
1861 wake_up_interruptible(&dev->wait_stream); 1862 wake_up_interruptible(&dev->wait_stream);
1862 } else { 1863 } else {
1863 dev->state |= DEV_DISCONNECTED; 1864 dev->state |= DEV_DISCONNECTED;
1864 em2820_release_resources(dev); 1865 em28xx_release_resources(dev);
1865 } 1866 }
1866 1867
1867 up(&dev->lock); 1868 up(&dev->lock);
@@ -1869,44 +1870,44 @@ static void em2820_usb_disconnect(struct usb_interface *interface)
1869 if (!dev->users) 1870 if (!dev->users)
1870 kfree(dev); 1871 kfree(dev);
1871 1872
1872 up_write(&em2820_disconnect); 1873 up_write(&em28xx_disconnect);
1873 1874
1874} 1875}
1875 1876
1876static struct usb_driver em2820_usb_driver = { 1877static struct usb_driver em28xx_usb_driver = {
1877 .owner = THIS_MODULE, 1878 .owner = THIS_MODULE,
1878 .name = "em2820", 1879 .name = "em28xx",
1879 .probe = em2820_usb_probe, 1880 .probe = em28xx_usb_probe,
1880 .disconnect = em2820_usb_disconnect, 1881 .disconnect = em28xx_usb_disconnect,
1881 .id_table = em2820_id_table, 1882 .id_table = em28xx_id_table,
1882}; 1883};
1883 1884
1884static int __init em2820_module_init(void) 1885static int __init em28xx_module_init(void)
1885{ 1886{
1886 int result; 1887 int result;
1887 1888
1888 printk(KERN_INFO DRIVER_NAME " v4l2 driver version %d.%d.%d loaded\n", 1889 printk(KERN_INFO DRIVER_NAME " v4l2 driver version %d.%d.%d loaded\n",
1889 (EM2820_VERSION_CODE >> 16) & 0xff, 1890 (EM28XX_VERSION_CODE >> 16) & 0xff,
1890 (EM2820_VERSION_CODE >> 8) & 0xff, EM2820_VERSION_CODE & 0xff); 1891 (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff);
1891#ifdef SNAPSHOT 1892#ifdef SNAPSHOT
1892 printk(KERN_INFO DRIVER_NAME " snapshot date %04d-%02d-%02d\n", 1893 printk(KERN_INFO DRIVER_NAME " snapshot date %04d-%02d-%02d\n",
1893 SNAPSHOT / 10000, (SNAPSHOT / 100) % 100, SNAPSHOT % 100); 1894 SNAPSHOT / 10000, (SNAPSHOT / 100) % 100, SNAPSHOT % 100);
1894#endif 1895#endif
1895 1896
1896 /* register this driver with the USB subsystem */ 1897 /* register this driver with the USB subsystem */
1897 result = usb_register(&em2820_usb_driver); 1898 result = usb_register(&em28xx_usb_driver);
1898 if (result) 1899 if (result)
1899 em2820_err(DRIVER_NAME 1900 em28xx_err(DRIVER_NAME
1900 " usb_register failed. Error number %d.\n", result); 1901 " usb_register failed. Error number %d.\n", result);
1901 1902
1902 return result; 1903 return result;
1903} 1904}
1904 1905
1905static void __exit em2820_module_exit(void) 1906static void __exit em28xx_module_exit(void)
1906{ 1907{
1907 /* deregister this driver with the USB subsystem */ 1908 /* deregister this driver with the USB subsystem */
1908 usb_deregister(&em2820_usb_driver); 1909 usb_deregister(&em28xx_usb_driver);
1909} 1910}
1910 1911
1911module_init(em2820_module_init); 1912module_init(em28xx_module_init);
1912module_exit(em2820_module_exit); 1913module_exit(em28xx_module_exit);