saa7134-input.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  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 <linux/slab.h>
  26. #include "saa7134-reg.h"
  27. #include "saa7134.h"
  28. #define MODULE_NAME "saa7134"
  29. static unsigned int disable_ir;
  30. module_param(disable_ir, int, 0444);
  31. MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
  32. static unsigned int ir_debug;
  33. module_param(ir_debug, int, 0644);
  34. MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
  35. static int pinnacle_remote;
  36. module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
  37. MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
  38. static int ir_rc5_remote_gap = 885;
  39. module_param(ir_rc5_remote_gap, int, 0644);
  40. static int ir_rc5_key_timeout = 115;
  41. module_param(ir_rc5_key_timeout, int, 0644);
  42. static int repeat_delay = 500;
  43. module_param(repeat_delay, int, 0644);
  44. MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
  45. static int repeat_period = 33;
  46. module_param(repeat_period, int, 0644);
  47. MODULE_PARM_DESC(repeat_period, "repeat period between "
  48. "keypresses when key is down");
  49. static unsigned int disable_other_ir;
  50. module_param(disable_other_ir, int, 0644);
  51. MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
  52. "alternative remotes from other manufacturers");
  53. #define dprintk(fmt, arg...) if (ir_debug) \
  54. printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
  55. #define i2cdprintk(fmt, arg...) if (ir_debug) \
  56. printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg)
  57. /* Helper functions for RC5 and NEC decoding at GPIO16 or GPIO18 */
  58. static int saa7134_rc5_irq(struct saa7134_dev *dev);
  59. static int saa7134_nec_irq(struct saa7134_dev *dev);
  60. static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
  61. static void nec_task(unsigned long data);
  62. static void saa7134_nec_timer(unsigned long data);
  63. /* -------------------- GPIO generic keycode builder -------------------- */
  64. static int build_key(struct saa7134_dev *dev)
  65. {
  66. struct card_ir *ir = dev->remote;
  67. u32 gpio, data;
  68. /* here comes the additional handshake steps for some cards */
  69. switch (dev->board) {
  70. case SAA7134_BOARD_GOTVIEW_7135:
  71. saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
  72. saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
  73. break;
  74. }
  75. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  76. saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
  77. saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
  78. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  79. if (ir->polling) {
  80. if (ir->last_gpio == gpio)
  81. return 0;
  82. ir->last_gpio = gpio;
  83. }
  84. data = ir_extract_bits(gpio, ir->mask_keycode);
  85. dprintk("build_key gpio=0x%x mask=0x%x data=%d\n",
  86. gpio, ir->mask_keycode, data);
  87. switch (dev->board) {
  88. case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
  89. if (data == ir->mask_keycode)
  90. ir_input_nokey(ir->dev, &ir->ir);
  91. else
  92. ir_input_keydown(ir->dev, &ir->ir, data);
  93. return 0;
  94. }
  95. if (ir->polling) {
  96. if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
  97. (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
  98. ir_input_keydown(ir->dev, &ir->ir, data);
  99. } else {
  100. ir_input_nokey(ir->dev, &ir->ir);
  101. }
  102. }
  103. else { /* IRQ driven mode - handle key press and release in one go */
  104. if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
  105. (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
  106. ir_input_keydown(ir->dev, &ir->ir, data);
  107. ir_input_nokey(ir->dev, &ir->ir);
  108. }
  109. }
  110. return 0;
  111. }
  112. /* --------------------- Chip specific I2C key builders ----------------- */
  113. static int get_key_flydvb_trio(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  114. {
  115. int gpio;
  116. int attempt = 0;
  117. unsigned char b;
  118. /* We need this to access GPI Used by the saa_readl macro. */
  119. struct saa7134_dev *dev = ir->c->adapter->algo_data;
  120. if (dev == NULL) {
  121. dprintk("get_key_flydvb_trio: "
  122. "gir->c->adapter->algo_data is NULL!\n");
  123. return -EIO;
  124. }
  125. /* rising SAA7134_GPIGPRESCAN reads the status */
  126. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  127. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  128. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  129. if (0x40000 & ~gpio)
  130. return 0; /* No button press */
  131. /* No button press - only before first key pressed */
  132. if (b == 0xFF)
  133. return 0;
  134. /* poll IR chip */
  135. /* weak up the IR chip */
  136. b = 0;
  137. while (1 != i2c_master_send(ir->c, &b, 1)) {
  138. if ((attempt++) < 10) {
  139. /*
  140. * wait a bit for next attempt -
  141. * I don't know how make it better
  142. */
  143. msleep(10);
  144. continue;
  145. }
  146. i2cdprintk("send wake up byte to pic16C505 (IR chip)"
  147. "failed %dx\n", attempt);
  148. return -EIO;
  149. }
  150. if (1 != i2c_master_recv(ir->c, &b, 1)) {
  151. i2cdprintk("read error\n");
  152. return -EIO;
  153. }
  154. *ir_key = b;
  155. *ir_raw = b;
  156. return 1;
  157. }
  158. static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key,
  159. u32 *ir_raw)
  160. {
  161. unsigned char b;
  162. int gpio;
  163. /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
  164. struct saa7134_dev *dev = ir->c->adapter->algo_data;
  165. if (dev == NULL) {
  166. dprintk("get_key_msi_tvanywhere_plus: "
  167. "gir->c->adapter->algo_data is NULL!\n");
  168. return -EIO;
  169. }
  170. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  171. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  172. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  173. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  174. /* GPIO&0x40 is pulsed low when a button is pressed. Don't do
  175. I2C receive if gpio&0x40 is not low. */
  176. if (gpio & 0x40)
  177. return 0; /* No button press */
  178. /* GPIO says there is a button press. Get it. */
  179. if (1 != i2c_master_recv(ir->c, &b, 1)) {
  180. i2cdprintk("read error\n");
  181. return -EIO;
  182. }
  183. /* No button press */
  184. if (b == 0xff)
  185. return 0;
  186. /* Button pressed */
  187. dprintk("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b);
  188. *ir_key = b;
  189. *ir_raw = b;
  190. return 1;
  191. }
  192. static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  193. {
  194. unsigned char b;
  195. /* poll IR chip */
  196. if (1 != i2c_master_recv(ir->c, &b, 1)) {
  197. i2cdprintk("read error\n");
  198. return -EIO;
  199. }
  200. /* no button press */
  201. if (b==0)
  202. return 0;
  203. /* repeating */
  204. if (b & 0x80)
  205. return 1;
  206. *ir_key = b;
  207. *ir_raw = b;
  208. return 1;
  209. }
  210. static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  211. {
  212. unsigned char buf[5], cod4, code3, code4;
  213. /* poll IR chip */
  214. if (5 != i2c_master_recv(ir->c, buf, 5))
  215. return -EIO;
  216. cod4 = buf[4];
  217. code4 = (cod4 >> 2);
  218. code3 = buf[3];
  219. if (code3 == 0)
  220. /* no key pressed */
  221. return 0;
  222. /* return key */
  223. *ir_key = code4;
  224. *ir_raw = code4;
  225. return 1;
  226. }
  227. static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  228. {
  229. unsigned char data[12];
  230. u32 gpio;
  231. struct saa7134_dev *dev = ir->c->adapter->algo_data;
  232. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  233. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  234. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  235. gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
  236. if (0x400000 & ~gpio)
  237. return 0; /* No button press */
  238. ir->c->addr = 0x5a >> 1;
  239. if (12 != i2c_master_recv(ir->c, data, 12)) {
  240. i2cdprintk("read error\n");
  241. return -EIO;
  242. }
  243. /* IR of this card normally decode signals NEC-standard from
  244. * - Sven IHOO MT 5.1R remote. xxyye718
  245. * - Sven DVD HD-10xx remote. xxyyf708
  246. * - BBK ...
  247. * - mayby others
  248. * So, skip not our, if disable full codes mode.
  249. */
  250. if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir)
  251. return 0;
  252. /* Wrong data decode fix */
  253. if (data[9] != (unsigned char)(~data[8]))
  254. return 0;
  255. *ir_key = data[9];
  256. *ir_raw = data[9];
  257. return 1;
  258. }
  259. /* Common (grey or coloured) pinnacle PCTV remote handling
  260. *
  261. */
  262. static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
  263. int parity_offset, int marker, int code_modulo)
  264. {
  265. unsigned char b[4];
  266. unsigned int start = 0,parity = 0,code = 0;
  267. /* poll IR chip */
  268. if (4 != i2c_master_recv(ir->c, b, 4)) {
  269. i2cdprintk("read error\n");
  270. return -EIO;
  271. }
  272. for (start = 0; start < ARRAY_SIZE(b); start++) {
  273. if (b[start] == marker) {
  274. code=b[(start+parity_offset + 1) % 4];
  275. parity=b[(start+parity_offset) % 4];
  276. }
  277. }
  278. /* Empty Request */
  279. if (parity == 0)
  280. return 0;
  281. /* Repeating... */
  282. if (ir->old == parity)
  283. return 0;
  284. ir->old = parity;
  285. /* drop special codes when a key is held down a long time for the grey controller
  286. In this case, the second bit of the code is asserted */
  287. if (marker == 0xfe && (code & 0x40))
  288. return 0;
  289. code %= code_modulo;
  290. *ir_raw = code;
  291. *ir_key = code;
  292. i2cdprintk("Pinnacle PCTV key %02x\n", code);
  293. return 1;
  294. }
  295. /* The grey pinnacle PCTV remote
  296. *
  297. * There are one issue with this remote:
  298. * - I2c packet does not change when the same key is pressed quickly. The workaround
  299. * is to hold down each key for about half a second, so that another code is generated
  300. * in the i2c packet, and the function can distinguish key presses.
  301. *
  302. * Sylvain Pasche <sylvain.pasche@gmail.com>
  303. */
  304. static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  305. {
  306. return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
  307. }
  308. /* The new pinnacle PCTV remote (with the colored buttons)
  309. *
  310. * Ricardo Cerqueira <v4l@cerqueira.org>
  311. */
  312. static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
  313. {
  314. /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
  315. *
  316. * this is the only value that results in 42 unique
  317. * codes < 128
  318. */
  319. return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
  320. }
  321. void saa7134_input_irq(struct saa7134_dev *dev)
  322. {
  323. struct card_ir *ir = dev->remote;
  324. if (ir->nec_gpio) {
  325. saa7134_nec_irq(dev);
  326. } else if (!ir->polling && !ir->rc5_gpio && !ir->raw_decode) {
  327. build_key(dev);
  328. } else if (ir->rc5_gpio) {
  329. saa7134_rc5_irq(dev);
  330. } else if (ir->raw_decode) {
  331. saa7134_raw_decode_irq(dev);
  332. }
  333. }
  334. static void saa7134_input_timer(unsigned long data)
  335. {
  336. struct saa7134_dev *dev = (struct saa7134_dev *)data;
  337. struct card_ir *ir = dev->remote;
  338. build_key(dev);
  339. mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
  340. }
  341. void ir_raw_decode_timer_end(unsigned long data)
  342. {
  343. struct saa7134_dev *dev = (struct saa7134_dev *)data;
  344. ir_raw_event_handle(dev->remote->dev);
  345. }
  346. void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
  347. {
  348. if (ir->running)
  349. return;
  350. ir->running = 1;
  351. if (ir->polling) {
  352. setup_timer(&ir->timer, saa7134_input_timer,
  353. (unsigned long)dev);
  354. ir->timer.expires = jiffies + HZ;
  355. add_timer(&ir->timer);
  356. } else if (ir->rc5_gpio) {
  357. /* set timer_end for code completion */
  358. init_timer(&ir->timer_end);
  359. ir->timer_end.function = ir_rc5_timer_end;
  360. ir->timer_end.data = (unsigned long)ir;
  361. init_timer(&ir->timer_keyup);
  362. ir->timer_keyup.function = ir_rc5_timer_keyup;
  363. ir->timer_keyup.data = (unsigned long)ir;
  364. ir->shift_by = 2;
  365. ir->start = 0x2;
  366. ir->addr = 0x17;
  367. ir->rc5_key_timeout = ir_rc5_key_timeout;
  368. ir->rc5_remote_gap = ir_rc5_remote_gap;
  369. } else if (ir->nec_gpio) {
  370. setup_timer(&ir->timer_keyup, saa7134_nec_timer,
  371. (unsigned long)dev);
  372. tasklet_init(&ir->tlet, nec_task, (unsigned long)dev);
  373. } else if (ir->raw_decode) {
  374. /* set timer_end for code completion */
  375. init_timer(&ir->timer_end);
  376. ir->timer_end.function = ir_raw_decode_timer_end;
  377. ir->timer_end.data = (unsigned long)dev;
  378. }
  379. }
  380. void saa7134_ir_stop(struct saa7134_dev *dev)
  381. {
  382. struct card_ir *ir = dev->remote;
  383. if (!ir->running)
  384. return;
  385. if (dev->remote->polling)
  386. del_timer_sync(&dev->remote->timer);
  387. else if (ir->rc5_gpio)
  388. del_timer_sync(&ir->timer_end);
  389. else if (ir->nec_gpio)
  390. tasklet_kill(&ir->tlet);
  391. else if (ir->raw_decode)
  392. del_timer_sync(&ir->timer_end);
  393. ir->running = 0;
  394. }
  395. int saa7134_ir_change_protocol(void *priv, u64 ir_type)
  396. {
  397. struct saa7134_dev *dev = priv;
  398. struct card_ir *ir = dev->remote;
  399. u32 nec_gpio, rc5_gpio;
  400. if (ir_type == IR_TYPE_RC5) {
  401. dprintk("Changing protocol to RC5\n");
  402. nec_gpio = 0;
  403. rc5_gpio = 1;
  404. } else if (ir_type == IR_TYPE_NEC) {
  405. dprintk("Changing protocol to NEC\n");
  406. nec_gpio = 1;
  407. rc5_gpio = 0;
  408. } else {
  409. dprintk("IR protocol type %ud is not supported\n",
  410. (unsigned)ir_type);
  411. return -EINVAL;
  412. }
  413. if (ir->running) {
  414. saa7134_ir_stop(dev);
  415. ir->nec_gpio = nec_gpio;
  416. ir->rc5_gpio = rc5_gpio;
  417. saa7134_ir_start(dev, ir);
  418. } else {
  419. ir->nec_gpio = nec_gpio;
  420. ir->rc5_gpio = rc5_gpio;
  421. }
  422. return 0;
  423. }
  424. int saa7134_input_init1(struct saa7134_dev *dev)
  425. {
  426. struct card_ir *ir;
  427. struct input_dev *input_dev;
  428. struct ir_scancode_table *ir_codes = NULL;
  429. u32 mask_keycode = 0;
  430. u32 mask_keydown = 0;
  431. u32 mask_keyup = 0;
  432. int polling = 0;
  433. int rc5_gpio = 0;
  434. int nec_gpio = 0;
  435. int raw_decode = 0;
  436. u64 ir_type = IR_TYPE_OTHER;
  437. int err;
  438. if (dev->has_remote != SAA7134_REMOTE_GPIO)
  439. return -ENODEV;
  440. if (disable_ir)
  441. return -ENODEV;
  442. /* detect & configure */
  443. switch (dev->board) {
  444. case SAA7134_BOARD_FLYVIDEO2000:
  445. case SAA7134_BOARD_FLYVIDEO3000:
  446. case SAA7134_BOARD_HAWELL_HW_404M7:
  447. case SAA7134_BOARD_FLYTVPLATINUM_FM:
  448. case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
  449. case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM:
  450. ir_codes = &ir_codes_flyvideo_table;
  451. mask_keycode = 0xEC00000;
  452. mask_keydown = 0x0040000;
  453. break;
  454. case SAA7134_BOARD_CINERGY400:
  455. case SAA7134_BOARD_CINERGY600:
  456. case SAA7134_BOARD_CINERGY600_MK3:
  457. ir_codes = &ir_codes_cinergy_table;
  458. mask_keycode = 0x00003f;
  459. mask_keyup = 0x040000;
  460. break;
  461. case SAA7134_BOARD_ECS_TVP3XP:
  462. case SAA7134_BOARD_ECS_TVP3XP_4CB5:
  463. ir_codes = &ir_codes_eztv_table;
  464. mask_keycode = 0x00017c;
  465. mask_keyup = 0x000002;
  466. polling = 50; // ms
  467. break;
  468. case SAA7134_BOARD_KWORLD_XPERT:
  469. case SAA7134_BOARD_AVACSSMARTTV:
  470. ir_codes = &ir_codes_pixelview_table;
  471. mask_keycode = 0x00001F;
  472. mask_keyup = 0x000020;
  473. polling = 50; // ms
  474. break;
  475. case SAA7134_BOARD_MD2819:
  476. case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
  477. case SAA7134_BOARD_AVERMEDIA_305:
  478. case SAA7134_BOARD_AVERMEDIA_307:
  479. case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
  480. case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
  481. case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
  482. case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
  483. case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
  484. case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
  485. case SAA7134_BOARD_AVERMEDIA_M102:
  486. case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
  487. ir_codes = &ir_codes_avermedia_table;
  488. mask_keycode = 0x0007C8;
  489. mask_keydown = 0x000010;
  490. polling = 50; // ms
  491. /* Set GPIO pin2 to high to enable the IR controller */
  492. saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
  493. saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
  494. break;
  495. case SAA7134_BOARD_AVERMEDIA_M135A:
  496. ir_codes = &ir_codes_avermedia_m135a_rm_jx_table;
  497. mask_keydown = 0x0040000;
  498. mask_keycode = 0xffff;
  499. raw_decode = 1;
  500. break;
  501. case SAA7134_BOARD_AVERMEDIA_777:
  502. case SAA7134_BOARD_AVERMEDIA_A16AR:
  503. ir_codes = &ir_codes_avermedia_table;
  504. mask_keycode = 0x02F200;
  505. mask_keydown = 0x000400;
  506. polling = 50; // ms
  507. /* Without this we won't receive key up events */
  508. saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
  509. saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
  510. break;
  511. case SAA7134_BOARD_AVERMEDIA_A16D:
  512. ir_codes = &ir_codes_avermedia_a16d_table;
  513. mask_keycode = 0x02F200;
  514. mask_keydown = 0x000400;
  515. polling = 50; /* ms */
  516. /* Without this we won't receive key up events */
  517. saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
  518. saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
  519. break;
  520. case SAA7134_BOARD_KWORLD_TERMINATOR:
  521. ir_codes = &ir_codes_pixelview_table;
  522. mask_keycode = 0x00001f;
  523. mask_keyup = 0x000060;
  524. polling = 50; // ms
  525. break;
  526. case SAA7134_BOARD_MANLI_MTV001:
  527. case SAA7134_BOARD_MANLI_MTV002:
  528. ir_codes = &ir_codes_manli_table;
  529. mask_keycode = 0x001f00;
  530. mask_keyup = 0x004000;
  531. polling = 50; /* ms */
  532. break;
  533. case SAA7134_BOARD_BEHOLD_409FM:
  534. case SAA7134_BOARD_BEHOLD_401:
  535. case SAA7134_BOARD_BEHOLD_403:
  536. case SAA7134_BOARD_BEHOLD_403FM:
  537. case SAA7134_BOARD_BEHOLD_405:
  538. case SAA7134_BOARD_BEHOLD_405FM:
  539. case SAA7134_BOARD_BEHOLD_407:
  540. case SAA7134_BOARD_BEHOLD_407FM:
  541. case SAA7134_BOARD_BEHOLD_409:
  542. case SAA7134_BOARD_BEHOLD_505FM:
  543. case SAA7134_BOARD_BEHOLD_505RDS_MK5:
  544. case SAA7134_BOARD_BEHOLD_505RDS_MK3:
  545. case SAA7134_BOARD_BEHOLD_507_9FM:
  546. case SAA7134_BOARD_BEHOLD_507RDS_MK3:
  547. case SAA7134_BOARD_BEHOLD_507RDS_MK5:
  548. ir_codes = &ir_codes_manli_table;
  549. mask_keycode = 0x003f00;
  550. mask_keyup = 0x004000;
  551. polling = 50; /* ms */
  552. break;
  553. case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
  554. ir_codes = &ir_codes_behold_columbus_table;
  555. mask_keycode = 0x003f00;
  556. mask_keyup = 0x004000;
  557. polling = 50; // ms
  558. break;
  559. case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
  560. ir_codes = &ir_codes_pctv_sedna_table;
  561. mask_keycode = 0x001f00;
  562. mask_keyup = 0x004000;
  563. polling = 50; // ms
  564. break;
  565. case SAA7134_BOARD_GOTVIEW_7135:
  566. ir_codes = &ir_codes_gotview7135_table;
  567. mask_keycode = 0x0003CC;
  568. mask_keydown = 0x000010;
  569. polling = 5; /* ms */
  570. saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
  571. break;
  572. case SAA7134_BOARD_VIDEOMATE_TV_PVR:
  573. case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
  574. case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
  575. ir_codes = &ir_codes_videomate_tv_pvr_table;
  576. mask_keycode = 0x00003F;
  577. mask_keyup = 0x400000;
  578. polling = 50; // ms
  579. break;
  580. case SAA7134_BOARD_PROTEUS_2309:
  581. ir_codes = &ir_codes_proteus_2309_table;
  582. mask_keycode = 0x00007F;
  583. mask_keyup = 0x000080;
  584. polling = 50; // ms
  585. break;
  586. case SAA7134_BOARD_VIDEOMATE_DVBT_300:
  587. case SAA7134_BOARD_VIDEOMATE_DVBT_200:
  588. ir_codes = &ir_codes_videomate_tv_pvr_table;
  589. mask_keycode = 0x003F00;
  590. mask_keyup = 0x040000;
  591. break;
  592. case SAA7134_BOARD_FLYDVBS_LR300:
  593. case SAA7134_BOARD_FLYDVBT_LR301:
  594. case SAA7134_BOARD_FLYDVBTDUO:
  595. ir_codes = &ir_codes_flydvb_table;
  596. mask_keycode = 0x0001F00;
  597. mask_keydown = 0x0040000;
  598. break;
  599. case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
  600. case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
  601. case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
  602. ir_codes = &ir_codes_asus_pc39_table;
  603. mask_keydown = 0x0040000;
  604. rc5_gpio = 1;
  605. break;
  606. case SAA7134_BOARD_ENCORE_ENLTV:
  607. case SAA7134_BOARD_ENCORE_ENLTV_FM:
  608. ir_codes = &ir_codes_encore_enltv_table;
  609. mask_keycode = 0x00007f;
  610. mask_keyup = 0x040000;
  611. polling = 50; // ms
  612. break;
  613. case SAA7134_BOARD_ENCORE_ENLTV_FM53:
  614. ir_codes = &ir_codes_encore_enltv_fm53_table;
  615. mask_keydown = 0x0040000;
  616. mask_keycode = 0x00007f;
  617. nec_gpio = 1;
  618. break;
  619. case SAA7134_BOARD_10MOONSTVMASTER3:
  620. ir_codes = &ir_codes_encore_enltv_table;
  621. mask_keycode = 0x5f80000;
  622. mask_keyup = 0x8000000;
  623. polling = 50; //ms
  624. break;
  625. case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
  626. ir_codes = &ir_codes_genius_tvgo_a11mce_table;
  627. mask_keycode = 0xff;
  628. mask_keydown = 0xf00000;
  629. polling = 50; /* ms */
  630. break;
  631. case SAA7134_BOARD_REAL_ANGEL_220:
  632. ir_codes = &ir_codes_real_audio_220_32_keys_table;
  633. mask_keycode = 0x3f00;
  634. mask_keyup = 0x4000;
  635. polling = 50; /* ms */
  636. break;
  637. case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
  638. ir_codes = &ir_codes_kworld_plus_tv_analog_table;
  639. mask_keycode = 0x7f;
  640. polling = 40; /* ms */
  641. break;
  642. case SAA7134_BOARD_VIDEOMATE_S350:
  643. ir_codes = &ir_codes_videomate_s350_table;
  644. mask_keycode = 0x003f00;
  645. mask_keydown = 0x040000;
  646. break;
  647. case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
  648. ir_codes = &ir_codes_winfast_table;
  649. mask_keycode = 0x5f00;
  650. mask_keyup = 0x020000;
  651. polling = 50; /* ms */
  652. break;
  653. break;
  654. }
  655. if (NULL == ir_codes) {
  656. printk("%s: Oops: IR config error [card=%d]\n",
  657. dev->name, dev->board);
  658. return -ENODEV;
  659. }
  660. ir = kzalloc(sizeof(*ir), GFP_KERNEL);
  661. input_dev = input_allocate_device();
  662. if (!ir || !input_dev) {
  663. err = -ENOMEM;
  664. goto err_out_free;
  665. }
  666. ir->dev = input_dev;
  667. dev->remote = ir;
  668. ir->running = 0;
  669. /* init hardware-specific stuff */
  670. ir->mask_keycode = mask_keycode;
  671. ir->mask_keydown = mask_keydown;
  672. ir->mask_keyup = mask_keyup;
  673. ir->polling = polling;
  674. ir->rc5_gpio = rc5_gpio;
  675. ir->nec_gpio = nec_gpio;
  676. ir->raw_decode = raw_decode;
  677. /* init input device */
  678. snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
  679. saa7134_boards[dev->board].name);
  680. snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
  681. pci_name(dev->pci));
  682. if (ir_codes->ir_type != IR_TYPE_OTHER && !raw_decode) {
  683. ir->props.allowed_protos = IR_TYPE_RC5 | IR_TYPE_NEC;
  684. ir->props.priv = dev;
  685. ir->props.change_protocol = saa7134_ir_change_protocol;
  686. /* Set IR protocol */
  687. saa7134_ir_change_protocol(ir->props.priv, ir_codes->ir_type);
  688. }
  689. err = ir_input_init(input_dev, &ir->ir, ir_type);
  690. if (err < 0)
  691. goto err_out_free;
  692. input_dev->name = ir->name;
  693. input_dev->phys = ir->phys;
  694. input_dev->id.bustype = BUS_PCI;
  695. input_dev->id.version = 1;
  696. if (dev->pci->subsystem_vendor) {
  697. input_dev->id.vendor = dev->pci->subsystem_vendor;
  698. input_dev->id.product = dev->pci->subsystem_device;
  699. } else {
  700. input_dev->id.vendor = dev->pci->vendor;
  701. input_dev->id.product = dev->pci->device;
  702. }
  703. input_dev->dev.parent = &dev->pci->dev;
  704. err = ir_input_register(ir->dev, ir_codes, &ir->props, MODULE_NAME);
  705. if (err)
  706. goto err_out_stop;
  707. if (ir_codes->ir_type != IR_TYPE_OTHER) {
  708. err = ir_raw_event_register(ir->dev);
  709. if (err)
  710. goto err_out_stop;
  711. }
  712. saa7134_ir_start(dev, ir);
  713. /* the remote isn't as bouncy as a keyboard */
  714. ir->dev->rep[REP_DELAY] = repeat_delay;
  715. ir->dev->rep[REP_PERIOD] = repeat_period;
  716. return 0;
  717. err_out_stop:
  718. saa7134_ir_stop(dev);
  719. dev->remote = NULL;
  720. err_out_free:
  721. kfree(ir);
  722. return err;
  723. }
  724. void saa7134_input_fini(struct saa7134_dev *dev)
  725. {
  726. if (NULL == dev->remote)
  727. return;
  728. saa7134_ir_stop(dev);
  729. ir_raw_event_unregister(dev->remote->dev);
  730. ir_input_unregister(dev->remote->dev);
  731. kfree(dev->remote);
  732. dev->remote = NULL;
  733. }
  734. void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
  735. {
  736. struct i2c_board_info info;
  737. struct i2c_msg msg_msi = {
  738. .addr = 0x50,
  739. .flags = I2C_M_RD,
  740. .len = 0,
  741. .buf = NULL,
  742. };
  743. int rc;
  744. if (disable_ir) {
  745. dprintk("IR has been disabled, not probing for i2c remote\n");
  746. return;
  747. }
  748. memset(&info, 0, sizeof(struct i2c_board_info));
  749. memset(&dev->init_data, 0, sizeof(dev->init_data));
  750. strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
  751. switch (dev->board) {
  752. case SAA7134_BOARD_PINNACLE_PCTV_110i:
  753. case SAA7134_BOARD_PINNACLE_PCTV_310i:
  754. dev->init_data.name = "Pinnacle PCTV";
  755. if (pinnacle_remote == 0) {
  756. dev->init_data.get_key = get_key_pinnacle_color;
  757. dev->init_data.ir_codes = &ir_codes_pinnacle_color_table;
  758. info.addr = 0x47;
  759. } else {
  760. dev->init_data.get_key = get_key_pinnacle_grey;
  761. dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table;
  762. info.addr = 0x47;
  763. }
  764. break;
  765. case SAA7134_BOARD_UPMOST_PURPLE_TV:
  766. dev->init_data.name = "Purple TV";
  767. dev->init_data.get_key = get_key_purpletv;
  768. dev->init_data.ir_codes = &ir_codes_purpletv_table;
  769. info.addr = 0x7a;
  770. break;
  771. case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
  772. dev->init_data.name = "MSI TV@nywhere Plus";
  773. dev->init_data.get_key = get_key_msi_tvanywhere_plus;
  774. dev->init_data.ir_codes = &ir_codes_msi_tvanywhere_plus_table;
  775. info.addr = 0x30;
  776. /* MSI TV@nywhere Plus controller doesn't seem to
  777. respond to probes unless we read something from
  778. an existing device. Weird...
  779. REVISIT: might no longer be needed */
  780. rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
  781. dprintk(KERN_DEBUG "probe 0x%02x @ %s: %s\n",
  782. msg_msi.addr, dev->i2c_adap.name,
  783. (1 == rc) ? "yes" : "no");
  784. break;
  785. case SAA7134_BOARD_HAUPPAUGE_HVR1110:
  786. dev->init_data.name = "HVR 1110";
  787. dev->init_data.get_key = get_key_hvr1110;
  788. dev->init_data.ir_codes = &ir_codes_hauppauge_new_table;
  789. info.addr = 0x71;
  790. break;
  791. case SAA7134_BOARD_BEHOLD_607FM_MK3:
  792. case SAA7134_BOARD_BEHOLD_607FM_MK5:
  793. case SAA7134_BOARD_BEHOLD_609FM_MK3:
  794. case SAA7134_BOARD_BEHOLD_609FM_MK5:
  795. case SAA7134_BOARD_BEHOLD_607RDS_MK3:
  796. case SAA7134_BOARD_BEHOLD_607RDS_MK5:
  797. case SAA7134_BOARD_BEHOLD_609RDS_MK3:
  798. case SAA7134_BOARD_BEHOLD_609RDS_MK5:
  799. case SAA7134_BOARD_BEHOLD_M6:
  800. case SAA7134_BOARD_BEHOLD_M63:
  801. case SAA7134_BOARD_BEHOLD_M6_EXTRA:
  802. case SAA7134_BOARD_BEHOLD_H6:
  803. case SAA7134_BOARD_BEHOLD_X7:
  804. dev->init_data.name = "BeholdTV";
  805. dev->init_data.get_key = get_key_beholdm6xx;
  806. dev->init_data.ir_codes = &ir_codes_behold_table;
  807. dev->init_data.type = IR_TYPE_NEC;
  808. info.addr = 0x2d;
  809. break;
  810. case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
  811. case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
  812. info.addr = 0x40;
  813. break;
  814. case SAA7134_BOARD_FLYDVB_TRIO:
  815. dev->init_data.name = "FlyDVB Trio";
  816. dev->init_data.get_key = get_key_flydvb_trio;
  817. dev->init_data.ir_codes = &ir_codes_flydvb_table;
  818. info.addr = 0x0b;
  819. break;
  820. default:
  821. dprintk("No I2C IR support for board %x\n", dev->board);
  822. return;
  823. }
  824. if (dev->init_data.name)
  825. info.platform_data = &dev->init_data;
  826. i2c_new_device(&dev->i2c_adap, &info);
  827. }
  828. static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
  829. {
  830. struct card_ir *ir = dev->remote;
  831. unsigned long timeout;
  832. int count, pulse, oldpulse;
  833. /* Disable IR IRQ line */
  834. saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
  835. /* Generate initial event */
  836. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  837. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  838. pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
  839. ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE);
  840. #if 1
  841. /* Wait up to 10 ms for event change */
  842. oldpulse = pulse;
  843. for (count = 0; count < 1000; count++) {
  844. udelay(10);
  845. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  846. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  847. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  848. pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2)
  849. & ir->mask_keydown;
  850. if (pulse != oldpulse)
  851. break;
  852. }
  853. /* Store final event */
  854. ir_raw_event_store(dev->remote->dev, pulse? IR_PULSE : IR_SPACE);
  855. #endif
  856. /* Wait 15 ms before deciding to do something else */
  857. timeout = jiffies + jiffies_to_msecs(15);
  858. mod_timer(&ir->timer_end, timeout);
  859. /* Enable IR IRQ line */
  860. saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
  861. return 1;
  862. }
  863. static int saa7134_rc5_irq(struct saa7134_dev *dev)
  864. {
  865. struct card_ir *ir = dev->remote;
  866. struct timeval tv;
  867. u32 gap;
  868. unsigned long current_jiffies, timeout;
  869. /* get time of bit */
  870. current_jiffies = jiffies;
  871. do_gettimeofday(&tv);
  872. /* avoid overflow with gap >1s */
  873. if (tv.tv_sec - ir->base_time.tv_sec > 1) {
  874. gap = 200000;
  875. } else {
  876. gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
  877. tv.tv_usec - ir->base_time.tv_usec;
  878. }
  879. /* active code => add bit */
  880. if (ir->active) {
  881. /* only if in the code (otherwise spurious IRQ or timer
  882. late) */
  883. if (ir->last_bit < 28) {
  884. ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
  885. ir_rc5_remote_gap;
  886. ir->code |= 1 << ir->last_bit;
  887. }
  888. /* starting new code */
  889. } else {
  890. ir->active = 1;
  891. ir->code = 0;
  892. ir->base_time = tv;
  893. ir->last_bit = 0;
  894. timeout = current_jiffies + (500 + 30 * HZ) / 1000;
  895. mod_timer(&ir->timer_end, timeout);
  896. }
  897. return 1;
  898. }
  899. /* On NEC protocol, One has 2.25 ms, and zero has 1.125 ms
  900. The first pulse (start) has 9 + 4.5 ms
  901. */
  902. static void saa7134_nec_timer(unsigned long data)
  903. {
  904. struct saa7134_dev *dev = (struct saa7134_dev *) data;
  905. struct card_ir *ir = dev->remote;
  906. dprintk("Cancel key repeat\n");
  907. ir_input_nokey(ir->dev, &ir->ir);
  908. }
  909. static void nec_task(unsigned long data)
  910. {
  911. struct saa7134_dev *dev = (struct saa7134_dev *) data;
  912. struct card_ir *ir;
  913. struct timeval tv;
  914. int count, pulse, oldpulse, gap;
  915. u32 ircode = 0, not_code = 0;
  916. int ngap = 0;
  917. if (!data) {
  918. printk(KERN_ERR "saa713x/ir: Can't recover dev struct\n");
  919. /* GPIO will be kept disabled */
  920. return;
  921. }
  922. ir = dev->remote;
  923. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  924. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  925. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  926. oldpulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
  927. pulse = oldpulse;
  928. do_gettimeofday(&tv);
  929. ir->base_time = tv;
  930. /* Decode NEC pulsecode. This code can take up to 76.5 ms to run.
  931. Unfortunately, using IRQ to decode pulse didn't work, since it uses
  932. a pulse train of 38KHz. This means one pulse on each 52 us
  933. */
  934. do {
  935. /* Wait until the end of pulse/space or 5 ms */
  936. for (count = 0; count < 500; count++) {
  937. udelay(10);
  938. /* rising SAA7134_GPIO_GPRESCAN reads the status */
  939. saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  940. saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
  941. pulse = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2)
  942. & ir->mask_keydown;
  943. if (pulse != oldpulse)
  944. break;
  945. }
  946. do_gettimeofday(&tv);
  947. gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
  948. tv.tv_usec - ir->base_time.tv_usec;
  949. if (!pulse) {
  950. /* Bit 0 has 560 us, while bit 1 has 1120 us.
  951. Do something only if bit == 1
  952. */
  953. if (ngap && (gap > 560 + 280)) {
  954. unsigned int shift = ngap - 1;
  955. /* Address first, then command */
  956. if (shift < 8) {
  957. shift += 8;
  958. ircode |= 1 << shift;
  959. } else if (shift < 16) {
  960. not_code |= 1 << shift;
  961. } else if (shift < 24) {
  962. shift -= 16;
  963. ircode |= 1 << shift;
  964. } else {
  965. shift -= 24;
  966. not_code |= 1 << shift;
  967. }
  968. }
  969. ngap++;
  970. }
  971. ir->base_time = tv;
  972. /* TIMEOUT - Long pulse */
  973. if (gap >= 5000)
  974. break;
  975. oldpulse = pulse;
  976. } while (ngap < 32);
  977. if (ngap == 32) {
  978. /* FIXME: should check if not_code == ~ircode */
  979. ir->code = ir_extract_bits(ircode, ir->mask_keycode);
  980. dprintk("scancode = 0x%02x (code = 0x%02x, notcode= 0x%02x)\n",
  981. ir->code, ircode, not_code);
  982. ir_input_keydown(ir->dev, &ir->ir, ir->code);
  983. } else
  984. dprintk("Repeat last key\n");
  985. /* Keep repeating the last key */
  986. mod_timer(&ir->timer_keyup, jiffies + msecs_to_jiffies(150));
  987. saa_setl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
  988. }
  989. static int saa7134_nec_irq(struct saa7134_dev *dev)
  990. {
  991. struct card_ir *ir = dev->remote;
  992. saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18);
  993. tasklet_schedule(&ir->tlet);
  994. return 1;
  995. }