diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-08-11 11:55:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-09-13 16:42:12 -0400 |
commit | 559c2009003bb8092e4927a4bac99cbf75834979 (patch) | |
tree | 10f15746d3f70662841d9da8c7b1545d76160f26 | |
parent | d1f280d615a0f0b723dac5a2cd3f2f7f18bca4fa (diff) |
[media] radio-shark: Add support for suspend & resume
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/radio/radio-shark.c | 43 | ||||
-rw-r--r-- | include/sound/tea575x-tuner.h | 1 | ||||
-rw-r--r-- | sound/i2c/other/tea575x-tuner.c | 3 |
3 files changed, 45 insertions, 2 deletions
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c index e1970bf031a4..248bc3a30832 100644 --- a/drivers/media/radio/radio-shark.c +++ b/drivers/media/radio/radio-shark.c | |||
@@ -59,7 +59,8 @@ MODULE_LICENSE("GPL"); | |||
59 | 59 | ||
60 | #define v4l2_dev_to_shark(d) container_of(d, struct shark_device, v4l2_dev) | 60 | #define v4l2_dev_to_shark(d) container_of(d, struct shark_device, v4l2_dev) |
61 | 61 | ||
62 | enum { BLUE_LED, BLUE_PULSE_LED, RED_LED, NO_LEDS }; | 62 | /* Note BLUE_IS_PULSE comes after NO_LEDS as it is a status bit, not a LED */ |
63 | enum { BLUE_LED, BLUE_PULSE_LED, RED_LED, NO_LEDS, BLUE_IS_PULSE }; | ||
63 | 64 | ||
64 | struct shark_device { | 65 | struct shark_device { |
65 | struct usb_device *usbdev; | 66 | struct usb_device *usbdev; |
@@ -190,6 +191,7 @@ static void shark_led_set_blue(struct led_classdev *led_cdev, | |||
190 | 191 | ||
191 | atomic_set(&shark->brightness[BLUE_LED], value); | 192 | atomic_set(&shark->brightness[BLUE_LED], value); |
192 | set_bit(BLUE_LED, &shark->brightness_new); | 193 | set_bit(BLUE_LED, &shark->brightness_new); |
194 | clear_bit(BLUE_IS_PULSE, &shark->brightness_new); | ||
193 | schedule_work(&shark->led_work); | 195 | schedule_work(&shark->led_work); |
194 | } | 196 | } |
195 | 197 | ||
@@ -201,6 +203,7 @@ static void shark_led_set_blue_pulse(struct led_classdev *led_cdev, | |||
201 | 203 | ||
202 | atomic_set(&shark->brightness[BLUE_PULSE_LED], 256 - value); | 204 | atomic_set(&shark->brightness[BLUE_PULSE_LED], 256 - value); |
203 | set_bit(BLUE_PULSE_LED, &shark->brightness_new); | 205 | set_bit(BLUE_PULSE_LED, &shark->brightness_new); |
206 | set_bit(BLUE_IS_PULSE, &shark->brightness_new); | ||
204 | schedule_work(&shark->led_work); | 207 | schedule_work(&shark->led_work); |
205 | } | 208 | } |
206 | 209 | ||
@@ -240,6 +243,7 @@ static int shark_register_leds(struct shark_device *shark, struct device *dev) | |||
240 | { | 243 | { |
241 | int i, retval; | 244 | int i, retval; |
242 | 245 | ||
246 | atomic_set(&shark->brightness[BLUE_LED], 127); | ||
243 | INIT_WORK(&shark->led_work, shark_led_work); | 247 | INIT_WORK(&shark->led_work, shark_led_work); |
244 | for (i = 0; i < NO_LEDS; i++) { | 248 | for (i = 0; i < NO_LEDS; i++) { |
245 | shark->leds[i] = shark_led_templates[i]; | 249 | shark->leds[i] = shark_led_templates[i]; |
@@ -266,6 +270,16 @@ static void shark_unregister_leds(struct shark_device *shark) | |||
266 | 270 | ||
267 | cancel_work_sync(&shark->led_work); | 271 | cancel_work_sync(&shark->led_work); |
268 | } | 272 | } |
273 | |||
274 | static void shark_resume_leds(struct shark_device *shark) | ||
275 | { | ||
276 | if (test_bit(BLUE_IS_PULSE, &shark->brightness_new)) | ||
277 | set_bit(BLUE_PULSE_LED, &shark->brightness_new); | ||
278 | else | ||
279 | set_bit(BLUE_LED, &shark->brightness_new); | ||
280 | set_bit(RED_LED, &shark->brightness_new); | ||
281 | schedule_work(&shark->led_work); | ||
282 | } | ||
269 | #else | 283 | #else |
270 | static int shark_register_leds(struct shark_device *shark, struct device *dev) | 284 | static int shark_register_leds(struct shark_device *shark, struct device *dev) |
271 | { | 285 | { |
@@ -274,6 +288,7 @@ static int shark_register_leds(struct shark_device *shark, struct device *dev) | |||
274 | return 0; | 288 | return 0; |
275 | } | 289 | } |
276 | static inline void shark_unregister_leds(struct shark_device *shark) { } | 290 | static inline void shark_unregister_leds(struct shark_device *shark) { } |
291 | static inline void shark_resume_leds(struct shark_device *shark) { } | ||
277 | #endif | 292 | #endif |
278 | 293 | ||
279 | static void usb_shark_disconnect(struct usb_interface *intf) | 294 | static void usb_shark_disconnect(struct usb_interface *intf) |
@@ -359,6 +374,27 @@ err_alloc_buffer: | |||
359 | return retval; | 374 | return retval; |
360 | } | 375 | } |
361 | 376 | ||
377 | #ifdef CONFIG_PM | ||
378 | int usb_shark_suspend(struct usb_interface *intf, pm_message_t message) | ||
379 | { | ||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | int usb_shark_resume(struct usb_interface *intf) | ||
384 | { | ||
385 | struct v4l2_device *v4l2_dev = usb_get_intfdata(intf); | ||
386 | struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev); | ||
387 | |||
388 | mutex_lock(&shark->tea.mutex); | ||
389 | snd_tea575x_set_freq(&shark->tea); | ||
390 | mutex_unlock(&shark->tea.mutex); | ||
391 | |||
392 | shark_resume_leds(shark); | ||
393 | |||
394 | return 0; | ||
395 | } | ||
396 | #endif | ||
397 | |||
362 | /* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */ | 398 | /* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */ |
363 | static struct usb_device_id usb_shark_device_table[] = { | 399 | static struct usb_device_id usb_shark_device_table[] = { |
364 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION | | 400 | { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION | |
@@ -378,5 +414,10 @@ static struct usb_driver usb_shark_driver = { | |||
378 | .probe = usb_shark_probe, | 414 | .probe = usb_shark_probe, |
379 | .disconnect = usb_shark_disconnect, | 415 | .disconnect = usb_shark_disconnect, |
380 | .id_table = usb_shark_device_table, | 416 | .id_table = usb_shark_device_table, |
417 | #ifdef CONFIG_PM | ||
418 | .suspend = usb_shark_suspend, | ||
419 | .resume = usb_shark_resume, | ||
420 | .reset_resume = usb_shark_resume, | ||
421 | #endif | ||
381 | }; | 422 | }; |
382 | module_usb_driver(usb_shark_driver); | 423 | module_usb_driver(usb_shark_driver); |
diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h index 2a6953568554..098c4de44945 100644 --- a/include/sound/tea575x-tuner.h +++ b/include/sound/tea575x-tuner.h | |||
@@ -73,5 +73,6 @@ struct snd_tea575x { | |||
73 | 73 | ||
74 | int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner); | 74 | int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner); |
75 | void snd_tea575x_exit(struct snd_tea575x *tea); | 75 | void snd_tea575x_exit(struct snd_tea575x *tea); |
76 | void snd_tea575x_set_freq(struct snd_tea575x *tea); | ||
76 | 77 | ||
77 | #endif /* __SOUND_TEA575X_TUNER_H */ | 78 | #endif /* __SOUND_TEA575X_TUNER_H */ |
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index 88bbd88c066e..cd79ed590f9a 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c | |||
@@ -191,7 +191,7 @@ static u32 snd_tea575x_get_freq(struct snd_tea575x *tea) | |||
191 | return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea)); | 191 | return snd_tea575x_val_to_freq(tea, snd_tea575x_read(tea)); |
192 | } | 192 | } |
193 | 193 | ||
194 | static void snd_tea575x_set_freq(struct snd_tea575x *tea) | 194 | void snd_tea575x_set_freq(struct snd_tea575x *tea) |
195 | { | 195 | { |
196 | u32 freq = tea->freq / 16; /* to kHz */ | 196 | u32 freq = tea->freq / 16; /* to kHz */ |
197 | u32 band = 0; | 197 | u32 band = 0; |
@@ -571,3 +571,4 @@ module_exit(alsa_tea575x_module_exit) | |||
571 | 571 | ||
572 | EXPORT_SYMBOL(snd_tea575x_init); | 572 | EXPORT_SYMBOL(snd_tea575x_init); |
573 | EXPORT_SYMBOL(snd_tea575x_exit); | 573 | EXPORT_SYMBOL(snd_tea575x_exit); |
574 | EXPORT_SYMBOL(snd_tea575x_set_freq); | ||