blob: 33ee8322895e01bcdf33a25226621e5b0f541c08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 */
16
Mauro Carvalho Chehab9a12ccf2015-04-30 06:44:56 -030017#include "saa7134.h"
18#include "saa7134-reg.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/init.h>
22#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/interrupt.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Mauro Carvalho Chehabd3025482010-10-06 22:02:58 -030026#define MODULE_NAME "saa7134"
Mauro Carvalho Chehab727e6252010-03-12 21:18:14 -030027
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030028static unsigned int disable_ir;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029module_param(disable_ir, int, 0444);
30MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
31
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030032static unsigned int ir_debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033module_param(ir_debug, int, 0644);
34MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
35
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030036static int pinnacle_remote;
Sylvain Pascheb93eedb2006-03-25 23:14:42 -030037module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
38MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
39
Mauro Carvalho Chehab45f38cb2015-05-13 14:09:25 -030040#define input_dbg(fmt, arg...) do { \
41 if (ir_debug) \
42 printk(KERN_DEBUG pr_fmt("input: " fmt), ## arg); \
43 } while (0)
44#define ir_dbg(ir, fmt, arg...) do { \
45 if (ir_debug) \
Sean Youngafc7f242017-10-18 09:39:12 -040046 printk(KERN_DEBUG pr_fmt("ir %s: " fmt), ir->rc->device_name, \
47 ## arg); \
Mauro Carvalho Chehab45f38cb2015-05-13 14:09:25 -030048 } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Mauro Carvalho Chehabbce8d0f2010-11-17 09:58:09 -030050/* Helper function for raw decoding at GPIO16 or GPIO18 */
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -030051static int saa7134_raw_decode_irq(struct saa7134_dev *dev);
Hermann Pitton91607232006-12-07 21:45:28 -030052
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -080053/* -------------------- GPIO generic keycode builder -------------------- */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55static int build_key(struct saa7134_dev *dev)
56{
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -030057 struct saa7134_card_ir *ir = dev->remote;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 u32 gpio, data;
59
Pedro0938e312007-10-17 17:58:40 -030060 /* here comes the additional handshake steps for some cards */
61 switch (dev->board) {
62 case SAA7134_BOARD_GOTVIEW_7135:
63 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
64 saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
65 break;
66 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 /* rising SAA7134_GPIO_GPRESCAN reads the status */
68 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
69 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
70
71 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -080072 if (ir->polling) {
73 if (ir->last_gpio == gpio)
74 return 0;
75 ir->last_gpio = gpio;
76 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -080078 data = ir_extract_bits(gpio, ir->mask_keycode);
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -030079 input_dbg("build_key gpio=0x%x mask=0x%x data=%d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 gpio, ir->mask_keycode, data);
81
Mauro Carvalho Chehab26d5f3a2008-12-07 13:19:29 -030082 switch (dev->board) {
83 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
84 if (data == ir->mask_keycode)
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -030085 rc_keyup(ir->dev);
Mauro Carvalho Chehab26d5f3a2008-12-07 13:19:29 -030086 else
Sean Young6d741bf2017-08-07 16:20:58 -040087 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
88 0);
Mauro Carvalho Chehab26d5f3a2008-12-07 13:19:29 -030089 return 0;
90 }
91
Peter Missel0602fbb2006-01-09 18:21:23 -020092 if (ir->polling) {
93 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
94 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
Sean Young6d741bf2017-08-07 16:20:58 -040095 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
96 0);
Peter Missel0602fbb2006-01-09 18:21:23 -020097 } else {
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -030098 rc_keyup(ir->dev);
Peter Missel0602fbb2006-01-09 18:21:23 -020099 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 }
Peter Missel0602fbb2006-01-09 18:21:23 -0200101 else { /* IRQ driven mode - handle key press and release in one go */
102 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
103 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
Sean Young6d741bf2017-08-07 16:20:58 -0400104 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
105 0);
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -0300106 rc_keyup(ir->dev);
Peter Missel0602fbb2006-01-09 18:21:23 -0200107 }
108 }
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 return 0;
111}
112
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800113/* --------------------- Chip specific I2C key builders ----------------- */
114
Sean Young6d741bf2017-08-07 16:20:58 -0400115static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300116 u32 *scancode, u8 *toggle)
Lukas Karasd995a182009-11-24 12:06:52 -0300117{
118 int gpio;
119 int attempt = 0;
120 unsigned char b;
121
122 /* We need this to access GPI Used by the saa_readl macro. */
123 struct saa7134_dev *dev = ir->c->adapter->algo_data;
124
125 if (dev == NULL) {
Mauro Carvalho Chehab395eff92016-10-18 17:44:06 -0200126 ir_dbg(ir, "get_key_flydvb_trio: ir->c->adapter->algo_data is NULL!\n");
Lukas Karasd995a182009-11-24 12:06:52 -0300127 return -EIO;
128 }
129
130 /* rising SAA7134_GPIGPRESCAN reads the status */
131 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
132 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
133
134 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
135
136 if (0x40000 & ~gpio)
137 return 0; /* No button press */
138
Lukas Karasd995a182009-11-24 12:06:52 -0300139 /* poll IR chip */
140 /* weak up the IR chip */
141 b = 0;
142
143 while (1 != i2c_master_send(ir->c, &b, 1)) {
144 if ((attempt++) < 10) {
145 /*
146 * wait a bit for next attempt -
147 * I don't know how make it better
148 */
149 msleep(10);
150 continue;
151 }
Mauro Carvalho Chehab395eff92016-10-18 17:44:06 -0200152 ir_dbg(ir, "send wake up byte to pic16C505 (IR chip)failed %dx\n",
153 attempt);
Lukas Karasd995a182009-11-24 12:06:52 -0300154 return -EIO;
155 }
156 if (1 != i2c_master_recv(ir->c, &b, 1)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300157 ir_dbg(ir, "read error\n");
Lukas Karasd995a182009-11-24 12:06:52 -0300158 return -EIO;
159 }
160
Sean Young6d741bf2017-08-07 16:20:58 -0400161 *protocol = RC_PROTO_UNKNOWN;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300162 *scancode = b;
163 *toggle = 0;
Lukas Karasd995a182009-11-24 12:06:52 -0300164 return 1;
165}
166
Sean Young6d741bf2017-08-07 16:20:58 -0400167static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir,
168 enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300169 u32 *scancode, u8 *toggle)
Brian Rogersba340b42008-10-13 08:37:06 -0300170{
171 unsigned char b;
172 int gpio;
173
174 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
Jean Delvarec668f322009-05-13 16:48:50 -0300175 struct saa7134_dev *dev = ir->c->adapter->algo_data;
Brian Rogersba340b42008-10-13 08:37:06 -0300176 if (dev == NULL) {
Mauro Carvalho Chehab395eff92016-10-18 17:44:06 -0200177 ir_dbg(ir, "get_key_msi_tvanywhere_plus: ir->c->adapter->algo_data is NULL!\n");
Brian Rogersba340b42008-10-13 08:37:06 -0300178 return -EIO;
179 }
180
181 /* rising SAA7134_GPIO_GPRESCAN reads the status */
182
183 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
184 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
185
186 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
187
188 /* GPIO&0x40 is pulsed low when a button is pressed. Don't do
189 I2C receive if gpio&0x40 is not low. */
190
191 if (gpio & 0x40)
192 return 0; /* No button press */
193
194 /* GPIO says there is a button press. Get it. */
195
Jean Delvarec668f322009-05-13 16:48:50 -0300196 if (1 != i2c_master_recv(ir->c, &b, 1)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300197 ir_dbg(ir, "read error\n");
Brian Rogersba340b42008-10-13 08:37:06 -0300198 return -EIO;
199 }
200
201 /* No button press */
202
203 if (b == 0xff)
204 return 0;
205
206 /* Button pressed */
207
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300208 input_dbg("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b);
Sean Young6d741bf2017-08-07 16:20:58 -0400209 *protocol = RC_PROTO_UNKNOWN;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300210 *scancode = b;
211 *toggle = 0;
Brian Rogersba340b42008-10-13 08:37:06 -0300212 return 1;
213}
214
Kyle Strickland25fa2072012-02-18 02:24:53 -0300215/* copied and modified from get_key_msi_tvanywhere_plus() */
Sean Young6d741bf2017-08-07 16:20:58 -0400216static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300217 u32 *scancode, u8 *toggle)
Kyle Strickland25fa2072012-02-18 02:24:53 -0300218{
219 unsigned char b;
220 unsigned int gpio;
221
222 /* <dev> is needed to access GPIO. Used by the saa_readl macro. */
223 struct saa7134_dev *dev = ir->c->adapter->algo_data;
224 if (dev == NULL) {
Mauro Carvalho Chehab395eff92016-10-18 17:44:06 -0200225 ir_dbg(ir, "get_key_kworld_pc150u: ir->c->adapter->algo_data is NULL!\n");
Kyle Strickland25fa2072012-02-18 02:24:53 -0300226 return -EIO;
227 }
228
229 /* rising SAA7134_GPIO_GPRESCAN reads the status */
230
231 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
232 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
233
234 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
235
236 /* GPIO&0x100 is pulsed low when a button is pressed. Don't do
237 I2C receive if gpio&0x100 is not low. */
238
239 if (gpio & 0x100)
240 return 0; /* No button press */
241
242 /* GPIO says there is a button press. Get it. */
243
244 if (1 != i2c_master_recv(ir->c, &b, 1)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300245 ir_dbg(ir, "read error\n");
Kyle Strickland25fa2072012-02-18 02:24:53 -0300246 return -EIO;
247 }
248
249 /* No button press */
250
251 if (b == 0xff)
252 return 0;
253
254 /* Button pressed */
255
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300256 input_dbg("get_key_kworld_pc150u: Key = 0x%02X\n", b);
Sean Young6d741bf2017-08-07 16:20:58 -0400257 *protocol = RC_PROTO_UNKNOWN;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300258 *scancode = b;
259 *toggle = 0;
Kyle Strickland25fa2072012-02-18 02:24:53 -0300260 return 1;
261}
262
Sean Young6d741bf2017-08-07 16:20:58 -0400263static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300264 u32 *scancode, u8 *toggle)
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800265{
266 unsigned char b;
267
268 /* poll IR chip */
Jean Delvarec668f322009-05-13 16:48:50 -0300269 if (1 != i2c_master_recv(ir->c, &b, 1)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300270 ir_dbg(ir, "read error\n");
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800271 return -EIO;
272 }
273
274 /* no button press */
275 if (b==0)
276 return 0;
277
278 /* repeating */
279 if (b & 0x80)
280 return 1;
281
Sean Young6d741bf2017-08-07 16:20:58 -0400282 *protocol = RC_PROTO_UNKNOWN;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300283 *scancode = b;
284 *toggle = 0;
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800285 return 1;
286}
287
Sean Young6d741bf2017-08-07 16:20:58 -0400288static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300289 u32 *scancode, u8 *toggle)
Thomas Genty177aaaf2006-11-29 21:57:24 -0300290{
Mauro Carvalho Chehab641269f2011-12-31 18:56:24 -0200291 unsigned char buf[5];
Thomas Genty177aaaf2006-11-29 21:57:24 -0300292
293 /* poll IR chip */
Jean Delvarec668f322009-05-13 16:48:50 -0300294 if (5 != i2c_master_recv(ir->c, buf, 5))
Thomas Genty177aaaf2006-11-29 21:57:24 -0300295 return -EIO;
296
Mauro Carvalho Chehab641269f2011-12-31 18:56:24 -0200297 /* Check if some key were pressed */
298 if (!(buf[0] & 0x80))
Thomas Genty177aaaf2006-11-29 21:57:24 -0300299 return 0;
300
Mauro Carvalho Chehab641269f2011-12-31 18:56:24 -0200301 /*
302 * buf[3] & 0x80 is always high.
303 * buf[3] & 0x40 is a parity bit. A repeat event is marked
304 * by preserving it into two separate readings
305 * buf[4] bits 0 and 1, and buf[1] and buf[2] are always
306 * zero.
David Härdeman4dd9bb92014-04-03 20:31:25 -0300307 *
308 * Note that the keymap which the hvr1110 uses is RC5.
309 *
310 * FIXME: start bits could maybe be used...?
Mauro Carvalho Chehab641269f2011-12-31 18:56:24 -0200311 */
Sean Young6d741bf2017-08-07 16:20:58 -0400312 *protocol = RC_PROTO_RC5;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300313 *scancode = RC_SCANCODE_RC5(buf[3] & 0x1f, buf[4] >> 2);
314 *toggle = !!(buf[3] & 0x40);
Thomas Genty177aaaf2006-11-29 21:57:24 -0300315 return 1;
316}
317
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300318
Sean Young6d741bf2017-08-07 16:20:58 -0400319static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300320 u32 *scancode, u8 *toggle)
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300321{
322 unsigned char data[12];
323 u32 gpio;
324
Jean Delvarec668f322009-05-13 16:48:50 -0300325 struct saa7134_dev *dev = ir->c->adapter->algo_data;
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300326
327 /* rising SAA7134_GPIO_GPRESCAN reads the status */
328 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
329 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
330
331 gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
332
Mauro Carvalho Chehab616f8872008-01-07 05:18:36 -0300333 if (0x400000 & ~gpio)
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300334 return 0; /* No button press */
335
Jean Delvarec668f322009-05-13 16:48:50 -0300336 ir->c->addr = 0x5a >> 1;
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300337
Jean Delvarec668f322009-05-13 16:48:50 -0300338 if (12 != i2c_master_recv(ir->c, data, 12)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300339 ir_dbg(ir, "read error\n");
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300340 return -EIO;
341 }
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300342
Dmitri Belimov2d21ffe2009-09-07 20:36:05 -0300343 if (data[9] != (unsigned char)(~data[8]))
344 return 0;
345
Sean Young6d741bf2017-08-07 16:20:58 -0400346 *protocol = RC_PROTO_NECX;
David Härdeman0bc56cb2014-04-03 20:32:01 -0300347 *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]);
David Härdeman4dd9bb92014-04-03 20:31:25 -0300348 *toggle = 0;
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300349 return 1;
350}
351
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300352/* Common (grey or coloured) pinnacle PCTV remote handling
353 *
354 */
Sean Young6d741bf2017-08-07 16:20:58 -0400355static int get_key_pinnacle(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300356 u32 *scancode, u8 *toggle, int parity_offset,
357 int marker, int code_modulo)
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300358{
359 unsigned char b[4];
360 unsigned int start = 0,parity = 0,code = 0;
361
362 /* poll IR chip */
Jean Delvarec668f322009-05-13 16:48:50 -0300363 if (4 != i2c_master_recv(ir->c, b, 4)) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300364 ir_dbg(ir, "read error\n");
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300365 return -EIO;
366 }
367
368 for (start = 0; start < ARRAY_SIZE(b); start++) {
369 if (b[start] == marker) {
370 code=b[(start+parity_offset + 1) % 4];
371 parity=b[(start+parity_offset) % 4];
372 }
373 }
374
375 /* Empty Request */
376 if (parity == 0)
377 return 0;
378
379 /* Repeating... */
380 if (ir->old == parity)
381 return 0;
382
383 ir->old = parity;
384
385 /* drop special codes when a key is held down a long time for the grey controller
386 In this case, the second bit of the code is asserted */
387 if (marker == 0xfe && (code & 0x40))
388 return 0;
389
390 code %= code_modulo;
391
Sean Young6d741bf2017-08-07 16:20:58 -0400392 *protocol = RC_PROTO_UNKNOWN;
David Härdeman4dd9bb92014-04-03 20:31:25 -0300393 *scancode = code;
394 *toggle = 0;
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300395
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300396 ir_dbg(ir, "Pinnacle PCTV key %02x\n", code);
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300397 return 1;
398}
399
400/* The grey pinnacle PCTV remote
401 *
402 * There are one issue with this remote:
403 * - I2c packet does not change when the same key is pressed quickly. The workaround
404 * is to hold down each key for about half a second, so that another code is generated
405 * in the i2c packet, and the function can distinguish key presses.
406 *
407 * Sylvain Pasche <sylvain.pasche@gmail.com>
408 */
Sean Young6d741bf2017-08-07 16:20:58 -0400409static int get_key_pinnacle_grey(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300410 u32 *scancode, u8 *toggle)
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300411{
412
David Härdeman4dd9bb92014-04-03 20:31:25 -0300413 return get_key_pinnacle(ir, protocol, scancode, toggle, 1, 0xfe, 0xff);
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300414}
415
416
417/* The new pinnacle PCTV remote (with the colored buttons)
418 *
419 * Ricardo Cerqueira <v4l@cerqueira.org>
420 */
Sean Young6d741bf2017-08-07 16:20:58 -0400421static int get_key_pinnacle_color(struct IR_i2c *ir, enum rc_proto *protocol,
David Härdeman4dd9bb92014-04-03 20:31:25 -0300422 u32 *scancode, u8 *toggle)
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300423{
424 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
425 *
426 * this is the only value that results in 42 unique
427 * codes < 128
428 */
429
David Härdeman4dd9bb92014-04-03 20:31:25 -0300430 return get_key_pinnacle(ir, protocol, scancode, toggle, 2, 0x80, 0x88);
Mauro Carvalho Chehab1c22dad2008-07-17 22:31:29 -0300431}
432
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433void saa7134_input_irq(struct saa7134_dev *dev)
434{
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300435 struct saa7134_card_ir *ir;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300436
437 if (!dev || !dev->remote)
438 return;
439
440 ir = dev->remote;
441 if (!ir->running)
442 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Mauro Carvalho Chehabbce8d0f2010-11-17 09:58:09 -0300444 if (!ir->polling && !ir->raw_decode) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 build_key(dev);
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -0300446 } else if (ir->raw_decode) {
447 saa7134_raw_decode_irq(dev);
Hermann Pitton91607232006-12-07 21:45:28 -0300448 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449}
450
Kees Cook1e7126b2017-10-16 19:11:30 -0400451static void saa7134_input_timer(struct timer_list *t)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452{
Kees Cook1e7126b2017-10-16 19:11:30 -0400453 struct saa7134_card_ir *ir = from_timer(ir, t, timer);
454 struct saa7134_dev *dev = ir->dev->priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 build_key(dev);
Dmitry Torokhovb4ba7882007-05-21 11:41:02 -0300457 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458}
459
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300460static int __saa7134_ir_start(void *priv)
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300461{
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300462 struct saa7134_dev *dev = priv;
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300463 struct saa7134_card_ir *ir;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300464
David Härdeman651c7a52010-11-19 20:42:51 -0300465 if (!dev || !dev->remote)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300466 return -EINVAL;
467
468 ir = dev->remote;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -0300469 if (ir->running)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300470 return 0;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -0300471
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300472 /* Moved here from saa7134_input_init1() because the latter
473 * is not called on device resume */
474 switch (dev->board) {
475 case SAA7134_BOARD_MD2819:
476 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
477 case SAA7134_BOARD_AVERMEDIA_305:
478 case SAA7134_BOARD_AVERMEDIA_307:
Dmitry Eremin-Solenikovde983452015-05-21 15:53:01 -0300479 case SAA7134_BOARD_AVERMEDIA_505:
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300480 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
481 case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
482 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
483 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
484 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
485 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
486 case SAA7134_BOARD_AVERMEDIA_M102:
487 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
488 /* Without this we won't receive key up events */
489 saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
490 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
491 break;
492 case SAA7134_BOARD_AVERMEDIA_777:
493 case SAA7134_BOARD_AVERMEDIA_A16AR:
494 /* Without this we won't receive key up events */
495 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
496 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
497 break;
498 case SAA7134_BOARD_AVERMEDIA_A16D:
499 /* Without this we won't receive key up events */
500 saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
501 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
502 break;
503 case SAA7134_BOARD_GOTVIEW_7135:
504 saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
505 break;
506 }
507
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300508 ir->running = true;
David Härdeman651c7a52010-11-19 20:42:51 -0300509
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300510 if (ir->polling) {
Kees Cook1e7126b2017-10-16 19:11:30 -0400511 timer_setup(&ir->timer, saa7134_input_timer, 0);
David Härdeman7c8352d2010-11-19 20:42:57 -0300512 ir->timer.expires = jiffies + HZ;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300513 add_timer(&ir->timer);
514 }
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300515
516 return 0;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300517}
518
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300519static void __saa7134_ir_stop(void *priv)
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300520{
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300521 struct saa7134_dev *dev = priv;
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300522 struct saa7134_card_ir *ir;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300523
David Härdeman651c7a52010-11-19 20:42:51 -0300524 if (!dev || !dev->remote)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300525 return;
526
527 ir = dev->remote;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -0300528 if (!ir->running)
529 return;
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -0300530
Sean Younge5e26432017-08-06 15:25:52 -0400531 if (ir->polling)
David Härdeman651c7a52010-11-19 20:42:51 -0300532 del_timer_sync(&ir->timer);
David Härdeman651c7a52010-11-19 20:42:51 -0300533
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300534 ir->running = false;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300535
536 return;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -0300537}
538
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300539int saa7134_ir_start(struct saa7134_dev *dev)
540{
541 if (dev->remote->users)
542 return __saa7134_ir_start(dev);
543
544 return 0;
545}
546
547void saa7134_ir_stop(struct saa7134_dev *dev)
548{
549 if (dev->remote->users)
550 __saa7134_ir_stop(dev);
551}
552
David Härdemand8b4b582010-10-29 16:08:23 -0300553static int saa7134_ir_open(struct rc_dev *rc)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300554{
David Härdemand8b4b582010-10-29 16:08:23 -0300555 struct saa7134_dev *dev = rc->priv;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300556
557 dev->remote->users++;
558 return __saa7134_ir_start(dev);
559}
560
David Härdemand8b4b582010-10-29 16:08:23 -0300561static void saa7134_ir_close(struct rc_dev *rc)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300562{
David Härdemand8b4b582010-10-29 16:08:23 -0300563 struct saa7134_dev *dev = rc->priv;
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300564
565 dev->remote->users--;
566 if (!dev->remote->users)
567 __saa7134_ir_stop(dev);
568}
569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570int saa7134_input_init1(struct saa7134_dev *dev)
571{
Mauro Carvalho Chehaba6e3b812010-11-17 10:05:29 -0300572 struct saa7134_card_ir *ir;
David Härdemand8b4b582010-10-29 16:08:23 -0300573 struct rc_dev *rc;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300574 char *ir_codes = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 u32 mask_keycode = 0;
576 u32 mask_keydown = 0;
577 u32 mask_keyup = 0;
David Härdeman651c7a52010-11-19 20:42:51 -0300578 unsigned polling = 0;
579 bool raw_decode = false;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300580 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581
Ricardo Cerqueiracb2444d2005-11-08 21:38:47 -0800582 if (dev->has_remote != SAA7134_REMOTE_GPIO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 return -ENODEV;
584 if (disable_ir)
585 return -ENODEV;
586
587 /* detect & configure */
588 switch (dev->board) {
589 case SAA7134_BOARD_FLYVIDEO2000:
590 case SAA7134_BOARD_FLYVIDEO3000:
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800591 case SAA7134_BOARD_FLYTVPLATINUM_FM:
Arnaud Patard6af90ab2005-11-08 21:36:55 -0800592 case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
Eugene Yudin23389b82009-08-29 09:32:11 -0300593 case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300594 ir_codes = RC_MAP_FLYVIDEO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 mask_keycode = 0xEC00000;
596 mask_keydown = 0x0040000;
597 break;
598 case SAA7134_BOARD_CINERGY400:
599 case SAA7134_BOARD_CINERGY600:
600 case SAA7134_BOARD_CINERGY600_MK3:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300601 ir_codes = RC_MAP_CINERGY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 mask_keycode = 0x00003f;
603 mask_keyup = 0x040000;
604 break;
605 case SAA7134_BOARD_ECS_TVP3XP:
606 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300607 ir_codes = RC_MAP_EZTV;
Mauro Carvalho Chehab330a1152005-07-12 13:59:01 -0700608 mask_keycode = 0x00017c;
609 mask_keyup = 0x000002;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 polling = 50; // ms
Mauro Carvalho Chehab330a1152005-07-12 13:59:01 -0700611 break;
612 case SAA7134_BOARD_KWORLD_XPERT:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 case SAA7134_BOARD_AVACSSMARTTV:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300614 ir_codes = RC_MAP_PIXELVIEW;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 mask_keycode = 0x00001F;
616 mask_keyup = 0x000020;
617 polling = 50; // ms
618 break;
619 case SAA7134_BOARD_MD2819:
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700620 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 case SAA7134_BOARD_AVERMEDIA_305:
622 case SAA7134_BOARD_AVERMEDIA_307:
Dmitry Eremin-Solenikovde983452015-05-21 15:53:01 -0300623 case SAA7134_BOARD_AVERMEDIA_505:
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700624 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
Vasiliy Temnikov5a5e1da2009-08-26 22:10:55 -0300625 case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700626 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
Mikhail Fedotov3ac706d2006-10-06 20:23:47 -0300627 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
Andy Shevchenkodf0dbbe2009-04-08 14:01:19 -0300628 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700629 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
Albert Grahamd2761f22007-12-09 09:44:38 -0300630 case SAA7134_BOARD_AVERMEDIA_M102:
Pham Thanh Nam6a2d8022008-12-30 23:26:09 -0300631 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300632 ir_codes = RC_MAP_AVERMEDIA;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 mask_keycode = 0x0007C8;
634 mask_keydown = 0x000010;
635 polling = 50; // ms
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300636 /* GPIO stuff moved to __saa7134_ir_start() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 break;
Mauro Carvalho Chehab36f6bb92008-06-26 17:03:00 -0300638 case SAA7134_BOARD_AVERMEDIA_M135A:
Herton Ronaldo Krzesinski63fc31e2010-05-10 15:43:31 -0300639 ir_codes = RC_MAP_AVERMEDIA_M135A;
Mauro Carvalho Chehab2f16f632010-04-03 18:51:50 -0300640 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
641 mask_keyup = 0x0040000;
Mauro Carvalho Chehabd152b8b2010-03-20 00:23:30 -0300642 mask_keycode = 0xffff;
David Härdeman651c7a52010-11-19 20:42:51 -0300643 raw_decode = true;
Mauro Carvalho Chehab36f6bb92008-06-26 17:03:00 -0300644 break;
Herton Ronaldo Krzesinski9e1d9e72010-05-08 02:23:37 -0300645 case SAA7134_BOARD_AVERMEDIA_M733A:
646 ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6;
647 mask_keydown = 0x0040000;
648 mask_keyup = 0x0040000;
649 mask_keycode = 0xffff;
David Härdeman651c7a52010-11-19 20:42:51 -0300650 raw_decode = true;
Herton Ronaldo Krzesinski9e1d9e72010-05-08 02:23:37 -0300651 break;
pasky@ucw.cz450efcf2006-11-12 14:22:32 -0300652 case SAA7134_BOARD_AVERMEDIA_777:
pasky@ucw.cz29e0f1a2006-11-12 14:23:32 -0300653 case SAA7134_BOARD_AVERMEDIA_A16AR:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300654 ir_codes = RC_MAP_AVERMEDIA;
pasky@ucw.cz450efcf2006-11-12 14:22:32 -0300655 mask_keycode = 0x02F200;
656 mask_keydown = 0x000400;
657 polling = 50; // ms
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300658 /* GPIO stuff moved to __saa7134_ir_start() */
Linus Torvalds4dd74062006-11-13 09:50:11 -0800659 break;
Tim Farrington6e501a32008-06-15 13:33:42 -0300660 case SAA7134_BOARD_AVERMEDIA_A16D:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300661 ir_codes = RC_MAP_AVERMEDIA_A16D;
Tim Farrington6e501a32008-06-15 13:33:42 -0300662 mask_keycode = 0x02F200;
663 mask_keydown = 0x000400;
664 polling = 50; /* ms */
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300665 /* GPIO stuff moved to __saa7134_ir_start() */
Tim Farrington6e501a32008-06-15 13:33:42 -0300666 break;
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800667 case SAA7134_BOARD_KWORLD_TERMINATOR:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300668 ir_codes = RC_MAP_PIXELVIEW;
James R. Webbdc2286c2005-11-08 21:37:00 -0800669 mask_keycode = 0x00001f;
670 mask_keyup = 0x000060;
671 polling = 50; // ms
672 break;
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700673 case SAA7134_BOARD_MANLI_MTV001:
674 case SAA7134_BOARD_MANLI_MTV002:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300675 ir_codes = RC_MAP_MANLI;
Dmitry Belimovb34dddb2008-04-23 14:09:08 -0300676 mask_keycode = 0x001f00;
677 mask_keyup = 0x004000;
678 polling = 50; /* ms */
679 break;
Nickolay V. Shmyreva8ff4172005-11-08 21:36:16 -0800680 case SAA7134_BOARD_BEHOLD_409FM:
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300681 case SAA7134_BOARD_BEHOLD_401:
682 case SAA7134_BOARD_BEHOLD_403:
683 case SAA7134_BOARD_BEHOLD_403FM:
684 case SAA7134_BOARD_BEHOLD_405:
685 case SAA7134_BOARD_BEHOLD_405FM:
686 case SAA7134_BOARD_BEHOLD_407:
687 case SAA7134_BOARD_BEHOLD_407FM:
688 case SAA7134_BOARD_BEHOLD_409:
689 case SAA7134_BOARD_BEHOLD_505FM:
Dmitri Belimov9c6f97a2009-12-21 02:00:38 -0300690 case SAA7134_BOARD_BEHOLD_505RDS_MK5:
691 case SAA7134_BOARD_BEHOLD_505RDS_MK3:
Andrey J. Melnikoff (TEMHOTA)e8018c92008-01-07 05:17:39 -0300692 case SAA7134_BOARD_BEHOLD_507_9FM:
Dmitri Belimov84d728c2009-04-23 02:32:49 -0300693 case SAA7134_BOARD_BEHOLD_507RDS_MK3:
694 case SAA7134_BOARD_BEHOLD_507RDS_MK5:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300695 ir_codes = RC_MAP_MANLI;
Dmitry Belimovb34dddb2008-04-23 14:09:08 -0300696 mask_keycode = 0x003f00;
697 mask_keyup = 0x004000;
698 polling = 50; /* ms */
699 break;
700 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300701 ir_codes = RC_MAP_BEHOLD_COLUMBUS;
Dmitry Belimovb34dddb2008-04-23 14:09:08 -0300702 mask_keycode = 0x003f00;
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700703 mask_keyup = 0x004000;
Mauro Carvalho Chehabac19ecc2005-06-23 22:05:09 -0700704 polling = 50; // ms
705 break;
Ricardo Cerqueira17ce1ff2005-11-08 21:38:47 -0800706 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300707 ir_codes = RC_MAP_PCTV_SEDNA;
Pavel Mihaylovc3d93192005-11-08 21:38:43 -0800708 mask_keycode = 0x001f00;
709 mask_keyup = 0x004000;
710 polling = 50; // ms
711 break;
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800712 case SAA7134_BOARD_GOTVIEW_7135:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300713 ir_codes = RC_MAP_GOTVIEW7135;
Pedro0938e312007-10-17 17:58:40 -0300714 mask_keycode = 0x0003CC;
Nickolay V. Shmyrev6b961442005-11-08 21:36:22 -0800715 mask_keydown = 0x000010;
Pedro0938e312007-10-17 17:58:40 -0300716 polling = 5; /* ms */
Vadim Solomin8c1476f2011-03-06 13:00:38 -0300717 /* GPIO stuff moved to __saa7134_ir_start() */
Nickolay V. Shmyrev6b961442005-11-08 21:36:22 -0800718 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
Nickolay V. Shmyrev2a9a9a82006-01-09 15:25:33 -0200720 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
Mauro Carvalho Chehab330a1152005-07-12 13:59:01 -0700721 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300722 ir_codes = RC_MAP_VIDEOMATE_TV_PVR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 mask_keycode = 0x00003F;
724 mask_keyup = 0x400000;
725 polling = 50; // ms
726 break;
Michal Majchrowiczb04c1ba2006-09-13 16:42:42 -0300727 case SAA7134_BOARD_PROTEUS_2309:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300728 ir_codes = RC_MAP_PROTEUS_2309;
Michal Majchrowiczb04c1ba2006-09-13 16:42:42 -0300729 mask_keycode = 0x00007F;
730 mask_keyup = 0x000080;
731 polling = 50; // ms
732 break;
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800733 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
734 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300735 ir_codes = RC_MAP_VIDEOMATE_TV_PVR;
Nickolay V. Shmyrevfea095f2005-11-08 21:36:47 -0800736 mask_keycode = 0x003F00;
737 mask_keyup = 0x040000;
738 break;
James Le Cuirotf5c965a2007-07-02 12:53:25 -0300739 case SAA7134_BOARD_FLYDVBS_LR300:
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -0200740 case SAA7134_BOARD_FLYDVBT_LR301:
Rudo Thomasa8029172006-02-27 00:08:46 -0300741 case SAA7134_BOARD_FLYDVBTDUO:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300742 ir_codes = RC_MAP_FLYDVB;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -0200743 mask_keycode = 0x0001F00;
744 mask_keydown = 0x0040000;
745 break;
Hermann Pitton91607232006-12-07 21:45:28 -0300746 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Ed Vipas904ab882007-03-29 18:32:49 -0300747 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabdfb4ba12009-08-20 10:13:40 -0300748 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300749 ir_codes = RC_MAP_ASUS_PC39;
Mauro Carvalho Chehabfe8b67132010-09-30 14:46:47 -0300750 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
751 mask_keyup = 0x0040000;
752 mask_keycode = 0xffff;
David Härdeman651c7a52010-11-19 20:42:51 -0300753 raw_decode = true;
Hermann Pitton91607232006-12-07 21:45:28 -0300754 break;
remi schwartz75c7dbc2012-05-19 06:11:47 -0300755 case SAA7134_BOARD_ASUSTeK_PS3_100:
756 ir_codes = RC_MAP_ASUS_PS3_100;
757 mask_keydown = 0x0040000;
758 mask_keyup = 0x0040000;
759 mask_keycode = 0xffff;
760 raw_decode = true;
761 break;
Juan Pablo Sormanic36c4592006-12-27 12:46:36 -0300762 case SAA7134_BOARD_ENCORE_ENLTV:
763 case SAA7134_BOARD_ENCORE_ENLTV_FM:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300764 ir_codes = RC_MAP_ENCORE_ENLTV;
Juan Pablo Sormanic36c4592006-12-27 12:46:36 -0300765 mask_keycode = 0x00007f;
766 mask_keyup = 0x040000;
767 polling = 50; // ms
768 break;
Mauro Carvalho Chehabbf1ece62008-06-26 17:03:00 -0300769 case SAA7134_BOARD_ENCORE_ENLTV_FM53:
Mauro Carvalho Chehabd642f2f2011-01-19 16:25:17 -0200770 case SAA7134_BOARD_ENCORE_ENLTV_FM3:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300771 ir_codes = RC_MAP_ENCORE_ENLTV_FM53;
Mauro Carvalho Chehabbce8d0f2010-11-17 09:58:09 -0300772 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
773 mask_keyup = 0x0040000;
774 mask_keycode = 0xffff;
David Härdeman651c7a52010-11-19 20:42:51 -0300775 raw_decode = true;
Mauro Carvalho Chehabbf1ece62008-06-26 17:03:00 -0300776 break;
Tony Wan480f75a2007-05-11 11:33:50 -0300777 case SAA7134_BOARD_10MOONSTVMASTER3:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300778 ir_codes = RC_MAP_ENCORE_ENLTV;
Tony Wan480f75a2007-05-11 11:33:50 -0300779 mask_keycode = 0x5f80000;
780 mask_keyup = 0x8000000;
781 polling = 50; //ms
782 break;
Adrian Pardinif0ba3562008-02-11 12:40:53 -0300783 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300784 ir_codes = RC_MAP_GENIUS_TVGO_A11MCE;
Adrian Pardinif0ba3562008-02-11 12:40:53 -0300785 mask_keycode = 0xff;
786 mask_keydown = 0xf00000;
787 polling = 50; /* ms */
788 break;
Mauro Carvalho Chehab9b000192008-06-26 17:03:00 -0300789 case SAA7134_BOARD_REAL_ANGEL_220:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300790 ir_codes = RC_MAP_REAL_AUDIO_220_32_KEYS;
Mauro Carvalho Chehab9b000192008-06-26 17:03:00 -0300791 mask_keycode = 0x3f00;
792 mask_keyup = 0x4000;
793 polling = 50; /* ms */
794 break;
Mauro Carvalho Chehab26d5f3a2008-12-07 13:19:29 -0300795 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300796 ir_codes = RC_MAP_KWORLD_PLUS_TV_ANALOG;
Mauro Carvalho Chehab26d5f3a2008-12-07 13:19:29 -0300797 mask_keycode = 0x7f;
798 polling = 40; /* ms */
799 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -0300800 case SAA7134_BOARD_VIDEOMATE_S350:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300801 ir_codes = RC_MAP_VIDEOMATE_S350;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -0300802 mask_keycode = 0x003f00;
803 mask_keydown = 0x040000;
804 break;
Michael Obst0700ade2009-10-31 14:05:42 -0300805 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300806 ir_codes = RC_MAP_WINFAST;
Michael Obst0700ade2009-10-31 14:05:42 -0300807 mask_keycode = 0x5f00;
808 mask_keyup = 0x020000;
Michael Krufky117e1342009-11-01 11:16:10 -0300809 polling = 50; /* ms */
Michael Obst0700ade2009-10-31 14:05:42 -0300810 break;
Ramiro Moralesb7a0f2e2010-12-26 18:13:30 -0300811 case SAA7134_BOARD_VIDEOMATE_M1F:
Samuel Rakitnican09631192012-01-06 17:34:53 -0300812 ir_codes = RC_MAP_VIDEOMATE_K100;
Ramiro Moralesb7a0f2e2010-12-26 18:13:30 -0300813 mask_keycode = 0x0ff00;
814 mask_keyup = 0x040000;
815 break;
Devin Heitmuellerda4b7b22011-05-20 15:28:24 -0300816 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
817 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
818 ir_codes = RC_MAP_HAUPPAUGE;
819 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
820 mask_keyup = 0x0040000;
821 mask_keycode = 0xffff;
822 raw_decode = true;
823 break;
Darek Zielski63ab664c2015-08-27 19:18:54 -0300824 case SAA7134_BOARD_LEADTEK_WINFAST_TV2100_FM:
825 ir_codes = RC_MAP_LEADTEK_Y04G0051;
826 mask_keydown = 0x0040000; /* Enable GPIO18 line on both edges */
827 mask_keyup = 0x0040000;
828 mask_keycode = 0xffff;
829 raw_decode = true;
830 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 }
832 if (NULL == ir_codes) {
Mauro Carvalho Chehab2bb3e2e2015-04-30 09:17:34 -0300833 pr_err("Oops: IR config error [card=%d]\n", dev->board);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 return -ENODEV;
835 }
836
Dmitry Torokhovb7df3912005-09-15 02:01:53 -0500837 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
Andi Shyti0f7499f2016-12-16 06:50:58 -0200838 rc = rc_allocate_device(RC_DRIVER_SCANCODE);
David Härdemand8b4b582010-10-29 16:08:23 -0300839 if (!ir || !rc) {
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300840 err = -ENOMEM;
841 goto err_out_free;
Dmitry Torokhovb7df3912005-09-15 02:01:53 -0500842 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843
David Härdemand8b4b582010-10-29 16:08:23 -0300844 ir->dev = rc;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -0300845 dev->remote = ir;
846
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 /* init hardware-specific stuff */
848 ir->mask_keycode = mask_keycode;
849 ir->mask_keydown = mask_keydown;
850 ir->mask_keyup = mask_keyup;
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800851 ir->polling = polling;
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -0300852 ir->raw_decode = raw_decode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853
854 /* init input device */
855 snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
856 saa7134_boards[dev->board].name);
857 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
858 pci_name(dev->pci));
859
David Härdemand8b4b582010-10-29 16:08:23 -0300860 rc->priv = dev;
861 rc->open = saa7134_ir_open;
862 rc->close = saa7134_ir_close;
Sean Young12c3b9b2017-08-07 15:54:51 -0400863 if (raw_decode) {
David Härdemand8b4b582010-10-29 16:08:23 -0300864 rc->driver_type = RC_DRIVER_IR_RAW;
Sean Young6d741bf2017-08-07 16:20:58 -0400865 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
Sean Young12c3b9b2017-08-07 15:54:51 -0400866 }
Mauro Carvalho Chehab626cf692010-04-06 23:21:46 -0300867
Sean Young518f4b22017-07-01 12:13:19 -0400868 rc->device_name = ir->name;
David Härdemand8b4b582010-10-29 16:08:23 -0300869 rc->input_phys = ir->phys;
870 rc->input_id.bustype = BUS_PCI;
871 rc->input_id.version = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 if (dev->pci->subsystem_vendor) {
David Härdemand8b4b582010-10-29 16:08:23 -0300873 rc->input_id.vendor = dev->pci->subsystem_vendor;
874 rc->input_id.product = dev->pci->subsystem_device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 } else {
David Härdemand8b4b582010-10-29 16:08:23 -0300876 rc->input_id.vendor = dev->pci->vendor;
877 rc->input_id.product = dev->pci->device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 }
David Härdemand8b4b582010-10-29 16:08:23 -0300879 rc->dev.parent = &dev->pci->dev;
880 rc->map_name = ir_codes;
881 rc->driver_name = MODULE_NAME;
Sean Young48b2de12017-08-07 08:30:18 -0400882 rc->min_timeout = 1;
883 rc->timeout = IR_DEFAULT_TIMEOUT;
884 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885
David Härdemand8b4b582010-10-29 16:08:23 -0300886 err = rc_register_device(rc);
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300887 if (err)
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300888 goto err_out_free;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300889
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 return 0;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300891
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -0300892err_out_free:
David Härdemand8b4b582010-10-29 16:08:23 -0300893 rc_free_device(rc);
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300894 dev->remote = NULL;
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300895 kfree(ir);
896 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897}
898
899void saa7134_input_fini(struct saa7134_dev *dev)
900{
901 if (NULL == dev->remote)
902 return;
903
Dmitry Torokhovb07b4782006-11-20 10:23:04 -0300904 saa7134_ir_stop(dev);
David Härdemand8b4b582010-10-29 16:08:23 -0300905 rc_unregister_device(dev->remote->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 kfree(dev->remote);
907 dev->remote = NULL;
908}
909
Jean Delvarec668f322009-05-13 16:48:50 -0300910void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800911{
Jean Delvare43e16ea2009-10-02 05:47:08 -0300912 struct i2c_board_info info;
Jean Delvarec668f322009-05-13 16:48:50 -0300913 struct i2c_msg msg_msi = {
914 .addr = 0x50,
915 .flags = I2C_M_RD,
916 .len = 0,
917 .buf = NULL,
918 };
Jean Delvarec668f322009-05-13 16:48:50 -0300919 int rc;
920
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800921 if (disable_ir) {
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300922 input_dbg("IR has been disabled, not probing for i2c remote\n");
Ricardo Cerqueiraac9cd972005-11-08 21:37:56 -0800923 return;
924 }
925
Jean Delvare43e16ea2009-10-02 05:47:08 -0300926 memset(&info, 0, sizeof(struct i2c_board_info));
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300927 memset(&dev->init_data, 0, sizeof(dev->init_data));
Jean Delvare43e16ea2009-10-02 05:47:08 -0300928 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300929
930 switch (dev->board) {
931 case SAA7134_BOARD_PINNACLE_PCTV_110i:
932 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300933 dev->init_data.name = "Pinnacle PCTV";
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300934 if (pinnacle_remote == 0) {
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300935 dev->init_data.get_key = get_key_pinnacle_color;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300936 dev->init_data.ir_codes = RC_MAP_PINNACLE_COLOR;
Jean Delvare43e16ea2009-10-02 05:47:08 -0300937 info.addr = 0x47;
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300938 } else {
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300939 dev->init_data.get_key = get_key_pinnacle_grey;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300940 dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY;
Jean Delvare43e16ea2009-10-02 05:47:08 -0300941 info.addr = 0x47;
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300942 }
943 break;
944 case SAA7134_BOARD_UPMOST_PURPLE_TV:
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300945 dev->init_data.name = "Purple TV";
946 dev->init_data.get_key = get_key_purpletv;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300947 dev->init_data.ir_codes = RC_MAP_PURPLETV;
Jean Delvareaef02aa2009-10-02 08:47:22 -0300948 info.addr = 0x7a;
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300949 break;
950 case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -0300951 dev->init_data.name = "MSI TV@nywhere Plus";
952 dev->init_data.get_key = get_key_msi_tvanywhere_plus;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -0300953 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS;
Mauro Carvalho Chehabc72ba8e2010-09-23 01:23:10 -0300954 /*
955 * MSI TV@nyware Plus requires more frequent polling
956 * otherwise it will miss some keypresses
957 */
958 dev->init_data.polling_interval = 50;
Jean Delvare43e16ea2009-10-02 05:47:08 -0300959 info.addr = 0x30;
Jean Delvareec218a42009-05-13 16:51:46 -0300960 /* MSI TV@nywhere Plus controller doesn't seem to
961 respond to probes unless we read something from
962 an existing device. Weird...
963 REVISIT: might no longer be needed */
964 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -0300965 input_dbg("probe 0x%02x @ %s: %s\n",
Jean Delvareec218a42009-05-13 16:51:46 -0300966 msg_msi.addr, dev->i2c_adap.name,
967 (1 == rc) ? "yes" : "no");
Jean Delvare4d7a2d62009-05-13 16:49:32 -0300968 break;
GEORGE9c917382016-02-14 19:23:15 -0200969 case SAA7134_BOARD_SNAZIO_TVPVR_PRO:
970 dev->init_data.name = "SnaZio* TVPVR PRO";
971 dev->init_data.get_key = get_key_msi_tvanywhere_plus;
972 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS;
973 /*
974 * MSI TV@nyware Plus requires more frequent polling
975 * otherwise it will miss some keypresses
976 */
977 dev->init_data.polling_interval = 50;
978 info.addr = 0x30;
979 /*
980 * MSI TV@nywhere Plus controller doesn't seem to
981 * respond to probes unless we read something from
982 * an existing device. Weird...
983 * REVISIT: might no longer be needed
984 */
985 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
986 input_dbg("probe 0x%02x @ %s: %s\n",
987 msg_msi.addr, dev->i2c_adap.name,
988 (rc == 1) ? "yes" : "no");
989 break;
Kyle Strickland25fa2072012-02-18 02:24:53 -0300990 case SAA7134_BOARD_KWORLD_PC150U:
991 /* copied and modified from MSI TV@nywhere Plus */
992 dev->init_data.name = "Kworld PC150-U";
993 dev->init_data.get_key = get_key_kworld_pc150u;
994 dev->init_data.ir_codes = RC_MAP_KWORLD_PC150U;
995 info.addr = 0x30;
996 /* MSI TV@nywhere Plus controller doesn't seem to
997 respond to probes unless we read something from
998 an existing device. Weird...
999 REVISIT: might no longer be needed */
1000 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1);
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -03001001 input_dbg("probe 0x%02x @ %s: %s\n",
Kyle Strickland25fa2072012-02-18 02:24:53 -03001002 msg_msi.addr, dev->i2c_adap.name,
1003 (1 == rc) ? "yes" : "no");
1004 break;
Jean Delvare4d7a2d62009-05-13 16:49:32 -03001005 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -03001006 dev->init_data.name = "HVR 1110";
1007 dev->init_data.get_key = get_key_hvr1110;
Mauro Carvalho Chehabaf86ce72011-01-24 12:18:48 -03001008 dev->init_data.ir_codes = RC_MAP_HAUPPAUGE;
Jean Delvare30093e82009-10-02 09:48:04 -03001009 info.addr = 0x71;
Jean Delvare4d7a2d62009-05-13 16:49:32 -03001010 break;
1011 case SAA7134_BOARD_BEHOLD_607FM_MK3:
1012 case SAA7134_BOARD_BEHOLD_607FM_MK5:
1013 case SAA7134_BOARD_BEHOLD_609FM_MK3:
1014 case SAA7134_BOARD_BEHOLD_609FM_MK5:
1015 case SAA7134_BOARD_BEHOLD_607RDS_MK3:
1016 case SAA7134_BOARD_BEHOLD_607RDS_MK5:
1017 case SAA7134_BOARD_BEHOLD_609RDS_MK3:
1018 case SAA7134_BOARD_BEHOLD_609RDS_MK5:
1019 case SAA7134_BOARD_BEHOLD_M6:
1020 case SAA7134_BOARD_BEHOLD_M63:
1021 case SAA7134_BOARD_BEHOLD_M6_EXTRA:
1022 case SAA7134_BOARD_BEHOLD_H6:
Dmitri Belimov2012c87f2009-08-26 01:01:12 -03001023 case SAA7134_BOARD_BEHOLD_X7:
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001024 case SAA7134_BOARD_BEHOLD_H7:
1025 case SAA7134_BOARD_BEHOLD_A7:
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -03001026 dev->init_data.name = "BeholdTV";
1027 dev->init_data.get_key = get_key_beholdm6xx;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -03001028 dev->init_data.ir_codes = RC_MAP_BEHOLD;
Sean Young6d741bf2017-08-07 16:20:58 -04001029 dev->init_data.type = RC_PROTO_BIT_NECX;
Jean Delvare30093e82009-10-02 09:48:04 -03001030 info.addr = 0x2d;
Jean Delvare4d7a2d62009-05-13 16:49:32 -03001031 break;
Jean Delvared9a88e62009-05-13 16:52:44 -03001032 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
1033 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Jean Delvare43e16ea2009-10-02 05:47:08 -03001034 info.addr = 0x40;
Jean Delvared9a88e62009-05-13 16:52:44 -03001035 break;
Ondrej Zary34fe2782013-04-06 14:28:16 -03001036 case SAA7134_BOARD_AVERMEDIA_A706:
1037 info.addr = 0x41;
1038 break;
Lukas Karasd995a182009-11-24 12:06:52 -03001039 case SAA7134_BOARD_FLYDVB_TRIO:
1040 dev->init_data.name = "FlyDVB Trio";
1041 dev->init_data.get_key = get_key_flydvb_trio;
Mauro Carvalho Chehab02858ee2010-04-02 20:01:00 -03001042 dev->init_data.ir_codes = RC_MAP_FLYDVB;
Lukas Karasd995a182009-11-24 12:06:52 -03001043 info.addr = 0x0b;
1044 break;
Jean Delvare30093e82009-10-02 09:48:04 -03001045 default:
Mauro Carvalho Chehab6be5b1a2015-04-30 09:02:03 -03001046 input_dbg("No I2C IR support for board %x\n", dev->board);
Jean Delvare30093e82009-10-02 09:48:04 -03001047 return;
Jean Delvare4d7a2d62009-05-13 16:49:32 -03001048 }
1049
Mauro Carvalho Chehab7aedd5ec2009-09-07 02:22:01 -03001050 if (dev->init_data.name)
Jean Delvare43e16ea2009-10-02 05:47:08 -03001051 info.platform_data = &dev->init_data;
Jean Delvare30093e82009-10-02 09:48:04 -03001052 i2c_new_device(&dev->i2c_adap, &info);
Jean Delvarec668f322009-05-13 16:48:50 -03001053}
1054
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -03001055static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
1056{
David Härdeman651c7a52010-11-19 20:42:51 -03001057 struct saa7134_card_ir *ir = dev->remote;
Mauro Carvalho Chehab2f16f632010-04-03 18:51:50 -03001058 int space;
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -03001059
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -03001060 /* Generate initial event */
1061 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
1062 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
Mauro Carvalho Chehab2f16f632010-04-03 18:51:50 -03001063 space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
Sean Young86fe1ac2017-08-07 08:38:10 -04001064 ir_raw_event_store_edge(dev->remote->dev, !space);
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -03001065
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -03001066 return 1;
1067}