diff options
Diffstat (limited to 'drivers/media/radio/radio-si470x.c')
-rw-r--r-- | drivers/media/radio/radio-si470x.c | 122 |
1 files changed, 67 insertions, 55 deletions
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 8743a521e4af..dfaaa467c043 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -481,7 +481,7 @@ struct si470x_device { | |||
481 | 481 | ||
482 | 482 | ||
483 | /************************************************************************** | 483 | /************************************************************************** |
484 | * General Driver Functions | 484 | * General Driver Functions - REGISTER_REPORTs |
485 | **************************************************************************/ | 485 | **************************************************************************/ |
486 | 486 | ||
487 | /* | 487 | /* |
@@ -567,60 +567,6 @@ static int si470x_set_register(struct si470x_device *radio, int regnr) | |||
567 | 567 | ||
568 | 568 | ||
569 | /* | 569 | /* |
570 | * si470x_get_all_registers - read entire registers | ||
571 | */ | ||
572 | static int si470x_get_all_registers(struct si470x_device *radio) | ||
573 | { | ||
574 | unsigned char buf[ENTIRE_REPORT_SIZE]; | ||
575 | int retval; | ||
576 | unsigned char regnr; | ||
577 | |||
578 | buf[0] = ENTIRE_REPORT; | ||
579 | |||
580 | retval = si470x_get_report(radio, (void *) &buf, sizeof(buf)); | ||
581 | |||
582 | if (retval >= 0) | ||
583 | for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++) | ||
584 | radio->registers[regnr] = get_unaligned_be16( | ||
585 | &buf[regnr * RADIO_REGISTER_SIZE + 1]); | ||
586 | |||
587 | return (retval < 0) ? -EINVAL : 0; | ||
588 | } | ||
589 | |||
590 | |||
591 | /* | ||
592 | * si470x_get_rds_registers - read rds registers | ||
593 | */ | ||
594 | static int si470x_get_rds_registers(struct si470x_device *radio) | ||
595 | { | ||
596 | unsigned char buf[RDS_REPORT_SIZE]; | ||
597 | int retval; | ||
598 | int size; | ||
599 | unsigned char regnr; | ||
600 | |||
601 | buf[0] = RDS_REPORT; | ||
602 | |||
603 | retval = usb_interrupt_msg(radio->usbdev, | ||
604 | usb_rcvintpipe(radio->usbdev, 1), | ||
605 | (void *) &buf, sizeof(buf), &size, usb_timeout); | ||
606 | if (size != sizeof(buf)) | ||
607 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | ||
608 | "return size differs: %d != %zu\n", size, sizeof(buf)); | ||
609 | if (retval < 0) | ||
610 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | ||
611 | "usb_interrupt_msg returned %d\n", retval); | ||
612 | |||
613 | if (retval >= 0) | ||
614 | for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++) | ||
615 | radio->registers[STATUSRSSI + regnr] = | ||
616 | get_unaligned_be16( | ||
617 | &buf[regnr * RADIO_REGISTER_SIZE + 1]); | ||
618 | |||
619 | return (retval < 0) ? -EINVAL : 0; | ||
620 | } | ||
621 | |||
622 | |||
623 | /* | ||
624 | * si470x_set_chan - set the channel | 570 | * si470x_set_chan - set the channel |
625 | */ | 571 | */ |
626 | static int si470x_set_chan(struct si470x_device *radio, unsigned short chan) | 572 | static int si470x_set_chan(struct si470x_device *radio, unsigned short chan) |
@@ -912,6 +858,70 @@ static int si470x_set_led_state(struct si470x_device *radio, | |||
912 | 858 | ||
913 | 859 | ||
914 | /************************************************************************** | 860 | /************************************************************************** |
861 | * General Driver Functions - ENTIRE_REPORT | ||
862 | **************************************************************************/ | ||
863 | |||
864 | /* | ||
865 | * si470x_get_all_registers - read entire registers | ||
866 | */ | ||
867 | static int si470x_get_all_registers(struct si470x_device *radio) | ||
868 | { | ||
869 | unsigned char buf[ENTIRE_REPORT_SIZE]; | ||
870 | int retval; | ||
871 | unsigned char regnr; | ||
872 | |||
873 | buf[0] = ENTIRE_REPORT; | ||
874 | |||
875 | retval = si470x_get_report(radio, (void *) &buf, sizeof(buf)); | ||
876 | |||
877 | if (retval >= 0) | ||
878 | for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++) | ||
879 | radio->registers[regnr] = get_unaligned_be16( | ||
880 | &buf[regnr * RADIO_REGISTER_SIZE + 1]); | ||
881 | |||
882 | return (retval < 0) ? -EINVAL : 0; | ||
883 | } | ||
884 | |||
885 | |||
886 | |||
887 | /************************************************************************** | ||
888 | * General Driver Functions - RDS_REPORT | ||
889 | **************************************************************************/ | ||
890 | |||
891 | /* | ||
892 | * si470x_get_rds_registers - read rds registers | ||
893 | */ | ||
894 | static int si470x_get_rds_registers(struct si470x_device *radio) | ||
895 | { | ||
896 | unsigned char buf[RDS_REPORT_SIZE]; | ||
897 | int retval; | ||
898 | int size; | ||
899 | unsigned char regnr; | ||
900 | |||
901 | buf[0] = RDS_REPORT; | ||
902 | |||
903 | retval = usb_interrupt_msg(radio->usbdev, | ||
904 | usb_rcvintpipe(radio->usbdev, 1), | ||
905 | (void *) &buf, sizeof(buf), &size, usb_timeout); | ||
906 | if (size != sizeof(buf)) | ||
907 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | ||
908 | "return size differs: %d != %zu\n", size, sizeof(buf)); | ||
909 | if (retval < 0) | ||
910 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | ||
911 | "usb_interrupt_msg returned %d\n", retval); | ||
912 | |||
913 | if (retval >= 0) | ||
914 | for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++) | ||
915 | radio->registers[STATUSRSSI + regnr] = | ||
916 | get_unaligned_be16( | ||
917 | &buf[regnr * RADIO_REGISTER_SIZE + 1]); | ||
918 | |||
919 | return (retval < 0) ? -EINVAL : 0; | ||
920 | } | ||
921 | |||
922 | |||
923 | |||
924 | /************************************************************************** | ||
915 | * RDS Driver Functions | 925 | * RDS Driver Functions |
916 | **************************************************************************/ | 926 | **************************************************************************/ |
917 | 927 | ||
@@ -1125,6 +1135,7 @@ static int si470x_fops_open(struct file *file) | |||
1125 | } | 1135 | } |
1126 | 1136 | ||
1127 | if (radio->users == 1) { | 1137 | if (radio->users == 1) { |
1138 | /* start radio */ | ||
1128 | retval = si470x_start(radio); | 1139 | retval = si470x_start(radio); |
1129 | if (retval < 0) | 1140 | if (retval < 0) |
1130 | usb_autopm_put_interface(radio->intf); | 1141 | usb_autopm_put_interface(radio->intf); |
@@ -1166,6 +1177,7 @@ static int si470x_fops_release(struct file *file) | |||
1166 | /* cancel read processes */ | 1177 | /* cancel read processes */ |
1167 | wake_up_interruptible(&radio->read_queue); | 1178 | wake_up_interruptible(&radio->read_queue); |
1168 | 1179 | ||
1180 | /* stop radio */ | ||
1169 | retval = si470x_stop(radio); | 1181 | retval = si470x_stop(radio); |
1170 | usb_autopm_put_interface(radio->intf); | 1182 | usb_autopm_put_interface(radio->intf); |
1171 | } | 1183 | } |