20 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/slab.h>
24 #include <linux/input.h>
25 #include <linux/videodev2.h>
39 #define USB_KEENE_VENDOR 0x046d
40 #define USB_KEENE_PRODUCT 0x0a0e
43 #define BUFFER_LENGTH 8
44 #define USB_TIMEOUT 500
49 #define FREQ_MUL 16000U
83 static int keene_cmd_main(
struct keene_device *radio,
unsigned freq,
bool play)
85 unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
90 radio->
buffer[2] = (freq_send >> 8) & 0xff;
91 radio->
buffer[3] = freq_send & 0xff;
98 radio->
buffer[5] = (radio->
muted ? 4 : 8) | (play ? 1 : 2) |
107 dev_warn(&radio->
vdev.dev,
"%s failed (%d)\n", __func__, ret);
136 dev_warn(&radio->
vdev.dev,
"%s failed (%d)\n", __func__, ret);
149 struct keene_device *radio = to_keene_dev(usb_get_intfdata(intf));
152 usb_set_intfdata(intf,
NULL);
161 struct keene_device *radio = to_keene_dev(usb_get_intfdata(intf));
163 return keene_cmd_main(radio, 0,
false);
168 struct keene_device *radio = to_keene_dev(usb_get_intfdata(intf));
171 keene_cmd_set(radio);
172 keene_cmd_main(radio, radio->
curfreq,
true);
176 static int vidioc_querycap(
struct file *
file,
void *
priv,
189 static int vidioc_g_modulator(
struct file *
file,
void *
priv,
205 static int vidioc_s_modulator(
struct file *file,
void *priv,
214 return keene_cmd_set(radio);
217 static int vidioc_s_frequency(
struct file *file,
void *priv,
226 return keene_cmd_main(radio, f->
frequency,
true);
229 static int vidioc_g_frequency(
struct file *file,
void *priv,
243 static const u8 db2tx[] = {
245 0x03, 0x13, 0x02, 0x12, 0x22, 0x32,
247 0x21, 0x31, 0x20, 0x30, 0x40, 0x50
255 return keene_cmd_main(radio, 0,
true);
260 radio->
pa = (ctrl->
val - 71) * 100 / 62;
261 return keene_cmd_main(radio, 0,
true);
265 return keene_cmd_set(radio);
269 return keene_cmd_set(radio);
284 .s_ctrl = keene_s_ctrl,
298 static void usb_keene_video_device_release(
struct v4l2_device *v4l2_dev)
312 struct usb_device *
dev = interface_to_usbdev(intf);
326 if (dev->product &&
strcmp(dev->product,
"B-LINK USB Audio "))
333 if (!radio || !radio->
buffer) {
334 dev_err(&intf->dev,
"kmalloc for keene_device failed\n");
362 dev_err(&intf->dev,
"couldn't register v4l2_device\n");
369 radio->
v4l2_dev.release = usb_keene_video_device_release;
371 sizeof(radio->
vdev.name));
373 radio->
vdev.fops = &usb_keene_fops;
374 radio->
vdev.ioctl_ops = &usb_keene_ioctl_ops;
378 radio->
usbdev = interface_to_usbdev(intf);
380 usb_set_intfdata(intf, &radio->
v4l2_dev);
382 video_set_drvdata(&radio->
vdev, radio);
387 dev_err(&intf->dev,
"could not register video device\n");
391 dev_info(&intf->dev,
"V4L2 device registered as %s\n",
392 video_device_node_name(&radio->
vdev));
405 static struct usb_driver usb_keene_driver = {
406 .name =
"radio-keene",
407 .probe = usb_keene_probe,
408 .disconnect = usb_keene_disconnect,
409 .id_table = usb_keene_device_table,
410 .suspend = usb_keene_suspend,
411 .resume = usb_keene_resume,
412 .reset_resume = usb_keene_resume,
415 static int __init keene_init(
void)
417 int retval = usb_register(&usb_keene_driver);
421 ": usb_register failed. Error number %d\n", retval);
426 static void __exit keene_exit(
void)