diff options
Diffstat (limited to 'drivers/media/pci/bt8xx/bttv-input.c')
-rw-r--r-- | drivers/media/pci/bt8xx/bttv-input.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c index 5930bce16658..67c8d6b2c335 100644 --- a/drivers/media/pci/bt8xx/bttv-input.c +++ b/drivers/media/pci/bt8xx/bttv-input.c | |||
@@ -73,12 +73,12 @@ static void ir_handle_key(struct bttv *btv) | |||
73 | 73 | ||
74 | if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || | 74 | if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || |
75 | (ir->mask_keyup && !(gpio & ir->mask_keyup))) { | 75 | (ir->mask_keyup && !(gpio & ir->mask_keyup))) { |
76 | rc_keydown_notimeout(ir->dev, data, 0); | 76 | rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); |
77 | } else { | 77 | } else { |
78 | /* HACK: Probably, ir->mask_keydown is missing | 78 | /* HACK: Probably, ir->mask_keydown is missing |
79 | for this board */ | 79 | for this board */ |
80 | if (btv->c.type == BTTV_BOARD_WINFAST2000) | 80 | if (btv->c.type == BTTV_BOARD_WINFAST2000) |
81 | rc_keydown_notimeout(ir->dev, data, 0); | 81 | rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); |
82 | 82 | ||
83 | rc_keyup(ir->dev); | 83 | rc_keyup(ir->dev); |
84 | } | 84 | } |
@@ -103,7 +103,7 @@ static void ir_enltv_handle_key(struct bttv *btv) | |||
103 | gpio, data, | 103 | gpio, data, |
104 | (gpio & ir->mask_keyup) ? " up" : "up/down"); | 104 | (gpio & ir->mask_keyup) ? " up" : "up/down"); |
105 | 105 | ||
106 | rc_keydown_notimeout(ir->dev, data, 0); | 106 | rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); |
107 | if (keyup) | 107 | if (keyup) |
108 | rc_keyup(ir->dev); | 108 | rc_keyup(ir->dev); |
109 | } else { | 109 | } else { |
@@ -117,7 +117,7 @@ static void ir_enltv_handle_key(struct bttv *btv) | |||
117 | if (keyup) | 117 | if (keyup) |
118 | rc_keyup(ir->dev); | 118 | rc_keyup(ir->dev); |
119 | else | 119 | else |
120 | rc_keydown_notimeout(ir->dev, data, 0); | 120 | rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); |
121 | } | 121 | } |
122 | 122 | ||
123 | ir->last_gpio = data | keyup; | 123 | ir->last_gpio = data | keyup; |
@@ -154,10 +154,10 @@ static void bttv_input_timer(unsigned long data) | |||
154 | * testing. | 154 | * testing. |
155 | */ | 155 | */ |
156 | 156 | ||
157 | #define RC5_START(x) (((x) >> 12) & 3) | 157 | #define RC5_START(x) (((x) >> 12) & 0x03) |
158 | #define RC5_TOGGLE(x) (((x) >> 11) & 1) | 158 | #define RC5_TOGGLE(x) (((x) >> 11) & 0x01) |
159 | #define RC5_ADDR(x) (((x) >> 6) & 31) | 159 | #define RC5_ADDR(x) (((x) >> 6) & 0x1f) |
160 | #define RC5_INSTR(x) ((x) & 63) | 160 | #define RC5_INSTR(x) (((x) >> 0) & 0x3f) |
161 | 161 | ||
162 | /* decode raw bit pattern to RC5 code */ | 162 | /* decode raw bit pattern to RC5 code */ |
163 | static u32 bttv_rc5_decode(unsigned int code) | 163 | static u32 bttv_rc5_decode(unsigned int code) |
@@ -195,8 +195,8 @@ static void bttv_rc5_timer_end(unsigned long data) | |||
195 | { | 195 | { |
196 | struct bttv_ir *ir = (struct bttv_ir *)data; | 196 | struct bttv_ir *ir = (struct bttv_ir *)data; |
197 | struct timeval tv; | 197 | struct timeval tv; |
198 | u32 gap; | 198 | u32 gap, rc5, scancode; |
199 | u32 rc5 = 0; | 199 | u8 toggle, command, system; |
200 | 200 | ||
201 | /* get time */ | 201 | /* get time */ |
202 | do_gettimeofday(&tv); | 202 | do_gettimeofday(&tv); |
@@ -221,26 +221,29 @@ static void bttv_rc5_timer_end(unsigned long data) | |||
221 | if (ir->last_bit < 20) { | 221 | if (ir->last_bit < 20) { |
222 | /* ignore spurious codes (caused by light/other remotes) */ | 222 | /* ignore spurious codes (caused by light/other remotes) */ |
223 | dprintk("short code: %x\n", ir->code); | 223 | dprintk("short code: %x\n", ir->code); |
224 | } else { | 224 | return; |
225 | ir->code = (ir->code << ir->shift_by) | 1; | ||
226 | rc5 = bttv_rc5_decode(ir->code); | ||
227 | |||
228 | /* two start bits? */ | ||
229 | if (RC5_START(rc5) != ir->start) { | ||
230 | pr_info(DEVNAME ":" | ||
231 | " rc5 start bits invalid: %u\n", RC5_START(rc5)); | ||
232 | |||
233 | /* right address? */ | ||
234 | } else if (RC5_ADDR(rc5) == ir->addr) { | ||
235 | u32 toggle = RC5_TOGGLE(rc5); | ||
236 | u32 instr = RC5_INSTR(rc5); | ||
237 | |||
238 | /* Good code */ | ||
239 | rc_keydown(ir->dev, instr, toggle); | ||
240 | dprintk("instruction %x, toggle %x\n", | ||
241 | instr, toggle); | ||
242 | } | ||
243 | } | 225 | } |
226 | |||
227 | ir->code = (ir->code << ir->shift_by) | 1; | ||
228 | rc5 = bttv_rc5_decode(ir->code); | ||
229 | |||
230 | toggle = RC5_TOGGLE(rc5); | ||
231 | system = RC5_ADDR(rc5); | ||
232 | command = RC5_INSTR(rc5); | ||
233 | |||
234 | switch (RC5_START(rc5)) { | ||
235 | case 0x3: | ||
236 | break; | ||
237 | case 0x2: | ||
238 | command += 0x40; | ||
239 | break; | ||
240 | default: | ||
241 | return; | ||
242 | } | ||
243 | |||
244 | scancode = RC_SCANCODE_RC5(system, command); | ||
245 | rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle); | ||
246 | dprintk("scancode %x, toggle %x\n", scancode, toggle); | ||
244 | } | 247 | } |
245 | 248 | ||
246 | static int bttv_rc5_irq(struct bttv *btv) | 249 | static int bttv_rc5_irq(struct bttv *btv) |
@@ -310,8 +313,6 @@ static void bttv_ir_start(struct bttv *btv, struct bttv_ir *ir) | |||
310 | /* set timer_end for code completion */ | 313 | /* set timer_end for code completion */ |
311 | setup_timer(&ir->timer, bttv_rc5_timer_end, (unsigned long)ir); | 314 | setup_timer(&ir->timer, bttv_rc5_timer_end, (unsigned long)ir); |
312 | ir->shift_by = 1; | 315 | ir->shift_by = 1; |
313 | ir->start = 3; | ||
314 | ir->addr = 0x0; | ||
315 | ir->rc5_remote_gap = ir_rc5_remote_gap; | 316 | ir->rc5_remote_gap = ir_rc5_remote_gap; |
316 | } | 317 | } |
317 | } | 318 | } |
@@ -335,7 +336,8 @@ static void bttv_ir_stop(struct bttv *btv) | |||
335 | * Get_key functions used by I2C remotes | 336 | * Get_key functions used by I2C remotes |
336 | */ | 337 | */ |
337 | 338 | ||
338 | static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | 339 | static int get_key_pv951(struct IR_i2c *ir, enum rc_type *protocol, |
340 | u32 *scancode, u8 *toggle) | ||
339 | { | 341 | { |
340 | unsigned char b; | 342 | unsigned char b; |
341 | 343 | ||
@@ -362,8 +364,9 @@ static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
362 | * the device is bound to the vendor-provided RC. | 364 | * the device is bound to the vendor-provided RC. |
363 | */ | 365 | */ |
364 | 366 | ||
365 | *ir_key = b; | 367 | *protocol = RC_TYPE_UNKNOWN; |
366 | *ir_raw = b; | 368 | *scancode = b; |
369 | *toggle = 0; | ||
367 | return 1; | 370 | return 1; |
368 | } | 371 | } |
369 | 372 | ||
@@ -490,8 +493,8 @@ int bttv_input_init(struct bttv *btv) | |||
490 | ir->polling = 50; // ms | 493 | ir->polling = 50; // ms |
491 | break; | 494 | break; |
492 | case BTTV_BOARD_NEBULA_DIGITV: | 495 | case BTTV_BOARD_NEBULA_DIGITV: |
493 | ir_codes = RC_MAP_NEBULA; | 496 | ir_codes = RC_MAP_NEBULA; |
494 | ir->rc5_gpio = true; | 497 | ir->rc5_gpio = true; |
495 | break; | 498 | break; |
496 | case BTTV_BOARD_MACHTV_MAGICTV: | 499 | case BTTV_BOARD_MACHTV_MAGICTV: |
497 | ir_codes = RC_MAP_APAC_VIEWCOMP; | 500 | ir_codes = RC_MAP_APAC_VIEWCOMP; |
@@ -514,7 +517,8 @@ int bttv_input_init(struct bttv *btv) | |||
514 | ir->mask_keycode); | 517 | ir->mask_keycode); |
515 | break; | 518 | break; |
516 | } | 519 | } |
517 | if (NULL == ir_codes) { | 520 | |
521 | if (!ir_codes) { | ||
518 | dprintk("Ooops: IR config error [card=%d]\n", btv->c.type); | 522 | dprintk("Ooops: IR config error [card=%d]\n", btv->c.type); |
519 | err = -ENODEV; | 523 | err = -ENODEV; |
520 | goto err_out_free; | 524 | goto err_out_free; |