redrat3.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * USB RedRat3 IR Transceiver rc-core driver
  4. *
  5. * Copyright (c) 2011 by Jarod Wilson <jarod@redhat.com>
  6. * based heavily on the work of Stephen Cox, with additional
  7. * help from RedRat Ltd.
  8. *
  9. * This driver began life based an an old version of the first-generation
  10. * lirc_mceusb driver from the lirc 0.7.2 distribution. It was then
  11. * significantly rewritten by Stephen Cox with the aid of RedRat Ltd's
  12. * Chris Dodge.
  13. *
  14. * The driver was then ported to rc-core and significantly rewritten again,
  15. * by Jarod, using the in-kernel mceusb driver as a guide, after an initial
  16. * port effort was started by Stephen.
  17. *
  18. * TODO LIST:
  19. * - fix lirc not showing repeats properly
  20. * --
  21. *
  22. * The RedRat3 is a USB transceiver with both send & receive,
  23. * with 2 separate sensors available for receive to enable
  24. * both good long range reception for general use, and good
  25. * short range reception when required for learning a signal.
  26. *
  27. * http://www.redrat.co.uk/
  28. *
  29. * It uses its own little protocol to communicate, the required
  30. * parts of which are embedded within this driver.
  31. * --
  32. */
  33. #include <asm/unaligned.h>
  34. #include <linux/device.h>
  35. #include <linux/leds.h>
  36. #include <linux/module.h>
  37. #include <linux/slab.h>
  38. #include <linux/usb.h>
  39. #include <linux/usb/input.h>
  40. #include <media/rc-core.h>
  41. /* Driver Information */
  42. #define DRIVER_AUTHOR "Jarod Wilson <jarod@redhat.com>"
  43. #define DRIVER_AUTHOR2 "The Dweller, Stephen Cox"
  44. #define DRIVER_DESC "RedRat3 USB IR Transceiver Driver"
  45. #define DRIVER_NAME "redrat3"
  46. /* bulk data transfer types */
  47. #define RR3_ERROR 0x01
  48. #define RR3_MOD_SIGNAL_IN 0x20
  49. #define RR3_MOD_SIGNAL_OUT 0x21
  50. /* Get the RR firmware version */
  51. #define RR3_FW_VERSION 0xb1
  52. #define RR3_FW_VERSION_LEN 64
  53. /* Send encoded signal bulk-sent earlier*/
  54. #define RR3_TX_SEND_SIGNAL 0xb3
  55. #define RR3_SET_IR_PARAM 0xb7
  56. #define RR3_GET_IR_PARAM 0xb8
  57. /* Blink the red LED on the device */
  58. #define RR3_BLINK_LED 0xb9
  59. /* Read serial number of device */
  60. #define RR3_READ_SER_NO 0xba
  61. #define RR3_SER_NO_LEN 4
  62. /* Start capture with the RC receiver */
  63. #define RR3_RC_DET_ENABLE 0xbb
  64. /* Stop capture with the RC receiver */
  65. #define RR3_RC_DET_DISABLE 0xbc
  66. /* Start capture with the wideband receiver */
  67. #define RR3_MODSIG_CAPTURE 0xb2
  68. /* Return the status of RC detector capture */
  69. #define RR3_RC_DET_STATUS 0xbd
  70. /* Reset redrat */
  71. #define RR3_RESET 0xa0
  72. /* Max number of lengths in the signal. */
  73. #define RR3_IR_IO_MAX_LENGTHS 0x01
  74. /* Periods to measure mod. freq. */
  75. #define RR3_IR_IO_PERIODS_MF 0x02
  76. /* Size of memory for main signal data */
  77. #define RR3_IR_IO_SIG_MEM_SIZE 0x03
  78. /* Delta value when measuring lengths */
  79. #define RR3_IR_IO_LENGTH_FUZZ 0x04
  80. /* Timeout for end of signal detection */
  81. #define RR3_IR_IO_SIG_TIMEOUT 0x05
  82. /* Minimum value for pause recognition. */
  83. #define RR3_IR_IO_MIN_PAUSE 0x06
  84. /* Clock freq. of EZ-USB chip */
  85. #define RR3_CLK 24000000
  86. /* Clock periods per timer count */
  87. #define RR3_CLK_PER_COUNT 12
  88. /* (RR3_CLK / RR3_CLK_PER_COUNT) */
  89. #define RR3_CLK_CONV_FACTOR 2000000
  90. /* USB bulk-in wideband IR data endpoint address */
  91. #define RR3_WIDE_IN_EP_ADDR 0x81
  92. /* USB bulk-in narrowband IR data endpoint address */
  93. #define RR3_NARROW_IN_EP_ADDR 0x82
  94. /* Size of the fixed-length portion of the signal */
  95. #define RR3_DRIVER_MAXLENS 255
  96. #define RR3_MAX_SIG_SIZE 512
  97. #define RR3_TIME_UNIT 50
  98. #define RR3_END_OF_SIGNAL 0x7f
  99. #define RR3_TX_TRAILER_LEN 2
  100. #define RR3_RX_MIN_TIMEOUT 5
  101. #define RR3_RX_MAX_TIMEOUT 2000
  102. /* The 8051's CPUCS Register address */
  103. #define RR3_CPUCS_REG_ADDR 0x7f92
  104. #define USB_RR3USB_VENDOR_ID 0x112a
  105. #define USB_RR3USB_PRODUCT_ID 0x0001
  106. #define USB_RR3IIUSB_PRODUCT_ID 0x0005
  107. /*
  108. * The redrat3 encodes an IR signal as set of different lengths and a set
  109. * of indices into those lengths. This sets how much two lengths must
  110. * differ before they are considered distinct, the value is specified
  111. * in microseconds.
  112. * Default 5, value 0 to 127.
  113. */
  114. static int length_fuzz = 5;
  115. module_param(length_fuzz, uint, 0644);
  116. MODULE_PARM_DESC(length_fuzz, "Length Fuzz (0-127)");
  117. /*
  118. * When receiving a continuous ir stream (for example when a user is
  119. * holding a button down on a remote), this specifies the minimum size
  120. * of a space when the redrat3 sends a irdata packet to the host. Specified
  121. * in milliseconds. Default value 18ms.
  122. * The value can be between 2 and 30 inclusive.
  123. */
  124. static int minimum_pause = 18;
  125. module_param(minimum_pause, uint, 0644);
  126. MODULE_PARM_DESC(minimum_pause, "Minimum Pause in ms (2-30)");
  127. /*
  128. * The carrier frequency is measured during the first pulse of the IR
  129. * signal. The larger the number of periods used To measure, the more
  130. * accurate the result is likely to be, however some signals have short
  131. * initial pulses, so in some case it may be necessary to reduce this value.
  132. * Default 8, value 1 to 255.
  133. */
  134. static int periods_measure_carrier = 8;
  135. module_param(periods_measure_carrier, uint, 0644);
  136. MODULE_PARM_DESC(periods_measure_carrier, "Number of Periods to Measure Carrier (1-255)");
  137. struct redrat3_header {
  138. __be16 length;
  139. __be16 transfer_type;
  140. } __packed;
  141. /* sending and receiving irdata */
  142. struct redrat3_irdata {
  143. struct redrat3_header header;
  144. __be32 pause;
  145. __be16 mod_freq_count;
  146. __be16 num_periods;
  147. __u8 max_lengths;
  148. __u8 no_lengths;
  149. __be16 max_sig_size;
  150. __be16 sig_size;
  151. __u8 no_repeats;
  152. __be16 lens[RR3_DRIVER_MAXLENS]; /* not aligned */
  153. __u8 sigdata[RR3_MAX_SIG_SIZE];
  154. } __packed;
  155. /* firmware errors */
  156. struct redrat3_error {
  157. struct redrat3_header header;
  158. __be16 fw_error;
  159. } __packed;
  160. /* table of devices that work with this driver */
  161. static const struct usb_device_id redrat3_dev_table[] = {
  162. /* Original version of the RedRat3 */
  163. {USB_DEVICE(USB_RR3USB_VENDOR_ID, USB_RR3USB_PRODUCT_ID)},
  164. /* Second Version/release of the RedRat3 - RetRat3-II */
  165. {USB_DEVICE(USB_RR3USB_VENDOR_ID, USB_RR3IIUSB_PRODUCT_ID)},
  166. {} /* Terminating entry */
  167. };
  168. /* Structure to hold all of our device specific stuff */
  169. struct redrat3_dev {
  170. /* core device bits */
  171. struct rc_dev *rc;
  172. struct device *dev;
  173. /* led control */
  174. struct led_classdev led;
  175. atomic_t flash;
  176. struct usb_ctrlrequest flash_control;
  177. struct urb *flash_urb;
  178. u8 flash_in_buf;
  179. /* learning */
  180. bool wideband;
  181. struct usb_ctrlrequest learn_control;
  182. struct urb *learn_urb;
  183. u8 learn_buf;
  184. /* save off the usb device pointer */
  185. struct usb_device *udev;
  186. /* the receive endpoint */
  187. struct usb_endpoint_descriptor *ep_narrow;
  188. /* the buffer to receive data */
  189. void *bulk_in_buf;
  190. /* urb used to read ir data */
  191. struct urb *narrow_urb;
  192. struct urb *wide_urb;
  193. /* the send endpoint */
  194. struct usb_endpoint_descriptor *ep_out;
  195. /* usb dma */
  196. dma_addr_t dma_in;
  197. /* Is the device currently transmitting?*/
  198. bool transmitting;
  199. /* store for current packet */
  200. struct redrat3_irdata irdata;
  201. u16 bytes_read;
  202. u32 carrier;
  203. char name[64];
  204. char phys[64];
  205. };
  206. static void redrat3_dump_fw_error(struct redrat3_dev *rr3, int code)
  207. {
  208. if (!rr3->transmitting && (code != 0x40))
  209. dev_info(rr3->dev, "fw error code 0x%02x: ", code);
  210. switch (code) {
  211. case 0x00:
  212. pr_cont("No Error\n");
  213. break;
  214. /* Codes 0x20 through 0x2f are IR Firmware Errors */
  215. case 0x20:
  216. pr_cont("Initial signal pulse not long enough to measure carrier frequency\n");
  217. break;
  218. case 0x21:
  219. pr_cont("Not enough length values allocated for signal\n");
  220. break;
  221. case 0x22:
  222. pr_cont("Not enough memory allocated for signal data\n");
  223. break;
  224. case 0x23:
  225. pr_cont("Too many signal repeats\n");
  226. break;
  227. case 0x28:
  228. pr_cont("Insufficient memory available for IR signal data memory allocation\n");
  229. break;
  230. case 0x29:
  231. pr_cont("Insufficient memory available for IrDa signal data memory allocation\n");
  232. break;
  233. /* Codes 0x30 through 0x3f are USB Firmware Errors */
  234. case 0x30:
  235. pr_cont("Insufficient memory available for bulk transfer structure\n");
  236. break;
  237. /*
  238. * Other error codes... These are primarily errors that can occur in
  239. * the control messages sent to the redrat
  240. */
  241. case 0x40:
  242. if (!rr3->transmitting)
  243. pr_cont("Signal capture has been terminated\n");
  244. break;
  245. case 0x41:
  246. pr_cont("Attempt to set/get and unknown signal I/O algorithm parameter\n");
  247. break;
  248. case 0x42:
  249. pr_cont("Signal capture already started\n");
  250. break;
  251. default:
  252. pr_cont("Unknown Error\n");
  253. break;
  254. }
  255. }
  256. static u32 redrat3_val_to_mod_freq(struct redrat3_irdata *irdata)
  257. {
  258. u32 mod_freq = 0;
  259. u16 mod_freq_count = be16_to_cpu(irdata->mod_freq_count);
  260. if (mod_freq_count != 0)
  261. mod_freq = (RR3_CLK * be16_to_cpu(irdata->num_periods)) /
  262. (mod_freq_count * RR3_CLK_PER_COUNT);
  263. return mod_freq;
  264. }
  265. /* this function scales down the figures for the same result... */
  266. static u32 redrat3_len_to_us(u32 length)
  267. {
  268. u32 biglen = length * 1000;
  269. u32 divisor = (RR3_CLK_CONV_FACTOR) / 1000;
  270. u32 result = (u32) (biglen / divisor);
  271. /* don't allow zero lengths to go back, breaks lirc */
  272. return result ? result : 1;
  273. }
  274. /*
  275. * convert us back into redrat3 lengths
  276. *
  277. * length * 1000 length * 1000000
  278. * ------------- = ---------------- = micro
  279. * rr3clk / 1000 rr3clk
  280. * 6 * 2 4 * 3 micro * rr3clk micro * rr3clk / 1000
  281. * ----- = 4 ----- = 6 -------------- = len ---------------------
  282. * 3 2 1000000 1000
  283. */
  284. static u32 redrat3_us_to_len(u32 microsec)
  285. {
  286. u32 result;
  287. u32 divisor;
  288. microsec = (microsec > IR_MAX_DURATION) ? IR_MAX_DURATION : microsec;
  289. divisor = (RR3_CLK_CONV_FACTOR / 1000);
  290. result = (u32)(microsec * divisor) / 1000;
  291. /* don't allow zero lengths to go back, breaks lirc */
  292. return result ? result : 1;
  293. }
  294. static void redrat3_process_ir_data(struct redrat3_dev *rr3)
  295. {
  296. struct ir_raw_event rawir = {};
  297. struct device *dev;
  298. unsigned int i, sig_size, offset, val;
  299. u32 mod_freq;
  300. dev = rr3->dev;
  301. mod_freq = redrat3_val_to_mod_freq(&rr3->irdata);
  302. dev_dbg(dev, "Got mod_freq of %u\n", mod_freq);
  303. if (mod_freq && rr3->wideband) {
  304. struct ir_raw_event ev = {
  305. .carrier_report = 1,
  306. .carrier = mod_freq
  307. };
  308. ir_raw_event_store(rr3->rc, &ev);
  309. }
  310. /* process each rr3 encoded byte into an int */
  311. sig_size = be16_to_cpu(rr3->irdata.sig_size);
  312. for (i = 0; i < sig_size; i++) {
  313. offset = rr3->irdata.sigdata[i];
  314. val = get_unaligned_be16(&rr3->irdata.lens[offset]);
  315. /* we should always get pulse/space/pulse/space samples */
  316. if (i % 2)
  317. rawir.pulse = false;
  318. else
  319. rawir.pulse = true;
  320. rawir.duration = redrat3_len_to_us(val);
  321. /* cap the value to IR_MAX_DURATION */
  322. rawir.duration = (rawir.duration > IR_MAX_DURATION) ?
  323. IR_MAX_DURATION : rawir.duration;
  324. dev_dbg(dev, "storing %s with duration %d (i: %d)\n",
  325. rawir.pulse ? "pulse" : "space", rawir.duration, i);
  326. ir_raw_event_store_with_filter(rr3->rc, &rawir);
  327. }
  328. /* add a trailing space */
  329. rawir.pulse = false;
  330. rawir.timeout = true;
  331. rawir.duration = rr3->rc->timeout;
  332. dev_dbg(dev, "storing trailing timeout with duration %d\n",
  333. rawir.duration);
  334. ir_raw_event_store_with_filter(rr3->rc, &rawir);
  335. dev_dbg(dev, "calling ir_raw_event_handle\n");
  336. ir_raw_event_handle(rr3->rc);
  337. }
  338. /* Util fn to send rr3 cmds */
  339. static int redrat3_send_cmd(int cmd, struct redrat3_dev *rr3)
  340. {
  341. struct usb_device *udev;
  342. u8 *data;
  343. int res;
  344. data = kzalloc(sizeof(u8), GFP_KERNEL);
  345. if (!data)
  346. return -ENOMEM;
  347. udev = rr3->udev;
  348. res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), cmd,
  349. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  350. 0x0000, 0x0000, data, sizeof(u8), 10000);
  351. if (res < 0) {
  352. dev_err(rr3->dev, "%s: Error sending rr3 cmd res %d, data %d",
  353. __func__, res, *data);
  354. res = -EIO;
  355. } else
  356. res = data[0];
  357. kfree(data);
  358. return res;
  359. }
  360. /* Enables the long range detector and starts async receive */
  361. static int redrat3_enable_detector(struct redrat3_dev *rr3)
  362. {
  363. struct device *dev = rr3->dev;
  364. u8 ret;
  365. ret = redrat3_send_cmd(RR3_RC_DET_ENABLE, rr3);
  366. if (ret != 0)
  367. dev_dbg(dev, "%s: unexpected ret of %d\n",
  368. __func__, ret);
  369. ret = redrat3_send_cmd(RR3_RC_DET_STATUS, rr3);
  370. if (ret != 1) {
  371. dev_err(dev, "%s: detector status: %d, should be 1\n",
  372. __func__, ret);
  373. return -EIO;
  374. }
  375. ret = usb_submit_urb(rr3->narrow_urb, GFP_KERNEL);
  376. if (ret) {
  377. dev_err(rr3->dev, "narrow band urb failed: %d", ret);
  378. return ret;
  379. }
  380. ret = usb_submit_urb(rr3->wide_urb, GFP_KERNEL);
  381. if (ret)
  382. dev_err(rr3->dev, "wide band urb failed: %d", ret);
  383. return ret;
  384. }
  385. static inline void redrat3_delete(struct redrat3_dev *rr3,
  386. struct usb_device *udev)
  387. {
  388. usb_kill_urb(rr3->narrow_urb);
  389. usb_kill_urb(rr3->wide_urb);
  390. usb_kill_urb(rr3->flash_urb);
  391. usb_kill_urb(rr3->learn_urb);
  392. usb_free_urb(rr3->narrow_urb);
  393. usb_free_urb(rr3->wide_urb);
  394. usb_free_urb(rr3->flash_urb);
  395. usb_free_urb(rr3->learn_urb);
  396. usb_free_coherent(udev, le16_to_cpu(rr3->ep_narrow->wMaxPacketSize),
  397. rr3->bulk_in_buf, rr3->dma_in);
  398. kfree(rr3);
  399. }
  400. static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
  401. {
  402. __be32 *tmp;
  403. u32 timeout = MS_TO_US(150); /* a sane default, if things go haywire */
  404. int len, ret, pipe;
  405. len = sizeof(*tmp);
  406. tmp = kzalloc(len, GFP_KERNEL);
  407. if (!tmp)
  408. return timeout;
  409. pipe = usb_rcvctrlpipe(rr3->udev, 0);
  410. ret = usb_control_msg(rr3->udev, pipe, RR3_GET_IR_PARAM,
  411. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  412. RR3_IR_IO_SIG_TIMEOUT, 0, tmp, len, 5000);
  413. if (ret != len)
  414. dev_warn(rr3->dev, "Failed to read timeout from hardware\n");
  415. else {
  416. timeout = redrat3_len_to_us(be32_to_cpup(tmp));
  417. dev_dbg(rr3->dev, "Got timeout of %d ms\n", timeout / 1000);
  418. }
  419. kfree(tmp);
  420. return timeout;
  421. }
  422. static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutus)
  423. {
  424. struct redrat3_dev *rr3 = rc_dev->priv;
  425. struct usb_device *udev = rr3->udev;
  426. struct device *dev = rr3->dev;
  427. __be32 *timeout;
  428. int ret;
  429. timeout = kmalloc(sizeof(*timeout), GFP_KERNEL);
  430. if (!timeout)
  431. return -ENOMEM;
  432. *timeout = cpu_to_be32(redrat3_us_to_len(timeoutus));
  433. ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RR3_SET_IR_PARAM,
  434. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  435. RR3_IR_IO_SIG_TIMEOUT, 0, timeout, sizeof(*timeout),
  436. 25000);
  437. dev_dbg(dev, "set ir parm timeout %d ret 0x%02x\n",
  438. be32_to_cpu(*timeout), ret);
  439. if (ret == sizeof(*timeout))
  440. ret = 0;
  441. else if (ret >= 0)
  442. ret = -EIO;
  443. kfree(timeout);
  444. return ret;
  445. }
  446. static void redrat3_reset(struct redrat3_dev *rr3)
  447. {
  448. struct usb_device *udev = rr3->udev;
  449. struct device *dev = rr3->dev;
  450. int rc, rxpipe, txpipe;
  451. u8 *val;
  452. size_t const len = sizeof(*val);
  453. rxpipe = usb_rcvctrlpipe(udev, 0);
  454. txpipe = usb_sndctrlpipe(udev, 0);
  455. val = kmalloc(len, GFP_KERNEL);
  456. if (!val)
  457. return;
  458. *val = 0x01;
  459. rc = usb_control_msg(udev, rxpipe, RR3_RESET,
  460. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  461. RR3_CPUCS_REG_ADDR, 0, val, len, 25000);
  462. dev_dbg(dev, "reset returned 0x%02x\n", rc);
  463. *val = length_fuzz;
  464. rc = usb_control_msg(udev, txpipe, RR3_SET_IR_PARAM,
  465. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  466. RR3_IR_IO_LENGTH_FUZZ, 0, val, len, 25000);
  467. dev_dbg(dev, "set ir parm len fuzz %d rc 0x%02x\n", *val, rc);
  468. *val = (65536 - (minimum_pause * 2000)) / 256;
  469. rc = usb_control_msg(udev, txpipe, RR3_SET_IR_PARAM,
  470. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  471. RR3_IR_IO_MIN_PAUSE, 0, val, len, 25000);
  472. dev_dbg(dev, "set ir parm min pause %d rc 0x%02x\n", *val, rc);
  473. *val = periods_measure_carrier;
  474. rc = usb_control_msg(udev, txpipe, RR3_SET_IR_PARAM,
  475. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  476. RR3_IR_IO_PERIODS_MF, 0, val, len, 25000);
  477. dev_dbg(dev, "set ir parm periods measure carrier %d rc 0x%02x", *val,
  478. rc);
  479. *val = RR3_DRIVER_MAXLENS;
  480. rc = usb_control_msg(udev, txpipe, RR3_SET_IR_PARAM,
  481. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  482. RR3_IR_IO_MAX_LENGTHS, 0, val, len, 25000);
  483. dev_dbg(dev, "set ir parm max lens %d rc 0x%02x\n", *val, rc);
  484. kfree(val);
  485. }
  486. static void redrat3_get_firmware_rev(struct redrat3_dev *rr3)
  487. {
  488. int rc;
  489. char *buffer;
  490. buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL);
  491. if (!buffer)
  492. return;
  493. rc = usb_control_msg(rr3->udev, usb_rcvctrlpipe(rr3->udev, 0),
  494. RR3_FW_VERSION,
  495. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  496. 0, 0, buffer, RR3_FW_VERSION_LEN, 5000);
  497. if (rc >= 0)
  498. dev_info(rr3->dev, "Firmware rev: %s", buffer);
  499. else
  500. dev_err(rr3->dev, "Problem fetching firmware ID\n");
  501. kfree(buffer);
  502. }
  503. static void redrat3_read_packet_start(struct redrat3_dev *rr3, unsigned len)
  504. {
  505. struct redrat3_header *header = rr3->bulk_in_buf;
  506. unsigned pktlen, pkttype;
  507. /* grab the Length and type of transfer */
  508. pktlen = be16_to_cpu(header->length);
  509. pkttype = be16_to_cpu(header->transfer_type);
  510. if (pktlen > sizeof(rr3->irdata)) {
  511. dev_warn(rr3->dev, "packet length %u too large\n", pktlen);
  512. return;
  513. }
  514. switch (pkttype) {
  515. case RR3_ERROR:
  516. if (len >= sizeof(struct redrat3_error)) {
  517. struct redrat3_error *error = rr3->bulk_in_buf;
  518. unsigned fw_error = be16_to_cpu(error->fw_error);
  519. redrat3_dump_fw_error(rr3, fw_error);
  520. }
  521. break;
  522. case RR3_MOD_SIGNAL_IN:
  523. memcpy(&rr3->irdata, rr3->bulk_in_buf, len);
  524. rr3->bytes_read = len;
  525. dev_dbg(rr3->dev, "bytes_read %d, pktlen %d\n",
  526. rr3->bytes_read, pktlen);
  527. break;
  528. default:
  529. dev_dbg(rr3->dev, "ignoring packet with type 0x%02x, len of %d, 0x%02x\n",
  530. pkttype, len, pktlen);
  531. break;
  532. }
  533. }
  534. static void redrat3_read_packet_continue(struct redrat3_dev *rr3, unsigned len)
  535. {
  536. void *irdata = &rr3->irdata;
  537. if (len + rr3->bytes_read > sizeof(rr3->irdata)) {
  538. dev_warn(rr3->dev, "too much data for packet\n");
  539. rr3->bytes_read = 0;
  540. return;
  541. }
  542. memcpy(irdata + rr3->bytes_read, rr3->bulk_in_buf, len);
  543. rr3->bytes_read += len;
  544. dev_dbg(rr3->dev, "bytes_read %d, pktlen %d\n", rr3->bytes_read,
  545. be16_to_cpu(rr3->irdata.header.length));
  546. }
  547. /* gather IR data from incoming urb, process it when we have enough */
  548. static int redrat3_get_ir_data(struct redrat3_dev *rr3, unsigned len)
  549. {
  550. struct device *dev = rr3->dev;
  551. unsigned pkttype;
  552. int ret = 0;
  553. if (rr3->bytes_read == 0 && len >= sizeof(struct redrat3_header)) {
  554. redrat3_read_packet_start(rr3, len);
  555. } else if (rr3->bytes_read != 0) {
  556. redrat3_read_packet_continue(rr3, len);
  557. } else if (rr3->bytes_read == 0) {
  558. dev_err(dev, "error: no packet data read\n");
  559. ret = -ENODATA;
  560. goto out;
  561. }
  562. if (rr3->bytes_read < be16_to_cpu(rr3->irdata.header.length) +
  563. sizeof(struct redrat3_header))
  564. /* we're still accumulating data */
  565. return 0;
  566. /* if we get here, we've got IR data to decode */
  567. pkttype = be16_to_cpu(rr3->irdata.header.transfer_type);
  568. if (pkttype == RR3_MOD_SIGNAL_IN)
  569. redrat3_process_ir_data(rr3);
  570. else
  571. dev_dbg(dev, "discarding non-signal data packet (type 0x%02x)\n",
  572. pkttype);
  573. out:
  574. rr3->bytes_read = 0;
  575. return ret;
  576. }
  577. /* callback function from USB when async USB request has completed */
  578. static void redrat3_handle_async(struct urb *urb)
  579. {
  580. struct redrat3_dev *rr3 = urb->context;
  581. int ret;
  582. switch (urb->status) {
  583. case 0:
  584. ret = redrat3_get_ir_data(rr3, urb->actual_length);
  585. if (!ret && rr3->wideband && !rr3->learn_urb->hcpriv) {
  586. ret = usb_submit_urb(rr3->learn_urb, GFP_ATOMIC);
  587. if (ret)
  588. dev_err(rr3->dev, "Failed to submit learning urb: %d",
  589. ret);
  590. }
  591. if (!ret) {
  592. /* no error, prepare to read more */
  593. ret = usb_submit_urb(urb, GFP_ATOMIC);
  594. if (ret)
  595. dev_err(rr3->dev, "Failed to resubmit urb: %d",
  596. ret);
  597. }
  598. break;
  599. case -ECONNRESET:
  600. case -ENOENT:
  601. case -ESHUTDOWN:
  602. usb_unlink_urb(urb);
  603. return;
  604. case -EPIPE:
  605. default:
  606. dev_warn(rr3->dev, "Error: urb status = %d\n", urb->status);
  607. rr3->bytes_read = 0;
  608. break;
  609. }
  610. }
  611. static u16 mod_freq_to_val(unsigned int mod_freq)
  612. {
  613. int mult = 6000000;
  614. /* Clk used in mod. freq. generation is CLK24/4. */
  615. return 65536 - (mult / mod_freq);
  616. }
  617. static int redrat3_set_tx_carrier(struct rc_dev *rcdev, u32 carrier)
  618. {
  619. struct redrat3_dev *rr3 = rcdev->priv;
  620. struct device *dev = rr3->dev;
  621. dev_dbg(dev, "Setting modulation frequency to %u", carrier);
  622. if (carrier == 0)
  623. return -EINVAL;
  624. rr3->carrier = carrier;
  625. return 0;
  626. }
  627. static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
  628. unsigned count)
  629. {
  630. struct redrat3_dev *rr3 = rcdev->priv;
  631. struct device *dev = rr3->dev;
  632. struct redrat3_irdata *irdata = NULL;
  633. int ret, ret_len;
  634. int lencheck, cur_sample_len, pipe;
  635. int *sample_lens = NULL;
  636. u8 curlencheck = 0;
  637. unsigned i, sendbuf_len;
  638. if (rr3->transmitting) {
  639. dev_warn(dev, "%s: transmitter already in use\n", __func__);
  640. return -EAGAIN;
  641. }
  642. if (count > RR3_MAX_SIG_SIZE - RR3_TX_TRAILER_LEN)
  643. return -EINVAL;
  644. /* rr3 will disable rc detector on transmit */
  645. rr3->transmitting = true;
  646. sample_lens = kcalloc(RR3_DRIVER_MAXLENS,
  647. sizeof(*sample_lens),
  648. GFP_KERNEL);
  649. if (!sample_lens)
  650. return -ENOMEM;
  651. irdata = kzalloc(sizeof(*irdata), GFP_KERNEL);
  652. if (!irdata) {
  653. ret = -ENOMEM;
  654. goto out;
  655. }
  656. for (i = 0; i < count; i++) {
  657. cur_sample_len = redrat3_us_to_len(txbuf[i]);
  658. if (cur_sample_len > 0xffff) {
  659. dev_warn(dev, "transmit period of %uus truncated to %uus\n",
  660. txbuf[i], redrat3_len_to_us(0xffff));
  661. cur_sample_len = 0xffff;
  662. }
  663. for (lencheck = 0; lencheck < curlencheck; lencheck++) {
  664. if (sample_lens[lencheck] == cur_sample_len)
  665. break;
  666. }
  667. if (lencheck == curlencheck) {
  668. dev_dbg(dev, "txbuf[%d]=%u, pos %d, enc %u\n",
  669. i, txbuf[i], curlencheck, cur_sample_len);
  670. if (curlencheck < RR3_DRIVER_MAXLENS) {
  671. /* now convert the value to a proper
  672. * rr3 value.. */
  673. sample_lens[curlencheck] = cur_sample_len;
  674. put_unaligned_be16(cur_sample_len,
  675. &irdata->lens[curlencheck]);
  676. curlencheck++;
  677. } else {
  678. ret = -EINVAL;
  679. goto out;
  680. }
  681. }
  682. irdata->sigdata[i] = lencheck;
  683. }
  684. irdata->sigdata[count] = RR3_END_OF_SIGNAL;
  685. irdata->sigdata[count + 1] = RR3_END_OF_SIGNAL;
  686. sendbuf_len = offsetof(struct redrat3_irdata,
  687. sigdata[count + RR3_TX_TRAILER_LEN]);
  688. /* fill in our packet header */
  689. irdata->header.length = cpu_to_be16(sendbuf_len -
  690. sizeof(struct redrat3_header));
  691. irdata->header.transfer_type = cpu_to_be16(RR3_MOD_SIGNAL_OUT);
  692. irdata->pause = cpu_to_be32(redrat3_len_to_us(100));
  693. irdata->mod_freq_count = cpu_to_be16(mod_freq_to_val(rr3->carrier));
  694. irdata->no_lengths = curlencheck;
  695. irdata->sig_size = cpu_to_be16(count + RR3_TX_TRAILER_LEN);
  696. pipe = usb_sndbulkpipe(rr3->udev, rr3->ep_out->bEndpointAddress);
  697. ret = usb_bulk_msg(rr3->udev, pipe, irdata,
  698. sendbuf_len, &ret_len, 10000);
  699. dev_dbg(dev, "sent %d bytes, (ret %d)\n", ret_len, ret);
  700. /* now tell the hardware to transmit what we sent it */
  701. pipe = usb_rcvctrlpipe(rr3->udev, 0);
  702. ret = usb_control_msg(rr3->udev, pipe, RR3_TX_SEND_SIGNAL,
  703. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  704. 0, 0, irdata, 2, 10000);
  705. if (ret < 0)
  706. dev_err(dev, "Error: control msg send failed, rc %d\n", ret);
  707. else
  708. ret = count;
  709. out:
  710. kfree(irdata);
  711. kfree(sample_lens);
  712. rr3->transmitting = false;
  713. /* rr3 re-enables rc detector because it was enabled before */
  714. return ret;
  715. }
  716. static void redrat3_brightness_set(struct led_classdev *led_dev, enum
  717. led_brightness brightness)
  718. {
  719. struct redrat3_dev *rr3 = container_of(led_dev, struct redrat3_dev,
  720. led);
  721. if (brightness != LED_OFF && atomic_cmpxchg(&rr3->flash, 0, 1) == 0) {
  722. int ret = usb_submit_urb(rr3->flash_urb, GFP_ATOMIC);
  723. if (ret != 0) {
  724. dev_dbg(rr3->dev, "%s: unexpected ret of %d\n",
  725. __func__, ret);
  726. atomic_set(&rr3->flash, 0);
  727. }
  728. }
  729. }
  730. static int redrat3_wideband_receiver(struct rc_dev *rcdev, int enable)
  731. {
  732. struct redrat3_dev *rr3 = rcdev->priv;
  733. int ret = 0;
  734. rr3->wideband = enable != 0;
  735. if (enable) {
  736. ret = usb_submit_urb(rr3->learn_urb, GFP_KERNEL);
  737. if (ret)
  738. dev_err(rr3->dev, "Failed to submit learning urb: %d",
  739. ret);
  740. }
  741. return ret;
  742. }
  743. static void redrat3_learn_complete(struct urb *urb)
  744. {
  745. struct redrat3_dev *rr3 = urb->context;
  746. switch (urb->status) {
  747. case 0:
  748. break;
  749. case -ECONNRESET:
  750. case -ENOENT:
  751. case -ESHUTDOWN:
  752. usb_unlink_urb(urb);
  753. return;
  754. case -EPIPE:
  755. default:
  756. dev_err(rr3->dev, "Error: learn urb status = %d", urb->status);
  757. break;
  758. }
  759. }
  760. static void redrat3_led_complete(struct urb *urb)
  761. {
  762. struct redrat3_dev *rr3 = urb->context;
  763. switch (urb->status) {
  764. case 0:
  765. break;
  766. case -ECONNRESET:
  767. case -ENOENT:
  768. case -ESHUTDOWN:
  769. usb_unlink_urb(urb);
  770. return;
  771. case -EPIPE:
  772. default:
  773. dev_dbg(rr3->dev, "Error: urb status = %d\n", urb->status);
  774. break;
  775. }
  776. rr3->led.brightness = LED_OFF;
  777. atomic_dec(&rr3->flash);
  778. }
  779. static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
  780. {
  781. struct device *dev = rr3->dev;
  782. struct rc_dev *rc;
  783. int ret;
  784. u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
  785. rc = rc_allocate_device(RC_DRIVER_IR_RAW);
  786. if (!rc)
  787. return NULL;
  788. snprintf(rr3->name, sizeof(rr3->name),
  789. "RedRat3%s Infrared Remote Transceiver",
  790. prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "");
  791. usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys));
  792. rc->device_name = rr3->name;
  793. rc->input_phys = rr3->phys;
  794. usb_to_input_id(rr3->udev, &rc->input_id);
  795. rc->dev.parent = dev;
  796. rc->priv = rr3;
  797. rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
  798. rc->min_timeout = MS_TO_US(RR3_RX_MIN_TIMEOUT);
  799. rc->max_timeout = MS_TO_US(RR3_RX_MAX_TIMEOUT);
  800. rc->timeout = redrat3_get_timeout(rr3);
  801. rc->s_timeout = redrat3_set_timeout;
  802. rc->tx_ir = redrat3_transmit_ir;
  803. rc->s_tx_carrier = redrat3_set_tx_carrier;
  804. rc->s_carrier_report = redrat3_wideband_receiver;
  805. rc->driver_name = DRIVER_NAME;
  806. rc->rx_resolution = 2;
  807. rc->map_name = RC_MAP_HAUPPAUGE;
  808. ret = rc_register_device(rc);
  809. if (ret < 0) {
  810. dev_err(dev, "remote dev registration failed\n");
  811. goto out;
  812. }
  813. return rc;
  814. out:
  815. rc_free_device(rc);
  816. return NULL;
  817. }
  818. static int redrat3_dev_probe(struct usb_interface *intf,
  819. const struct usb_device_id *id)
  820. {
  821. struct usb_device *udev = interface_to_usbdev(intf);
  822. struct device *dev = &intf->dev;
  823. struct usb_host_interface *uhi;
  824. struct redrat3_dev *rr3;
  825. struct usb_endpoint_descriptor *ep;
  826. struct usb_endpoint_descriptor *ep_narrow = NULL;
  827. struct usb_endpoint_descriptor *ep_wide = NULL;
  828. struct usb_endpoint_descriptor *ep_out = NULL;
  829. u8 addr, attrs;
  830. int pipe, i;
  831. int retval = -ENOMEM;
  832. uhi = intf->cur_altsetting;
  833. /* find our bulk-in and bulk-out endpoints */
  834. for (i = 0; i < uhi->desc.bNumEndpoints; ++i) {
  835. ep = &uhi->endpoint[i].desc;
  836. addr = ep->bEndpointAddress;
  837. attrs = ep->bmAttributes;
  838. if (((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
  839. ((attrs & USB_ENDPOINT_XFERTYPE_MASK) ==
  840. USB_ENDPOINT_XFER_BULK)) {
  841. dev_dbg(dev, "found bulk-in endpoint at 0x%02x\n",
  842. ep->bEndpointAddress);
  843. /* data comes in on 0x82, 0x81 is for learning */
  844. if (ep->bEndpointAddress == RR3_NARROW_IN_EP_ADDR)
  845. ep_narrow = ep;
  846. if (ep->bEndpointAddress == RR3_WIDE_IN_EP_ADDR)
  847. ep_wide = ep;
  848. }
  849. if ((ep_out == NULL) &&
  850. ((addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
  851. ((attrs & USB_ENDPOINT_XFERTYPE_MASK) ==
  852. USB_ENDPOINT_XFER_BULK)) {
  853. dev_dbg(dev, "found bulk-out endpoint at 0x%02x\n",
  854. ep->bEndpointAddress);
  855. ep_out = ep;
  856. }
  857. }
  858. if (!ep_narrow || !ep_out || !ep_wide) {
  859. dev_err(dev, "Couldn't find all endpoints\n");
  860. retval = -ENODEV;
  861. goto no_endpoints;
  862. }
  863. /* allocate memory for our device state and initialize it */
  864. rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL);
  865. if (!rr3)
  866. goto no_endpoints;
  867. rr3->dev = &intf->dev;
  868. rr3->ep_narrow = ep_narrow;
  869. rr3->ep_out = ep_out;
  870. rr3->udev = udev;
  871. /* set up bulk-in endpoint */
  872. rr3->narrow_urb = usb_alloc_urb(0, GFP_KERNEL);
  873. if (!rr3->narrow_urb)
  874. goto redrat_free;
  875. rr3->wide_urb = usb_alloc_urb(0, GFP_KERNEL);
  876. if (!rr3->wide_urb)
  877. goto redrat_free;
  878. rr3->bulk_in_buf = usb_alloc_coherent(udev,
  879. le16_to_cpu(ep_narrow->wMaxPacketSize),
  880. GFP_KERNEL, &rr3->dma_in);
  881. if (!rr3->bulk_in_buf)
  882. goto redrat_free;
  883. pipe = usb_rcvbulkpipe(udev, ep_narrow->bEndpointAddress);
  884. usb_fill_bulk_urb(rr3->narrow_urb, udev, pipe, rr3->bulk_in_buf,
  885. le16_to_cpu(ep_narrow->wMaxPacketSize),
  886. redrat3_handle_async, rr3);
  887. rr3->narrow_urb->transfer_dma = rr3->dma_in;
  888. rr3->narrow_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  889. pipe = usb_rcvbulkpipe(udev, ep_wide->bEndpointAddress);
  890. usb_fill_bulk_urb(rr3->wide_urb, udev, pipe, rr3->bulk_in_buf,
  891. le16_to_cpu(ep_narrow->wMaxPacketSize),
  892. redrat3_handle_async, rr3);
  893. rr3->wide_urb->transfer_dma = rr3->dma_in;
  894. rr3->wide_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  895. redrat3_reset(rr3);
  896. redrat3_get_firmware_rev(rr3);
  897. /* default.. will get overridden by any sends with a freq defined */
  898. rr3->carrier = 38000;
  899. atomic_set(&rr3->flash, 0);
  900. rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL);
  901. if (!rr3->flash_urb)
  902. goto redrat_free;
  903. /* learn urb */
  904. rr3->learn_urb = usb_alloc_urb(0, GFP_KERNEL);
  905. if (!rr3->learn_urb)
  906. goto redrat_free;
  907. /* setup packet is 'c0 b2 0000 0000 0001' */
  908. rr3->learn_control.bRequestType = 0xc0;
  909. rr3->learn_control.bRequest = RR3_MODSIG_CAPTURE;
  910. rr3->learn_control.wLength = cpu_to_le16(1);
  911. usb_fill_control_urb(rr3->learn_urb, udev, usb_rcvctrlpipe(udev, 0),
  912. (unsigned char *)&rr3->learn_control,
  913. &rr3->learn_buf, sizeof(rr3->learn_buf),
  914. redrat3_learn_complete, rr3);
  915. /* setup packet is 'c0 b9 0000 0000 0001' */
  916. rr3->flash_control.bRequestType = 0xc0;
  917. rr3->flash_control.bRequest = RR3_BLINK_LED;
  918. rr3->flash_control.wLength = cpu_to_le16(1);
  919. usb_fill_control_urb(rr3->flash_urb, udev, usb_rcvctrlpipe(udev, 0),
  920. (unsigned char *)&rr3->flash_control,
  921. &rr3->flash_in_buf, sizeof(rr3->flash_in_buf),
  922. redrat3_led_complete, rr3);
  923. /* led control */
  924. rr3->led.name = "redrat3:red:feedback";
  925. rr3->led.default_trigger = "rc-feedback";
  926. rr3->led.brightness_set = redrat3_brightness_set;
  927. retval = led_classdev_register(&intf->dev, &rr3->led);
  928. if (retval)
  929. goto redrat_free;
  930. rr3->rc = redrat3_init_rc_dev(rr3);
  931. if (!rr3->rc) {
  932. retval = -ENOMEM;
  933. goto led_free;
  934. }
  935. /* might be all we need to do? */
  936. retval = redrat3_enable_detector(rr3);
  937. if (retval < 0)
  938. goto led_free;
  939. /* we can register the device now, as it is ready */
  940. usb_set_intfdata(intf, rr3);
  941. return 0;
  942. led_free:
  943. led_classdev_unregister(&rr3->led);
  944. redrat_free:
  945. redrat3_delete(rr3, rr3->udev);
  946. no_endpoints:
  947. return retval;
  948. }
  949. static void redrat3_dev_disconnect(struct usb_interface *intf)
  950. {
  951. struct usb_device *udev = interface_to_usbdev(intf);
  952. struct redrat3_dev *rr3 = usb_get_intfdata(intf);
  953. usb_set_intfdata(intf, NULL);
  954. rc_unregister_device(rr3->rc);
  955. led_classdev_unregister(&rr3->led);
  956. redrat3_delete(rr3, udev);
  957. }
  958. static int redrat3_dev_suspend(struct usb_interface *intf, pm_message_t message)
  959. {
  960. struct redrat3_dev *rr3 = usb_get_intfdata(intf);
  961. led_classdev_suspend(&rr3->led);
  962. usb_kill_urb(rr3->narrow_urb);
  963. usb_kill_urb(rr3->wide_urb);
  964. usb_kill_urb(rr3->flash_urb);
  965. return 0;
  966. }
  967. static int redrat3_dev_resume(struct usb_interface *intf)
  968. {
  969. struct redrat3_dev *rr3 = usb_get_intfdata(intf);
  970. if (usb_submit_urb(rr3->narrow_urb, GFP_ATOMIC))
  971. return -EIO;
  972. if (usb_submit_urb(rr3->wide_urb, GFP_ATOMIC))
  973. return -EIO;
  974. led_classdev_resume(&rr3->led);
  975. return 0;
  976. }
  977. static struct usb_driver redrat3_dev_driver = {
  978. .name = DRIVER_NAME,
  979. .probe = redrat3_dev_probe,
  980. .disconnect = redrat3_dev_disconnect,
  981. .suspend = redrat3_dev_suspend,
  982. .resume = redrat3_dev_resume,
  983. .reset_resume = redrat3_dev_resume,
  984. .id_table = redrat3_dev_table
  985. };
  986. module_usb_driver(redrat3_dev_driver);
  987. MODULE_DESCRIPTION(DRIVER_DESC);
  988. MODULE_AUTHOR(DRIVER_AUTHOR);
  989. MODULE_AUTHOR(DRIVER_AUTHOR2);
  990. MODULE_LICENSE("GPL");
  991. MODULE_DEVICE_TABLE(usb, redrat3_dev_table);