saa7134-input.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. *
  3. * handle saa7134 IR remotes via linux kernel input layer.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #include <linux/module.h>
  21. #include <linux/init.h>
  22. #include <linux/delay.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/input.h>
  25. #include "saa7134-reg.h"
  26. #include "saa7134.h"
  27. static unsigned int disable_ir;
  28. module_param(disable_ir, int, 0444);
  29. MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
  30. static unsigned int ir_debug;
  31. module_param(ir_debug, int, 0644);
  32. MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
  33. static int pinnacle_remote;
  34. module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
  35. MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
  36. static int ir_rc5_remote_gap = 885;
  37. module_param(ir_rc5_remote_gap, int, 0644);
  38. static int ir_rc5_key_timeout = 115;
  39. module_param(ir_rc5_key_timeout, int, 0644);
  40. static int repeat_delay = 500;
  41. module_param(repeat_delay, int, 0644);
  42. MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
  43. static int repeat_period = 33;
  44. module_param(repeat_period, int, 0644);
  45. MODULE_PARM_DESC(repeat_period, "repeat period between "
  46. "keypresses when key is down");
  47. static unsigned int disable_other_ir;
  48. module_param(disable_other_ir, int, 0644);
  49. MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
  50. "alternative remotes from other manufacturers");
  51. #define dprintk(fmt, arg...) if (ir_debug) \
  52. printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
  53. #define i2cdprintk(fmt, arg...) if (ir_debug) \
  54. printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
  55. /** rc5 functions */
  56. static int saa7134_rc5_irq(struct saa7134_dev *dev);
  57. /* -------------------- GPIO generic keycode builder -------------------- */
  58. static int build_key(struct saa7134_dev *dev)
  59. {
  60. struct card_ir *ir = dev->remote;
  61. u32 gpio, data;
  62. /* here comes the additional handshake steps for some cards */
  63. switch (dev->board) {
  64. case SAA7134_BOARD_GOTVIEW_7135:
  65. saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
  66. saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
  67. break;
  68. }
  69. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  70. saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
  71. saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
  72. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  73. if (ir->polling) {
  74. if (ir->last_gpio == gpio)
  75. return 0;
  76. ir->last_gpio = gpio;
  77. }
  78. data = ir_extract_bits(gpio, ir->mask_keycode);
  79. dprintk("build_key gpio=0x%x mask=0x%x data=%d\n",
  80. gpio, ir->mask_keycode, data);
  81. if (ir->polling) {
  82. if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
  83. (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
  84. ir_input_keydown(ir->dev, &ir->ir, data, data);
  85. } else {
  86. ir_input_nokey(ir->dev, &ir->ir);
  87. }
  88. }
  89. else { /* IRQ driven mode - handle key press and release in one go */
  90. if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
  91. (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
  92. ir_input_keydown(ir->dev, &ir->ir, data, data);
  93. ir_input_nokey(ir->dev, &ir->ir);
  94. }
  95. }
  96. return 0;
  97. }
  98. /* --------------------- Chip specific I2C key builders ----------------- */
  99. static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  100. {
  101. unsigned char b;
  102. /* poll IR chip */
  103. if (1 != i2c_master_recv(&ir->c,&b,1)) {
  104. i2cdprintk("read error\n");
  105. return -EIO;
  106. }
  107. /* no button press */
  108. if (b==0)
  109. return 0;
  110. /* repeating */
  111. if (b & 0x80)
  112. return 1;
  113. *ir_key = b;
  114. *ir_raw = b;
  115. return 1;
  116. }
  117. static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  118. {
  119. unsigned char buf[5], cod4, code3, code4;
  120. /* poll IR chip */
  121. if (5 != i2c_master_recv(&ir->c,buf,5))
  122. return -EIO;
  123. cod4 = buf[4];
  124. code4 = (cod4 >> 2);
  125. code3 = buf[3];
  126. if (code3 == 0)
  127. /* no key pressed */
  128. return 0;
  129. /* return key */
  130. *ir_key = code4;
  131. *ir_raw = code4;
  132. return 1;
  133. }
  134. static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  135. {
  136. unsigned char data[12];
  137. u32 gpio;
  138. struct saa7134_dev *dev = ir->c.adapter->algo_data;
  139. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  140. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  141. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  142. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  143. if (0x400000 & ~gpio)
  144. return 0; /* No button press */
  145. ir->c.addr = 0x5a >> 1;
  146. if (12 != i2c_master_recv(&ir->c, data, 12)) {
  147. i2cdprintk("read error\n");
  148. return -EIO;
  149. }
  150. /* IR of this card normally decode signals NEC-standard from
  151. * - Sven IHOO MT 5.1R remote. xxyye718
  152. * - Sven DVD HD-10xx remote. xxyyf708
  153. * - BBK ...
  154. * - mayby others
  155. * So, skip not our, if disable full codes mode.
  156. */
  157. if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir)
  158. return 0;
  159. *ir_key = data[9];
  160. *ir_raw = data[9];
  161. return 1;
  162. }
  163. void saa7134_input_irq(struct saa7134_dev *dev)
  164. {
  165. struct card_ir *ir = dev->remote;
  166. if (!ir->polling && !ir->rc5_gpio) {
  167. build_key(dev);
  168. } else if (ir->rc5_gpio) {
  169. saa7134_rc5_irq(dev);
  170. }
  171. }
  172. static void saa7134_input_timer(unsigned long data)
  173. {
  174. struct saa7134_dev *dev = (struct saa7134_dev *)data;
  175. struct card_ir *ir = dev->remote;
  176. build_key(dev);
  177. mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
  178. }
  179. void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
  180. {
  181. if (ir->polling) {
  182. setup_timer(&ir->timer, saa7134_input_timer,
  183. (unsigned long)dev);
  184. ir->timer.expires = jiffies + HZ;
  185. add_timer(&ir->timer);
  186. } else if (ir->rc5_gpio) {
  187. /* set timer_end for code completion */
  188. init_timer(&ir->timer_end);
  189. ir->timer_end.function = ir_rc5_timer_end;
  190. ir->timer_end.data = (unsigned long)ir;
  191. init_timer(&ir->timer_keyup);
  192. ir->timer_keyup.function = ir_rc5_timer_keyup;
  193. ir->timer_keyup.data = (unsigned long)ir;
  194. ir->shift_by = 2;
  195. ir->start = 0x2;
  196. ir->addr = 0x17;
  197. ir->rc5_key_timeout = ir_rc5_key_timeout;
  198. ir->rc5_remote_gap = ir_rc5_remote_gap;
  199. }
  200. }
  201. void saa7134_ir_stop(struct saa7134_dev *dev)
  202. {
  203. if (dev->remote->polling)
  204. del_timer_sync(&dev->remote->timer);
  205. }
  206. int saa7134_input_init1(struct saa7134_dev *dev)
  207. {
  208. struct card_ir *ir;
  209. struct input_dev *input_dev;
  210. IR_KEYTAB_TYPE *ir_codes = NULL;
  211. u32 mask_keycode = 0;
  212. u32 mask_keydown = 0;
  213. u32 mask_keyup = 0;
  214. int polling = 0;
  215. int rc5_gpio = 0;
  216. int ir_type = IR_TYPE_OTHER;
  217. int err;
  218. if (dev->has_remote != SAA7134_REMOTE_GPIO)
  219. return -ENODEV;
  220. if (disable_ir)
  221. return -ENODEV;
  222. /* detect & configure */
  223. switch (dev->board) {
  224. case SAA7134_BOARD_FLYVIDEO2000:
  225. case SAA7134_BOARD_FLYVIDEO3000:
  226. case SAA7134_BOARD_FLYTVPLATINUM_FM:
  227. case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
  228. ir_codes = ir_codes_flyvideo;
  229. mask_keycode = 0xEC00000;
  230. mask_keydown = 0x0040000;
  231. break;
  232. case SAA7134_BOARD_CINERGY400:
  233. case SAA7134_BOARD_CINERGY600:
  234. case SAA7134_BOARD_CINERGY600_MK3:
  235. ir_codes = ir_codes_cinergy;
  236. mask_keycode = 0x00003f;
  237. mask_keyup = 0x040000;
  238. break;
  239. case SAA7134_BOARD_ECS_TVP3XP:
  240. case SAA7134_BOARD_ECS_TVP3XP_4CB5:
  241. ir_codes = ir_codes_eztv;
  242. mask_keycode = 0x00017c;
  243. mask_keyup = 0x000002;
  244. polling = 50; // ms
  245. break;
  246. case SAA7134_BOARD_KWORLD_XPERT:
  247. case SAA7134_BOARD_AVACSSMARTTV:
  248. ir_codes = ir_codes_pixelview;
  249. mask_keycode = 0x00001F;
  250. mask_keyup = 0x000020;
  251. polling = 50; // ms
  252. break;
  253. case SAA7134_BOARD_MD2819:
  254. case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
  255. case SAA7134_BOARD_AVERMEDIA_305:
  256. case SAA7134_BOARD_AVERMEDIA_307:
  257. case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
  258. case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
  259. case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
  260. case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
  261. case SAA7134_BOARD_AVERMEDIA_M102:
  262. ir_codes = ir_codes_avermedia;
  263. mask_keycode = 0x0007C8;
  264. mask_keydown = 0x000010;
  265. polling = 50; // ms
  266. /* Set GPIO pin2 to high to enable the IR controller */
  267. saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
  268. saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
  269. break;
  270. case SAA7134_BOARD_AVERMEDIA_777:
  271. case SAA7134_BOARD_AVERMEDIA_A16AR:
  272. ir_codes = ir_codes_avermedia;
  273. mask_keycode = 0x02F200;
  274. mask_keydown = 0x000400;
  275. polling = 50; // ms
  276. /* Without this we won't receive key up events */
  277. saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
  278. saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
  279. break;
  280. case SAA7134_BOARD_KWORLD_TERMINATOR:
  281. ir_codes = ir_codes_pixelview;
  282. mask_keycode = 0x00001f;
  283. mask_keyup = 0x000060;
  284. polling = 50; // ms
  285. break;
  286. case SAA7134_BOARD_MANLI_MTV001:
  287. case SAA7134_BOARD_MANLI_MTV002:
  288. case SAA7134_BOARD_BEHOLD_409FM:
  289. case SAA7134_BOARD_BEHOLD_401:
  290. case SAA7134_BOARD_BEHOLD_403:
  291. case SAA7134_BOARD_BEHOLD_403FM:
  292. case SAA7134_BOARD_BEHOLD_405:
  293. case SAA7134_BOARD_BEHOLD_405FM:
  294. case SAA7134_BOARD_BEHOLD_407:
  295. case SAA7134_BOARD_BEHOLD_407FM:
  296. case SAA7134_BOARD_BEHOLD_409:
  297. case SAA7134_BOARD_BEHOLD_505FM:
  298. case SAA7134_BOARD_BEHOLD_507_9FM:
  299. ir_codes = ir_codes_manli;
  300. mask_keycode = 0x001f00;
  301. mask_keyup = 0x004000;
  302. polling = 50; // ms
  303. break;
  304. case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
  305. ir_codes = ir_codes_pctv_sedna;
  306. mask_keycode = 0x001f00;
  307. mask_keyup = 0x004000;
  308. polling = 50; // ms
  309. break;
  310. case SAA7134_BOARD_GOTVIEW_7135:
  311. ir_codes = ir_codes_gotview7135;
  312. mask_keycode = 0x0003CC;
  313. mask_keydown = 0x000010;
  314. polling = 5; /* ms */
  315. saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
  316. break;
  317. case SAA7134_BOARD_VIDEOMATE_TV_PVR:
  318. case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
  319. case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
  320. ir_codes = ir_codes_videomate_tv_pvr;
  321. mask_keycode = 0x00003F;
  322. mask_keyup = 0x400000;
  323. polling = 50; // ms
  324. break;
  325. case SAA7134_BOARD_PROTEUS_2309:
  326. ir_codes = ir_codes_proteus_2309;
  327. mask_keycode = 0x00007F;
  328. mask_keyup = 0x000080;
  329. polling = 50; // ms
  330. break;
  331. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  332. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  333. ir_codes = ir_codes_videomate_tv_pvr;
  334. mask_keycode = 0x003F00;
  335. mask_keyup = 0x040000;
  336. break;
  337. case SAA7134_BOARD_FLYDVBS_LR300:
  338. case SAA7134_BOARD_FLYDVBT_LR301:
  339. case SAA7134_BOARD_FLYDVBTDUO:
  340. ir_codes = ir_codes_flydvb;
  341. mask_keycode = 0x0001F00;
  342. mask_keydown = 0x0040000;
  343. break;
  344. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  345. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  346. ir_codes = ir_codes_asus_pc39;
  347. mask_keydown = 0x0040000;
  348. rc5_gpio = 1;
  349. break;
  350. case SAA7134_BOARD_ENCORE_ENLTV:
  351. case SAA7134_BOARD_ENCORE_ENLTV_FM:
  352. ir_codes = ir_codes_encore_enltv;
  353. mask_keycode = 0x00007f;
  354. mask_keyup = 0x040000;
  355. polling = 50; // ms
  356. break;
  357. case SAA7134_BOARD_10MOONSTVMASTER3:
  358. ir_codes = ir_codes_encore_enltv;
  359. mask_keycode = 0x5f80000;
  360. mask_keyup = 0x8000000;
  361. polling = 50; //ms
  362. break;
  363. case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
  364. ir_codes = ir_codes_genius_tvgo_a11mce;
  365. mask_keycode = 0xff;
  366. mask_keydown = 0xf00000;
  367. polling = 50; /* ms */
  368. break;
  369. }
  370. if (NULL == ir_codes) {
  371. printk("%s: Oops: IR config error [card=%d]\n",
  372. dev->name, dev->board);
  373. return -ENODEV;
  374. }
  375. ir = kzalloc(sizeof(*ir), GFP_KERNEL);
  376. input_dev = input_allocate_device();
  377. if (!ir || !input_dev) {
  378. err = -ENOMEM;
  379. goto err_out_free;
  380. }
  381. ir->dev = input_dev;
  382. /* init hardware-specific stuff */
  383. ir->mask_keycode = mask_keycode;
  384. ir->mask_keydown = mask_keydown;
  385. ir->mask_keyup = mask_keyup;
  386. ir->polling = polling;
  387. ir->rc5_gpio = rc5_gpio;
  388. /* init input device */
  389. snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
  390. saa7134_boards[dev->board].name);
  391. snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
  392. pci_name(dev->pci));
  393. ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
  394. input_dev->name = ir->name;
  395. input_dev->phys = ir->phys;
  396. input_dev->id.bustype = BUS_PCI;
  397. input_dev->id.version = 1;
  398. if (dev->pci->subsystem_vendor) {
  399. input_dev->id.vendor = dev->pci->subsystem_vendor;
  400. input_dev->id.product = dev->pci->subsystem_device;
  401. } else {
  402. input_dev->id.vendor = dev->pci->vendor;
  403. input_dev->id.product = dev->pci->device;
  404. }
  405. input_dev->dev.parent = &dev->pci->dev;
  406. dev->remote = ir;
  407. saa7134_ir_start(dev, ir);
  408. err = input_register_device(ir->dev);
  409. if (err)
  410. goto err_out_stop;
  411. /* the remote isn't as bouncy as a keyboard */
  412. ir->dev->rep[REP_DELAY] = repeat_delay;
  413. ir->dev->rep[REP_PERIOD] = repeat_period;
  414. return 0;
  415. err_out_stop:
  416. saa7134_ir_stop(dev);
  417. dev->remote = NULL;
  418. err_out_free:
  419. input_free_device(input_dev);
  420. kfree(ir);
  421. return err;
  422. }
  423. void saa7134_input_fini(struct saa7134_dev *dev)
  424. {
  425. if (NULL == dev->remote)
  426. return;
  427. saa7134_ir_stop(dev);
  428. input_unregister_device(dev->remote->dev);
  429. kfree(dev->remote);
  430. dev->remote = NULL;
  431. }
  432. void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
  433. {
  434. if (disable_ir) {
  435. dprintk("Found supported i2c remote, but IR has been disabled\n");
  436. ir->get_key=NULL;
  437. return;
  438. }
  439. switch (dev->board) {
  440. case SAA7134_BOARD_PINNACLE_PCTV_110i:
  441. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  442. snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
  443. if (pinnacle_remote == 0) {
  444. ir->get_key = get_key_pinnacle_color;
  445. ir->ir_codes = ir_codes_pinnacle_color;
  446. } else {
  447. ir->get_key = get_key_pinnacle_grey;
  448. ir->ir_codes = ir_codes_pinnacle_grey;
  449. }
  450. break;
  451. case SAA7134_BOARD_UPMOST_PURPLE_TV:
  452. snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
  453. ir->get_key = get_key_purpletv;
  454. ir->ir_codes = ir_codes_purpletv;
  455. break;
  456. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  457. snprintf(ir->c.name, sizeof(ir->c.name), "HVR 1110");
  458. ir->get_key = get_key_hvr1110;
  459. ir->ir_codes = ir_codes_hauppauge_new;
  460. break;
  461. case SAA7134_BOARD_BEHOLD_607_9FM:
  462. case SAA7134_BOARD_BEHOLD_M6:
  463. snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV");
  464. ir->get_key = get_key_beholdm6xx;
  465. ir->ir_codes = ir_codes_behold;
  466. break;
  467. default:
  468. dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board);
  469. break;
  470. }
  471. }
  472. static int saa7134_rc5_irq(struct saa7134_dev *dev)
  473. {
  474. struct card_ir *ir = dev->remote;
  475. struct timeval tv;
  476. u32 gap;
  477. unsigned long current_jiffies, timeout;
  478. /* get time of bit */
  479. current_jiffies = jiffies;
  480. do_gettimeofday(&tv);
  481. /* avoid overflow with gap >1s */
  482. if (tv.tv_sec - ir->base_time.tv_sec > 1) {
  483. gap = 200000;
  484. } else {
  485. gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
  486. tv.tv_usec - ir->base_time.tv_usec;
  487. }
  488. /* active code => add bit */
  489. if (ir->active) {
  490. /* only if in the code (otherwise spurious IRQ or timer
  491. late) */
  492. if (ir->last_bit < 28) {
  493. ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
  494. ir_rc5_remote_gap;
  495. ir->code |= 1 << ir->last_bit;
  496. }
  497. /* starting new code */
  498. } else {
  499. ir->active = 1;
  500. ir->code = 0;
  501. ir->base_time = tv;
  502. ir->last_bit = 0;
  503. timeout = current_jiffies + (500 + 30 * HZ) / 1000;
  504. mod_timer(&ir->timer_end, timeout);
  505. }
  506. return 1;
  507. }
  508. /* ----------------------------------------------------------------------
  509. * Local variables:
  510. * c-basic-offset: 8
  511. * End:
  512. */