Merge branch 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[platform/kernel/linux-rpi.git] / include / media / rc-map.h
1 /*
2  * rc-map.h - define RC map names used by RC drivers
3  *
4  * Copyright (c) 2010 by Mauro Carvalho Chehab
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11
12 #include <linux/input.h>
13
14 /**
15  * enum rc_proto - the Remote Controller protocol
16  *
17  * @RC_PROTO_UNKNOWN: Protocol not known
18  * @RC_PROTO_OTHER: Protocol known but proprietary
19  * @RC_PROTO_RC5: Philips RC5 protocol
20  * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol
21  * @RC_PROTO_RC5_SZ: StreamZap variant of RC5
22  * @RC_PROTO_JVC: JVC protocol
23  * @RC_PROTO_SONY12: Sony 12 bit protocol
24  * @RC_PROTO_SONY15: Sony 15 bit protocol
25  * @RC_PROTO_SONY20: Sony 20 bit protocol
26  * @RC_PROTO_NEC: NEC protocol
27  * @RC_PROTO_NECX: Extended NEC protocol
28  * @RC_PROTO_NEC32: NEC 32 bit protocol
29  * @RC_PROTO_SANYO: Sanyo protocol
30  * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard
31  * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse
32  * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol
33  * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol
34  * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol
35  * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol
36  * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol
37  * @RC_PROTO_SHARP: Sharp protocol
38  * @RC_PROTO_XMP: XMP protocol
39  * @RC_PROTO_CEC: CEC protocol
40  */
41 enum rc_proto {
42         RC_PROTO_UNKNOWN        = 0,
43         RC_PROTO_OTHER          = 1,
44         RC_PROTO_RC5            = 2,
45         RC_PROTO_RC5X_20        = 3,
46         RC_PROTO_RC5_SZ         = 4,
47         RC_PROTO_JVC            = 5,
48         RC_PROTO_SONY12         = 6,
49         RC_PROTO_SONY15         = 7,
50         RC_PROTO_SONY20         = 8,
51         RC_PROTO_NEC            = 9,
52         RC_PROTO_NECX           = 10,
53         RC_PROTO_NEC32          = 11,
54         RC_PROTO_SANYO          = 12,
55         RC_PROTO_MCIR2_KBD      = 13,
56         RC_PROTO_MCIR2_MSE      = 14,
57         RC_PROTO_RC6_0          = 15,
58         RC_PROTO_RC6_6A_20      = 16,
59         RC_PROTO_RC6_6A_24      = 17,
60         RC_PROTO_RC6_6A_32      = 18,
61         RC_PROTO_RC6_MCE        = 19,
62         RC_PROTO_SHARP          = 20,
63         RC_PROTO_XMP            = 21,
64         RC_PROTO_CEC            = 22,
65 };
66
67 #define RC_PROTO_BIT_NONE               0ULL
68 #define RC_PROTO_BIT_UNKNOWN            BIT_ULL(RC_PROTO_UNKNOWN)
69 #define RC_PROTO_BIT_OTHER              BIT_ULL(RC_PROTO_OTHER)
70 #define RC_PROTO_BIT_RC5                BIT_ULL(RC_PROTO_RC5)
71 #define RC_PROTO_BIT_RC5X_20            BIT_ULL(RC_PROTO_RC5X_20)
72 #define RC_PROTO_BIT_RC5_SZ             BIT_ULL(RC_PROTO_RC5_SZ)
73 #define RC_PROTO_BIT_JVC                BIT_ULL(RC_PROTO_JVC)
74 #define RC_PROTO_BIT_SONY12             BIT_ULL(RC_PROTO_SONY12)
75 #define RC_PROTO_BIT_SONY15             BIT_ULL(RC_PROTO_SONY15)
76 #define RC_PROTO_BIT_SONY20             BIT_ULL(RC_PROTO_SONY20)
77 #define RC_PROTO_BIT_NEC                BIT_ULL(RC_PROTO_NEC)
78 #define RC_PROTO_BIT_NECX               BIT_ULL(RC_PROTO_NECX)
79 #define RC_PROTO_BIT_NEC32              BIT_ULL(RC_PROTO_NEC32)
80 #define RC_PROTO_BIT_SANYO              BIT_ULL(RC_PROTO_SANYO)
81 #define RC_PROTO_BIT_MCIR2_KBD          BIT_ULL(RC_PROTO_MCIR2_KBD)
82 #define RC_PROTO_BIT_MCIR2_MSE          BIT_ULL(RC_PROTO_MCIR2_MSE)
83 #define RC_PROTO_BIT_RC6_0              BIT_ULL(RC_PROTO_RC6_0)
84 #define RC_PROTO_BIT_RC6_6A_20          BIT_ULL(RC_PROTO_RC6_6A_20)
85 #define RC_PROTO_BIT_RC6_6A_24          BIT_ULL(RC_PROTO_RC6_6A_24)
86 #define RC_PROTO_BIT_RC6_6A_32          BIT_ULL(RC_PROTO_RC6_6A_32)
87 #define RC_PROTO_BIT_RC6_MCE            BIT_ULL(RC_PROTO_RC6_MCE)
88 #define RC_PROTO_BIT_SHARP              BIT_ULL(RC_PROTO_SHARP)
89 #define RC_PROTO_BIT_XMP                BIT_ULL(RC_PROTO_XMP)
90 #define RC_PROTO_BIT_CEC                BIT_ULL(RC_PROTO_CEC)
91
92 #define RC_PROTO_BIT_ALL \
93                         (RC_PROTO_BIT_UNKNOWN | RC_PROTO_BIT_OTHER | \
94                          RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
95                          RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
96                          RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
97                          RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
98                          RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
99                          RC_PROTO_BIT_SANYO | \
100                          RC_PROTO_BIT_MCIR2_KBD | RC_PROTO_BIT_MCIR2_MSE | \
101                          RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
102                          RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 | \
103                          RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
104                          RC_PROTO_BIT_XMP | RC_PROTO_BIT_CEC)
105 /* All rc protocols for which we have decoders */
106 #define RC_PROTO_BIT_ALL_IR_DECODER \
107                         (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
108                          RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
109                          RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
110                          RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
111                          RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
112                          RC_PROTO_BIT_SANYO | RC_PROTO_BIT_MCIR2_KBD | \
113                          RC_PROTO_BIT_MCIR2_MSE | \
114                          RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
115                          RC_PROTO_BIT_RC6_6A_24 |  RC_PROTO_BIT_RC6_6A_32 | \
116                          RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
117                          RC_PROTO_BIT_XMP)
118
119 #define RC_PROTO_BIT_ALL_IR_ENCODER \
120                         (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
121                          RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
122                          RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
123                          RC_PROTO_BIT_SONY20 |  RC_PROTO_BIT_NEC | \
124                          RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
125                          RC_PROTO_BIT_SANYO | RC_PROTO_BIT_MCIR2_KBD | \
126                          RC_PROTO_BIT_MCIR2_MSE | \
127                          RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
128                          RC_PROTO_BIT_RC6_6A_24 | \
129                          RC_PROTO_BIT_RC6_6A_32 | RC_PROTO_BIT_RC6_MCE | \
130                          RC_PROTO_BIT_SHARP)
131
132 #define RC_SCANCODE_UNKNOWN(x)                  (x)
133 #define RC_SCANCODE_OTHER(x)                    (x)
134 #define RC_SCANCODE_NEC(addr, cmd)              (((addr) << 8) | (cmd))
135 #define RC_SCANCODE_NECX(addr, cmd)             (((addr) << 8) | (cmd))
136 #define RC_SCANCODE_NEC32(data)                 ((data) & 0xffffffff)
137 #define RC_SCANCODE_RC5(sys, cmd)               (((sys) << 8) | (cmd))
138 #define RC_SCANCODE_RC5_SZ(sys, cmd)            (((sys) << 8) | (cmd))
139 #define RC_SCANCODE_RC6_0(sys, cmd)             (((sys) << 8) | (cmd))
140 #define RC_SCANCODE_RC6_6A(vendor, sys, cmd)    (((vendor) << 16) | ((sys) << 8) | (cmd))
141
142 /**
143  * struct rc_map_table - represents a scancode/keycode pair
144  *
145  * @scancode: scan code (u32)
146  * @keycode: Linux input keycode
147  */
148 struct rc_map_table {
149         u32     scancode;
150         u32     keycode;
151 };
152
153 /**
154  * struct rc_map - represents a keycode map table
155  *
156  * @scan: pointer to struct &rc_map_table
157  * @size: Max number of entries
158  * @len: Number of entries that are in use
159  * @alloc: size of \*scan, in bytes
160  * @rc_proto: type of the remote controller protocol, as defined at
161  *           enum &rc_proto
162  * @name: name of the key map table
163  * @lock: lock to protect access to this structure
164  */
165 struct rc_map {
166         struct rc_map_table     *scan;
167         unsigned int            size;
168         unsigned int            len;
169         unsigned int            alloc;
170         enum rc_proto           rc_proto;
171         const char              *name;
172         spinlock_t              lock;
173 };
174
175 /**
176  * struct rc_map_list - list of the registered &rc_map maps
177  *
178  * @list: pointer to struct &list_head
179  * @map: pointer to struct &rc_map
180  */
181 struct rc_map_list {
182         struct list_head         list;
183         struct rc_map map;
184 };
185
186 /* Routines from rc-map.c */
187
188 /**
189  * rc_map_register() - Registers a Remote Controler scancode map
190  *
191  * @map:        pointer to struct rc_map_list
192  */
193 int rc_map_register(struct rc_map_list *map);
194
195 /**
196  * rc_map_unregister() - Unregisters a Remote Controler scancode map
197  *
198  * @map:        pointer to struct rc_map_list
199  */
200 void rc_map_unregister(struct rc_map_list *map);
201
202 /**
203  * rc_map_get - gets an RC map from its name
204  * @name: name of the RC scancode map
205  */
206 struct rc_map *rc_map_get(const char *name);
207
208 /* Names of the several keytables defined in-kernel */
209
210 #define RC_MAP_ADSTECH_DVB_T_PCI         "rc-adstech-dvb-t-pci"
211 #define RC_MAP_ALINK_DTU_M               "rc-alink-dtu-m"
212 #define RC_MAP_ANYSEE                    "rc-anysee"
213 #define RC_MAP_APAC_VIEWCOMP             "rc-apac-viewcomp"
214 #define RC_MAP_ASUS_PC39                 "rc-asus-pc39"
215 #define RC_MAP_ASUS_PS3_100              "rc-asus-ps3-100"
216 #define RC_MAP_ATI_TV_WONDER_HD_600      "rc-ati-tv-wonder-hd-600"
217 #define RC_MAP_ATI_X10                   "rc-ati-x10"
218 #define RC_MAP_AVERMEDIA_A16D            "rc-avermedia-a16d"
219 #define RC_MAP_AVERMEDIA_CARDBUS         "rc-avermedia-cardbus"
220 #define RC_MAP_AVERMEDIA_DVBT            "rc-avermedia-dvbt"
221 #define RC_MAP_AVERMEDIA_M135A           "rc-avermedia-m135a"
222 #define RC_MAP_AVERMEDIA_M733A_RM_K6     "rc-avermedia-m733a-rm-k6"
223 #define RC_MAP_AVERMEDIA_RM_KS           "rc-avermedia-rm-ks"
224 #define RC_MAP_AVERMEDIA                 "rc-avermedia"
225 #define RC_MAP_AVERTV_303                "rc-avertv-303"
226 #define RC_MAP_AZUREWAVE_AD_TU700        "rc-azurewave-ad-tu700"
227 #define RC_MAP_BEHOLD_COLUMBUS           "rc-behold-columbus"
228 #define RC_MAP_BEHOLD                    "rc-behold"
229 #define RC_MAP_BUDGET_CI_OLD             "rc-budget-ci-old"
230 #define RC_MAP_CEC                       "rc-cec"
231 #define RC_MAP_CINERGY_1400              "rc-cinergy-1400"
232 #define RC_MAP_CINERGY                   "rc-cinergy"
233 #define RC_MAP_D680_DMB                  "rc-d680-dmb"
234 #define RC_MAP_DELOCK_61959              "rc-delock-61959"
235 #define RC_MAP_DIB0700_NEC_TABLE         "rc-dib0700-nec"
236 #define RC_MAP_DIB0700_RC5_TABLE         "rc-dib0700-rc5"
237 #define RC_MAP_DIGITALNOW_TINYTWIN       "rc-digitalnow-tinytwin"
238 #define RC_MAP_DIGITTRADE                "rc-digittrade"
239 #define RC_MAP_DM1105_NEC                "rc-dm1105-nec"
240 #define RC_MAP_DNTV_LIVE_DVBT_PRO        "rc-dntv-live-dvbt-pro"
241 #define RC_MAP_DNTV_LIVE_DVB_T           "rc-dntv-live-dvb-t"
242 #define RC_MAP_DTT200U                   "rc-dtt200u"
243 #define RC_MAP_DVBSKY                    "rc-dvbsky"
244 #define RC_MAP_DVICO_MCE                 "rc-dvico-mce"
245 #define RC_MAP_DVICO_PORTABLE            "rc-dvico-portable"
246 #define RC_MAP_EMPTY                     "rc-empty"
247 #define RC_MAP_EM_TERRATEC               "rc-em-terratec"
248 #define RC_MAP_ENCORE_ENLTV2             "rc-encore-enltv2"
249 #define RC_MAP_ENCORE_ENLTV_FM53         "rc-encore-enltv-fm53"
250 #define RC_MAP_ENCORE_ENLTV              "rc-encore-enltv"
251 #define RC_MAP_EVGA_INDTUBE              "rc-evga-indtube"
252 #define RC_MAP_EZTV                      "rc-eztv"
253 #define RC_MAP_FLYDVB                    "rc-flydvb"
254 #define RC_MAP_FLYVIDEO                  "rc-flyvideo"
255 #define RC_MAP_FUSIONHDTV_MCE            "rc-fusionhdtv-mce"
256 #define RC_MAP_GADMEI_RM008Z             "rc-gadmei-rm008z"
257 #define RC_MAP_GEEKBOX                   "rc-geekbox"
258 #define RC_MAP_GENIUS_TVGO_A11MCE        "rc-genius-tvgo-a11mce"
259 #define RC_MAP_GOTVIEW7135               "rc-gotview7135"
260 #define RC_MAP_HAUPPAUGE_NEW             "rc-hauppauge"
261 #define RC_MAP_IMON_MCE                  "rc-imon-mce"
262 #define RC_MAP_IMON_PAD                  "rc-imon-pad"
263 #define RC_MAP_IODATA_BCTV7E             "rc-iodata-bctv7e"
264 #define RC_MAP_IT913X_V1                 "rc-it913x-v1"
265 #define RC_MAP_IT913X_V2                 "rc-it913x-v2"
266 #define RC_MAP_KAIOMY                    "rc-kaiomy"
267 #define RC_MAP_KWORLD_315U               "rc-kworld-315u"
268 #define RC_MAP_KWORLD_PC150U             "rc-kworld-pc150u"
269 #define RC_MAP_KWORLD_PLUS_TV_ANALOG     "rc-kworld-plus-tv-analog"
270 #define RC_MAP_LEADTEK_Y04G0051          "rc-leadtek-y04g0051"
271 #define RC_MAP_LME2510                   "rc-lme2510"
272 #define RC_MAP_MANLI                     "rc-manli"
273 #define RC_MAP_MEDION_X10                "rc-medion-x10"
274 #define RC_MAP_MEDION_X10_DIGITAINER     "rc-medion-x10-digitainer"
275 #define RC_MAP_MEDION_X10_OR2X           "rc-medion-x10-or2x"
276 #define RC_MAP_MSI_DIGIVOX_II            "rc-msi-digivox-ii"
277 #define RC_MAP_MSI_DIGIVOX_III           "rc-msi-digivox-iii"
278 #define RC_MAP_MSI_TVANYWHERE_PLUS       "rc-msi-tvanywhere-plus"
279 #define RC_MAP_MSI_TVANYWHERE            "rc-msi-tvanywhere"
280 #define RC_MAP_NEBULA                    "rc-nebula"
281 #define RC_MAP_NEC_TERRATEC_CINERGY_XS   "rc-nec-terratec-cinergy-xs"
282 #define RC_MAP_NORWOOD                   "rc-norwood"
283 #define RC_MAP_NPGTECH                   "rc-npgtech"
284 #define RC_MAP_PCTV_SEDNA                "rc-pctv-sedna"
285 #define RC_MAP_PINNACLE_COLOR            "rc-pinnacle-color"
286 #define RC_MAP_PINNACLE_GREY             "rc-pinnacle-grey"
287 #define RC_MAP_PINNACLE_PCTV_HD          "rc-pinnacle-pctv-hd"
288 #define RC_MAP_PIXELVIEW_NEW             "rc-pixelview-new"
289 #define RC_MAP_PIXELVIEW                 "rc-pixelview"
290 #define RC_MAP_PIXELVIEW_002T            "rc-pixelview-002t"
291 #define RC_MAP_PIXELVIEW_MK12            "rc-pixelview-mk12"
292 #define RC_MAP_POWERCOLOR_REAL_ANGEL     "rc-powercolor-real-angel"
293 #define RC_MAP_PROTEUS_2309              "rc-proteus-2309"
294 #define RC_MAP_PURPLETV                  "rc-purpletv"
295 #define RC_MAP_PV951                     "rc-pv951"
296 #define RC_MAP_HAUPPAUGE                 "rc-hauppauge"
297 #define RC_MAP_RC5_TV                    "rc-rc5-tv"
298 #define RC_MAP_RC6_MCE                   "rc-rc6-mce"
299 #define RC_MAP_REAL_AUDIO_220_32_KEYS    "rc-real-audio-220-32-keys"
300 #define RC_MAP_REDDO                     "rc-reddo"
301 #define RC_MAP_SNAPSTREAM_FIREFLY        "rc-snapstream-firefly"
302 #define RC_MAP_STREAMZAP                 "rc-streamzap"
303 #define RC_MAP_TBS_NEC                   "rc-tbs-nec"
304 #define RC_MAP_TECHNISAT_TS35            "rc-technisat-ts35"
305 #define RC_MAP_TECHNISAT_USB2            "rc-technisat-usb2"
306 #define RC_MAP_TERRATEC_CINERGY_C_PCI    "rc-terratec-cinergy-c-pci"
307 #define RC_MAP_TERRATEC_CINERGY_S2_HD    "rc-terratec-cinergy-s2-hd"
308 #define RC_MAP_TERRATEC_CINERGY_XS       "rc-terratec-cinergy-xs"
309 #define RC_MAP_TERRATEC_SLIM             "rc-terratec-slim"
310 #define RC_MAP_TERRATEC_SLIM_2           "rc-terratec-slim-2"
311 #define RC_MAP_TEVII_NEC                 "rc-tevii-nec"
312 #define RC_MAP_TIVO                      "rc-tivo"
313 #define RC_MAP_TOTAL_MEDIA_IN_HAND       "rc-total-media-in-hand"
314 #define RC_MAP_TOTAL_MEDIA_IN_HAND_02    "rc-total-media-in-hand-02"
315 #define RC_MAP_TREKSTOR                  "rc-trekstor"
316 #define RC_MAP_TT_1500                   "rc-tt-1500"
317 #define RC_MAP_TWINHAN_DTV_CAB_CI        "rc-twinhan-dtv-cab-ci"
318 #define RC_MAP_TWINHAN_VP1027_DVBS       "rc-twinhan1027"
319 #define RC_MAP_VIDEOMATE_K100            "rc-videomate-k100"
320 #define RC_MAP_VIDEOMATE_S350            "rc-videomate-s350"
321 #define RC_MAP_VIDEOMATE_TV_PVR          "rc-videomate-tv-pvr"
322 #define RC_MAP_WINFAST                   "rc-winfast"
323 #define RC_MAP_WINFAST_USBII_DELUXE      "rc-winfast-usbii-deluxe"
324 #define RC_MAP_SU3000                    "rc-su3000"
325 #define RC_MAP_ZX_IRDEC                  "rc-zx-irdec"
326
327 /*
328  * Please, do not just append newer Remote Controller names at the end.
329  * The names should be ordered in alphabetical order
330  */