37 #include <linux/kernel.h>
38 #include <linux/module.h>
40 #include <linux/slab.h>
41 #include <linux/input.h>
42 #include <linux/videodev2.h>
57 #define DSB100_VENDOR 0x04b4
58 #define DSB100_PRODUCT 0x1002
62 #define DSB100_ONOFF 2
69 #define FREQ_MAX 108.0
70 #define FREQ_MUL 16000
72 #define v4l2_dev_to_radio(d) container_of(d, struct dsbr100_device, v4l2_dev)
74 static int radio_nr = -1;
96 unsigned f = (freq / 16 * 80) / 1000 + 856;
101 usb_rcvctrlpipe(radio->
usbdev, 0),
104 (f >> 8) & 0x00ff, f & 0xff,
115 "%s - usb_control_msg returned %i, request %i\n",
124 usb_rcvctrlpipe(radio->
usbdev, 0),
130 return dsbr100_setfreq(radio, radio->
curfreq);
132 "%s - usb_control_msg returned %i, request %i\n",
142 usb_rcvctrlpipe(radio->
usbdev, 0),
150 "%s - usb_control_msg returned %i, request %i\n",
161 usb_rcvctrlpipe(radio->
usbdev, 0),
169 "%s - usb_control_msg returned %i, request %i\n",
176 static int vidioc_querycap(
struct file *
file,
void *
priv,
189 static int vidioc_g_tuner(
struct file *
file,
void *
priv,
197 dsbr100_getstat(radio);
210 static int vidioc_s_tuner(
struct file *file,
void *priv,
216 static int vidioc_s_frequency(
struct file *file,
void *priv,
228 static int vidioc_g_frequency(
struct file *file,
void *priv,
248 return radio->
muted ? dsbr100_stop(radio) : dsbr100_start(radio);
273 usb_rcvctrlpipe(radio->
usbdev, 0),
277 usb_set_intfdata(intf,
NULL);
291 if (!radio->
muted && dsbr100_stop(radio) < 0)
292 dev_warn(&intf->dev,
"dsbr100_stop failed\n");
295 dev_info(&intf->dev,
"going into suspend..\n");
305 if (!radio->
muted && dsbr100_start(radio) < 0)
306 dev_warn(&intf->dev,
"dsbr100_start failed\n");
309 dev_info(&intf->dev,
"coming out of suspend..\n");
325 .s_ctrl = usb_dsbr100_s_ctrl,
369 v4l2_dev->
release = usb_dsbr100_release;
373 v4l2_err(v4l2_dev,
"couldn't register v4l2_device\n");
380 if (radio->
hdl.error) {
381 retval = radio->
hdl.error;
382 v4l2_err(v4l2_dev,
"couldn't register control\n");
387 radio->
videodev.v4l2_dev = v4l2_dev;
388 radio->
videodev.fops = &usb_dsbr100_fops;
389 radio->
videodev.ioctl_ops = &usb_dsbr100_ioctl_ops;
395 radio->
usbdev = interface_to_usbdev(intf);
399 video_set_drvdata(&radio->
videodev, radio);
400 usb_set_intfdata(intf, radio);
405 v4l2_err(v4l2_dev,
"couldn't register video device\n");
424 static struct usb_driver usb_dsbr100_driver = {
426 .probe = usb_dsbr100_probe,
427 .disconnect = usb_dsbr100_disconnect,
428 .id_table = usb_dsbr100_device_table,
429 .suspend = usb_dsbr100_suspend,
430 .resume = usb_dsbr100_resume,
431 .reset_resume = usb_dsbr100_resume,