diff options
author | Alexey Klimov <klimov.linux@gmail.com> | 2009-06-10 23:22:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 18:07:36 -0400 |
commit | f1ca0adfcf2c2f1129a59b93caa80a1dbd6b6c81 (patch) | |
tree | 5361ee39fb202a5736f4d09ffe085a0d7131f9a2 /drivers/media/radio/dsbr100.c | |
parent | 917fab4f3e5563e8f88ca0af297728452c6fa265 (diff) |
V4L/DVB (11957): dsbr100: change radio->muted to radio->status, update suspend/resume
Patch renames radio->muted to radio->status, add defines for that
variable, and fixes suspend/resume procedure. Radio->status set to
STOPPED in usb_dsbr100_probe because of removing open call.
Also, patch increases driver version.
Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio/dsbr100.c')
-rw-r--r-- | drivers/media/radio/dsbr100.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 17e8f2ca7d90..ed9cd7ad0604 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -33,6 +33,10 @@ | |||
33 | 33 | ||
34 | History: | 34 | History: |
35 | 35 | ||
36 | Version 0.46: | ||
37 | Removed usb_dsbr100_open/close calls and radio->users counter. Also, | ||
38 | radio->muted changed to radio->status and suspend/resume calls updated. | ||
39 | |||
36 | Version 0.45: | 40 | Version 0.45: |
37 | Converted to v4l2_device. | 41 | Converted to v4l2_device. |
38 | 42 | ||
@@ -100,8 +104,8 @@ | |||
100 | */ | 104 | */ |
101 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 105 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
102 | 106 | ||
103 | #define DRIVER_VERSION "v0.45" | 107 | #define DRIVER_VERSION "v0.46" |
104 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 5) | 108 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 6) |
105 | 109 | ||
106 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" | 110 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" |
107 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" | 111 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" |
@@ -121,6 +125,10 @@ devices, that would be 76 and 91. */ | |||
121 | #define FREQ_MAX 108.0 | 125 | #define FREQ_MAX 108.0 |
122 | #define FREQ_MUL 16000 | 126 | #define FREQ_MUL 16000 |
123 | 127 | ||
128 | /* defines for radio->status */ | ||
129 | #define STARTED 0 | ||
130 | #define STOPPED 1 | ||
131 | |||
124 | #define videodev_to_radio(d) container_of(d, struct dsbr100_device, videodev) | 132 | #define videodev_to_radio(d) container_of(d, struct dsbr100_device, videodev) |
125 | 133 | ||
126 | static int usb_dsbr100_probe(struct usb_interface *intf, | 134 | static int usb_dsbr100_probe(struct usb_interface *intf, |
@@ -144,7 +152,7 @@ struct dsbr100_device { | |||
144 | int curfreq; | 152 | int curfreq; |
145 | int stereo; | 153 | int stereo; |
146 | int removed; | 154 | int removed; |
147 | int muted; | 155 | int status; |
148 | }; | 156 | }; |
149 | 157 | ||
150 | static struct usb_device_id usb_dsbr100_device_table [] = { | 158 | static struct usb_device_id usb_dsbr100_device_table [] = { |
@@ -198,7 +206,7 @@ static int dsbr100_start(struct dsbr100_device *radio) | |||
198 | goto usb_control_msg_failed; | 206 | goto usb_control_msg_failed; |
199 | } | 207 | } |
200 | 208 | ||
201 | radio->muted = 0; | 209 | radio->status = STARTED; |
202 | mutex_unlock(&radio->lock); | 210 | mutex_unlock(&radio->lock); |
203 | return (radio->transfer_buffer)[0]; | 211 | return (radio->transfer_buffer)[0]; |
204 | 212 | ||
@@ -241,7 +249,7 @@ static int dsbr100_stop(struct dsbr100_device *radio) | |||
241 | goto usb_control_msg_failed; | 249 | goto usb_control_msg_failed; |
242 | } | 250 | } |
243 | 251 | ||
244 | radio->muted = 1; | 252 | radio->status = STOPPED; |
245 | mutex_unlock(&radio->lock); | 253 | mutex_unlock(&radio->lock); |
246 | return (radio->transfer_buffer)[0]; | 254 | return (radio->transfer_buffer)[0]; |
247 | 255 | ||
@@ -470,7 +478,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
470 | 478 | ||
471 | switch (ctrl->id) { | 479 | switch (ctrl->id) { |
472 | case V4L2_CID_AUDIO_MUTE: | 480 | case V4L2_CID_AUDIO_MUTE: |
473 | ctrl->value = radio->muted; | 481 | ctrl->value = radio->status; |
474 | return 0; | 482 | return 0; |
475 | } | 483 | } |
476 | return -EINVAL; | 484 | return -EINVAL; |
@@ -546,9 +554,21 @@ static int usb_dsbr100_suspend(struct usb_interface *intf, pm_message_t message) | |||
546 | struct dsbr100_device *radio = usb_get_intfdata(intf); | 554 | struct dsbr100_device *radio = usb_get_intfdata(intf); |
547 | int retval; | 555 | int retval; |
548 | 556 | ||
549 | retval = dsbr100_stop(radio); | 557 | if (radio->status == STARTED) { |
550 | if (retval < 0) | 558 | retval = dsbr100_stop(radio); |
551 | dev_warn(&intf->dev, "dsbr100_stop failed\n"); | 559 | if (retval < 0) |
560 | dev_warn(&intf->dev, "dsbr100_stop failed\n"); | ||
561 | |||
562 | /* After dsbr100_stop() status set to STOPPED. | ||
563 | * If we want driver to start radio on resume | ||
564 | * we set status equal to STARTED. | ||
565 | * On resume we will check status and run radio if needed. | ||
566 | */ | ||
567 | |||
568 | mutex_lock(&radio->lock); | ||
569 | radio->status = STARTED; | ||
570 | mutex_unlock(&radio->lock); | ||
571 | } | ||
552 | 572 | ||
553 | dev_info(&intf->dev, "going into suspend..\n"); | 573 | dev_info(&intf->dev, "going into suspend..\n"); |
554 | 574 | ||
@@ -561,9 +581,11 @@ static int usb_dsbr100_resume(struct usb_interface *intf) | |||
561 | struct dsbr100_device *radio = usb_get_intfdata(intf); | 581 | struct dsbr100_device *radio = usb_get_intfdata(intf); |
562 | int retval; | 582 | int retval; |
563 | 583 | ||
564 | retval = dsbr100_start(radio); | 584 | if (radio->status == STARTED) { |
565 | if (retval < 0) | 585 | retval = dsbr100_start(radio); |
566 | dev_warn(&intf->dev, "dsbr100_start failed\n"); | 586 | if (retval < 0) |
587 | dev_warn(&intf->dev, "dsbr100_start failed\n"); | ||
588 | } | ||
567 | 589 | ||
568 | dev_info(&intf->dev, "coming out of suspend..\n"); | 590 | dev_info(&intf->dev, "coming out of suspend..\n"); |
569 | 591 | ||
@@ -642,6 +664,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
642 | radio->removed = 0; | 664 | radio->removed = 0; |
643 | radio->usbdev = interface_to_usbdev(intf); | 665 | radio->usbdev = interface_to_usbdev(intf); |
644 | radio->curfreq = FREQ_MIN * FREQ_MUL; | 666 | radio->curfreq = FREQ_MIN * FREQ_MUL; |
667 | radio->status = STOPPED; | ||
645 | 668 | ||
646 | video_set_drvdata(&radio->videodev, radio); | 669 | video_set_drvdata(&radio->videodev, radio); |
647 | 670 | ||