radio-mr800.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * A driver for the AverMedia MR 800 USB FM radio. This device plugs
  4. * into both the USB and an analog audio input, so this thing
  5. * only deals with initialization and frequency setting, the
  6. * audio data has to be handled by a sound driver.
  7. *
  8. * Copyright (c) 2008 Alexey Klimov <[email protected]>
  9. */
  10. /*
  11. * Big thanks to authors and contributors of dsbr100.c and radio-si470x.c
  12. *
  13. * When work was looked pretty good, i discover this:
  14. * http://av-usbradio.sourceforge.net/index.php
  15. * http://sourceforge.net/projects/av-usbradio/
  16. * Latest release of theirs project was in 2005.
  17. * Probably, this driver could be improved through using their
  18. * achievements (specifications given).
  19. * Also, Faidon Liambotis <[email protected]> wrote nice driver for this radio
  20. * in 2007. He allowed to use his driver to improve current mr800 radio driver.
  21. * http://www.spinics.net/lists/linux-usb-devel/msg10109.html
  22. *
  23. * Version 0.01: First working version.
  24. * It's required to blacklist AverMedia USB Radio
  25. * in usbhid/hid-quirks.c
  26. * Version 0.10: A lot of cleanups and fixes: unpluging the device,
  27. * few mutex locks were added, codinstyle issues, etc.
  28. * Added stereo support. Thanks to
  29. * Douglas Schilling Landgraf <[email protected]> and
  30. * David Ellingsworth <[email protected]>
  31. * for discussion, help and support.
  32. * Version 0.11: Converted to v4l2_device.
  33. *
  34. * Many things to do:
  35. * - Correct power management of device (suspend & resume)
  36. * - Add code for scanning and smooth tuning
  37. * - Add code for sensitivity value
  38. * - Correct mistakes
  39. * - In Japan another FREQ_MIN and FREQ_MAX
  40. */
  41. /* kernel includes */
  42. #include <linux/kernel.h>
  43. #include <linux/module.h>
  44. #include <linux/init.h>
  45. #include <linux/slab.h>
  46. #include <linux/input.h>
  47. #include <linux/videodev2.h>
  48. #include <media/v4l2-device.h>
  49. #include <media/v4l2-ioctl.h>
  50. #include <media/v4l2-ctrls.h>
  51. #include <media/v4l2-event.h>
  52. #include <linux/usb.h>
  53. #include <linux/mutex.h>
  54. /* driver and module definitions */
  55. #define DRIVER_AUTHOR "Alexey Klimov <[email protected]>"
  56. #define DRIVER_DESC "AverMedia MR 800 USB FM radio driver"
  57. #define DRIVER_VERSION "0.1.2"
  58. MODULE_AUTHOR(DRIVER_AUTHOR);
  59. MODULE_DESCRIPTION(DRIVER_DESC);
  60. MODULE_LICENSE("GPL");
  61. MODULE_VERSION(DRIVER_VERSION);
  62. #define USB_AMRADIO_VENDOR 0x07ca
  63. #define USB_AMRADIO_PRODUCT 0xb800
  64. /* dev_warn macro with driver name */
  65. #define MR800_DRIVER_NAME "radio-mr800"
  66. #define amradio_dev_warn(dev, fmt, arg...) \
  67. dev_warn(dev, MR800_DRIVER_NAME " - " fmt, ##arg)
  68. #define amradio_dev_err(dev, fmt, arg...) \
  69. dev_err(dev, MR800_DRIVER_NAME " - " fmt, ##arg)
  70. /* Probably USB_TIMEOUT should be modified in module parameter */
  71. #define BUFFER_LENGTH 8
  72. #define USB_TIMEOUT 500
  73. /* Frequency limits in MHz -- these are European values. For Japanese
  74. devices, that would be 76 and 91. */
  75. #define FREQ_MIN 87.5
  76. #define FREQ_MAX 108.0
  77. #define FREQ_MUL 16000
  78. /*
  79. * Commands that device should understand
  80. * List isn't full and will be updated with implementation of new functions
  81. */
  82. #define AMRADIO_SET_FREQ 0xa4
  83. #define AMRADIO_GET_READY_FLAG 0xa5
  84. #define AMRADIO_GET_SIGNAL 0xa7
  85. #define AMRADIO_GET_FREQ 0xa8
  86. #define AMRADIO_SET_SEARCH_UP 0xa9
  87. #define AMRADIO_SET_SEARCH_DOWN 0xaa
  88. #define AMRADIO_SET_MUTE 0xab
  89. #define AMRADIO_SET_RIGHT_MUTE 0xac
  90. #define AMRADIO_SET_LEFT_MUTE 0xad
  91. #define AMRADIO_SET_MONO 0xae
  92. #define AMRADIO_SET_SEARCH_LVL 0xb0
  93. #define AMRADIO_STOP_SEARCH 0xb1
  94. /* Comfortable defines for amradio_set_stereo */
  95. #define WANT_STEREO 0x00
  96. #define WANT_MONO 0x01
  97. /* module parameter */
  98. static int radio_nr = -1;
  99. module_param(radio_nr, int, 0);
  100. MODULE_PARM_DESC(radio_nr, "Radio Nr");
  101. /* Data for one (physical) device */
  102. struct amradio_device {
  103. /* reference to USB and video device */
  104. struct usb_device *usbdev;
  105. struct usb_interface *intf;
  106. struct video_device vdev;
  107. struct v4l2_device v4l2_dev;
  108. struct v4l2_ctrl_handler hdl;
  109. u8 *buffer;
  110. struct mutex lock; /* buffer locking */
  111. int curfreq;
  112. int stereo;
  113. int muted;
  114. };
  115. static inline struct amradio_device *to_amradio_dev(struct v4l2_device *v4l2_dev)
  116. {
  117. return container_of(v4l2_dev, struct amradio_device, v4l2_dev);
  118. }
  119. static int amradio_send_cmd(struct amradio_device *radio, u8 cmd, u8 arg,
  120. u8 *extra, u8 extralen, bool reply)
  121. {
  122. int retval;
  123. int size;
  124. radio->buffer[0] = 0x00;
  125. radio->buffer[1] = 0x55;
  126. radio->buffer[2] = 0xaa;
  127. radio->buffer[3] = extralen;
  128. radio->buffer[4] = cmd;
  129. radio->buffer[5] = arg;
  130. radio->buffer[6] = 0x00;
  131. radio->buffer[7] = extra || reply ? 8 : 0;
  132. retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2),
  133. radio->buffer, BUFFER_LENGTH, &size, USB_TIMEOUT);
  134. if (retval < 0 || size != BUFFER_LENGTH) {
  135. if (video_is_registered(&radio->vdev))
  136. amradio_dev_warn(&radio->vdev.dev,
  137. "cmd %02x failed\n", cmd);
  138. return retval ? retval : -EIO;
  139. }
  140. if (!extra && !reply)
  141. return 0;
  142. if (extra) {
  143. memcpy(radio->buffer, extra, extralen);
  144. memset(radio->buffer + extralen, 0, 8 - extralen);
  145. retval = usb_bulk_msg(radio->usbdev, usb_sndintpipe(radio->usbdev, 2),
  146. radio->buffer, BUFFER_LENGTH, &size, USB_TIMEOUT);
  147. } else {
  148. memset(radio->buffer, 0, 8);
  149. retval = usb_bulk_msg(radio->usbdev, usb_rcvbulkpipe(radio->usbdev, 0x81),
  150. radio->buffer, BUFFER_LENGTH, &size, USB_TIMEOUT);
  151. }
  152. if (retval == 0 && size == BUFFER_LENGTH)
  153. return 0;
  154. if (video_is_registered(&radio->vdev) && cmd != AMRADIO_GET_READY_FLAG)
  155. amradio_dev_warn(&radio->vdev.dev, "follow-up to cmd %02x failed\n", cmd);
  156. return retval ? retval : -EIO;
  157. }
  158. /* switch on/off the radio. Send 8 bytes to device */
  159. static int amradio_set_mute(struct amradio_device *radio, bool mute)
  160. {
  161. int ret = amradio_send_cmd(radio,
  162. AMRADIO_SET_MUTE, mute, NULL, 0, false);
  163. if (!ret)
  164. radio->muted = mute;
  165. return ret;
  166. }
  167. /* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */
  168. static int amradio_set_freq(struct amradio_device *radio, int freq)
  169. {
  170. unsigned short freq_send;
  171. u8 buf[3];
  172. int retval;
  173. /* we need to be sure that frequency isn't out of range */
  174. freq = clamp_t(unsigned, freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
  175. freq_send = 0x10 + (freq >> 3) / 25;
  176. /* frequency is calculated from freq_send and placed in first 2 bytes */
  177. buf[0] = (freq_send >> 8) & 0xff;
  178. buf[1] = freq_send & 0xff;
  179. buf[2] = 0x01;
  180. retval = amradio_send_cmd(radio, AMRADIO_SET_FREQ, 0, buf, 3, false);
  181. if (retval)
  182. return retval;
  183. radio->curfreq = freq;
  184. msleep(40);
  185. return 0;
  186. }
  187. static int amradio_set_stereo(struct amradio_device *radio, bool stereo)
  188. {
  189. int ret = amradio_send_cmd(radio,
  190. AMRADIO_SET_MONO, !stereo, NULL, 0, false);
  191. if (!ret)
  192. radio->stereo = stereo;
  193. return ret;
  194. }
  195. static int amradio_get_stat(struct amradio_device *radio, bool *is_stereo, u32 *signal)
  196. {
  197. int ret = amradio_send_cmd(radio,
  198. AMRADIO_GET_SIGNAL, 0, NULL, 0, true);
  199. if (ret)
  200. return ret;
  201. *is_stereo = radio->buffer[2] >> 7;
  202. *signal = (radio->buffer[3] & 0xf0) << 8;
  203. return 0;
  204. }
  205. /* Handle unplugging the device.
  206. * We call video_unregister_device in any case.
  207. * The last function called in this procedure is
  208. * usb_amradio_device_release.
  209. */
  210. static void usb_amradio_disconnect(struct usb_interface *intf)
  211. {
  212. struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
  213. mutex_lock(&radio->lock);
  214. video_unregister_device(&radio->vdev);
  215. amradio_set_mute(radio, true);
  216. usb_set_intfdata(intf, NULL);
  217. v4l2_device_disconnect(&radio->v4l2_dev);
  218. mutex_unlock(&radio->lock);
  219. v4l2_device_put(&radio->v4l2_dev);
  220. }
  221. /* vidioc_querycap - query device capabilities */
  222. static int vidioc_querycap(struct file *file, void *priv,
  223. struct v4l2_capability *v)
  224. {
  225. struct amradio_device *radio = video_drvdata(file);
  226. strscpy(v->driver, "radio-mr800", sizeof(v->driver));
  227. strscpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card));
  228. usb_make_path(radio->usbdev, v->bus_info, sizeof(v->bus_info));
  229. return 0;
  230. }
  231. /* vidioc_g_tuner - get tuner attributes */
  232. static int vidioc_g_tuner(struct file *file, void *priv,
  233. struct v4l2_tuner *v)
  234. {
  235. struct amradio_device *radio = video_drvdata(file);
  236. bool is_stereo = false;
  237. int retval;
  238. if (v->index > 0)
  239. return -EINVAL;
  240. v->signal = 0;
  241. retval = amradio_get_stat(radio, &is_stereo, &v->signal);
  242. if (retval)
  243. return retval;
  244. strscpy(v->name, "FM", sizeof(v->name));
  245. v->type = V4L2_TUNER_RADIO;
  246. v->rangelow = FREQ_MIN * FREQ_MUL;
  247. v->rangehigh = FREQ_MAX * FREQ_MUL;
  248. v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
  249. V4L2_TUNER_CAP_HWSEEK_WRAP;
  250. v->rxsubchans = is_stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
  251. v->audmode = radio->stereo ?
  252. V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO;
  253. return 0;
  254. }
  255. /* vidioc_s_tuner - set tuner attributes */
  256. static int vidioc_s_tuner(struct file *file, void *priv,
  257. const struct v4l2_tuner *v)
  258. {
  259. struct amradio_device *radio = video_drvdata(file);
  260. if (v->index > 0)
  261. return -EINVAL;
  262. /* mono/stereo selector */
  263. switch (v->audmode) {
  264. case V4L2_TUNER_MODE_MONO:
  265. return amradio_set_stereo(radio, WANT_MONO);
  266. default:
  267. return amradio_set_stereo(radio, WANT_STEREO);
  268. }
  269. }
  270. /* vidioc_s_frequency - set tuner radio frequency */
  271. static int vidioc_s_frequency(struct file *file, void *priv,
  272. const struct v4l2_frequency *f)
  273. {
  274. struct amradio_device *radio = video_drvdata(file);
  275. if (f->tuner != 0)
  276. return -EINVAL;
  277. return amradio_set_freq(radio, f->frequency);
  278. }
  279. /* vidioc_g_frequency - get tuner radio frequency */
  280. static int vidioc_g_frequency(struct file *file, void *priv,
  281. struct v4l2_frequency *f)
  282. {
  283. struct amradio_device *radio = video_drvdata(file);
  284. if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
  285. return -EINVAL;
  286. f->type = V4L2_TUNER_RADIO;
  287. f->frequency = radio->curfreq;
  288. return 0;
  289. }
  290. static int vidioc_s_hw_freq_seek(struct file *file, void *priv,
  291. const struct v4l2_hw_freq_seek *seek)
  292. {
  293. static u8 buf[8] = {
  294. 0x3d, 0x32, 0x0f, 0x08, 0x3d, 0x32, 0x0f, 0x08
  295. };
  296. struct amradio_device *radio = video_drvdata(file);
  297. unsigned long timeout;
  298. int retval;
  299. if (seek->tuner != 0 || !seek->wrap_around)
  300. return -EINVAL;
  301. if (file->f_flags & O_NONBLOCK)
  302. return -EWOULDBLOCK;
  303. retval = amradio_send_cmd(radio,
  304. AMRADIO_SET_SEARCH_LVL, 0, buf, 8, false);
  305. if (retval)
  306. return retval;
  307. amradio_set_freq(radio, radio->curfreq);
  308. retval = amradio_send_cmd(radio,
  309. seek->seek_upward ? AMRADIO_SET_SEARCH_UP : AMRADIO_SET_SEARCH_DOWN,
  310. 0, NULL, 0, false);
  311. if (retval)
  312. return retval;
  313. timeout = jiffies + msecs_to_jiffies(30000);
  314. for (;;) {
  315. if (time_after(jiffies, timeout)) {
  316. retval = -ENODATA;
  317. break;
  318. }
  319. if (schedule_timeout_interruptible(msecs_to_jiffies(10))) {
  320. retval = -ERESTARTSYS;
  321. break;
  322. }
  323. retval = amradio_send_cmd(radio, AMRADIO_GET_READY_FLAG,
  324. 0, NULL, 0, true);
  325. if (retval)
  326. continue;
  327. amradio_send_cmd(radio, AMRADIO_GET_FREQ, 0, NULL, 0, true);
  328. if (radio->buffer[1] || radio->buffer[2]) {
  329. /* To check: sometimes radio->curfreq is set to out of range value */
  330. radio->curfreq = (radio->buffer[1] << 8) | radio->buffer[2];
  331. radio->curfreq = (radio->curfreq - 0x10) * 200;
  332. amradio_send_cmd(radio, AMRADIO_STOP_SEARCH,
  333. 0, NULL, 0, false);
  334. amradio_set_freq(radio, radio->curfreq);
  335. retval = 0;
  336. break;
  337. }
  338. }
  339. amradio_send_cmd(radio, AMRADIO_STOP_SEARCH, 0, NULL, 0, false);
  340. amradio_set_freq(radio, radio->curfreq);
  341. return retval;
  342. }
  343. static int usb_amradio_s_ctrl(struct v4l2_ctrl *ctrl)
  344. {
  345. struct amradio_device *radio =
  346. container_of(ctrl->handler, struct amradio_device, hdl);
  347. switch (ctrl->id) {
  348. case V4L2_CID_AUDIO_MUTE:
  349. return amradio_set_mute(radio, ctrl->val);
  350. }
  351. return -EINVAL;
  352. }
  353. static int usb_amradio_init(struct amradio_device *radio)
  354. {
  355. int retval;
  356. retval = amradio_set_mute(radio, true);
  357. if (retval)
  358. goto out_err;
  359. retval = amradio_set_stereo(radio, true);
  360. if (retval)
  361. goto out_err;
  362. retval = amradio_set_freq(radio, radio->curfreq);
  363. if (retval)
  364. goto out_err;
  365. return 0;
  366. out_err:
  367. amradio_dev_err(&radio->vdev.dev, "initialization failed\n");
  368. return retval;
  369. }
  370. /* Suspend device - stop device. Need to be checked and fixed */
  371. static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message)
  372. {
  373. struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
  374. mutex_lock(&radio->lock);
  375. if (!radio->muted) {
  376. amradio_set_mute(radio, true);
  377. radio->muted = false;
  378. }
  379. mutex_unlock(&radio->lock);
  380. dev_info(&intf->dev, "going into suspend..\n");
  381. return 0;
  382. }
  383. /* Resume device - start device. Need to be checked and fixed */
  384. static int usb_amradio_resume(struct usb_interface *intf)
  385. {
  386. struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
  387. mutex_lock(&radio->lock);
  388. amradio_set_stereo(radio, radio->stereo);
  389. amradio_set_freq(radio, radio->curfreq);
  390. if (!radio->muted)
  391. amradio_set_mute(radio, false);
  392. mutex_unlock(&radio->lock);
  393. dev_info(&intf->dev, "coming out of suspend..\n");
  394. return 0;
  395. }
  396. static const struct v4l2_ctrl_ops usb_amradio_ctrl_ops = {
  397. .s_ctrl = usb_amradio_s_ctrl,
  398. };
  399. /* File system interface */
  400. static const struct v4l2_file_operations usb_amradio_fops = {
  401. .owner = THIS_MODULE,
  402. .open = v4l2_fh_open,
  403. .release = v4l2_fh_release,
  404. .poll = v4l2_ctrl_poll,
  405. .unlocked_ioctl = video_ioctl2,
  406. };
  407. static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = {
  408. .vidioc_querycap = vidioc_querycap,
  409. .vidioc_g_tuner = vidioc_g_tuner,
  410. .vidioc_s_tuner = vidioc_s_tuner,
  411. .vidioc_g_frequency = vidioc_g_frequency,
  412. .vidioc_s_frequency = vidioc_s_frequency,
  413. .vidioc_s_hw_freq_seek = vidioc_s_hw_freq_seek,
  414. .vidioc_log_status = v4l2_ctrl_log_status,
  415. .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
  416. .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
  417. };
  418. static void usb_amradio_release(struct v4l2_device *v4l2_dev)
  419. {
  420. struct amradio_device *radio = to_amradio_dev(v4l2_dev);
  421. /* free rest memory */
  422. v4l2_ctrl_handler_free(&radio->hdl);
  423. v4l2_device_unregister(&radio->v4l2_dev);
  424. kfree(radio->buffer);
  425. kfree(radio);
  426. }
  427. /* check if the device is present and register with v4l and usb if it is */
  428. static int usb_amradio_probe(struct usb_interface *intf,
  429. const struct usb_device_id *id)
  430. {
  431. struct amradio_device *radio;
  432. int retval;
  433. radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL);
  434. if (!radio) {
  435. dev_err(&intf->dev, "kmalloc for amradio_device failed\n");
  436. retval = -ENOMEM;
  437. goto err;
  438. }
  439. radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL);
  440. if (!radio->buffer) {
  441. dev_err(&intf->dev, "kmalloc for radio->buffer failed\n");
  442. retval = -ENOMEM;
  443. goto err_nobuf;
  444. }
  445. retval = v4l2_device_register(&intf->dev, &radio->v4l2_dev);
  446. if (retval < 0) {
  447. dev_err(&intf->dev, "couldn't register v4l2_device\n");
  448. goto err_v4l2;
  449. }
  450. v4l2_ctrl_handler_init(&radio->hdl, 1);
  451. v4l2_ctrl_new_std(&radio->hdl, &usb_amradio_ctrl_ops,
  452. V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
  453. if (radio->hdl.error) {
  454. retval = radio->hdl.error;
  455. dev_err(&intf->dev, "couldn't register control\n");
  456. goto err_ctrl;
  457. }
  458. mutex_init(&radio->lock);
  459. radio->v4l2_dev.ctrl_handler = &radio->hdl;
  460. radio->v4l2_dev.release = usb_amradio_release;
  461. strscpy(radio->vdev.name, radio->v4l2_dev.name,
  462. sizeof(radio->vdev.name));
  463. radio->vdev.v4l2_dev = &radio->v4l2_dev;
  464. radio->vdev.fops = &usb_amradio_fops;
  465. radio->vdev.ioctl_ops = &usb_amradio_ioctl_ops;
  466. radio->vdev.release = video_device_release_empty;
  467. radio->vdev.lock = &radio->lock;
  468. radio->vdev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER |
  469. V4L2_CAP_HW_FREQ_SEEK;
  470. radio->usbdev = interface_to_usbdev(intf);
  471. radio->intf = intf;
  472. usb_set_intfdata(intf, &radio->v4l2_dev);
  473. radio->curfreq = 95.16 * FREQ_MUL;
  474. video_set_drvdata(&radio->vdev, radio);
  475. retval = usb_amradio_init(radio);
  476. if (retval)
  477. goto err_vdev;
  478. retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO,
  479. radio_nr);
  480. if (retval < 0) {
  481. dev_err(&intf->dev, "could not register video device\n");
  482. goto err_vdev;
  483. }
  484. return 0;
  485. err_vdev:
  486. v4l2_ctrl_handler_free(&radio->hdl);
  487. err_ctrl:
  488. v4l2_device_unregister(&radio->v4l2_dev);
  489. err_v4l2:
  490. kfree(radio->buffer);
  491. err_nobuf:
  492. kfree(radio);
  493. err:
  494. return retval;
  495. }
  496. /* USB Device ID List */
  497. static const struct usb_device_id usb_amradio_device_table[] = {
  498. { USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT,
  499. USB_CLASS_HID, 0, 0) },
  500. { } /* Terminating entry */
  501. };
  502. MODULE_DEVICE_TABLE(usb, usb_amradio_device_table);
  503. /* USB subsystem interface */
  504. static struct usb_driver usb_amradio_driver = {
  505. .name = MR800_DRIVER_NAME,
  506. .probe = usb_amradio_probe,
  507. .disconnect = usb_amradio_disconnect,
  508. .suspend = usb_amradio_suspend,
  509. .resume = usb_amradio_resume,
  510. .reset_resume = usb_amradio_resume,
  511. .id_table = usb_amradio_device_table,
  512. };
  513. module_usb_driver(usb_amradio_driver);