aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ir-kbd-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r--drivers/media/video/ir-kbd-i2c.c202
1 files changed, 16 insertions, 186 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 0cd1fc89b2d0..bdb3ba551360 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -82,104 +82,6 @@ static IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE] = {
82 [ 28 ] = KEY_MEDIA, /* PC/TV */ 82 [ 28 ] = KEY_MEDIA, /* PC/TV */
83}; 83};
84 84
85static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
86 [ 0x3 ] = KEY_POWER,
87 [ 0x6f ] = KEY_MUTE,
88 [ 0x10 ] = KEY_BACKSPACE, /* Recall */
89
90 [ 0x11 ] = KEY_KP0,
91 [ 0x4 ] = KEY_KP1,
92 [ 0x5 ] = KEY_KP2,
93 [ 0x6 ] = KEY_KP3,
94 [ 0x8 ] = KEY_KP4,
95 [ 0x9 ] = KEY_KP5,
96 [ 0xa ] = KEY_KP6,
97 [ 0xc ] = KEY_KP7,
98 [ 0xd ] = KEY_KP8,
99 [ 0xe ] = KEY_KP9,
100 [ 0x12 ] = KEY_KPDOT, /* 100+ */
101
102 [ 0x7 ] = KEY_VOLUMEUP,
103 [ 0xb ] = KEY_VOLUMEDOWN,
104 [ 0x1a ] = KEY_KPPLUS,
105 [ 0x18 ] = KEY_KPMINUS,
106 [ 0x15 ] = KEY_UP,
107 [ 0x1d ] = KEY_DOWN,
108 [ 0xf ] = KEY_CHANNELUP,
109 [ 0x13 ] = KEY_CHANNELDOWN,
110 [ 0x48 ] = KEY_ZOOM,
111
112 [ 0x1b ] = KEY_VIDEO, /* Video source */
113 [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */
114 [ 0x19 ] = KEY_SEARCH, /* Auto Scan */
115
116 [ 0x4b ] = KEY_RECORD,
117 [ 0x46 ] = KEY_PLAY,
118 [ 0x45 ] = KEY_PAUSE, /* Pause */
119 [ 0x44 ] = KEY_STOP,
120 [ 0x40 ] = KEY_FORWARD, /* Forward ? */
121 [ 0x42 ] = KEY_REWIND, /* Backward ? */
122
123};
124
125static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
126 [ 0x59 ] = KEY_MUTE,
127 [ 0x4a ] = KEY_POWER,
128
129 [ 0x18 ] = KEY_TEXT,
130 [ 0x26 ] = KEY_TV,
131 [ 0x3d ] = KEY_PRINT,
132
133 [ 0x48 ] = KEY_RED,
134 [ 0x04 ] = KEY_GREEN,
135 [ 0x11 ] = KEY_YELLOW,
136 [ 0x00 ] = KEY_BLUE,
137
138 [ 0x2d ] = KEY_VOLUMEUP,
139 [ 0x1e ] = KEY_VOLUMEDOWN,
140
141 [ 0x49 ] = KEY_MENU,
142
143 [ 0x16 ] = KEY_CHANNELUP,
144 [ 0x17 ] = KEY_CHANNELDOWN,
145
146 [ 0x20 ] = KEY_UP,
147 [ 0x21 ] = KEY_DOWN,
148 [ 0x22 ] = KEY_LEFT,
149 [ 0x23 ] = KEY_RIGHT,
150 [ 0x0d ] = KEY_SELECT,
151
152
153
154 [ 0x08 ] = KEY_BACK,
155 [ 0x07 ] = KEY_REFRESH,
156
157 [ 0x2f ] = KEY_ZOOM,
158 [ 0x29 ] = KEY_RECORD,
159
160 [ 0x4b ] = KEY_PAUSE,
161 [ 0x4d ] = KEY_REWIND,
162 [ 0x2e ] = KEY_PLAY,
163 [ 0x4e ] = KEY_FORWARD,
164 [ 0x53 ] = KEY_PREVIOUS,
165 [ 0x4c ] = KEY_STOP,
166 [ 0x54 ] = KEY_NEXT,
167
168 [ 0x69 ] = KEY_KP0,
169 [ 0x6a ] = KEY_KP1,
170 [ 0x6b ] = KEY_KP2,
171 [ 0x6c ] = KEY_KP3,
172 [ 0x6d ] = KEY_KP4,
173 [ 0x6e ] = KEY_KP5,
174 [ 0x6f ] = KEY_KP6,
175 [ 0x70 ] = KEY_KP7,
176 [ 0x71 ] = KEY_KP8,
177 [ 0x72 ] = KEY_KP9,
178
179 [ 0x74 ] = KEY_CHANNEL,
180 [ 0x0a ] = KEY_BACKSPACE,
181};
182
183/* ----------------------------------------------------------------------- */ 85/* ----------------------------------------------------------------------- */
184/* insmod parameters */ 86/* insmod parameters */
185 87
@@ -281,80 +183,6 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
281 return 1; 183 return 1;
282} 184}
283 185
284static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
285{
286 unsigned char b;
287
288 /* poll IR chip */
289 if (1 != i2c_master_recv(&ir->c,&b,1)) {
290 dprintk(1,"read error\n");
291 return -EIO;
292 }
293
294 /* no button press */
295 if (b==0)
296 return 0;
297
298 /* repeating */
299 if (b & 0x80)
300 return 1;
301
302 *ir_key = b;
303 *ir_raw = b;
304 return 1;
305}
306
307/* The new pinnacle PCTV remote (with the colored buttons)
308 *
309 * Ricardo Cerqueira <v4l@cerqueira.org>
310 */
311
312static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
313{
314 unsigned char b[4];
315 unsigned int start = 0,parity = 0,code = 0;
316
317 /* poll IR chip */
318 if (4 != i2c_master_recv(&ir->c,b,4)) {
319 dprintk(1,"read error\n");
320 return -EIO;
321 }
322
323 for (start = 0; start<4; start++) {
324 if (b[start] == 0x80) {
325 code=b[(start+3)%4];
326 parity=b[(start+2)%4];
327 }
328 }
329
330 /* Empty Request */
331 if (parity==0)
332 return 0;
333
334 /* Repeating... */
335 if (ir->old == parity)
336 return 0;
337
338
339 ir->old = parity;
340
341 /* Reduce code value to fit inside IR_KEYTAB_SIZE
342 *
343 * this is the only value that results in 42 unique
344 * codes < 128
345 */
346
347 code %= 0x88;
348
349 *ir_raw = code;
350 *ir_key = code;
351
352 dprintk(1,"Pinnacle PCTV key %02x\n", code);
353
354 return 1;
355}
356
357
358/* ----------------------------------------------------------------------- */ 186/* ----------------------------------------------------------------------- */
359 187
360static void ir_key_poll(struct IR_i2c *ir) 188static void ir_key_poll(struct IR_i2c *ir)
@@ -460,19 +288,12 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
460 ir_type = IR_TYPE_OTHER; 288 ir_type = IR_TYPE_OTHER;
461 ir_codes = ir_codes_empty; 289 ir_codes = ir_codes_empty;
462 break; 290 break;
463 case 0x47:
464 name = "Pinnacle PCTV";
465 ir->get_key = get_key_pinnacle;
466 ir_type = IR_TYPE_OTHER;
467 ir_codes = ir_codes_pinnacle;
468 break;
469 case 0x7a: 291 case 0x7a:
470 name = "Purple TV"; 292 case 0x47:
471 ir->get_key = get_key_purpletv; 293 /* Handled by saa7134-input */
294 name = "SAA713x remote";
472 ir_type = IR_TYPE_OTHER; 295 ir_type = IR_TYPE_OTHER;
473 ir_codes = ir_codes_purpletv;
474 break; 296 break;
475
476 default: 297 default:
477 /* shouldn't happen */ 298 /* shouldn't happen */
478 printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n",addr); 299 printk(DEVNAME ": Huh? unknown i2c address (0x%02x)?\n",addr);
@@ -480,11 +301,8 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
480 return -1; 301 return -1;
481 } 302 }
482 303
483 /* Sets name and its physical addr */ 304 /* Sets name */
484 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name); 305 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (%s)", name);
485 snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0",
486 ir->c.adapter->dev.bus_id,
487 ir->c.dev.bus_id);
488 ir->ir_codes=ir_codes; 306 ir->ir_codes=ir_codes;
489 307
490 /* register i2c device 308 /* register i2c device
@@ -493,6 +311,18 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
493 */ 311 */
494 i2c_attach_client(&ir->c); 312 i2c_attach_client(&ir->c);
495 313
314 /* If IR not supported or disabled, unregisters driver */
315 if (ir->get_key == NULL) {
316 i2c_detach_client(&ir->c);
317 kfree(ir);
318 return -1;
319 }
320
321 /* Phys addr can only be set after attaching (for ir->c.dev.bus_id) */
322 snprintf(ir->phys, sizeof(ir->phys), "%s/%s/ir0",
323 ir->c.adapter->dev.bus_id,
324 ir->c.dev.bus_id);
325
496 /* init + register input device */ 326 /* init + register input device */
497 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes); 327 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
498 input_dev->id.bustype = BUS_I2C; 328 input_dev->id.bustype = BUS_I2C;