saa7134-input.c 30 KB

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