blob: 4a32e89a3cfe4dd755fe1c1c2a68b09728cdcf1b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
David Härdeman62c65032010-10-29 16:08:07 -03002 * some common functions to handle infrared remote protocol decoding for
3 * drivers which have not yet been (or can't be) converted to use the
4 * regular protocol decoders...
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
Mauro Carvalho Chehabd5e52652005-11-08 21:37:32 -080023#ifndef _IR_COMMON
24#define _IR_COMMON
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Mauro Carvalho Chehabd5e52652005-11-08 21:37:32 -080026#include <linux/input.h>
Mauro Carvalho Chehab0b778a52006-12-27 14:04:09 -020027#include <linux/workqueue.h>
Mauro Carvalho Chehab622ecb32008-08-05 10:03:17 -030028#include <linux/interrupt.h>
Mauro Carvalho Chehab446e4a62009-12-11 08:34:07 -030029#include <media/ir-core.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
Hermann Pitton91607232006-12-07 21:45:28 -030031#define RC5_START(x) (((x)>>12)&3)
32#define RC5_TOGGLE(x) (((x)>>11)&1)
33#define RC5_ADDR(x) (((x)>>6)&31)
34#define RC5_INSTR(x) ((x)&63)
35
Hermann Pitton91607232006-12-07 21:45:28 -030036/* this was saa7134_ir and bttv_ir, moved here for
37 * rc5 decoding. */
38struct card_ir {
39 struct input_dev *dev;
Hermann Pitton91607232006-12-07 21:45:28 -030040 char name[32];
41 char phys[32];
Mauro Carvalho Chehab716aab42010-03-31 14:40:35 -030042 int users;
Mauro Carvalho Chehab02108942010-03-20 00:25:37 -030043 u32 running:1;
44 struct ir_dev_props props;
45
Hermann Pitton91607232006-12-07 21:45:28 -030046 /* Usual gpio signalling */
Hermann Pitton91607232006-12-07 21:45:28 -030047 u32 mask_keycode;
48 u32 mask_keydown;
49 u32 mask_keyup;
50 u32 polling;
51 u32 last_gpio;
52 int shift_by;
53 int start; // What should RC5_START() be
54 int addr; // What RC5_ADDR() should be.
Hermann Pitton91607232006-12-07 21:45:28 -030055 int rc5_remote_gap;
56 struct work_struct work;
57 struct timer_list timer;
58
59 /* RC5 gpio */
60 u32 rc5_gpio;
61 struct timer_list timer_end; /* timer_end for code completion */
Hermann Pitton91607232006-12-07 21:45:28 -030062 u32 last_bit; /* last raw bit seen */
63 u32 code; /* raw code under construction */
64 struct timeval base_time; /* time of last seen code */
65 int active; /* building raw code */
Mauro Carvalho Chehab622ecb32008-08-05 10:03:17 -030066
67 /* NEC decoding */
68 u32 nec_gpio;
69 struct tasklet_struct tlet;
Mauro Carvalho Chehaba3572c32010-03-20 20:59:44 -030070
71 /* IR core raw decoding */
72 u32 raw_decode;
Hermann Pitton91607232006-12-07 21:45:28 -030073};
74
Mauro Carvalho Chehabef53a112009-11-27 22:01:23 -030075/* Routines from ir-functions.c */
Linus Torvalds1da177e2005-04-16 15:20:36 -070076u32 ir_extract_bits(u32 data, u32 mask);
Hermann Pitton91607232006-12-07 21:45:28 -030077void ir_rc5_timer_end(unsigned long data);
Hermann Pitton91607232006-12-07 21:45:28 -030078
Mauro Carvalho Chehabd5e52652005-11-08 21:37:32 -080079#endif