Lines Matching +full:button +full:-
1 // SPDX-License-Identifier: GPL-2.0+
33 dev_printk(KERN_DEBUG, &ir->dev->intf->dev, \
69 * I2C IR based get keycodes - should be used with ir-kbd-i2c
83 return -EIO; in em28xx_get_key_terratec()
87 * it seems that 0xFE indicates that a button is still hold in em28xx_get_key_terratec()
88 * down, while 0xff indicates that no button is hold down. in em28xx_get_key_terratec()
113 return -EIO; in em28xx_get_key_em_haup()
142 return -EIO; in em28xx_get_key_pinnacle_usb_grey()
160 .addr = i2c_dev->addr, in em28xx_get_key_winfast_usbii_deluxe()
164 .addr = i2c_dev->addr, in em28xx_get_key_winfast_usbii_deluxe()
172 if (i2c_transfer(i2c_dev->adapter, msg, 2) != 2) in em28xx_get_key_winfast_usbii_deluxe()
173 return -EIO; in em28xx_get_key_winfast_usbii_deluxe()
179 if (i2c_transfer(i2c_dev->adapter, msg, 2) != 2) in em28xx_get_key_winfast_usbii_deluxe()
180 return -EIO; in em28xx_get_key_winfast_usbii_deluxe()
197 struct em28xx *dev = ir->dev; in default_polling_getkey()
205 rc = dev->em28xx_read_reg_req_len(dev, 0, EM28XX_R45_IR, in default_polling_getkey()
211 poll_result->toggle_bit = (msg[0] >> 7); in default_polling_getkey()
214 poll_result->read_count = (msg[0] & 0x7f); in default_polling_getkey()
217 switch (ir->rc_proto) { in default_polling_getkey()
219 poll_result->protocol = RC_PROTO_RC5; in default_polling_getkey()
220 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]); in default_polling_getkey()
224 poll_result->protocol = RC_PROTO_NEC; in default_polling_getkey()
225 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[2]); in default_polling_getkey()
229 poll_result->protocol = RC_PROTO_UNKNOWN; in default_polling_getkey()
230 poll_result->scancode = msg[1] << 8 | msg[2]; in default_polling_getkey()
240 struct em28xx *dev = ir->dev; in em2874_polling_getkey()
246 * on registers 0x51-55 in em2874_polling_getkey()
248 rc = dev->em28xx_read_reg_req_len(dev, 0, EM2874_R51_IR, in em2874_polling_getkey()
254 poll_result->toggle_bit = (msg[0] >> 7); in em2874_polling_getkey()
257 poll_result->read_count = (msg[0] & 0x7f); in em2874_polling_getkey()
261 * Remote Control Data (Reg 0x53-0x55) in em2874_polling_getkey()
263 switch (ir->rc_proto) { in em2874_polling_getkey()
265 poll_result->protocol = RC_PROTO_RC5; in em2874_polling_getkey()
266 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]); in em2874_polling_getkey()
270 poll_result->scancode = ir_nec_bytes_to_scancode(msg[1], msg[2], msg[3], msg[4], in em2874_polling_getkey()
271 &poll_result->protocol); in em2874_polling_getkey()
275 poll_result->protocol = RC_PROTO_RC6_0; in em2874_polling_getkey()
276 poll_result->scancode = RC_SCANCODE_RC6_0(msg[1], msg[2]); in em2874_polling_getkey()
280 poll_result->protocol = RC_PROTO_UNKNOWN; in em2874_polling_getkey()
281 poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) | in em2874_polling_getkey()
299 rc = ir->get_key_i2c(ir->i2c_client, &protocol, &scancode); in em28xx_i2c_ir_handle_key()
301 dprintk("ir->get_key_i2c() failed: %d\n", rc); in em28xx_i2c_ir_handle_key()
308 rc_keydown(ir->rc, protocol, scancode, 0); in em28xx_i2c_ir_handle_key()
319 result = ir->get_key(ir, &poll_result); in em28xx_ir_handle_key()
321 dprintk("ir->get_key() failed: %d\n", result); in em28xx_ir_handle_key()
325 if (unlikely(poll_result.read_count != ir->last_readcount)) { in em28xx_ir_handle_key()
329 if (ir->full_code) in em28xx_ir_handle_key()
330 rc_keydown(ir->rc, in em28xx_ir_handle_key()
335 rc_keydown(ir->rc, in em28xx_ir_handle_key()
340 if (ir->dev->chip_id == CHIP_ID_EM2874 || in em28xx_ir_handle_key()
341 ir->dev->chip_id == CHIP_ID_EM2884) in em28xx_ir_handle_key()
347 * non-zero read count as opposed to a readcount in em28xx_ir_handle_key()
350 ir->last_readcount = 0; in em28xx_ir_handle_key()
352 ir->last_readcount = poll_result.read_count; in em28xx_ir_handle_key()
360 if (ir->i2c_client) /* external i2c device */ in em28xx_ir_work()
364 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); in em28xx_ir_work()
369 struct em28xx_IR *ir = rc->priv; in em28xx_ir_start()
371 INIT_DELAYED_WORK(&ir->work, em28xx_ir_work); in em28xx_ir_start()
372 schedule_delayed_work(&ir->work, 0); in em28xx_ir_start()
379 struct em28xx_IR *ir = rc->priv; in em28xx_ir_stop()
381 cancel_delayed_work_sync(&ir->work); in em28xx_ir_stop()
386 struct em28xx_IR *ir = rc_dev->priv; in em2860_ir_change_protocol()
387 struct em28xx *dev = ir->dev; in em2860_ir_change_protocol()
391 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; in em2860_ir_change_protocol()
392 ir->full_code = 1; in em2860_ir_change_protocol()
395 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; in em2860_ir_change_protocol()
396 ir->full_code = 1; in em2860_ir_change_protocol()
401 *rc_proto = ir->rc_proto; in em2860_ir_change_protocol()
402 return -EINVAL; in em2860_ir_change_protocol()
404 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, in em2860_ir_change_protocol()
407 ir->rc_proto = *rc_proto; in em2860_ir_change_protocol()
414 struct em28xx_IR *ir = rc_dev->priv; in em2874_ir_change_protocol()
415 struct em28xx *dev = ir->dev; in em2874_ir_change_protocol()
420 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; in em2874_ir_change_protocol()
421 ir->full_code = 1; in em2874_ir_change_protocol()
424 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; in em2874_ir_change_protocol()
426 ir->full_code = 1; in em2874_ir_change_protocol()
429 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; in em2874_ir_change_protocol()
431 ir->full_code = 1; in em2874_ir_change_protocol()
436 *rc_proto = ir->rc_proto; in em2874_ir_change_protocol()
437 return -EINVAL; in em2874_ir_change_protocol()
440 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, in em2874_ir_change_protocol()
443 ir->rc_proto = *rc_proto; in em2874_ir_change_protocol()
450 struct em28xx_IR *ir = rc_dev->priv; in em28xx_ir_change_protocol()
451 struct em28xx *dev = ir->dev; in em28xx_ir_change_protocol()
454 switch (dev->chip_id) { in em28xx_ir_change_protocol()
464 dev_err(&ir->dev->intf->dev, in em28xx_ir_change_protocol()
466 dev->chip_id); in em28xx_ir_change_protocol()
467 return -EINVAL; in em28xx_ir_change_protocol()
475 * Leadtek winfast tv USBII deluxe can find a non working IR-device in em28xx_probe_i2c_ir()
484 if (i2c_probe_func_quick_read(&dev->i2c_adap[dev->def_i2c_bus], in em28xx_probe_i2c_ir()
490 return -ENODEV; in em28xx_probe_i2c_ir()
507 for (i = 0; i < dev->num_button_polling_addresses; i++) { in em28xx_query_buttons()
509 regval = em28xx_read_reg(dev, dev->button_polling_addresses[i]); in em28xx_query_buttons()
514 while (dev->board.buttons[j].role >= 0 && in em28xx_query_buttons()
515 dev->board.buttons[j].role < EM28XX_NUM_BUTTON_ROLES) { in em28xx_query_buttons()
516 const struct em28xx_button *button; in em28xx_query_buttons() local
518 button = &dev->board.buttons[j]; in em28xx_query_buttons()
520 /* Check if button uses the current address */ in em28xx_query_buttons()
521 if (button->reg_r != dev->button_polling_addresses[i]) { in em28xx_query_buttons()
525 /* Determine if button is and was pressed last time */ in em28xx_query_buttons()
526 is_pressed = regval & button->mask; in em28xx_query_buttons()
527 was_pressed = dev->button_polling_last_values[i] in em28xx_query_buttons()
528 & button->mask; in em28xx_query_buttons()
529 if (button->inverted) { in em28xx_query_buttons()
533 /* Clear button state (if needed) */ in em28xx_query_buttons()
534 if (is_pressed && button->reg_clearing) in em28xx_query_buttons()
535 em28xx_write_reg(dev, button->reg_clearing, in em28xx_query_buttons()
536 (~regval & button->mask) in em28xx_query_buttons()
537 | (regval & ~button->mask)); in em28xx_query_buttons()
538 /* Handle button state */ in em28xx_query_buttons()
543 switch (button->role) { in em28xx_query_buttons()
546 input_report_key(dev->sbutton_input_dev, in em28xx_query_buttons()
549 input_report_key(dev->sbutton_input_dev, in em28xx_query_buttons()
558 led->gpio_reg, in em28xx_query_buttons()
559 led->gpio_mask); in em28xx_query_buttons()
562 WARN_ONCE(1, "BUG: unhandled button role."); in em28xx_query_buttons()
564 /* Next button */ in em28xx_query_buttons()
568 dev->button_polling_last_values[i] = regval; in em28xx_query_buttons()
571 schedule_delayed_work(&dev->buttons_query_work, in em28xx_query_buttons()
572 msecs_to_jiffies(dev->button_polling_interval)); in em28xx_query_buttons()
577 struct usb_device *udev = interface_to_usbdev(dev->intf); in em28xx_register_snapshot_button()
581 dev_info(&dev->intf->dev, "Registering snapshot button...\n"); in em28xx_register_snapshot_button()
584 return -ENOMEM; in em28xx_register_snapshot_button()
586 usb_make_path(udev, dev->snapshot_button_path, in em28xx_register_snapshot_button()
587 sizeof(dev->snapshot_button_path)); in em28xx_register_snapshot_button()
588 strlcat(dev->snapshot_button_path, "/sbutton", in em28xx_register_snapshot_button()
589 sizeof(dev->snapshot_button_path)); in em28xx_register_snapshot_button()
591 input_dev->name = "em28xx snapshot button"; in em28xx_register_snapshot_button()
592 input_dev->phys = dev->snapshot_button_path; in em28xx_register_snapshot_button()
593 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); in em28xx_register_snapshot_button()
594 set_bit(EM28XX_SNAPSHOT_KEY, input_dev->keybit); in em28xx_register_snapshot_button()
595 input_dev->keycodesize = 0; in em28xx_register_snapshot_button()
596 input_dev->keycodemax = 0; in em28xx_register_snapshot_button()
597 usb_to_input_id(udev, &input_dev->id); in em28xx_register_snapshot_button()
598 input_dev->dev.parent = &dev->intf->dev; in em28xx_register_snapshot_button()
602 dev_err(&dev->intf->dev, "input_register_device failed\n"); in em28xx_register_snapshot_button()
607 dev->sbutton_input_dev = input_dev; in em28xx_register_snapshot_button()
616 dev->button_polling_interval = EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL; in em28xx_init_buttons()
617 while (dev->board.buttons[i].role >= 0 && in em28xx_init_buttons()
618 dev->board.buttons[i].role < EM28XX_NUM_BUTTON_ROLES) { in em28xx_init_buttons()
619 const struct em28xx_button *button = &dev->board.buttons[i]; in em28xx_init_buttons() local
623 for (j = 0; j < dev->num_button_polling_addresses; j++) { in em28xx_init_buttons()
624 if (button->reg_r == dev->button_polling_addresses[j]) { in em28xx_init_buttons()
630 if (addr_new && dev->num_button_polling_addresses in em28xx_init_buttons()
632 WARN_ONCE(1, "BUG: maximum number of button polling addresses exceeded."); in em28xx_init_buttons()
635 /* Button role specific checks and actions */ in em28xx_init_buttons()
636 if (button->role == EM28XX_BUTTON_SNAPSHOT) { in em28xx_init_buttons()
640 } else if (button->role == EM28XX_BUTTON_ILLUMINATION) { in em28xx_init_buttons()
643 dev_err(&dev->intf->dev, in em28xx_init_buttons()
644 "BUG: illumination button defined, but no illumination LED.\n"); in em28xx_init_buttons()
650 unsigned int index = dev->num_button_polling_addresses; in em28xx_init_buttons()
652 dev->button_polling_addresses[index] = button->reg_r; in em28xx_init_buttons()
653 dev->num_button_polling_addresses++; in em28xx_init_buttons()
656 if (!button->reg_clearing) in em28xx_init_buttons()
657 dev->button_polling_interval = in em28xx_init_buttons()
660 /* Next button */ in em28xx_init_buttons()
665 if (dev->num_button_polling_addresses) { in em28xx_init_buttons()
666 memset(dev->button_polling_last_values, 0, in em28xx_init_buttons()
668 schedule_delayed_work(&dev->buttons_query_work, in em28xx_init_buttons()
669 msecs_to_jiffies(dev->button_polling_interval)); in em28xx_init_buttons()
676 cancel_delayed_work_sync(&dev->buttons_query_work); in em28xx_shutdown_buttons()
678 dev->num_button_polling_addresses = 0; in em28xx_shutdown_buttons()
680 if (dev->sbutton_input_dev) { in em28xx_shutdown_buttons()
681 dev_info(&dev->intf->dev, "Deregistering snapshot button\n"); in em28xx_shutdown_buttons()
682 input_unregister_device(dev->sbutton_input_dev); in em28xx_shutdown_buttons()
683 dev->sbutton_input_dev = NULL; in em28xx_shutdown_buttons()
689 struct usb_device *udev = interface_to_usbdev(dev->intf); in em28xx_ir_init()
692 int err = -ENOMEM; in em28xx_ir_init()
696 if (dev->is_audio_only) { in em28xx_ir_init()
701 kref_get(&dev->ref); in em28xx_ir_init()
702 INIT_DELAYED_WORK(&dev->buttons_query_work, em28xx_query_buttons); in em28xx_ir_init()
704 if (dev->board.buttons) in em28xx_ir_init()
707 if (dev->board.has_ir_i2c) { in em28xx_ir_init()
710 dev->board.has_ir_i2c = 0; in em28xx_ir_init()
711 dev_warn(&dev->intf->dev, in em28xx_ir_init()
713 err = -ENODEV; in em28xx_ir_init()
718 if (!dev->board.ir_codes && !dev->board.has_ir_i2c) { in em28xx_ir_init()
720 dev_warn(&dev->intf->dev, in em28xx_ir_init()
725 dev_info(&dev->intf->dev, "Registering input extension\n"); in em28xx_ir_init()
735 ir->dev = dev; in em28xx_ir_init()
736 dev->ir = ir; in em28xx_ir_init()
737 ir->rc = rc; in em28xx_ir_init()
739 rc->priv = ir; in em28xx_ir_init()
740 rc->open = em28xx_ir_start; in em28xx_ir_init()
741 rc->close = em28xx_ir_stop; in em28xx_ir_init()
743 if (dev->board.has_ir_i2c) { /* external i2c device */ in em28xx_ir_init()
744 switch (dev->model) { in em28xx_ir_init()
747 rc->map_name = RC_MAP_EM_TERRATEC; in em28xx_ir_init()
748 ir->get_key_i2c = em28xx_get_key_terratec; in em28xx_ir_init()
751 rc->map_name = RC_MAP_PINNACLE_GREY; in em28xx_ir_init()
752 ir->get_key_i2c = em28xx_get_key_pinnacle_usb_grey; in em28xx_ir_init()
755 rc->map_name = RC_MAP_HAUPPAUGE; in em28xx_ir_init()
756 ir->get_key_i2c = em28xx_get_key_em_haup; in em28xx_ir_init()
757 rc->allowed_protocols = RC_PROTO_BIT_RC5; in em28xx_ir_init()
760 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE; in em28xx_ir_init()
761 ir->get_key_i2c = em28xx_get_key_winfast_usbii_deluxe; in em28xx_ir_init()
764 err = -ENODEV; in em28xx_ir_init()
768 ir->i2c_client = kzalloc(sizeof(*ir->i2c_client), GFP_KERNEL); in em28xx_ir_init()
769 if (!ir->i2c_client) in em28xx_ir_init()
771 ir->i2c_client->adapter = &ir->dev->i2c_adap[dev->def_i2c_bus]; in em28xx_ir_init()
772 ir->i2c_client->addr = i2c_rc_dev_addr; in em28xx_ir_init()
773 ir->i2c_client->flags = 0; in em28xx_ir_init()
776 switch (dev->chip_id) { in em28xx_ir_init()
779 rc->allowed_protocols = RC_PROTO_BIT_RC5 | in em28xx_ir_init()
781 ir->get_key = default_polling_getkey; in em28xx_ir_init()
787 ir->get_key = em2874_polling_getkey; in em28xx_ir_init()
788 rc->allowed_protocols = RC_PROTO_BIT_RC5 | in em28xx_ir_init()
793 err = -ENODEV; in em28xx_ir_init()
797 rc->change_protocol = em28xx_ir_change_protocol; in em28xx_ir_init()
798 rc->map_name = dev->board.ir_codes; in em28xx_ir_init()
808 ir->polling = 100; /* ms */ in em28xx_ir_init()
810 usb_make_path(udev, ir->phys, sizeof(ir->phys)); in em28xx_ir_init()
811 strlcat(ir->phys, "/input0", sizeof(ir->phys)); in em28xx_ir_init()
813 rc->device_name = em28xx_boards[dev->model].name; in em28xx_ir_init()
814 rc->input_phys = ir->phys; in em28xx_ir_init()
815 usb_to_input_id(udev, &rc->input_id); in em28xx_ir_init()
816 rc->dev.parent = &dev->intf->dev; in em28xx_ir_init()
817 rc->driver_name = MODULE_NAME; in em28xx_ir_init()
824 dev_info(&dev->intf->dev, "Input extension successfully initialized\n"); in em28xx_ir_init()
829 kfree(ir->i2c_client); in em28xx_ir_init()
830 dev->ir = NULL; in em28xx_ir_init()
840 struct em28xx_IR *ir = dev->ir; in em28xx_ir_fini()
842 if (dev->is_audio_only) { in em28xx_ir_fini()
847 dev_info(&dev->intf->dev, "Closing input extension\n"); in em28xx_ir_fini()
855 rc_unregister_device(ir->rc); in em28xx_ir_fini()
857 kfree(ir->i2c_client); in em28xx_ir_fini()
861 dev->ir = NULL; in em28xx_ir_fini()
864 kref_put(&dev->ref, em28xx_free_device); in em28xx_ir_fini()
871 struct em28xx_IR *ir = dev->ir; in em28xx_ir_suspend()
873 if (dev->is_audio_only) in em28xx_ir_suspend()
876 dev_info(&dev->intf->dev, "Suspending input extension\n"); in em28xx_ir_suspend()
878 cancel_delayed_work_sync(&ir->work); in em28xx_ir_suspend()
879 cancel_delayed_work_sync(&dev->buttons_query_work); in em28xx_ir_suspend()
890 struct em28xx_IR *ir = dev->ir; in em28xx_ir_resume()
892 if (dev->is_audio_only) in em28xx_ir_resume()
895 dev_info(&dev->intf->dev, "Resuming input extension\n"); in em28xx_ir_resume()
901 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); in em28xx_ir_resume()
902 if (dev->num_button_polling_addresses) in em28xx_ir_resume()
903 schedule_delayed_work(&dev->buttons_query_work, in em28xx_ir_resume()
904 msecs_to_jiffies(dev->button_polling_interval)); in em28xx_ir_resume()
929 MODULE_DESCRIPTION(DRIVER_DESC " - input interface");