aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/si470x/radio-si470x-usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/si470x/radio-si470x-usb.c')
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c97
1 files changed, 2 insertions, 95 deletions
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index f2d0e1ddb301..a96e1b9dd646 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -509,89 +509,9 @@ resubmit:
509 **************************************************************************/ 509 **************************************************************************/
510 510
511/* 511/*
512 * si470x_fops_read - read RDS data
513 */
514static ssize_t si470x_fops_read(struct file *file, char __user *buf,
515 size_t count, loff_t *ppos)
516{
517 struct si470x_device *radio = video_drvdata(file);
518 int retval = 0;
519 unsigned int block_count = 0;
520
521 /* switch on rds reception */
522 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
523 si470x_rds_on(radio);
524
525 /* block if no new data available */
526 while (radio->wr_index == radio->rd_index) {
527 if (file->f_flags & O_NONBLOCK) {
528 retval = -EWOULDBLOCK;
529 goto done;
530 }
531 if (wait_event_interruptible(radio->read_queue,
532 radio->wr_index != radio->rd_index) < 0) {
533 retval = -EINTR;
534 goto done;
535 }
536 }
537
538 /* calculate block count from byte count */
539 count /= 3;
540
541 /* copy RDS block out of internal buffer and to user buffer */
542 mutex_lock(&radio->lock);
543 while (block_count < count) {
544 if (radio->rd_index == radio->wr_index)
545 break;
546
547 /* always transfer rds complete blocks */
548 if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
549 /* retval = -EFAULT; */
550 break;
551
552 /* increment and wrap read pointer */
553 radio->rd_index += 3;
554 if (radio->rd_index >= radio->buf_size)
555 radio->rd_index = 0;
556
557 /* increment counters */
558 block_count++;
559 buf += 3;
560 retval += 3;
561 }
562 mutex_unlock(&radio->lock);
563
564done:
565 return retval;
566}
567
568
569/*
570 * si470x_fops_poll - poll RDS data
571 */
572static unsigned int si470x_fops_poll(struct file *file,
573 struct poll_table_struct *pts)
574{
575 struct si470x_device *radio = video_drvdata(file);
576 int retval = 0;
577
578 /* switch on rds reception */
579 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
580 si470x_rds_on(radio);
581
582 poll_wait(file, &radio->read_queue, pts);
583
584 if (radio->rd_index != radio->wr_index)
585 retval = POLLIN | POLLRDNORM;
586
587 return retval;
588}
589
590
591/*
592 * si470x_fops_open - file open 512 * si470x_fops_open - file open
593 */ 513 */
594static int si470x_fops_open(struct file *file) 514int si470x_fops_open(struct file *file)
595{ 515{
596 struct si470x_device *radio = video_drvdata(file); 516 struct si470x_device *radio = video_drvdata(file);
597 int retval; 517 int retval;
@@ -645,7 +565,7 @@ done:
645/* 565/*
646 * si470x_fops_release - file release 566 * si470x_fops_release - file release
647 */ 567 */
648static int si470x_fops_release(struct file *file) 568int si470x_fops_release(struct file *file)
649{ 569{
650 struct si470x_device *radio = video_drvdata(file); 570 struct si470x_device *radio = video_drvdata(file);
651 int retval = 0; 571 int retval = 0;
@@ -688,19 +608,6 @@ done:
688} 608}
689 609
690 610
691/*
692 * si470x_fops - file operations interface
693 */
694const struct v4l2_file_operations si470x_fops = {
695 .owner = THIS_MODULE,
696 .read = si470x_fops_read,
697 .poll = si470x_fops_poll,
698 .ioctl = video_ioctl2,
699 .open = si470x_fops_open,
700 .release = si470x_fops_release,
701};
702
703
704 611
705/************************************************************************** 612/**************************************************************************
706 * Video4Linux Interface 613 * Video4Linux Interface