Advertisement
Guest User

Untitled

a guest
Dec 6th, 2010
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.90 KB | None | 0 0
  1. --- drivers/lirc_atiusb/lirc_atiusb.c 2009/03/11 00:21:46 1.85
  2. +++ drivers/lirc_atiusb/lirc_atiusb.c 2010/03/17 14:16:15 1.86
  3. @@ -17,7 +17,7 @@
  4. * Vassilis Virvilis <vasvir@iit.demokritos.gr> 2006
  5. * reworked the patch for lirc submission
  6. *
  7. - * $Id: lirc_atiusb.c,v 1.85 2009/03/11 00:21:46 jarodwilson Exp $
  8. + * $Id: lirc_atiusb.c,v 1.86 2010/03/17 14:16:15 jarodwilson Exp $
  9. */
  10.  
  11. /*
  12. @@ -67,7 +69,7 @@
  13. #include "drivers/kcompat.h"
  14. #include "drivers/lirc_dev/lirc_dev.h"
  15.  
  16. -#define DRIVER_VERSION "$Revision: 1.85 $"
  17. +#define DRIVER_VERSION "$Revision: 1.86 $"
  18. #define DRIVER_AUTHOR "Paul Miller <pmiller9@users.sourceforge.net>"
  19. #define DRIVER_DESC "USB remote driver for LIRC"
  20. #define DRIVER_NAME "lirc_atiusb"
  21. @@ -1374,7 +1376,7 @@
  22. DRIVER_VERSION "\n");
  23. printk(DRIVER_NAME ": " DRIVER_AUTHOR "\n");
  24. dprintk(DRIVER_NAME ": debug mode enabled: "
  25. - "$Id: lirc_atiusb.c,v 1.85 2009/03/11 00:21:46 jarodwilson Exp $\n");
  26. + "$Id: lirc_atiusb.c,v 1.86 2010/03/17 14:16:15 jarodwilson Exp $\n");
  27.  
  28. repeat_jiffies = repeat*HZ/100;
  29.  
  30. --- drivers/lirc_atiusb/lirc_atiusb.c 2010/03/17 14:16:15 1.86
  31. +++ drivers/lirc_atiusb/lirc_atiusb.c 2010/07/24 14:35:58 1.87
  32. @@ -17,7 +17,7 @@
  33. * Vassilis Virvilis <vasvir@iit.demokritos.gr> 2006
  34. * reworked the patch for lirc submission
  35. *
  36. - * $Id: lirc_atiusb.c,v 1.86 2010/03/17 14:16:15 jarodwilson Exp $
  37. + * $Id: lirc_atiusb.c,v 1.87 2010/07/24 14:35:58 jarodwilson Exp $
  38. */
  39.  
  40. /*
  41. @@ -69,7 +69,7 @@
  42. #include "drivers/kcompat.h"
  43. #include "drivers/lirc_dev/lirc_dev.h"
  44.  
  45. -#define DRIVER_VERSION "$Revision: 1.86 $"
  46. +#define DRIVER_VERSION "$Revision: 1.87 $"
  47. #define DRIVER_AUTHOR "Paul Miller <pmiller9@users.sourceforge.net>"
  48. #define DRIVER_DESC "USB remote driver for LIRC"
  49. #define DRIVER_NAME "lirc_atiusb"
  50. @@ -824,7 +824,11 @@
  51. ir->devnum);
  52. case 3:
  53. #ifdef KERNEL_2_5
  54. +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  55. + usb_free_coherent(iep->ir->usbdev, iep->len, iep->buf, iep->dma);
  56. +#else
  57. usb_buffer_free(iep->ir->usbdev, iep->len, iep->buf, iep->dma);
  58. +#endif
  59. #else
  60. kfree(iep->buf);
  61. #endif
  62. @@ -869,7 +873,11 @@
  63. iep->len = len;
  64.  
  65. #ifdef KERNEL_2_5
  66. +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  67. + iep->buf = usb_alloc_coherent(dev, len, GFP_ATOMIC, &iep->dma);
  68. +#else
  69. iep->buf = usb_buffer_alloc(dev, len, GFP_ATOMIC, &iep->dma);
  70. +#endif
  71. #else
  72. iep->buf = kmalloc(len, GFP_KERNEL);
  73. #endif
  74. @@ -931,8 +939,13 @@
  75. }
  76. case 3:
  77. #ifdef KERNEL_2_5
  78. +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  79. + usb_free_coherent(oep->ir->usbdev, USB_OUTLEN,
  80. + oep->buf, oep->dma);
  81. +#else
  82. usb_buffer_free(oep->ir->usbdev, USB_OUTLEN,
  83. oep->buf, oep->dma);
  84. +#endif
  85. #else
  86. kfree(oep->buf);
  87. #endif
  88. @@ -965,8 +978,13 @@
  89. init_waitqueue_head(&oep->wait);
  90.  
  91. #ifdef KERNEL_2_5
  92. +#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  93. + oep->buf = usb_alloc_coherent(dev, USB_OUTLEN,
  94. + GFP_ATOMIC, &oep->dma);
  95. +#else
  96. oep->buf = usb_buffer_alloc(dev, USB_OUTLEN,
  97. GFP_ATOMIC, &oep->dma);
  98. +#endif
  99. #else
  100. oep->buf = kmalloc(USB_OUTLEN, GFP_KERNEL);
  101. #endif
  102. @@ -1376,7 +1394,7 @@
  103. DRIVER_VERSION "\n");
  104. printk(DRIVER_NAME ": " DRIVER_AUTHOR "\n");
  105. dprintk(DRIVER_NAME ": debug mode enabled: "
  106. - "$Id: lirc_atiusb.c,v 1.86 2010/03/17 14:16:15 jarodwilson Exp $\n");
  107. + "$Id: lirc_atiusb.c,v 1.87 2010/07/24 14:35:58 jarodwilson Exp $\n");
  108.  
  109. repeat_jiffies = repeat*HZ/100;
  110.  
  111. --- drivers/lirc_atiusb/lirc_atiusb.c 2010/07/24 14:35:58 1.87
  112. +++ drivers/lirc_atiusb/lirc_atiusb.c 2010/07/25 16:43:33 1.88
  113. @@ -17,7 +17,7 @@
  114. * Vassilis Virvilis <vasvir@iit.demokritos.gr> 2006
  115. * reworked the patch for lirc submission
  116. *
  117. - * $Id: lirc_atiusb.c,v 1.87 2010/07/24 14:35:58 jarodwilson Exp $
  118. + * $Id: lirc_atiusb.c,v 1.88 2010/07/25 16:43:33 jarodwilson Exp $
  119. */
  120.  
  121. /*
  122. @@ -69,7 +69,7 @@
  123. #include "drivers/kcompat.h"
  124. #include "drivers/lirc_dev/lirc_dev.h"
  125.  
  126. -#define DRIVER_VERSION "$Revision: 1.87 $"
  127. +#define DRIVER_VERSION "$Revision: 1.88 $"
  128. #define DRIVER_AUTHOR "Paul Miller <pmiller9@users.sourceforge.net>"
  129. #define DRIVER_DESC "USB remote driver for LIRC"
  130. #define DRIVER_NAME "lirc_atiusb"
  131. @@ -824,12 +824,8 @@
  132. ir->devnum);
  133. case 3:
  134. #ifdef KERNEL_2_5
  135. -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  136. usb_free_coherent(iep->ir->usbdev, iep->len, iep->buf, iep->dma);
  137. #else
  138. - usb_buffer_free(iep->ir->usbdev, iep->len, iep->buf, iep->dma);
  139. -#endif
  140. -#else
  141. kfree(iep->buf);
  142. #endif
  143. iep->buf = 0;
  144. @@ -873,12 +869,8 @@
  145. iep->len = len;
  146.  
  147. #ifdef KERNEL_2_5
  148. -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  149. iep->buf = usb_alloc_coherent(dev, len, GFP_ATOMIC, &iep->dma);
  150. #else
  151. - iep->buf = usb_buffer_alloc(dev, len, GFP_ATOMIC, &iep->dma);
  152. -#endif
  153. -#else
  154. iep->buf = kmalloc(len, GFP_KERNEL);
  155. #endif
  156. if (!iep->buf) {
  157. @@ -939,14 +931,9 @@
  158. }
  159. case 3:
  160. #ifdef KERNEL_2_5
  161. -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  162. usb_free_coherent(oep->ir->usbdev, USB_OUTLEN,
  163. oep->buf, oep->dma);
  164. #else
  165. - usb_buffer_free(oep->ir->usbdev, USB_OUTLEN,
  166. - oep->buf, oep->dma);
  167. -#endif
  168. -#else
  169. kfree(oep->buf);
  170. #endif
  171. oep->buf = 0;
  172. @@ -978,14 +965,9 @@
  173. init_waitqueue_head(&oep->wait);
  174.  
  175. #ifdef KERNEL_2_5
  176. -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
  177. oep->buf = usb_alloc_coherent(dev, USB_OUTLEN,
  178. GFP_ATOMIC, &oep->dma);
  179. #else
  180. - oep->buf = usb_buffer_alloc(dev, USB_OUTLEN,
  181. - GFP_ATOMIC, &oep->dma);
  182. -#endif
  183. -#else
  184. oep->buf = kmalloc(USB_OUTLEN, GFP_KERNEL);
  185. #endif
  186. if (!oep->buf)
  187. @@ -1394,7 +1376,7 @@
  188. DRIVER_VERSION "\n");
  189. printk(DRIVER_NAME ": " DRIVER_AUTHOR "\n");
  190. dprintk(DRIVER_NAME ": debug mode enabled: "
  191. - "$Id: lirc_atiusb.c,v 1.87 2010/07/24 14:35:58 jarodwilson Exp $\n");
  192. + "$Id: lirc_atiusb.c,v 1.88 2010/07/25 16:43:33 jarodwilson Exp $\n");
  193.  
  194. repeat_jiffies = repeat*HZ/100;
  195.  
  196. --- drivers/kcompat.h 2009/08/02 11:15:28 5.45
  197. +++ drivers/kcompat.h 2010/07/27 05:43:21 5.50
  198. @@ -1,4 +1,4 @@
  199. -/* $Id: kcompat.h,v 5.45 2009/08/02 11:15:28 lirc Exp $ */
  200. +/* $Id: kcompat.h,v 5.50 2010/07/27 05:43:21 jarodwilson Exp $ */
  201.  
  202. #ifndef _KCOMPAT_H
  203. #define _KCOMPAT_H
  204. @@ -9,6 +9,11 @@
  205. #define __func__ __FUNCTION__
  206. #endif
  207.  
  208. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
  209. +#define usb_alloc_coherent usb_buffer_alloc
  210. +#define usb_free_coherent usb_buffer_free
  211. +#endif
  212. +
  213. #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
  214. #define LIRC_THIS_MODULE(x) x,
  215. #else /* >= 2.6.16 */
  216. @@ -364,6 +369,11 @@
  217. #endif /* kernel < 2.6.11 */
  218. #endif /* kernel >= 2.6.0 */
  219.  
  220. +/*************************** pm_wakeup.h ******************************/
  221. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
  222. +static inline void device_set_wakeup_capable(struct device *dev, int val) {}
  223. +#endif /* kernel < 2.6.27 */
  224. +
  225. /*************************** interrupt.h ******************************/
  226. /* added in 2.6.18, old defines removed in 2.6.24 */
  227. #ifndef IRQF_DISABLED
  228. @@ -378,6 +388,9 @@
  229. #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11)
  230. #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
  231. #endif
  232. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
  233. +#define __SPIN_LOCK_UNLOCKED(x) SPIN_LOCK_UNLOCKED;
  234. +#endif
  235.  
  236. /***************************** slab.h *********************************/
  237. /* added in 2.6.14 */
  238. @@ -405,4 +418,14 @@
  239. #define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
  240. #endif
  241.  
  242. +/****************************** kernel.h **********************************/
  243. +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
  244. +#define DIV_ROUND_CLOSEST(x, divisor)( \
  245. +{ \
  246. + typeof(divisor) __divisor = divisor; \
  247. + (((x) + ((__divisor) / 2)) / (__divisor)); \
  248. +} \
  249. +)
  250. +#endif
  251. +
  252. #endif /* _KCOMPAT_H */
  253. --- drivers/lirc_igorplugusb/lirc_igorplugusb.c 2009/11/09 18:59:21 1.35
  254. +++ drivers/lirc_igorplugusb/lirc_igorplugusb.c 2010/07/25 16:43:33 1.38
  255. @@ -450,7 +452,7 @@
  256. }
  257.  
  258. #if defined(KERNEL_2_5)
  259. - ir->buf_in = usb_buffer_alloc(dev,
  260. + ir->buf_in = usb_alloc_coherent(dev,
  261. DEVICE_BUFLEN+DEVICE_HEADERLEN,
  262. GFP_ATOMIC, &ir->dma_in);
  263. #else
  264. @@ -486,7 +488,7 @@
  265. switch (mem_failure) {
  266. case 9:
  267. #if defined(KERNEL_2_5)
  268. - usb_buffer_free(dev, DEVICE_BUFLEN+DEVICE_HEADERLEN,
  269. + usb_free_coherent(dev, DEVICE_BUFLEN+DEVICE_HEADERLEN,
  270. ir->buf_in, ir->dma_in);
  271. #else
  272. kfree(ir->buf_in);
  273. @@ -566,7 +568,7 @@
  274.  
  275.  
  276. #if defined(KERNEL_2_5)
  277. - usb_buffer_free(dev, ir->len_in, ir->buf_in, ir->dma_in);
  278. + usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
  279. #else
  280. kfree(ir->buf_in);
  281. #endif
  282. --- drivers/lirc_mceusb/lirc_mceusb.c 2010/03/17 14:16:16 1.54
  283. +++ drivers/lirc_mceusb/lirc_mceusb.c 2010/07/25 16:43:33 1.70
  284. @@ -80,6 +80,7 @@
  285. #define DRIVER_NAME "lirc_mceusb"
  286.  
  287. #define USB_BUFLEN 32 /* USB reception buffer length */
  288. +#define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */
  289. #define LIRCBUF_SIZE 256 /* LIRC work buffer length */
  290.  
  291. /* MCE constants */
  292. @@ -95,7 +96,7 @@
  293. #define MCE_PULSE_BIT 0x80 /* Pulse bit, MSB set == PULSE else SPACE */
  294. #define MCE_PULSE_MASK 0x7F /* Pulse mask */
  295. #define MCE_MAX_PULSE_LENGTH 0x7F /* Longest transmittable pulse symbol */
  296. -#define MCE_PACKET_LENGTH_MASK 0x7F /* Pulse mask */
  297. +#define MCE_PACKET_LENGTH_MASK 0x7F /* Packet length mask */
  298.  
  299.  
  300. /* module parameters */
  301. @@ -116,8 +117,8 @@
  302. #define RECV_FLAG_IN_PROGRESS 3
  303. #define RECV_FLAG_COMPLETE 4
  304.  
  305. -#define MCEUSB_INBOUND 1
  306. -#define MCEUSB_OUTBOUND 2
  307. +#define MCEUSB_RX 1
  308. +#define MCEUSB_TX 2
  309.  
  310. #define VENDOR_PHILIPS 0x0471
  311. #define VENDOR_SMK 0x0609
  312. @@ -211,6 +212,8 @@
  313. { USB_DEVICE(VENDOR_FORMOSA, 0xe03a) },
  314. /* Formosa Industrial Computing AIM IR605/A */
  315. { USB_DEVICE(VENDOR_FORMOSA, 0xe03c) },
  316. + /* Formosa Industrial Computing AIM IR605/A */
  317. + { USB_DEVICE(VENDOR_FORMOSA, 0xe03e) },
  318. /* Fintek eHome Infrared Transceiver */
  319. { USB_DEVICE(VENDOR_FINTEK, 0x0602) },
  320. /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */
  321. @@ -233,8 +236,9 @@
  322. { }
  323. };
  324.  
  325. -static struct usb_device_id pinnacle_list[] = {
  326. +static struct usb_device_id gen3_list[] = {
  327. { USB_DEVICE(VENDOR_PINNACLE, 0x0225) },
  328. + { USB_DEVICE(VENDOR_TOPSEED, 0x0008) },
  329. {}
  330. };
  331.  
  332. @@ -282,10 +286,9 @@
  333. unsigned char is_pulse;
  334. struct {
  335. u32 connected:1;
  336. - u32 pinnacle:1;
  337. u32 transmitter_mask_inverted:1;
  338. u32 microsoft_gen1:1;
  339. - u32 reserved:28;
  340. + u32 reserved:29;
  341. } flags;
  342.  
  343. unsigned char transmitter_mask;
  344. @@ -295,16 +298,44 @@
  345. int send_flags;
  346. wait_queue_head_t wait_out;
  347.  
  348. - struct mutex lock;
  349. + struct mutex dev_lock;
  350. };
  351.  
  352. -/* init strings */
  353. -static char init1[] = {0x00, 0xff, 0xaa, 0xff, 0x0b};
  354. -static char init2[] = {0xff, 0x18};
  355. -
  356. -static char pin_init1[] = { 0x9f, 0x07};
  357. -static char pin_init2[] = { 0x9f, 0x13};
  358. -static char pin_init3[] = { 0x9f, 0x0d};
  359. +/*
  360. + * MCE Device Command Strings
  361. + * Device command responses vary from device to device...
  362. + * - DEVICE_RESET resets the hardware to its default state
  363. + * - GET_REVISION fetches the hardware/software revision, common
  364. + * replies are ff 0b 45 ff 1b 08 and ff 0b 50 ff 1b 42
  365. + * - GET_CARRIER_FREQ gets the carrier mode and frequency of the
  366. + * device, with replies in the form of 9f 06 MM FF, where MM is 0-3,
  367. + * meaning clk of 10000000, 2500000, 625000 or 156250, and FF is
  368. + * ((clk / frequency) - 1)
  369. + * - GET_RX_TIMEOUT fetches the receiver timeout in units of 50us,
  370. + * response in the form of 9f 0c msb lsb
  371. + * - GET_TX_BITMASK fetches the transmitter bitmask, replies in
  372. + * the form of 9f 08 bm, where bm is the bitmask
  373. + * - GET_RX_SENSOR fetches the RX sensor setting -- long-range
  374. + * general use one or short-range learning one, in the form of
  375. + * 9f 14 ss, where ss is either 01 for long-range or 02 for short
  376. + * - SET_CARRIER_FREQ sets a new carrier mode and frequency
  377. + * - SET_TX_BITMASK sets the transmitter bitmask
  378. + * - SET_RX_TIMEOUT sets the receiver timeout
  379. + * - SET_RX_SENSOR sets which receiver sensor to use
  380. + */
  381. +static char DEVICE_RESET[] = {0x00, 0xff, 0xaa};
  382. +static char GET_REVISION[] = {0xff, 0x0b};
  383. +static char GET_UNKNOWN[] = {0xff, 0x18};
  384. +static char GET_UNKNOWN2[] = {0x9f, 0x05};
  385. +static char GET_CARRIER_FREQ[] = {0x9f, 0x07};
  386. +static char GET_RX_TIMEOUT[] = {0x9f, 0x0d};
  387. +static char GET_TX_BITMASK[] = {0x9f, 0x13};
  388. +static char GET_RX_SENSOR[] = {0x9f, 0x15};
  389. +/* sub in desired values in lower byte or bytes for full command */
  390. +//static char SET_CARRIER_FREQ[] = {0x9f, 0x06, 0x00, 0x00};
  391. +//static char SET_TX_BITMASK[] = {0x9f, 0x08, 0x00};
  392. +//static char SET_RX_TIMEOUT[] = {0x9f, 0x0c, 0x00, 0x00};
  393. +//static char SET_RX_SENSOR[] = {0x9f, 0x14, 0x00};
  394.  
  395. #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11)
  396. static unsigned long usecs_to_jiffies(const unsigned int u)
  397. @@ -320,22 +351,126 @@
  398. #endif
  399. }
  400. #endif
  401. -static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, int len)
  402. +static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
  403. + int len, bool out)
  404. {
  405. char codes[USB_BUFLEN * 3 + 1];
  406. + char inout[9];
  407. int i;
  408. + u8 cmd, subcmd, data1, data2;
  409. + int idx = 0;
  410.  
  411. - if (len <= 0)
  412. - return;
  413. + if (ir->flags.microsoft_gen1 && !out)
  414. + idx = 2;
  415.  
  416. - if (ir->flags.microsoft_gen1 && len <= 2)
  417. + if (len <= idx)
  418. return;
  419.  
  420. for (i = 0; i < len && i < USB_BUFLEN; i++)
  421. snprintf(codes + i * 3, 4, "%02x ", buf[i] & 0xFF);
  422.  
  423. - printk(KERN_INFO "" DRIVER_NAME "[%d]: data received %s (length=%d)\n",
  424. - ir->devnum, codes, len);
  425. + printk(KERN_INFO "" DRIVER_NAME "[%d]: %sx data: %s (length=%d)\n",
  426. + ir->devnum, (out ? "t" : "r"), codes, len);
  427. +
  428. + if (out)
  429. + strcpy(inout, "Request\0");
  430. + else
  431. + strcpy(inout, "Got\0");
  432. +
  433. + cmd = buf[idx] & 0xff;
  434. + subcmd = buf[idx + 1] & 0xff;
  435. + data1 = buf[idx + 2] & 0xff;
  436. + data2 = buf[idx + 3] & 0xff;
  437. +
  438. + switch (cmd) {
  439. + case 0x00:
  440. + if (subcmd == 0xff && data1 == 0xaa)
  441. + printk(KERN_INFO "Device reset requested\n");
  442. + else
  443. + printk(KERN_INFO "Unknown command 0x%02x 0x%02x\n",
  444. + cmd, subcmd);
  445. + break;
  446. + case 0xff:
  447. + switch (subcmd) {
  448. + case 0x0b:
  449. + if (len == 2)
  450. + printk(KERN_INFO "Get hw/sw rev?\n");
  451. + else
  452. + printk(KERN_INFO "hw/sw rev 0x%02x 0x%02x "
  453. + "0x%02x 0x%02x\n", data1, data2,
  454. + buf[4], buf[5]);
  455. + break;
  456. + case 0xaa:
  457. + printk(KERN_INFO "Device reset requested\n");
  458. + break;
  459. + case 0xfe:
  460. + printk(KERN_INFO "Previous command not supported\n");
  461. + break;
  462. + case 0x18:
  463. + case 0x1b:
  464. + default:
  465. + printk(KERN_INFO "Unknown command 0x%02x 0x%02x\n",
  466. + cmd, subcmd);
  467. + break;
  468. + }
  469. + break;
  470. + case 0x9f:
  471. + switch (subcmd) {
  472. + case 0x03:
  473. + printk(KERN_INFO "Ping\n");
  474. + break;
  475. + case 0x04:
  476. + printk(KERN_INFO "Resp to 9f 05 of 0x%02x 0x%02x\n",
  477. + data1, data2);
  478. + break;
  479. + case 0x06:
  480. + printk(KERN_INFO "%s carrier mode and freq of 0x%02x 0x%02x\n",
  481. + inout, data1, data2);
  482. + break;
  483. + case 0x07:
  484. + printk(KERN_INFO "Get carrier mode and freq\n");
  485. + break;
  486. + case 0x08:
  487. + printk(KERN_INFO "%s transmit blaster mask of 0x%02x\n",
  488. + inout, data1);
  489. + break;
  490. + case 0x0c:
  491. + /* value is in units of 50us, so x*50/100 or x/2 ms */
  492. + printk(KERN_INFO "%s receive timeout of %d ms\n",
  493. + inout, ((data1 << 8) | data2) / 2);
  494. + break;
  495. + case 0x0d:
  496. + printk(KERN_INFO "Get receive timeout\n");
  497. + break;
  498. + case 0x13:
  499. + printk(KERN_INFO "Get transmit blaster mask\n");
  500. + break;
  501. + case 0x14:
  502. + printk(KERN_INFO "%s %s-range receive sensor in use\n",
  503. + inout, data1 == 0x02 ? "short" : "long");
  504. + break;
  505. + case 0x15:
  506. + if (len == 2)
  507. + printk(KERN_INFO "Get receive sensor\n");
  508. + else
  509. + printk(KERN_INFO "Received pulse count is %d\n",
  510. + ((data1 << 8) | data2));
  511. + break;
  512. + case 0xfe:
  513. + printk(KERN_INFO "Error! Hardware is likely wedged...\n");
  514. + break;
  515. + case 0x05:
  516. + case 0x09:
  517. + case 0x0f:
  518. + default:
  519. + printk(KERN_INFO "Unknown command 0x%02x 0x%02x\n",
  520. + cmd, subcmd);
  521. + break;
  522. + }
  523. + break;
  524. + default:
  525. + break;
  526. + }
  527. }
  528.  
  529. static void usb_async_callback(struct urb *urb, struct pt_regs *regs)
  530. @@ -355,54 +490,48 @@
  531. ir->devnum, urb->status, len);
  532.  
  533. if (debug)
  534. - mceusb_dev_printdata(ir, urb->transfer_buffer, len);
  535. + mceusb_dev_printdata(ir, urb->transfer_buffer, len, true);
  536. }
  537.  
  538. }
  539.  
  540. /* request incoming or send outgoing usb packet - used to initialize remote */
  541. -static void request_packet_async(struct mceusb_dev *ir,
  542. - struct usb_endpoint_descriptor *ep,
  543. - unsigned char *data, int size, int urb_type)
  544. +static void mce_request_packet(struct mceusb_dev *ir,
  545. + struct usb_endpoint_descriptor *ep,
  546. + unsigned char *data, int size, int urb_type)
  547. {
  548. int res;
  549. struct urb *async_urb;
  550. unsigned char *async_buf;
  551.  
  552. - if (urb_type) {
  553. + if (urb_type == MCEUSB_TX) {
  554. async_urb = usb_alloc_urb(0, GFP_KERNEL);
  555. - if (unlikely(!async_urb))
  556. + if (unlikely(!async_urb)) {
  557. + printk(KERN_ERR "Error, couldn't allocate urb!\n");
  558. return;
  559. + }
  560.  
  561. - async_buf = kmalloc(size, GFP_KERNEL);
  562. + async_buf = kzalloc(size, GFP_KERNEL);
  563. if (!async_buf) {
  564. + printk(KERN_ERR "Error, couldn't allocate buf!\n");
  565. usb_free_urb(async_urb);
  566. return;
  567. }
  568.  
  569. - if (urb_type == MCEUSB_OUTBOUND) {
  570. - /* outbound data */
  571. - usb_fill_int_urb(async_urb, ir->usbdev,
  572. - usb_sndintpipe(ir->usbdev,
  573. - ep->bEndpointAddress),
  574. - async_buf, size,
  575. - (usb_complete_t) usb_async_callback,
  576. - ir, ep->bInterval);
  577. - memcpy(async_buf, data, size);
  578. - } else {
  579. - /* inbound data */
  580. - usb_fill_int_urb(async_urb, ir->usbdev,
  581. - usb_rcvintpipe(ir->usbdev,
  582. - ep->bEndpointAddress),
  583. - async_buf, size,
  584. - (usb_complete_t) usb_async_callback,
  585. - ir, ep->bInterval);
  586. - }
  587. - async_urb->transfer_flags = URB_ASYNC_UNLINK;
  588. - } else {
  589. + /* outbound data */
  590. + usb_fill_int_urb(async_urb, ir->usbdev,
  591. + usb_sndintpipe(ir->usbdev, ep->bEndpointAddress),
  592. + async_buf, size, (usb_complete_t) usb_async_callback,
  593. + ir, ep->bInterval);
  594. + memcpy(async_buf, data, size);
  595. +
  596. + } else if (urb_type == MCEUSB_RX) {
  597. /* standard request */
  598. async_urb = ir->urb_in;
  599. ir->send_flags = RECV_FLAG_IN_PROGRESS;
  600. + } else {
  601. + printk(KERN_ERR "Error! Unknown urb type %d\n", urb_type);
  602. + return;
  603. }
  604.  
  605. dprintk(DRIVER_NAME "[%d]: receive request called (size=%#x)\n",
  606. @@ -421,6 +550,16 @@
  607. ir->devnum, res);
  608. }
  609.  
  610. +static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
  611. +{
  612. + mce_request_packet(ir, ir->usb_ep_out, data, size, MCEUSB_TX);
  613. +}
  614. +
  615. +static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size)
  616. +{
  617. + mce_request_packet(ir, ir->usb_ep_in, data, size, MCEUSB_RX);
  618. +}
  619. +
  620. static int unregister_from_lirc(struct mceusb_dev *ir)
  621. {
  622. struct lirc_driver *d = ir->d;
  623. @@ -496,9 +635,9 @@
  624. dprintk(DRIVER_NAME "[%d]: mceusb IR device closed\n", ir->devnum);
  625.  
  626. if (ir->flags.connected) {
  627. - mutex_lock(&ir->lock);
  628. + mutex_lock(&ir->dev_lock);
  629. ir->flags.connected = 0;
  630. - mutex_unlock(&ir->lock);
  631. + mutex_unlock(&ir->dev_lock);
  632. }
  633. MOD_DEC_USE_COUNT;
  634. }
  635. @@ -616,7 +755,7 @@
  636. buf_len = urb->actual_length;
  637.  
  638. if (debug)
  639. - mceusb_dev_printdata(ir, urb->transfer_buffer, buf_len);
  640. + mceusb_dev_printdata(ir, urb->transfer_buffer, buf_len, false);
  641.  
  642. if (ir->send_flags == RECV_FLAG_IN_PROGRESS) {
  643. ir->send_flags = SEND_FLAG_COMPLETE;
  644. @@ -715,8 +854,7 @@
  645. cmdbuf[cmdcount++] = 0x80;
  646.  
  647. /* Transmit the command to the mce device */
  648. - request_packet_async(ir, ir->usb_ep_out, cmdbuf,
  649. - cmdcount, MCEUSB_OUTBOUND);
  650. + mce_async_out(ir, cmdbuf, cmdcount);
  651.  
  652. /*
  653. * The lircd gap calculation expects the write function to
  654. @@ -762,9 +900,7 @@
  655. ir->carrier_freq = carrier;
  656. dprintk(DRIVER_NAME "[%d]: SET_CARRIER disabling "
  657. "carrier modulation\n", ir->devnum);
  658. - request_packet_async(ir, ir->usb_ep_out,
  659. - cmdbuf, sizeof(cmdbuf),
  660. - MCEUSB_OUTBOUND);
  661. + mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
  662. return carrier;
  663. }
  664.  
  665. @@ -779,9 +915,7 @@
  666. ir->devnum, carrier);
  667.  
  668. /* Transmit new carrier to mce device */
  669. - request_packet_async(ir, ir->usb_ep_out,
  670. - cmdbuf, sizeof(cmdbuf),
  671. - MCEUSB_OUTBOUND);
  672. + mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
  673. return carrier;
  674. }
  675. }
  676. @@ -799,7 +933,6 @@
  677. {
  678. int result;
  679. unsigned int ivalue;
  680. - unsigned long lvalue;
  681. struct mceusb_dev *ir = NULL;
  682.  
  683. /* Retrieve lirc_driver data for the device */
  684. @@ -828,26 +961,6 @@
  685. dprintk(DRIVER_NAME ": SET_TRANSMITTERS mask=%d\n", ivalue);
  686. break;
  687.  
  688. - case LIRC_GET_SEND_MODE:
  689. -
  690. - result = put_user(LIRC_SEND2MODE(LIRC_CAN_SEND_PULSE &
  691. - LIRC_CAN_SEND_MASK),
  692. - (unsigned long *) arg);
  693. -
  694. - if (result)
  695. - return result;
  696. - break;
  697. -
  698. - case LIRC_SET_SEND_MODE:
  699. -
  700. - result = get_user(lvalue, (unsigned long *) arg);
  701. -
  702. - if (result)
  703. - return result;
  704. - if (lvalue != (LIRC_MODE_PULSE&LIRC_CAN_SEND_MASK))
  705. - return -EINVAL;
  706. - break;
  707. -
  708. case LIRC_SET_SEND_CARRIER:
  709.  
  710. result = get_user(ivalue, (unsigned int *) arg);
  711. @@ -870,45 +983,25 @@
  712. .ioctl = mceusb_lirc_ioctl,
  713. };
  714.  
  715. -static int mceusb_gen1_init(struct mceusb_dev *ir)
  716. +static void mceusb_gen1_init(struct mceusb_dev *ir)
  717. {
  718. - int i, ret;
  719. - char junk[64], data[8];
  720. - int partial = 0;
  721. -
  722. - /*
  723. - * Clear off the first few messages. These look like calibration
  724. - * or test data, I can't really tell. This also flushes in case
  725. - * we have random ir data queued up.
  726. - */
  727. - for (i = 0; i < 40; i++)
  728. - usb_bulk_msg(ir->usbdev,
  729. - usb_rcvbulkpipe(ir->usbdev,
  730. - ir->usb_ep_in->bEndpointAddress),
  731. - junk, 64, &partial, HZ * 10);
  732. -
  733. - ir->is_pulse = 1;
  734. -
  735. - memset(data, 0, 8);
  736. -
  737. - /* Get Status */
  738. - ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
  739. - USB_REQ_GET_STATUS, USB_DIR_IN,
  740. - 0, 0, data, 2, HZ * 3);
  741. -
  742. - /* ret = usb_get_status( ir->usbdev, 0, 0, data ); */
  743. - dprintk("%s - ret = %d status = 0x%x 0x%x\n", __func__,
  744. - ret, data[0], data[1]);
  745. + int ret;
  746. + int maxp = ir->len_in;
  747. + char *data;
  748. +
  749. + data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
  750. + if (!data) {
  751. + printk(KERN_ERR "%s: memory allocation failed!\n", __func__);
  752. + return;
  753. + }
  754.  
  755. /*
  756. * This is a strange one. They issue a set address to the device
  757. * on the receive control pipe and expect a certain value pair back
  758. */
  759. - memset(data, 0, 8);
  760. -
  761. ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
  762. USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
  763. - data, 2, HZ * 3);
  764. + data, USB_CTRL_MSG_SZ, HZ * 3);
  765. dprintk("%s - ret = %d, devnum = %d\n",
  766. __func__, ret, ir->usbdev->devnum);
  767. dprintk("%s - data[0] = %d, data[1] = %d\n",
  768. @@ -933,12 +1026,62 @@
  769. 0x0000, 0x0100, NULL, 0, HZ * 3);
  770. dprintk("%s - retC = %d\n", __func__, ret);
  771.  
  772. - return ret;
  773. + /* device reset */
  774. + mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
  775. + mce_sync_in(ir, NULL, maxp);
  776. +
  777. + /* get hw/sw revision? */
  778. + mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
  779. + mce_sync_in(ir, NULL, maxp);
  780. +
  781. + kfree(data);
  782. +
  783. + return;
  784.  
  785. };
  786.  
  787. -static int mceusb_dev_probe(struct usb_interface *intf,
  788. - const struct usb_device_id *id)
  789. +static void mceusb_gen2_init(struct mceusb_dev *ir)
  790. +{
  791. + int maxp = ir->len_in;
  792. +
  793. + /* device reset */
  794. + mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET));
  795. + mce_sync_in(ir, NULL, maxp);
  796. +
  797. + /* get hw/sw revision? */
  798. + mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION));
  799. + mce_sync_in(ir, NULL, maxp);
  800. +
  801. + /* unknown what the next two actually return... */
  802. + mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN));
  803. + mce_sync_in(ir, NULL, maxp);
  804. + mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2));
  805. + mce_sync_in(ir, NULL, maxp);
  806. +}
  807. +
  808. +static void mceusb_get_parameters(struct mceusb_dev *ir)
  809. +{
  810. + int maxp = ir->len_in;
  811. +
  812. + /* get the carrier and frequency */
  813. + mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ));
  814. + mce_sync_in(ir, NULL, maxp);
  815. +
  816. + /* get the transmitter bitmask */
  817. + mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK));
  818. + mce_sync_in(ir, NULL, maxp);
  819. +
  820. + /* get receiver timeout value */
  821. + mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
  822. + mce_sync_in(ir, NULL, maxp);
  823. +
  824. + /* get receiver sensor setting */
  825. + mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR));
  826. + mce_sync_in(ir, NULL, maxp);
  827. +}
  828. +
  829. +static int __devinit mceusb_dev_probe(struct usb_interface *intf,
  830. + const struct usb_device_id *id)
  831. {
  832. struct usb_device *dev = interface_to_usbdev(intf);
  833. struct usb_host_interface *idesc;
  834. @@ -954,19 +1097,15 @@
  835. int i;
  836. char buf[63], name[128] = "";
  837. int mem_failure = 0;
  838. - int is_pinnacle;
  839. - int is_microsoft_gen1;
  840. + bool is_gen3;
  841. + bool is_microsoft_gen1;
  842.  
  843. dprintk(DRIVER_NAME ": %s called\n", __func__);
  844.  
  845. - usb_reset_device(dev);
  846. -
  847. config = dev->actconfig;
  848. -
  849. idesc = intf->cur_altsetting;
  850.  
  851. - is_pinnacle = usb_match_id(intf, pinnacle_list) ? 1 : 0;
  852. -
  853. + is_gen3 = usb_match_id(intf, gen3_list) ? 1 : 0;
  854. is_microsoft_gen1 = usb_match_id(intf, microsoft_gen1_list) ? 1 : 0;
  855.  
  856. /* step through the endpoints to find first bulk in and out endpoint */
  857. @@ -985,14 +1124,7 @@
  858. "found\n");
  859. ep_in = ep;
  860. ep_in->bmAttributes = USB_ENDPOINT_XFER_INT;
  861. - if (is_pinnacle)
  862. - /*
  863. - * setting seems to 1 seem to cause issues with
  864. - * Pinnacle timing out on transfer.
  865. - */
  866. - ep_in->bInterval = ep->bInterval;
  867. - else
  868. - ep_in->bInterval = 1;
  869. + ep_in->bInterval = 1;
  870. }
  871.  
  872. if ((ep_out == NULL)
  873. @@ -1007,14 +1139,7 @@
  874. "found\n");
  875. ep_out = ep;
  876. ep_out->bmAttributes = USB_ENDPOINT_XFER_INT;
  877. - if (is_pinnacle)
  878. - /*
  879. - * setting seems to 1 seem to cause issues with
  880. - * Pinnacle timing out on transfer.
  881. - */
  882. - ep_out->bInterval = ep->bInterval;
  883. - else
  884. - ep_out->bInterval = 1;
  885. + ep_out->bInterval = 1;
  886. }
  887. }
  888. if (ep_in == NULL || ep_out == NULL) {
  889. @@ -1029,39 +1154,27 @@
  890.  
  891. mem_failure = 0;
  892. ir = kzalloc(sizeof(struct mceusb_dev), GFP_KERNEL);
  893. - if (!ir) {
  894. - mem_failure = 1;
  895. - goto mem_failure_switch;
  896. - }
  897. + if (!ir)
  898. + goto mem_alloc_fail;
  899.  
  900. driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
  901. - if (!driver) {
  902. - mem_failure = 2;
  903. - goto mem_failure_switch;
  904. - }
  905. + if (!driver)
  906. + goto mem_alloc_fail;
  907.  
  908. - rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
  909. - if (!rbuf) {
  910. - mem_failure = 3;
  911. - goto mem_failure_switch;
  912. - }
  913. -
  914. - if (lirc_buffer_init(rbuf, sizeof(lirc_t), LIRCBUF_SIZE)) {
  915. - mem_failure = 4;
  916. - goto mem_failure_switch;
  917. - }
  918. -
  919. - ir->buf_in = usb_buffer_alloc(dev, maxp, GFP_ATOMIC, &ir->dma_in);
  920. - if (!ir->buf_in) {
  921. - mem_failure = 5;
  922. - goto mem_failure_switch;
  923. - }
  924. + rbuf = kzalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
  925. + if (!rbuf)
  926. + goto mem_alloc_fail;
  927. +
  928. + if (lirc_buffer_init(rbuf, sizeof(lirc_t), LIRCBUF_SIZE))
  929. + goto mem_alloc_fail;
  930. +
  931. + ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_ATOMIC, &ir->dma_in);
  932. + if (!ir->buf_in)
  933. + goto buf_in_alloc_fail;
  934.  
  935. ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
  936. - if (!ir->urb_in) {
  937. - mem_failure = 7;
  938. - goto mem_failure_switch;
  939. - }
  940. + if (!ir->urb_in)
  941. + goto urb_in_alloc_fail;
  942.  
  943. strcpy(driver->name, DRIVER_NAME " ");
  944. driver->minor = -1;
  945. @@ -1078,33 +1191,12 @@
  946. driver->dev = &intf->dev;
  947. driver->owner = THIS_MODULE;
  948.  
  949. - mutex_init(&ir->lock);
  950. + mutex_init(&ir->dev_lock);
  951. init_waitqueue_head(&ir->wait_out);
  952.  
  953. minor = lirc_register_driver(driver);
  954. if (minor < 0)
  955. - mem_failure = 9;
  956. -
  957. -mem_failure_switch:
  958. -
  959. - switch (mem_failure) {
  960. - case 9:
  961. - usb_free_urb(ir->urb_in);
  962. - case 7:
  963. - usb_buffer_free(dev, maxp, ir->buf_in, ir->dma_in);
  964. - case 5:
  965. - lirc_buffer_free(rbuf);
  966. - case 4:
  967. - kfree(rbuf);
  968. - case 3:
  969. - kfree(driver);
  970. - case 2:
  971. - kfree(ir);
  972. - case 1:
  973. - printk(DRIVER_NAME "[%d]: out of memory (code=%d)\n",
  974. - devnum, mem_failure);
  975. - return -ENOMEM;
  976. - }
  977. + goto lirc_register_fail;
  978.  
  979. driver->minor = minor;
  980. ir->d = driver;
  981. @@ -1113,7 +1205,6 @@
  982. ir->len_in = maxp;
  983. ir->overflow_len = 0;
  984. ir->flags.connected = 0;
  985. - ir->flags.pinnacle = is_pinnacle;
  986. ir->flags.microsoft_gen1 = is_microsoft_gen1;
  987. ir->flags.transmitter_mask_inverted =
  988. usb_match_id(intf, transmitter_mask_list) ? 0 : 1;
  989. @@ -1121,8 +1212,6 @@
  990. ir->lircdata = PULSE_MASK;
  991. ir->is_pulse = 0;
  992.  
  993. - /* ir->flags.transmitter_mask_inverted must be set */
  994. - set_transmitter_mask(ir, MCE_DEFAULT_TX_MASK);
  995. /* Saving usb interface data for use by the transmitter routine */
  996. ir->usb_ep_in = ep_in;
  997. ir->usb_ep_out = ep_out;
  998. @@ -1139,73 +1228,49 @@
  999. printk(DRIVER_NAME "[%d]: %s on usb%d:%d\n", devnum, name,
  1000. dev->bus->busnum, devnum);
  1001.  
  1002. - /* inbound data */
  1003. + /* flush buffers on the device */
  1004. + mce_sync_in(ir, NULL, maxp);
  1005. + mce_sync_in(ir, NULL, maxp);
  1006. +
  1007. + /* wire up inbound data handler */
  1008. usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in,
  1009. maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval);
  1010. ir->urb_in->transfer_dma = ir->dma_in;
  1011. ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  1012.  
  1013. /* initialize device */
  1014. - if (ir->flags.pinnacle) {
  1015. - int usbret;
  1016. -
  1017. - /*
  1018. - * I have no idea why but this reset seems to be crucial to
  1019. - * getting the device to do outbound IO correctly - without
  1020. - * this the device seems to hang, ignoring all input - although
  1021. - * IR signals are correctly sent from the device, no input is
  1022. - * interpreted by the device and the host never does the
  1023. - * completion routine
  1024. - */
  1025. -
  1026. - usbret = usb_reset_configuration(dev);
  1027. - printk(DRIVER_NAME "[%d]: usb reset config ret %x\n",
  1028. - devnum, usbret);
  1029. -
  1030. - /*
  1031. - * its possible we really should wait for a return
  1032. - * for each of these...
  1033. - */
  1034. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1035. - request_packet_async(ir, ep_out, pin_init1, sizeof(pin_init1),
  1036. - MCEUSB_OUTBOUND);
  1037. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1038. - request_packet_async(ir, ep_out, pin_init2, sizeof(pin_init2),
  1039. - MCEUSB_OUTBOUND);
  1040. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1041. - request_packet_async(ir, ep_out, pin_init3, sizeof(pin_init3),
  1042. - MCEUSB_OUTBOUND);
  1043. - } else if (ir->flags.microsoft_gen1) {
  1044. - /* original ms mce device requires some additional setup */
  1045. + if (ir->flags.microsoft_gen1)
  1046. mceusb_gen1_init(ir);
  1047. - } else {
  1048. + else if (!is_gen3)
  1049. + mceusb_gen2_init(ir);
  1050.  
  1051. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1052. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1053. - request_packet_async(ir, ep_out, init1,
  1054. - sizeof(init1), MCEUSB_OUTBOUND);
  1055. - request_packet_async(ir, ep_in, NULL, maxp, MCEUSB_INBOUND);
  1056. - request_packet_async(ir, ep_out, init2,
  1057. - sizeof(init2), MCEUSB_OUTBOUND);
  1058. - }
  1059. + mceusb_get_parameters(ir);
  1060.  
  1061. - /*
  1062. - * if we don't issue the correct number of receives (MCEUSB_INBOUND)
  1063. - * for each outbound, then the first few ir pulses will be interpreted
  1064. - * by the usb_async_callback routine - we should ensure we have the
  1065. - * right amount OR less - as the meusb_dev_recv routine will handle
  1066. - * the control packets OK - they start with 0x9f - but the async
  1067. - * callback doesn't handle ir pulse packets
  1068. - */
  1069. - request_packet_async(ir, ep_in, NULL, maxp, 0);
  1070. + /* ir->flags.transmitter_mask_inverted must be set */
  1071. + set_transmitter_mask(ir, MCE_DEFAULT_TX_MASK);
  1072.  
  1073. usb_set_intfdata(intf, ir);
  1074.  
  1075. return 0;
  1076. +
  1077. + /* Error-handling path */
  1078. +lirc_register_fail:
  1079. + usb_free_urb(ir->urb_in);
  1080. +urb_in_alloc_fail:
  1081. + usb_free_coherent(dev, maxp, ir->buf_in, ir->dma_in);
  1082. +buf_in_alloc_fail:
  1083. + lirc_buffer_free(rbuf);
  1084. +mem_alloc_fail:
  1085. + kfree(rbuf);
  1086. + kfree(driver);
  1087. + kfree(ir);
  1088. + printk(KERN_ERR "out of memory (code=%d)\n", mem_failure);
  1089. +
  1090. + return -ENOMEM;
  1091. }
  1092.  
  1093.  
  1094. -static void mceusb_dev_disconnect(struct usb_interface *intf)
  1095. +static void __devexit mceusb_dev_disconnect(struct usb_interface *intf)
  1096. {
  1097. struct usb_device *dev = interface_to_usbdev(intf);
  1098. struct mceusb_dev *ir = usb_get_intfdata(intf);
  1099. @@ -1218,11 +1283,11 @@
  1100. ir->usbdev = NULL;
  1101. wake_up_all(&ir->wait_out);
  1102.  
  1103. - mutex_lock(&ir->lock);
  1104. + mutex_lock(&ir->dev_lock);
  1105. usb_kill_urb(ir->urb_in);
  1106. usb_free_urb(ir->urb_in);
  1107. - usb_buffer_free(dev, ir->len_in, ir->buf_in, ir->dma_in);
  1108. - mutex_unlock(&ir->lock);
  1109. + usb_free_coherent(dev, ir->len_in, ir->buf_in, ir->dma_in);
  1110. + mutex_unlock(&ir->dev_lock);
  1111.  
  1112. unregister_from_lirc(ir);
  1113. }
  1114. --- drivers/lirc_streamzap/lirc_streamzap.c 2010/03/17 14:16:16 1.48
  1115. +++ drivers/lirc_streanzap/lirc_streamzap.c 2010/07/25 16:43:33 1.54
  1116. @@ -1,4 +1,4 @@
  1117. -/* $Id: lirc_streamzap.c,v 1.48 2009/03/15 09:34:00 lirc Exp $ */
  1118. +/* $Id: lirc_streamzap.c,v 1.54 2010/07/25 16:43:33 jarodwilson Exp $ */
  1119. /*
  1120. * Streamzap Remote Control driver
  1121. *
  1122. @@ -54,7 +56,7 @@
  1123. #include "drivers/kcompat.h"
  1124. #include "drivers/lirc_dev/lirc_dev.h"
  1125.  
  1126. -#define DRIVER_VERSION "$Revision: 1.48 $"
  1127. +#define DRIVER_VERSION "$Revision: 1.54 $"
  1128. #define DRIVER_NAME "lirc_streamzap"
  1129. #define DRIVER_DESC "Streamzap Remote Control driver"
  1130.  
  1131. @@ -83,10 +85,11 @@
  1132.  
  1133. #define STREAMZAP_PULSE_MASK 0xf0
  1134. #define STREAMZAP_SPACE_MASK 0x0f
  1135. +#define STREAMZAP_TIMEOUT 0xff
  1136. #define STREAMZAP_RESOLUTION 256
  1137.  
  1138. /* number of samples buffered */
  1139. -#define STREAMZAP_BUFFER_SIZE 128
  1140. +#define STREAMZAP_BUFFER_SIZE 256
  1141.  
  1142. enum StreamzapDecoderState {
  1143. PulseSpace,
  1144. @@ -154,6 +157,7 @@
  1145. struct timer_list flush_timer;
  1146. int flush;
  1147. int in_use;
  1148. + int timeout_enabled;
  1149. };
  1150.  
  1151.  
  1152. @@ -317,12 +321,14 @@
  1153.  
  1154. deltv = sz->signal_start.tv_sec-sz->signal_last.tv_sec;
  1155. if (deltv > 15) {
  1156. - tmp = PULSE_MASK; /* really long time */
  1157. + /* really long time */
  1158. + tmp = LIRC_SPACE(LIRC_VALUE_MASK);
  1159. } else {
  1160. tmp = (lirc_t) (deltv*1000000+
  1161. sz->signal_start.tv_usec -
  1162. sz->signal_last.tv_usec);
  1163. tmp -= sz->sum;
  1164. + tmp = LIRC_SPACE(tmp);
  1165. }
  1166. dprintk("ls %u", sz->driver.minor, tmp);
  1167. push(sz, (char *)&tmp);
  1168. @@ -334,7 +340,7 @@
  1169. pulse = ((lirc_t) value)*STREAMZAP_RESOLUTION;
  1170. pulse += STREAMZAP_RESOLUTION/2;
  1171. sz->sum += pulse;
  1172. - pulse |= PULSE_BIT;
  1173. + pulse = LIRC_PULSE(pulse);
  1174.  
  1175. dprintk("p %u", sz->driver.minor, pulse&PULSE_MASK);
  1176. push(sz, (char *)&pulse);
  1177. @@ -354,6 +360,7 @@
  1178. space = ((lirc_t) value)*STREAMZAP_RESOLUTION;
  1179. space += STREAMZAP_RESOLUTION/2;
  1180. sz->sum += space;
  1181. + space = LIRC_SPACE(space);
  1182. dprintk("s %u", sz->driver.minor, space);
  1183. push(sz, (char *)&space);
  1184. }
  1185. @@ -426,9 +433,16 @@
  1186. sz->decoder_state = IgnorePulse;
  1187. break;
  1188. case FullSpace:
  1189. - if (sz->buf_in[i] == 0xff) {
  1190. + if (sz->buf_in[i] == STREAMZAP_TIMEOUT) {
  1191. sz->idle = 1;
  1192. stop_timer(sz);
  1193. + if (sz->timeout_enabled) {
  1194. + lirc_t timeout =
  1195. + LIRC_TIMEOUT
  1196. + (STREAMZAP_TIMEOUT *
  1197. + STREAMZAP_RESOLUTION);
  1198. + push(sz, (char *)&timeout);
  1199. + }
  1200. flush_delay_buffer(sz);
  1201. } else
  1202. push_full_space(sz, sz->buf_in[i]);
  1203. @@ -546,8 +560,8 @@
  1204.  
  1205. sz->buf_in_len = sz->endpoint->wMaxPacketSize;
  1206. #ifdef KERNEL_2_5
  1207. - sz->buf_in = usb_buffer_alloc(sz->udev, sz->buf_in_len,
  1208. - GFP_ATOMIC, &sz->dma_in);
  1209. + sz->buf_in = usb_alloc_coherent(sz->udev, sz->buf_in_len,
  1210. + GFP_ATOMIC, &sz->dma_in);
  1211. #else
  1212. sz->buf_in = kmalloc(sz->buf_in_len, GFP_KERNEL);
  1213. #endif
  1214. @@ -579,8 +593,12 @@
  1215. sz->driver.minor = -1;
  1216. sz->driver.sample_rate = 0;
  1217. sz->driver.code_length = sizeof(lirc_t) * 8;
  1218. - sz->driver.features = LIRC_CAN_REC_MODE2 | LIRC_CAN_GET_REC_RESOLUTION;
  1219. + sz->driver.features = LIRC_CAN_REC_MODE2 |
  1220. + LIRC_CAN_GET_REC_RESOLUTION |
  1221. + LIRC_CAN_SET_REC_TIMEOUT;
  1222. sz->driver.data = sz;
  1223. + sz->driver.min_timeout = STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION;
  1224. + sz->driver.max_timeout = STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION;
  1225. sz->driver.rbuf = &sz->lirc_buf;
  1226. sz->driver.set_use_inc = &streamzap_use_inc;
  1227. sz->driver.set_use_dec = &streamzap_use_dec;
  1228. @@ -657,7 +675,7 @@
  1229. if (sz) {
  1230. usb_free_urb(sz->urb_in);
  1231. #ifdef KERNEL_2_5
  1232. - usb_buffer_free(udev, sz->buf_in_len, sz->buf_in, sz->dma_in);
  1233. + usb_free_coherent(udev, sz->buf_in_len, sz->buf_in, sz->dma_in);
  1234. #else
  1235. if (sz->buf_in) {
  1236. kfree(sz->buf_in);
  1237. @@ -691,6 +709,8 @@
  1238. sz->flush = 1;
  1239. add_timer(&sz->flush_timer);
  1240.  
  1241. + sz->timeout_enabled = 0;
  1242. +
  1243. sz->urb_in->dev = sz->udev;
  1244. #ifdef KERNEL_2_5
  1245. if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) {
  1246. @@ -733,18 +753,35 @@
  1247. static int streamzap_ioctl(struct inode *node, struct file *filep,
  1248. unsigned int cmd, unsigned long arg)
  1249. {
  1250. - int result;
  1251. + int result = 0;
  1252. + lirc_t val;
  1253. + unsigned int flag = 0;
  1254. + struct usb_streamzap *sz = lirc_get_pdata(filep);
  1255.  
  1256. switch (cmd) {
  1257. case LIRC_GET_REC_RESOLUTION:
  1258. result = put_user(STREAMZAP_RESOLUTION, (unsigned int *) arg);
  1259. - if (result)
  1260. - return result;
  1261. + break;
  1262. + case LIRC_SET_REC_TIMEOUT:
  1263. + result = get_user(val, (lirc_t *)arg);
  1264. + if (result == 0) {
  1265. + if (val != STREAMZAP_TIMEOUT * STREAMZAP_RESOLUTION)
  1266. + result = -EINVAL;
  1267. + }
  1268. + break;
  1269. + case LIRC_SET_REC_TIMEOUT_REPORTS:
  1270. + result = get_user(flag, (unsigned int *)arg);
  1271. + if (result == 0) {
  1272. + if (flag != 0)
  1273. + sz->timeout_enabled = 1;
  1274. + else
  1275. + sz->timeout_enabled = 0;
  1276. + }
  1277. break;
  1278. default:
  1279. return -ENOIOCTLCMD;
  1280. }
  1281. - return 0;
  1282. + return result;
  1283. }
  1284.  
  1285. /**
  1286. @@ -788,7 +825,7 @@
  1287. usb_free_urb(sz->urb_in);
  1288.  
  1289. #ifdef KERNEL_2_5
  1290. - usb_buffer_free(sz->udev, sz->buf_in_len, sz->buf_in, sz->dma_in);
  1291. + usb_free_coherent(sz->udev, sz->buf_in_len, sz->buf_in, sz->dma_in);
  1292. #else
  1293. kfree(sz->buf_in);
  1294. #endif
  1295. --- drivers/lirc.h 2009/08/29 07:52:41 5.19
  1296. +++ drivers/lirc.h 2010/05/13 15:45:48 5.27
  1297. @@ -1,4 +1,4 @@
  1298. -/* $Id: lirc.h,v 5.19 2009/08/29 07:52:41 lirc Exp $ */
  1299. +/* $Id: lirc.h,v 5.27 2010/05/13 15:45:48 lirc Exp $ */
  1300.  
  1301. #ifndef _LINUX_LIRC_H
  1302. #define _LINUX_LIRC_H
  1303. @@ -12,8 +12,31 @@
  1304. #include <sys/ioctl.h>
  1305. #endif
  1306.  
  1307. -#define PULSE_BIT 0x01000000
  1308. -#define PULSE_MASK 0x00FFFFFF
  1309. +/* <obsolete> */
  1310. +#define PULSE_BIT 0x01000000
  1311. +#define PULSE_MASK 0x00FFFFFF
  1312. +/* </obsolete> */
  1313. +
  1314. +#define LIRC_MODE2_SPACE 0x00000000
  1315. +#define LIRC_MODE2_PULSE 0x01000000
  1316. +#define LIRC_MODE2_FREQUENCY 0x02000000
  1317. +#define LIRC_MODE2_TIMEOUT 0x03000000
  1318. +
  1319. +#define LIRC_VALUE_MASK 0x00FFFFFF
  1320. +#define LIRC_MODE2_MASK 0xFF000000
  1321. +
  1322. +#define LIRC_SPACE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
  1323. +#define LIRC_PULSE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
  1324. +#define LIRC_FREQUENCY(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
  1325. +#define LIRC_TIMEOUT(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
  1326. +
  1327. +#define LIRC_VALUE(val) ((val)&LIRC_VALUE_MASK)
  1328. +#define LIRC_MODE2(val) ((val)&LIRC_MODE2_MASK)
  1329. +
  1330. +#define LIRC_IS_SPACE(val) (LIRC_MODE2(val) == LIRC_MODE2_SPACE)
  1331. +#define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)
  1332. +#define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)
  1333. +#define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT)
  1334.  
  1335. typedef int lirc_t;
  1336.  
  1337. @@ -27,17 +50,17 @@
  1338. #define LIRC_MODE_RAW 0x00000001
  1339. #define LIRC_MODE_PULSE 0x00000002
  1340. #define LIRC_MODE_MODE2 0x00000004
  1341. -#define LIRC_MODE_CODE 0x00000008
  1342. +/* obsolete: #define LIRC_MODE_CODE 0x00000008 */
  1343. #define LIRC_MODE_LIRCCODE 0x00000010
  1344. -#define LIRC_MODE_STRING 0x00000020
  1345. +/* obsolete: #define LIRC_MODE_STRING 0x00000020 */
  1346.  
  1347.  
  1348. #define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW)
  1349. #define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE)
  1350. #define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2)
  1351. -#define LIRC_CAN_SEND_CODE LIRC_MODE2SEND(LIRC_MODE_CODE)
  1352. +/* obsolete: #define LIRC_CAN_SEND_CODE LIRC_MODE2SEND(LIRC_MODE_CODE) */
  1353. #define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE)
  1354. -#define LIRC_CAN_SEND_STRING LIRC_MODE2SEND(LIRC_MODE_STRING)
  1355. +/* obsolete: #define LIRC_CAN_SEND_STRING LIRC_MODE2SEND(LIRC_MODE_STRING) */
  1356.  
  1357. #define LIRC_CAN_SEND_MASK 0x0000003f
  1358.  
  1359. @@ -48,9 +71,9 @@
  1360. #define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW)
  1361. #define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE)
  1362. #define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2)
  1363. -#define LIRC_CAN_REC_CODE LIRC_MODE2REC(LIRC_MODE_CODE)
  1364. +/* obsolete: #define LIRC_CAN_REC_CODE LIRC_MODE2REC(LIRC_MODE_CODE) */
  1365. #define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE)
  1366. -#define LIRC_CAN_REC_STRING LIRC_MODE2REC(LIRC_MODE_STRING)
  1367. +/* obsolete: #define LIRC_CAN_REC_STRING LIRC_MODE2REC(LIRC_MODE_STRING) */
  1368.  
  1369. #define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
  1370.  
  1371. @@ -60,6 +83,10 @@
  1372. #define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000
  1373. #define LIRC_CAN_SET_REC_CARRIER_RANGE 0x80000000
  1374. #define LIRC_CAN_GET_REC_RESOLUTION 0x20000000
  1375. +#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000
  1376. +#define LIRC_CAN_SET_REC_FILTER 0x08000000
  1377. +
  1378. +#define LIRC_CAN_MEASURE_CARRIER 0x02000000
  1379.  
  1380. #define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)
  1381. #define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK)
  1382. @@ -78,10 +105,23 @@
  1383. #define LIRC_GET_REC_DUTY_CYCLE _IOR('i', 0x00000006, unsigned int)
  1384. #define LIRC_GET_REC_RESOLUTION _IOR('i', 0x00000007, unsigned int)
  1385.  
  1386. +#define LIRC_GET_MIN_TIMEOUT _IOR('i', 0x00000008, lirc_t)
  1387. +#define LIRC_GET_MAX_TIMEOUT _IOR('i', 0x00000009, lirc_t)
  1388. +
  1389. +#define LIRC_GET_MIN_FILTER_PULSE _IOR('i', 0x0000000a, lirc_t)
  1390. +#define LIRC_GET_MAX_FILTER_PULSE _IOR('i', 0x0000000b, lirc_t)
  1391. +#define LIRC_GET_MIN_FILTER_SPACE _IOR('i', 0x0000000c, lirc_t)
  1392. +#define LIRC_GET_MAX_FILTER_SPACE _IOR('i', 0x0000000d, lirc_t)
  1393. +
  1394. /* code length in bits, currently only for LIRC_MODE_LIRCCODE */
  1395. #define LIRC_GET_LENGTH _IOR('i', 0x0000000f, unsigned long)
  1396.  
  1397. +/* all values set should be reset by the driver when the device is
  1398. + reopened */
  1399. +
  1400. +/* obsolete: drivers only support one mode */
  1401. #define LIRC_SET_SEND_MODE _IOW('i', 0x00000011, unsigned long)
  1402. +/* obsolete: drivers only support one mode */
  1403. #define LIRC_SET_REC_MODE _IOW('i', 0x00000012, unsigned long)
  1404. /* Note: these can reset the according pulse_width */
  1405. #define LIRC_SET_SEND_CARRIER _IOW('i', 0x00000013, unsigned int)
  1406. @@ -90,6 +130,26 @@
  1407. #define LIRC_SET_REC_DUTY_CYCLE _IOW('i', 0x00000016, unsigned int)
  1408. #define LIRC_SET_TRANSMITTER_MASK _IOW('i', 0x00000017, unsigned int)
  1409.  
  1410. +/* a value of 0 disables all hardware timeouts and data should be
  1411. + reported as soon as possible */
  1412. +#define LIRC_SET_REC_TIMEOUT _IOW('i', 0x00000018, lirc_t)
  1413. +/* 1 enables, 0 disables timeout reports in MODE2 */
  1414. +#define LIRC_SET_REC_TIMEOUT_REPORTS _IOW('i', 0x00000019, unsigned int)
  1415. +
  1416. +/* pulses shorter than this are filtered out by hardware (software
  1417. + emulation in lirc_dev/lircd?) */
  1418. +#define LIRC_SET_REC_FILTER_PULSE _IOW('i', 0x0000001a, lirc_t)
  1419. +/* spaces shorter than this are filtered out by hardware (software
  1420. + emulation in lirc_dev/lircd?) */
  1421. +#define LIRC_SET_REC_FILTER_SPACE _IOW('i', 0x0000001b, lirc_t)
  1422. +/* if filter cannot be set independently for pulse/space, this should
  1423. + be used */
  1424. +#define LIRC_SET_REC_FILTER _IOW('i', 0x0000001c, lirc_t)
  1425. +
  1426. +/* if enabled from the next key press on the driver will send
  1427. + LIRC_MODE2_FREQUENCY packets */
  1428. +#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, unsigned int)
  1429. +
  1430. /*
  1431. * to set a range use
  1432. * LIRC_SET_REC_DUTY_CYCLE_RANGE/LIRC_SET_REC_CARRIER_RANGE with the
  1433. @@ -102,4 +162,7 @@
  1434.  
  1435. #define LIRC_NOTIFY_DECODE _IO('i', 0x00000020)
  1436.  
  1437. +#define LIRC_SETUP_START _IO('i', 0x00000021)
  1438. +#define LIRC_SETUP_END _IO('i', 0x00000022)
  1439. +
  1440. #endif
  1441. --- drivers/lirc_dev/lirc_dev.c 2009/08/31 16:57:55 1.96
  1442. +++ drivers/lirc_dev/lirc_dev.c 2010/05/13 15:45:48 1.105
  1443. @@ -17,7 +17,7 @@
  1444. * along with this program; if not, write to the Free Software
  1445. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  1446. *
  1447. - * $Id: lirc_dev.c,v 1.96 2009/08/31 16:57:55 lirc Exp $
  1448. + * $Id: lirc_dev.c,v 1.105 2010/05/13 15:45:48 lirc Exp $
  1449. *
  1450. */
  1451.  
  1452. @@ -367,8 +369,7 @@
  1453. ir->chunk_size = ir->buf->chunk_size;
  1454.  
  1455. if (d->features == 0)
  1456. - d->features = (d->code_length > 8) ?
  1457. - LIRC_CAN_REC_LIRCCODE : LIRC_CAN_REC_CODE;
  1458. + d->features = LIRC_CAN_REC_LIRCCODE;
  1459.  
  1460. ir->d = *d;
  1461. ir->d.minor = minor;
  1462. @@ -541,7 +542,7 @@
  1463. static int irctl_open(struct inode *inode, struct file *file)
  1464. {
  1465. struct irctl *ir;
  1466. - int retval;
  1467. + int retval = 0;
  1468.  
  1469. if (iminor(inode) >= MAX_IRCTL_DEVICES || !irctls[iminor(inode)]) {
  1470. dprintk("lirc_dev [%d]: open result = -ENODEV\n",
  1471. @@ -591,6 +592,8 @@
  1472. if (ir->task)
  1473. wake_up_process(ir->task);
  1474. #endif
  1475. + } else {
  1476. + retval = -ENODEV;
  1477. }
  1478. error:
  1479. if (ir)
  1480. @@ -692,6 +695,23 @@
  1481. case LIRC_GET_FEATURES:
  1482. result = put_user(ir->d.features, (unsigned long *)arg);
  1483. break;
  1484. + case LIRC_GET_LENGTH:
  1485. + result = put_user(ir->d.code_length, (unsigned long *) arg);
  1486. + break;
  1487. + case LIRC_GET_MIN_TIMEOUT:
  1488. + if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) ||
  1489. + ir->d.min_timeout == 0)
  1490. + return -ENOSYS;
  1491. +
  1492. + result = put_user(ir->d.min_timeout, (lirc_t *) arg);
  1493. + break;
  1494. + case LIRC_GET_MAX_TIMEOUT:
  1495. + if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) ||
  1496. + ir->d.max_timeout == 0)
  1497. + return -ENOSYS;
  1498. +
  1499. + result = put_user(ir->d.max_timeout, (lirc_t *) arg);
  1500. + break;
  1501. case LIRC_GET_REC_MODE:
  1502. if (!(ir->d.features & LIRC_CAN_REC_MASK))
  1503. return -ENOSYS;
  1504. @@ -700,6 +720,16 @@
  1505. (ir->d.features & LIRC_CAN_REC_MASK),
  1506. (unsigned long *)arg);
  1507. break;
  1508. + case LIRC_GET_SEND_MODE:
  1509. + if (!(ir->d.features & LIRC_CAN_SEND_MASK))
  1510. + return -ENOSYS;
  1511. +
  1512. + result = put_user(LIRC_SEND2MODE
  1513. + (ir->d.features & LIRC_CAN_SEND_MASK),
  1514. + (unsigned long *)arg);
  1515. + break;
  1516. +
  1517. + /*obsolete */
  1518. case LIRC_SET_REC_MODE:
  1519. if (!(ir->d.features & LIRC_CAN_REC_MASK))
  1520. return -ENOSYS;
  1521. @@ -707,18 +737,30 @@
  1522. result = get_user(mode, (unsigned long *)arg);
  1523. if (!result && !(LIRC_MODE2REC(mode) & ir->d.features))
  1524. result = -EINVAL;
  1525. - /*
  1526. - * FIXME: We should actually set the mode somehow but
  1527. - * for now, lirc_serial doesn't support mode changing either
  1528. - */
  1529. break;
  1530. - case LIRC_GET_LENGTH:
  1531. - result = put_user(ir->d.code_length, (unsigned long *) arg);
  1532. + case LIRC_SET_SEND_MODE:
  1533. + if (!(ir->d.features & LIRC_CAN_SEND_MASK))
  1534. + return -ENOSYS;
  1535. +
  1536. + result = get_user(mode, (unsigned long *)arg);
  1537. + if (!result && !(LIRC_MODE2SEND(mode) & ir->d.features))
  1538. + result = -EINVAL;
  1539. break;
  1540. default:
  1541. result = -EINVAL;
  1542. }
  1543.  
  1544. + switch (cmd) {
  1545. + case LIRC_SET_REC_MODE:
  1546. + case LIRC_SET_SEND_MODE:
  1547. + printk(KERN_NOTICE LOGHEAD "userspace uses outdated ioctl "
  1548. + "please update your lirc installation\n",
  1549. + ir->d.name, ir->d.minor);
  1550. + break;
  1551. + default:
  1552. + break;
  1553. + }
  1554. +
  1555. dprintk(LOGHEAD "ioctl result = %d\n",
  1556. ir->d.name, ir->d.minor, result);
  1557.  
  1558. @@ -791,16 +833,31 @@
  1559. case LIRC_GET_SEND_DUTY_CYCLE:
  1560. case LIRC_GET_REC_DUTY_CYCLE:
  1561. case LIRC_GET_REC_RESOLUTION:
  1562. + case LIRC_GET_MIN_TIMEOUT:
  1563. + case LIRC_GET_MAX_TIMEOUT:
  1564. + case LIRC_GET_MIN_FILTER_PULSE:
  1565. + case LIRC_GET_MAX_FILTER_PULSE:
  1566. + case LIRC_GET_MIN_FILTER_SPACE:
  1567. + case LIRC_GET_MAX_FILTER_SPACE:
  1568. case LIRC_SET_SEND_CARRIER:
  1569. case LIRC_SET_REC_CARRIER:
  1570. case LIRC_SET_SEND_DUTY_CYCLE:
  1571. case LIRC_SET_REC_DUTY_CYCLE:
  1572. case LIRC_SET_TRANSMITTER_MASK:
  1573. + case LIRC_SET_REC_TIMEOUT:
  1574. + case LIRC_SET_REC_TIMEOUT_REPORTS:
  1575. + case LIRC_SET_REC_FILTER_PULSE:
  1576. + case LIRC_SET_REC_FILTER_SPACE:
  1577. + case LIRC_SET_REC_FILTER:
  1578. + case LIRC_SET_MEASURE_CARRIER_MODE:
  1579. case LIRC_SET_REC_DUTY_CYCLE_RANGE:
  1580. case LIRC_SET_REC_CARRIER_RANGE:
  1581. + case LIRC_NOTIFY_DECODE:
  1582. + case LIRC_SETUP_START:
  1583. + case LIRC_SETUP_END:
  1584. /*
  1585. - * These commands expect (unsigned int *)arg
  1586. - * so no problems here. Just handle the locking.
  1587. + * These commands expect (unsigned int *) or (lirc_t *)
  1588. + * arg so no problems here. Just handle the locking.
  1589. */
  1590. lock_kernel();
  1591. cmd = cmd32;
  1592. --- drivers/lirc_dev/lirc_dev.h 2009/12/28 15:21:17 1.38
  1593. +++ drivers/lirc_dev/lirc_dev.h 2010/04/25 08:33:52 1.41
  1594. @@ -4,7 +4,7 @@
  1595. * (L) by Artur Lipowski <alipowski@interia.pl>
  1596. * This code is licensed under GNU GPL
  1597. *
  1598. - * $Id: lirc_dev.h,v 1.38 2009/12/28 15:21:17 jarodwilson Exp $
  1599. + * $Id: lirc_dev.h,v 1.41 2010/04/25 08:33:52 lirc Exp $
  1600. *
  1601. */
  1602.  
  1603. @@ -28,6 +28,8 @@
  1604. #include <linux/kfifo.h>
  1605. #endif
  1606.  
  1607. +#include "drivers/lirc.h"
  1608. +
  1609. struct lirc_buffer {
  1610. wait_queue_head_t wait_poll;
  1611. spinlock_t fifo_lock;
  1612. @@ -68,13 +70,13 @@
  1613. #endif
  1614. static inline void lirc_buffer_clear(struct lirc_buffer *buf)
  1615. {
  1616. - unsigned long flags;
  1617. -
  1618. #ifdef LIRC_HAVE_KFIFO
  1619. #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
  1620. if (buf->fifo)
  1621. kfifo_reset(buf->fifo);
  1622. #else
  1623. + unsigned long flags;
  1624. +
  1625. if (buf->fifo_initialized) {
  1626. spin_lock_irqsave(&buf->fifo_lock, flags);
  1627. kfifo_reset(&buf->fifo);
  1628. @@ -82,6 +84,8 @@
  1629. }
  1630. #endif
  1631. #else
  1632. + unsigned long flags;
  1633. +
  1634. lirc_buffer_lock(buf, &flags);
  1635. _lirc_buffer_clear(buf);
  1636. lirc_buffer_unlock(buf, &flags);
  1637. @@ -331,6 +335,8 @@
  1638. int sample_rate;
  1639. unsigned long features;
  1640. void *data;
  1641. + lirc_t min_timeout;
  1642. + lirc_t max_timeout;
  1643. int (*add_to_buf) (void *data, struct lirc_buffer *buf);
  1644. #ifndef LIRC_REMOVE_DURING_EXPORT
  1645. wait_queue_head_t* (*get_queue) (void *data);
  1646. @@ -338,7 +344,7 @@
  1647. struct lirc_buffer *rbuf;
  1648. int (*set_use_inc) (void *data);
  1649. void (*set_use_dec) (void *data);
  1650. - struct file_operations *fops;
  1651. + const struct file_operations *fops;
  1652. struct device *dev;
  1653. struct module *owner;
  1654. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement