[media] radio-shark2: Add support for suspend & resume
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
d7aab0bf9d
commit
d1f280d615
|
@ -209,6 +209,7 @@ static int shark_register_leds(struct shark_device *shark, struct device *dev)
|
||||||
{
|
{
|
||||||
int i, retval;
|
int i, retval;
|
||||||
|
|
||||||
|
atomic_set(&shark->brightness[BLUE_LED], 127);
|
||||||
INIT_WORK(&shark->led_work, shark_led_work);
|
INIT_WORK(&shark->led_work, shark_led_work);
|
||||||
for (i = 0; i < NO_LEDS; i++) {
|
for (i = 0; i < NO_LEDS; i++) {
|
||||||
shark->leds[i] = shark_led_templates[i];
|
shark->leds[i] = shark_led_templates[i];
|
||||||
|
@ -235,6 +236,16 @@ static void shark_unregister_leds(struct shark_device *shark)
|
||||||
|
|
||||||
cancel_work_sync(&shark->led_work);
|
cancel_work_sync(&shark->led_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shark_resume_leds(struct shark_device *shark)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NO_LEDS; i++)
|
||||||
|
set_bit(i, &shark->brightness_new);
|
||||||
|
|
||||||
|
schedule_work(&shark->led_work);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static int shark_register_leds(struct shark_device *shark, struct device *dev)
|
static int shark_register_leds(struct shark_device *shark, struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -243,6 +254,7 @@ static int shark_register_leds(struct shark_device *shark, struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline void shark_unregister_leds(struct shark_device *shark) { }
|
static inline void shark_unregister_leds(struct shark_device *shark) { }
|
||||||
|
static inline void shark_resume_leds(struct shark_device *shark) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void usb_shark_disconnect(struct usb_interface *intf)
|
static void usb_shark_disconnect(struct usb_interface *intf)
|
||||||
|
@ -327,6 +339,28 @@ err_alloc_buffer:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
int usb_shark_suspend(struct usb_interface *intf, pm_message_t message)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int usb_shark_resume(struct usb_interface *intf)
|
||||||
|
{
|
||||||
|
struct v4l2_device *v4l2_dev = usb_get_intfdata(intf);
|
||||||
|
struct shark_device *shark = v4l2_dev_to_shark(v4l2_dev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mutex_lock(&shark->tea.mutex);
|
||||||
|
ret = radio_tea5777_set_freq(&shark->tea);
|
||||||
|
mutex_unlock(&shark->tea.mutex);
|
||||||
|
|
||||||
|
shark_resume_leds(shark);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */
|
/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */
|
||||||
static struct usb_device_id usb_shark_device_table[] = {
|
static struct usb_device_id usb_shark_device_table[] = {
|
||||||
{ .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION |
|
{ .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION |
|
||||||
|
@ -346,5 +380,10 @@ static struct usb_driver usb_shark_driver = {
|
||||||
.probe = usb_shark_probe,
|
.probe = usb_shark_probe,
|
||||||
.disconnect = usb_shark_disconnect,
|
.disconnect = usb_shark_disconnect,
|
||||||
.id_table = usb_shark_device_table,
|
.id_table = usb_shark_device_table,
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
.suspend = usb_shark_suspend,
|
||||||
|
.resume = usb_shark_resume,
|
||||||
|
.reset_resume = usb_shark_resume,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
module_usb_driver(usb_shark_driver);
|
module_usb_driver(usb_shark_driver);
|
||||||
|
|
|
@ -184,7 +184,7 @@ static u32 tea5777_freq_to_v4l2_freq(struct radio_tea5777 *tea, u32 freq)
|
||||||
return 0; /* Never reached */
|
return 0; /* Never reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int radio_tea5777_set_freq(struct radio_tea5777 *tea)
|
int radio_tea5777_set_freq(struct radio_tea5777 *tea)
|
||||||
{
|
{
|
||||||
u32 freq;
|
u32 freq;
|
||||||
int res;
|
int res;
|
||||||
|
|
|
@ -85,5 +85,6 @@ struct radio_tea5777 {
|
||||||
|
|
||||||
int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
|
int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
|
||||||
void radio_tea5777_exit(struct radio_tea5777 *tea);
|
void radio_tea5777_exit(struct radio_tea5777 *tea);
|
||||||
|
int radio_tea5777_set_freq(struct radio_tea5777 *tea);
|
||||||
|
|
||||||
#endif /* __RADIO_TEA5777_H */
|
#endif /* __RADIO_TEA5777_H */
|
||||||
|
|
Loading…
Reference in a new issue