1 // SPDX-License-Identifier: GPL-2.0+
2 // rc-hauppauge.c - Keytable for Hauppauge Remote Controllers
3 //
4 // keymap imported from ir-keymaps.c
5 //
6 // This map currently contains the code for four different RCs:
7 //	- New Hauppauge Gray;
8 //	- Old Hauppauge Gray (with a golden screen for media keys);
9 //	- Hauppauge Black;
10 //	- DSR-0112 remote bundled with Haupauge MiniStick.
11 //
12 // Copyright (c) 2010-2011 by Mauro Carvalho Chehab
13 
14 #include <media/rc-map.h>
15 #include <linux/module.h>
16 
17 /*
18  * Hauppauge:the newer, gray remotes (seems there are multiple
19  * slightly different versions), shipped with cx88+ivtv cards.
20  *
21  * This table contains the complete RC5 code, instead of just the data part
22  */
23 
24 static struct rc_map_table rc5_hauppauge_new[] = {
25 	/*
26 	 * Remote Controller Hauppauge Gray found on modern devices
27 	 * Keycodes start with address = 0x1e
28 	 */
29 
30 	{ 0x1e3b, KEY_SELECT },		/* GO / house symbol */
31 	{ 0x1e3d, KEY_POWER2 },		/* system power (green button) */
32 
33 	{ 0x1e1c, KEY_TV },
34 	{ 0x1e18, KEY_VIDEO },		/* Videos */
35 	{ 0x1e19, KEY_AUDIO },		/* Music */
36 	{ 0x1e1a, KEY_CAMERA },		/* Pictures */
37 
38 	{ 0x1e1b, KEY_EPG },		/* Guide */
39 	{ 0x1e0c, KEY_RADIO },
40 
41 	{ 0x1e14, KEY_UP },
42 	{ 0x1e15, KEY_DOWN },
43 	{ 0x1e16, KEY_LEFT },
44 	{ 0x1e17, KEY_RIGHT },
45 	{ 0x1e25, KEY_OK },		/* OK */
46 
47 	{ 0x1e1f, KEY_EXIT },		/* back/exit */
48 	{ 0x1e0d, KEY_MENU },
49 
50 	{ 0x1e10, KEY_VOLUMEUP },
51 	{ 0x1e11, KEY_VOLUMEDOWN },
52 
53 	{ 0x1e12, KEY_PREVIOUS },	/* previous channel */
54 	{ 0x1e0f, KEY_MUTE },
55 
56 	{ 0x1e20, KEY_CHANNELUP },	/* channel / program + */
57 	{ 0x1e21, KEY_CHANNELDOWN },	/* channel / program - */
58 
59 	{ 0x1e37, KEY_RECORD },		/* recording */
60 	{ 0x1e36, KEY_STOP },
61 
62 	{ 0x1e32, KEY_REWIND },		/* backward << */
63 	{ 0x1e35, KEY_PLAY },
64 	{ 0x1e34, KEY_FASTFORWARD },	/* forward >> */
65 
66 	{ 0x1e24, KEY_PREVIOUSSONG },	/* replay |< */
67 	{ 0x1e30, KEY_PAUSE },		/* pause */
68 	{ 0x1e1e, KEY_NEXTSONG },	/* skip >| */
69 
70 	{ 0x1e01, KEY_1 },
71 	{ 0x1e02, KEY_2 },
72 	{ 0x1e03, KEY_3 },
73 
74 	{ 0x1e04, KEY_4 },
75 	{ 0x1e05, KEY_5 },
76 	{ 0x1e06, KEY_6 },
77 
78 	{ 0x1e07, KEY_7 },
79 	{ 0x1e08, KEY_8 },
80 	{ 0x1e09, KEY_9 },
81 
82 	{ 0x1e0a, KEY_TEXT },		/* keypad asterisk as well */
83 	{ 0x1e00, KEY_0 },
84 	{ 0x1e0e, KEY_SUBTITLE },	/* also the Pound key (#) */
85 
86 	{ 0x1e0b, KEY_RED },		/* red button */
87 	{ 0x1e2e, KEY_GREEN },		/* green button */
88 	{ 0x1e38, KEY_YELLOW },		/* yellow key */
89 	{ 0x1e29, KEY_BLUE },		/* blue key */
90 
91 	/*
92 	 * Old Remote Controller Hauppauge Gray with a golden screen
93 	 * Keycodes start with address = 0x1f
94 	 */
95 	{ 0x1f3d, KEY_POWER2 },		/* system power (green button) */
96 	{ 0x1f3b, KEY_SELECT },		/* GO */
97 
98 	/* Keys 0 to 9 */
99 	{ 0x1f00, KEY_0 },
100 	{ 0x1f01, KEY_1 },
101 	{ 0x1f02, KEY_2 },
102 	{ 0x1f03, KEY_3 },
103 	{ 0x1f04, KEY_4 },
104 	{ 0x1f05, KEY_5 },
105 	{ 0x1f06, KEY_6 },
106 	{ 0x1f07, KEY_7 },
107 	{ 0x1f08, KEY_8 },
108 	{ 0x1f09, KEY_9 },
109 
110 	{ 0x1f1f, KEY_EXIT },		/* back/exit */
111 	{ 0x1f0d, KEY_MENU },
112 
113 	{ 0x1f10, KEY_VOLUMEUP },
114 	{ 0x1f11, KEY_VOLUMEDOWN },
115 	{ 0x1f20, KEY_CHANNELUP },	/* channel / program + */
116 	{ 0x1f21, KEY_CHANNELDOWN },	/* channel / program - */
117 	{ 0x1f25, KEY_ENTER },		/* OK */
118 
119 	{ 0x1f0b, KEY_RED },		/* red button */
120 	{ 0x1f2e, KEY_GREEN },		/* green button */
121 	{ 0x1f38, KEY_YELLOW },		/* yellow key */
122 	{ 0x1f29, KEY_BLUE },		/* blue key */
123 
124 	{ 0x1f0f, KEY_MUTE },
125 	{ 0x1f0c, KEY_RADIO },		/* There's no indicator on this key */
126 	{ 0x1f3c, KEY_ZOOM },		/* full */
127 
128 	{ 0x1f32, KEY_REWIND },		/* backward << */
129 	{ 0x1f35, KEY_PLAY },
130 	{ 0x1f34, KEY_FASTFORWARD },	/* forward >> */
131 
132 	{ 0x1f37, KEY_RECORD },		/* recording */
133 	{ 0x1f36, KEY_STOP },
134 	{ 0x1f30, KEY_PAUSE },		/* pause */
135 
136 	{ 0x1f24, KEY_PREVIOUSSONG },	/* replay |< */
137 	{ 0x1f1e, KEY_NEXTSONG },	/* skip >| */
138 
139 	/*
140 	 * Keycodes for DSR-0112 remote bundled with Haupauge MiniStick
141 	 * Keycodes start with address = 0x1d
142 	 */
143 	{ 0x1d00, KEY_0 },
144 	{ 0x1d01, KEY_1 },
145 	{ 0x1d02, KEY_2 },
146 	{ 0x1d03, KEY_3 },
147 	{ 0x1d04, KEY_4 },
148 	{ 0x1d05, KEY_5 },
149 	{ 0x1d06, KEY_6 },
150 	{ 0x1d07, KEY_7 },
151 	{ 0x1d08, KEY_8 },
152 	{ 0x1d09, KEY_9 },
153 	{ 0x1d0a, KEY_TEXT },
154 	{ 0x1d0d, KEY_MENU },
155 	{ 0x1d0f, KEY_MUTE },
156 	{ 0x1d10, KEY_VOLUMEUP },
157 	{ 0x1d11, KEY_VOLUMEDOWN },
158 	{ 0x1d12, KEY_PREVIOUS },        /* Prev.Ch .. ??? */
159 	{ 0x1d14, KEY_UP },
160 	{ 0x1d15, KEY_DOWN },
161 	{ 0x1d16, KEY_LEFT },
162 	{ 0x1d17, KEY_RIGHT },
163 	{ 0x1d1c, KEY_TV },
164 	{ 0x1d1e, KEY_NEXT },           /* >|             */
165 	{ 0x1d1f, KEY_EXIT },
166 	{ 0x1d20, KEY_CHANNELUP },
167 	{ 0x1d21, KEY_CHANNELDOWN },
168 	{ 0x1d24, KEY_LAST },           /* <|             */
169 	{ 0x1d25, KEY_OK },
170 	{ 0x1d30, KEY_PAUSE },
171 	{ 0x1d32, KEY_REWIND },
172 	{ 0x1d34, KEY_FASTFORWARD },
173 	{ 0x1d35, KEY_PLAY },
174 	{ 0x1d36, KEY_STOP },
175 	{ 0x1d37, KEY_RECORD },
176 	{ 0x1d3b, KEY_GOTO },
177 	{ 0x1d3d, KEY_POWER },
178 	{ 0x1d3f, KEY_HOME },
179 
180 	/*
181 	 * Keycodes for PT# R-005 remote bundled with Haupauge HVR-930C
182 	 * Keycodes start with address = 0x1c
183 	 */
184 	{ 0x1c3b, KEY_GOTO },
185 	{ 0x1c3d, KEY_POWER },
186 
187 	{ 0x1c14, KEY_UP },
188 	{ 0x1c15, KEY_DOWN },
189 	{ 0x1c16, KEY_LEFT },
190 	{ 0x1c17, KEY_RIGHT },
191 	{ 0x1c25, KEY_OK },
192 
193 	{ 0x1c00, KEY_0 },
194 	{ 0x1c01, KEY_1 },
195 	{ 0x1c02, KEY_2 },
196 	{ 0x1c03, KEY_3 },
197 	{ 0x1c04, KEY_4 },
198 	{ 0x1c05, KEY_5 },
199 	{ 0x1c06, KEY_6 },
200 	{ 0x1c07, KEY_7 },
201 	{ 0x1c08, KEY_8 },
202 	{ 0x1c09, KEY_9 },
203 
204 	{ 0x1c1f, KEY_EXIT },	/* BACK */
205 	{ 0x1c0d, KEY_MENU },
206 	{ 0x1c1c, KEY_TV },
207 
208 	{ 0x1c10, KEY_VOLUMEUP },
209 	{ 0x1c11, KEY_VOLUMEDOWN },
210 
211 	{ 0x1c20, KEY_CHANNELUP },
212 	{ 0x1c21, KEY_CHANNELDOWN },
213 
214 	{ 0x1c0f, KEY_MUTE },
215 	{ 0x1c12, KEY_PREVIOUS }, /* Prev */
216 
217 	{ 0x1c36, KEY_STOP },
218 	{ 0x1c37, KEY_RECORD },
219 
220 	{ 0x1c24, KEY_LAST },           /* <|             */
221 	{ 0x1c1e, KEY_NEXT },           /* >|             */
222 
223 	{ 0x1c0a, KEY_TEXT },
224 	{ 0x1c0e, KEY_SUBTITLE },	/* CC */
225 
226 	{ 0x1c32, KEY_REWIND },
227 	{ 0x1c30, KEY_PAUSE },
228 	{ 0x1c35, KEY_PLAY },
229 	{ 0x1c34, KEY_FASTFORWARD },
230 
231 	/*
232 	 * Keycodes for the old Black Remote Controller
233 	 * This one also uses RC-5 protocol
234 	 * Keycodes start with address = 0x00
235 	 */
236 	{ 0x001f, KEY_TV },
237 	{ 0x0020, KEY_CHANNELUP },
238 	{ 0x000c, KEY_RADIO },
239 
240 	{ 0x0011, KEY_VOLUMEDOWN },
241 	{ 0x002e, KEY_ZOOM },		/* full screen */
242 	{ 0x0010, KEY_VOLUMEUP },
243 
244 	{ 0x000d, KEY_MUTE },
245 	{ 0x0021, KEY_CHANNELDOWN },
246 	{ 0x0022, KEY_VIDEO },		/* source */
247 
248 	{ 0x0001, KEY_1 },
249 	{ 0x0002, KEY_2 },
250 	{ 0x0003, KEY_3 },
251 
252 	{ 0x0004, KEY_4 },
253 	{ 0x0005, KEY_5 },
254 	{ 0x0006, KEY_6 },
255 
256 	{ 0x0007, KEY_7 },
257 	{ 0x0008, KEY_8 },
258 	{ 0x0009, KEY_9 },
259 
260 	{ 0x001e, KEY_RED },	/* Reserved */
261 	{ 0x0000, KEY_0 },
262 	{ 0x0026, KEY_SLEEP },	/* Minimize */
263 };
264 
265 static struct rc_map_list rc5_hauppauge_new_map = {
266 	.map = {
267 		.scan     = rc5_hauppauge_new,
268 		.size     = ARRAY_SIZE(rc5_hauppauge_new),
269 		.rc_proto = RC_PROTO_RC5,
270 		.name     = RC_MAP_HAUPPAUGE,
271 	}
272 };
273 
init_rc_map_rc5_hauppauge_new(void)274 static int __init init_rc_map_rc5_hauppauge_new(void)
275 {
276 	return rc_map_register(&rc5_hauppauge_new_map);
277 }
278 
exit_rc_map_rc5_hauppauge_new(void)279 static void __exit exit_rc_map_rc5_hauppauge_new(void)
280 {
281 	rc_map_unregister(&rc5_hauppauge_new_map);
282 }
283 
284 module_init(init_rc_map_rc5_hauppauge_new)
285 module_exit(exit_rc_map_rc5_hauppauge_new)
286 
287 MODULE_LICENSE("GPL");
288 MODULE_AUTHOR("Mauro Carvalho Chehab");
289