Lines Matching +full:i2c +full:- +full:polling

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 #include "saa7134-reg.h"
36 printk(KERN_DEBUG pr_fmt("ir %s: " fmt), ir->rc->device_name, \
43 /* -------------------- GPIO generic keycode builder -------------------- */
47 struct saa7134_card_ir *ir = dev->remote; in build_key()
51 switch (dev->board) { in build_key()
62 if (ir->polling) { in build_key()
63 if (ir->last_gpio == gpio) in build_key()
65 ir->last_gpio = gpio; in build_key()
68 data = ir_extract_bits(gpio, ir->mask_keycode); in build_key()
70 gpio, ir->mask_keycode, data); in build_key()
72 switch (dev->board) { in build_key()
74 if (data == ir->mask_keycode) in build_key()
75 rc_keyup(ir->dev); in build_key()
77 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, in build_key()
82 if (ir->polling) { in build_key()
83 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || in build_key()
84 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { in build_key()
85 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, in build_key()
88 rc_keyup(ir->dev); in build_key()
91 else { /* IRQ driven mode - handle key press and release in one go */ in build_key()
92 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || in build_key()
93 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { in build_key()
94 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, in build_key()
96 rc_keyup(ir->dev); in build_key()
103 /* --------------------- Chip specific I2C key builders ----------------- */
113 struct saa7134_dev *dev = ir->c->adapter->algo_data; in get_key_flydvb_trio()
116 ir_dbg(ir, "get_key_flydvb_trio: ir->c->adapter->algo_data is NULL!\n"); in get_key_flydvb_trio()
117 return -EIO; in get_key_flydvb_trio()
133 while (1 != i2c_master_send(ir->c, &b, 1)) { in get_key_flydvb_trio()
136 * wait a bit for next attempt - in get_key_flydvb_trio()
144 return -EIO; in get_key_flydvb_trio()
146 rc = i2c_master_recv(ir->c, &b, 1); in get_key_flydvb_trio()
151 return -EIO; in get_key_flydvb_trio()
168 struct saa7134_dev *dev = ir->c->adapter->algo_data; in get_key_msi_tvanywhere_plus()
170 ir_dbg(ir, "get_key_msi_tvanywhere_plus: ir->c->adapter->algo_data is NULL!\n"); in get_key_msi_tvanywhere_plus()
171 return -EIO; in get_key_msi_tvanywhere_plus()
182 I2C receive if gpio&0x40 is not low. */ in get_key_msi_tvanywhere_plus()
189 rc = i2c_master_recv(ir->c, &b, 1); in get_key_msi_tvanywhere_plus()
194 return -EIO; in get_key_msi_tvanywhere_plus()
220 struct saa7134_dev *dev = ir->c->adapter->algo_data; in get_key_kworld_pc150u()
222 ir_dbg(ir, "get_key_kworld_pc150u: ir->c->adapter->algo_data is NULL!\n"); in get_key_kworld_pc150u()
223 return -EIO; in get_key_kworld_pc150u()
234 I2C receive if gpio&0x100 is not low. */ in get_key_kworld_pc150u()
241 rc = i2c_master_recv(ir->c, &b, 1); in get_key_kworld_pc150u()
246 return -EIO; in get_key_kworld_pc150u()
270 rc = i2c_master_recv(ir->c, &b, 1); in get_key_purpletv()
275 return -EIO; in get_key_purpletv()
299 struct saa7134_dev *dev = ir->c->adapter->algo_data; in get_key_beholdm6xx()
310 ir->c->addr = 0x5a >> 1; in get_key_beholdm6xx()
312 rc = i2c_master_recv(ir->c, data, 12); in get_key_beholdm6xx()
317 return -EIO; in get_key_beholdm6xx()
341 rc = i2c_master_recv(ir->c, b, 4); in get_key_pinnacle()
346 return -EIO; in get_key_pinnacle()
361 if (ir->old == parity) in get_key_pinnacle()
364 ir->old = parity; in get_key_pinnacle()
384 * - I2c packet does not change when the same key is pressed quickly. The workaround
386 * in the i2c packet, and the function can distinguish key presses.
418 if (!dev || !dev->remote) in saa7134_input_irq()
421 ir = dev->remote; in saa7134_input_irq()
422 if (!ir->running) in saa7134_input_irq()
425 if (!ir->polling && !ir->raw_decode) { in saa7134_input_irq()
427 } else if (ir->raw_decode) { in saa7134_input_irq()
435 struct saa7134_dev *dev = ir->dev->priv; in saa7134_input_timer()
438 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); in saa7134_input_timer()
443 struct saa7134_dev *dev = rc->priv; in saa7134_ir_open()
444 struct saa7134_card_ir *ir = dev->remote; in saa7134_ir_open()
448 switch (dev->board) { in saa7134_ir_open()
482 ir->running = true; in saa7134_ir_open()
484 if (ir->polling) { in saa7134_ir_open()
485 timer_setup(&ir->timer, saa7134_input_timer, 0); in saa7134_ir_open()
486 ir->timer.expires = jiffies + HZ; in saa7134_ir_open()
487 add_timer(&ir->timer); in saa7134_ir_open()
495 struct saa7134_dev *dev = rc->priv; in saa7134_ir_close()
496 struct saa7134_card_ir *ir = dev->remote; in saa7134_ir_close()
498 if (ir->polling) in saa7134_ir_close()
499 del_timer_sync(&ir->timer); in saa7134_ir_close()
501 ir->running = false; in saa7134_ir_close()
512 unsigned polling = 0; in saa7134_input_init1() local
516 if (dev->has_remote != SAA7134_REMOTE_GPIO) in saa7134_input_init1()
517 return -ENODEV; in saa7134_input_init1()
519 return -ENODEV; in saa7134_input_init1()
522 switch (dev->board) { in saa7134_input_init1()
544 polling = 50; // ms in saa7134_input_init1()
551 polling = 50; // ms in saa7134_input_init1()
569 polling = 50; // ms in saa7134_input_init1()
591 polling = 50; // ms in saa7134_input_init1()
598 polling = 50; /* ms */ in saa7134_input_init1()
605 polling = 50; // ms in saa7134_input_init1()
612 polling = 50; /* ms */ in saa7134_input_init1()
632 polling = 50; /* ms */ in saa7134_input_init1()
638 polling = 50; // ms in saa7134_input_init1()
644 polling = 50; // ms in saa7134_input_init1()
650 polling = 5; /* ms */ in saa7134_input_init1()
659 polling = 50; // ms in saa7134_input_init1()
665 polling = 50; // ms in saa7134_input_init1()
701 polling = 50; // ms in saa7134_input_init1()
715 polling = 50; //ms in saa7134_input_init1()
721 polling = 50; /* ms */ in saa7134_input_init1()
727 polling = 50; /* ms */ in saa7134_input_init1()
732 polling = 40; /* ms */ in saa7134_input_init1()
743 polling = 50; /* ms */ in saa7134_input_init1()
767 pr_err("Oops: IR config error [card=%d]\n", dev->board); in saa7134_input_init1()
768 return -ENODEV; in saa7134_input_init1()
774 err = -ENOMEM; in saa7134_input_init1()
778 ir->dev = rc; in saa7134_input_init1()
779 dev->remote = ir; in saa7134_input_init1()
781 /* init hardware-specific stuff */ in saa7134_input_init1()
782 ir->mask_keycode = mask_keycode; in saa7134_input_init1()
783 ir->mask_keydown = mask_keydown; in saa7134_input_init1()
784 ir->mask_keyup = mask_keyup; in saa7134_input_init1()
785 ir->polling = polling; in saa7134_input_init1()
786 ir->raw_decode = raw_decode; in saa7134_input_init1()
789 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", in saa7134_input_init1()
790 pci_name(dev->pci)); in saa7134_input_init1()
792 rc->priv = dev; in saa7134_input_init1()
793 rc->open = saa7134_ir_open; in saa7134_input_init1()
794 rc->close = saa7134_ir_close; in saa7134_input_init1()
796 rc->driver_type = RC_DRIVER_IR_RAW; in saa7134_input_init1()
797 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in saa7134_input_init1()
800 rc->device_name = saa7134_boards[dev->board].name; in saa7134_input_init1()
801 rc->input_phys = ir->phys; in saa7134_input_init1()
802 rc->input_id.bustype = BUS_PCI; in saa7134_input_init1()
803 rc->input_id.version = 1; in saa7134_input_init1()
804 if (dev->pci->subsystem_vendor) { in saa7134_input_init1()
805 rc->input_id.vendor = dev->pci->subsystem_vendor; in saa7134_input_init1()
806 rc->input_id.product = dev->pci->subsystem_device; in saa7134_input_init1()
808 rc->input_id.vendor = dev->pci->vendor; in saa7134_input_init1()
809 rc->input_id.product = dev->pci->device; in saa7134_input_init1()
811 rc->dev.parent = &dev->pci->dev; in saa7134_input_init1()
812 rc->map_name = ir_codes; in saa7134_input_init1()
813 rc->driver_name = MODULE_NAME; in saa7134_input_init1()
814 rc->min_timeout = 1; in saa7134_input_init1()
815 rc->timeout = IR_DEFAULT_TIMEOUT; in saa7134_input_init1()
816 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; in saa7134_input_init1()
826 dev->remote = NULL; in saa7134_input_init1()
833 if (NULL == dev->remote) in saa7134_input_fini()
836 rc_unregister_device(dev->remote->dev); in saa7134_input_fini()
837 kfree(dev->remote); in saa7134_input_fini()
838 dev->remote = NULL; in saa7134_input_fini()
853 input_dbg("IR has been disabled, not probing for i2c remote\n"); in saa7134_probe_i2c_ir()
858 memset(&dev->init_data, 0, sizeof(dev->init_data)); in saa7134_probe_i2c_ir()
861 switch (dev->board) { in saa7134_probe_i2c_ir()
864 dev->init_data.name = "Pinnacle PCTV"; in saa7134_probe_i2c_ir()
866 dev->init_data.get_key = get_key_pinnacle_color; in saa7134_probe_i2c_ir()
867 dev->init_data.ir_codes = RC_MAP_PINNACLE_COLOR; in saa7134_probe_i2c_ir()
870 dev->init_data.get_key = get_key_pinnacle_grey; in saa7134_probe_i2c_ir()
871 dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY; in saa7134_probe_i2c_ir()
876 dev->init_data.name = "Purple TV"; in saa7134_probe_i2c_ir()
877 dev->init_data.get_key = get_key_purpletv; in saa7134_probe_i2c_ir()
878 dev->init_data.ir_codes = RC_MAP_PURPLETV; in saa7134_probe_i2c_ir()
882 dev->init_data.name = "MSI TV@nywhere Plus"; in saa7134_probe_i2c_ir()
883 dev->init_data.get_key = get_key_msi_tvanywhere_plus; in saa7134_probe_i2c_ir()
884 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS; in saa7134_probe_i2c_ir()
886 * MSI TV@nyware Plus requires more frequent polling in saa7134_probe_i2c_ir()
889 dev->init_data.polling_interval = 50; in saa7134_probe_i2c_ir()
895 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1); in saa7134_probe_i2c_ir()
897 msg_msi.addr, dev->i2c_adap.name, in saa7134_probe_i2c_ir()
901 dev->init_data.name = "SnaZio* TVPVR PRO"; in saa7134_probe_i2c_ir()
902 dev->init_data.get_key = get_key_msi_tvanywhere_plus; in saa7134_probe_i2c_ir()
903 dev->init_data.ir_codes = RC_MAP_MSI_TVANYWHERE_PLUS; in saa7134_probe_i2c_ir()
905 * MSI TV@nyware Plus requires more frequent polling in saa7134_probe_i2c_ir()
908 dev->init_data.polling_interval = 50; in saa7134_probe_i2c_ir()
916 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1); in saa7134_probe_i2c_ir()
918 msg_msi.addr, dev->i2c_adap.name, in saa7134_probe_i2c_ir()
923 dev->init_data.name = "Kworld PC150-U"; in saa7134_probe_i2c_ir()
924 dev->init_data.get_key = get_key_kworld_pc150u; in saa7134_probe_i2c_ir()
925 dev->init_data.ir_codes = RC_MAP_KWORLD_PC150U; in saa7134_probe_i2c_ir()
931 rc = i2c_transfer(&dev->i2c_adap, &msg_msi, 1); in saa7134_probe_i2c_ir()
933 msg_msi.addr, dev->i2c_adap.name, in saa7134_probe_i2c_ir()
937 dev->init_data.name = saa7134_boards[dev->board].name; in saa7134_probe_i2c_ir()
938 dev->init_data.ir_codes = RC_MAP_HAUPPAUGE; in saa7134_probe_i2c_ir()
939 dev->init_data.type = RC_PROTO_BIT_RC5 | in saa7134_probe_i2c_ir()
941 dev->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; in saa7134_probe_i2c_ir()
959 dev->init_data.name = "BeholdTV"; in saa7134_probe_i2c_ir()
960 dev->init_data.get_key = get_key_beholdm6xx; in saa7134_probe_i2c_ir()
961 dev->init_data.ir_codes = RC_MAP_BEHOLD; in saa7134_probe_i2c_ir()
962 dev->init_data.type = RC_PROTO_BIT_NECX; in saa7134_probe_i2c_ir()
973 dev->init_data.name = "FlyDVB Trio"; in saa7134_probe_i2c_ir()
974 dev->init_data.get_key = get_key_flydvb_trio; in saa7134_probe_i2c_ir()
975 dev->init_data.ir_codes = RC_MAP_FLYDVB; in saa7134_probe_i2c_ir()
979 input_dbg("No I2C IR support for board %x\n", dev->board); in saa7134_probe_i2c_ir()
983 if (dev->init_data.name) in saa7134_probe_i2c_ir()
984 info.platform_data = &dev->init_data; in saa7134_probe_i2c_ir()
985 i2c_new_client_device(&dev->i2c_adap, &info); in saa7134_probe_i2c_ir()
990 struct saa7134_card_ir *ir = dev->remote; in saa7134_raw_decode_irq()
996 space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; in saa7134_raw_decode_irq()
997 ir_raw_event_store_edge(dev->remote->dev, !space); in saa7134_raw_decode_irq()