Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * |
3 | * keyboard input driver for i2c IR remote controls | |
4 | * | |
5 | * Copyright (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org> | |
6 | * modified for PixelView (BT878P+W/FM) by | |
7 | * Michal Kochanowicz <mkochano@pld.org.pl> | |
8 | * Christoph Bartelmus <lirc@bartelmus.de> | |
9 | * modified for KNC ONE TV Station/Anubis Typhoon TView Tuner by | |
10 | * Ulrich Mueller <ulrich.mueller42@web.de> | |
c365864f MR |
11 | * modified for em2820 based USB TV tuners by |
12 | * Markus Rechberger <mrechberger@gmail.com> | |
d54d6980 CZ |
13 | * modified for DViCO Fusion HDTV 5 RT GOLD by |
14 | * Chaogui Zhang <czhang1974@gmail.com> | |
ba340b40 BR |
15 | * modified for MSI TV@nywhere Plus by |
16 | * Henry Wong <henry@stuffedcow.net> | |
17 | * Mark Schultz <n9xmj@yahoo.com> | |
18 | * Brian Rogers <brian_rogers@comcast.net> | |
cb3bf504 OJ |
19 | * modified for AVerMedia Cardbus by |
20 | * Oldrich Jedlicka <oldium.pro@seznam.cz> | |
1da177e4 LT |
21 | * |
22 | * This program is free software; you can redistribute it and/or modify | |
23 | * it under the terms of the GNU General Public License as published by | |
24 | * the Free Software Foundation; either version 2 of the License, or | |
25 | * (at your option) any later version. | |
26 | * | |
27 | * This program is distributed in the hope that it will be useful, | |
28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
30 | * GNU General Public License for more details. | |
31 | * | |
1da177e4 LT |
32 | */ |
33 | ||
00bb8207 | 34 | #include <asm/unaligned.h> |
1da177e4 | 35 | #include <linux/module.h> |
1da177e4 LT |
36 | #include <linux/init.h> |
37 | #include <linux/kernel.h> | |
1da177e4 LT |
38 | #include <linux/string.h> |
39 | #include <linux/timer.h> | |
40 | #include <linux/delay.h> | |
41 | #include <linux/errno.h> | |
42 | #include <linux/slab.h> | |
43 | #include <linux/i2c.h> | |
44 | #include <linux/workqueue.h> | |
674434c6 | 45 | |
6bda9644 | 46 | #include <media/rc-core.h> |
b5dcee22 | 47 | #include <media/i2c/ir-kbd-i2c.h> |
c365864f | 48 | |
1da177e4 LT |
49 | /* ----------------------------------------------------------------------- */ |
50 | /* insmod parameters */ | |
51 | ||
52 | static int debug; | |
53 | module_param(debug, int, 0644); /* debug level (0,1,2) */ | |
54 | ||
bf47e4e4 | 55 | |
727e625c | 56 | #define MODULE_NAME "ir-kbd-i2c" |
1da177e4 | 57 | #define dprintk(level, fmt, arg...) if (debug >= level) \ |
727e625c | 58 | printk(KERN_DEBUG MODULE_NAME ": " fmt , ## arg) |
1da177e4 LT |
59 | |
60 | /* ----------------------------------------------------------------------- */ | |
61 | ||
6d741bfe SY |
62 | static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol, |
63 | u32 *scancode, u8 *ptoggle, int size) | |
1da177e4 | 64 | { |
39cf1e81 | 65 | unsigned char buf[6]; |
00bb8207 | 66 | int start, range, toggle, dev, code, ircode, vendor; |
1da177e4 LT |
67 | |
68 | /* poll IR chip */ | |
c668f32d | 69 | if (size != i2c_master_recv(ir->c, buf, size)) |
1da177e4 LT |
70 | return -EIO; |
71 | ||
00bb8207 SY |
72 | if (buf[0] & 0x80) { |
73 | int offset = (size == 6) ? 3 : 0; | |
1da177e4 | 74 | |
00bb8207 SY |
75 | /* split rc5 data block ... */ |
76 | start = (buf[offset] >> 7) & 1; | |
77 | range = (buf[offset] >> 6) & 1; | |
78 | toggle = (buf[offset] >> 5) & 1; | |
79 | dev = buf[offset] & 0x1f; | |
80 | code = (buf[offset+1] >> 2) & 0x3f; | |
4dd9bb91 | 81 | |
00bb8207 SY |
82 | /* rc5 has two start bits |
83 | * the first bit must be one | |
84 | * the second bit defines the command range: | |
85 | * 1 = 0-63, 0 = 64 - 127 | |
86 | */ | |
87 | if (!start) | |
88 | /* no key pressed */ | |
89 | return 0; | |
34c08029 | 90 | |
00bb8207 SY |
91 | /* filter out invalid key presses */ |
92 | ircode = (start << 12) | (toggle << 11) | (dev << 6) | code; | |
93 | if ((ircode & 0x1fff) == 0x1fff) | |
94 | return 0; | |
cc7093df | 95 | |
00bb8207 SY |
96 | if (!range) |
97 | code += 64; | |
1da177e4 | 98 | |
00bb8207 SY |
99 | dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", |
100 | start, range, toggle, dev, code); | |
101 | ||
6d741bfe | 102 | *protocol = RC_PROTO_RC5; |
00bb8207 SY |
103 | *scancode = RC_SCANCODE_RC5(dev, code); |
104 | *ptoggle = toggle; | |
105 | ||
106 | return 1; | |
107 | } else if (size == 6 && (buf[0] & 0x40)) { | |
108 | code = buf[4]; | |
109 | dev = buf[3]; | |
110 | vendor = get_unaligned_be16(buf + 1); | |
111 | ||
112 | if (vendor == 0x800f) { | |
113 | *ptoggle = (dev & 0x80) != 0; | |
6d741bfe | 114 | *protocol = RC_PROTO_RC6_MCE; |
00bb8207 SY |
115 | dev &= 0x7f; |
116 | dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n", | |
9cdbe14f | 117 | *ptoggle, vendor, dev, code); |
00bb8207 SY |
118 | } else { |
119 | *ptoggle = 0; | |
6d741bfe | 120 | *protocol = RC_PROTO_RC6_6A_32; |
00bb8207 SY |
121 | dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n", |
122 | vendor, dev, code); | |
123 | } | |
124 | ||
125 | *scancode = RC_SCANCODE_RC6_6A(vendor, dev, code); | |
126 | ||
127 | return 1; | |
128 | } | |
129 | ||
130 | return 0; | |
1da177e4 LT |
131 | } |
132 | ||
6d741bfe | 133 | static int get_key_haup(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 134 | u32 *scancode, u8 *toggle) |
39cf1e81 | 135 | { |
00bb8207 | 136 | return get_key_haup_common(ir, protocol, scancode, toggle, 3); |
39cf1e81 JF |
137 | } |
138 | ||
6d741bfe | 139 | static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 140 | u32 *scancode, u8 *toggle) |
39cf1e81 | 141 | { |
8df59918 JW |
142 | int ret; |
143 | unsigned char buf[1] = { 0 }; | |
144 | ||
145 | /* | |
146 | * This is the same apparent "are you ready?" poll command observed | |
147 | * watching Windows driver traffic and implemented in lirc_zilog. With | |
148 | * this added, we get far saner remote behavior with z8 chips on usb | |
149 | * connected devices, even with the default polling interval of 100ms. | |
150 | */ | |
151 | ret = i2c_master_send(ir->c, buf, 1); | |
152 | if (ret != 1) | |
153 | return (ret < 0) ? ret : -EINVAL; | |
154 | ||
00bb8207 | 155 | return get_key_haup_common(ir, protocol, scancode, toggle, 6); |
39cf1e81 JF |
156 | } |
157 | ||
6d741bfe | 158 | static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 159 | u32 *scancode, u8 *toggle) |
1da177e4 | 160 | { |
4ac97914 | 161 | unsigned char b; |
1da177e4 LT |
162 | |
163 | /* poll IR chip */ | |
c668f32d | 164 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
1da177e4 LT |
165 | dprintk(1,"read error\n"); |
166 | return -EIO; | |
167 | } | |
4dd9bb91 | 168 | |
6d741bfe | 169 | *protocol = RC_PROTO_OTHER; |
4dd9bb91 DH |
170 | *scancode = b; |
171 | *toggle = 0; | |
1da177e4 LT |
172 | return 1; |
173 | } | |
174 | ||
6d741bfe | 175 | static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 176 | u32 *scancode, u8 *toggle) |
d54d6980 CZ |
177 | { |
178 | unsigned char buf[4]; | |
179 | ||
180 | /* poll IR chip */ | |
c668f32d | 181 | if (4 != i2c_master_recv(ir->c, buf, 4)) { |
d54d6980 CZ |
182 | dprintk(1,"read error\n"); |
183 | return -EIO; | |
184 | } | |
185 | ||
186 | if(buf[0] !=0 || buf[1] !=0 || buf[2] !=0 || buf[3] != 0) | |
7e28adb2 | 187 | dprintk(2, "%s: 0x%2x 0x%2x 0x%2x 0x%2x\n", __func__, |
d54d6980 CZ |
188 | buf[0], buf[1], buf[2], buf[3]); |
189 | ||
190 | /* no key pressed or signal from other ir remote */ | |
191 | if(buf[0] != 0x1 || buf[1] != 0xfe) | |
192 | return 0; | |
193 | ||
6d741bfe | 194 | *protocol = RC_PROTO_UNKNOWN; |
4dd9bb91 DH |
195 | *scancode = buf[2]; |
196 | *toggle = 0; | |
d54d6980 | 197 | return 1; |
d54d6980 CZ |
198 | } |
199 | ||
6d741bfe | 200 | static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 201 | u32 *scancode, u8 *toggle) |
1da177e4 LT |
202 | { |
203 | unsigned char b; | |
204 | ||
205 | /* poll IR chip */ | |
c668f32d | 206 | if (1 != i2c_master_recv(ir->c, &b, 1)) { |
1da177e4 LT |
207 | dprintk(1,"read error\n"); |
208 | return -EIO; | |
209 | } | |
210 | ||
211 | /* it seems that 0xFE indicates that a button is still hold | |
4f9c05aa MCC |
212 | down, while 0xff indicates that no button is hold |
213 | down. 0xfe sequences are sometimes interrupted by 0xFF */ | |
1da177e4 LT |
214 | |
215 | dprintk(2,"key %02x\n", b); | |
216 | ||
4f9c05aa | 217 | if (b == 0xff) |
1da177e4 LT |
218 | return 0; |
219 | ||
4f9c05aa | 220 | if (b == 0xfe) |
1da177e4 LT |
221 | /* keep old data */ |
222 | return 1; | |
223 | ||
6d741bfe | 224 | *protocol = RC_PROTO_UNKNOWN; |
4dd9bb91 DH |
225 | *scancode = b; |
226 | *toggle = 0; | |
1da177e4 LT |
227 | return 1; |
228 | } | |
229 | ||
6d741bfe | 230 | static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol, |
4dd9bb91 | 231 | u32 *scancode, u8 *toggle) |
cb3bf504 OJ |
232 | { |
233 | unsigned char subaddr, key, keygroup; | |
c668f32d | 234 | struct i2c_msg msg[] = { { .addr = ir->c->addr, .flags = 0, |
cb3bf504 | 235 | .buf = &subaddr, .len = 1}, |
c668f32d | 236 | { .addr = ir->c->addr, .flags = I2C_M_RD, |
cb3bf504 OJ |
237 | .buf = &key, .len = 1} }; |
238 | subaddr = 0x0d; | |
c668f32d | 239 | if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { |
cb3bf504 OJ |
240 | dprintk(1, "read error\n"); |
241 | return -EIO; | |
242 | } | |
243 | ||
244 | if (key == 0xff) | |
245 | return 0; | |
246 | ||
247 | subaddr = 0x0b; | |
248 | msg[1].buf = &keygroup; | |
c668f32d | 249 | if (2 != i2c_transfer(ir->c->adapter, msg, 2)) { |
cb3bf504 OJ |
250 | dprintk(1, "read error\n"); |
251 | return -EIO; | |
252 | } | |
253 | ||
254 | if (keygroup == 0xff) | |
255 | return 0; | |
256 | ||
257 | dprintk(1, "read key 0x%02x/0x%02x\n", key, keygroup); | |
34fe2784 | 258 | if (keygroup < 2 || keygroup > 4) { |
cb3bf504 OJ |
259 | /* Only a warning */ |
260 | dprintk(1, "warning: invalid key group 0x%02x for key 0x%02x\n", | |
261 | keygroup, key); | |
262 | } | |
263 | key |= (keygroup & 1) << 6; | |
264 | ||
6d741bfe | 265 | *protocol = RC_PROTO_UNKNOWN; |
4dd9bb91 DH |
266 | *scancode = key; |
267 | if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ | |
268 | *scancode |= keygroup << 8; | |
269 | *toggle = 0; | |
cb3bf504 OJ |
270 | return 1; |
271 | } | |
272 | ||
1da177e4 LT |
273 | /* ----------------------------------------------------------------------- */ |
274 | ||
90bf3aab | 275 | static int ir_key_poll(struct IR_i2c *ir) |
1da177e4 | 276 | { |
6d741bfe | 277 | enum rc_proto protocol; |
4dd9bb91 DH |
278 | u32 scancode; |
279 | u8 toggle; | |
1da177e4 LT |
280 | int rc; |
281 | ||
e6bcb2f3 | 282 | dprintk(3, "%s\n", __func__); |
4dd9bb91 | 283 | rc = ir->get_key(ir, &protocol, &scancode, &toggle); |
1da177e4 LT |
284 | if (rc < 0) { |
285 | dprintk(2,"error\n"); | |
90bf3aab | 286 | return rc; |
1da177e4 LT |
287 | } |
288 | ||
e6bcb2f3 | 289 | if (rc) { |
120703f9 DH |
290 | dprintk(1, "%s: proto = 0x%04x, scancode = 0x%08x\n", |
291 | __func__, protocol, scancode); | |
292 | rc_keydown(ir->rc, protocol, scancode, toggle); | |
e6bcb2f3 | 293 | } |
90bf3aab | 294 | return 0; |
1da177e4 LT |
295 | } |
296 | ||
c4028958 | 297 | static void ir_work(struct work_struct *work) |
1da177e4 | 298 | { |
90bf3aab | 299 | int rc; |
c1089bdc | 300 | struct IR_i2c *ir = container_of(work, struct IR_i2c, work.work); |
8083c520 | 301 | |
90bf3aab MCC |
302 | rc = ir_key_poll(ir); |
303 | if (rc == -ENODEV) { | |
304 | rc_unregister_device(ir->rc); | |
305 | ir->rc = NULL; | |
306 | return; | |
307 | } | |
308 | ||
c72ba8e6 | 309 | schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling_interval)); |
1da177e4 LT |
310 | } |
311 | ||
312 | /* ----------------------------------------------------------------------- */ | |
313 | ||
c668f32d | 314 | static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) |
1da177e4 | 315 | { |
02858eed | 316 | char *ir_codes = NULL; |
9a4cc5ac | 317 | const char *name = NULL; |
6d741bfe | 318 | u64 rc_proto = RC_PROTO_BIT_UNKNOWN; |
afd1a0c9 | 319 | struct IR_i2c *ir; |
2eb25832 | 320 | struct rc_dev *rc = NULL; |
c668f32d JD |
321 | struct i2c_adapter *adap = client->adapter; |
322 | unsigned short addr = client->addr; | |
b07b4783 | 323 | int err; |
1da177e4 | 324 | |
c02b211d | 325 | ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL); |
2eb25832 MCC |
326 | if (!ir) |
327 | return -ENOMEM; | |
b7df3910 | 328 | |
c668f32d | 329 | ir->c = client; |
c72ba8e6 | 330 | ir->polling_interval = DEFAULT_POLLING_INTERVAL; |
c668f32d | 331 | i2c_set_clientdata(client, ir); |
d21838dd | 332 | |
1da177e4 LT |
333 | switch(addr) { |
334 | case 0x64: | |
335 | name = "Pixelview"; | |
336 | ir->get_key = get_key_pixelview; | |
6d741bfe | 337 | rc_proto = RC_PROTO_BIT_OTHER; |
02858eed | 338 | ir_codes = RC_MAP_EMPTY; |
1da177e4 | 339 | break; |
1da177e4 | 340 | case 0x18: |
ca39d84d | 341 | case 0x1f: |
1da177e4 LT |
342 | case 0x1a: |
343 | name = "Hauppauge"; | |
344 | ir->get_key = get_key_haup; | |
6d741bfe | 345 | rc_proto = RC_PROTO_BIT_RC5; |
20624106 | 346 | ir_codes = RC_MAP_HAUPPAUGE; |
1da177e4 LT |
347 | break; |
348 | case 0x30: | |
d5e52653 MCC |
349 | name = "KNC One"; |
350 | ir->get_key = get_key_knc1; | |
6d741bfe | 351 | rc_proto = RC_PROTO_BIT_OTHER; |
02858eed | 352 | ir_codes = RC_MAP_EMPTY; |
1da177e4 | 353 | break; |
d54d6980 | 354 | case 0x6b: |
3c44358c MK |
355 | name = "FusionHDTV"; |
356 | ir->get_key = get_key_fusionhdtv; | |
6d741bfe | 357 | rc_proto = RC_PROTO_BIT_UNKNOWN; |
02858eed | 358 | ir_codes = RC_MAP_FUSIONHDTV_MCE; |
d54d6980 | 359 | break; |
cb3bf504 OJ |
360 | case 0x40: |
361 | name = "AVerMedia Cardbus remote"; | |
362 | ir->get_key = get_key_avermedia_cardbus; | |
6d741bfe | 363 | rc_proto = RC_PROTO_BIT_OTHER; |
02858eed | 364 | ir_codes = RC_MAP_AVERMEDIA_CARDBUS; |
cb3bf504 | 365 | break; |
34fe2784 OZ |
366 | case 0x41: |
367 | name = "AVerMedia EM78P153"; | |
368 | ir->get_key = get_key_avermedia_cardbus; | |
6d741bfe | 369 | rc_proto = RC_PROTO_BIT_OTHER; |
34fe2784 OZ |
370 | /* RM-KV remote, seems to be same as RM-K6 */ |
371 | ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6; | |
372 | break; | |
c69a4af6 AW |
373 | case 0x71: |
374 | name = "Hauppauge/Zilog Z8"; | |
375 | ir->get_key = get_key_haup_xvr; | |
6d741bfe SY |
376 | rc_proto = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE | |
377 | RC_PROTO_BIT_RC6_6A_32; | |
20624106 | 378 | ir_codes = RC_MAP_HAUPPAUGE; |
c69a4af6 | 379 | break; |
1da177e4 LT |
380 | } |
381 | ||
4d7a2d67 JD |
382 | /* Let the caller override settings */ |
383 | if (client->dev.platform_data) { | |
384 | const struct IR_i2c_init_data *init_data = | |
385 | client->dev.platform_data; | |
386 | ||
387 | ir_codes = init_data->ir_codes; | |
2eb25832 MCC |
388 | rc = init_data->rc_dev; |
389 | ||
4d7a2d67 | 390 | name = init_data->name; |
1b6e59e3 | 391 | if (init_data->type) |
6d741bfe | 392 | rc_proto = init_data->type; |
1b6e59e3 | 393 | |
c72ba8e6 MCC |
394 | if (init_data->polling_interval) |
395 | ir->polling_interval = init_data->polling_interval; | |
396 | ||
1b6e59e3 AW |
397 | switch (init_data->internal_get_key_func) { |
398 | case IR_KBD_GET_KEY_CUSTOM: | |
399 | /* The bridge driver provided us its own function */ | |
400 | ir->get_key = init_data->get_key; | |
401 | break; | |
402 | case IR_KBD_GET_KEY_PIXELVIEW: | |
403 | ir->get_key = get_key_pixelview; | |
404 | break; | |
1b6e59e3 AW |
405 | case IR_KBD_GET_KEY_HAUP: |
406 | ir->get_key = get_key_haup; | |
407 | break; | |
408 | case IR_KBD_GET_KEY_KNC1: | |
409 | ir->get_key = get_key_knc1; | |
410 | break; | |
411 | case IR_KBD_GET_KEY_FUSIONHDTV: | |
412 | ir->get_key = get_key_fusionhdtv; | |
413 | break; | |
414 | case IR_KBD_GET_KEY_HAUP_XVR: | |
415 | ir->get_key = get_key_haup_xvr; | |
416 | break; | |
417 | case IR_KBD_GET_KEY_AVERMEDIA_CARDBUS: | |
418 | ir->get_key = get_key_avermedia_cardbus; | |
419 | break; | |
420 | } | |
4d7a2d67 JD |
421 | } |
422 | ||
2eb25832 MCC |
423 | if (!rc) { |
424 | /* | |
39c1cb2b | 425 | * If platform_data doesn't specify rc_dev, initialize it |
2eb25832 MCC |
426 | * internally |
427 | */ | |
0f7499fd | 428 | rc = rc_allocate_device(RC_DRIVER_SCANCODE); |
c02b211d LP |
429 | if (!rc) |
430 | return -ENOMEM; | |
2eb25832 MCC |
431 | } |
432 | ir->rc = rc; | |
433 | ||
9a4cc5ac | 434 | /* Make sure we are all setup before going on */ |
6d741bfe | 435 | if (!name || !ir->get_key || !rc_proto || !ir_codes) { |
d995a187 | 436 | dprintk(1, ": Unsupported device at address 0x%02x\n", |
9a4cc5ac JD |
437 | addr); |
438 | err = -ENODEV; | |
439 | goto err_out_free; | |
440 | } | |
441 | ||
b07b4783 | 442 | ir->ir_codes = ir_codes; |
d5e52653 | 443 | |
afc7f24c | 444 | snprintf(ir->phys, sizeof(ir->phys), "%s/%s", dev_name(&adap->dev), |
c668f32d | 445 | dev_name(&client->dev)); |
ac9cd976 | 446 | |
2eb25832 MCC |
447 | /* |
448 | * Initialize input_dev fields | |
449 | * It doesn't make sense to allow overriding them via platform_data | |
450 | */ | |
d8b4b582 | 451 | rc->input_id.bustype = BUS_I2C; |
d8b4b582 | 452 | rc->input_phys = ir->phys; |
afc7f24c SY |
453 | rc->device_name = name; |
454 | rc->dev.parent = &client->dev; | |
2eb25832 MCC |
455 | |
456 | /* | |
457 | * Initialize the other fields of rc_dev | |
458 | */ | |
459 | rc->map_name = ir->ir_codes; | |
6d741bfe | 460 | rc->allowed_protocols = rc_proto; |
2eb25832 MCC |
461 | if (!rc->driver_name) |
462 | rc->driver_name = MODULE_NAME; | |
b7df3910 | 463 | |
d8b4b582 | 464 | err = rc_register_device(rc); |
b07b4783 | 465 | if (err) |
c668f32d | 466 | goto err_out_free; |
b07b4783 | 467 | |
1da177e4 | 468 | /* start polling via eventd */ |
c1089bdc JD |
469 | INIT_DELAYED_WORK(&ir->work, ir_work); |
470 | schedule_delayed_work(&ir->work, 0); | |
1da177e4 LT |
471 | |
472 | return 0; | |
b07b4783 | 473 | |
b07b4783 | 474 | err_out_free: |
2eb25832 | 475 | /* Only frees rc if it were allocated internally */ |
d8b4b582 | 476 | rc_free_device(rc); |
b07b4783 | 477 | return err; |
1da177e4 LT |
478 | } |
479 | ||
c668f32d | 480 | static int ir_remove(struct i2c_client *client) |
1da177e4 | 481 | { |
4ac97914 | 482 | struct IR_i2c *ir = i2c_get_clientdata(client); |
1da177e4 LT |
483 | |
484 | /* kill outstanding polls */ | |
c1089bdc | 485 | cancel_delayed_work_sync(&ir->work); |
1da177e4 | 486 | |
c668f32d | 487 | /* unregister device */ |
8f1aeedf | 488 | rc_unregister_device(ir->rc); |
1da177e4 LT |
489 | |
490 | /* free memory */ | |
1da177e4 LT |
491 | return 0; |
492 | } | |
493 | ||
c668f32d JD |
494 | static const struct i2c_device_id ir_kbd_id[] = { |
495 | /* Generic entry for any IR receiver */ | |
496 | { "ir_video", 0 }, | |
f5d887ae AW |
497 | /* IR device specific entries should be added here */ |
498 | { "ir_rx_z8f0811_haup", 0 }, | |
a9cd591e | 499 | { "ir_rx_z8f0811_hdpvr", 0 }, |
c668f32d JD |
500 | { } |
501 | }; | |
cb3bf504 | 502 | |
c6e8d86f | 503 | static struct i2c_driver ir_kbd_driver = { |
c668f32d JD |
504 | .driver = { |
505 | .name = "ir-kbd-i2c", | |
506 | }, | |
507 | .probe = ir_probe, | |
508 | .remove = ir_remove, | |
509 | .id_table = ir_kbd_id, | |
510 | }; | |
1da177e4 | 511 | |
c6e8d86f AL |
512 | module_i2c_driver(ir_kbd_driver); |
513 | ||
1da177e4 LT |
514 | /* ----------------------------------------------------------------------- */ |
515 | ||
516 | MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, Ulrich Mueller"); | |
517 | MODULE_DESCRIPTION("input driver for i2c IR remote controls"); | |
518 | MODULE_LICENSE("GPL"); |