diff options
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/radio-si470x.c | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 67cbce82cb91..4dfed6aa2dbc 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
@@ -98,11 +98,16 @@ | |||
98 | * - blacklisted KWorld radio in hid-core.c and hid-ids.h | 98 | * - blacklisted KWorld radio in hid-core.c and hid-ids.h |
99 | * 2008-12-03 Mark Lord <mlord@pobox.com> | 99 | * 2008-12-03 Mark Lord <mlord@pobox.com> |
100 | * - add support for DealExtreme USB Radio | 100 | * - add support for DealExtreme USB Radio |
101 | * 2009-01-31 Bob Ross <pigiron@gmx.com> | ||
102 | * - correction of stereo detection/setting | ||
103 | * - correction of signal strength indicator scaling | ||
104 | * 2009-01-31 Rick Bronson <rick@efn.org> | ||
105 | * Tobias Lorenz <tobias.lorenz@gmx.net> | ||
106 | * - add LED status output | ||
101 | * | 107 | * |
102 | * ToDo: | 108 | * ToDo: |
103 | * - add firmware download/update support | 109 | * - add firmware download/update support |
104 | * - RDS support: interrupt mode, instead of polling | 110 | * - RDS support: interrupt mode, instead of polling |
105 | * - add LED status output (check if that's not already done in firmware) | ||
106 | */ | 111 | */ |
107 | 112 | ||
108 | 113 | ||
@@ -882,6 +887,30 @@ static int si470x_rds_on(struct si470x_device *radio) | |||
882 | 887 | ||
883 | 888 | ||
884 | /************************************************************************** | 889 | /************************************************************************** |
890 | * General Driver Functions - LED_REPORT | ||
891 | **************************************************************************/ | ||
892 | |||
893 | /* | ||
894 | * si470x_set_led_state - sets the led state | ||
895 | */ | ||
896 | static int si470x_set_led_state(struct si470x_device *radio, | ||
897 | unsigned char led_state) | ||
898 | { | ||
899 | unsigned char buf[LED_REPORT_SIZE]; | ||
900 | int retval; | ||
901 | |||
902 | buf[0] = LED_REPORT; | ||
903 | buf[1] = LED_COMMAND; | ||
904 | buf[2] = led_state; | ||
905 | |||
906 | retval = si470x_set_report(radio, (void *) &buf, sizeof(buf)); | ||
907 | |||
908 | return (retval < 0) ? -EINVAL : 0; | ||
909 | } | ||
910 | |||
911 | |||
912 | |||
913 | /************************************************************************** | ||
885 | * RDS Driver Functions | 914 | * RDS Driver Functions |
886 | **************************************************************************/ | 915 | **************************************************************************/ |
887 | 916 | ||
@@ -1385,20 +1414,22 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
1385 | }; | 1414 | }; |
1386 | 1415 | ||
1387 | /* stereo indicator == stereo (instead of mono) */ | 1416 | /* stereo indicator == stereo (instead of mono) */ |
1388 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 1) | 1417 | if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 0) |
1389 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; | ||
1390 | else | ||
1391 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO; | 1418 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO; |
1419 | else | ||
1420 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; | ||
1392 | 1421 | ||
1393 | /* mono/stereo selector */ | 1422 | /* mono/stereo selector */ |
1394 | if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 1) | 1423 | if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0) |
1395 | tuner->audmode = V4L2_TUNER_MODE_MONO; | ||
1396 | else | ||
1397 | tuner->audmode = V4L2_TUNER_MODE_STEREO; | 1424 | tuner->audmode = V4L2_TUNER_MODE_STEREO; |
1425 | else | ||
1426 | tuner->audmode = V4L2_TUNER_MODE_MONO; | ||
1398 | 1427 | ||
1399 | /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ | 1428 | /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */ |
1400 | tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI) | 1429 | /* measured in units of dbµV in 1 db increments (max at ~75 dbµV) */ |
1401 | * 0x0101; | 1430 | tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI); |
1431 | /* the ideal factor is 0xffff/75 = 873,8 */ | ||
1432 | tuner->signal = (tuner->signal * 873) + (8 * tuner->signal / 10); | ||
1402 | 1433 | ||
1403 | /* automatic frequency control: -1: freq to low, 1 freq to high */ | 1434 | /* automatic frequency control: -1: freq to low, 1 freq to high */ |
1404 | /* AFCRL does only indicate that freq. differs, not if too low/high */ | 1435 | /* AFCRL does only indicate that freq. differs, not if too low/high */ |
@@ -1632,6 +1663,9 @@ static int si470x_usb_driver_probe(struct usb_interface *intf, | |||
1632 | /* set initial frequency */ | 1663 | /* set initial frequency */ |
1633 | si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ | 1664 | si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ |
1634 | 1665 | ||
1666 | /* set led to connect state */ | ||
1667 | si470x_set_led_state(radio, BLINK_GREEN_LED); | ||
1668 | |||
1635 | /* rds buffer allocation */ | 1669 | /* rds buffer allocation */ |
1636 | radio->buf_size = rds_buf * 3; | 1670 | radio->buf_size = rds_buf * 3; |
1637 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); | 1671 | radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); |
@@ -1715,6 +1749,9 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf) | |||
1715 | cancel_delayed_work_sync(&radio->work); | 1749 | cancel_delayed_work_sync(&radio->work); |
1716 | usb_set_intfdata(intf, NULL); | 1750 | usb_set_intfdata(intf, NULL); |
1717 | if (radio->users == 0) { | 1751 | if (radio->users == 0) { |
1752 | /* set led to disconnect state */ | ||
1753 | si470x_set_led_state(radio, BLINK_ORANGE_LED); | ||
1754 | |||
1718 | video_unregister_device(radio->videodev); | 1755 | video_unregister_device(radio->videodev); |
1719 | kfree(radio->buffer); | 1756 | kfree(radio->buffer); |
1720 | kfree(radio); | 1757 | kfree(radio); |