Skip to content

Commit

Permalink
V4L/DVB (11957): dsbr100: change radio->muted to radio->status, updat…
Browse files Browse the repository at this point in the history
…e 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>
  • Loading branch information
Alexey Klimov authored and Mauro Carvalho Chehab committed Jun 16, 2009
1 parent 917fab4 commit f1ca0ad
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions drivers/media/radio/dsbr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
History:
Version 0.46:
Removed usb_dsbr100_open/close calls and radio->users counter. Also,
radio->muted changed to radio->status and suspend/resume calls updated.
Version 0.45:
Converted to v4l2_device.
Expand Down Expand Up @@ -100,8 +104,8 @@
*/
#include <linux/version.h> /* for KERNEL_VERSION MACRO */

#define DRIVER_VERSION "v0.45"
#define RADIO_VERSION KERNEL_VERSION(0, 4, 5)
#define DRIVER_VERSION "v0.46"
#define RADIO_VERSION KERNEL_VERSION(0, 4, 6)

#define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>"
#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver"
Expand All @@ -121,6 +125,10 @@ devices, that would be 76 and 91. */
#define FREQ_MAX 108.0
#define FREQ_MUL 16000

/* defines for radio->status */
#define STARTED 0
#define STOPPED 1

#define videodev_to_radio(d) container_of(d, struct dsbr100_device, videodev)

static int usb_dsbr100_probe(struct usb_interface *intf,
Expand All @@ -144,7 +152,7 @@ struct dsbr100_device {
int curfreq;
int stereo;
int removed;
int muted;
int status;
};

static struct usb_device_id usb_dsbr100_device_table [] = {
Expand Down Expand Up @@ -198,7 +206,7 @@ static int dsbr100_start(struct dsbr100_device *radio)
goto usb_control_msg_failed;
}

radio->muted = 0;
radio->status = STARTED;
mutex_unlock(&radio->lock);
return (radio->transfer_buffer)[0];

Expand Down Expand Up @@ -241,7 +249,7 @@ static int dsbr100_stop(struct dsbr100_device *radio)
goto usb_control_msg_failed;
}

radio->muted = 1;
radio->status = STOPPED;
mutex_unlock(&radio->lock);
return (radio->transfer_buffer)[0];

Expand Down Expand Up @@ -470,7 +478,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,

switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
ctrl->value = radio->muted;
ctrl->value = radio->status;
return 0;
}
return -EINVAL;
Expand Down Expand Up @@ -546,9 +554,21 @@ static int usb_dsbr100_suspend(struct usb_interface *intf, pm_message_t message)
struct dsbr100_device *radio = usb_get_intfdata(intf);
int retval;

retval = dsbr100_stop(radio);
if (retval < 0)
dev_warn(&intf->dev, "dsbr100_stop failed\n");
if (radio->status == STARTED) {
retval = dsbr100_stop(radio);
if (retval < 0)
dev_warn(&intf->dev, "dsbr100_stop failed\n");

/* After dsbr100_stop() status set to STOPPED.
* If we want driver to start radio on resume
* we set status equal to STARTED.
* On resume we will check status and run radio if needed.
*/

mutex_lock(&radio->lock);
radio->status = STARTED;
mutex_unlock(&radio->lock);
}

dev_info(&intf->dev, "going into suspend..\n");

Expand All @@ -561,9 +581,11 @@ static int usb_dsbr100_resume(struct usb_interface *intf)
struct dsbr100_device *radio = usb_get_intfdata(intf);
int retval;

retval = dsbr100_start(radio);
if (retval < 0)
dev_warn(&intf->dev, "dsbr100_start failed\n");
if (radio->status == STARTED) {
retval = dsbr100_start(radio);
if (retval < 0)
dev_warn(&intf->dev, "dsbr100_start failed\n");
}

dev_info(&intf->dev, "coming out of suspend..\n");

Expand Down Expand Up @@ -642,6 +664,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
radio->removed = 0;
radio->usbdev = interface_to_usbdev(intf);
radio->curfreq = FREQ_MIN * FREQ_MUL;
radio->status = STOPPED;

video_set_drvdata(&radio->videodev, radio);

Expand Down

0 comments on commit f1ca0ad

Please sign in to comment.