aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx231xx/cx231xx-vbi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-vbi.c')
-rw-r--r--drivers/media/video/cx231xx/cx231xx-vbi.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c
index 689c5e25776c..d2147cadbfce 100644
--- a/drivers/media/video/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/video/cx231xx/cx231xx-vbi.c
@@ -102,7 +102,7 @@ static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb)
102 return 0; 102 return 0;
103 } 103 }
104 104
105 buf = dev->vbi_mode.isoc_ctl.buf; 105 buf = dev->vbi_mode.bulk_ctl.buf;
106 106
107 /* get buffer pointer and length */ 107 /* get buffer pointer and length */
108 p_buffer = urb->transfer_buffer; 108 p_buffer = urb->transfer_buffer;
@@ -209,8 +209,8 @@ static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
209 VIDEOBUF_ACTIVE, it won't be, though. 209 VIDEOBUF_ACTIVE, it won't be, though.
210 */ 210 */
211 spin_lock_irqsave(&dev->vbi_mode.slock, flags); 211 spin_lock_irqsave(&dev->vbi_mode.slock, flags);
212 if (dev->vbi_mode.isoc_ctl.buf == buf) 212 if (dev->vbi_mode.bulk_ctl.buf == buf)
213 dev->vbi_mode.isoc_ctl.buf = NULL; 213 dev->vbi_mode.bulk_ctl.buf = NULL;
214 spin_unlock_irqrestore(&dev->vbi_mode.slock, flags); 214 spin_unlock_irqrestore(&dev->vbi_mode.slock, flags);
215 215
216 videobuf_vmalloc_free(&buf->vb); 216 videobuf_vmalloc_free(&buf->vb);
@@ -246,7 +246,7 @@ vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
246 goto fail; 246 goto fail;
247 } 247 }
248 248
249 if (!dev->vbi_mode.isoc_ctl.num_bufs) 249 if (!dev->vbi_mode.bulk_ctl.num_bufs)
250 urb_init = 1; 250 urb_init = 1;
251 251
252 if (urb_init) { 252 if (urb_init) {
@@ -328,7 +328,7 @@ static void cx231xx_irq_vbi_callback(struct urb *urb)
328 328
329 /* Copy data from URB */ 329 /* Copy data from URB */
330 spin_lock(&dev->vbi_mode.slock); 330 spin_lock(&dev->vbi_mode.slock);
331 rc = dev->vbi_mode.isoc_ctl.isoc_copy(dev, urb); 331 rc = dev->vbi_mode.bulk_ctl.bulk_copy(dev, urb);
332 spin_unlock(&dev->vbi_mode.slock); 332 spin_unlock(&dev->vbi_mode.slock);
333 333
334 /* Reset status */ 334 /* Reset status */
@@ -351,34 +351,34 @@ void cx231xx_uninit_vbi_isoc(struct cx231xx *dev)
351 351
352 cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n"); 352 cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n");
353 353
354 dev->vbi_mode.isoc_ctl.nfields = -1; 354 dev->vbi_mode.bulk_ctl.nfields = -1;
355 for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { 355 for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
356 urb = dev->vbi_mode.isoc_ctl.urb[i]; 356 urb = dev->vbi_mode.bulk_ctl.urb[i];
357 if (urb) { 357 if (urb) {
358 if (!irqs_disabled()) 358 if (!irqs_disabled())
359 usb_kill_urb(urb); 359 usb_kill_urb(urb);
360 else 360 else
361 usb_unlink_urb(urb); 361 usb_unlink_urb(urb);
362 362
363 if (dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { 363 if (dev->vbi_mode.bulk_ctl.transfer_buffer[i]) {
364 364
365 kfree(dev->vbi_mode.isoc_ctl. 365 kfree(dev->vbi_mode.bulk_ctl.
366 transfer_buffer[i]); 366 transfer_buffer[i]);
367 dev->vbi_mode.isoc_ctl.transfer_buffer[i] = 367 dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
368 NULL; 368 NULL;
369 } 369 }
370 usb_free_urb(urb); 370 usb_free_urb(urb);
371 dev->vbi_mode.isoc_ctl.urb[i] = NULL; 371 dev->vbi_mode.bulk_ctl.urb[i] = NULL;
372 } 372 }
373 dev->vbi_mode.isoc_ctl.transfer_buffer[i] = NULL; 373 dev->vbi_mode.bulk_ctl.transfer_buffer[i] = NULL;
374 } 374 }
375 375
376 kfree(dev->vbi_mode.isoc_ctl.urb); 376 kfree(dev->vbi_mode.bulk_ctl.urb);
377 kfree(dev->vbi_mode.isoc_ctl.transfer_buffer); 377 kfree(dev->vbi_mode.bulk_ctl.transfer_buffer);
378 378
379 dev->vbi_mode.isoc_ctl.urb = NULL; 379 dev->vbi_mode.bulk_ctl.urb = NULL;
380 dev->vbi_mode.isoc_ctl.transfer_buffer = NULL; 380 dev->vbi_mode.bulk_ctl.transfer_buffer = NULL;
381 dev->vbi_mode.isoc_ctl.num_bufs = 0; 381 dev->vbi_mode.bulk_ctl.num_bufs = 0;
382 382
383 cx231xx_capture_start(dev, 0, Vbi); 383 cx231xx_capture_start(dev, 0, Vbi);
384} 384}
@@ -389,7 +389,7 @@ EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc);
389 */ 389 */
390int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, 390int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
391 int num_bufs, int max_pkt_size, 391 int num_bufs, int max_pkt_size,
392 int (*isoc_copy) (struct cx231xx *dev, 392 int (*bulk_copy) (struct cx231xx *dev,
393 struct urb *urb)) 393 struct urb *urb))
394{ 394{
395 struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq; 395 struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq;
@@ -408,8 +408,8 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
408 usb_rcvbulkpipe(dev->udev, 408 usb_rcvbulkpipe(dev->udev,
409 dev->vbi_mode.end_point_addr)); 409 dev->vbi_mode.end_point_addr));
410 410
411 dev->vbi_mode.isoc_ctl.isoc_copy = isoc_copy; 411 dev->vbi_mode.bulk_ctl.bulk_copy = bulk_copy;
412 dev->vbi_mode.isoc_ctl.num_bufs = num_bufs; 412 dev->vbi_mode.bulk_ctl.num_bufs = num_bufs;
413 dma_q->pos = 0; 413 dma_q->pos = 0;
414 dma_q->is_partial_line = 0; 414 dma_q->is_partial_line = 0;
415 dma_q->last_sav = 0; 415 dma_q->last_sav = 0;
@@ -421,42 +421,42 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
421 for (i = 0; i < 8; i++) 421 for (i = 0; i < 8; i++)
422 dma_q->partial_buf[i] = 0; 422 dma_q->partial_buf[i] = 0;
423 423
424 dev->vbi_mode.isoc_ctl.urb = kzalloc(sizeof(void *) * num_bufs, 424 dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs,
425 GFP_KERNEL); 425 GFP_KERNEL);
426 if (!dev->vbi_mode.isoc_ctl.urb) { 426 if (!dev->vbi_mode.bulk_ctl.urb) {
427 cx231xx_errdev("cannot alloc memory for usb buffers\n"); 427 cx231xx_errdev("cannot alloc memory for usb buffers\n");
428 return -ENOMEM; 428 return -ENOMEM;
429 } 429 }
430 430
431 dev->vbi_mode.isoc_ctl.transfer_buffer = 431 dev->vbi_mode.bulk_ctl.transfer_buffer =
432 kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); 432 kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
433 if (!dev->vbi_mode.isoc_ctl.transfer_buffer) { 433 if (!dev->vbi_mode.bulk_ctl.transfer_buffer) {
434 cx231xx_errdev("cannot allocate memory for usbtransfer\n"); 434 cx231xx_errdev("cannot allocate memory for usbtransfer\n");
435 kfree(dev->vbi_mode.isoc_ctl.urb); 435 kfree(dev->vbi_mode.bulk_ctl.urb);
436 return -ENOMEM; 436 return -ENOMEM;
437 } 437 }
438 438
439 dev->vbi_mode.isoc_ctl.max_pkt_size = max_pkt_size; 439 dev->vbi_mode.bulk_ctl.max_pkt_size = max_pkt_size;
440 dev->vbi_mode.isoc_ctl.buf = NULL; 440 dev->vbi_mode.bulk_ctl.buf = NULL;
441 441
442 sb_size = max_packets * dev->vbi_mode.isoc_ctl.max_pkt_size; 442 sb_size = max_packets * dev->vbi_mode.bulk_ctl.max_pkt_size;
443 443
444 /* allocate urbs and transfer buffers */ 444 /* allocate urbs and transfer buffers */
445 for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { 445 for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
446 446
447 urb = usb_alloc_urb(0, GFP_KERNEL); 447 urb = usb_alloc_urb(0, GFP_KERNEL);
448 if (!urb) { 448 if (!urb) {
449 cx231xx_err(DRIVER_NAME 449 cx231xx_err(DRIVER_NAME
450 ": cannot alloc isoc_ctl.urb %i\n", i); 450 ": cannot alloc bulk_ctl.urb %i\n", i);
451 cx231xx_uninit_vbi_isoc(dev); 451 cx231xx_uninit_vbi_isoc(dev);
452 return -ENOMEM; 452 return -ENOMEM;
453 } 453 }
454 dev->vbi_mode.isoc_ctl.urb[i] = urb; 454 dev->vbi_mode.bulk_ctl.urb[i] = urb;
455 urb->transfer_flags = 0; 455 urb->transfer_flags = 0;
456 456
457 dev->vbi_mode.isoc_ctl.transfer_buffer[i] = 457 dev->vbi_mode.bulk_ctl.transfer_buffer[i] =
458 kzalloc(sb_size, GFP_KERNEL); 458 kzalloc(sb_size, GFP_KERNEL);
459 if (!dev->vbi_mode.isoc_ctl.transfer_buffer[i]) { 459 if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) {
460 cx231xx_err(DRIVER_NAME 460 cx231xx_err(DRIVER_NAME
461 ": unable to allocate %i bytes for transfer" 461 ": unable to allocate %i bytes for transfer"
462 " buffer %i%s\n", sb_size, i, 462 " buffer %i%s\n", sb_size, i,
@@ -467,15 +467,15 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
467 467
468 pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr); 468 pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr);
469 usb_fill_bulk_urb(urb, dev->udev, pipe, 469 usb_fill_bulk_urb(urb, dev->udev, pipe,
470 dev->vbi_mode.isoc_ctl.transfer_buffer[i], 470 dev->vbi_mode.bulk_ctl.transfer_buffer[i],
471 sb_size, cx231xx_irq_vbi_callback, dma_q); 471 sb_size, cx231xx_irq_vbi_callback, dma_q);
472 } 472 }
473 473
474 init_waitqueue_head(&dma_q->wq); 474 init_waitqueue_head(&dma_q->wq);
475 475
476 /* submit urbs and enables IRQ */ 476 /* submit urbs and enables IRQ */
477 for (i = 0; i < dev->vbi_mode.isoc_ctl.num_bufs; i++) { 477 for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) {
478 rc = usb_submit_urb(dev->vbi_mode.isoc_ctl.urb[i], GFP_ATOMIC); 478 rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC);
479 if (rc) { 479 if (rc) {
480 cx231xx_err(DRIVER_NAME 480 cx231xx_err(DRIVER_NAME
481 ": submit of urb %i failed (error=%i)\n", i, 481 ": submit of urb %i failed (error=%i)\n", i,
@@ -536,7 +536,7 @@ static inline void vbi_buffer_filled(struct cx231xx *dev,
536 buf->vb.field_count++; 536 buf->vb.field_count++;
537 do_gettimeofday(&buf->vb.ts); 537 do_gettimeofday(&buf->vb.ts);
538 538
539 dev->vbi_mode.isoc_ctl.buf = NULL; 539 dev->vbi_mode.bulk_ctl.buf = NULL;
540 540
541 list_del(&buf->vb.queue); 541 list_del(&buf->vb.queue);
542 wake_up(&buf->vb.done); 542 wake_up(&buf->vb.done);
@@ -553,7 +553,7 @@ u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
553 cx231xx_reset_vbi_buffer(dev, dma_q); 553 cx231xx_reset_vbi_buffer(dev, dma_q);
554 554
555 /* get the buffer pointer */ 555 /* get the buffer pointer */
556 buf = dev->vbi_mode.isoc_ctl.buf; 556 buf = dev->vbi_mode.bulk_ctl.buf;
557 557
558 /* Remember the field number for next time */ 558 /* Remember the field number for next time */
559 dma_q->current_field = field_number; 559 dma_q->current_field = field_number;
@@ -618,7 +618,7 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q,
618 618
619 if (list_empty(&dma_q->active)) { 619 if (list_empty(&dma_q->active)) {
620 cx231xx_err(DRIVER_NAME ": No active queue to serve\n"); 620 cx231xx_err(DRIVER_NAME ": No active queue to serve\n");
621 dev->vbi_mode.isoc_ctl.buf = NULL; 621 dev->vbi_mode.bulk_ctl.buf = NULL;
622 *buf = NULL; 622 *buf = NULL;
623 return; 623 return;
624 } 624 }
@@ -630,7 +630,7 @@ static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q,
630 outp = videobuf_to_vmalloc(&(*buf)->vb); 630 outp = videobuf_to_vmalloc(&(*buf)->vb);
631 memset(outp, 0, (*buf)->vb.size); 631 memset(outp, 0, (*buf)->vb.size);
632 632
633 dev->vbi_mode.isoc_ctl.buf = *buf; 633 dev->vbi_mode.bulk_ctl.buf = *buf;
634 634
635 return; 635 return;
636} 636}
@@ -640,7 +640,7 @@ void cx231xx_reset_vbi_buffer(struct cx231xx *dev,
640{ 640{
641 struct cx231xx_buffer *buf; 641 struct cx231xx_buffer *buf;
642 642
643 buf = dev->vbi_mode.isoc_ctl.buf; 643 buf = dev->vbi_mode.bulk_ctl.buf;
644 644
645 if (buf == NULL) { 645 if (buf == NULL) {
646 /* first try to get the buffer */ 646 /* first try to get the buffer */
@@ -664,7 +664,7 @@ int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
664 void *startwrite; 664 void *startwrite;
665 int offset, lencopy; 665 int offset, lencopy;
666 666
667 buf = dev->vbi_mode.isoc_ctl.buf; 667 buf = dev->vbi_mode.bulk_ctl.buf;
668 668
669 if (buf == NULL) 669 if (buf == NULL)
670 return -EINVAL; 670 return -EINVAL;