aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/si470x/radio-si470x-common.c98
-rw-r--r--drivers/media/radio/si470x/radio-si470x-i2c.c15
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c97
-rw-r--r--drivers/media/radio/si470x/radio-si470x.h3
4 files changed, 104 insertions, 109 deletions
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index f33315f2c543..4da0f150c6e2 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -426,6 +426,104 @@ int si470x_rds_on(struct si470x_device *radio)
426 426
427 427
428/************************************************************************** 428/**************************************************************************
429 * File Operations Interface
430 **************************************************************************/
431
432/*
433 * si470x_fops_read - read RDS data
434 */
435static ssize_t si470x_fops_read(struct file *file, char __user *buf,
436 size_t count, loff_t *ppos)
437{
438 struct si470x_device *radio = video_drvdata(file);
439 int retval = 0;
440 unsigned int block_count = 0;
441
442 /* switch on rds reception */
443 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
444 si470x_rds_on(radio);
445
446 /* block if no new data available */
447 while (radio->wr_index == radio->rd_index) {
448 if (file->f_flags & O_NONBLOCK) {
449 retval = -EWOULDBLOCK;
450 goto done;
451 }
452 if (wait_event_interruptible(radio->read_queue,
453 radio->wr_index != radio->rd_index) < 0) {
454 retval = -EINTR;
455 goto done;
456 }
457 }
458
459 /* calculate block count from byte count */
460 count /= 3;
461
462 /* copy RDS block out of internal buffer and to user buffer */
463 mutex_lock(&radio->lock);
464 while (block_count < count) {
465 if (radio->rd_index == radio->wr_index)
466 break;
467
468 /* always transfer rds complete blocks */
469 if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
470 /* retval = -EFAULT; */
471 break;
472
473 /* increment and wrap read pointer */
474 radio->rd_index += 3;
475 if (radio->rd_index >= radio->buf_size)
476 radio->rd_index = 0;
477
478 /* increment counters */
479 block_count++;
480 buf += 3;
481 retval += 3;
482 }
483 mutex_unlock(&radio->lock);
484
485done:
486 return retval;
487}
488
489
490/*
491 * si470x_fops_poll - poll RDS data
492 */
493static unsigned int si470x_fops_poll(struct file *file,
494 struct poll_table_struct *pts)
495{
496 struct si470x_device *radio = video_drvdata(file);
497 int retval = 0;
498
499 /* switch on rds reception */
500 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
501 si470x_rds_on(radio);
502
503 poll_wait(file, &radio->read_queue, pts);
504
505 if (radio->rd_index != radio->wr_index)
506 retval = POLLIN | POLLRDNORM;
507
508 return retval;
509}
510
511
512/*
513 * si470x_fops - file operations interface
514 */
515static const struct v4l2_file_operations si470x_fops = {
516 .owner = THIS_MODULE,
517 .read = si470x_fops_read,
518 .poll = si470x_fops_poll,
519 .ioctl = video_ioctl2,
520 .open = si470x_fops_open,
521 .release = si470x_fops_release,
522};
523
524
525
526/**************************************************************************
429 * Video4Linux Interface 527 * Video4Linux Interface
430 **************************************************************************/ 528 **************************************************************************/
431 529
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 2d53b6a9409b..4816a6d501c6 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -173,7 +173,7 @@ int si470x_disconnect_check(struct si470x_device *radio)
173/* 173/*
174 * si470x_fops_open - file open 174 * si470x_fops_open - file open
175 */ 175 */
176static int si470x_fops_open(struct file *file) 176int si470x_fops_open(struct file *file)
177{ 177{
178 struct si470x_device *radio = video_drvdata(file); 178 struct si470x_device *radio = video_drvdata(file);
179 int retval = 0; 179 int retval = 0;
@@ -194,7 +194,7 @@ static int si470x_fops_open(struct file *file)
194/* 194/*
195 * si470x_fops_release - file release 195 * si470x_fops_release - file release
196 */ 196 */
197static int si470x_fops_release(struct file *file) 197int si470x_fops_release(struct file *file)
198{ 198{
199 struct si470x_device *radio = video_drvdata(file); 199 struct si470x_device *radio = video_drvdata(file);
200 int retval = 0; 200 int retval = 0;
@@ -215,17 +215,6 @@ static int si470x_fops_release(struct file *file)
215} 215}
216 216
217 217
218/*
219 * si470x_fops - file operations interface
220 */
221const struct v4l2_file_operations si470x_fops = {
222 .owner = THIS_MODULE,
223 .ioctl = video_ioctl2,
224 .open = si470x_fops_open,
225 .release = si470x_fops_release,
226};
227
228
229 218
230/************************************************************************** 219/**************************************************************************
231 * Video4Linux Interface 220 * Video4Linux Interface
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
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h
index d0af194d194c..f646f79d2f7a 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -212,7 +212,6 @@ struct si470x_device {
212/************************************************************************** 212/**************************************************************************
213 * Common Functions 213 * Common Functions
214 **************************************************************************/ 214 **************************************************************************/
215extern const struct v4l2_file_operations si470x_fops;
216extern struct video_device si470x_viddev_template; 215extern struct video_device si470x_viddev_template;
217int si470x_get_register(struct si470x_device *radio, int regnr); 216int si470x_get_register(struct si470x_device *radio, int regnr);
218int si470x_set_register(struct si470x_device *radio, int regnr); 217int si470x_set_register(struct si470x_device *radio, int regnr);
@@ -221,5 +220,7 @@ int si470x_set_freq(struct si470x_device *radio, unsigned int freq);
221int si470x_start(struct si470x_device *radio); 220int si470x_start(struct si470x_device *radio);
222int si470x_stop(struct si470x_device *radio); 221int si470x_stop(struct si470x_device *radio);
223int si470x_rds_on(struct si470x_device *radio); 222int si470x_rds_on(struct si470x_device *radio);
223int si470x_fops_open(struct file *file);
224int si470x_fops_release(struct file *file);
224int si470x_vidioc_querycap(struct file *file, void *priv, 225int si470x_vidioc_querycap(struct file *file, void *priv,
225 struct v4l2_capability *capability); 226 struct v4l2_capability *capability);